Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
7e877240
Commit
7e877240
authored
Apr 25, 2016
by
peastman
Browse files
Merge pull request #1470 from peastman/minimize
Improved minimization with strict constraint tolerance
parents
95584c96
cce10705
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
openmmapi/src/LocalEnergyMinimizer.cpp
openmmapi/src/LocalEnergyMinimizer.cpp
+12
-5
No files found.
openmmapi/src/LocalEnergyMinimizer.cpp
View file @
7e877240
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -108,7 +108,8 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
if
(
x
==
NULL
)
throw
OpenMMException
(
"LocalEnergyMinimizer: Failed to allocate memory"
);
double
constraintTol
=
context
.
getIntegrator
().
getConstraintTolerance
();
double
k
=
tolerance
/
constraintTol
;
double
workingConstraintTol
=
max
(
1e-4
,
constraintTol
);
double
k
=
tolerance
/
workingConstraintTol
;
// Initialize the minimizer.
...
...
@@ -121,7 +122,7 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
// Make sure the initial configuration satisfies all constraints.
context
.
applyConstraints
(
c
onstraintTol
);
context
.
applyConstraints
(
workingC
onstraintTol
);
// Record the initial positions and determine a normalization constant for scaling the tolerance.
...
...
@@ -162,14 +163,14 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
if
(
error
>
maxError
)
maxError
=
error
;
}
if
(
maxError
<=
c
onstraintTol
)
if
(
maxError
<=
workingC
onstraintTol
)
break
;
// All constraints are satisfied.
context
.
setPositions
(
initialPos
);
if
(
maxError
>=
prevMaxError
)
break
;
// Further tightening the springs doesn't seem to be helping, so just give up.
prevMaxError
=
maxError
;
k
*=
10
;
if
(
maxError
>
100
*
c
onstraintTol
)
{
if
(
maxError
>
100
*
workingC
onstraintTol
)
{
// We've gotten far enough from a valid state that we might have trouble getting
// back, so reset to the original positions.
...
...
@@ -181,5 +182,11 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
}
}
lbfgs_free
(
x
);
// If necessary, do a final constraint projection to make sure they are satisfied
// to the full precision requested by the user.
if
(
constraintTol
<
workingConstraintTol
)
context
.
applyConstraints
(
workingConstraintTol
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment