Skip to content

Commit

Permalink
Fixed bug in CustomIntegrator detecting changes to context parameters (
Browse files Browse the repository at this point in the history
  • Loading branch information
peastman authored Aug 28, 2023
1 parent e069e1f commit a0c7a7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions platforms/common/src/CommonKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7087,6 +7087,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
for (int i = 0; i < (int) parameterNames.size(); i++) {
double value = context.getParameter(parameterNames[i]);
if (value != localGlobalValues[parameterVariableIndex[i]]) {
expressionSet.setVariable(parameterVariableIndex[i], value);
localGlobalValues[parameterVariableIndex[i]] = value;
deviceGlobalsAreCurrent = false;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/TestCustomIntegrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ void testParameter() {
integrator.step(1);
ASSERT_EQUAL_TOL(context.getParameter("AndersenTemperature"), 0.1*(1<<(i+1)), 1e-10);
}
context.setParameter("AndersenTemperature", -5.0);
integrator.step(1);
ASSERT_EQUAL(-5.0, integrator.getGlobalVariable(0));
ASSERT_EQUAL(-10.0, context.getParameter("AndersenTemperature"));
}

/**
Expand Down

0 comments on commit a0c7a7c

Please sign in to comment.