Commit c13a8697 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed another error in CustomIntegrator

parent 90ddfc31
...@@ -6775,6 +6775,7 @@ void CudaIntegrateCustomStepKernel::recordGlobalValue(double value, GlobalTarget ...@@ -6775,6 +6775,7 @@ void CudaIntegrateCustomStepKernel::recordGlobalValue(double value, GlobalTarget
case DT: case DT:
if (value != globalValuesDouble[dtVariableIndex]) if (value != globalValuesDouble[dtVariableIndex])
deviceGlobalsAreCurrent = false; deviceGlobalsAreCurrent = false;
expressionSet.setVariable(dtVariableIndex, value);
globalValuesDouble[dtVariableIndex] = value; globalValuesDouble[dtVariableIndex] = value;
cu.getIntegrationUtilities().setNextStepSize(value); cu.getIntegrationUtilities().setNextStepSize(value);
break; break;
......
...@@ -7053,6 +7053,7 @@ void OpenCLIntegrateCustomStepKernel::recordGlobalValue(double value, GlobalTarg ...@@ -7053,6 +7053,7 @@ void OpenCLIntegrateCustomStepKernel::recordGlobalValue(double value, GlobalTarg
case DT: case DT:
if (value != globalValuesDouble[dtVariableIndex]) if (value != globalValuesDouble[dtVariableIndex])
deviceGlobalsAreCurrent = false; deviceGlobalsAreCurrent = false;
expressionSet.setVariable(dtVariableIndex, value);
globalValuesDouble[dtVariableIndex] = value; globalValuesDouble[dtVariableIndex] = value;
cl.getIntegrationUtilities().setNextStepSize(value); cl.getIntegrationUtilities().setNextStepSize(value);
break; break;
......
...@@ -391,21 +391,21 @@ void testSum() { ...@@ -391,21 +391,21 @@ void testSum() {
} }
CustomIntegrator integrator(0.005); CustomIntegrator integrator(0.005);
integrator.addGlobalVariable("ke", 0); integrator.addGlobalVariable("ke", 0);
integrator.addGlobalVariable("kecopy", 0); integrator.addGlobalVariable("temp", 0);
integrator.addComputePerDof("v", "v+dt*f/m"); integrator.addComputePerDof("v", "v+dt*f/m");
integrator.addComputePerDof("x", "x+dt*v"); integrator.addComputePerDof("x", "x+dt*v");
integrator.addComputeSum("ke", "m*v*v/2"); integrator.addComputeSum("ke", "m*v*v/2");
integrator.addComputeGlobal("kecopy", "ke"); integrator.addComputeGlobal("temp", "ke+dt");
Context context(system, integrator, platform); Context context(system, integrator, platform);
context.setPositions(positions); context.setPositions(positions);
// See if the sum is being computed correctly. // See if the sum is being computed correctly.
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
integrator.step(1);
State state = context.getState(State::Energy); State state = context.getState(State::Energy);
ASSERT_EQUAL_TOL(state.getKineticEnergy(), integrator.getGlobalVariable(0), 1e-5); ASSERT_EQUAL_TOL(state.getKineticEnergy(), integrator.getGlobalVariable(0), 1e-5);
ASSERT_EQUAL(integrator.getGlobalVariable(0), integrator.getGlobalVariable(1)); ASSERT_EQUAL_TOL(integrator.getGlobalVariable(0)+integrator.getStepSize(), integrator.getGlobalVariable(1), 1e-5);
integrator.step(1);
} }
} }
......
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