"...serialization/src/DrudeNoseHooverIntegratorProxy.cpp" did not exist on "84165803c8a431fe81990177ebf406d651e7e67e"
Commit 64493da6 authored by Peter Eastman's avatar Peter Eastman
Browse files

Modified the API for lots of classes so that the number of...

Modified the API for lots of classes so that the number of particles/bonds/etc. need not be specified in the constructor.
parent 29e3fa57
...@@ -41,6 +41,12 @@ namespace OpenMM { ...@@ -41,6 +41,12 @@ 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.
* <p> * <p>
* 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
* be exactly equal to the number of particles in the System, or else an exception will be thrown when you
* try to create an OpenMMContext. After a particle has been added, you can modify its force field parameters
* by calling setParticleParameters().
* <p>
* If the System also contains a NonbondedForce, this force will use the cutoffs * If the System also contains a NonbondedForce, this force will use the cutoffs
* and periodic boundary conditions specified in it. * and periodic boundary conditions specified in it.
*/ */
...@@ -49,16 +55,23 @@ class OPENMM_EXPORT GBSAOBCForce : public Force { ...@@ -49,16 +55,23 @@ class OPENMM_EXPORT GBSAOBCForce : public Force {
public: public:
/* /*
* Create a GBSAOBCForce. * Create a GBSAOBCForce.
*
* @param numParticles the number of particles in the system
*/ */
GBSAOBCForce(int numParticles); GBSAOBCForce();
/** /**
* Get the number of particles in the system. * Get the number of particles in the system.
*/ */
int getNumParticles() const { int getNumParticles() const {
return particles.size(); return particles.size();
} }
/**
* Add the GBSA 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 GBSA radius of the particle, measured in nm
* @param scalingFactor the OBC scaling factor for the particle
*/
void addParticle(double charge, double radius, double scalingFactor);
/** /**
* Get the force field parameters for a particle. * Get the force field parameters for a particle.
* *
...@@ -129,6 +142,9 @@ public: ...@@ -129,6 +142,9 @@ public:
ParticleInfo() { ParticleInfo() {
charge = radius = scalingFactor = 0.0; charge = radius = scalingFactor = 0.0;
} }
ParticleInfo(double charge, double radius, double scalingFactor) :
charge(charge), radius(radius), scalingFactor(scalingFactor) {
}
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -41,6 +41,12 @@ namespace OpenMM { ...@@ -41,6 +41,12 @@ namespace OpenMM {
/** /**
* This class implements an implicit solvation force using the GB/VI model. * This class implements an implicit solvation force using the GB/VI model.
* <p> * <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 an OpenMMContext. After a particle has been added, you can modify its force field parameters
* by calling setParticleParameters().
* <p>
* If the System also contains a NonbondedForce, this force will use the cutoffs * If the System also contains a NonbondedForce, this force will use the cutoffs
* and periodic boundary conditions specified in it. * and periodic boundary conditions specified in it.
*/ */
...@@ -49,16 +55,23 @@ class OPENMM_EXPORT GBVIForce : public Force { ...@@ -49,16 +55,23 @@ class OPENMM_EXPORT GBVIForce : public Force {
public: public:
/* /*
* Create a GBVIForce. * Create a GBVIForce.
*
* @param numParticles the number of particles in the system
*/ */
GBVIForce(int numParticles); GBVIForce();
/** /**
* Get the number of particles in the system. * Get the number of particles in the system.
*/ */
int getNumParticles() const { int getNumParticles() const {
return particles.size(); 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
*/
void addParticle(double charge, double radius, double gamma);
/** /**
* Get the force field parameters for a particle. * Get the force field parameters for a particle.
* *
...@@ -129,6 +142,9 @@ public: ...@@ -129,6 +142,9 @@ public:
ParticleInfo() { ParticleInfo() {
charge = radius = gamma = 0.0; charge = radius = gamma = 0.0;
} }
ParticleInfo(double charge, double radius, double gamma) :
charge(charge), radius(radius), gamma(gamma) {
}
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,24 +42,32 @@ namespace OpenMM { ...@@ -42,24 +42,32 @@ namespace OpenMM {
/** /**
* This class implements an interaction between groups of three particles that varies harmonically with the angle * This class implements an interaction between groups of three particles that varies harmonically with the angle
* between them. When creating a HarmonicAngleForce, you specify the number of angle as an argument to the * between them. To use it, create a HarmonicAngleForce object then call addAngle() once for each angle. After
* constructor, then loop over them and call setAngleParameters() to set the force field parameters for each one. * an angle has been added, you can modify its force field parameters by calling setAngleParameters().
*/ */
class OPENMM_EXPORT HarmonicAngleForce : public Force { class OPENMM_EXPORT HarmonicAngleForce : public Force {
public: public:
/** /**
* Create a HarmonicAngleForce. * Create a HarmonicAngleForce.
*
* @param numAngles the number of harmonic bond angle terms in the potential function
*/ */
HarmonicAngleForce(int numAngles); HarmonicAngleForce();
/** /**
* Get the number of harmonic bond angle terms in the potential function * Get the number of harmonic bond angle terms in the potential function
*/ */
int getNumAngles() const { int getNumAngles() const {
return angles.size(); return angles.size();
} }
/**
* Add an angle term to the force field.
*
* @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 length the equilibrium angle, measured in radians
* @param k the harmonic force constant for the angle
*/
void 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.
* *
...@@ -109,6 +117,9 @@ public: ...@@ -109,6 +117,9 @@ public:
particle1 = particle2 = particle3 = -1; particle1 = particle2 = particle3 = -1;
angle = k = 0.0; angle = k = 0.0;
} }
AngleInfo(int particle1, int particle2, int particle3, double angle, double k) :
particle1(particle1), particle2(particle2), particle3(particle3), angle(angle), k(k) {
}
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,24 +42,31 @@ namespace OpenMM { ...@@ -42,24 +42,31 @@ namespace OpenMM {
/** /**
* This class implements an interaction between pairs of particles that varies harmonically with the distance * This class implements an interaction between pairs of particles that varies harmonically with the distance
* between them. When creating a HarmonicBondForce, you specify the number of bonds as an argument to the * between them. To use it, create a HarmonicBondForce object then call addBond() once for each bond. After
* constructor, then loop over them and call setBondParameters() to set the force field parameters for each one. * a bond has been added, you can modify its force field parameters by calling setBondParameters().
*/ */
class OPENMM_EXPORT HarmonicBondForce : public Force { class OPENMM_EXPORT HarmonicBondForce : public Force {
public: public:
/** /**
* Create a HarmonicBondForce. * Create a HarmonicBondForce.
*
* @param numBonds the number of harmonic bond stretch terms in the potential function
*/ */
HarmonicBondForce(int numBonds); HarmonicBondForce();
/** /**
* Get the number of harmonic bond stretch terms in the potential function * Get the number of harmonic bond stretch terms in the potential function
*/ */
int getNumBonds() const { int getNumBonds() const {
return bonds.size(); return bonds.size();
} }
/**
* Add a bond term to the force field.
*
* @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
*/
void 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.
* *
...@@ -107,6 +114,9 @@ public: ...@@ -107,6 +114,9 @@ public:
particle1 = particle2 = -1; particle1 = particle2 = -1;
length = k = 0.0; length = k = 0.0;
} }
BondInfo(int particle1, int particle2, double length, double k) :
particle1(particle1), particle2(particle2), length(length), k(k) {
}
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,24 +42,34 @@ namespace OpenMM { ...@@ -42,24 +42,34 @@ namespace OpenMM {
/** /**
* This class implements an interaction between groups of four particles that varies periodically with the torsion angle * This class implements an interaction between groups of four particles that varies periodically with the torsion angle
* between them. When creating a PeriodicTorsionForce, you specify the number of torsions as an argument to the * between them. To use it, create a PeriodicTorsionForce object then call addTorsion() once for each torsion. After
* constructor, then loop over them and call setTorsionParameters() to set the force field parameters for each one. * a torsion has been added, you can modify its force field parameters by calling setTorsionParameters().
*/ */
class OPENMM_EXPORT PeriodicTorsionForce : public Force { class OPENMM_EXPORT PeriodicTorsionForce : public Force {
public: public:
/** /**
* Create a PeriodicTorsionForce. * Create a PeriodicTorsionForce.
*
* @param numTorsions the number of periodic torsion terms in the potential function
*/ */
PeriodicTorsionForce(int numTorsions); PeriodicTorsionForce();
/** /**
* Get the number of periodic torsion terms in the potential function * Get the number of periodic torsion terms in the potential function
*/ */
int getNumTorsions() const { int getNumTorsions() const {
return periodicTorsions.size(); return periodicTorsions.size();
} }
/**
* Add a periodic torsion term to the force field.
*
* @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 particle3 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
*/
void 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.
* *
...@@ -114,6 +124,9 @@ public: ...@@ -114,6 +124,9 @@ public:
periodicity = 1; periodicity = 1;
phase = k = 0.0; phase = k = 0.0;
} }
PeriodicTorsionInfo(int particle1, int particle2, int particle3, int particle4, int periodicity, double phase, double k) :
particle1(particle1), particle2(particle2), particle3(particle3), particle4(particle4), periodicity(periodicity), phase(phase), k(k) {
}
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,25 +42,37 @@ namespace OpenMM { ...@@ -42,25 +42,37 @@ namespace OpenMM {
/** /**
* This class implements an interaction between groups of four particles that varies with the torsion angle between them * This class implements an interaction between groups of four particles that varies with the torsion angle between them
* according to the Ryckaert-Bellemans potential. When creating an RBTorsionForce, you specify the number of torsions * according to the Ryckaert-Bellemans potential. To use it, create an RBTorsionForce object then call addTorsion() once
* as an argument to the constructor, then loop over them and call setTorsionParameters() to set the force field * for each torsion. After a torsion has been added, you can modify its force field parameters by calling setTorsionParameters().
* parameters for each one.
*/ */
class OPENMM_EXPORT RBTorsionForce : public Force { class OPENMM_EXPORT RBTorsionForce : public Force {
public: public:
/** /**
* Create a RBTorsionForce. * Create a RBTorsionForce.
*
* @param numTorsions the number of torsion terms in the potential function
*/ */
RBTorsionForce(int numTorsions); RBTorsionForce();
/** /**
* Get the number of Ryckaert-Bellemans torsion terms in the potential function * Get the number of Ryckaert-Bellemans torsion terms in the potential function
*/ */
int getNumTorsions() const { int getNumTorsions() const {
return rbTorsions.size(); return rbTorsions.size();
} }
/**
* Add a Ryckaert-Bellemans torsion term to the force field.
*
* @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 particle3 the index of the fourth particle forming the torsion
* @param c0 the coefficient of the constant term
* @param c1 the coefficient of the 1st order term
* @param c2 the coefficient of the 2nd order term
* @param c3 the coefficient of the 3rd order term
* @param c4 the coefficient of the 4th order term
* @param c5 the coefficient of the 5th order term
*/
void 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.
* *
...@@ -120,6 +132,15 @@ public: ...@@ -120,6 +132,15 @@ public:
particle1 = particle2 = particle3 = particle4 = -1; particle1 = particle2 = particle3 = particle4 = -1;
c[0] = c[1] = c[2] = c[3] = c[4] = c[5] = 0.0; c[0] = c[1] = c[2] = c[3] = c[4] = c[5] = 0.0;
} }
RBTorsionInfo(int particle1, int particle2, int particle3, int particle4, double c0, double c1, double c2, double c3, double c4, double c5) :
particle1(particle1), particle2(particle2), particle3(particle3), particle4(particle4) {
c[0] = c0;
c[1] = c1;
c[2] = c2;
c[3] = c3;
c[4] = c4;
c[5] = c5;
}
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -49,20 +49,18 @@ class OPENMM_EXPORT Force; ...@@ -49,20 +49,18 @@ class OPENMM_EXPORT Force;
* <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>
* </ol> * </ol>
* *
* The particles and constraints are defined directly by the System object. * The particles and constraints are defined directly by the System object, while
* The forces are defined by objects that extend the Force class. The System * forces are defined by objects that extend the Force class. After creating a
* stores a list of Force objects that determine the motion of the particles. * System, call addParticle() once for each particle, addConstraint() for each constraint,
* and addForce() for each Force.
*/ */
class OPENMM_EXPORT System { class OPENMM_EXPORT System {
public: public:
/** /**
* Create a new System. * Create a new System.
*
* @param numParticles the number of particles in the System
* @param numConstraints the number of distance constraints in the System.
*/ */
System(int numParticles, int numConstraints); System();
~System(); ~System();
/** /**
* Get the number of particles in this System. * Get the number of particles in this System.
...@@ -70,6 +68,14 @@ public: ...@@ -70,6 +68,14 @@ public:
int getNumParticles() const { int getNumParticles() const {
return masses.size(); return masses.size();
} }
/**
* Add a particle to the System.
*
* @param mass the mass of the particle (in atomic mass units)
*/
void addParticle(double mass) {
masses.push_back(mass);
}
/** /**
* Get the mass (in atomic mass units) of a particle. * Get the mass (in atomic mass units) of a particle.
* *
...@@ -93,6 +99,14 @@ public: ...@@ -93,6 +99,14 @@ public:
int getNumConstraints() const { int getNumConstraints() const {
return constraints.size(); return constraints.size();
} }
/**
* Add a constraint to the System.
*
* @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
*/
void addConstraint(int particle1, int particle2, double distance);
/** /**
* Get the parameters defining a distance constraint. * Get the parameters defining a distance constraint.
* *
...@@ -170,6 +184,9 @@ public: ...@@ -170,6 +184,9 @@ public:
particle1 = particle2 = -1; particle1 = particle2 = -1;
distance = 0.0; distance = 0.0;
} }
ConstraintInfo(int particle1, int particle2, double distance) :
particle1(particle1), particle2(particle2), distance(distance) {
}
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -36,7 +36,11 @@ ...@@ -36,7 +36,11 @@
using namespace OpenMM; using namespace OpenMM;
GBSAOBCForce::GBSAOBCForce(int numParticles) : particles(numParticles), solventDielectric(78.3), soluteDielectric(1.0) { GBSAOBCForce::GBSAOBCForce() : solventDielectric(78.3), soluteDielectric(1.0) {
}
void GBSAOBCForce::addParticle(double charge, double radius, double scalingFactor) {
particles.push_back(ParticleInfo(charge, radius, scalingFactor));
} }
void GBSAOBCForce::getParticleParameters(int index, double& charge, double& radius, double& scalingFactor) const { void GBSAOBCForce::getParticleParameters(int index, double& charge, double& radius, double& scalingFactor) const {
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * * USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include "OpenMMException.h"
#include "internal/GBSAOBCForceImpl.h" #include "internal/GBSAOBCForceImpl.h"
#include "internal/OpenMMContextImpl.h" #include "internal/OpenMMContextImpl.h"
#include "kernels.h" #include "kernels.h"
...@@ -42,6 +43,8 @@ GBSAOBCForceImpl::GBSAOBCForceImpl(GBSAOBCForce& owner) : owner(owner) { ...@@ -42,6 +43,8 @@ GBSAOBCForceImpl::GBSAOBCForceImpl(GBSAOBCForce& owner) : owner(owner) {
void GBSAOBCForceImpl::initialize(OpenMMContextImpl& context) { void GBSAOBCForceImpl::initialize(OpenMMContextImpl& context) {
kernel = context.getPlatform().createKernel(CalcGBSAOBCForceKernel::Name(), context); kernel = context.getPlatform().createKernel(CalcGBSAOBCForceKernel::Name(), context);
if (owner.getNumParticles() != context.getSystem().getNumParticles())
throw OpenMMException("GBSAOBCForce must have exactly as many particles as the System it belongs to.");
dynamic_cast<CalcGBSAOBCForceKernel&>(kernel.getImpl()).initialize(context.getSystem(), owner); dynamic_cast<CalcGBSAOBCForceKernel&>(kernel.getImpl()).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) 2008 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -36,7 +36,11 @@ ...@@ -36,7 +36,11 @@
using namespace OpenMM; using namespace OpenMM;
GBVIForce::GBVIForce(int numParticles) : particles(numParticles), solventDielectric(78.3), soluteDielectric(1.0) { GBVIForce::GBVIForce() : solventDielectric(78.3), soluteDielectric(1.0) {
}
void GBVIForce::addParticle(double charge, double radius, double gamma) {
particles.push_back(ParticleInfo(charge, radius, gamma));
} }
void GBVIForce::getParticleParameters(int index, double& charge, double& radius, double& gamma) const { void GBVIForce::getParticleParameters(int index, double& charge, double& radius, double& gamma) const {
......
...@@ -44,6 +44,8 @@ GBVIForceImpl::GBVIForceImpl(GBVIForce& owner) : owner(owner) { ...@@ -44,6 +44,8 @@ GBVIForceImpl::GBVIForceImpl(GBVIForce& owner) : owner(owner) {
void GBVIForceImpl::initialize(OpenMMContextImpl& context) { void GBVIForceImpl::initialize(OpenMMContextImpl& context) {
kernel = context.getPlatform().createKernel(CalcGBVIForceKernel::Name(), context); kernel = context.getPlatform().createKernel(CalcGBVIForceKernel::Name(), context);
if (owner.getNumParticles() != context.getSystem().getNumParticles())
throw OpenMMException("GBVIForce must have exactly as many particles as the System it belongs to.");
// load 1-2 atom pairs along w/ bond distance using HarmonicBondForce & constraints // load 1-2 atom pairs along w/ bond distance using HarmonicBondForce & constraints
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -36,7 +36,11 @@ ...@@ -36,7 +36,11 @@
using namespace OpenMM; using namespace OpenMM;
HarmonicAngleForce::HarmonicAngleForce(int numAngles) : angles(numAngles) { HarmonicAngleForce::HarmonicAngleForce() {
}
void HarmonicAngleForce::addAngle(int particle1, int particle2, int particle3, double angle, double k) {
angles.push_back(AngleInfo(particle1, particle2, particle3, angle, k));
} }
void HarmonicAngleForce::getAngleParameters(int index, int& particle1, int& particle2, int& particle3, double& angle, double& k) const { void HarmonicAngleForce::getAngleParameters(int index, int& particle1, int& particle2, int& particle3, double& angle, double& k) const {
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -36,7 +36,11 @@ ...@@ -36,7 +36,11 @@
using namespace OpenMM; using namespace OpenMM;
HarmonicBondForce::HarmonicBondForce(int numBonds) : bonds(numBonds) { HarmonicBondForce::HarmonicBondForce() {
}
void HarmonicBondForce::addBond(int particle1, int particle2, double length, double k) {
bonds.push_back(BondInfo(particle1, particle2, length, k));
} }
void HarmonicBondForce::getBondParameters(int index, int& particle1, int& particle2, double& length, double& k) const { void HarmonicBondForce::getBondParameters(int index, int& particle1, int& particle2, double& length, double& k) const {
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -36,7 +36,11 @@ ...@@ -36,7 +36,11 @@
using namespace OpenMM; using namespace OpenMM;
PeriodicTorsionForce::PeriodicTorsionForce(int numTorsions) : periodicTorsions(numTorsions) { PeriodicTorsionForce::PeriodicTorsionForce() {
}
void PeriodicTorsionForce::addTorsion(int particle1, int particle2, int particle3, int particle4, int periodicity, double phase, double k) {
periodicTorsions.push_back(PeriodicTorsionInfo(particle1, particle2, particle3, particle4, periodicity, phase, k));
} }
void PeriodicTorsionForce::getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, int& periodicity, double& phase, double& k) const { void PeriodicTorsionForce::getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, int& periodicity, double& phase, double& k) const {
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -36,7 +36,11 @@ ...@@ -36,7 +36,11 @@
using namespace OpenMM; using namespace OpenMM;
RBTorsionForce::RBTorsionForce(int numTorsions) : rbTorsions(numTorsions) { RBTorsionForce::RBTorsionForce() {
}
void RBTorsionForce::addTorsion(int particle1, int particle2, int particle3, int particle4, double c0, double c1, double c2, double c3, double c4, double c5) {
rbTorsions.push_back(RBTorsionInfo(particle1, particle2, particle3, particle4, c0, c1, c2, c3, c4, c5));
} }
void RBTorsionForce::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 RBTorsionForce::getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, double& c0, double& c1, double& c2, double& c3, double& c4, double& c5) const {
......
...@@ -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 Stanford University and the Authors. * * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -34,9 +34,7 @@ ...@@ -34,9 +34,7 @@
using namespace OpenMM; using namespace OpenMM;
System::System(int numParticles, int numConstraints) : masses(numParticles), constraints(numConstraints), forces(0) { System::System() {
for (int i = 0; i < numParticles; ++i)
masses[i] = 0.0;
} }
System::~System() { System::~System() {
...@@ -44,6 +42,10 @@ System::~System() { ...@@ -44,6 +42,10 @@ System::~System() {
delete forces[i]; delete forces[i];
} }
void System::addConstraint(int particle1, int particle2, double distance) {
constraints.push_back(ConstraintInfo(particle1, particle2, distance));
}
void System::getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const { void System::getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const {
particle1 = constraints[index].particle1; particle1 = constraints[index].particle1;
particle2 = constraints[index].particle2; particle2 = constraints[index].particle2;
......
...@@ -69,16 +69,16 @@ void testBrookAngles( FILE* log ){ ...@@ -69,16 +69,16 @@ void testBrookAngles( FILE* log ){
} }
BrookPlatform platform( 32, "cal", log ); BrookPlatform platform( 32, "cal", log );
System system( numberOfParticles, 0 ); System system;
for (int i = 0; i < numberOfParticles; i++)
system.addParticle(1.0);
LangevinIntegrator integrator( 0, 0.1, 0.01 ); LangevinIntegrator integrator( 0, 0.1, 0.01 );
// int numParticles, int numBonds, int numAngles, int numPeriodicTorsions, int numRBTorsions HarmonicAngleForce* forceField = new HarmonicAngleForce();
HarmonicAngleForce* forceField = new HarmonicAngleForce(2); // int atom1, int atom2, int atom3, double angle, double k
forceField->addAngle(0, 1, 2, PI_M/3, 1.1);
// int index, int atom1, int atom2, int atom3, double angle, double k forceField->addAngle(1, 2, 3, PI_M/2, 1.2);
forceField->setAngleParameters(0, 0, 1, 2, PI_M/3, 1.1);
forceField->setAngleParameters(1, 1, 2, 3, PI_M/2, 1.2);
system.addForce(forceField); system.addForce(forceField);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
......
...@@ -82,15 +82,15 @@ void testMotionRemoval( FILE* log ) { ...@@ -82,15 +82,15 @@ void testMotionRemoval( FILE* log ) {
//ReferencePlatform platform; //ReferencePlatform platform;
BrookPlatform platform( 32, "cal", log ); BrookPlatform platform( 32, "cal", log );
System system( numberOfParticles, 0 ); System system;
VerletIntegrator integrator(0.001); VerletIntegrator integrator(0.001);
HarmonicBondForce* bonds = new HarmonicBondForce(1); HarmonicBondForce* bonds = new HarmonicBondForce();
bonds->setBondParameters(0, 2, 3, 2.0, 0.5); bonds->addBond(2, 3, 2.0, 0.5);
system.addForce(bonds); system.addForce(bonds);
NonbondedForce* nonbonded = new NonbondedForce(); NonbondedForce* nonbonded = new NonbondedForce();
for (int i = 0; i < numberOfParticles; ++i) { for (int i = 0; i < numberOfParticles; ++i) {
system.setParticleMass(i, (double) (i+1) ); system.addParticle((double) (i+1) );
nonbonded->addParticle((i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0); nonbonded->addParticle((i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0);
} }
system.addForce(nonbonded); system.addForce(nonbonded);
......
...@@ -64,16 +64,18 @@ void testBrookBonds( FILE* log ){ ...@@ -64,16 +64,18 @@ void testBrookBonds( FILE* log ){
} }
BrookPlatform platform( 32, "cal", log ); BrookPlatform platform( 32, "cal", log );
System system( numberOfParticles, 0 ); System system;
for (int i = 0; i < numberOfParticles; i++)
system.addParticle(1.0);
LangevinIntegrator integrator(0, 0.1, 0.01); LangevinIntegrator integrator(0, 0.1, 0.01);
// int numParticles, int numBonds, int numAngles, int numPeriodicTorsions, int numRBTorsions // int numParticles, int numBonds, int numAngles, int numPeriodicTorsions, int numRBTorsions
HarmonicBondForce* forceField = new HarmonicBondForce( 2 ); HarmonicBondForce* forceField = new HarmonicBondForce();
// ( index, atom1, atom2, length, k ) // ( index, atom1, atom2, length, k )
forceField->setBondParameters(0, 0, 1, 1.5, 0.8); forceField->addBond(0, 1, 1.5, 0.8);
forceField->setBondParameters(1, 1, 2, 1.2, 0.7); forceField->addBond(1, 2, 1.2, 0.7);
system.addForce(forceField); system.addForce(forceField);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
......
...@@ -79,17 +79,17 @@ static OpenMMContext* testLangevinSingleBondSetup( int brookContext, LangevinInt ...@@ -79,17 +79,17 @@ static OpenMMContext* testLangevinSingleBondSetup( int brookContext, LangevinInt
platform = new ReferencePlatform(); platform = new ReferencePlatform();
} }
System* system = new System( numberOfParticles, 0); System* system = new System;
system->setParticleMass(0, mass ); system->addParticle(mass);
system->setParticleMass(1, mass ); system->addParticle(mass);
// double temperature, double frictionCoeff, double stepSize // double temperature, double frictionCoeff, double stepSize
LangevinIntegrator* integrator = new LangevinIntegrator(0, 0.1, 0.001); LangevinIntegrator* integrator = new LangevinIntegrator(0, 0.1, 0.001);
integrator->setConstraintTolerance(1e-5); integrator->setConstraintTolerance(1e-5);
*outIntegrator = integrator; *outIntegrator = integrator;
HarmonicBondForce* forceField = new HarmonicBondForce(1); HarmonicBondForce* forceField = new HarmonicBondForce();
forceField->setBondParameters(0, 0, 1, 1.5, 1); forceField->addBond(0, 1, 1.5, 1);
system->addForce(forceField); system->addForce(forceField);
OpenMMContext* context = new OpenMMContext( *system, *integrator, *platform ); OpenMMContext* context = new OpenMMContext( *system, *integrator, *platform );
...@@ -215,11 +215,11 @@ void testLangevinTemperature( FILE* log ){ ...@@ -215,11 +215,11 @@ void testLangevinTemperature( FILE* log ){
BrookPlatform platform( 32, "cal", log ); BrookPlatform platform( 32, "cal", log );
//ReferencePlatform platform; //ReferencePlatform platform;
System system(numberOfParticles, 0); System system;
LangevinIntegrator integrator(temp, 0.2, 0.002); LangevinIntegrator integrator(temp, 0.2, 0.002);
NonbondedForce* forceField = new NonbondedForce(); NonbondedForce* forceField = new NonbondedForce();
for (int i = 0; i < numberOfParticles; ++i){ for (int i = 0; i < numberOfParticles; ++i){
system.setParticleMass(i, mass ); system.addParticle(mass);
forceField->addParticle((i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0); forceField->addParticle((i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0);
} }
system.addForce(forceField); system.addForce(forceField);
...@@ -312,16 +312,16 @@ void testLangevinConstraints( FILE* log ){ ...@@ -312,16 +312,16 @@ void testLangevinConstraints( FILE* log ){
const int numConstraints = 4; const int numConstraints = 4;
const double temp = 100.0; const double temp = 100.0;
// ReferencePlatform platform; // ReferencePlatform platform;
System system( numParticles, numConstraints ); System system;
LangevinIntegrator integrator( temp, 2.0, 0.001 ); LangevinIntegrator integrator( temp, 2.0, 0.001 );
integrator.setConstraintTolerance(1e-5); integrator.setConstraintTolerance(1e-5);
NonbondedForce* forceField = new NonbondedForce(); NonbondedForce* forceField = new NonbondedForce();
for (int i = 0; i < numParticles; ++i) { for (int i = 0; i < numParticles; ++i) {
system.setParticleMass(i, mass); system.addParticle(mass);
forceField->addParticle((i%2 == 0 ? 0.2 : -0.2), 0.5, 5.0); forceField->addParticle((i%2 == 0 ? 0.2 : -0.2), 0.5, 5.0);
} }
for (int i = 0; i < numConstraints; ++i){ for (int i = 0; i < numConstraints; ++i){
system.setConstraintParameters(i, 2*i, 2*i+1, 1.0); system.addConstraint(2*i, 2*i+1, 1.0);
} }
system.addForce(forceField); system.addForce(forceField);
......
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