Commit 1c938ceb authored by Jason Swails's avatar Jason Swails
Browse files

Merge branch 'master' into amber-switching

 Conflicts:
	wrappers/python/simtk/openmm/app/amberprmtopfile.py

In fixing the merge conflict, I went ahead and fixed up the switchDistance logic
to match what I did in CharmmPsfFile.
parents a1113e7b 167ae8a0
......@@ -170,7 +170,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -185,8 +185,8 @@ public:
* Get the force field parameters for a force field term.
*
* @param index the index of the particle term for which to get parameters
* @param particle the index of the particle this term is applied to
* @param parameters the list of parameters for the force field term
* @param[out] particle the index of the particle this term is applied to
* @param[out] parameters the list of parameters for the force field term
*/
void getParticleParameters(int index, int& particle, std::vector<double>& parameters) const;
/**
......
......@@ -309,7 +309,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -324,7 +324,7 @@ public:
* Get the nonbonded force parameters for a particle.
*
* @param index the index of the particle for which to get parameters
* @param parameters the list of parameters for the specified particle
* @param[out] parameters the list of parameters for the specified particle
*/
void getParticleParameters(int index, std::vector<double>& parameters) const;
/**
......@@ -355,8 +355,8 @@ public:
* Get the properties of a computed value.
*
* @param index the index of the computed value for which to get parameters
* @param name the name of the value
* @param expression an algebraic expression to evaluate when calculating the computed value. If the
* @param[out] name the name of the value
* @param[out] expression an algebraic expression to evaluate when calculating the computed value. If the
* ComputationType is SingleParticle, the expression is evaluated independently
* for each particle, and may depend on its x, y, and z coordinates, as well as the per-particle
* parameters and previous computed values for that particle. If the ComputationType is ParticlePair
......@@ -366,7 +366,7 @@ public:
* the per-particle parameters and previous computed values for each of them.
* Append "1" to a variable name to indicate the parameter for the particle whose
* value is being calculated, and "2" to indicate the particle it is interacting with.
* @param type the method to use for computing this value
* @param[out] type the method to use for computing this value
*/
void getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType& type) const;
/**
......@@ -407,7 +407,7 @@ public:
* Get the properties of a term to the energy computation.
*
* @param index the index of the term for which to get parameters
* @param expression an algebraic expression to evaluate when calculating the energy. If the
* @param[out] expression an algebraic expression to evaluate when calculating the energy. If the
* ComputationType is SingleParticle, the expression is evaluated once
* for each particle, and may depend on its x, y, and z coordinates, as well as the per-particle
* parameters and computed values for that particle. If the ComputationType is ParticlePair or
......@@ -417,7 +417,7 @@ public:
* the per-particle parameters and computed values for each of them.
* Append "1" to a variable name to indicate the parameter for the first particle
* in the pair and "2" to indicate the second particle in the pair.
* @param type the method to use for computing this value
* @param[out] type the method to use for computing this value
*/
void getEnergyTermParameters(int index, std::string& expression, ComputationType& type) const;
/**
......@@ -449,8 +449,8 @@ public:
* Get the particles in a pair whose interaction should be excluded.
*
* @param index the index of the exclusion for which to get particle indices
* @param particle1 the index of the first particle in the pair
* @param particle2 the index of the second particle in the pair
* @param[out] particle1 the index of the first particle in the pair
* @param[out] particle2 the index of the second particle in the pair
*/
void getExclusionParticles(int index, int& particle1, int& particle2) const;
/**
......
......@@ -282,7 +282,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -301,12 +301,12 @@ public:
* Get the properties of a donor group.
*
* @param index the index of the donor group to get
* @param d1 the index of the first particle for this donor group
* @param d2 the index of the second particle for this donor group. If the group only
* @param[out] d1 the index of the first particle for this donor group
* @param[out] d2 the index of the second particle for this donor group. If the group only
* includes one particle, this will be -1.
* @param d3 the index of the third particle for this donor group. If the group includes
* @param[out] d3 the index of the third particle for this donor group. If the group includes
* less than three particles, this will be -1.
* @param parameters the list of per-donor parameter values for the donor
* @param[out] parameters the list of per-donor parameter values for the donor
*/
void getDonorParameters(int index, int& d1, int& d2, int& d3, std::vector<double>& parameters) const;
/**
......@@ -337,12 +337,12 @@ public:
* Get the properties of an acceptor group.
*
* @param index the index of the acceptor group to get
* @param a1 the index of the first particle for this acceptor group
* @param a2 the index of the second particle for this acceptor group. If the group only
* @param[out] a1 the index of the first particle for this acceptor group
* @param[out] a2 the index of the second particle for this acceptor group. If the group only
* includes one particle, this will be -1.
* @param a3 the index of the third particle for this acceptor group. If the group includes
* @param[out] a3 the index of the third particle for this acceptor group. If the group includes
* less than three particles, this will be -1.
* @param parameters the list of per-acceptor parameter values for the acceptor
* @param[out] parameters the list of per-acceptor parameter values for the acceptor
*/
void getAcceptorParameters(int index, int& a1, int& a2, int& a3, std::vector<double>& parameters) const;
/**
......@@ -369,16 +369,16 @@ public:
* Get the donor and acceptor in a pair whose interaction should be excluded.
*
* @param index the index of the exclusion for which to get donor and acceptor indices
* @param particle1 the index of the donor
* @param particle2 the index of the acceptor
* @param[out] particle1 the index of the donor
* @param[out] particle2 the index of the acceptor
*/
void getExclusionParticles(int index, int& donor, int& acceptor) const;
/**
* Get the donor and acceptor in a pair whose interaction should be excluded.
*
* @param index the index of the exclusion for which to get donor and acceptor indices
* @param particle1 the index of the donor
* @param particle2 the index of the acceptor
* @param donor the index of the donor
* @param acceptor the index of the acceptor
*/
void setExclusionParticles(int index, int donor, int acceptor);
/**
......
......@@ -371,7 +371,7 @@ public:
* Get the value of a per-DOF variable, specified by name.
*
* @param name the name of the variable to get
* @param values the values of the variable for all degrees of freedom
* @param[out] values the values of the variable for all degrees of freedom
* are stored into this
*/
void getPerDofVariableByName(const std::string& name, std::vector<Vec3>& values) const;
......@@ -446,7 +446,7 @@ public:
/**
* Add a step which begins a new "if" block.
*
* @param expression a mathematical expression involving a comparison operator
* @param condition a mathematical expression involving a comparison operator
* and global variables. All steps between this one and
* the end of the block are executed only if the condition
* is true.
......@@ -457,7 +457,7 @@ public:
/**
* Add a step which begins a new "while" block.
*
* @param expression a mathematical expression involving a comparison operator
* @param condition a mathematical expression involving a comparison operator
* and global variables. All steps between this one and
* the end of the block are executed repeatedly as long as
* the condition remains true.
......@@ -476,12 +476,13 @@ public:
* Get the details of a computation step that has been added to the integration algorithm.
*
* @param index the index of the computation step to get
* @param type on exit, the type of computation this step performs
* @param variable on exit, the variable into which this step stores its result. If this
* step does not store a result in a variable, this will be an
* empty string.
* @param expression on exit, the expression this step evaluates. If this step does not
* evaluate an expression, this will be an empty string.
* @param[out] type the type of computation this step performs
* @param[out] variable the variable into which this step stores its
* result. If this step does not store a result in
* a variable, this will be an empty string.
* @param[out] expression the expression this step evaluates. If
* this step does not evaluate an expression, this
* will be an empty string.
*/
void getComputationStep(int index, ComputationType& type, std::string& variable, std::string& expression) const;
/**
......
......@@ -337,7 +337,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -353,8 +353,8 @@ public:
* Get the nonbonded force parameters for a particle.
*
* @param index the index of the particle for which to get parameters
* @param parameters the list of parameters for the specified particle
* @param type the type of the specified particle
* @param[out] parameters the list of parameters for the specified particle
* @param[out] type the type of the specified particle
*/
void getParticleParameters(int index, std::vector<double>& parameters, int& type) const;
/**
......@@ -379,8 +379,8 @@ public:
* Get the particles in a pair whose interaction should be excluded.
*
* @param index the index of the exclusion for which to get particle indices
* @param particle1 the index of the first particle in the pair
* @param particle2 the index of the second particle in the pair
* @param[out] particle1 the index of the first particle in the pair
* @param[out] particle2 the index of the second particle in the pair
*/
void getExclusionParticles(int index, int& particle1, int& particle2) const;
/**
......@@ -406,7 +406,7 @@ public:
* regardless of the type of the specified particle.
*
* @param index the index of the particle within the interaction (between 0 and getNumParticlesPerSet())
* @param types the allowed types for the specified particle
* @param[out] types the allowed types for the specified particle
*/
void getTypeFilter(int index, std::set<int>& types) const;
/**
......
......@@ -318,7 +318,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -333,7 +333,7 @@ public:
* Get the nonbonded force parameters for a particle.
*
* @param index the index of the particle for which to get parameters
* @param parameters the list of parameters for the specified particle
* @param[out] parameters the list of parameters for the specified particle
*/
void getParticleParameters(int index, std::vector<double>& parameters) const;
/**
......@@ -357,8 +357,8 @@ public:
* Get the particles in a pair whose interaction should be excluded.
*
* @param index the index of the exclusion for which to get particle indices
* @param particle1 the index of the first particle in the pair
* @param particle2 the index of the second particle in the pair
* @param[out] particle1 the index of the first particle in the pair
* @param[out] particle2 the index of the second particle in the pair
*/
void getExclusionParticles(int index, int& particle1, int& particle2) const;
/**
......@@ -441,8 +441,8 @@ public:
* Get the parameters for an interaction group.
*
* @param index the index of the interaction group for which to get parameters
* @param set1 the first set of particles forming the interaction group
* @param set2 the second set of particles forming the interaction group
* @param[out] set1 the first set of particles forming the interaction group
* @param[out] set2 the second set of particles forming the interaction group
*/
void getInteractionGroupParameters(int index, std::set<int>& set1, std::set<int>& set2) const;
/**
......
......@@ -159,7 +159,7 @@ public:
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
* @param defaultValue the default value of the parameter
*/
void setGlobalParameterDefaultValue(int index, double defaultValue);
/**
......@@ -177,11 +177,11 @@ public:
* Get the force field parameters for a torsion term.
*
* @param index the index of the torsion for which to get parameters
* @param particle1 the index of the first particle connected by the torsion
* @param particle2 the index of the second particle connected by the torsion
* @param particle3 the index of the third particle connected by the torsion
* @param particle4 the index of the fourth particle connected by the torsion
* @param parameters the list of parameters for the torsion
* @param[out] particle1 the index of the first particle connected by the torsion
* @param[out] particle2 the index of the second particle connected by the torsion
* @param[out] particle3 the index of the third particle connected by the torsion
* @param[out] particle4 the index of the fourth particle connected by the torsion
* @param[out] parameters the list of parameters for the torsion
*/
void getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, std::vector<double>& parameters) const;
/**
......
......@@ -100,9 +100,9 @@ public:
* Get the force field parameters for a particle.
*
* @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 radius the GBSA radius of the particle, measured in nm
* @param scalingFactor the OBC scaling factor for the particle
* @param[out] charge the charge of the particle, measured in units of the proton charge
* @param[out] radius the GBSA radius of the particle, measured in nm
* @param[out] scalingFactor the OBC scaling factor for the particle
*/
void getParticleParameters(int index, double& charge, double& radius, double& scalingFactor) const;
/**
......
#ifndef OPENMM_GBVIFORCEFIELD_H_
#define OPENMM_GBVIFORCEFIELD_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) 2008-2009 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 <vector>
#include "internal/windowsExport.h"
namespace OpenMM {
/**
* This class implements an implicit solvation force using the GB/VI model.
* <p>
* To use this class, create a GBVIForce object, then call addParticle() once for each particle in the
* System to define its parameters. The number of particles for which you define GB/VI parameters must
* 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
* 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.
*/
class OPENMM_EXPORT GBVIForce : public Force {
public:
/**
* This is an enumeration of the different methods that may be used for handling long range nonbonded forces.
*/
enum NonbondedMethod {
/**
* No cutoff is applied to nonbonded interactions. The full set of N^2 interactions is computed exactly.
* This necessarily means that periodic boundary conditions cannot be used. This is the default.
*/
NoCutoff = 0,
/**
* Interactions beyond the cutoff distance are ignored.
*/
CutoffNonPeriodic = 1,
/**
* Periodic boundary conditions are used, so that each particle interacts only with the nearest periodic copy of
* each other particle. Interactions beyond the cutoff distance are ignored.
*/
CutoffPeriodic = 2,
};
/**
* This is an enumeration of the different methods that may be used for scaling of the Born radii.
*/
enum BornRadiusScalingMethod {
/**
* No scaling method is applied.
*/
NoScaling = 0,
/**
* Use quintic spline scaling function
*/
QuinticSpline = 1
};
/*
* Create a GBVIForce.
*/
GBVIForce();
/**
* Get the number of particles in the system.
*/
int getNumParticles() const {
return particles.size();
}
/**
* Add the GB/VI parameters for a particle. This should be called once for each particle
* in the System. When it is called for the i'th time, it specifies the parameters for the i'th particle.
*
* @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 gamma the gamma parameter
* @return the index of the particle that was added
*/
int addParticle(double charge, double radius, double gamma);
/**
* Get the force field parameters for a particle.
*
* @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 radius the GBSA radius of the particle, measured in nm
* @param gamma the gamma parameter
*/
void getParticleParameters(int index, double& charge, double& radius, double& gamma) const;
/**
* Set the force field parameters for a particle.
*
* @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 radius the GB/VI radius of the particle, measured in nm
* @param gamma the gamma parameter
*/
void setParticleParameters(int index, double charge, double radius, double gamma);
/**
* Add a bond
*
* @param particle1 the index of the first particle
* @param particle2 the index of the second particle
* @param distance the distance between the two particles, measured in nm
* @return the index of the bond that was added
*/
int addBond(int particle1, int particle2, double distance);
/**
* Get the parameters defining a bond
*
* @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 particle2 the index of the second particle involved in the bond
* @param distance the distance between the two particles, measured in nm
*/
void getBondParameters(int index, int& particle1, int& particle2, double& distance) const;
/**
* Set 1-2 bonds
*
* @param index index of the bond for which to set parameters
* @param particle1 index of first atom in bond
* @param particle2 index of second atom in bond
* @param bondLength bond length, measured in nm
*/
void setBondParameters( int index, int particle1, int particle2, double bondLength);
/**
* Get number of bonds
*
* @return number of bonds
*/
int getNumBonds() const;
/**
* Get the dielectric constant for the solvent.
*/
double getSolventDielectric() const {
return solventDielectric;
}
/**
* Set the dielectric constant for the solvent.
*/
void setSolventDielectric(double dielectric) {
solventDielectric = dielectric;
}
/**
* Get the dielectric constant for the solute.
*/
double getSoluteDielectric() const {
return soluteDielectric;
}
/**
* Set the dielectric constant for the solute.
*/
void setSoluteDielectric(double dielectric) {
soluteDielectric = dielectric;
}
/**
* Get the method used for handling long range nonbonded interactions.
*/
NonbondedMethod getNonbondedMethod() const;
/**
* Set the method used for handling long range nonbonded interactions.
*/
void setNonbondedMethod(NonbondedMethod method);
/**
* Get the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use
* is NoCutoff, this value will have no effect.
*
* @return the cutoff distance, measured in nm
*/
double getCutoffDistance() const;
/**
* Set the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use
* is NoCutoff, this value will have no effect.
*
* @param distance the cutoff distance, measured in nm
*/
void setCutoffDistance(double distance);
/**
* Get Born radius scaling method
*/
BornRadiusScalingMethod getBornRadiusScalingMethod() const;
/**
* Set Born radius scaling method
*/
void setBornRadiusScalingMethod( BornRadiusScalingMethod method);
/**
* Get the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8)
*/
double getQuinticLowerLimitFactor() const;
/**
* Set the lower limit factor used in the quintic spline scaling method (typically 0.5-0.8)
*/
void setQuinticLowerLimitFactor(double quinticLowerLimitFactor );
/**
* Get the upper limit used in the quintic spline scaling method, measured in nm (~5.0)
*/
double getQuinticUpperBornRadiusLimit() const;
/**
* Set the upper limit used in the quintic spline scaling method, measured in nm (~5.0)
*/
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:
ForceImpl* createImpl() const;
private:
class ParticleInfo;
NonbondedMethod nonbondedMethod;
double cutoffDistance, solventDielectric, soluteDielectric;
BornRadiusScalingMethod scalingMethod;
double quinticLowerLimitFactor, quinticUpperBornRadiusLimit;
class BondInfo;
std::vector<ParticleInfo> particles;
std::vector<BondInfo> bonds;
};
/**
* This is an internal class used to record information about a particle.
* @private
*/
class GBVIForce::ParticleInfo {
public:
double charge, radius, gamma;
ParticleInfo() {
charge = radius = gamma = 0.0;
}
ParticleInfo(double charge, double radius, double gamma) :
charge(charge), radius(radius), gamma(gamma) {
}
};
/**
* This is an internal class used to record information about a bond.
* @private
*/
class GBVIForce::BondInfo {
public:
int particle1, particle2;
double bondLength;
BondInfo() {
bondLength = 0.0;
particle1 = -1;
particle2 = -1;
}
BondInfo(int atomIndex1, int atomIndex2, double bondLength) :
particle1(atomIndex1), particle2(atomIndex2), bondLength(bondLength) {
}
};
} // namespace OpenMM
#endif /*OPENMM_GBVIFORCEFIELD_H_*/
......@@ -74,11 +74,11 @@ public:
* Get the force field parameters for an angle term.
*
* @param index the index of the angle for which to get parameters
* @param particle1 the index of the first particle forming the angle
* @param particle2 the index of the second particle forming the angle
* @param particle3 the index of the third particle forming the angle
* @param angle the equilibrium angle, measured in radians
* @param k the harmonic force constant for the angle, measured in kJ/mol/radian^2
* @param[out] particle1 the index of the first particle forming the angle
* @param[out] particle2 the index of the second particle forming the angle
* @param[out] particle3 the index of the third particle forming the angle
* @param[out] angle the equilibrium angle, measured in radians
* @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;
/**
......
......@@ -73,10 +73,10 @@ public:
* Get the force field parameters for a bond term.
*
* @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 particle2 the index of the second particle connected by the bond
* @param 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] particle1 the index of the first particle connected by the bond
* @param[out] particle2 the index of the second particle connected by the bond
* @param[out] length the equilibrium length of the bond, measured in nm
* @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;
/**
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* 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 *
* Contributors: *
* *
......@@ -61,30 +61,22 @@ public:
*
* @return the step size, measured in ps
*/
double getStepSize() const {
return stepSize;
}
virtual double getStepSize() const;
/**
* 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.
*
* @param size the step size, measured in ps
*/
void setStepSize(double size) {
stepSize = size;
}
virtual void setStepSize(double size);
/**
* Get the distance tolerance within which constraints are maintained, as a fraction of the constrained distance.
*/
double getConstraintTolerance() const {
return constraintTol;
}
virtual double getConstraintTolerance() const;
/**
* Set the distance tolerance within which constraints are maintained, as a fraction of the constrained distance.
*/
void setConstraintTolerance(double tol) {
constraintTol = tol;
}
virtual void setConstraintTolerance(double tol);
/**
* Advance a simulation through time by taking a series of time steps.
*
......@@ -94,6 +86,7 @@ public:
protected:
friend class Context;
friend class ContextImpl;
friend class CompoundIntegrator;
ContextImpl* context;
Context* owner;
/**
......
......@@ -201,10 +201,10 @@ public:
* 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.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
* @param[out] alpha the separation parameter
* @param[out] nx the number of grid points along the X axis
* @param[out] ny the number of grid points along the Y axis
* @param[out] nz the number of grid points along the Z axis
*/
void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/**
......@@ -224,10 +224,10 @@ public:
* See the manual for details.
*
* @param context the Context for which to get the parameters
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
* @param[out] alpha the separation parameter
* @param[out] nx the number of grid points along the X axis
* @param[out] ny the number of grid points along the Y 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;
/**
......@@ -247,9 +247,9 @@ public:
* Get the nonbonded force parameters for a particle.
*
* @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 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] charge the charge of the particle, measured in units of the proton charge
* @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[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;
/**
......@@ -284,11 +284,11 @@ public:
* 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 particle1 the index of the first particle involved in the interaction
* @param 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 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] particle1 the index of the first particle involved in the interaction
* @param[out] particle2 the index of the second particle involved in the interaction
* @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[out] sigma the sigma parameter of the Lennard-Jones potential (corresponding to the van der Waals radius of the particle), measured in nm
* @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;
/**
......
......@@ -76,13 +76,13 @@ public:
* Get the force field parameters for a periodic torsion term.
*
* @param index the index of the torsion for which to get parameters
* @param particle1 the index of the first particle forming the torsion
* @param particle2 the index of the second particle forming the torsion
* @param particle3 the index of the third particle forming the torsion
* @param particle4 the index of the fourth particle forming the torsion
* @param periodicity the periodicity of the torsion
* @param phase the phase offset of the torsion, measured in radians
* @param k the force constant for the torsion
* @param[out] particle1 the index of the first particle forming the torsion
* @param[out] particle2 the index of the second particle forming the torsion
* @param[out] particle3 the index of the third particle forming the torsion
* @param[out] particle4 the index of the fourth particle forming the torsion
* @param[out] periodicity the periodicity of the torsion
* @param[out] phase the phase offset of the torsion, measured in radians
* @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;
/**
......
......@@ -79,16 +79,16 @@ public:
* Get the force field parameters for a Ryckaert-Bellemans torsion term.
*
* @param index the index of the torsion for which to get parameters
* @param particle1 the index of the first particle forming the torsion
* @param particle2 the index of the second particle forming the torsion
* @param particle3 the index of the third particle forming the torsion
* @param particle4 the index of the fourth particle forming the torsion
* @param 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 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 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] particle1 the index of the first particle forming the torsion
* @param[out] particle2 the index of the second particle forming the torsion
* @param[out] particle3 the index of the third particle forming the torsion
* @param[out] particle4 the index of the fourth particle forming the torsion
* @param[out] c0 the coefficient of the constant term, measured in kJ/mol
* @param[out] c1 the coefficient of the 1st order term, measured in kJ/mol
* @param[out] c2 the coefficient of the 2nd order term, measured in kJ/mol
* @param[out] c3 the coefficient of the 3rd order term, measured in kJ/mol
* @param[out] c4 the coefficient of the 4th 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;
/**
......
......@@ -95,9 +95,9 @@ public:
/**
* 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 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[out] a the vector defining the first edge of the periodic box
* @param[out] b the vector defining the second 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;
/**
......
......@@ -153,9 +153,9 @@ public:
* Get the parameters defining a distance constraint.
*
* @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 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] particle1 the index of the first particle involved in the constraint
* @param[out] particle2 the index of the second particle involved in the constraint
* @param[out] distance the required distance between the two particles, measured in nm
*/
void getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const;
/**
......@@ -216,9 +216,9 @@ public:
* created Context will have its box vectors set to these. They will affect
* 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 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[out] a the vector defining the first edge of the periodic box
* @param[out] b the vector defining the second 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;
/**
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -29,101 +29,97 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/Force.h"
#include "openmm/CompoundIntegrator.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/GBVIForce.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/internal/GBVIForceImpl.h"
#include <sstream>
#include "openmm/kernels.h"
#include <string>
using namespace OpenMM;
using namespace std;
GBVIForce::GBVIForce() : nonbondedMethod(NoCutoff), cutoffDistance(1.0), solventDielectric(78.3), soluteDielectric(1.0),
scalingMethod(QuinticSpline), quinticLowerLimitFactor(0.8), quinticUpperBornRadiusLimit(5.0) {
CompoundIntegrator::CompoundIntegrator() : currentIntegrator(0) {
}
int GBVIForce::addParticle(double charge, double radius, double gamma) {
particles.push_back(ParticleInfo(charge, radius, gamma));
return particles.size()-1;
CompoundIntegrator::~CompoundIntegrator() {
for (int i = 0; i < integrators.size(); i++)
delete integrators[i];
}
void GBVIForce::getParticleParameters(int index, double& charge, double& radius, double& gamma) const {
ASSERT_VALID_INDEX(index, particles);
charge = particles[index].charge;
radius = particles[index].radius;
gamma = particles[index].gamma;
int CompoundIntegrator::getNumIntegrators() const {
return integrators.size();
}
void GBVIForce::setParticleParameters(int index, double charge, double radius, double gamma) {
ASSERT_VALID_INDEX(index, particles);
particles[index].charge = charge;
particles[index].radius = radius;
particles[index].gamma = gamma;
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;
}
GBVIForce::NonbondedMethod GBVIForce::getNonbondedMethod() const {
return nonbondedMethod;
Integrator& CompoundIntegrator::getIntegrator(int index) {
ASSERT_VALID_INDEX(index, integrators);
return *integrators[index];
}
void GBVIForce::setNonbondedMethod(NonbondedMethod method) {
nonbondedMethod = method;
const Integrator& CompoundIntegrator::getIntegrator(int index) const {
ASSERT_VALID_INDEX(index, integrators);
return *integrators[index];
}
double GBVIForce::getCutoffDistance() const {
return cutoffDistance;
int CompoundIntegrator::getCurrentIntegrator() const {
return currentIntegrator;
}
void GBVIForce::setCutoffDistance(double distance) {
cutoffDistance = distance;
void CompoundIntegrator::setCurrentIntegrator(int index) {
if (index < 0 || index >= integrators.size())
throw OpenMMException("Illegal index for setCurrentIntegrator()");
currentIntegrator = index;
}
GBVIForce::BornRadiusScalingMethod GBVIForce::getBornRadiusScalingMethod() const {
return scalingMethod;
double CompoundIntegrator::getStepSize() const {
return integrators[currentIntegrator]->getStepSize();
}
void GBVIForce::setBornRadiusScalingMethod(BornRadiusScalingMethod method) {
scalingMethod = method;
void CompoundIntegrator::setStepSize(double size) {
integrators[currentIntegrator]->setStepSize(size);
}
double GBVIForce::getQuinticLowerLimitFactor() const {
return quinticLowerLimitFactor;
double CompoundIntegrator::getConstraintTolerance() const {
return integrators[currentIntegrator]->getConstraintTolerance();
}
void GBVIForce::setQuinticLowerLimitFactor(double inputQuinticLowerLimitFactor ){
quinticLowerLimitFactor = inputQuinticLowerLimitFactor;
void CompoundIntegrator::setConstraintTolerance(double tol) {
integrators[currentIntegrator]->setConstraintTolerance(tol);
}
double GBVIForce::getQuinticUpperBornRadiusLimit() const {
return quinticUpperBornRadiusLimit;
void CompoundIntegrator::step(int steps) {
integrators[currentIntegrator]->step(steps);
}
void GBVIForce::setQuinticUpperBornRadiusLimit(double inputQuinticUpperBornRadiusLimit){
quinticUpperBornRadiusLimit = inputQuinticUpperBornRadiusLimit;
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);
}
int GBVIForce::addBond(int particle1, int particle2, double bondLength) {
bonds.push_back(BondInfo(particle1, particle2, bondLength));
return bonds.size()-1;
void CompoundIntegrator::cleanup() {
for (int i = 0; i < integrators.size(); i++)
integrators[i]->cleanup();
}
void GBVIForce::setBondParameters( int index, int particle1, int particle2, double bondLength) {
ASSERT_VALID_INDEX(index, bonds);
bonds[index].particle1 = particle1;
bonds[index].particle2 = particle2;
bonds[index].bondLength = bondLength;
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;
}
int GBVIForce::getNumBonds() const {
return (int) bonds.size();
}
void GBVIForce::getBondParameters(int index, int& bondIndex1, int& bondIndex2, double& bondLength) const {
ASSERT_VALID_INDEX(index, bonds);
bondIndex1 = bonds[index].particle1;
bondIndex2 = bonds[index].particle2;
bondLength = bonds[index].bondLength;
}
ForceImpl* GBVIForce::createImpl() const {
return new GBVIForceImpl(*this);
double CompoundIntegrator::computeKineticEnergy() {
return integrators[currentIntegrator]->computeKineticEnergy();
}
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* 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 *
* Contributors: *
* *
......@@ -114,21 +114,15 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
center *= 1.0/molecules[i].size();
// Find the displacement to move it into the first periodic box.
int xcell = (int) floor(center[0]/periodicBoxSize[0][0]);
int ycell = (int) floor(center[1]/periodicBoxSize[1][1]);
int zcell = (int) floor(center[2]/periodicBoxSize[2][2]);
double dx = xcell*periodicBoxSize[0][0];
double dy = ycell*periodicBoxSize[1][1];
double dz = zcell*periodicBoxSize[2][2];
Vec3 diff;
diff -= periodicBoxSize[0]*static_cast<int>(center[0]/periodicBoxSize[0][0]);
diff -= periodicBoxSize[1]*static_cast<int>(center[1]/periodicBoxSize[1][1]);
diff -= periodicBoxSize[2]*static_cast<int>(center[2]/periodicBoxSize[2][2]);
// Translate all the particles in the molecule.
for (int j = 0; j < (int) molecules[i].size(); j++) {
Vec3& pos = positions[molecules[i][j]];
pos[0] -= dx;
pos[1] -= dy;
pos[2] -= dz;
pos -= diff;
}
}
}
......@@ -207,6 +201,10 @@ void Context::setVelocitiesToTemperature(double temperature, int randomSeed) {
impl->applyVelocityConstraints(1e-5);
}
const map<string, double>& Context::getParameters() const {
return impl->getParameters();
}
double Context::getParameter(const string& name) const {
return impl->getParameter(name);
}
......
......@@ -262,6 +262,10 @@ void CustomNonbondedForce::setFunctionParameters(int index, const std::string& n
}
int CustomNonbondedForce::addInteractionGroup(const std::set<int>& set1, const std::set<int>& set2) {
for (set<int>::iterator it = set1.begin(); it != set1.end(); ++it)
ASSERT(*it >= 0);
for (set<int>::iterator it = set2.begin(); it != set2.end(); ++it)
ASSERT(*it >= 0);
interactionGroups.push_back(InteractionGroupInfo(set1, set2));
return interactionGroups.size()-1;
}
......@@ -274,6 +278,10 @@ void CustomNonbondedForce::getInteractionGroupParameters(int index, std::set<int
void CustomNonbondedForce::setInteractionGroupParameters(int index, const std::set<int>& set1, const std::set<int>& set2) {
ASSERT_VALID_INDEX(index, interactionGroups);
for (set<int>::iterator it = set1.begin(); it != set1.end(); ++it)
ASSERT_VALID_INDEX(*it, particles);
for (set<int>::iterator it = set2.begin(); it != set2.end(); ++it)
ASSERT_VALID_INDEX(*it, particles);
interactionGroups[index].set1 = set1;
interactionGroups[index].set2 = set2;
}
......
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