Unverified Commit 2c78200c authored by Andy Simmonett's avatar Andy Simmonett
Browse files

Clean up reference code, fix silly CUDA bug I just introduced

parent d6fe5f61
...@@ -8705,13 +8705,13 @@ std::pair<double, double> CudaNoseHooverChainKernel::computeMaskedKineticEnergy( ...@@ -8705,13 +8705,13 @@ std::pair<double, double> CudaNoseHooverChainKernel::computeMaskedKineticEnergy(
kineticEnergyBuffer.upload(zeros); kineticEnergyBuffer.upload(zeros);
} }
} }
cu.clearBuffer(cu.getEnergyBuffer()); cu.clearBuffer(energyBuffer);
if (nAtoms) { if (nAtoms) {
void *args[] = {&cu.getEnergyBuffer().getDevicePointer(),&nAtoms, &cu.getVelm().getDevicePointer(), &atomlists[chainID].getDevicePointer()}; void *args[] = {&energyBuffer.getDevicePointer(),&nAtoms, &cu.getVelm().getDevicePointer(), &atomlists[chainID].getDevicePointer()};
cu.executeKernel(computeAtomsKineticEnergyKernel, args, nAtoms); cu.executeKernel(computeAtomsKineticEnergyKernel, args, nAtoms);
} }
if (nPairs) { if (nPairs) {
void *args[] = {&cu.getEnergyBuffer().getDevicePointer(),&nPairs, &cu.getVelm().getDevicePointer(), &pairlists[chainID].getDevicePointer()}; void *args[] = {&energyBuffer.getDevicePointer(),&nPairs, &cu.getVelm().getDevicePointer(), &pairlists[chainID].getDevicePointer()};
cu.executeKernel(computePairsKineticEnergyKernel, args, nPairs); cu.executeKernel(computePairsKineticEnergyKernel, args, nPairs);
} }
......
...@@ -105,11 +105,9 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const ...@@ -105,11 +105,9 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
// Regular atoms // Regular atoms
for (const auto &atom : atomList) { for (const auto &atom : atomList) {
if (masses[atom] != 0.0) { if (masses[atom] != 0.0) {
for (int xyz = 0; xyz < 3; ++xyz) { velocities[atom] += 0.5 * inverseMasses[atom]*forces[atom]*getDeltaT();
velocities[atom][xyz] += 0.5 * inverseMasses[atom]*forces[atom][xyz]*getDeltaT(); xPrime[atom] = atomCoordinates[atom];
xPrime[atom][xyz] = atomCoordinates[atom][xyz]; atomCoordinates[atom] += velocities[atom]*getDeltaT();
atomCoordinates[atom][xyz] += velocities[atom][xyz]*getDeltaT();
}
} }
} }
// Connected particles // Connected particles
...@@ -129,18 +127,14 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const ...@@ -129,18 +127,14 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
comVel += 0.5 * comForce * getDeltaT() * invTotMass; comVel += 0.5 * comForce * getDeltaT() * invTotMass;
relVel += 0.5 * relForce * getDeltaT() * invRedMass; relVel += 0.5 * relForce * getDeltaT() * invRedMass;
if (m1 != 0.0) { if (m1 != 0.0) {
for (int xyz = 0; xyz < 3; ++xyz) { velocities[atom1] = comVel - relVel*mass2fract;
velocities[atom1][xyz] = comVel[xyz] - relVel[xyz]*mass2fract; xPrime[atom1] = atomCoordinates[atom1];
xPrime[atom1][xyz] = atomCoordinates[atom1][xyz]; atomCoordinates[atom1] += velocities[atom1]*getDeltaT();
atomCoordinates[atom1][xyz] += velocities[atom1][xyz]*getDeltaT();
}
} }
if (m2 != 0.0) { if (m2 != 0.0) {
for (int xyz = 0; xyz < 3; ++xyz) { velocities[atom2] = comVel + relVel*mass1fract;
velocities[atom2][xyz] = comVel[xyz] + relVel[xyz]*mass1fract; xPrime[atom2] = atomCoordinates[atom2];
xPrime[atom2][xyz] = atomCoordinates[atom2][xyz]; atomCoordinates[atom2] += velocities[atom2]*getDeltaT();
atomCoordinates[atom2][xyz] += velocities[atom2][xyz]*getDeltaT();
}
} }
} }
...@@ -235,9 +229,7 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const ...@@ -235,9 +229,7 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
// Regular atoms // Regular atoms
for (const auto &atom : atomList) { for (const auto &atom : atomList) {
if (masses[atom] != 0.0) { if (masses[atom] != 0.0) {
for (int xyz = 0; xyz < 3; ++xyz) { velocities[atom] += 0.5 * inverseMasses[atom]*forces[atom]*getDeltaT() + (atomCoordinates[atom] - xPrime[atom])/getDeltaT();
velocities[atom][xyz] += 0.5 * inverseMasses[atom]*forces[atom][xyz]*getDeltaT() + (atomCoordinates[atom][xyz] - xPrime[atom][xyz])/getDeltaT();
}
} }
} }
// Connected particles // Connected particles
...@@ -257,14 +249,10 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const ...@@ -257,14 +249,10 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
comVel += 0.5 * comForce * getDeltaT() * invTotMass; comVel += 0.5 * comForce * getDeltaT() * invTotMass;
relVel += 0.5 * relForce * getDeltaT() * invRedMass; relVel += 0.5 * relForce * getDeltaT() * invRedMass;
if (m1 != 0.0) { if (m1 != 0.0) {
for (int xyz = 0; xyz < 3; ++xyz) { velocities[atom1] = comVel - relVel*mass2fract + (atomCoordinates[atom1] - xPrime[atom1])/getDeltaT();
velocities[atom1][xyz] = comVel[xyz] - relVel[xyz]*mass2fract + (atomCoordinates[atom1][xyz] - xPrime[atom1][xyz])/getDeltaT();
}
} }
if (m2 != 0.0) { if (m2 != 0.0) {
for (int xyz = 0; xyz < 3; ++xyz) { velocities[atom2] = comVel + relVel*mass1fract + (atomCoordinates[atom2] - xPrime[atom2])/getDeltaT();
velocities[atom2][xyz] = comVel[xyz] + relVel[xyz]*mass1fract + (atomCoordinates[atom2][xyz] - xPrime[atom2][xyz])/getDeltaT();
}
} }
} }
if (referenceConstraintAlgorithm) if (referenceConstraintAlgorithm)
......
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