Commit 62c4fd53 authored by Peter Eastman's avatar Peter Eastman
Browse files

Renamed "atoms" to "particles"

parent ad75a390
...@@ -39,16 +39,16 @@ using namespace OpenMM; ...@@ -39,16 +39,16 @@ using namespace OpenMM;
HarmonicBondForce::HarmonicBondForce(int numBonds) : bonds(numBonds) { HarmonicBondForce::HarmonicBondForce(int numBonds) : bonds(numBonds) {
} }
void HarmonicBondForce::getBondParameters(int index, int& atom1, int& atom2, double& length, double& k) const { void HarmonicBondForce::getBondParameters(int index, int& particle1, int& particle2, double& length, double& k) const {
atom1 = bonds[index].atom1; particle1 = bonds[index].particle1;
atom2 = bonds[index].atom2; particle2 = bonds[index].particle2;
length = bonds[index].length; length = bonds[index].length;
k = bonds[index].k; k = bonds[index].k;
} }
void HarmonicBondForce::setBondParameters(int index, int atom1, int atom2, double length, double k) { void HarmonicBondForce::setBondParameters(int index, int particle1, int particle2, double length, double k) {
bonds[index].atom1 = atom1; bonds[index].particle1 = particle1;
bonds[index].atom2 = atom2; bonds[index].particle2 = particle2;
bonds[index].length = length; bonds[index].length = length;
bonds[index].k = k; bonds[index].k = k;
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
using namespace OpenMM; using namespace OpenMM;
NonbondedForce::NonbondedForce(int numAtoms, int numNonbonded14) : atoms(numAtoms), nb14s(numNonbonded14), NonbondedForce::NonbondedForce(int numParticles, int numNonbonded14) : particles(numParticles), nb14s(numNonbonded14),
nonbondedMethod(NoCutoff), cutoffDistance(1.0) { nonbondedMethod(NoCutoff), cutoffDistance(1.0) {
periodicBoxVectors[0] = Vec3(2, 0, 0); periodicBoxVectors[0] = Vec3(2, 0, 0);
periodicBoxVectors[1] = Vec3(0, 2, 0); periodicBoxVectors[1] = Vec3(0, 2, 0);
...@@ -77,29 +77,29 @@ void NonbondedForce::setPeriodicBoxVectors(Vec3 a, Vec3 b, Vec3 c) { ...@@ -77,29 +77,29 @@ void NonbondedForce::setPeriodicBoxVectors(Vec3 a, Vec3 b, Vec3 c) {
periodicBoxVectors[2] = c; periodicBoxVectors[2] = c;
} }
void NonbondedForce::getAtomParameters(int index, double& charge, double& radius, double& depth) const { void NonbondedForce::getParticleParameters(int index, double& charge, double& radius, double& depth) const {
charge = atoms[index].charge; charge = particles[index].charge;
radius = atoms[index].radius; radius = particles[index].radius;
depth = atoms[index].depth; depth = particles[index].depth;
} }
void NonbondedForce::setAtomParameters(int index, double charge, double radius, double depth) { void NonbondedForce::setParticleParameters(int index, double charge, double radius, double depth) {
atoms[index].charge = charge; particles[index].charge = charge;
atoms[index].radius = radius; particles[index].radius = radius;
atoms[index].depth = depth; particles[index].depth = depth;
} }
void NonbondedForce::getNonbonded14Parameters(int index, int& atom1, int& atom2, double& charge, double& radius, double& depth) const { void NonbondedForce::getNonbonded14Parameters(int index, int& particle1, int& particle2, double& charge, double& radius, double& depth) const {
atom1 = nb14s[index].atom1; particle1 = nb14s[index].particle1;
atom2 = nb14s[index].atom2; particle2 = nb14s[index].particle2;
charge = nb14s[index].charge; charge = nb14s[index].charge;
radius = nb14s[index].radius; radius = nb14s[index].radius;
depth = nb14s[index].depth; depth = nb14s[index].depth;
} }
void NonbondedForce::setNonbonded14Parameters(int index, int atom1, int atom2, double charge, double radius, double depth) { void NonbondedForce::setNonbonded14Parameters(int index, int particle1, int particle2, double charge, double radius, double depth) {
nb14s[index].atom1 = atom1; nb14s[index].particle1 = particle1;
nb14s[index].atom2 = atom2; nb14s[index].particle2 = particle2;
nb14s[index].charge = charge; nb14s[index].charge = charge;
nb14s[index].radius = radius; nb14s[index].radius = radius;
nb14s[index].depth = depth; nb14s[index].depth = depth;
......
...@@ -50,23 +50,23 @@ void NonbondedForceImpl::initialize(OpenMMContextImpl& context) { ...@@ -50,23 +50,23 @@ void NonbondedForceImpl::initialize(OpenMMContextImpl& context) {
// See if the system contains a HarmonicBondForce. If so, use it to identify exclusions. // See if the system contains a HarmonicBondForce. If so, use it to identify exclusions.
System& system = context.getSystem(); System& system = context.getSystem();
vector<set<int> > exclusions(owner.getNumAtoms()); vector<set<int> > exclusions(owner.getNumParticles());
for (int i = 0; i < system.getNumForces(); i++) { for (int i = 0; i < system.getNumForces(); i++) {
if (dynamic_cast<HarmonicBondForce*>(&system.getForce(i)) != NULL) { if (dynamic_cast<HarmonicBondForce*>(&system.getForce(i)) != NULL) {
const HarmonicBondForce& force = dynamic_cast<const HarmonicBondForce&>(system.getForce(i)); const HarmonicBondForce& force = dynamic_cast<const HarmonicBondForce&>(system.getForce(i));
vector<vector<int> > bondIndices(force.getNumBonds()); vector<vector<int> > bondIndices(force.getNumBonds());
set<pair<int, int> > bonded14set; set<pair<int, int> > bonded14set;
for (int i = 0; i < force.getNumBonds(); ++i) { for (int i = 0; i < force.getNumBonds(); ++i) {
int atom1, atom2; int particle1, particle2;
double length, k; double length, k;
force.getBondParameters(i, atom1, atom2, length, k); force.getBondParameters(i, particle1, particle2, length, k);
bondIndices[i].push_back(atom1); bondIndices[i].push_back(particle1);
bondIndices[i].push_back(atom2); bondIndices[i].push_back(particle2);
} }
findExclusions(bondIndices, exclusions, bonded14set); findExclusions(bondIndices, exclusions, bonded14set);
} }
} }
dynamic_cast<CalcNonbondedForceKernel&>(kernel.getImpl()).initialize(context.getSystem(), owner, exclusions); dynamic_cast<CalcNonbondedForceKernel&>(kernel.getImpl()).initialize(context.getSystem(), owner, exclusions);
} }
void NonbondedForceImpl::calcForces(OpenMMContextImpl& context, Stream& forces) { void NonbondedForceImpl::calcForces(OpenMMContextImpl& context, Stream& forces) {
...@@ -100,12 +100,12 @@ void NonbondedForceImpl::findExclusions(const vector<vector<int> >& bondIndices, ...@@ -100,12 +100,12 @@ void NonbondedForceImpl::findExclusions(const vector<vector<int> >& bondIndices,
} }
} }
void NonbondedForceImpl::addExclusionsToSet(const vector<set<int> >& bonded12, set<int>& exclusions, int baseAtom, int fromAtom, int currentLevel) const { void NonbondedForceImpl::addExclusionsToSet(const vector<set<int> >& bonded12, set<int>& exclusions, int baseParticle, int fromParticle, int currentLevel) const {
for (set<int>::const_iterator iter = bonded12[fromAtom].begin(); iter != bonded12[fromAtom].end(); ++iter) { for (set<int>::const_iterator iter = bonded12[fromParticle].begin(); iter != bonded12[fromParticle].end(); ++iter) {
if (*iter != baseAtom) if (*iter != baseParticle)
exclusions.insert(*iter); exclusions.insert(*iter);
if (currentLevel > 0) if (currentLevel > 0)
addExclusionsToSet(bonded12, exclusions, baseAtom, *iter, currentLevel-1); addExclusionsToSet(bonded12, exclusions, baseParticle, *iter, currentLevel-1);
} }
} }
...@@ -66,7 +66,7 @@ Integrator& OpenMMContext::getIntegrator() { ...@@ -66,7 +66,7 @@ Integrator& OpenMMContext::getIntegrator() {
} }
State OpenMMContext::getState(int types) const { State OpenMMContext::getState(int types) const {
State state(impl->getTime(), impl->getSystem().getNumAtoms(), State::DataType(types)); State state(impl->getTime(), impl->getSystem().getNumParticles(), State::DataType(types));
if (types&State::Energy) if (types&State::Energy)
state.setEnergy(impl->calcKineticEnergy(), impl->calcPotentialEnergy()); state.setEnergy(impl->calcKineticEnergy(), impl->calcPotentialEnergy());
if (types&State::Forces) { if (types&State::Forces) {
...@@ -93,13 +93,13 @@ void OpenMMContext::setTime(double time) { ...@@ -93,13 +93,13 @@ void OpenMMContext::setTime(double time) {
} }
void OpenMMContext::setPositions(const vector<Vec3>& positions) { void OpenMMContext::setPositions(const vector<Vec3>& positions) {
if ((int) positions.size() != impl->getSystem().getNumAtoms()) if ((int) positions.size() != impl->getSystem().getNumParticles())
throw OpenMMException("Called setPositions() on an OpenMMContext with the wrong number of positions"); throw OpenMMException("Called setPositions() on an OpenMMContext with the wrong number of positions");
impl->getPositions().loadFromArray(&positions[0]); impl->getPositions().loadFromArray(&positions[0]);
} }
void OpenMMContext::setVelocities(const vector<Vec3>& velocities) { void OpenMMContext::setVelocities(const vector<Vec3>& velocities) {
if ((int) velocities.size() != impl->getSystem().getNumAtoms()) if ((int) velocities.size() != impl->getSystem().getNumParticles())
throw OpenMMException("Called setVelocities() on an OpenMMContext with the wrong number of velocities"); throw OpenMMException("Called setVelocities() on an OpenMMContext with the wrong number of velocities");
impl->getVelocities().loadFromArray(&velocities[0]); impl->getVelocities().loadFromArray(&velocities[0]);
} }
......
...@@ -67,16 +67,16 @@ OpenMMContextImpl::OpenMMContextImpl(OpenMMContext& owner, System& system, Integ ...@@ -67,16 +67,16 @@ OpenMMContextImpl::OpenMMContextImpl(OpenMMContext& owner, System& system, Integ
throw OpenMMException("Specified a Platform for an OpenMMContext which does not support all required kernels"); throw OpenMMException("Specified a Platform for an OpenMMContext which does not support all required kernels");
platform->contextCreated(*this); platform->contextCreated(*this);
kineticEnergyKernel = platform->createKernel(CalcKineticEnergyKernel::Name(), *this); kineticEnergyKernel = platform->createKernel(CalcKineticEnergyKernel::Name(), *this);
vector<double> masses(system.getNumAtoms()); vector<double> masses(system.getNumParticles());
for (size_t i = 0; i < masses.size(); ++i) for (size_t i = 0; i < masses.size(); ++i)
masses[i] = system.getAtomMass(i); masses[i] = system.getParticleMass(i);
dynamic_cast<CalcKineticEnergyKernel&>(kineticEnergyKernel.getImpl()).initialize(system); dynamic_cast<CalcKineticEnergyKernel&>(kineticEnergyKernel.getImpl()).initialize(system);
for (size_t i = 0; i < forceImpls.size(); ++i) for (size_t i = 0; i < forceImpls.size(); ++i)
forceImpls[i]->initialize(*this); forceImpls[i]->initialize(*this);
integrator.initialize(*this); integrator.initialize(*this);
positions = platform->createStream("atomPositions", system.getNumAtoms(), Stream::Double3, *this); positions = platform->createStream("particlePositions", system.getNumParticles(), Stream::Double3, *this);
velocities = platform->createStream("atomVelocities", system.getNumAtoms(), Stream::Double3, *this); velocities = platform->createStream("particleVelocities", system.getNumParticles(), Stream::Double3, *this);
forces = platform->createStream("atomForces", system.getNumAtoms(), Stream::Double3, *this); forces = platform->createStream("particleForces", system.getNumParticles(), Stream::Double3, *this);
double zero[] = {0.0, 0.0, 0.0}; double zero[] = {0.0, 0.0, 0.0};
velocities.fillWithValue(&zero); velocities.fillWithValue(&zero);
} }
......
...@@ -39,21 +39,21 @@ using namespace OpenMM; ...@@ -39,21 +39,21 @@ using namespace OpenMM;
PeriodicTorsionForce::PeriodicTorsionForce(int numTorsions) : periodicTorsions(numTorsions) { PeriodicTorsionForce::PeriodicTorsionForce(int numTorsions) : periodicTorsions(numTorsions) {
} }
void PeriodicTorsionForce::getTorsionParameters(int index, int& atom1, int& atom2, int& atom3, int& atom4, 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 {
atom1 = periodicTorsions[index].atom1; particle1 = periodicTorsions[index].particle1;
atom2 = periodicTorsions[index].atom2; particle2 = periodicTorsions[index].particle2;
atom3 = periodicTorsions[index].atom3; particle3 = periodicTorsions[index].particle3;
atom4 = periodicTorsions[index].atom4; particle4 = periodicTorsions[index].particle4;
periodicity = periodicTorsions[index].periodicity; periodicity = periodicTorsions[index].periodicity;
phase = periodicTorsions[index].phase; phase = periodicTorsions[index].phase;
k = periodicTorsions[index].k; k = periodicTorsions[index].k;
} }
void PeriodicTorsionForce::setTorsionParameters(int index, int atom1, int atom2, int atom3, int atom4, int periodicity, double phase, double k) { void PeriodicTorsionForce::setTorsionParameters(int index, int particle1, int particle2, int particle3, int particle4, int periodicity, double phase, double k) {
periodicTorsions[index].atom1 = atom1; periodicTorsions[index].particle1 = particle1;
periodicTorsions[index].atom2 = atom2; periodicTorsions[index].particle2 = particle2;
periodicTorsions[index].atom3 = atom3; periodicTorsions[index].particle3 = particle3;
periodicTorsions[index].atom4 = atom4; periodicTorsions[index].particle4 = particle4;
periodicTorsions[index].periodicity = periodicity; periodicTorsions[index].periodicity = periodicity;
periodicTorsions[index].phase = phase; periodicTorsions[index].phase = phase;
periodicTorsions[index].k = k; periodicTorsions[index].k = k;
......
...@@ -39,11 +39,11 @@ using namespace OpenMM; ...@@ -39,11 +39,11 @@ using namespace OpenMM;
RBTorsionForce::RBTorsionForce(int numTorsions) : rbTorsions(numTorsions) { RBTorsionForce::RBTorsionForce(int numTorsions) : rbTorsions(numTorsions) {
} }
void RBTorsionForce::getTorsionParameters(int index, int& atom1, int& atom2, int& atom3, int& atom4, 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 {
atom1 = rbTorsions[index].atom1; particle1 = rbTorsions[index].particle1;
atom2 = rbTorsions[index].atom2; particle2 = rbTorsions[index].particle2;
atom3 = rbTorsions[index].atom3; particle3 = rbTorsions[index].particle3;
atom4 = rbTorsions[index].atom4; particle4 = rbTorsions[index].particle4;
c0 = rbTorsions[index].c[0]; c0 = rbTorsions[index].c[0];
c1 = rbTorsions[index].c[1]; c1 = rbTorsions[index].c[1];
c2 = rbTorsions[index].c[2]; c2 = rbTorsions[index].c[2];
...@@ -52,11 +52,11 @@ void RBTorsionForce::getTorsionParameters(int index, int& atom1, int& atom2, int ...@@ -52,11 +52,11 @@ void RBTorsionForce::getTorsionParameters(int index, int& atom1, int& atom2, int
c5 = rbTorsions[index].c[5]; c5 = rbTorsions[index].c[5];
} }
void RBTorsionForce::setTorsionParameters(int index, int atom1, int atom2, int atom3, int atom4, double c0, double c1, double c2, double c3, double c4, double c5) { void RBTorsionForce::setTorsionParameters(int index, int particle1, int particle2, int particle3, int particle4, double c0, double c1, double c2, double c3, double c4, double c5) {
rbTorsions[index].atom1 = atom1; rbTorsions[index].particle1 = particle1;
rbTorsions[index].atom2 = atom2; rbTorsions[index].particle2 = particle2;
rbTorsions[index].atom3 = atom3; rbTorsions[index].particle3 = particle3;
rbTorsions[index].atom4 = atom4; rbTorsions[index].particle4 = particle4;
rbTorsions[index].c[0] = c0; rbTorsions[index].c[0] = c0;
rbTorsions[index].c[1] = c1; rbTorsions[index].c[1] = c1;
rbTorsions[index].c[2] = c2; rbTorsions[index].c[2] = c2;
......
...@@ -68,9 +68,9 @@ const map<string, double>& State::getParameters() const { ...@@ -68,9 +68,9 @@ const map<string, double>& State::getParameters() const {
throw OpenMMException("Invoked getParameters() on a State which does not contain parameters."); throw OpenMMException("Invoked getParameters() on a State which does not contain parameters.");
return parameters; return parameters;
} }
State::State(double time, int numAtoms, DataType types) : types(types), time(time), ke(0), pe(0), State::State(double time, int numParticles, DataType types) : types(types), time(time), ke(0), pe(0),
positions( (types & Positions) == 0 ? 0 : numAtoms), velocities( (types & Velocities) == 0 ? 0 : numAtoms), positions( (types & Positions) == 0 ? 0 : numParticles), velocities( (types & Velocities) == 0 ? 0 : numParticles),
forces( (types & Forces) == 0 ? 0 : numAtoms) { forces( (types & Forces) == 0 ? 0 : numParticles) {
} }
vector<Vec3>& State::updPositions() { vector<Vec3>& State::updPositions() {
return positions; return positions;
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
using namespace OpenMM; using namespace OpenMM;
System::System(int numAtoms, int numConstraints) : masses(numAtoms), constraints(numConstraints), forces(0) { System::System(int numParticles, int numConstraints) : masses(numParticles), constraints(numConstraints), forces(0) {
for (int i = 0; i < numAtoms; ++i) for (int i = 0; i < numParticles; ++i)
masses[i] = 0.0; masses[i] = 0.0;
} }
...@@ -44,14 +44,14 @@ System::~System() { ...@@ -44,14 +44,14 @@ System::~System() {
delete forces[i]; delete forces[i];
} }
void System::getConstraintParameters(int index, int& atom1, int& atom2, double& distance) const { void System::getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const {
atom1 = constraints[index].atom1; particle1 = constraints[index].particle1;
atom2 = constraints[index].atom2; particle2 = constraints[index].particle2;
distance = constraints[index].distance; distance = constraints[index].distance;
} }
void System::setConstraintParameters(int index, int atom1, int atom2, double distance) { void System::setConstraintParameters(int index, int particle1, int particle2, double distance) {
constraints[index].atom1 = atom1; constraints[index].particle1 = particle1;
constraints[index].atom2 = atom2; constraints[index].particle2 = particle2;
constraints[index].distance = distance; constraints[index].distance = distance;
} }
...@@ -86,17 +86,17 @@ void CudaCalcHarmonicBondForceKernel::initialize(const System& system, const Har ...@@ -86,17 +86,17 @@ void CudaCalcHarmonicBondForceKernel::initialize(const System& system, const Har
data.primaryKernel = this; data.primaryKernel = this;
data.hasBonds = true; data.hasBonds = true;
numBonds = force.getNumBonds(); numBonds = force.getNumBonds();
vector<int> atom1(numBonds); vector<int> particle1(numBonds);
vector<int> atom2(numBonds); vector<int> particle2(numBonds);
vector<float> length(numBonds); vector<float> length(numBonds);
vector<float> k(numBonds); vector<float> k(numBonds);
for (int i = 0; i < numBonds; i++) { for (int i = 0; i < numBonds; i++) {
double lengthValue, kValue; double lengthValue, kValue;
force.getBondParameters(i, atom1[i], atom2[i], lengthValue, kValue); force.getBondParameters(i, particle1[i], particle2[i], lengthValue, kValue);
length[i] = (float) lengthValue; length[i] = (float) lengthValue;
k[i] = (float) kValue; k[i] = (float) kValue;
} }
gpuSetBondParameters(data.gpu, atom1, atom2, length, k); gpuSetBondParameters(data.gpu, particle1, particle2, length, k);
} }
void CudaCalcHarmonicBondForceKernel::executeForces(OpenMMContextImpl& context) { void CudaCalcHarmonicBondForceKernel::executeForces(OpenMMContextImpl& context) {
...@@ -119,18 +119,18 @@ void CudaCalcHarmonicAngleForceKernel::initialize(const System& system, const Ha ...@@ -119,18 +119,18 @@ void CudaCalcHarmonicAngleForceKernel::initialize(const System& system, const Ha
data.hasAngles = true; data.hasAngles = true;
numAngles = force.getNumAngles(); numAngles = force.getNumAngles();
const float RadiansToDegrees = 180.0/3.14159265; const float RadiansToDegrees = 180.0/3.14159265;
vector<int> atom1(numAngles); vector<int> particle1(numAngles);
vector<int> atom2(numAngles); vector<int> particle2(numAngles);
vector<int> atom3(numAngles); vector<int> particle3(numAngles);
vector<float> angle(numAngles); vector<float> angle(numAngles);
vector<float> k(numAngles); vector<float> k(numAngles);
for (int i = 0; i < numAngles; i++) { for (int i = 0; i < numAngles; i++) {
double angleValue, kValue; double angleValue, kValue;
force.getAngleParameters(i, atom1[i], atom2[i], atom3[i], angleValue, kValue); force.getAngleParameters(i, particle1[i], particle2[i], particle3[i], angleValue, kValue);
angle[i] = (float) (angleValue*RadiansToDegrees); angle[i] = (float) (angleValue*RadiansToDegrees);
k[i] = (float) kValue; k[i] = (float) kValue;
} }
gpuSetBondAngleParameters(data.gpu, atom1, atom2, atom3, angle, k); gpuSetBondAngleParameters(data.gpu, particle1, particle2, particle3, angle, k);
} }
void CudaCalcHarmonicAngleForceKernel::executeForces(OpenMMContextImpl& context) { void CudaCalcHarmonicAngleForceKernel::executeForces(OpenMMContextImpl& context) {
...@@ -153,20 +153,20 @@ void CudaCalcPeriodicTorsionForceKernel::initialize(const System& system, const ...@@ -153,20 +153,20 @@ void CudaCalcPeriodicTorsionForceKernel::initialize(const System& system, const
data.hasPeriodicTorsions = true; data.hasPeriodicTorsions = true;
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
const float RadiansToDegrees = 180.0/3.14159265; const float RadiansToDegrees = 180.0/3.14159265;
vector<int> atom1(numTorsions); vector<int> particle1(numTorsions);
vector<int> atom2(numTorsions); vector<int> particle2(numTorsions);
vector<int> atom3(numTorsions); vector<int> particle3(numTorsions);
vector<int> atom4(numTorsions); vector<int> particle4(numTorsions);
vector<float> k(numTorsions); vector<float> k(numTorsions);
vector<float> phase(numTorsions); vector<float> phase(numTorsions);
vector<int> periodicity(numTorsions); vector<int> periodicity(numTorsions);
for (int i = 0; i < numTorsions; i++) { for (int i = 0; i < numTorsions; i++) {
double kValue, phaseValue; double kValue, phaseValue;
force.getTorsionParameters(i, atom1[i], atom2[i], atom3[i], atom4[i], periodicity[i], phaseValue, kValue); force.getTorsionParameters(i, particle1[i], particle2[i], particle3[i], particle4[i], periodicity[i], phaseValue, kValue);
k[i] = (float) kValue; k[i] = (float) kValue;
phase[i] = (float) (phaseValue*RadiansToDegrees); phase[i] = (float) (phaseValue*RadiansToDegrees);
} }
gpuSetDihedralParameters(data.gpu, atom1, atom2, atom3, atom4, k, phase, periodicity); gpuSetDihedralParameters(data.gpu, particle1, particle2, particle3, particle4, k, phase, periodicity);
} }
void CudaCalcPeriodicTorsionForceKernel::executeForces(OpenMMContextImpl& context) { void CudaCalcPeriodicTorsionForceKernel::executeForces(OpenMMContextImpl& context) {
...@@ -188,10 +188,10 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors ...@@ -188,10 +188,10 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
data.primaryKernel = this; data.primaryKernel = this;
data.hasRB = true; data.hasRB = true;
numTorsions = force.getNumTorsions(); numTorsions = force.getNumTorsions();
vector<int> atom1(numTorsions); vector<int> particle1(numTorsions);
vector<int> atom2(numTorsions); vector<int> particle2(numTorsions);
vector<int> atom3(numTorsions); vector<int> particle3(numTorsions);
vector<int> atom4(numTorsions); vector<int> particle4(numTorsions);
vector<float> c0(numTorsions); vector<float> c0(numTorsions);
vector<float> c1(numTorsions); vector<float> c1(numTorsions);
vector<float> c2(numTorsions); vector<float> c2(numTorsions);
...@@ -200,7 +200,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors ...@@ -200,7 +200,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
vector<float> c5(numTorsions); vector<float> c5(numTorsions);
for (int i = 0; i < numTorsions; i++) { for (int i = 0; i < numTorsions; i++) {
double c[6]; double c[6];
force.getTorsionParameters(i, atom1[i], atom2[i], atom3[i], atom4[i], c[0], c[1], c[2], c[3], c[4], c[5]); force.getTorsionParameters(i, particle1[i], particle2[i], particle3[i], particle4[i], c[0], c[1], c[2], c[3], c[4], c[5]);
c0[i] = (float) c[0]; c0[i] = (float) c[0];
c1[i] = (float) c[1]; c1[i] = (float) c[1];
c2[i] = (float) c[2]; c2[i] = (float) c[2];
...@@ -208,7 +208,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors ...@@ -208,7 +208,7 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
c4[i] = (float) c[4]; c4[i] = (float) c[4];
c5[i] = (float) c[5]; c5[i] = (float) c[5];
} }
gpuSetRbDihedralParameters(data.gpu, atom1, atom2, atom3, atom4, c0, c1, c2, c3, c4, c5); gpuSetRbDihedralParameters(data.gpu, particle1, particle2, particle3, particle4, c0, c1, c2, c3, c4, c5);
} }
void CudaCalcRBTorsionForceKernel::executeForces(OpenMMContextImpl& context) { void CudaCalcRBTorsionForceKernel::executeForces(OpenMMContextImpl& context) {
...@@ -229,51 +229,51 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon ...@@ -229,51 +229,51 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
if (data.primaryKernel == NULL) if (data.primaryKernel == NULL)
data.primaryKernel = this; data.primaryKernel = this;
data.hasNonbonded = true; data.hasNonbonded = true;
numAtoms = force.getNumAtoms(); numParticles = force.getNumParticles();
num14 = force.getNumNonbonded14(); num14 = force.getNumNonbonded14();
_gpuContext* gpu = data.gpu; _gpuContext* gpu = data.gpu;
// Initialize nonbonded interactions. // Initialize nonbonded interactions.
{ {
vector<int> atom(numAtoms); vector<int> particle(numParticles);
vector<float> c6(numAtoms); vector<float> c6(numParticles);
vector<float> c12(numAtoms); vector<float> c12(numParticles);
vector<float> q(numAtoms); vector<float> q(numParticles);
vector<char> symbol; vector<char> symbol;
vector<vector<int> > exclusionList(numAtoms); vector<vector<int> > exclusionList(numParticles);
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numParticles; i++) {
double charge, radius, depth; double charge, radius, depth;
force.getAtomParameters(i, charge, radius, depth); force.getParticleParameters(i, charge, radius, depth);
atom[i] = i; particle[i] = i;
q[i] = (float) charge; q[i] = (float) charge;
c6[i] = (float) (4*depth*pow(radius, 6.0)); c6[i] = (float) (4*depth*pow(radius, 6.0));
c12[i] = (float) (4*depth*pow(radius, 12.0)); c12[i] = (float) (4*depth*pow(radius, 12.0));
exclusionList[i] = vector<int>(exclusions[i].begin(), exclusions[i].end()); exclusionList[i] = vector<int>(exclusions[i].begin(), exclusions[i].end());
exclusionList[i].push_back(i); exclusionList[i].push_back(i);
} }
gpuSetCoulombParameters(gpu, 138.935485f, atom, c6, c12, q, symbol, exclusionList); gpuSetCoulombParameters(gpu, 138.935485f, particle, c6, c12, q, symbol, exclusionList);
} }
// Initialize 1-4 nonbonded interactions. // Initialize 1-4 nonbonded interactions.
{ {
vector<int> atom1(num14); vector<int> particle1(num14);
vector<int> atom2(num14); vector<int> particle2(num14);
vector<float> c6(num14); vector<float> c6(num14);
vector<float> c12(num14); vector<float> c12(num14);
vector<float> q1(num14); vector<float> q1(num14);
vector<float> q2(num14); vector<float> q2(num14);
for (int i = 0; i < num14; i++) { for (int i = 0; i < num14; i++) {
double charge, sig, eps; double charge, sig, eps;
force.getNonbonded14Parameters(i, atom1[i], atom2[i], charge, sig, eps); force.getNonbonded14Parameters(i, particle1[i], particle2[i], charge, sig, eps);
c6[i] = (float) (4*eps*pow(sig, 6.0)); c6[i] = (float) (4*eps*pow(sig, 6.0));
c12[i] = (float) (4*eps*pow(sig, 12.0)); c12[i] = (float) (4*eps*pow(sig, 12.0));
float q = (float) std::sqrt(charge); float q = (float) std::sqrt(charge);
q1[i] = q; q1[i] = q;
q2[i] = q; q2[i] = q;
} }
gpuSetLJ14Parameters(gpu, 138.935485f, 1.0f, atom1, atom2, c6, c12, q1, q2); gpuSetLJ14Parameters(gpu, 138.935485f, 1.0f, particle1, particle2, c6, c12, q1, q2);
} }
} }
...@@ -292,19 +292,19 @@ CudaCalcGBSAOBCForceFieldKernel::~CudaCalcGBSAOBCForceFieldKernel() { ...@@ -292,19 +292,19 @@ CudaCalcGBSAOBCForceFieldKernel::~CudaCalcGBSAOBCForceFieldKernel() {
} }
void CudaCalcGBSAOBCForceFieldKernel::initialize(const System& system, const GBSAOBCForceField& force) { void CudaCalcGBSAOBCForceFieldKernel::initialize(const System& system, const GBSAOBCForceField& force) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
_gpuContext* gpu = data.gpu; _gpuContext* gpu = data.gpu;
vector<int> atom(numAtoms); vector<int> particle(numParticles);
vector<float> radius(numAtoms); vector<float> radius(numParticles);
vector<float> scale(numAtoms); vector<float> scale(numParticles);
for (int i = 0; i < numAtoms; i++) { for (int i = 0; i < numParticles; i++) {
double charge, atomRadius, scalingFactor; double charge, particleRadius, scalingFactor;
force.getAtomParameters(i, charge, atomRadius, scalingFactor); force.getParticleParameters(i, charge, particleRadius, scalingFactor);
atom[i] = i; particle[i] = i;
radius[i] = (float) atomRadius; radius[i] = (float) particleRadius;
scale[i] = (float) scalingFactor; scale[i] = (float) scalingFactor;
} }
gpuSetObcParameters(gpu, force.getSoluteDielectric(), force.getSolventDielectric(), atom, radius, scale); gpuSetObcParameters(gpu, force.getSoluteDielectric(), force.getSolventDielectric(), particle, radius, scale);
data.useOBC = true; data.useOBC = true;
} }
...@@ -331,31 +331,31 @@ void CudaIntegrateLangevinStepKernel::initialize(const System& system, const Lan ...@@ -331,31 +331,31 @@ void CudaIntegrateLangevinStepKernel::initialize(const System& system, const Lan
// Set masses. // Set masses.
_gpuContext* gpu = data.gpu; _gpuContext* gpu = data.gpu;
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
vector<float> mass(numAtoms); vector<float> mass(numParticles);
for (int i = 0; i < numAtoms; i++) for (int i = 0; i < numParticles; i++)
mass[i] = (float) system.getAtomMass(i); mass[i] = (float) system.getParticleMass(i);
gpuSetMass(gpu, mass); gpuSetMass(gpu, mass);
// Set constraints. // Set constraints.
int numConstraints = system.getNumConstraints(); int numConstraints = system.getNumConstraints();
vector<int> atom1(numConstraints); vector<int> particle1(numConstraints);
vector<int> atom2(numConstraints); vector<int> particle2(numConstraints);
vector<float> distance(numConstraints); vector<float> distance(numConstraints);
vector<float> invMass1(numConstraints); vector<float> invMass1(numConstraints);
vector<float> invMass2(numConstraints); vector<float> invMass2(numConstraints);
for (int i = 0; i < numConstraints; i++) { for (int i = 0; i < numConstraints; i++) {
int atom1Index, atom2Index; int particle1Index, particle2Index;
double constraintDistance; double constraintDistance;
system.getConstraintParameters(i, atom1Index, atom2Index, constraintDistance); system.getConstraintParameters(i, particle1Index, particle2Index, constraintDistance);
atom1[i] = atom1Index; particle1[i] = particle1Index;
atom2[i] = atom2Index; particle2[i] = particle2Index;
distance[i] = (float) constraintDistance; distance[i] = (float) constraintDistance;
invMass1[i] = 1.0f/mass[atom1Index]; invMass1[i] = 1.0f/mass[particle1Index];
invMass2[i] = 1.0f/mass[atom2Index]; invMass2[i] = 1.0f/mass[particle2Index];
} }
gpuSetShakeParameters(gpu, atom1, atom2, distance, invMass1, invMass2); gpuSetShakeParameters(gpu, particle1, particle2, distance, invMass1, invMass2);
// Initialize any terms that haven't already been handled by a Force. // Initialize any terms that haven't already been handled by a Force.
...@@ -433,10 +433,10 @@ void CudaIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, const ...@@ -433,10 +433,10 @@ void CudaIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, const
//} //}
void CudaCalcKineticEnergyKernel::initialize(const System& system) { void CudaCalcKineticEnergyKernel::initialize(const System& system) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
masses.resize(numAtoms); masses.resize(numParticles);
for (size_t i = 0; i < numAtoms; ++i) for (size_t i = 0; i < numParticles; ++i)
masses[i] = system.getAtomMass(i); masses[i] = system.getParticleMass(i);
} }
double CudaCalcKineticEnergyKernel::execute(OpenMMContextImpl& context) { double CudaCalcKineticEnergyKernel::execute(OpenMMContextImpl& context) {
......
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
* *
* @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
* @param force the NonbondedForce this kernel will be used for * @param force the NonbondedForce this kernel will be used for
* @param exclusions the i'th element lists the indices of all atoms with which the i'th atom should not interact through * @param exclusions the i'th element lists the indices of all particles with which the i'th particle should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from * nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation. * the standard nonbonded calculation.
*/ */
...@@ -215,7 +215,7 @@ public: ...@@ -215,7 +215,7 @@ public:
double executeEnergy(OpenMMContextImpl& context); double executeEnergy(OpenMMContextImpl& context);
private: private:
CudaPlatform::PlatformData& data; CudaPlatform::PlatformData& data;
int numAtoms, num14; int numParticles, num14;
System& system; System& system;
}; };
...@@ -293,7 +293,7 @@ public: ...@@ -293,7 +293,7 @@ public:
} }
~CudaIntegrateLangevinStepKernel(); ~CudaIntegrateLangevinStepKernel();
/** /**
* Initialize the kernel, setting up the atomic masses. * Initialize the kernel, setting up the particle masses.
* *
* @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
* @param integrator the LangevinIntegrator this kernel will be used for * @param integrator the LangevinIntegrator this kernel will be used for
...@@ -345,7 +345,7 @@ private: ...@@ -345,7 +345,7 @@ private:
//}; //};
// //
///** ///**
// * This kernel is invoked by AndersenThermostat at the start of each time step to adjust the atom velocities. // * This kernel is invoked by AndersenThermostat at the start of each time step to adjust the particle velocities.
// */ // */
//class CudaApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel { //class CudaApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel {
//public: //public:
...@@ -401,7 +401,7 @@ public: ...@@ -401,7 +401,7 @@ public:
CudaRemoveCMMotionKernel(std::string name, const Platform& platform, CudaPlatform::PlatformData& data) : RemoveCMMotionKernel(name, platform), data(data) { CudaRemoveCMMotionKernel(std::string name, const Platform& platform, CudaPlatform::PlatformData& data) : RemoveCMMotionKernel(name, platform), data(data) {
} }
/** /**
* Initialize the kernel, setting up the atomic masses. * Initialize the kernel, setting up the particle masses.
* *
* @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
* @param force the CMMotionRemover this kernel will be used for * @param force the CMMotionRemover this kernel will be used for
......
...@@ -63,8 +63,8 @@ const StreamFactory& CudaPlatform::getDefaultStreamFactory() const { ...@@ -63,8 +63,8 @@ const StreamFactory& CudaPlatform::getDefaultStreamFactory() const {
} }
void CudaPlatform::contextCreated(OpenMMContextImpl& context) const { void CudaPlatform::contextCreated(OpenMMContextImpl& context) const {
int numAtoms = context.getSystem().getNumAtoms(); int numParticles = context.getSystem().getNumParticles();
_gpuContext* gpu = (_gpuContext*) gpuInit(numAtoms); _gpuContext* gpu = (_gpuContext*) gpuInit(numParticles);
context.setPlatformData(new PlatformData(gpu)); context.setPlatformData(new PlatformData(gpu));
} }
......
...@@ -39,17 +39,17 @@ ...@@ -39,17 +39,17 @@
using namespace OpenMM; using namespace OpenMM;
StreamImpl* CudaStreamFactory::createStreamImpl(std::string name, int size, Stream::DataType type, const Platform& platform, OpenMMContextImpl& context) const { StreamImpl* CudaStreamFactory::createStreamImpl(std::string name, int size, Stream::DataType type, const Platform& platform, OpenMMContextImpl& context) const {
if (name == "atomPositions") { if (name == "particlePositions") {
CudaPlatform::PlatformData& data = *static_cast<CudaPlatform::PlatformData*>(context.getPlatformData()); CudaPlatform::PlatformData& data = *static_cast<CudaPlatform::PlatformData*>(context.getPlatformData());
float padding[] = {100000.0f, 100000.0f, 100000.0f, 0.2f}; float padding[] = {100000.0f, 100000.0f, 100000.0f, 0.2f};
return new CudaStreamImpl<float4>(name, size, type, platform, data.gpu->psPosq4, 4, padding); return new CudaStreamImpl<float4>(name, size, type, platform, data.gpu->psPosq4, 4, padding);
} }
if (name == "atomVelocities") { if (name == "particleVelocities") {
CudaPlatform::PlatformData& data = *static_cast<CudaPlatform::PlatformData*>(context.getPlatformData()); CudaPlatform::PlatformData& data = *static_cast<CudaPlatform::PlatformData*>(context.getPlatformData());
float padding[] = {0.0f, 0.0f, 0.0f, 0.0f}; float padding[] = {0.0f, 0.0f, 0.0f, 0.0f};
return new CudaStreamImpl<float4>(name, size, type, platform, data.gpu->psVelm4, 4, padding); return new CudaStreamImpl<float4>(name, size, type, platform, data.gpu->psVelm4, 4, padding);
} }
if (name == "atomForces") { if (name == "particleForces") {
CudaPlatform::PlatformData& data = *static_cast<CudaPlatform::PlatformData*>(context.getPlatformData()); CudaPlatform::PlatformData& data = *static_cast<CudaPlatform::PlatformData*>(context.getPlatformData());
float padding[] = {0.0f, 0.0f, 0.0f, 0.0f}; float padding[] = {0.0f, 0.0f, 0.0f, 0.0f};
return new CudaStreamImpl<float4>(name, size, type, platform, data.gpu->psForce4, 4, padding); return new CudaStreamImpl<float4>(name, size, type, platform, data.gpu->psForce4, 4, padding);
......
...@@ -51,35 +51,35 @@ using namespace std; ...@@ -51,35 +51,35 @@ using namespace std;
Vec3 calcCM(const vector<Vec3>& values, System& system) { Vec3 calcCM(const vector<Vec3>& values, System& system) {
Vec3 cm; Vec3 cm;
for (int j = 0; j < system.getNumAtoms(); ++j) { for (int j = 0; j < system.getNumParticles(); ++j) {
cm[0] += values[j][0]*system.getAtomMass(j); cm[0] += values[j][0]*system.getParticleMass(j);
cm[1] += values[j][1]*system.getAtomMass(j); cm[1] += values[j][1]*system.getParticleMass(j);
cm[2] += values[j][2]*system.getAtomMass(j); cm[2] += values[j][2]*system.getParticleMass(j);
} }
return cm; return cm;
} }
void testMotionRemoval() { void testMotionRemoval() {
const int numAtoms = 8; const int numParticles = 8;
CudaPlatform platform; CudaPlatform platform;
System system(numAtoms, 0); System system(numParticles, 0);
LangevinIntegrator integrator(0.0, 1e-5, 0.01); LangevinIntegrator integrator(0.0, 1e-5, 0.01);
HarmonicBondForce* bonds = new HarmonicBondForce(1); HarmonicBondForce* bonds = new HarmonicBondForce(1);
bonds->setBondParameters(0, 2, 3, 2.0, 0.5); bonds->setBondParameters(0, 2, 3, 2.0, 0.5);
system.addForce(bonds); system.addForce(bonds);
NonbondedForce* nonbonded = new NonbondedForce(numAtoms, 0); NonbondedForce* nonbonded = new NonbondedForce(numParticles, 0);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
system.setAtomMass(i, i+1); system.setParticleMass(i, i+1);
nonbonded->setAtomParameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0); nonbonded->setParticleParameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0);
} }
system.addForce(nonbonded); system.addForce(nonbonded);
CMMotionRemover* remover = new CMMotionRemover(); CMMotionRemover* remover = new CMMotionRemover();
system.addForce(remover); system.addForce(remover);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
vector<Vec3> positions(numAtoms); vector<Vec3> positions(numParticles);
vector<Vec3> velocities(numAtoms); vector<Vec3> velocities(numParticles);
init_gen_rand(0); init_gen_rand(0);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
positions[i] = Vec3((i%2 == 0 ? 2 : -2), (i%4 < 2 ? 2 : -2), (i < 4 ? 2 : -2)); positions[i] = Vec3((i%2 == 0 ? 2 : -2), (i%4 < 2 ? 2 : -2), (i < 4 ? 2 : -2));
velocities[i] = Vec3(genrand_real2()-0.5, genrand_real2()-0.5, genrand_real2()-0.5); velocities[i] = Vec3(genrand_real2()-0.5, genrand_real2()-0.5, genrand_real2()-0.5);
} }
......
...@@ -50,15 +50,15 @@ using namespace std; ...@@ -50,15 +50,15 @@ using namespace std;
const double TOL = 1e-5; const double TOL = 1e-5;
void testSingleAtom() { void testSingleParticle() {
CudaPlatform platform; CudaPlatform platform;
System system(1, 0); System system(1, 0);
system.setAtomMass(0, 2.0); system.setParticleMass(0, 2.0);
LangevinIntegrator integrator(0, 0.1, 0.01); LangevinIntegrator integrator(0, 0.1, 0.01);
GBSAOBCForceField* forceField = new GBSAOBCForceField(1); GBSAOBCForceField* forceField = new GBSAOBCForceField(1);
NonbondedForce* standard = new NonbondedForce(1, 0); NonbondedForce* standard = new NonbondedForce(1, 0);
forceField->setAtomParameters(0, 0.5, 0.15, 1); forceField->setParticleParameters(0, 0.5, 0.15, 1);
standard->setAtomParameters(0, 0.5, 1, 0); standard->setParticleParameters(0, 0.5, 1, 0);
system.addForce(forceField); system.addForce(forceField);
system.addForce(standard); system.addForce(standard);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
...@@ -76,25 +76,25 @@ void testSingleAtom() { ...@@ -76,25 +76,25 @@ void testSingleAtom() {
void testForce() { void testForce() {
CudaPlatform platform; CudaPlatform platform;
const int numAtoms = 10; const int numParticles = 10;
System system(numAtoms, 0); System system(numParticles, 0);
LangevinIntegrator integrator(0, 0.1, 0.01); LangevinIntegrator integrator(0, 0.1, 0.01);
GBSAOBCForceField* forceField = new GBSAOBCForceField(numAtoms); GBSAOBCForceField* forceField = new GBSAOBCForceField(numParticles);
NonbondedForce* standard = new NonbondedForce(numAtoms, 0); NonbondedForce* standard = new NonbondedForce(numParticles, 0);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
double charge = i%2 == 0 ? -1 : 1; double charge = i%2 == 0 ? -1 : 1;
forceField->setAtomParameters(i, charge, 0.15, 1); forceField->setParticleParameters(i, charge, 0.15, 1);
standard->setAtomParameters(i, charge, 1, 0); standard->setParticleParameters(i, charge, 1, 0);
} }
system.addForce(forceField); system.addForce(forceField);
system.addForce(standard); system.addForce(standard);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
// Set random positions for all the atoms. // Set random positions for all the particles.
vector<Vec3> positions(numAtoms); vector<Vec3> positions(numParticles);
init_gen_rand(0); init_gen_rand(0);
for (int i = 0; i < numAtoms; ++i) for (int i = 0; i < numParticles; ++i)
positions[i] = Vec3(5.0*genrand_real2(), 5.0*genrand_real2(), 5.0*genrand_real2()); positions[i] = Vec3(5.0*genrand_real2(), 5.0*genrand_real2(), 5.0*genrand_real2());
context.setPositions(positions); context.setPositions(positions);
State state = context.getState(State::Forces | State::Energy); State state = context.getState(State::Forces | State::Energy);
...@@ -102,14 +102,14 @@ void testForce() { ...@@ -102,14 +102,14 @@ void testForce() {
// Take a small step in the direction of the energy gradient. // Take a small step in the direction of the energy gradient.
double norm = 0.0; double norm = 0.0;
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
Vec3 f = state.getForces()[i]; Vec3 f = state.getForces()[i];
norm += f[0]*f[0] + f[1]*f[1] + f[2]*f[2]; norm += f[0]*f[0] + f[1]*f[1] + f[2]*f[2];
} }
norm = std::sqrt(norm); norm = std::sqrt(norm);
const double delta = 1e-3; const double delta = 1e-3;
double step = delta/norm; double step = delta/norm;
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
Vec3 p = positions[i]; Vec3 p = positions[i];
Vec3 f = state.getForces()[i]; Vec3 f = state.getForces()[i];
positions[i] = Vec3(p[0]-f[0]*step, p[1]-f[1]*step, p[2]-f[2]*step); positions[i] = Vec3(p[0]-f[0]*step, p[1]-f[1]*step, p[2]-f[2]*step);
...@@ -124,7 +124,7 @@ void testForce() { ...@@ -124,7 +124,7 @@ void testForce() {
int main() { int main() {
try { try {
testSingleAtom(); testSingleParticle();
testForce(); testForce();
} }
catch(const exception& e) { catch(const exception& e) {
......
...@@ -53,8 +53,8 @@ const double TOL = 1e-5; ...@@ -53,8 +53,8 @@ const double TOL = 1e-5;
void testSingleBond() { void testSingleBond() {
CudaPlatform platform; CudaPlatform platform;
System system(2, 0); System system(2, 0);
system.setAtomMass(0, 2.0); system.setParticleMass(0, 2.0);
system.setAtomMass(1, 2.0); system.setParticleMass(1, 2.0);
LangevinIntegrator integrator(0, 0.1, 0.01); LangevinIntegrator integrator(0, 0.1, 0.01);
HarmonicBondForce* forceField = new HarmonicBondForce(1); HarmonicBondForce* forceField = new HarmonicBondForce(1);
forceField->setBondParameters(0, 0, 1, 1.5, 1); forceField->setBondParameters(0, 0, 1, 1.5, 1);
...@@ -95,20 +95,20 @@ void testSingleBond() { ...@@ -95,20 +95,20 @@ void testSingleBond() {
} }
void testTemperature() { void testTemperature() {
const int numAtoms = 8; const int numParticles = 8;
const double temp = 100.0; const double temp = 100.0;
CudaPlatform platform; CudaPlatform platform;
System system(numAtoms, 0); System system(numParticles, 0);
LangevinIntegrator integrator(temp, 2.0, 0.01); LangevinIntegrator integrator(temp, 2.0, 0.01);
NonbondedForce* forceField = new NonbondedForce(numAtoms, 0); NonbondedForce* forceField = new NonbondedForce(numParticles, 0);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
system.setAtomMass(i, 2.0); system.setParticleMass(i, 2.0);
forceField->setAtomParameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0); forceField->setParticleParameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0);
} }
system.addForce(forceField); system.addForce(forceField);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
vector<Vec3> positions(numAtoms); vector<Vec3> positions(numParticles);
for (int i = 0; i < numAtoms; ++i) for (int i = 0; i < numParticles; ++i)
positions[i] = Vec3((i%2 == 0 ? 2 : -2), (i%4 < 2 ? 2 : -2), (i < 4 ? 2 : -2)); positions[i] = Vec3((i%2 == 0 ? 2 : -2), (i%4 < 2 ? 2 : -2), (i < 4 ? 2 : -2));
context.setPositions(positions); context.setPositions(positions);
...@@ -125,30 +125,30 @@ void testTemperature() { ...@@ -125,30 +125,30 @@ void testTemperature() {
integrator.step(1); integrator.step(1);
} }
ke /= 1000; ke /= 1000;
double expected = 0.5*numAtoms*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0)); ASSERT_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0));
} }
void testConstraints() { void testConstraints() {
const int numAtoms = 8; const int numParticles = 8;
const int numConstraints = 4; const int numConstraints = 4;
const double temp = 100.0; const double temp = 100.0;
CudaPlatform platform; CudaPlatform platform;
System system(numAtoms, numConstraints); System system(numParticles, numConstraints);
LangevinIntegrator integrator(temp, 2.0, 0.01); LangevinIntegrator integrator(temp, 2.0, 0.01);
NonbondedForce* forceField = new NonbondedForce(numAtoms, 0); NonbondedForce* forceField = new NonbondedForce(numParticles, 0);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
system.setAtomMass(i, 10.0); system.setParticleMass(i, 10.0);
forceField->setAtomParameters(i, (i%2 == 0 ? 0.2 : -0.2), 0.5, 5.0); forceField->setParticleParameters(i, (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.setConstraintParameters(i, 2*i, 2*i+1, 1.0);
system.addForce(forceField); system.addForce(forceField);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
vector<Vec3> positions(numAtoms); vector<Vec3> positions(numParticles);
vector<Vec3> velocities(numAtoms); vector<Vec3> velocities(numParticles);
init_gen_rand(0); init_gen_rand(0);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
positions[i] = Vec3(i/2, (i+1)/2, 0); positions[i] = Vec3(i/2, (i+1)/2, 0);
velocities[i] = Vec3(genrand_real2()-0.5, genrand_real2()-0.5, genrand_real2()-0.5); velocities[i] = Vec3(genrand_real2()-0.5, genrand_real2()-0.5, genrand_real2()-0.5);
} }
...@@ -160,11 +160,11 @@ void testConstraints() { ...@@ -160,11 +160,11 @@ void testConstraints() {
for (int i = 0; i < 1000; ++i) { for (int i = 0; i < 1000; ++i) {
State state = context.getState(State::Positions); State state = context.getState(State::Positions);
for (int j = 0; j < numConstraints; ++j) { for (int j = 0; j < numConstraints; ++j) {
int atom1, atom2; int particle1, particle2;
double distance; double distance;
system.getConstraintParameters(j, atom1, atom2, distance); system.getConstraintParameters(j, particle1, particle2, distance);
Vec3 p1 = state.getPositions()[atom1]; Vec3 p1 = state.getPositions()[particle1];
Vec3 p2 = state.getPositions()[atom2]; Vec3 p2 = state.getPositions()[particle2];
double dist = std::sqrt((p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1])+(p1[2]-p2[2])*(p1[2]-p2[2])); double dist = std::sqrt((p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1])+(p1[2]-p2[2])*(p1[2]-p2[2]));
ASSERT_EQUAL_TOL(distance, dist, 2e-4); ASSERT_EQUAL_TOL(distance, dist, 2e-4);
} }
......
...@@ -54,8 +54,8 @@ void testCoulomb() { ...@@ -54,8 +54,8 @@ void testCoulomb() {
System system(2, 0); System system(2, 0);
LangevinIntegrator integrator(0.0, 0.1, 0.01); LangevinIntegrator integrator(0.0, 0.1, 0.01);
NonbondedForce* forceField = new NonbondedForce(2, 0); NonbondedForce* forceField = new NonbondedForce(2, 0);
forceField->setAtomParameters(0, 0.5, 1, 0); forceField->setParticleParameters(0, 0.5, 1, 0);
forceField->setAtomParameters(1, -1.5, 1, 0); forceField->setParticleParameters(1, -1.5, 1, 0);
system.addForce(forceField); system.addForce(forceField);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
vector<Vec3> positions(2); vector<Vec3> positions(2);
...@@ -75,8 +75,8 @@ void testLJ() { ...@@ -75,8 +75,8 @@ void testLJ() {
System system(2, 0); System system(2, 0);
LangevinIntegrator integrator(0.0, 0.1, 0.01); LangevinIntegrator integrator(0.0, 0.1, 0.01);
NonbondedForce* forceField = new NonbondedForce(2, 0); NonbondedForce* forceField = new NonbondedForce(2, 0);
forceField->setAtomParameters(0, 0, 1.2, 1); forceField->setParticleParameters(0, 0, 1.2, 1);
forceField->setAtomParameters(1, 0, 1.4, 2); forceField->setParticleParameters(1, 0, 1.4, 2);
system.addForce(forceField); system.addForce(forceField);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
vector<Vec3> positions(2); vector<Vec3> positions(2);
...@@ -112,11 +112,11 @@ void testExclusionsAnd14() { ...@@ -112,11 +112,11 @@ void testExclusionsAnd14() {
vector<Vec3> positions(5); vector<Vec3> positions(5);
const double r = 1.0; const double r = 1.0;
for (int j = 0; j < 5; ++j) { for (int j = 0; j < 5; ++j) {
nonbonded->setAtomParameters(j, 0, 1.5, 0); nonbonded->setParticleParameters(j, 0, 1.5, 0);
positions[j] = Vec3(0, j, 0); positions[j] = Vec3(0, j, 0);
} }
nonbonded->setAtomParameters(0, 0, 1.5, 1); nonbonded->setParticleParameters(0, 0, 1.5, 1);
nonbonded->setAtomParameters(i, 0, 1.5, 1); nonbonded->setParticleParameters(i, 0, 1.5, 1);
nonbonded->setNonbonded14Parameters(0, 0, 3, 0, 1.5, i == 3 ? 0.5 : 0.0); nonbonded->setNonbonded14Parameters(0, 0, 3, 0, 1.5, i == 3 ? 0.5 : 0.0);
nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0.0); nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0.0);
positions[i] = Vec3(r, 0, 0); positions[i] = Vec3(r, 0, 0);
...@@ -142,8 +142,8 @@ void testExclusionsAnd14() { ...@@ -142,8 +142,8 @@ void testExclusionsAnd14() {
// Test Coulomb forces // Test Coulomb forces
nonbonded->setAtomParameters(0, 2, 1.5, 0); nonbonded->setParticleParameters(0, 2, 1.5, 0);
nonbonded->setAtomParameters(i, 2, 1.5, 0); nonbonded->setParticleParameters(i, 2, 1.5, 0);
nonbonded->setNonbonded14Parameters(0, 0, 3, i == 3 ? 4/1.2 : 0, 1.5, 0); nonbonded->setNonbonded14Parameters(0, 0, 3, i == 3 ? 4/1.2 : 0, 1.5, 0);
nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0); nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0);
OpenMMContext context2(system, integrator, platform); OpenMMContext context2(system, integrator, platform);
...@@ -171,9 +171,9 @@ void testCutoff() { ...@@ -171,9 +171,9 @@ void testCutoff() {
System system(3, 0); System system(3, 0);
LangevinIntegrator integrator(0.0, 0.1, 0.01); LangevinIntegrator integrator(0.0, 0.1, 0.01);
NonbondedForce* forceField = new NonbondedForce(3, 0); NonbondedForce* forceField = new NonbondedForce(3, 0);
forceField->setAtomParameters(0, 1.0, 1, 0); forceField->setParticleParameters(0, 1.0, 1, 0);
forceField->setAtomParameters(1, 1.0, 1, 0); forceField->setParticleParameters(1, 1.0, 1, 0);
forceField->setAtomParameters(2, 1.0, 1, 0); forceField->setParticleParameters(2, 1.0, 1, 0);
forceField->setNonbondedMethod(NonbondedForce::CutoffNonPeriodic); forceField->setNonbondedMethod(NonbondedForce::CutoffNonPeriodic);
const double cutoff = 2.9; const double cutoff = 2.9;
forceField->setCutoffDistance(cutoff); forceField->setCutoffDistance(cutoff);
...@@ -225,10 +225,10 @@ void testCutoff14() { ...@@ -225,10 +225,10 @@ void testCutoff14() {
// Test LJ forces // Test LJ forces
nonbonded->setAtomParameters(0, 0, 1.5, 1); nonbonded->setParticleParameters(0, 0, 1.5, 1);
for (int j = 1; j < 5; ++j) for (int j = 1; j < 5; ++j)
nonbonded->setAtomParameters(j, 0, 1.5, 0); nonbonded->setParticleParameters(j, 0, 1.5, 0);
nonbonded->setAtomParameters(i, 0, 1.5, 1); nonbonded->setParticleParameters(i, 0, 1.5, 1);
nonbonded->setNonbonded14Parameters(0, 0, 3, 0, 1.5, i == 3 ? 0.5 : 0.0); nonbonded->setNonbonded14Parameters(0, 0, 3, 0, 1.5, i == 3 ? 0.5 : 0.0);
nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0.0); nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0.0);
context.reinitialize(); context.reinitialize();
...@@ -255,8 +255,8 @@ void testCutoff14() { ...@@ -255,8 +255,8 @@ void testCutoff14() {
// Test Coulomb forces // Test Coulomb forces
const double q = 0.7; const double q = 0.7;
nonbonded->setAtomParameters(0, q, 1.5, 0); nonbonded->setParticleParameters(0, q, 1.5, 0);
nonbonded->setAtomParameters(i, q, 1.5, 0); nonbonded->setParticleParameters(i, q, 1.5, 0);
nonbonded->setNonbonded14Parameters(0, 0, 3, i == 3 ? q*q/1.2 : 0, 1.5, 0); nonbonded->setNonbonded14Parameters(0, 0, 3, i == 3 ? q*q/1.2 : 0, 1.5, 0);
nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0); nonbonded->setNonbonded14Parameters(1, 1, 4, 0, 1.5, 0);
context.reinitialize(); context.reinitialize();
...@@ -290,9 +290,9 @@ void testPeriodic() { ...@@ -290,9 +290,9 @@ void testPeriodic() {
bonds->setBondParameters(0, 0, 1, 1, 0); bonds->setBondParameters(0, 0, 1, 1, 0);
system.addForce(bonds); system.addForce(bonds);
NonbondedForce* nonbonded = new NonbondedForce(3, 0); NonbondedForce* nonbonded = new NonbondedForce(3, 0);
nonbonded->setAtomParameters(0, 1.0, 1, 0); nonbonded->setParticleParameters(0, 1.0, 1, 0);
nonbonded->setAtomParameters(1, 1.0, 1, 0); nonbonded->setParticleParameters(1, 1.0, 1, 0);
nonbonded->setAtomParameters(2, 1.0, 1, 0); nonbonded->setParticleParameters(2, 1.0, 1, 0);
nonbonded->setNonbondedMethod(NonbondedForce::CutoffPeriodic); nonbonded->setNonbondedMethod(NonbondedForce::CutoffPeriodic);
const double cutoff = 2.0; const double cutoff = 2.0;
nonbonded->setCutoffDistance(cutoff); nonbonded->setCutoffDistance(cutoff);
......
...@@ -114,11 +114,11 @@ void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, cons ...@@ -114,11 +114,11 @@ void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, cons
bondIndexArray = allocateIntArray(numBonds, 2); bondIndexArray = allocateIntArray(numBonds, 2);
bondParamArray = allocateRealArray(numBonds, 2); bondParamArray = allocateRealArray(numBonds, 2);
for (int i = 0; i < force.getNumBonds(); ++i) { for (int i = 0; i < force.getNumBonds(); ++i) {
int atom1, atom2; int particle1, particle2;
double length, k; double length, k;
force.getBondParameters(i, atom1, atom2, length, k); force.getBondParameters(i, particle1, particle2, length, k);
bondIndexArray[i][0] = atom1; bondIndexArray[i][0] = particle1;
bondIndexArray[i][1] = atom2; bondIndexArray[i][1] = particle2;
bondParamArray[i][0] = length; bondParamArray[i][0] = length;
bondParamArray[i][1] = k; bondParamArray[i][1] = k;
} }
...@@ -134,7 +134,7 @@ void ReferenceCalcHarmonicBondForceKernel::executeForces(OpenMMContextImpl& cont ...@@ -134,7 +134,7 @@ void ReferenceCalcHarmonicBondForceKernel::executeForces(OpenMMContextImpl& cont
double ReferenceCalcHarmonicBondForceKernel::executeEnergy(OpenMMContextImpl& context) { double ReferenceCalcHarmonicBondForceKernel::executeEnergy(OpenMMContextImpl& context) {
RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct
RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumAtoms(), 3); RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumParticles(), 3);
RealOpenMM* energyArray = new RealOpenMM[numBonds]; RealOpenMM* energyArray = new RealOpenMM[numBonds];
RealOpenMM energy = 0; RealOpenMM energy = 0;
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
...@@ -142,7 +142,7 @@ double ReferenceCalcHarmonicBondForceKernel::executeEnergy(OpenMMContextImpl& co ...@@ -142,7 +142,7 @@ double ReferenceCalcHarmonicBondForceKernel::executeEnergy(OpenMMContextImpl& co
for (int i = 0; i < numBonds; ++i) for (int i = 0; i < numBonds; ++i)
energyArray[i] = 0; energyArray[i] = 0;
refBondForce.calculateForce(numBonds, bondIndexArray, posData, bondParamArray, forceData, energyArray, 0, &energy, harmonicBond); refBondForce.calculateForce(numBonds, bondIndexArray, posData, bondParamArray, forceData, energyArray, 0, &energy, harmonicBond);
disposeRealArray(forceData, context.getSystem().getNumAtoms()); disposeRealArray(forceData, context.getSystem().getNumParticles());
delete[] energyArray; delete[] energyArray;
return energy; return energy;
} }
...@@ -157,12 +157,12 @@ void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, con ...@@ -157,12 +157,12 @@ void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, con
angleIndexArray = allocateIntArray(numAngles, 3); angleIndexArray = allocateIntArray(numAngles, 3);
angleParamArray = allocateRealArray(numAngles, 2); angleParamArray = allocateRealArray(numAngles, 2);
for (int i = 0; i < force.getNumAngles(); ++i) { for (int i = 0; i < force.getNumAngles(); ++i) {
int atom1, atom2, atom3; int particle1, particle2, particle3;
double angle, k; double angle, k;
force.getAngleParameters(i, atom1, atom2, atom3, angle, k); force.getAngleParameters(i, particle1, particle2, particle3, angle, k);
angleIndexArray[i][0] = atom1; angleIndexArray[i][0] = particle1;
angleIndexArray[i][1] = atom2; angleIndexArray[i][1] = particle2;
angleIndexArray[i][2] = atom3; angleIndexArray[i][2] = particle3;
angleParamArray[i][0] = angle; angleParamArray[i][0] = angle;
angleParamArray[i][1] = k; angleParamArray[i][1] = k;
} }
...@@ -178,7 +178,7 @@ void ReferenceCalcHarmonicAngleForceKernel::executeForces(OpenMMContextImpl& con ...@@ -178,7 +178,7 @@ void ReferenceCalcHarmonicAngleForceKernel::executeForces(OpenMMContextImpl& con
double ReferenceCalcHarmonicAngleForceKernel::executeEnergy(OpenMMContextImpl& context) { double ReferenceCalcHarmonicAngleForceKernel::executeEnergy(OpenMMContextImpl& context) {
RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct
RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumAtoms(), 3); RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumParticles(), 3);
RealOpenMM* energyArray = new RealOpenMM[numAngles]; RealOpenMM* energyArray = new RealOpenMM[numAngles];
RealOpenMM energy = 0; RealOpenMM energy = 0;
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
...@@ -186,7 +186,7 @@ double ReferenceCalcHarmonicAngleForceKernel::executeEnergy(OpenMMContextImpl& c ...@@ -186,7 +186,7 @@ double ReferenceCalcHarmonicAngleForceKernel::executeEnergy(OpenMMContextImpl& c
for (int i = 0; i < numAngles; ++i) for (int i = 0; i < numAngles; ++i)
energyArray[i] = 0; energyArray[i] = 0;
refBondForce.calculateForce(numAngles, angleIndexArray, posData, angleParamArray, forceData, energyArray, 0, &energy, angleBond); refBondForce.calculateForce(numAngles, angleIndexArray, posData, angleParamArray, forceData, energyArray, 0, &energy, angleBond);
disposeRealArray(forceData, context.getSystem().getNumAtoms()); disposeRealArray(forceData, context.getSystem().getNumParticles());
delete[] energyArray; delete[] energyArray;
return energy; return energy;
} }
...@@ -201,13 +201,13 @@ void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, c ...@@ -201,13 +201,13 @@ void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, c
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray = allocateIntArray(numTorsions, 4);
torsionParamArray = allocateRealArray(numTorsions, 3); torsionParamArray = allocateRealArray(numTorsions, 3);
for (int i = 0; i < force.getNumTorsions(); ++i) { for (int i = 0; i < force.getNumTorsions(); ++i) {
int atom1, atom2, atom3, atom4, periodicity; int particle1, particle2, particle3, particle4, periodicity;
double phase, k; double phase, k;
force.getTorsionParameters(i, atom1, atom2, atom3, atom4, periodicity, phase, k); force.getTorsionParameters(i, particle1, particle2, particle3, particle4, periodicity, phase, k);
torsionIndexArray[i][0] = atom1; torsionIndexArray[i][0] = particle1;
torsionIndexArray[i][1] = atom2; torsionIndexArray[i][1] = particle2;
torsionIndexArray[i][2] = atom3; torsionIndexArray[i][2] = particle3;
torsionIndexArray[i][3] = atom4; torsionIndexArray[i][3] = particle4;
torsionParamArray[i][0] = k; torsionParamArray[i][0] = k;
torsionParamArray[i][1] = phase; torsionParamArray[i][1] = phase;
torsionParamArray[i][2] = periodicity; torsionParamArray[i][2] = periodicity;
...@@ -224,7 +224,7 @@ void ReferenceCalcPeriodicTorsionForceKernel::executeForces(OpenMMContextImpl& c ...@@ -224,7 +224,7 @@ void ReferenceCalcPeriodicTorsionForceKernel::executeForces(OpenMMContextImpl& c
double ReferenceCalcPeriodicTorsionForceKernel::executeEnergy(OpenMMContextImpl& context) { double ReferenceCalcPeriodicTorsionForceKernel::executeEnergy(OpenMMContextImpl& context) {
RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct
RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumAtoms(), 3); RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumParticles(), 3);
RealOpenMM* energyArray = new RealOpenMM[numTorsions]; RealOpenMM* energyArray = new RealOpenMM[numTorsions];
RealOpenMM energy = 0; RealOpenMM energy = 0;
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
...@@ -232,7 +232,7 @@ double ReferenceCalcPeriodicTorsionForceKernel::executeEnergy(OpenMMContextImpl& ...@@ -232,7 +232,7 @@ double ReferenceCalcPeriodicTorsionForceKernel::executeEnergy(OpenMMContextImpl&
for (int i = 0; i < numTorsions; ++i) for (int i = 0; i < numTorsions; ++i)
energyArray[i] = 0; energyArray[i] = 0;
refBondForce.calculateForce(numTorsions, torsionIndexArray, posData, torsionParamArray, forceData, energyArray, 0, &energy, periodicTorsionBond); refBondForce.calculateForce(numTorsions, torsionIndexArray, posData, torsionParamArray, forceData, energyArray, 0, &energy, periodicTorsionBond);
disposeRealArray(forceData, context.getSystem().getNumAtoms()); disposeRealArray(forceData, context.getSystem().getNumParticles());
delete[] energyArray; delete[] energyArray;
return energy; return energy;
} }
...@@ -247,13 +247,13 @@ void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const R ...@@ -247,13 +247,13 @@ void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const R
torsionIndexArray = allocateIntArray(numTorsions, 4); torsionIndexArray = allocateIntArray(numTorsions, 4);
torsionParamArray = allocateRealArray(numTorsions, 6); torsionParamArray = allocateRealArray(numTorsions, 6);
for (int i = 0; i < force.getNumTorsions(); ++i) { for (int i = 0; i < force.getNumTorsions(); ++i) {
int atom1, atom2, atom3, atom4; int particle1, particle2, particle3, particle4;
double c0, c1, c2, c3, c4, c5; double c0, c1, c2, c3, c4, c5;
force.getTorsionParameters(i, atom1, atom2, atom3, atom4, c0, c1, c2, c3, c4, c5); force.getTorsionParameters(i, particle1, particle2, particle3, particle4, c0, c1, c2, c3, c4, c5);
torsionIndexArray[i][0] = atom1; torsionIndexArray[i][0] = particle1;
torsionIndexArray[i][1] = atom2; torsionIndexArray[i][1] = particle2;
torsionIndexArray[i][2] = atom3; torsionIndexArray[i][2] = particle3;
torsionIndexArray[i][3] = atom4; torsionIndexArray[i][3] = particle4;
torsionParamArray[i][0] = c0; torsionParamArray[i][0] = c0;
torsionParamArray[i][1] = c1; torsionParamArray[i][1] = c1;
torsionParamArray[i][2] = c2; torsionParamArray[i][2] = c2;
...@@ -273,7 +273,7 @@ void ReferenceCalcRBTorsionForceKernel::executeForces(OpenMMContextImpl& context ...@@ -273,7 +273,7 @@ void ReferenceCalcRBTorsionForceKernel::executeForces(OpenMMContextImpl& context
double ReferenceCalcRBTorsionForceKernel::executeEnergy(OpenMMContextImpl& context) { double ReferenceCalcRBTorsionForceKernel::executeEnergy(OpenMMContextImpl& context) {
RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct
RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumAtoms(), 3); RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumParticles(), 3);
RealOpenMM* energyArray = new RealOpenMM[numTorsions]; RealOpenMM* energyArray = new RealOpenMM[numTorsions];
RealOpenMM energy = 0; RealOpenMM energy = 0;
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
...@@ -281,14 +281,14 @@ double ReferenceCalcRBTorsionForceKernel::executeEnergy(OpenMMContextImpl& conte ...@@ -281,14 +281,14 @@ double ReferenceCalcRBTorsionForceKernel::executeEnergy(OpenMMContextImpl& conte
for (int i = 0; i < numTorsions; ++i) for (int i = 0; i < numTorsions; ++i)
energyArray[i] = 0; energyArray[i] = 0;
refBondForce.calculateForce(numTorsions, torsionIndexArray, posData, torsionParamArray, forceData, energyArray, 0, &energy, rbTorsionBond); refBondForce.calculateForce(numTorsions, torsionIndexArray, posData, torsionParamArray, forceData, energyArray, 0, &energy, rbTorsionBond);
disposeRealArray(forceData, context.getSystem().getNumAtoms()); disposeRealArray(forceData, context.getSystem().getNumParticles());
delete[] energyArray; delete[] energyArray;
return energy; return energy;
} }
ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() { ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() {
disposeRealArray(atomParamArray, numAtoms); disposeRealArray(particleParamArray, numParticles);
disposeIntArray(exclusionArray, numAtoms); disposeIntArray(exclusionArray, numParticles);
disposeIntArray(bonded14IndexArray, num14); disposeIntArray(bonded14IndexArray, num14);
disposeRealArray(bonded14ParamArray, num14); disposeRealArray(bonded14ParamArray, num14);
if (neighborList != NULL) if (neighborList != NULL)
...@@ -296,22 +296,22 @@ ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() { ...@@ -296,22 +296,22 @@ ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() {
} }
void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const NonbondedForce& force, const std::vector<std::set<int> >& exclusions) { void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const NonbondedForce& force, const std::vector<std::set<int> >& exclusions) {
numAtoms = force.getNumAtoms(); numParticles = force.getNumParticles();
num14 = force.getNumNonbonded14(); num14 = force.getNumNonbonded14();
bonded14IndexArray = allocateIntArray(num14, 2); bonded14IndexArray = allocateIntArray(num14, 2);
bonded14ParamArray = allocateRealArray(num14, 3); bonded14ParamArray = allocateRealArray(num14, 3);
atomParamArray = allocateRealArray(numAtoms, 3); particleParamArray = allocateRealArray(numParticles, 3);
RealOpenMM sqrtEps = static_cast<RealOpenMM>( std::sqrt(138.935485) ); RealOpenMM sqrtEps = static_cast<RealOpenMM>( std::sqrt(138.935485) );
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
double charge, radius, depth; double charge, radius, depth;
force.getAtomParameters(i, charge, radius, depth); force.getParticleParameters(i, charge, radius, depth);
atomParamArray[i][0] = static_cast<RealOpenMM>(0.5*radius); particleParamArray[i][0] = static_cast<RealOpenMM>(0.5*radius);
atomParamArray[i][1] = static_cast<RealOpenMM>(2.0*sqrt(depth)); particleParamArray[i][1] = static_cast<RealOpenMM>(2.0*sqrt(depth));
atomParamArray[i][2] = static_cast<RealOpenMM>(charge*sqrtEps); particleParamArray[i][2] = static_cast<RealOpenMM>(charge*sqrtEps);
} }
this->exclusions = exclusions; this->exclusions = exclusions;
exclusionArray = new int*[numAtoms]; exclusionArray = new int*[numParticles];
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
exclusionArray[i] = new int[exclusions[i].size()+1]; exclusionArray[i] = new int[exclusions[i].size()+1];
exclusionArray[i][0] = exclusions[i].size(); exclusionArray[i][0] = exclusions[i].size();
int index = 0; int index = 0;
...@@ -319,11 +319,11 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N ...@@ -319,11 +319,11 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
exclusionArray[i][++index] = *iter; exclusionArray[i][++index] = *iter;
} }
for (int i = 0; i < num14; ++i) { for (int i = 0; i < num14; ++i) {
int atom1, atom2; int particle1, particle2;
double charge, radius, depth; double charge, radius, depth;
force.getNonbonded14Parameters(i, atom1, atom2, charge, radius, depth); force.getNonbonded14Parameters(i, particle1, particle2, charge, radius, depth);
bonded14IndexArray[i][0] = atom1; bonded14IndexArray[i][0] = particle1;
bonded14IndexArray[i][1] = atom2; bonded14IndexArray[i][1] = particle2;
bonded14ParamArray[i][0] = static_cast<RealOpenMM>(radius); bonded14ParamArray[i][0] = static_cast<RealOpenMM>(radius);
bonded14ParamArray[i][1] = static_cast<RealOpenMM>(4.0*depth); bonded14ParamArray[i][1] = static_cast<RealOpenMM>(4.0*depth);
bonded14ParamArray[i][2] = static_cast<RealOpenMM>(charge*sqrtEps*sqrtEps); bonded14ParamArray[i][2] = static_cast<RealOpenMM>(charge*sqrtEps*sqrtEps);
...@@ -348,12 +348,12 @@ void ReferenceCalcNonbondedForceKernel::executeForces(OpenMMContextImpl& context ...@@ -348,12 +348,12 @@ void ReferenceCalcNonbondedForceKernel::executeForces(OpenMMContextImpl& context
ReferenceLJCoulombIxn clj; ReferenceLJCoulombIxn clj;
bool periodic = (nonbondedMethod == CutoffPeriodic); bool periodic = (nonbondedMethod == CutoffPeriodic);
if (nonbondedMethod != NoCutoff) { if (nonbondedMethod != NoCutoff) {
computeNeighborListVoxelHash(*neighborList, numAtoms, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0); computeNeighborListVoxelHash(*neighborList, numParticles, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0);
clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3f); clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3f);
} }
if (periodic) if (periodic)
clj.setPeriodic(periodicBoxSize); clj.setPeriodic(periodicBoxSize);
clj.calculatePairIxn(numAtoms, posData, atomParamArray, exclusionArray, 0, forceData, 0, 0); clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusionArray, 0, forceData, 0, 0);
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
ReferenceLJCoulomb14 nonbonded14; ReferenceLJCoulomb14 nonbonded14;
if (nonbondedMethod != NoCutoff) if (nonbondedMethod != NoCutoff)
...@@ -363,26 +363,26 @@ void ReferenceCalcNonbondedForceKernel::executeForces(OpenMMContextImpl& context ...@@ -363,26 +363,26 @@ void ReferenceCalcNonbondedForceKernel::executeForces(OpenMMContextImpl& context
double ReferenceCalcNonbondedForceKernel::executeEnergy(OpenMMContextImpl& context) { double ReferenceCalcNonbondedForceKernel::executeEnergy(OpenMMContextImpl& context) {
RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct
RealOpenMM** forceData = allocateRealArray(numAtoms, 3); RealOpenMM** forceData = allocateRealArray(numParticles, 3);
RealOpenMM energy = 0; RealOpenMM energy = 0;
ReferenceLJCoulombIxn clj; ReferenceLJCoulombIxn clj;
bool periodic = (nonbondedMethod == CutoffPeriodic); bool periodic = (nonbondedMethod == CutoffPeriodic);
if (nonbondedMethod != NoCutoff) { if (nonbondedMethod != NoCutoff) {
computeNeighborListVoxelHash(*neighborList, numAtoms, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0); computeNeighborListVoxelHash(*neighborList, numParticles, posData, exclusions, periodic ? periodicBoxSize : NULL, nonbondedCutoff, 0.0);
clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3f); clj.setUseCutoff(nonbondedCutoff, *neighborList, 78.3f);
} }
if (periodic) if (periodic)
clj.setPeriodic(periodicBoxSize); clj.setPeriodic(periodicBoxSize);
clj.calculatePairIxn(numAtoms, posData, atomParamArray, exclusionArray, 0, forceData, 0, &energy); clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusionArray, 0, forceData, 0, &energy);
ReferenceBondForce refBondForce; ReferenceBondForce refBondForce;
ReferenceLJCoulomb14 nonbonded14; ReferenceLJCoulomb14 nonbonded14;
if (nonbondedMethod != NoCutoff) if (nonbondedMethod != NoCutoff)
nonbonded14.setUseCutoff(nonbondedCutoff, 78.3f); nonbonded14.setUseCutoff(nonbondedCutoff, 78.3f);
RealOpenMM* energyArray = new RealOpenMM[numAtoms]; RealOpenMM* energyArray = new RealOpenMM[numParticles];
for (int i = 0; i < numAtoms; ++i) for (int i = 0; i < numParticles; ++i)
energyArray[i] = 0; energyArray[i] = 0;
refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, energyArray, 0, &energy, nonbonded14); refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, energyArray, 0, &energy, nonbonded14);
disposeRealArray(forceData, numAtoms); disposeRealArray(forceData, numParticles);
delete[] energyArray; delete[] energyArray;
return energy; return energy;
} }
...@@ -395,18 +395,18 @@ ReferenceCalcGBSAOBCForceFieldKernel::~ReferenceCalcGBSAOBCForceFieldKernel() { ...@@ -395,18 +395,18 @@ ReferenceCalcGBSAOBCForceFieldKernel::~ReferenceCalcGBSAOBCForceFieldKernel() {
} }
void ReferenceCalcGBSAOBCForceFieldKernel::initialize(const System& system, const GBSAOBCForceField& force) { void ReferenceCalcGBSAOBCForceFieldKernel::initialize(const System& system, const GBSAOBCForceField& force) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
charges.resize(numAtoms); charges.resize(numParticles);
vector<RealOpenMM> atomicRadii(numAtoms); vector<RealOpenMM> atomicRadii(numParticles);
vector<RealOpenMM> scaleFactors(numAtoms); vector<RealOpenMM> scaleFactors(numParticles);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
double charge, radius, scalingFactor; double charge, radius, scalingFactor;
force.getAtomParameters(i, charge, radius, scalingFactor); force.getParticleParameters(i, charge, radius, scalingFactor);
charges[i] = static_cast<RealOpenMM>(charge); charges[i] = static_cast<RealOpenMM>(charge);
atomicRadii[i] = static_cast<RealOpenMM>(radius); atomicRadii[i] = static_cast<RealOpenMM>(radius);
scaleFactors[i] = static_cast<RealOpenMM>(scalingFactor); scaleFactors[i] = static_cast<RealOpenMM>(scalingFactor);
} }
ObcParameters* obcParameters = new ObcParameters(numAtoms, ObcParameters::ObcTypeII); ObcParameters* obcParameters = new ObcParameters(numParticles, ObcParameters::ObcTypeII);
obcParameters->setAtomicRadii(atomicRadii); obcParameters->setAtomicRadii(atomicRadii);
obcParameters->setScaledRadiusFactors(scaleFactors); obcParameters->setScaledRadiusFactors(scaleFactors);
obcParameters->setSolventDielectric( static_cast<RealOpenMM>(force.getSolventDielectric()) ); obcParameters->setSolventDielectric( static_cast<RealOpenMM>(force.getSolventDielectric()) );
...@@ -423,9 +423,9 @@ void ReferenceCalcGBSAOBCForceFieldKernel::executeForces(OpenMMContextImpl& cont ...@@ -423,9 +423,9 @@ void ReferenceCalcGBSAOBCForceFieldKernel::executeForces(OpenMMContextImpl& cont
double ReferenceCalcGBSAOBCForceFieldKernel::executeEnergy(OpenMMContextImpl& context) { double ReferenceCalcGBSAOBCForceFieldKernel::executeEnergy(OpenMMContextImpl& context) {
RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct RealOpenMM** posData = const_cast<RealOpenMM**>(((ReferenceFloatStreamImpl&) context.getPositions().getImpl()).getData()); // Reference code needs to be made const correct
RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumAtoms(), 3); RealOpenMM** forceData = allocateRealArray(context.getSystem().getNumParticles(), 3);
obc->computeImplicitSolventForces(posData, &charges[0], forceData, 1); obc->computeImplicitSolventForces(posData, &charges[0], forceData, 1);
disposeRealArray(forceData, context.getSystem().getNumAtoms()); disposeRealArray(forceData, context.getSystem().getNumParticles());
return obc->getEnergy(); return obc->getEnergy();
} }
...@@ -443,19 +443,19 @@ ReferenceIntegrateVerletStepKernel::~ReferenceIntegrateVerletStepKernel() { ...@@ -443,19 +443,19 @@ ReferenceIntegrateVerletStepKernel::~ReferenceIntegrateVerletStepKernel() {
} }
void ReferenceIntegrateVerletStepKernel::initialize(const System& system, const VerletIntegrator& integrator) { void ReferenceIntegrateVerletStepKernel::initialize(const System& system, const VerletIntegrator& integrator) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
masses = new RealOpenMM[numAtoms]; masses = new RealOpenMM[numParticles];
for (size_t i = 0; i < numAtoms; ++i) for (size_t i = 0; i < numParticles; ++i)
masses[i] = static_cast<RealOpenMM>(system.getAtomMass(i)); masses[i] = static_cast<RealOpenMM>(system.getParticleMass(i));
numConstraints = system.getNumConstraints(); numConstraints = system.getNumConstraints();
constraintIndices = allocateIntArray(numConstraints, 2); constraintIndices = allocateIntArray(numConstraints, 2);
shakeParameters = allocateRealArray(numConstraints, 1); shakeParameters = allocateRealArray(numConstraints, 1);
for (int i = 0; i < numConstraints; ++i) { for (int i = 0; i < numConstraints; ++i) {
int atom1, atom2; int particle1, particle2;
double distance; double distance;
system.getConstraintParameters(i, atom1, atom2, distance); system.getConstraintParameters(i, particle1, particle2, distance);
constraintIndices[i][0] = atom1; constraintIndices[i][0] = particle1;
constraintIndices[i][1] = atom2; constraintIndices[i][1] = particle2;
shakeParameters[i][0] = static_cast<RealOpenMM>(distance); shakeParameters[i][0] = static_cast<RealOpenMM>(distance);
} }
} }
...@@ -472,12 +472,12 @@ void ReferenceIntegrateVerletStepKernel::execute(OpenMMContextImpl& context, con ...@@ -472,12 +472,12 @@ void ReferenceIntegrateVerletStepKernel::execute(OpenMMContextImpl& context, con
delete dynamics; delete dynamics;
delete shake; delete shake;
} }
dynamics = new ReferenceVerletDynamics(context.getSystem().getNumAtoms(), static_cast<RealOpenMM>(stepSize) ); dynamics = new ReferenceVerletDynamics(context.getSystem().getNumParticles(), static_cast<RealOpenMM>(stepSize) );
shake = new ReferenceShakeAlgorithm(numConstraints, constraintIndices, shakeParameters); shake = new ReferenceShakeAlgorithm(numConstraints, constraintIndices, shakeParameters);
dynamics->setReferenceShakeAlgorithm(shake); dynamics->setReferenceShakeAlgorithm(shake);
prevStepSize = stepSize; prevStepSize = stepSize;
} }
dynamics->update(context.getSystem().getNumAtoms(), posData, velData, forceData, masses); dynamics->update(context.getSystem().getNumParticles(), posData, velData, forceData, masses);
} }
ReferenceIntegrateLangevinStepKernel::~ReferenceIntegrateLangevinStepKernel() { ReferenceIntegrateLangevinStepKernel::~ReferenceIntegrateLangevinStepKernel() {
...@@ -494,19 +494,19 @@ ReferenceIntegrateLangevinStepKernel::~ReferenceIntegrateLangevinStepKernel() { ...@@ -494,19 +494,19 @@ ReferenceIntegrateLangevinStepKernel::~ReferenceIntegrateLangevinStepKernel() {
} }
void ReferenceIntegrateLangevinStepKernel::initialize(const System& system, const LangevinIntegrator& integrator) { void ReferenceIntegrateLangevinStepKernel::initialize(const System& system, const LangevinIntegrator& integrator) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
masses = new RealOpenMM[numAtoms]; masses = new RealOpenMM[numParticles];
for (size_t i = 0; i < numAtoms; ++i) for (size_t i = 0; i < numParticles; ++i)
masses[i] = static_cast<RealOpenMM>(system.getAtomMass(i)); masses[i] = static_cast<RealOpenMM>(system.getParticleMass(i));
numConstraints = system.getNumConstraints(); numConstraints = system.getNumConstraints();
constraintIndices = allocateIntArray(numConstraints, 2); constraintIndices = allocateIntArray(numConstraints, 2);
shakeParameters = allocateRealArray(numConstraints, 1); shakeParameters = allocateRealArray(numConstraints, 1);
for (int i = 0; i < numConstraints; ++i) { for (int i = 0; i < numConstraints; ++i) {
int atom1, atom2; int particle1, particle2;
double distance; double distance;
system.getConstraintParameters(i, atom1, atom2, distance); system.getConstraintParameters(i, particle1, particle2, distance);
constraintIndices[i][0] = atom1; constraintIndices[i][0] = particle1;
constraintIndices[i][1] = atom2; constraintIndices[i][1] = particle2;
shakeParameters[i][0] = static_cast<RealOpenMM>(distance); shakeParameters[i][0] = static_cast<RealOpenMM>(distance);
} }
} }
...@@ -527,7 +527,7 @@ void ReferenceIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, c ...@@ -527,7 +527,7 @@ void ReferenceIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, c
} }
RealOpenMM tau = static_cast<RealOpenMM>( friction == 0.0 ? 0.0 : 1.0/friction ); RealOpenMM tau = static_cast<RealOpenMM>( friction == 0.0 ? 0.0 : 1.0/friction );
dynamics = new ReferenceStochasticDynamics( dynamics = new ReferenceStochasticDynamics(
context.getSystem().getNumAtoms(), context.getSystem().getNumParticles(),
static_cast<RealOpenMM>(stepSize), static_cast<RealOpenMM>(stepSize),
static_cast<RealOpenMM>(tau), static_cast<RealOpenMM>(tau),
static_cast<RealOpenMM>(temperature) ); static_cast<RealOpenMM>(temperature) );
...@@ -537,7 +537,7 @@ void ReferenceIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, c ...@@ -537,7 +537,7 @@ void ReferenceIntegrateLangevinStepKernel::execute(OpenMMContextImpl& context, c
prevFriction = friction; prevFriction = friction;
prevStepSize = stepSize; prevStepSize = stepSize;
} }
dynamics->update(context.getSystem().getNumAtoms(), posData, velData, forceData, masses); dynamics->update(context.getSystem().getNumParticles(), posData, velData, forceData, masses);
} }
ReferenceIntegrateBrownianStepKernel::~ReferenceIntegrateBrownianStepKernel() { ReferenceIntegrateBrownianStepKernel::~ReferenceIntegrateBrownianStepKernel() {
...@@ -554,19 +554,19 @@ ReferenceIntegrateBrownianStepKernel::~ReferenceIntegrateBrownianStepKernel() { ...@@ -554,19 +554,19 @@ ReferenceIntegrateBrownianStepKernel::~ReferenceIntegrateBrownianStepKernel() {
} }
void ReferenceIntegrateBrownianStepKernel::initialize(const System& system, const BrownianIntegrator& integrator) { void ReferenceIntegrateBrownianStepKernel::initialize(const System& system, const BrownianIntegrator& integrator) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
masses = new RealOpenMM[numAtoms]; masses = new RealOpenMM[numParticles];
for (size_t i = 0; i < numAtoms; ++i) for (size_t i = 0; i < numParticles; ++i)
masses[i] = static_cast<RealOpenMM>(system.getAtomMass(i)); masses[i] = static_cast<RealOpenMM>(system.getParticleMass(i));
numConstraints = system.getNumConstraints(); numConstraints = system.getNumConstraints();
constraintIndices = allocateIntArray(numConstraints, 2); constraintIndices = allocateIntArray(numConstraints, 2);
shakeParameters = allocateRealArray(numConstraints, 1); shakeParameters = allocateRealArray(numConstraints, 1);
for (int i = 0; i < numConstraints; ++i) { for (int i = 0; i < numConstraints; ++i) {
int atom1, atom2; int particle1, particle2;
double distance; double distance;
system.getConstraintParameters(i, atom1, atom2, distance); system.getConstraintParameters(i, particle1, particle2, distance);
constraintIndices[i][0] = atom1; constraintIndices[i][0] = particle1;
constraintIndices[i][1] = atom2; constraintIndices[i][1] = particle2;
shakeParameters[i][0] = static_cast<RealOpenMM>(distance); shakeParameters[i][0] = static_cast<RealOpenMM>(distance);
} }
} }
...@@ -586,7 +586,7 @@ void ReferenceIntegrateBrownianStepKernel::execute(OpenMMContextImpl& context, c ...@@ -586,7 +586,7 @@ void ReferenceIntegrateBrownianStepKernel::execute(OpenMMContextImpl& context, c
delete shake; delete shake;
} }
dynamics = new ReferenceBrownianDynamics( dynamics = new ReferenceBrownianDynamics(
context.getSystem().getNumAtoms(), context.getSystem().getNumParticles(),
static_cast<RealOpenMM>(stepSize), static_cast<RealOpenMM>(stepSize),
static_cast<RealOpenMM>(friction), static_cast<RealOpenMM>(friction),
static_cast<RealOpenMM>(temperature) ); static_cast<RealOpenMM>(temperature) );
...@@ -596,7 +596,7 @@ void ReferenceIntegrateBrownianStepKernel::execute(OpenMMContextImpl& context, c ...@@ -596,7 +596,7 @@ void ReferenceIntegrateBrownianStepKernel::execute(OpenMMContextImpl& context, c
prevFriction = friction; prevFriction = friction;
prevStepSize = stepSize; prevStepSize = stepSize;
} }
dynamics->update(context.getSystem().getNumAtoms(), posData, velData, forceData, masses); dynamics->update(context.getSystem().getNumParticles(), posData, velData, forceData, masses);
} }
ReferenceApplyAndersenThermostatKernel::~ReferenceApplyAndersenThermostatKernel() { ReferenceApplyAndersenThermostatKernel::~ReferenceApplyAndersenThermostatKernel() {
...@@ -607,10 +607,10 @@ ReferenceApplyAndersenThermostatKernel::~ReferenceApplyAndersenThermostatKernel( ...@@ -607,10 +607,10 @@ ReferenceApplyAndersenThermostatKernel::~ReferenceApplyAndersenThermostatKernel(
} }
void ReferenceApplyAndersenThermostatKernel::initialize(const System& system, const AndersenThermostat& thermostat) { void ReferenceApplyAndersenThermostatKernel::initialize(const System& system, const AndersenThermostat& thermostat) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
masses = new RealOpenMM[numAtoms]; masses = new RealOpenMM[numParticles];
for (size_t i = 0; i < numAtoms; ++i) for (size_t i = 0; i < numParticles; ++i)
masses[i] = static_cast<RealOpenMM>(system.getAtomMass(i)); masses[i] = static_cast<RealOpenMM>(system.getParticleMass(i));
this->thermostat = new ReferenceAndersenThermostat(); this->thermostat = new ReferenceAndersenThermostat();
} }
...@@ -626,10 +626,10 @@ void ReferenceApplyAndersenThermostatKernel::execute(OpenMMContextImpl& context) ...@@ -626,10 +626,10 @@ void ReferenceApplyAndersenThermostatKernel::execute(OpenMMContextImpl& context)
} }
void ReferenceCalcKineticEnergyKernel::initialize(const System& system) { void ReferenceCalcKineticEnergyKernel::initialize(const System& system) {
int numAtoms = system.getNumAtoms(); int numParticles = system.getNumParticles();
masses.resize(numAtoms); masses.resize(numParticles);
for (size_t i = 0; i < numAtoms; ++i) for (size_t i = 0; i < numParticles; ++i)
masses[i] = system.getAtomMass(i); masses[i] = system.getParticleMass(i);
} }
double ReferenceCalcKineticEnergyKernel::execute(OpenMMContextImpl& context) { double ReferenceCalcKineticEnergyKernel::execute(OpenMMContextImpl& context) {
...@@ -642,9 +642,9 @@ double ReferenceCalcKineticEnergyKernel::execute(OpenMMContextImpl& context) { ...@@ -642,9 +642,9 @@ double ReferenceCalcKineticEnergyKernel::execute(OpenMMContextImpl& context) {
void ReferenceRemoveCMMotionKernel::initialize(const System& system, const CMMotionRemover& force) { void ReferenceRemoveCMMotionKernel::initialize(const System& system, const CMMotionRemover& force) {
frequency = force.getFrequency(); frequency = force.getFrequency();
masses.resize(system.getNumAtoms()); masses.resize(system.getNumParticles());
for (size_t i = 0; i < masses.size(); ++i) for (size_t i = 0; i < masses.size(); ++i)
masses[i] = system.getAtomMass(i); masses[i] = system.getParticleMass(i);
} }
void ReferenceRemoveCMMotionKernel::execute(OpenMMContextImpl& context) { void ReferenceRemoveCMMotionKernel::execute(OpenMMContextImpl& context) {
...@@ -662,7 +662,7 @@ void ReferenceRemoveCMMotionKernel::execute(OpenMMContextImpl& context) { ...@@ -662,7 +662,7 @@ void ReferenceRemoveCMMotionKernel::execute(OpenMMContextImpl& context) {
momentum[2] += static_cast<RealOpenMM>( masses[i]*velData[i][2] ); momentum[2] += static_cast<RealOpenMM>( masses[i]*velData[i][2] );
} }
// Adjust the atom velocities. // Adjust the particle velocities.
momentum[0] /= static_cast<RealOpenMM>( masses.size() ); momentum[0] /= static_cast<RealOpenMM>( masses.size() );
momentum[1] /= static_cast<RealOpenMM>( masses.size() ); momentum[1] /= static_cast<RealOpenMM>( masses.size() );
......
...@@ -194,7 +194,7 @@ public: ...@@ -194,7 +194,7 @@ public:
* *
* @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
* @param force the NonbondedForce this kernel will be used for * @param force the NonbondedForce this kernel will be used for
* @param exclusions the i'th element lists the indices of all atoms with which the i'th atom should not interact through * @param exclusions the i'th element lists the indices of all particles with which the i'th particle should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from * nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation. * the standard nonbonded calculation.
*/ */
...@@ -213,9 +213,9 @@ public: ...@@ -213,9 +213,9 @@ public:
*/ */
double executeEnergy(OpenMMContextImpl& context); double executeEnergy(OpenMMContextImpl& context);
private: private:
int numAtoms, num14; int numParticles, num14;
int **exclusionArray, **bonded14IndexArray; int **exclusionArray, **bonded14IndexArray;
RealOpenMM **atomParamArray, **bonded14ParamArray; RealOpenMM **particleParamArray, **bonded14ParamArray;
RealOpenMM nonbondedCutoff, periodicBoxSize[3]; RealOpenMM nonbondedCutoff, periodicBoxSize[3];
std::vector<std::set<int> > exclusions; std::vector<std::set<int> > exclusions;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
...@@ -298,7 +298,7 @@ public: ...@@ -298,7 +298,7 @@ public:
} }
~ReferenceIntegrateLangevinStepKernel(); ~ReferenceIntegrateLangevinStepKernel();
/** /**
* Initialize the kernel, setting up the atomic masses. * Initialize the kernel, setting up the particle masses.
* *
* @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
* @param integrator the LangevinIntegrator this kernel will be used for * @param integrator the LangevinIntegrator this kernel will be used for
...@@ -355,7 +355,7 @@ private: ...@@ -355,7 +355,7 @@ private:
}; };
/** /**
* This kernel is invoked by AndersenThermostat at the start of each time step to adjust the atom velocities. * This kernel is invoked by AndersenThermostat at the start of each time step to adjust the particle velocities.
*/ */
class ReferenceApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel { class ReferenceApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel {
public: public:
...@@ -411,7 +411,7 @@ public: ...@@ -411,7 +411,7 @@ public:
ReferenceRemoveCMMotionKernel(std::string name, const Platform& platform) : RemoveCMMotionKernel(name, platform) { ReferenceRemoveCMMotionKernel(std::string name, const Platform& platform) : RemoveCMMotionKernel(name, platform) {
} }
/** /**
* Initialize the kernel, setting up the atomic masses. * Initialize the kernel, setting up the particle masses.
* *
* @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
* @param force the CMMotionRemover this kernel will be used for * @param force the CMMotionRemover this kernel will be used for
......
...@@ -49,23 +49,23 @@ using namespace OpenMM; ...@@ -49,23 +49,23 @@ using namespace OpenMM;
using namespace std; using namespace std;
void testTemperature() { void testTemperature() {
const int numAtoms = 8; const int numParticles = 8;
const double temp = 100.0; const double temp = 100.0;
const double collisionFreq = 10.0; const double collisionFreq = 10.0;
ReferencePlatform platform; ReferencePlatform platform;
System system(numAtoms, 0); System system(numParticles, 0);
VerletIntegrator integrator(0.01); VerletIntegrator integrator(0.01);
NonbondedForce* forceField = new NonbondedForce(numAtoms, 0); NonbondedForce* forceField = new NonbondedForce(numParticles, 0);
for (int i = 0; i < numAtoms; ++i) { for (int i = 0; i < numParticles; ++i) {
system.setAtomMass(i, 2.0); system.setParticleMass(i, 2.0);
forceField->setAtomParameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0); forceField->setParticleParameters(i, (i%2 == 0 ? 1.0 : -1.0), 1.0, 5.0);
} }
system.addForce(forceField); system.addForce(forceField);
AndersenThermostat* thermstat = new AndersenThermostat(temp, collisionFreq); AndersenThermostat* thermstat = new AndersenThermostat(temp, collisionFreq);
system.addForce(thermstat); system.addForce(thermstat);
OpenMMContext context(system, integrator, platform); OpenMMContext context(system, integrator, platform);
vector<Vec3> positions(numAtoms); vector<Vec3> positions(numParticles);
for (int i = 0; i < numAtoms; ++i) for (int i = 0; i < numParticles; ++i)
positions[i] = Vec3((i%2 == 0 ? 2 : -2), (i%4 < 2 ? 2 : -2), (i < 4 ? 2 : -2)); positions[i] = Vec3((i%2 == 0 ? 2 : -2), (i%4 < 2 ? 2 : -2), (i < 4 ? 2 : -2));
context.setPositions(positions); context.setPositions(positions);
...@@ -82,7 +82,7 @@ void testTemperature() { ...@@ -82,7 +82,7 @@ void testTemperature() {
integrator.step(1); integrator.step(1);
} }
ke /= 1000; ke /= 1000;
double expected = 0.5*numAtoms*3*BOLTZ*temp; double expected = 0.5*numParticles*3*BOLTZ*temp;
ASSERT_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0)); ASSERT_EQUAL_TOL(expected, ke, 3*expected/std::sqrt(1000.0));
} }
......
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