Unverified Commit e854f8f3 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fixed error in barostat (#4364)

parent 0e9ef3f8
......@@ -1693,7 +1693,7 @@ private:
ComputeContext& cc;
bool hasInitializedKernels, rigidMolecules, atomsWereReordered;
int numMolecules;
ComputeArray savedPositions, savedFloatForces, savedLongForces;
ComputeArray savedPositions, savedFloatForces, savedLongForces, savedVelocities;
ComputeArray moleculeAtoms;
ComputeArray moleculeStartIndex;
ComputeKernel kernel;
......
......@@ -8034,6 +8034,7 @@ void CommonApplyMonteCarloBarostatKernel::initialize(const System& system, const
this->rigidMolecules = rigidMolecules;
ContextSelector selector(cc);
savedPositions.initialize(cc, cc.getPaddedNumAtoms(), cc.getUseDoublePrecision() ? sizeof(mm_double4) : sizeof(mm_float4), "savedPositions");
savedVelocities.initialize(cc, cc.getPaddedNumAtoms(), cc.getUseDoublePrecision() || cc.getUseMixedPrecision() ? sizeof(mm_double4) : sizeof(mm_float4), "savedVelocities");
savedLongForces.initialize<long long>(cc, cc.getPaddedNumAtoms()*3, "savedLongForces");
try {
cc.getFloatForceBuffer(); // This will throw an exception on the CUDA platform.
......@@ -8049,6 +8050,7 @@ void CommonApplyMonteCarloBarostatKernel::initialize(const System& system, const
void CommonApplyMonteCarloBarostatKernel::saveCoordinates(ContextImpl& context) {
ContextSelector selector(cc);
cc.getPosq().copyTo(savedPositions);
cc.getVelm().copyTo(savedVelocities);
cc.getLongForceBuffer().copyTo(savedLongForces);
if (savedFloatForces.isInitialized())
cc.getFloatForceBuffer().copyTo(savedFloatForces);
......@@ -8112,6 +8114,7 @@ void CommonApplyMonteCarloBarostatKernel::scaleCoordinates(ContextImpl& context,
void CommonApplyMonteCarloBarostatKernel::restoreCoordinates(ContextImpl& context) {
ContextSelector selector(cc);
savedPositions.copyTo(cc.getPosq());
savedVelocities.copyTo(cc.getVelm());
savedLongForces.copyTo(cc.getLongForceBuffer());
cc.setPosCellOffsets(lastPosCellOffsets);
if (savedFloatForces.isInitialized())
......
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