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 {
/**
* This class implements an implicit solvation force using the GBSA-OBC model.
* <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
* and periodic boundary conditions specified in it.
*/
......@@ -49,16 +55,23 @@ class OPENMM_EXPORT GBSAOBCForce : public Force {
public:
/*
* Create a GBSAOBCForce.
*
* @param numParticles the number of particles in the system
*/
GBSAOBCForce(int numParticles);
GBSAOBCForce();
/**
* Get the number of particles in the system.
*/
int getNumParticles() const {
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.
*
......@@ -129,6 +142,9 @@ public:
ParticleInfo() {
charge = radius = scalingFactor = 0.0;
}
ParticleInfo(double charge, double radius, double scalingFactor) :
charge(charge), radius(radius), scalingFactor(scalingFactor) {
}
};
} // namespace OpenMM
......
......@@ -41,6 +41,12 @@ 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 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
* and periodic boundary conditions specified in it.
*/
......@@ -49,16 +55,23 @@ class OPENMM_EXPORT GBVIForce : public Force {
public:
/*
* Create a GBVIForce.
*
* @param numParticles the number of particles in the system
*/
GBVIForce(int numParticles);
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
*/
void addParticle(double charge, double radius, double gamma);
/**
* Get the force field parameters for a particle.
*
......@@ -129,6 +142,9 @@ public:
ParticleInfo() {
charge = radius = gamma = 0.0;
}
ParticleInfo(double charge, double radius, double gamma) :
charge(charge), radius(radius), gamma(gamma) {
}
};
} // namespace OpenMM
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -42,24 +42,32 @@ namespace OpenMM {
/**
* 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
* constructor, then loop over them and call setAngleParameters() to set the force field parameters for each one.
* between them. To use it, create a HarmonicAngleForce object then call addAngle() once for each angle. After
* an angle has been added, you can modify its force field parameters by calling setAngleParameters().
*/
class OPENMM_EXPORT HarmonicAngleForce : public Force {
public:
/**
* 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
*/
int getNumAngles() const {
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.
*
......@@ -109,6 +117,9 @@ public:
particle1 = particle2 = particle3 = -1;
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
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -42,24 +42,31 @@ namespace OpenMM {
/**
* 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
* constructor, then loop over them and call setBondParameters() to set the force field parameters for each one.
* between them. To use it, create a HarmonicBondForce object then call addBond() once for each bond. After
* a bond has been added, you can modify its force field parameters by calling setBondParameters().
*/
class OPENMM_EXPORT HarmonicBondForce : public Force {
public:
/**
* 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
*/
int getNumBonds() const {
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.
*
......@@ -107,6 +114,9 @@ public:
particle1 = particle2 = -1;
length = k = 0.0;
}
BondInfo(int particle1, int particle2, double length, double k) :
particle1(particle1), particle2(particle2), length(length), k(k) {
}
};
} // namespace OpenMM
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -42,24 +42,34 @@ namespace OpenMM {
/**
* 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
* constructor, then loop over them and call setTorsionParameters() to set the force field parameters for each one.
* between them. To use it, create a PeriodicTorsionForce object then call addTorsion() once for each torsion. After
* a torsion has been added, you can modify its force field parameters by calling setTorsionParameters().
*/
class OPENMM_EXPORT PeriodicTorsionForce : public Force {
public:
/**
* 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
*/
int getNumTorsions() const {
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.
*
......@@ -114,6 +124,9 @@ public:
periodicity = 1;
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
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -42,25 +42,37 @@ namespace OpenMM {
/**
* 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
* as an argument to the constructor, then loop over them and call setTorsionParameters() to set the force field
* parameters for each one.
* according to the Ryckaert-Bellemans potential. To use it, create an RBTorsionForce object then call addTorsion() once
* for each torsion. After a torsion has been added, you can modify its force field parameters by calling setTorsionParameters().
*/
class OPENMM_EXPORT RBTorsionForce : public Force {
public:
/**
* 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
*/
int getNumTorsions() const {
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.
*
......@@ -120,6 +132,15 @@ public:
particle1 = particle2 = particle3 = particle4 = -1;
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
......
......@@ -49,20 +49,18 @@ class OPENMM_EXPORT Force;
* <li>Pairs of particles whose separation should be constrained to a fixed value</li>
* </ol>
*
* The particles and constraints are defined directly by the System object.
* The forces are defined by objects that extend the Force class. The System
* stores a list of Force objects that determine the motion of the particles.
* 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
* System, call addParticle() once for each particle, addConstraint() for each constraint,
* and addForce() for each Force.
*/
class OPENMM_EXPORT System {
public:
/**
* 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();
/**
* Get the number of particles in this System.
......@@ -70,6 +68,14 @@ public:
int getNumParticles() const {
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.
*
......@@ -93,6 +99,14 @@ public:
int getNumConstraints() const {
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.
*
......@@ -170,6 +184,9 @@ public:
particle1 = particle2 = -1;
distance = 0.0;
}
ConstraintInfo(int particle1, int particle2, double distance) :
particle1(particle1), particle2(particle2), distance(distance) {
}
};
} // namespace OpenMM
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -36,7 +36,11 @@
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 {
......
......@@ -29,6 +29,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "OpenMMException.h"
#include "internal/GBSAOBCForceImpl.h"
#include "internal/OpenMMContextImpl.h"
#include "kernels.h"
......@@ -42,6 +43,8 @@ GBSAOBCForceImpl::GBSAOBCForceImpl(GBSAOBCForce& owner) : owner(owner) {
void GBSAOBCForceImpl::initialize(OpenMMContextImpl& 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);
}
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -36,7 +36,11 @@
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 {
......
......@@ -44,6 +44,8 @@ GBVIForceImpl::GBVIForceImpl(GBVIForce& owner) : owner(owner) {
void GBVIForceImpl::initialize(OpenMMContextImpl& 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
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -36,7 +36,11 @@
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 {
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -36,7 +36,11 @@
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 {
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -36,7 +36,11 @@
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 {
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -36,7 +36,11 @@
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 {
......
......@@ -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 Stanford University and the Authors. *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -34,9 +34,7 @@
using namespace OpenMM;
System::System(int numParticles, int numConstraints) : masses(numParticles), constraints(numConstraints), forces(0) {
for (int i = 0; i < numParticles; ++i)
masses[i] = 0.0;
System::System() {
}
System::~System() {
......@@ -44,6 +42,10 @@ System::~System() {
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 {
particle1 = constraints[index].particle1;
particle2 = constraints[index].particle2;
......
......@@ -69,16 +69,16 @@ void testBrookAngles( FILE* 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 );
// int numParticles, int numBonds, int numAngles, int numPeriodicTorsions, int numRBTorsions
HarmonicAngleForce* forceField = new HarmonicAngleForce();
HarmonicAngleForce* forceField = new HarmonicAngleForce(2);
// int index, int atom1, int atom2, int atom3, double angle, double k
forceField->setAngleParameters(0, 0, 1, 2, PI_M/3, 1.1);
forceField->setAngleParameters(1, 1, 2, 3, PI_M/2, 1.2);
// int atom1, int atom2, int atom3, double angle, double k
forceField->addAngle(0, 1, 2, PI_M/3, 1.1);
forceField->addAngle(1, 2, 3, PI_M/2, 1.2);
system.addForce(forceField);
OpenMMContext context(system, integrator, platform);
......
......@@ -82,15 +82,15 @@ void testMotionRemoval( FILE* log ) {
//ReferencePlatform platform;
BrookPlatform platform( 32, "cal", log );
System system( numberOfParticles, 0 );
System system;
VerletIntegrator integrator(0.001);
HarmonicBondForce* bonds = new HarmonicBondForce(1);
bonds->setBondParameters(0, 2, 3, 2.0, 0.5);
HarmonicBondForce* bonds = new HarmonicBondForce();
bonds->addBond(2, 3, 2.0, 0.5);
system.addForce(bonds);
NonbondedForce* nonbonded = new NonbondedForce();
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);
}
system.addForce(nonbonded);
......
......@@ -64,16 +64,18 @@ void testBrookBonds( FILE* 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);
// int numParticles, int numBonds, int numAngles, int numPeriodicTorsions, int numRBTorsions
HarmonicBondForce* forceField = new HarmonicBondForce( 2 );
HarmonicBondForce* forceField = new HarmonicBondForce();
// ( index, atom1, atom2, length, k )
forceField->setBondParameters(0, 0, 1, 1.5, 0.8);
forceField->setBondParameters(1, 1, 2, 1.2, 0.7);
forceField->addBond(0, 1, 1.5, 0.8);
forceField->addBond(1, 2, 1.2, 0.7);
system.addForce(forceField);
OpenMMContext context(system, integrator, platform);
......
......@@ -79,17 +79,17 @@ static OpenMMContext* testLangevinSingleBondSetup( int brookContext, LangevinInt
platform = new ReferencePlatform();
}
System* system = new System( numberOfParticles, 0);
system->setParticleMass(0, mass );
system->setParticleMass(1, mass );
System* system = new System;
system->addParticle(mass);
system->addParticle(mass);
// double temperature, double frictionCoeff, double stepSize
LangevinIntegrator* integrator = new LangevinIntegrator(0, 0.1, 0.001);
integrator->setConstraintTolerance(1e-5);
*outIntegrator = integrator;
HarmonicBondForce* forceField = new HarmonicBondForce(1);
forceField->setBondParameters(0, 0, 1, 1.5, 1);
HarmonicBondForce* forceField = new HarmonicBondForce();
forceField->addBond(0, 1, 1.5, 1);
system->addForce(forceField);
OpenMMContext* context = new OpenMMContext( *system, *integrator, *platform );
......@@ -215,11 +215,11 @@ void testLangevinTemperature( FILE* log ){
BrookPlatform platform( 32, "cal", log );
//ReferencePlatform platform;
System system(numberOfParticles, 0);
System system;
LangevinIntegrator integrator(temp, 0.2, 0.002);
NonbondedForce* forceField = new NonbondedForce();
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);
}
system.addForce(forceField);
......@@ -312,16 +312,16 @@ void testLangevinConstraints( FILE* log ){
const int numConstraints = 4;
const double temp = 100.0;
// ReferencePlatform platform;
System system( numParticles, numConstraints );
System system;
LangevinIntegrator integrator( temp, 2.0, 0.001 );
integrator.setConstraintTolerance(1e-5);
NonbondedForce* forceField = new NonbondedForce();
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);
}
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);
......
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