Commit 61d5cc0f authored by Peter's avatar Peter
Browse files

Merge branch 'master' into applecl

parents e2999354 afae4bc8
...@@ -138,6 +138,18 @@ public: ...@@ -138,6 +138,18 @@ public:
void setSoluteDielectric(double dielectric) { void setSoluteDielectric(double dielectric) {
soluteDielectric = dielectric; soluteDielectric = dielectric;
} }
/**
* Get the energy scale for the surface energy term, measured in kJ/mol/nm^2.
*/
double getSurfaceAreaEnergy() const {
return surfaceAreaEnergy;
}
/**
* Set the energy scale for the surface energy term, measured in kJ/mol/nm^2.
*/
void setSurfaceAreaEnergy(double energy) {
surfaceAreaEnergy = energy;
}
/** /**
* Get the method used for handling long range nonbonded interactions. * Get the method used for handling long range nonbonded interactions.
*/ */
...@@ -164,7 +176,7 @@ public: ...@@ -164,7 +176,7 @@ public:
* Update the particle parameters in a Context to match those stored in this Force object. This method * Update the particle parameters in a Context to match those stored in this Force object. This method
* provides an efficient method to update certain parameters in an existing Context without needing to * provides an efficient method to update certain parameters in an existing Context without needing to
* reinitialize it. Simply call setParticleParameters() to modify this object's parameters, then call * reinitialize it. Simply call setParticleParameters() to modify this object's parameters, then call
* updateParametersInState() to copy them over to the Context. * updateParametersInContext() to copy them over to the Context.
* *
* The only information this method updates is the values of per-particle parameters. All other aspects * The only information this method updates is the values of per-particle parameters. All other aspects
* of the Force (the nonbonded method, the cutoff distance, etc.) are unaffected and can only be changed * of the Force (the nonbonded method, the cutoff distance, etc.) are unaffected and can only be changed
...@@ -172,12 +184,21 @@ public: ...@@ -172,12 +184,21 @@ public:
* change the parameters of existing ones. * change the parameters of existing ones.
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == GBSAOBCForce::CutoffPeriodic;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
class ParticleInfo; class ParticleInfo;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
double cutoffDistance, solventDielectric, soluteDielectric; double cutoffDistance, solventDielectric, soluteDielectric, surfaceAreaEnergy;
std::vector<ParticleInfo> particles; std::vector<ParticleInfo> particles;
}; };
......
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
* *
* @return number of bonds * @return number of bonds
*/ */
int getNumBonds( void ) const; int getNumBonds() const;
/** /**
* Get the dielectric constant for the solvent. * Get the dielectric constant for the solvent.
...@@ -208,7 +208,7 @@ public: ...@@ -208,7 +208,7 @@ public:
/** /**
* Get Born radius scaling method * Get Born radius scaling method
*/ */
BornRadiusScalingMethod getBornRadiusScalingMethod( void ) const; BornRadiusScalingMethod getBornRadiusScalingMethod() const;
/** /**
* Set Born radius scaling method * Set Born radius scaling method
*/ */
...@@ -216,7 +216,7 @@ public: ...@@ -216,7 +216,7 @@ public:
/** /**
* Get the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8) * Get the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8)
*/ */
double getQuinticLowerLimitFactor( void ) const; double getQuinticLowerLimitFactor() const;
/** /**
* Set the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8) * Set the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8)
*/ */
...@@ -224,11 +224,20 @@ public: ...@@ -224,11 +224,20 @@ public:
/** /**
* Get the upper limit used in the quintic spline scaling method, measured in nm (~5.0) * Get the upper limit used in the quintic spline scaling method, measured in nm (~5.0)
*/ */
double getQuinticUpperBornRadiusLimit( void ) const; double getQuinticUpperBornRadiusLimit() const;
/** /**
* Set the upper limit used in the quintic spline scaling method, measured in nm (~5.0) * Set the upper limit used in the quintic spline scaling method, measured in nm (~5.0)
*/ */
void setQuinticUpperBornRadiusLimit(double quinticUpperBornRadiusLimit); void setQuinticUpperBornRadiusLimit(double quinticUpperBornRadiusLimit);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == GBVIForce::CutoffPeriodic;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
...@@ -95,13 +95,22 @@ public: ...@@ -95,13 +95,22 @@ public:
/** /**
* Update the per-angle parameters in a Context to match those stored in this Force object. This method provides * Update the per-angle parameters in a Context to match those stored in this Force object. This method provides
* an efficient method to update certain parameters in an existing Context without needing to reinitialize it. * an efficient method to update certain parameters in an existing Context without needing to reinitialize it.
* Simply call setAngleParameters() to modify this object's parameters, then call updateParametersInState() * Simply call setAngleParameters() to modify this object's parameters, then call updateParametersInContext()
* to copy them over to the Context. * to copy them over to the Context.
* *
* The only information this method updates is the values of per-angle parameters. The set of particles involved * The only information this method updates is the values of per-angle parameters. The set of particles involved
* in a angle cannot be changed, nor can new angles be added. * in a angle cannot be changed, nor can new angles be added.
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return false;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
...@@ -92,13 +92,22 @@ public: ...@@ -92,13 +92,22 @@ public:
/** /**
* Update the per-bond parameters in a Context to match those stored in this Force object. This method provides * Update the per-bond parameters in a Context to match those stored in this Force object. This method provides
* an efficient method to update certain parameters in an existing Context without needing to reinitialize it. * an efficient method to update certain parameters in an existing Context without needing to reinitialize it.
* Simply call setBondParameters() to modify this object's parameters, then call updateParametersInState() * Simply call setBondParameters() to modify this object's parameters, then call updateParametersInContext()
* to copy them over to the Context. * to copy them over to the Context.
* *
* The only information this method updates is the values of per-bond parameters. The set of particles involved * The only information this method updates is the values of per-bond parameters. The set of particles involved
* in a bond cannot be changed, nor can new bonds be added. * in a bond cannot be changed, nor can new bonds be added.
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return false;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
* *
* @param temperature the temperature of the heat bath (in Kelvin) * @param temperature the temperature of the heat bath (in Kelvin)
* @param frictionCoeff the friction coefficient which couples the system to the heat bath (in inverse picoseconds) * @param frictionCoeff the friction coefficient which couples the system to the heat bath (in inverse picoseconds)
* @param stepSize the step size with which to integrator the system (in picoseconds) * @param stepSize the step size with which to integrate the system (in picoseconds)
*/ */
LangevinIntegrator(double temperature, double frictionCoeff, double stepSize); LangevinIntegrator(double temperature, double frictionCoeff, double stepSize);
/** /**
...@@ -99,6 +99,10 @@ public: ...@@ -99,6 +99,10 @@ public:
* the other hand, no guarantees are made about the behavior of simulations that use the same seed. * the other hand, no guarantees are made about the behavior of simulations that use the same seed.
* In particular, Platforms are permitted to use non-deterministic algorithms which produce different * In particular, Platforms are permitted to use non-deterministic algorithms which produce different
* results on successive runs, even if those runs were initialized identically. * results on successive runs, even if those runs were initialized identically.
*
* If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context
* is created from this Force. This is done to ensure that each Context receives unique random seeds
* without you needing to set them explicitly.
*/ */
void setRandomNumberSeed(int seed) { void setRandomNumberSeed(int seed) {
randomNumberSeed = seed; randomNumberSeed = seed;
......
...@@ -167,10 +167,23 @@ public: ...@@ -167,10 +167,23 @@ public:
* the other hand, no guarantees are made about the behavior of simulations that use the same seed. * the other hand, no guarantees are made about the behavior of simulations that use the same seed.
* In particular, Platforms are permitted to use non-deterministic algorithms which produce different * In particular, Platforms are permitted to use non-deterministic algorithms which produce different
* results on successive runs, even if those runs were initialized identically. * results on successive runs, even if those runs were initialized identically.
*
* If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context
* is created from this Force. This is done to ensure that each Context receives unique random seeds
* without you needing to set them explicitly.
*/ */
void setRandomNumberSeed(int seed) { void setRandomNumberSeed(int seed) {
randomNumberSeed = seed; randomNumberSeed = seed;
} }
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return true;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
...@@ -123,10 +123,23 @@ public: ...@@ -123,10 +123,23 @@ public:
* the other hand, no guarantees are made about the behavior of simulations that use the same seed. * the other hand, no guarantees are made about the behavior of simulations that use the same seed.
* In particular, Platforms are permitted to use non-deterministic algorithms which produce different * In particular, Platforms are permitted to use non-deterministic algorithms which produce different
* results on successive runs, even if those runs were initialized identically. * results on successive runs, even if those runs were initialized identically.
*
* If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context
* is created from this Force. This is done to ensure that each Context receives unique random seeds
* without you needing to set them explicitly.
*/ */
void setRandomNumberSeed(int seed) { void setRandomNumberSeed(int seed) {
randomNumberSeed = seed; randomNumberSeed = seed;
} }
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return true;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
#ifndef OPENMM_MONTECARLOMEMBRANEBAROSTAT_H_
#define OPENMM_MONTECARLOMEMBRANEBAROSTAT_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "Force.h"
#include <string>
#include "internal/windowsExport.h"
namespace OpenMM {
/**
* This is a Monte Carlo barostat designed specifically for membrane simulations. It assumes the
* membrane lies in the XY plane. The Monte Carlo acceptance criterion includes a term to model
* isotropic pressure, which depends on the volume of the periodic box, and a second term to model
* surface tension, which depends on the cross sectional area of the box in the XY plane. Note
* that pressure and surface tension are defined with opposite senses: a larger pressure tends to
* make the box smaller, but a larger surface tension tends to make the box larger.
*
* There are options for configuring exactly how the various box dimensions are allowed to change:
*
* <ul>
* <li>The X and Y axes may be treated isotropically, in which case they always scale by the same
* amount and remain in proportion to each other; or they may be treated anisotropically, in which
* case they can vary independently of each other.</li>
* <li>The Z axis can be allowed to vary independently of the other axes; or held fixed; or constrained
* to vary in inverse proportion to the other two axes, so that the total box volume remains fixed.</li>
* </ul>
*
* This class assumes the simulation is also being run at constant temperature, and requires you
* to specify the system temperature (since it affects the acceptance probability for Monte Carlo
* moves). It does not actually perform temperature regulation, however. You must use another
* mechanism along with it to maintain the temperature, such as LangevinIntegrator or AndersenThermostat.
*/
class OPENMM_EXPORT MonteCarloMembraneBarostat : public Force {
public:
/**
* This is an enumeration of the different behaviors for the X and Y axes.
*/
enum XYMode {
/**
* The X and Y axes are always scaled by the same amount, so the ratio of their lengths remains constant.
*/
XYIsotropic = 0,
/**
* The X and Y axes are allowed to vary independently of each other.
*/
XYAnisotropic = 1
};
/**
* This is an enumeration of the different behaviors for Z axis.
*/
enum ZMode {
/**
* The Z axis is allowed to vary freely, independent of the other two axes.
*/
ZFree = 0,
/**
* The Z axis is held fixed and does not change.
*/
ZFixed = 1,
/**
* The Z axis is always scaled in inverse proportion to the other two axes so the box volume remains
* fixed. Note that in this mode pressure has no effect on the system, only surface tension.
*/
ConstantVolume = 2
};
/**
* This is the name of the parameter which stores the current pressure acting on
* the system (in bar).
*/
static const std::string& Pressure() {
static const std::string key = "MembraneMonteCarloPressure";
return key;
}
/**
* This is the name of the parameter which stores the current surface tension acting on
* the system (in bar*nm).
*/
static const std::string& SurfaceTension() {
static const std::string key = "MembraneMonteCarloSurfaceTension";
return key;
}
/**
* Create a MonteCarloMembraneBarostat.
*
* @param defaultPressure the default pressure acting on the system (in bar)
* @param defaultSurfaceTension the default surface tension acting on the system (in bar*nm)
* @param temperature the temperature at which the system is being maintained (in Kelvin)
* @param xymode the mode specifying the behavior of the X and Y axes
* @param zmode the mode specifying the behavior of the Z axis
* @param frequency the frequency at which Monte Carlo volume changes should be attempted (in time steps)
*/
MonteCarloMembraneBarostat(double defaultPressure, double defaultSurfaceTension, double temperature, XYMode xymode, ZMode zmode, int frequency = 25);
/**
* Get the default pressure acting on the system (in bar).
*
* @return the default pressure acting on the system, measured in bar.
*/
double getDefaultPressure() const {
return defaultPressure;
}
/**
* Set the default pressure acting on the system. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param pressure the default pressure acting on the system, measured in bar.
*/
void setDefaultPressure(double pressure) {
defaultPressure = pressure;
}
/**
* Get the default surface tension acting on the system (in bar*nm).
*
* @return the default surface tension acting on the system, measured in bar*nm.
*/
double getDefaultSurfaceTension() const {
return defaultSurfaceTension;
}
/**
* Set the default surface tension acting on the system. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param surfaceTension the default surface tension acting on the system, measured in bar.
*/
void setDefaultSurfaceTension(double surfaceTension) {
defaultSurfaceTension = surfaceTension;
}
/**
* Get the frequency (in time steps) at which Monte Carlo volume changes should be attempted. If this is set to
* 0, the barostat is disabled.
*/
int getFrequency() const {
return frequency;
}
/**
* Set the frequency (in time steps) at which Monte Carlo volume changes should be attempted. If this is set to
* 0, the barostat is disabled.
*/
void setFrequency(int freq) {
frequency = freq;
}
/**
* Get the temperature at which the system is being maintained, measured in Kelvin.
*/
double getTemperature() const {
return temperature;
}
/**
* Set the temperature at which the system is being maintained.
*
* @param temp the system temperature, measured in Kelvin.
*/
void setTemperature(double temp) {
temperature = temp;
}
/**
* Get the mode specifying the behavior of the X and Y axes.
*/
XYMode getXYMode() const {
return xymode;
}
/**
* Set the mode specifying the behavior of the X and Y axes.
*/
void setXYMode(XYMode mode) {
xymode = mode;
}
/**
* Get the mode specifying the behavior of the Z axis.
*/
ZMode getZMode() const {
return zmode;
}
/**
* Set the mode specifying the behavior of the Z axis.
*/
void setZMode(ZMode mode) {
zmode = mode;
}
/**
* Get the random number seed. See setRandomNumberSeed() for details.
*/
int getRandomNumberSeed() const {
return randomNumberSeed;
}
/**
* Set the random number seed. It is guaranteed that if two simulations are run
* with different random number seeds, the sequence of Monte Carlo steps will be different. On
* the other hand, no guarantees are made about the behavior of simulations that use the same seed.
* In particular, Platforms are permitted to use non-deterministic algorithms which produce different
* results on successive runs, even if those runs were initialized identically.
*
* If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context
* is created from this Force. This is done to ensure that each Context receives unique random seeds
* without you needing to set them explicitly.
*/
void setRandomNumberSeed(int seed) {
randomNumberSeed = seed;
}
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return true;
}
protected:
ForceImpl* createImpl() const;
private:
double defaultPressure, defaultSurfaceTension, temperature;
XYMode xymode;
ZMode zmode;
int frequency, randomNumberSeed;
};
} // namespace OpenMM
#endif /*OPENMM_MONTECARLOMEMBRANEBAROSTAT_H_*/
...@@ -343,7 +343,7 @@ public: ...@@ -343,7 +343,7 @@ public:
* Update the particle and exception parameters in a Context to match those stored in this Force object. This method * Update the particle and exception parameters in a Context to match those stored in this Force object. This method
* provides an efficient method to update certain parameters in an existing Context without needing to reinitialize it. * provides an efficient method to update certain parameters in an existing Context without needing to reinitialize it.
* Simply call setParticleParameters() and setExceptionParameters() to modify this object's parameters, then call * Simply call setParticleParameters() and setExceptionParameters() to modify this object's parameters, then call
* updateParametersInState() to copy them over to the Context. * updateParametersInContext() to copy them over to the Context.
* *
* This method has several limitations. The only information it updates is the parameters of particles and exceptions. * This method has several limitations. The only information it updates is the parameters of particles and exceptions.
* All other aspects of the Force (the nonbonded method, the cutoff distance, etc.) are unaffected and can only be * All other aspects of the Force (the nonbonded method, the cutoff distance, etc.) are unaffected and can only be
...@@ -352,6 +352,17 @@ public: ...@@ -352,6 +352,17 @@ public:
* to add new particles or exceptions, only to change the parameters of existing ones. * to add new particles or exceptions, only to change the parameters of existing ones.
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == NonbondedForce::CutoffPeriodic ||
nonbondedMethod == NonbondedForce::Ewald ||
nonbondedMethod == NonbondedForce::PME;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
...@@ -101,13 +101,22 @@ public: ...@@ -101,13 +101,22 @@ public:
/** /**
* Update the per-torsion parameters in a Context to match those stored in this Force object. This method provides * Update the per-torsion parameters in a Context to match those stored in this Force object. This method provides
* an efficient method to update certain parameters in an existing Context without needing to reinitialize it. * an efficient method to update certain parameters in an existing Context without needing to reinitialize it.
* Simply call setTorsionParameters() to modify this object's parameters, then call updateParametersInState() * Simply call setTorsionParameters() to modify this object's parameters, then call updateParametersInContext()
* to copy them over to the Context. * to copy them over to the Context.
* *
* The only information this method updates is the values of per-torsion parameters. The set of particles involved * The only information this method updates is the values of per-torsion parameters. The set of particles involved
* in a torsion cannot be changed, nor can new torsions be added. * in a torsion cannot be changed, nor can new torsions be added.
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return false;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
...@@ -110,13 +110,22 @@ public: ...@@ -110,13 +110,22 @@ public:
/** /**
* Update the per-torsion parameters in a Context to match those stored in this Force object. This method provides * Update the per-torsion parameters in a Context to match those stored in this Force object. This method provides
* an efficient method to update certain parameters in an existing Context without needing to reinitialize it. * an efficient method to update certain parameters in an existing Context without needing to reinitialize it.
* Simply call setTorsionParameters() to modify this object's parameters, then call updateParametersInState() * Simply call setTorsionParameters() to modify this object's parameters, then call updateParametersInContext()
* to copy them over to the Context. * to copy them over to the Context.
* *
* The only information this method updates is the values of per-torsion parameters. The set of particles involved * The only information this method updates is the values of per-torsion parameters. The set of particles involved
* in a torsion cannot be changed, nor can new torsions be added. * in a torsion cannot be changed, nor can new torsions be added.
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return false;
}
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
......
...@@ -108,6 +108,10 @@ public: ...@@ -108,6 +108,10 @@ public:
* Get a map containing the values of all parameters. If this State does not contain parameters, this will throw an exception. * Get a map containing the values of all parameters. If this State does not contain parameters, this will throw an exception.
*/ */
const std::map<std::string, double>& getParameters() const; const std::map<std::string, double>& getParameters() const;
/**
* Get which data types are stored in this State. The return value is a sum of DataType flags.
*/
int getDataTypes() const;
private: private:
State(double time); State(double time);
void setPositions(const std::vector<Vec3>& pos); void setPositions(const std::vector<Vec3>& pos);
......
...@@ -168,6 +168,12 @@ public: ...@@ -168,6 +168,12 @@ public:
* @param distance the required distance between the two particles, measured in nm * @param distance the required distance between the two particles, measured in nm
*/ */
void setConstraintParameters(int index, int particle1, int particle2, double distance); void setConstraintParameters(int index, int particle1, int particle2, double distance);
/**
* Remove a constraint from the System.
*
* @param index the index of the constraint to remove
*/
void removeConstraint(int index);
/** /**
* Add a Force to the System. The Force should have been created on the heap with the * Add a Force to the System. The Force should have been created on the heap with the
* "new" operator. The System takes over ownership of it, and deletes the Force when the * "new" operator. The System takes over ownership of it, and deletes the Force when the
...@@ -198,14 +204,18 @@ public: ...@@ -198,14 +204,18 @@ public:
* @param index the index of the Force to get * @param index the index of the Force to get
*/ */
Force& getForce(int index); Force& getForce(int index);
/**
* Remove a Force from the System. The memory associated with the removed Force
* object is deleted.
*
* @param index the index of the Force to remove
*/
void removeForce(int index);
/** /**
* Get the default values of the vectors defining the axes of the periodic box (measured in nm). Any newly * Get the default values of the vectors defining the axes of the periodic box (measured in nm). Any newly
* created Context will have its box vectors set to these. They will affect * created Context will have its box vectors set to these. They will affect
* any Force added to the System that uses periodic boundary conditions. * any Force added to the System that uses periodic boundary conditions.
* *
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
*
* @param a on exit, this contains the vector defining the first edge of the periodic box * @param a on exit, this contains the vector defining the first edge of the periodic box
* @param b on exit, this contains the vector defining the second edge of the periodic box * @param b on exit, this contains the vector defining the second edge of the periodic box
* @param c on exit, this contains the vector defining the third edge of the periodic box * @param c on exit, this contains the vector defining the third edge of the periodic box
...@@ -216,14 +226,24 @@ public: ...@@ -216,14 +226,24 @@ public:
* created Context will have its box vectors set to these. They will affect * created Context will have its box vectors set to these. They will affect
* any Force added to the System that uses periodic boundary conditions. * any Force added to the System that uses periodic boundary conditions.
* *
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the * Triclinic boxes are supported, but the vectors must satisfy certain requirements. In particular,
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes. * a must point in the x direction, b must point "mostly" in the y direction, and c must point "mostly"
* in the z direction. See the documentation for details.
* *
* @param a the vector defining the first edge of the periodic box * @param a the vector defining the first edge of the periodic box
* @param b the vector defining the second edge of the periodic box * @param b the vector defining the second edge of the periodic box
* @param c the vector defining the third edge of the periodic box * @param c the vector defining the third edge of the periodic box
*/ */
void setDefaultPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3& c); void setDefaultPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3& c);
/**
* Returns whether or not any forces in this System use periodic boundaries.
*
* If a force in this System does not implement usesPeriodicBoundaryConditions
* a OpenMM::OpenMMException is thrown
*
* @return true if at least one force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions();
private: private:
class ConstraintInfo; class ConstraintInfo;
Vec3 periodicBoxVectors[3]; Vec3 periodicBoxVectors[3];
......
...@@ -121,6 +121,10 @@ public: ...@@ -121,6 +121,10 @@ public:
* the other hand, no guarantees are made about the behavior of simulations that use the same seed. * the other hand, no guarantees are made about the behavior of simulations that use the same seed.
* In particular, Platforms are permitted to use non-deterministic algorithms which produce different * In particular, Platforms are permitted to use non-deterministic algorithms which produce different
* results on successive runs, even if those runs were initialized identically. * results on successive runs, even if those runs were initialized identically.
*
* If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context
* is created from this Force. This is done to ensure that each Context receives unique random seeds
* without you needing to set them explicitly.
*/ */
void setRandomNumberSeed(int seed) { void setRandomNumberSeed(int seed) {
randomNumberSeed = seed; randomNumberSeed = seed;
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
/** /**
* Create a VerletIntegrator. * Create a VerletIntegrator.
* *
* @param stepSize the step size with which to integrator the system (in picoseconds) * @param stepSize the step size with which to integrate the system (in picoseconds)
*/ */
explicit VerletIntegrator(double stepSize); explicit VerletIntegrator(double stepSize);
/** /**
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2010 Stanford University and the Authors. * * Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
return std::map<std::string, double>(); // This force field doesn't define any parameters. return std::map<std::string, double>(); // This force field doesn't define any parameters.
} }
std::vector<std::string> getKernelNames(); std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context);
/** /**
* Given the energy values for a map, compute the spline coefficients at each point of the map. * Given the energy values for a map, compute the spline coefficients at each point of the map.
*/ */
......
...@@ -142,9 +142,6 @@ public: ...@@ -142,9 +142,6 @@ public:
* Get the vectors defining the axes of the periodic box (measured in nm). They will affect * Get the vectors defining the axes of the periodic box (measured in nm). They will affect
* any Force that uses periodic boundary conditions. * any Force that uses periodic boundary conditions.
* *
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
*
* @param a the vector defining the first edge of the periodic box * @param a the vector defining the first edge of the periodic box
* @param b the vector defining the second edge of the periodic box * @param b the vector defining the second edge of the periodic box
* @param c the vector defining the third edge of the periodic box * @param c the vector defining the third edge of the periodic box
...@@ -154,8 +151,9 @@ public: ...@@ -154,8 +151,9 @@ public:
* Set the vectors defining the axes of the periodic box (measured in nm). They will affect * Set the vectors defining the axes of the periodic box (measured in nm). They will affect
* any Force that uses periodic boundary conditions. * any Force that uses periodic boundary conditions.
* *
* Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the * Triclinic boxes are supported, but the vectors must satisfy certain requirements. In particular,
* x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes. * a must point in the x direction, b must point "mostly" in the y direction, and c must point "mostly"
* in the z direction. See the documentation for details.
* *
* @param a the vector defining the first edge of the periodic box * @param a the vector defining the first edge of the periodic box
* @param b the vector defining the second edge of the periodic box * @param b the vector defining the second edge of the periodic box
......
#ifndef OPENMM_MONTECARLOMEMBRANEBAROSTATIMPL_H_
#define OPENMM_MONTECARLOMEMBRANEBAROSTATIMPL_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "ForceImpl.h"
#include "openmm/MonteCarloMembraneBarostat.h"
#include "openmm/Kernel.h"
#include "sfmt/SFMT.h"
#include <string>
namespace OpenMM {
/**
* This is the internal implementation of MonteCarloMembraneBarostat.
*/
class MonteCarloMembraneBarostatImpl : public ForceImpl {
public:
MonteCarloMembraneBarostatImpl(const MonteCarloMembraneBarostat& owner);
void initialize(ContextImpl& context);
const MonteCarloMembraneBarostat& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context);
double calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) {
// This force doesn't apply forces to particles.
return 0.0;
}
std::map<std::string, double> getDefaultParameters();
std::vector<std::string> getKernelNames();
private:
const MonteCarloMembraneBarostat& owner;
int step, numAttempted[3], numAccepted[3];
double volumeScale[3];
OpenMM_SFMT::SFMT random;
Kernel kernel;
};
} // namespace OpenMM
#endif /*OPENMM_MONTECARLOMEMBRANEBAROSTATIMPL_H_*/
...@@ -191,6 +191,18 @@ static inline fvec8 sqrt(const fvec8& v) { ...@@ -191,6 +191,18 @@ static inline fvec8 sqrt(const fvec8& v) {
return fvec8(_mm256_sqrt_ps(v.val)); return fvec8(_mm256_sqrt_ps(v.val));
} }
static inline fvec8 rsqrt(const fvec8& v) {
// Initial estimate of rsqrt().
fvec8 y(_mm256_rsqrt_ps(v.val));
// Perform an iteration of Newton refinement.
fvec8 x2 = v*0.5f;
y *= fvec8(1.5f)-x2*y*y;
return y;
}
static inline float dot8(const fvec8& v1, const fvec8& v2) { static inline float dot8(const fvec8& v1, const fvec8& v2) {
fvec8 result = _mm256_dp_ps(v1, v2, 0xF1); fvec8 result = _mm256_dp_ps(v1, v2, 0xF1);
return _mm_cvtss_f32(result.lowerVec())+_mm_cvtss_f32(result.upperVec()); return _mm_cvtss_f32(result.lowerVec())+_mm_cvtss_f32(result.upperVec());
......
...@@ -251,11 +251,15 @@ static inline fvec4 abs(const fvec4& v) { ...@@ -251,11 +251,15 @@ static inline fvec4 abs(const fvec4& v) {
return vabsq_f32(v); return vabsq_f32(v);
} }
static inline fvec4 sqrt(const fvec4& v) { static inline fvec4 rsqrt(const fvec4& v) {
float32x4_t recipSqrt = vrsqrteq_f32(v); float32x4_t recipSqrt = vrsqrteq_f32(v);
recipSqrt = vmulq_f32(recipSqrt, vrsqrtsq_f32(vmulq_f32(recipSqrt, v), recipSqrt)); recipSqrt = vmulq_f32(recipSqrt, vrsqrtsq_f32(vmulq_f32(recipSqrt, v), recipSqrt));
recipSqrt = vmulq_f32(recipSqrt, vrsqrtsq_f32(vmulq_f32(recipSqrt, v), recipSqrt)); recipSqrt = vmulq_f32(recipSqrt, vrsqrtsq_f32(vmulq_f32(recipSqrt, v), recipSqrt));
return vmulq_f32(v, recipSqrt); return recipSqrt;
}
static inline fvec4 sqrt(const fvec4& v) {
return rsqrt(v)*v;
} }
static inline float dot3(const fvec4& v1, const fvec4& v2) { static inline float dot3(const fvec4& v1, const fvec4& v2) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment