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
cce10705
Commit
cce10705
authored
Apr 22, 2016
by
peastman
Browse files
Improved minimization with strict constraint tolerance
parent
95584c96
Changes
1
Show 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 @
cce10705
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* 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 *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -108,7 +108,8 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
...
@@ -108,7 +108,8 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
if
(
x
==
NULL
)
if
(
x
==
NULL
)
throw
OpenMMException
(
"LocalEnergyMinimizer: Failed to allocate memory"
);
throw
OpenMMException
(
"LocalEnergyMinimizer: Failed to allocate memory"
);
double
constraintTol
=
context
.
getIntegrator
().
getConstraintTolerance
();
double
constraintTol
=
context
.
getIntegrator
().
getConstraintTolerance
();
double
k
=
tolerance
/
constraintTol
;
double
workingConstraintTol
=
max
(
1e-4
,
constraintTol
);
double
k
=
tolerance
/
workingConstraintTol
;
// Initialize the minimizer.
// Initialize the minimizer.
...
@@ -121,7 +122,7 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
...
@@ -121,7 +122,7 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
// Make sure the initial configuration satisfies all constraints.
// 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.
// 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
...
@@ -162,14 +163,14 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
if
(
error
>
maxError
)
if
(
error
>
maxError
)
maxError
=
error
;
maxError
=
error
;
}
}
if
(
maxError
<=
c
onstraintTol
)
if
(
maxError
<=
workingC
onstraintTol
)
break
;
// All constraints are satisfied.
break
;
// All constraints are satisfied.
context
.
setPositions
(
initialPos
);
context
.
setPositions
(
initialPos
);
if
(
maxError
>=
prevMaxError
)
if
(
maxError
>=
prevMaxError
)
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
*
c
onstraintTol
)
{
if
(
maxError
>
100
*
workingC
onstraintTol
)
{
// We've gotten far enough from a valid state that we might have trouble getting
// We've gotten far enough from a valid state that we might have trouble getting
// back, so reset to the original positions.
// back, so reset to the original positions.
...
@@ -181,5 +182,11 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
...
@@ -181,5 +182,11 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
}
}
}
}
lbfgs_free
(
x
);
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