"vscode:/vscode.git/clone" did not exist on "1010df3365f3d19062153d99b8dc95c1a3deb3ad"
Commit 51b7f9e2 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Merge master

parents 85bfd73c be0387b6
...@@ -40,14 +40,14 @@ namespace OpenMM { ...@@ -40,14 +40,14 @@ namespace OpenMM {
/** /**
* This class implements an implicit solvation force using the GBSA-OBC model. * This class implements an implicit solvation force using the GBSA-OBC model.
* *
* To use this class, create a GBSAOBCForce object, then call addParticle() once for each particle in the * To use this class, create a GBSAOBCForce object, then call addParticle() once for each particle in the
* System to define its parameters. The number of particles for which you define GBSA parameters must * System to define its parameters. The number of particles for which you define GBSA parameters must
* be exactly equal to the number of particles in the System, or else an exception will be thrown when you * be exactly equal to the number of particles in the System, or else an exception will be thrown when you
* try to create a Context. After a particle has been added, you can modify its force field parameters * try to create a Context. After a particle has been added, you can modify its force field parameters
* by calling setParticleParameters(). This will have no effect on Contexts that already exist unless you * by calling setParticleParameters(). This will have no effect on Contexts that already exist unless you
* call updateParametersInContext(). * call updateParametersInContext().
* *
* When using this Force, the System should also include a NonbondedForce, and both objects must specify * When using this Force, the System should also include a NonbondedForce, and both objects must specify
* identical charges for all particles. Otherwise, the results will not be correct. Furthermore, if the * identical charges for all particles. Otherwise, the results will not be correct. Furthermore, if the
* nonbonded method is set to CutoffNonPeriodic or CutoffPeriodic, you should call setReactionFieldDielectric(1.0) * nonbonded method is set to CutoffNonPeriodic or CutoffPeriodic, you should call setReactionFieldDielectric(1.0)
...@@ -98,16 +98,16 @@ public: ...@@ -98,16 +98,16 @@ public:
int addParticle(double charge, double radius, double scalingFactor); int addParticle(double charge, double radius, double scalingFactor);
/** /**
* Get the force field parameters for a particle. * Get the force field parameters for a particle.
* *
* @param index the index of the particle for which to get parameters * @param index the index of the particle for which to get parameters
* @param charge the charge of the particle, measured in units of the proton charge * @param[out] charge the charge of the particle, measured in units of the proton charge
* @param radius the GBSA radius of the particle, measured in nm * @param[out] radius the GBSA radius of the particle, measured in nm
* @param scalingFactor the OBC scaling factor for the particle * @param[out] scalingFactor the OBC scaling factor for the particle
*/ */
void getParticleParameters(int index, double& charge, double& radius, double& scalingFactor) const; void getParticleParameters(int index, double& charge, double& radius, double& scalingFactor) const;
/** /**
* Set the force field parameters for a particle. * Set the force field parameters for a particle.
* *
* @param index the index of the particle for which to set parameters * @param index the index of the particle for which to set parameters
* @param charge the charge of the particle, measured in units of the proton charge * @param charge the charge of the particle, measured in units of the proton charge
* @param radius the GBSA radius of the particle, measured in nm * @param radius the GBSA radius of the particle, measured in nm
...@@ -177,7 +177,7 @@ public: ...@@ -177,7 +177,7 @@ public:
* 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
* updateParametersInContext() 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
* by reinitializing the Context. Furthermore, this method cannot be used to add new particles, only to * by reinitializing the Context. Furthermore, this method cannot be used to add new particles, only to
......
...@@ -46,13 +46,13 @@ namespace OpenMM { ...@@ -46,13 +46,13 @@ namespace OpenMM {
* be exactly equal to the number of particles in the System, or else an exception will be thrown when you * be exactly equal to the number of particles in the System, or else an exception will be thrown when you
* try to create a Context. After a particle has been added, you can modify its force field parameters * try to create a Context. After a particle has been added, you can modify its force field parameters
* by calling setParticleParameters(). * by calling setParticleParameters().
* *
* @deprecated This class is not supported by most platforms, and will eventually be removed. You can implement the same force with CustomGBForce. * @deprecated This class is not supported by most platforms, and will eventually be removed. You can implement the same force with CustomGBForce.
*/ */
class OPENMM_EXPORT GBVIForce : public Force { class OPENMM_EXPORT GBVIForce : public Force {
public: public:
/** /**
* This is an enumeration of the different methods that may be used for handling long range nonbonded forces. * This is an enumeration of the different methods that may be used for handling long range nonbonded forces.
*/ */
enum NonbondedMethod { enum NonbondedMethod {
...@@ -70,9 +70,9 @@ public: ...@@ -70,9 +70,9 @@ public:
* each other particle. Interactions beyond the cutoff distance are ignored. * each other particle. Interactions beyond the cutoff distance are ignored.
*/ */
CutoffPeriodic = 2, CutoffPeriodic = 2,
}; };
/** /**
* This is an enumeration of the different methods that may be used for scaling of the Born radii. * This is an enumeration of the different methods that may be used for scaling of the Born radii.
*/ */
enum BornRadiusScalingMethod { enum BornRadiusScalingMethod {
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
* Use quintic spline scaling function * Use quintic spline scaling function
*/ */
QuinticSpline = 1 QuinticSpline = 1
}; };
/* /*
* Create a GBVIForce. * Create a GBVIForce.
...@@ -108,16 +108,16 @@ public: ...@@ -108,16 +108,16 @@ public:
int addParticle(double charge, double radius, double gamma); int addParticle(double charge, double radius, double gamma);
/** /**
* Get the force field parameters for a particle. * Get the force field parameters for a particle.
* *
* @param index the index of the particle for which to get parameters * @param index the index of the particle for which to get parameters
* @param charge the charge of the particle, measured in units of the proton charge * @param[out] charge the charge of the particle, measured in units of the proton charge
* @param radius the GBSA radius of the particle, measured in nm * @param[out] radius the GBSA radius of the particle, measured in nm
* @param gamma the gamma parameter * @param[out] gamma the gamma parameter
*/ */
void getParticleParameters(int index, double& charge, double& radius, double& gamma) const; void getParticleParameters(int index, double& charge, double& radius, double& gamma) const;
/** /**
* Set the force field parameters for a particle. * Set the force field parameters for a particle.
* *
* @param index the index of the particle for which to set parameters * @param index the index of the particle for which to set parameters
* @param charge the charge of the particle, measured in units of the proton charge * @param charge the charge of the particle, measured in units of the proton charge
* @param radius the GB/VI radius of the particle, measured in nm * @param radius the GB/VI radius of the particle, measured in nm
...@@ -125,36 +125,36 @@ public: ...@@ -125,36 +125,36 @@ public:
*/ */
void setParticleParameters(int index, double charge, double radius, double gamma); void setParticleParameters(int index, double charge, double radius, double gamma);
/** /**
* Add a bond * Add a bond
* *
* @param particle1 the index of the first particle * @param particle1 the index of the first particle
* @param particle2 the index of the second particle * @param particle2 the index of the second particle
* @param distance the distance between the two particles, measured in nm * @param distance the distance between the two particles, measured in nm
* @return the index of the bond that was added * @return the index of the bond that was added
*/ */
int addBond(int particle1, int particle2, double distance); int addBond(int particle1, int particle2, double distance);
/** /**
* Get the parameters defining a bond * Get the parameters defining a bond
* *
* @param index the index of the bond for which to get parameters * @param index the index of the bond for which to get parameters
* @param particle1 the index of the first particle involved in the bond * @param[out] particle1 the index of the first particle involved in the bond
* @param particle2 the index of the second particle involved in the bond * @param[out] particle2 the index of the second particle involved in the bond
* @param distance the distance between the two particles, measured in nm * @param[out] distance the distance between the two particles, measured in nm
*/ */
void getBondParameters(int index, int& particle1, int& particle2, double& distance) const; void getBondParameters(int index, int& particle1, int& particle2, double& distance) const;
/** /**
* Set 1-2 bonds * Set 1-2 bonds
* *
* @param index index of the bond for which to set parameters * @param index index of the bond for which to set parameters
* @param particle1 index of first atom in bond * @param particle1 index of first atom in bond
* @param particle2 index of second atom in bond * @param particle2 index of second atom in bond
* @param bondLength bond length, measured in nm * @param bondLength bond length, measured in nm
*/ */
void setBondParameters( int index, int particle1, int particle2, double bondLength); void setBondParameters( int index, int particle1, int particle2, double bondLength);
/** /**
* Get number of bonds * Get number of bonds
* *
* @return number of bonds * @return number of bonds
*/ */
int getNumBonds() const; int getNumBonds() const;
...@@ -183,49 +183,49 @@ public: ...@@ -183,49 +183,49 @@ public:
void setSoluteDielectric(double dielectric) { void setSoluteDielectric(double dielectric) {
soluteDielectric = dielectric; soluteDielectric = dielectric;
} }
/** /**
* Get the method used for handling long range nonbonded interactions. * Get the method used for handling long range nonbonded interactions.
*/ */
NonbondedMethod getNonbondedMethod() const; NonbondedMethod getNonbondedMethod() const;
/** /**
* Set the method used for handling long range nonbonded interactions. * Set the method used for handling long range nonbonded interactions.
*/ */
void setNonbondedMethod(NonbondedMethod method); void setNonbondedMethod(NonbondedMethod method);
/** /**
* Get the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use * Get the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use
* is NoCutoff, this value will have no effect. * is NoCutoff, this value will have no effect.
* *
* @return the cutoff distance, measured in nm * @return the cutoff distance, measured in nm
*/ */
double getCutoffDistance() const; double getCutoffDistance() const;
/** /**
* Set the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use * Set the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use
* is NoCutoff, this value will have no effect. * is NoCutoff, this value will have no effect.
* *
* @param distance the cutoff distance, measured in nm * @param distance the cutoff distance, measured in nm
*/ */
void setCutoffDistance(double distance); void setCutoffDistance(double distance);
/** /**
* Get Born radius scaling method * Get Born radius scaling method
*/ */
BornRadiusScalingMethod getBornRadiusScalingMethod() const; BornRadiusScalingMethod getBornRadiusScalingMethod() const;
/** /**
* Set Born radius scaling method * Set Born radius scaling method
*/ */
void setBornRadiusScalingMethod( BornRadiusScalingMethod method); void setBornRadiusScalingMethod( BornRadiusScalingMethod method);
/** /**
* 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() 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)
*/ */
void setQuinticLowerLimitFactor(double quinticLowerLimitFactor ); void setQuinticLowerLimitFactor(double quinticLowerLimitFactor );
/** /**
* 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() 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);
......
...@@ -72,18 +72,18 @@ public: ...@@ -72,18 +72,18 @@ public:
int addAngle(int particle1, int particle2, int particle3, double angle, double k); int addAngle(int particle1, int particle2, int particle3, double angle, double k);
/** /**
* Get the force field parameters for an angle term. * Get the force field parameters for an angle term.
* *
* @param index the index of the angle for which to get parameters * @param index the index of the angle for which to get parameters
* @param particle1 the index of the first particle forming the angle * @param[out] particle1 the index of the first particle forming the angle
* @param particle2 the index of the second particle forming the angle * @param[out] particle2 the index of the second particle forming the angle
* @param particle3 the index of the third particle forming the angle * @param[out] particle3 the index of the third particle forming the angle
* @param angle the equilibrium angle, measured in radians * @param[out] angle the equilibrium angle, measured in radians
* @param k the harmonic force constant for the angle, measured in kJ/mol/radian^2 * @param[out] k the harmonic force constant for the angle, measured in kJ/mol/radian^2
*/ */
void getAngleParameters(int index, int& particle1, int& particle2, int& particle3, double& angle, double& k) const; void getAngleParameters(int index, int& particle1, int& particle2, int& particle3, double& angle, double& k) const;
/** /**
* Set the force field parameters for an angle term. * Set the force field parameters for an angle term.
* *
* @param index the index of the angle for which to set parameters * @param index the index of the angle for which to set parameters
* @param particle1 the index of the first particle forming the angle * @param particle1 the index of the first particle forming the angle
* @param particle2 the index of the second particle forming the angle * @param particle2 the index of the second particle forming the angle
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
* 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 updateParametersInContext() * 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.
*/ */
......
...@@ -71,17 +71,17 @@ public: ...@@ -71,17 +71,17 @@ public:
int addBond(int particle1, int particle2, double length, double k); int addBond(int particle1, int particle2, double length, double k);
/** /**
* Get the force field parameters for a bond term. * Get the force field parameters for a bond term.
* *
* @param index the index of the bond for which to get parameters * @param index the index of the bond for which to get parameters
* @param particle1 the index of the first particle connected by the bond * @param[out] particle1 the index of the first particle connected by the bond
* @param particle2 the index of the second particle connected by the bond * @param[out] particle2 the index of the second particle connected by the bond
* @param length the equilibrium length of the bond, measured in nm * @param[out] length the equilibrium length of the bond, measured in nm
* @param k the harmonic force constant for the bond, measured in kJ/mol/nm^2 * @param[out] k the harmonic force constant for the bond, measured in kJ/mol/nm^2
*/ */
void getBondParameters(int index, int& particle1, int& particle2, double& length, double& k) const; void getBondParameters(int index, int& particle1, int& particle2, double& length, double& k) const;
/** /**
* Set the force field parameters for a bond term. * Set the force field parameters for a bond term.
* *
* @param index the index of the bond for which to set parameters * @param index the index of the bond for which to set parameters
* @param particle1 the index of the first particle connected by the bond * @param particle1 the index of the first particle connected by the bond
* @param particle2 the index of the second particle connected by the bond * @param particle2 the index of the second particle connected by the bond
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
* 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 updateParametersInContext() * 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.
*/ */
......
...@@ -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-2012 Stanford University and the Authors. * * Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -61,30 +61,22 @@ public: ...@@ -61,30 +61,22 @@ public:
* *
* @return the step size, measured in ps * @return the step size, measured in ps
*/ */
double getStepSize() const { virtual double getStepSize() const;
return stepSize;
}
/** /**
* Set the size of each time step, in picoseconds. If this integrator uses variable time steps, * Set the size of each time step, in picoseconds. If this integrator uses variable time steps,
* the effect of calling this method is undefined, and it may simply be ignored. * the effect of calling this method is undefined, and it may simply be ignored.
* *
* @param size the step size, measured in ps * @param size the step size, measured in ps
*/ */
void setStepSize(double size) { virtual void setStepSize(double size);
stepSize = size;
}
/** /**
* Get the distance tolerance within which constraints are maintained, as a fraction of the constrained distance. * Get the distance tolerance within which constraints are maintained, as a fraction of the constrained distance.
*/ */
double getConstraintTolerance() const { virtual double getConstraintTolerance() const;
return constraintTol;
}
/** /**
* Set the distance tolerance within which constraints are maintained, as a fraction of the constrained distance. * Set the distance tolerance within which constraints are maintained, as a fraction of the constrained distance.
*/ */
void setConstraintTolerance(double tol) { virtual void setConstraintTolerance(double tol);
constraintTol = tol;
}
/** /**
* Advance a simulation through time by taking a series of time steps. * Advance a simulation through time by taking a series of time steps.
* *
...@@ -94,6 +86,7 @@ public: ...@@ -94,6 +86,7 @@ public:
protected: protected:
friend class Context; friend class Context;
friend class ContextImpl; friend class ContextImpl;
friend class CompoundIntegrator;
ContextImpl* context; ContextImpl* context;
Context* owner; Context* owner;
/** /**
......
...@@ -65,13 +65,13 @@ namespace OpenMM { ...@@ -65,13 +65,13 @@ namespace OpenMM {
* This class provides a convenience method for this case called createExceptionsFromBonds(). You pass to it * This class provides a convenience method for this case called createExceptionsFromBonds(). You pass to it
* a list of bonds and the scale factors to use for 1-4 interactions. It identifies all pairs of particles which * a list of bonds and the scale factors to use for 1-4 interactions. It identifies all pairs of particles which
* are separated by 1, 2, or 3 bonds, then automatically creates exceptions for them. * are separated by 1, 2, or 3 bonds, then automatically creates exceptions for them.
* *
* When using a cutoff, by default Lennard-Jones interactions are sharply truncated at the cutoff distance. * When using a cutoff, by default Lennard-Jones interactions are sharply truncated at the cutoff distance.
* Optionally you can instead use a switching function to make the interaction smoothly go to zero over a finite * Optionally you can instead use a switching function to make the interaction smoothly go to zero over a finite
* distance range. To enable this, call setUseSwitchingFunction(). You must also call setSwitchingDistance() * distance range. To enable this, call setUseSwitchingFunction(). You must also call setSwitchingDistance()
* to specify the distance at which the interaction should begin to decrease. The switching distance must be * to specify the distance at which the interaction should begin to decrease. The switching distance must be
* less than the cutoff distance. * less than the cutoff distance.
* *
* Another optional feature of this class (enabled by default) is to add a contribution to the energy which approximates * Another optional feature of this class (enabled by default) is to add a contribution to the energy which approximates
* the effect of all Lennard-Jones interactions beyond the cutoff in a periodic system. When running a simulation * the effect of all Lennard-Jones interactions beyond the cutoff in a periodic system. When running a simulation
* at constant pressure, this can improve the quality of the result. Call setUseDispersionCorrection() to set whether * at constant pressure, this can improve the quality of the result. Call setUseDispersionCorrection() to set whether
...@@ -182,7 +182,7 @@ public: ...@@ -182,7 +182,7 @@ public:
* which is acceptable. This value is used to select the reciprocal space cutoff and separation * which is acceptable. This value is used to select the reciprocal space cutoff and separation
* parameter so that the average error level will be less than the tolerance. There is not a * parameter so that the average error level will be less than the tolerance. There is not a
* rigorous guarantee that all forces on all atoms will be less than the tolerance, however. * rigorous guarantee that all forces on all atoms will be less than the tolerance, however.
* *
* For PME calculations, if setPMEParameters() is used to set alpha to something other than 0, * For PME calculations, if setPMEParameters() is used to set alpha to something other than 0,
* this value is ignored. * this value is ignored.
*/ */
...@@ -192,7 +192,7 @@ public: ...@@ -192,7 +192,7 @@ public:
* which is acceptable. This value is used to select the reciprocal space cutoff and separation * which is acceptable. This value is used to select the reciprocal space cutoff and separation
* parameter so that the average error level will be less than the tolerance. There is not a * parameter so that the average error level will be less than the tolerance. There is not a
* rigorous guarantee that all forces on all atoms will be less than the tolerance, however. * rigorous guarantee that all forces on all atoms will be less than the tolerance, however.
* *
* For PME calculations, if setPMEParameters() is used to set alpha to something other than 0, * For PME calculations, if setPMEParameters() is used to set alpha to something other than 0,
* this value is ignored. * this value is ignored.
*/ */
...@@ -200,17 +200,17 @@ public: ...@@ -200,17 +200,17 @@ public:
/** /**
* Get the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are * Get the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are
* ignored and instead their values are chosen based on the Ewald error tolerance. * ignored and instead their values are chosen based on the Ewald error tolerance.
* *
* @param alpha the separation parameter * @param[out] alpha the separation parameter
* @param nx the number of grid points along the X axis * @param[out] nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis * @param[out] ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis * @param[out] nz the number of grid points along the Z axis
*/ */
void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const; void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/** /**
* Set the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are * Set the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are
* ignored and instead their values are chosen based on the Ewald error tolerance. * ignored and instead their values are chosen based on the Ewald error tolerance.
* *
* @param alpha the separation parameter * @param alpha the separation parameter
* @param nx the number of grid points along the X axis * @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis * @param ny the number of grid points along the Y axis
...@@ -222,12 +222,12 @@ public: ...@@ -222,12 +222,12 @@ public:
* on the allowed grid sizes, the values that are actually used may be slightly different from those * on the allowed grid sizes, the values that are actually used may be slightly different from those
* specified with setPMEParameters(), or the standard values calculated based on the Ewald error tolerance. * specified with setPMEParameters(), or the standard values calculated based on the Ewald error tolerance.
* See the manual for details. * See the manual for details.
* *
* @param context the Context for which to get the parameters * @param context the Context for which to get the parameters
* @param alpha the separation parameter * @param[out] alpha the separation parameter
* @param nx the number of grid points along the X axis * @param[out] nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis * @param[out] ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis * @param[out] nz the number of grid points along the Z axis
*/ */
void getPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const; void getPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const;
/** /**
...@@ -246,10 +246,10 @@ public: ...@@ -246,10 +246,10 @@ public:
/** /**
* Get the nonbonded force parameters for a particle. * Get the nonbonded force parameters for a particle.
* *
* @param index the index of the particle for which to get parameters * @param index the index of the particle for which to get parameters
* @param charge the charge of the particle, measured in units of the proton charge * @param[out] charge the charge of the particle, measured in units of the proton charge
* @param sigma the sigma parameter of the Lennard-Jones potential (corresponding to the van der Waals radius of the particle), measured in nm * @param[out] sigma the sigma parameter of the Lennard-Jones potential (corresponding to the van der Waals radius of the particle), measured in nm
* @param epsilon the epsilon parameter of the Lennard-Jones potential (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol * @param[out] epsilon the epsilon parameter of the Lennard-Jones potential (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol
*/ */
void getParticleParameters(int index, double& charge, double& sigma, double& epsilon) const; void getParticleParameters(int index, double& charge, double& sigma, double& epsilon) const;
/** /**
...@@ -282,20 +282,20 @@ public: ...@@ -282,20 +282,20 @@ public:
int addException(int particle1, int particle2, double chargeProd, double sigma, double epsilon, bool replace = false); int addException(int particle1, int particle2, double chargeProd, double sigma, double epsilon, bool replace = false);
/** /**
* Get the force field parameters for an interaction that should be calculated differently from others. * Get the force field parameters for an interaction that should be calculated differently from others.
* *
* @param index the index of the interaction for which to get parameters * @param index the index of the interaction for which to get parameters
* @param particle1 the index of the first particle involved in the interaction * @param[out] particle1 the index of the first particle involved in the interaction
* @param particle2 the index of the second particle involved in the interaction * @param[out] particle2 the index of the second particle involved in the interaction
* @param chargeProd the scaled product of the atomic charges (i.e. the strength of the Coulomb interaction), measured in units of the proton charge squared * @param[out] chargeProd the scaled product of the atomic charges (i.e. the strength of the Coulomb interaction), measured in units of the proton charge squared
* @param sigma the sigma parameter of the Lennard-Jones potential (corresponding to the van der Waals radius of the particle), measured in nm * @param[out] sigma the sigma parameter of the Lennard-Jones potential (corresponding to the van der Waals radius of the particle), measured in nm
* @param epsilon the epsilon parameter of the Lennard-Jones potential (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol * @param[out] epsilon the epsilon parameter of the Lennard-Jones potential (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol
*/ */
void getExceptionParameters(int index, int& particle1, int& particle2, double& chargeProd, double& sigma, double& epsilon) const; void getExceptionParameters(int index, int& particle1, int& particle2, double& chargeProd, double& sigma, double& epsilon) const;
/** /**
* Set the force field parameters for an interaction that should be calculated differently from others. * Set the force field parameters for an interaction that should be calculated differently from others.
* If chargeProd and epsilon are both equal to 0, this will cause the interaction to be completely omitted from * If chargeProd and epsilon are both equal to 0, this will cause the interaction to be completely omitted from
* force and energy calculations. * force and energy calculations.
* *
* @param index the index of the interaction for which to get parameters * @param index the index of the interaction for which to get parameters
* @param particle1 the index of the first particle involved in the interaction * @param particle1 the index of the first particle involved in the interaction
* @param particle2 the index of the second particle involved in the interaction * @param particle2 the index of the second particle involved in the interaction
...@@ -347,7 +347,7 @@ public: ...@@ -347,7 +347,7 @@ public:
* time step integrators to evaluate direct and reciprocal space interactions at different intervals: setForceGroup() * time step integrators to evaluate direct and reciprocal space interactions at different intervals: setForceGroup()
* specifies the group for direct space, and setReciprocalSpaceForceGroup() specifies the group for reciprocal space. * specifies the group for direct space, and setReciprocalSpaceForceGroup() specifies the group for reciprocal space.
* If this is -1 (the default value), the same force group is used for reciprocal space as for direct space. * If this is -1 (the default value), the same force group is used for reciprocal space as for direct space.
* *
* @param group the group index. Legal values are between 0 and 31 (inclusive), or -1 to use the same force group * @param group the group index. Legal values are between 0 and 31 (inclusive), or -1 to use the same force group
* that is specified for direct space. * that is specified for direct space.
*/ */
...@@ -357,7 +357,7 @@ public: ...@@ -357,7 +357,7 @@ public:
* 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
* updateParametersInContext() 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
* changed by reinitializing the Context. Furthermore, only the chargeProd, sigma, and epsilon values of an exception * changed by reinitializing the Context. Furthermore, only the chargeProd, sigma, and epsilon values of an exception
......
...@@ -74,20 +74,20 @@ public: ...@@ -74,20 +74,20 @@ public:
int addTorsion(int particle1, int particle2, int particle3, int particle4, int periodicity, double phase, double k); int addTorsion(int particle1, int particle2, int particle3, int particle4, int periodicity, double phase, double k);
/** /**
* Get the force field parameters for a periodic torsion term. * Get the force field parameters for a periodic torsion term.
* *
* @param index the index of the torsion for which to get parameters * @param index the index of the torsion for which to get parameters
* @param particle1 the index of the first particle forming the torsion * @param[out] particle1 the index of the first particle forming the torsion
* @param particle2 the index of the second particle forming the torsion * @param[out] particle2 the index of the second particle forming the torsion
* @param particle3 the index of the third particle forming the torsion * @param[out] particle3 the index of the third particle forming the torsion
* @param particle4 the index of the fourth particle forming the torsion * @param[out] particle4 the index of the fourth particle forming the torsion
* @param periodicity the periodicity of the torsion * @param[out] periodicity the periodicity of the torsion
* @param phase the phase offset of the torsion, measured in radians * @param[out] phase the phase offset of the torsion, measured in radians
* @param k the force constant for the torsion * @param[out] k the force constant for the torsion
*/ */
void getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, int& periodicity, double& phase, double& k) const; void getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, int& periodicity, double& phase, double& k) const;
/** /**
* Set the force field parameters for a periodic torsion term. * Set the force field parameters for a periodic torsion term.
* *
* @param index the index of the torsion for which to set parameters * @param index the index of the torsion for which to set parameters
* @param particle1 the index of the first particle forming the torsion * @param particle1 the index of the first particle forming the torsion
* @param particle2 the index of the second particle forming the torsion * @param particle2 the index of the second particle forming the torsion
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
* 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 updateParametersInContext() * 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.
*/ */
......
...@@ -77,23 +77,23 @@ public: ...@@ -77,23 +77,23 @@ public:
int addTorsion(int particle1, int particle2, int particle3, int particle4, double c0, double c1, double c2, double c3, double c4, double c5); int addTorsion(int particle1, int particle2, int particle3, int particle4, double c0, double c1, double c2, double c3, double c4, double c5);
/** /**
* Get the force field parameters for a Ryckaert-Bellemans torsion term. * Get the force field parameters for a Ryckaert-Bellemans torsion term.
* *
* @param index the index of the torsion for which to get parameters * @param index the index of the torsion for which to get parameters
* @param particle1 the index of the first particle forming the torsion * @param[out] particle1 the index of the first particle forming the torsion
* @param particle2 the index of the second particle forming the torsion * @param[out] particle2 the index of the second particle forming the torsion
* @param particle3 the index of the third particle forming the torsion * @param[out] particle3 the index of the third particle forming the torsion
* @param particle4 the index of the fourth particle forming the torsion * @param[out] particle4 the index of the fourth particle forming the torsion
* @param c0 the coefficient of the constant term, measured in kJ/mol * @param[out] c0 the coefficient of the constant term, measured in kJ/mol
* @param c1 the coefficient of the 1st order term, measured in kJ/mol * @param[out] c1 the coefficient of the 1st order term, measured in kJ/mol
* @param c2 the coefficient of the 2nd order term, measured in kJ/mol * @param[out] c2 the coefficient of the 2nd order term, measured in kJ/mol
* @param c3 the coefficient of the 3rd order term, measured in kJ/mol * @param[out] c3 the coefficient of the 3rd order term, measured in kJ/mol
* @param c4 the coefficient of the 4th order term, measured in kJ/mol * @param[out] c4 the coefficient of the 4th order term, measured in kJ/mol
* @param c5 the coefficient of the 5th order term, measured in kJ/mol * @param[out] c5 the coefficient of the 5th order term, measured in kJ/mol
*/ */
void getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, double& c0, double& c1, double& c2, double& c3, double& c4, double& c5) const; void getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, double& c0, double& c1, double& c2, double& c3, double& c4, double& c5) const;
/** /**
* Set the force field parameters for a Ryckaert-Bellemans torsion term. * Set the force field parameters for a Ryckaert-Bellemans torsion term.
* *
* @param index the index of the torsion for which to set parameters * @param index the index of the torsion for which to set parameters
* @param particle1 the index of the first particle forming the torsion * @param particle1 the index of the first particle forming the torsion
* @param particle2 the index of the second particle forming the torsion * @param particle2 the index of the second particle forming the torsion
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
* 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 updateParametersInContext() * 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.
*/ */
......
...@@ -43,7 +43,7 @@ namespace OpenMM { ...@@ -43,7 +43,7 @@ namespace OpenMM {
/** /**
* A State object records a snapshot of the current state of a simulation at a point in time. * A State object records a snapshot of the current state of a simulation at a point in time.
* You create it by calling getState() on a Context. * You create it by calling getState() on a Context.
* *
* When a State is created, you specify what information should be stored in it. This saves * When a State is created, you specify what information should be stored in it. This saves
* time and memory by only copying in the information that you actually want. This is especially * time and memory by only copying in the information that you actually want. This is especially
* important for forces and energies, since they may need to be calculated. If you query a * important for forces and energies, since they may need to be calculated. If you query a
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
const std::vector<Vec3>& getForces() const; const std::vector<Vec3>& getForces() const;
/** /**
* Get the total kinetic energy of the system. If this State does not contain energies, this will throw an exception. * Get the total kinetic energy of the system. If this State does not contain energies, this will throw an exception.
* *
* Note that this may be different from simply mv<sup>2</sup>/2 summed over all particles. For example, a leapfrog * Note that this may be different from simply mv<sup>2</sup>/2 summed over all particles. For example, a leapfrog
* integrator will store velocities offset by half a step, so they must be adjusted before computing the kinetic energy. * integrator will store velocities offset by half a step, so they must be adjusted before computing the kinetic energy.
* This routine returns the kinetic energy at the current time, computed in a way that is appropriate for whatever * This routine returns the kinetic energy at the current time, computed in a way that is appropriate for whatever
...@@ -95,9 +95,9 @@ public: ...@@ -95,9 +95,9 @@ public:
/** /**
* Get the vectors defining the axes of the periodic box (measured in nm). * Get the vectors defining the axes of the periodic box (measured in nm).
* *
* @param a on exit, this contains the vector defining the first edge of the periodic box * @param[out] a 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[out] b 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[out] c the vector defining the third edge of the periodic box
*/ */
void getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const; void getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const;
/** /**
......
...@@ -44,19 +44,19 @@ class OPENMM_EXPORT VirtualSite; ...@@ -44,19 +44,19 @@ class OPENMM_EXPORT VirtualSite;
/** /**
* This class represents a molecular system. The definition of a System involves * This class represents a molecular system. The definition of a System involves
* four elements: * four elements:
* *
* <ol> * <ol>
* <li>The set of particles in the system</li> * <li>The set of particles in the system</li>
* <li>The forces acting on them</li> * <li>The forces acting on them</li>
* <li>Pairs of particles whose separation should be constrained to a fixed value</li> * <li>Pairs of particles whose separation should be constrained to a fixed value</li>
* <li>For periodic systems, the dimensions of the periodic box</li> * <li>For periodic systems, the dimensions of the periodic box</li>
* </ol> * </ol>
* *
* The particles and constraints are defined directly by the System object, while * The particles and constraints are defined directly by the System object, while
* forces are defined by objects that extend the Force class. After creating a * forces are defined by objects that extend the Force class. After creating a
* System, call addParticle() once for each particle, addConstraint() for each constraint, * System, call addParticle() once for each particle, addConstraint() for each constraint,
* and addForce() for each Force. * and addForce() for each Force.
* *
* In addition, particles may be designated as "virtual sites". These are particles * In addition, particles may be designated as "virtual sites". These are particles
* whose positions are computed automatically based on the positions of other particles. * whose positions are computed automatically based on the positions of other particles.
* To define a virtual site, call setVirtualSite(), passing in a VirtualSite object * To define a virtual site, call setVirtualSite(), passing in a VirtualSite object
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
* the particle and not modify its position or velocity. This is most often * the particle and not modify its position or velocity. This is most often
* used for virtual sites, but can also be used as a way to prevent a particle * used for virtual sites, but can also be used as a way to prevent a particle
* from moving. * from moving.
* *
* @param index the index of the particle for which to get the mass * @param index the index of the particle for which to get the mass
*/ */
double getParticleMass(int index) const; double getParticleMass(int index) const;
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
* the particle and not modify its position or velocity. This is most often * the particle and not modify its position or velocity. This is most often
* used for virtual sites, but can also be used as a way to prevent a particle * used for virtual sites, but can also be used as a way to prevent a particle
* from moving. * from moving.
* *
* @param index the index of the particle for which to set the mass * @param index the index of the particle for which to set the mass
* @param mass the mass of the particle * @param mass the mass of the particle
*/ */
...@@ -120,7 +120,7 @@ public: ...@@ -120,7 +120,7 @@ public:
void setVirtualSite(int index, VirtualSite* virtualSite); void setVirtualSite(int index, VirtualSite* virtualSite);
/** /**
* Get whether a particle is a VirtualSite. * Get whether a particle is a VirtualSite.
* *
* @param index the index of the particle to check * @param index the index of the particle to check
*/ */
bool isVirtualSite(int index) const { bool isVirtualSite(int index) const {
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
/** /**
* Get VirtualSite object for a particle. If the particle is not a virtual * Get VirtualSite object for a particle. If the particle is not a virtual
* site, this throws an exception. * site, this throws an exception.
* *
* @param index the index of the particle to get * @param index the index of the particle to get
*/ */
const VirtualSite& getVirtualSite(int index) const; const VirtualSite& getVirtualSite(int index) const;
...@@ -151,17 +151,17 @@ public: ...@@ -151,17 +151,17 @@ public:
int addConstraint(int particle1, int particle2, double distance); int addConstraint(int particle1, int particle2, double distance);
/** /**
* Get the parameters defining a distance constraint. * Get the parameters defining a distance constraint.
* *
* @param index the index of the constraint for which to get parameters * @param index the index of the constraint for which to get parameters
* @param particle1 the index of the first particle involved in the constraint * @param[out] particle1 the index of the first particle involved in the constraint
* @param particle2 the index of the second particle involved in the constraint * @param[out] particle2 the index of the second particle involved in the constraint
* @param distance the required distance between the two particles, measured in nm * @param[out] distance the required distance between the two particles, measured in nm
*/ */
void getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const; void getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const;
/** /**
* Set the parameters defining a distance constraint. Particles whose mass is 0 cannot participate * Set the parameters defining a distance constraint. Particles whose mass is 0 cannot participate
* in constraints. * in constraints.
* *
* @param index the index of the constraint for which to set parameters * @param index the index of the constraint for which to set parameters
* @param particle1 the index of the first particle involved in the constraint * @param particle1 the index of the first particle involved in the constraint
* @param particle2 the index of the second particle involved in the constraint * @param particle2 the index of the second particle involved in the constraint
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
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. * Remove a constraint from the System.
* *
* @param index the index of the constraint to remove * @param index the index of the constraint to remove
*/ */
void removeConstraint(int index); void removeConstraint(int index);
...@@ -194,7 +194,7 @@ public: ...@@ -194,7 +194,7 @@ public:
} }
/** /**
* Get a const reference to one of the Forces in this System. * Get a const reference to one of the Forces in this System.
* *
* @param index the index of the Force to get * @param index the index of the Force to get
*/ */
const Force& getForce(int index) const; const Force& getForce(int index) const;
...@@ -216,9 +216,9 @@ public: ...@@ -216,9 +216,9 @@ 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.
* *
* @param a on exit, this contains the vector defining the first edge of the periodic box * @param[out] a 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[out] b 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[out] c the vector defining the third edge of the periodic box
*/ */
void getDefaultPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const; void getDefaultPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const;
/** /**
......
/* -------------------------------------------------------------------------- *
* 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) 2015 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 "openmm/CompoundIntegrator.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/kernels.h"
#include <string>
using namespace OpenMM;
using namespace std;
CompoundIntegrator::CompoundIntegrator() : currentIntegrator(0) {
}
CompoundIntegrator::~CompoundIntegrator() {
for (int i = 0; i < integrators.size(); i++)
delete integrators[i];
}
int CompoundIntegrator::getNumIntegrators() const {
return integrators.size();
}
int CompoundIntegrator::addIntegrator(Integrator* integrator) {
if (owner != NULL)
throw OpenMMException("addIntegrator() cannot be called after a CustomIntegrator is already bound to a context");
integrators.push_back(integrator);
return integrators.size()-1;
}
Integrator& CompoundIntegrator::getIntegrator(int index) {
ASSERT_VALID_INDEX(index, integrators);
return *integrators[index];
}
const Integrator& CompoundIntegrator::getIntegrator(int index) const {
ASSERT_VALID_INDEX(index, integrators);
return *integrators[index];
}
int CompoundIntegrator::getCurrentIntegrator() const {
return currentIntegrator;
}
void CompoundIntegrator::setCurrentIntegrator(int index) {
if (index < 0 || index >= integrators.size())
throw OpenMMException("Illegal index for setCurrentIntegrator()");
currentIntegrator = index;
}
double CompoundIntegrator::getStepSize() const {
return integrators[currentIntegrator]->getStepSize();
}
void CompoundIntegrator::setStepSize(double size) {
integrators[currentIntegrator]->setStepSize(size);
}
double CompoundIntegrator::getConstraintTolerance() const {
return integrators[currentIntegrator]->getConstraintTolerance();
}
void CompoundIntegrator::setConstraintTolerance(double tol) {
integrators[currentIntegrator]->setConstraintTolerance(tol);
}
void CompoundIntegrator::step(int steps) {
integrators[currentIntegrator]->step(steps);
}
void CompoundIntegrator::initialize(ContextImpl& context) {
if (integrators.size() == 0)
throw OpenMMException("CompoundIntegrator must contain at least one Integrator");
for (int i = 0; i < integrators.size(); i++)
integrators[i]->initialize(context);
}
void CompoundIntegrator::cleanup() {
for (int i = 0; i < integrators.size(); i++)
integrators[i]->cleanup();
}
vector<string> CompoundIntegrator::getKernelNames() {
vector<string> kernels;
for (int i = 0; i < integrators.size(); i++) {
vector<string> integratorKernels = integrators[i]->getKernelNames();
kernels.insert(kernels.end(), integratorKernels.begin(), integratorKernels.end());
}
return kernels;
}
double CompoundIntegrator::computeKineticEnergy() {
return integrators[currentIntegrator]->computeKineticEnergy();
}
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,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-2013 Stanford University and the Authors. * * Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -114,21 +114,15 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const { ...@@ -114,21 +114,15 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
center *= 1.0/molecules[i].size(); center *= 1.0/molecules[i].size();
// Find the displacement to move it into the first periodic box. // Find the displacement to move it into the first periodic box.
Vec3 diff;
int xcell = (int) floor(center[0]/periodicBoxSize[0][0]); diff -= periodicBoxSize[0]*static_cast<int>(center[0]/periodicBoxSize[0][0]);
int ycell = (int) floor(center[1]/periodicBoxSize[1][1]); diff -= periodicBoxSize[1]*static_cast<int>(center[1]/periodicBoxSize[1][1]);
int zcell = (int) floor(center[2]/periodicBoxSize[2][2]); diff -= periodicBoxSize[2]*static_cast<int>(center[2]/periodicBoxSize[2][2]);
double dx = xcell*periodicBoxSize[0][0];
double dy = ycell*periodicBoxSize[1][1];
double dz = zcell*periodicBoxSize[2][2];
// Translate all the particles in the molecule. // Translate all the particles in the molecule.
for (int j = 0; j < (int) molecules[i].size(); j++) { for (int j = 0; j < (int) molecules[i].size(); j++) {
Vec3& pos = positions[molecules[i][j]]; Vec3& pos = positions[molecules[i][j]];
pos[0] -= dx; pos -= diff;
pos[1] -= dy;
pos[2] -= dz;
} }
} }
} }
...@@ -207,6 +201,10 @@ void Context::setVelocitiesToTemperature(double temperature, int randomSeed) { ...@@ -207,6 +201,10 @@ void Context::setVelocitiesToTemperature(double temperature, int randomSeed) {
impl->applyVelocityConstraints(1e-5); impl->applyVelocityConstraints(1e-5);
} }
const map<string, double>& Context::getParameters() const {
return impl->getParameters();
}
double Context::getParameter(const string& name) const { double Context::getParameter(const string& name) const {
return impl->getParameter(name); return impl->getParameter(name);
} }
......
...@@ -263,9 +263,9 @@ void CustomNonbondedForce::setFunctionParameters(int index, const std::string& n ...@@ -263,9 +263,9 @@ void CustomNonbondedForce::setFunctionParameters(int index, const std::string& n
int CustomNonbondedForce::addInteractionGroup(const std::set<int>& set1, const std::set<int>& set2) { int CustomNonbondedForce::addInteractionGroup(const std::set<int>& set1, const std::set<int>& set2) {
for (set<int>::iterator it = set1.begin(); it != set1.end(); ++it) for (set<int>::iterator it = set1.begin(); it != set1.end(); ++it)
ASSERT_VALID_INDEX(*it, particles); ASSERT(*it >= 0);
for (set<int>::iterator it = set2.begin(); it != set2.end(); ++it) for (set<int>::iterator it = set2.begin(); it != set2.end(); ++it)
ASSERT_VALID_INDEX(*it, particles); ASSERT(*it >= 0);
interactionGroups.push_back(InteractionGroupInfo(set1, set2)); interactionGroups.push_back(InteractionGroupInfo(set1, set2));
return interactionGroups.size()-1; return interactionGroups.size()-1;
} }
......
...@@ -111,6 +111,26 @@ void CustomNonbondedForceImpl::initialize(ContextImpl& context) { ...@@ -111,6 +111,26 @@ void CustomNonbondedForceImpl::initialize(ContextImpl& context) {
if (cutoff > 0.5*boxVectors[0][0] || cutoff > 0.5*boxVectors[1][1] || cutoff > 0.5*boxVectors[2][2]) if (cutoff > 0.5*boxVectors[0][0] || cutoff > 0.5*boxVectors[1][1] || cutoff > 0.5*boxVectors[2][2])
throw OpenMMException("CustomNonbondedForce: The cutoff distance cannot be greater than half the periodic box size."); throw OpenMMException("CustomNonbondedForce: The cutoff distance cannot be greater than half the periodic box size.");
} }
// Check that all interaction groups only specify particles that have been defined.
for (int group = 0; group < owner.getNumInteractionGroups(); group++) {
set<int> set1, set2;
owner.getInteractionGroupParameters(group, set1, set2);
for (set<int>::iterator it = set1.begin(); it != set1.end(); ++it)
if ((*it < 0) || (*it >= owner.getNumParticles())) {
stringstream msg;
msg << "CustomNonbondedForce: Interaction group " << group << " set1 contains a particle index (" << *it << ") "
<< "not present in system (" << owner.getNumParticles() << " particles).";
throw OpenMMException(msg.str());
}
for (set<int>::iterator it = set2.begin(); it != set2.end(); ++it)
if ((*it < 0) || (*it >= owner.getNumParticles())) {
stringstream msg;
msg << "CustomNonbondedForce: Interaction group " << group << " set2 contains a particle index (" << *it << ") "
<< "not present in system (" << owner.getNumParticles() << " particles).";
throw OpenMMException(msg.str());
}
}
kernel.getAs<CalcCustomNonbondedForceKernel>().initialize(context.getSystem(), owner); kernel.getAs<CalcCustomNonbondedForceKernel>().initialize(context.getSystem(), owner);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,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) 2013 Stanford University and the Authors. * * Portions copyright (c) 2013-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -47,3 +47,19 @@ Integrator::~Integrator() { ...@@ -47,3 +47,19 @@ Integrator::~Integrator() {
context->integratorDeleted(); context->integratorDeleted();
} }
} }
double Integrator::getStepSize() const {
return stepSize;
}
void Integrator::setStepSize(double size) {
stepSize = size;
}
double Integrator::getConstraintTolerance() const {
return constraintTol;
}
void Integrator::setConstraintTolerance(double tol) {
constraintTol = tol;
}
/* -------------------------------------------------------------------------- *
* 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) 2015 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 "CpuTests.h"
#include "TestCompoundIntegrator.h"
void runPlatformTests() {
}
...@@ -62,6 +62,14 @@ public: ...@@ -62,6 +62,14 @@ public:
CudaArray& getStepSize() { CudaArray& getStepSize() {
return *stepSize; return *stepSize;
} }
/**
* Set the size to use for the next step.
*/
void setNextStepSize(double size);
/**
* Get the size that was used for the last step.
*/
double getLastStepSize();
/** /**
* Apply constraints to the atom positions. * Apply constraints to the atom positions.
* *
...@@ -154,6 +162,7 @@ private: ...@@ -154,6 +162,7 @@ private:
CudaArray* vsiteLocalCoordsParams; CudaArray* vsiteLocalCoordsParams;
int randomPos; int randomPos;
int lastSeed, numVsites; int lastSeed, numVsites;
double2 lastStepSize;
struct ShakeCluster; struct ShakeCluster;
struct ConstraintOrderer; struct ConstraintOrderer;
}; };
......
...@@ -592,7 +592,7 @@ class CudaCalcNonbondedForceKernel : public CalcNonbondedForceKernel { ...@@ -592,7 +592,7 @@ class CudaCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
public: public:
CudaCalcNonbondedForceKernel(std::string name, const Platform& platform, CudaContext& cu, const System& system) : CalcNonbondedForceKernel(name, platform), CudaCalcNonbondedForceKernel(std::string name, const Platform& platform, CudaContext& cu, const System& system) : CalcNonbondedForceKernel(name, platform),
cu(cu), hasInitializedFFT(false), sigmaEpsilon(NULL), exceptionParams(NULL), cosSinSums(NULL), directPmeGrid(NULL), reciprocalPmeGrid(NULL), cu(cu), hasInitializedFFT(false), sigmaEpsilon(NULL), exceptionParams(NULL), cosSinSums(NULL), directPmeGrid(NULL), reciprocalPmeGrid(NULL),
pmeBsplineModuliX(NULL), pmeBsplineModuliY(NULL), pmeBsplineModuliZ(NULL), pmeAtomRange(NULL), pmeAtomGridIndex(NULL), sort(NULL), fft(NULL), pmeio(NULL) { pmeBsplineModuliX(NULL), pmeBsplineModuliY(NULL), pmeBsplineModuliZ(NULL), pmeAtomRange(NULL), pmeAtomGridIndex(NULL), pmeEnergyBuffer(NULL), sort(NULL), fft(NULL), pmeio(NULL) {
} }
~CudaCalcNonbondedForceKernel(); ~CudaCalcNonbondedForceKernel();
/** /**
...@@ -657,6 +657,7 @@ private: ...@@ -657,6 +657,7 @@ private:
CudaArray* pmeBsplineModuliZ; CudaArray* pmeBsplineModuliZ;
CudaArray* pmeAtomRange; CudaArray* pmeAtomRange;
CudaArray* pmeAtomGridIndex; CudaArray* pmeAtomGridIndex;
CudaArray* pmeEnergyBuffer;
CudaSort* sort; CudaSort* sort;
Kernel cpuPme; Kernel cpuPme;
PmeIO* pmeio; PmeIO* pmeio;
...@@ -1123,7 +1124,6 @@ public: ...@@ -1123,7 +1124,6 @@ public:
double computeKineticEnergy(ContextImpl& context, const VerletIntegrator& integrator); double computeKineticEnergy(ContextImpl& context, const VerletIntegrator& integrator);
private: private:
CudaContext& cu; CudaContext& cu;
double prevStepSize;
CUfunction kernel1, kernel2; CUfunction kernel1, kernel2;
}; };
...@@ -1354,7 +1354,7 @@ private: ...@@ -1354,7 +1354,7 @@ private:
void recordChangedParameters(ContextImpl& context); void recordChangedParameters(ContextImpl& context);
bool evaluateCondition(int step); bool evaluateCondition(int step);
CudaContext& cu; CudaContext& cu;
double prevStepSize, energy; double energy;
float energyFloat; float energyFloat;
int numGlobalVariables; int numGlobalVariables;
bool hasInitializedKernels, deviceValuesAreCurrent, deviceGlobalsAreCurrent, modifiesParameters, keNeedsForce, hasAnyConstraints; bool hasInitializedKernels, deviceValuesAreCurrent, deviceGlobalsAreCurrent, modifiesParameters, keNeedsForce, hasAnyConstraints;
......
...@@ -121,7 +121,7 @@ public: ...@@ -121,7 +121,7 @@ public:
ContextImpl* context; ContextImpl* context;
std::vector<CudaContext*> contexts; std::vector<CudaContext*> contexts;
std::vector<double> contextEnergy; std::vector<double> contextEnergy;
bool removeCM, peerAccessSupported, useCpuPme; bool hasInitializedContexts, removeCM, peerAccessSupported, useCpuPme;
int cmMotionFrequency; int cmMotionFrequency;
int stepCount, computeForceCount; int stepCount, computeForceCount;
double time; double time;
......
...@@ -106,21 +106,21 @@ CudaIntegrationUtilities::CudaIntegrationUtilities(CudaContext& context, const S ...@@ -106,21 +106,21 @@ CudaIntegrationUtilities::CudaIntegrationUtilities(CudaContext& context, const S
vsiteOutOfPlaneAtoms(NULL), vsiteOutOfPlaneWeights(NULL), vsiteLocalCoordsAtoms(NULL), vsiteLocalCoordsParams(NULL) { vsiteOutOfPlaneAtoms(NULL), vsiteOutOfPlaneWeights(NULL), vsiteLocalCoordsAtoms(NULL), vsiteLocalCoordsParams(NULL) {
// Create workspace arrays. // Create workspace arrays.
lastStepSize = make_double2(0.0, 0.0);
if (context.getUseDoublePrecision() || context.getUseMixedPrecision()) { if (context.getUseDoublePrecision() || context.getUseMixedPrecision()) {
posDelta = CudaArray::create<double4>(context, context.getPaddedNumAtoms(), "posDelta"); posDelta = CudaArray::create<double4>(context, context.getPaddedNumAtoms(), "posDelta");
vector<double4> deltas(posDelta->getSize(), make_double4(0.0, 0.0, 0.0, 0.0)); vector<double4> deltas(posDelta->getSize(), make_double4(0.0, 0.0, 0.0, 0.0));
posDelta->upload(deltas); posDelta->upload(deltas);
stepSize = CudaArray::create<double2>(context, 1, "stepSize"); stepSize = CudaArray::create<double2>(context, 1, "stepSize");
vector<double2> step(1, make_double2(0.0, 0.0)); stepSize->upload(&lastStepSize);
stepSize->upload(step);
} }
else { else {
posDelta = CudaArray::create<float4>(context, context.getPaddedNumAtoms(), "posDelta"); posDelta = CudaArray::create<float4>(context, context.getPaddedNumAtoms(), "posDelta");
vector<float4> deltas(posDelta->getSize(), make_float4(0.0f, 0.0f, 0.0f, 0.0f)); vector<float4> deltas(posDelta->getSize(), make_float4(0.0f, 0.0f, 0.0f, 0.0f));
posDelta->upload(deltas); posDelta->upload(deltas);
stepSize = CudaArray::create<float2>(context, 1, "stepSize"); stepSize = CudaArray::create<float2>(context, 1, "stepSize");
vector<float2> step(1, make_float2(0.0f, 0.0f)); float2 lastStepSizeFloat = make_float2(0.0f, 0.0f);
stepSize->upload(step); stepSize->upload(&lastStepSizeFloat);
} }
// Record the set of constraints and how many constraints each atom is involved in. // Record the set of constraints and how many constraints each atom is involved in.
...@@ -650,6 +650,29 @@ CudaIntegrationUtilities::~CudaIntegrationUtilities() { ...@@ -650,6 +650,29 @@ CudaIntegrationUtilities::~CudaIntegrationUtilities() {
delete vsiteLocalCoordsParams; delete vsiteLocalCoordsParams;
} }
void CudaIntegrationUtilities::setNextStepSize(double size) {
if (size != lastStepSize.x || size != lastStepSize.y) {
lastStepSize = make_double2(size, size);
if (context.getUseDoublePrecision() || context.getUseMixedPrecision())
stepSize->upload(&lastStepSize);
else {
float2 lastStepSizeFloat = make_float2((float) size, (float) size);
stepSize->upload(&lastStepSizeFloat);
}
}
}
double CudaIntegrationUtilities::getLastStepSize() {
if (context.getUseDoublePrecision() || context.getUseMixedPrecision())
stepSize->download(&lastStepSize);
else {
float2 lastStepSizeFloat;
stepSize->download(&lastStepSizeFloat);
lastStepSize = make_double2(lastStepSizeFloat.x, lastStepSizeFloat.y);
}
return lastStepSize.y;
}
void CudaIntegrationUtilities::applyConstraints(double tol) { void CudaIntegrationUtilities::applyConstraints(double tol) {
applyConstraints(false, tol); applyConstraints(false, tol);
} }
......
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