Commit 420fac9c authored by Peter Eastman's avatar Peter Eastman
Browse files

Made constrained energy minimization hopefully more robust

parent 73b4405a
...@@ -169,6 +169,16 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI ...@@ -169,6 +169,16 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
break; // Further tightening the springs doesn't seem to be helping, so just give up. break; // Further tightening the springs doesn't seem to be helping, so just give up.
prevMaxError = maxError; prevMaxError = maxError;
k *= 10; k *= 10;
if (maxError > 100*constraintTol) {
// We've gotten far enough from a valid state that we might have trouble getting
// back, so reset to the original positions.
for (int i = 0; i < numParticles; i++) {
x[3*i] = initialPos[i][0];
x[3*i+1] = initialPos[i][1];
x[3*i+2] = initialPos[i][2];
}
}
} }
lbfgs_free(x); lbfgs_free(x);
} }
......
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