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