"vscode:/vscode.git/clone" did not exist on "add2bbeee88933f4ffe9066fb8a41fce561c8086"
Commit 1375899c authored by Peter Eastman's avatar Peter Eastman
Browse files

Prevent exception when calling getState() before step() has been called.

parent 30fa6ecb
...@@ -86,6 +86,15 @@ void RPMDIntegrator::setVelocities(int copy, const vector<Vec3>& velocities) { ...@@ -86,6 +86,15 @@ void RPMDIntegrator::setVelocities(int copy, const vector<Vec3>& velocities) {
} }
State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int groups) { State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int groups) {
if (isFirstStep) {
// Call setPositions() on the Context so it doesn't think the user is trying to
// run a simulation without setting positions first. These positions will
// immediately get overwritten by the ones stored in this integrator.
vector<Vec3> p(context->getSystem().getNumParticles(), Vec3());
context->getOwner().setPositions(p);
isFirstStep = false;
}
kernel.getAs<IntegrateRPMDStepKernel>().copyToContext(copy, *context); kernel.getAs<IntegrateRPMDStepKernel>().copyToContext(copy, *context);
return context->getOwner().getState(types, enforcePeriodicBox, groups); return context->getOwner().getState(types, enforcePeriodicBox, groups);
} }
......
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