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
5ee23330
"csrc/sm90/prefill/vscode:/vscode.git/clone" did not exist on "c3cf875a2fa607ae0c3d62fb228f5643d9606ce6"
Commit
5ee23330
authored
Apr 24, 2020
by
peastman
Browse files
CompoundIntegrator handles checkpoints correctly
parent
62394b00
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
3 deletions
+52
-3
openmmapi/include/openmm/CompoundIntegrator.h
openmmapi/include/openmm/CompoundIntegrator.h
+11
-1
openmmapi/src/CompoundIntegrator.cpp
openmmapi/src/CompoundIntegrator.cpp
+11
-1
tests/TestCompoundIntegrator.h
tests/TestCompoundIntegrator.h
+30
-1
No files found.
openmmapi/include/openmm/CompoundIntegrator.h
View file @
5ee23330
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015-20
16
Stanford University and the Authors. *
* Portions copyright (c) 2015-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -194,6 +194,16 @@ protected:
double
getVelocityTimeOffset
()
const
{
return
getIntegrator
(
0
).
getVelocityTimeOffset
();
}
/**
* This is called while writing checkpoints. It gives the integrator a chance to write
* its own data.
*/
void
createCheckpoint
(
std
::
ostream
&
stream
)
const
;
/**
* This is called while loading a checkpoint. The integrator should read in whatever
* data it wrote in createCheckpoint() and update its internal state accordingly.
*/
void
loadCheckpoint
(
std
::
istream
&
stream
);
private:
int
currentIntegrator
;
std
::
vector
<
Integrator
*>
integrators
;
...
...
openmmapi/src/CompoundIntegrator.cpp
View file @
5ee23330
...
...
@@ -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) 2015-20
16
Stanford University and the Authors. *
* Portions copyright (c) 2015-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -128,3 +128,13 @@ void CompoundIntegrator::stateChanged(State::DataType changed) {
double
CompoundIntegrator
::
computeKineticEnergy
()
{
return
integrators
[
currentIntegrator
]
->
computeKineticEnergy
();
}
void
CompoundIntegrator
::
createCheckpoint
(
std
::
ostream
&
stream
)
const
{
for
(
int
i
=
0
;
i
<
integrators
.
size
();
i
++
)
integrators
[
i
]
->
createCheckpoint
(
stream
);
}
void
CompoundIntegrator
::
loadCheckpoint
(
std
::
istream
&
stream
)
{
for
(
int
i
=
0
;
i
<
integrators
.
size
();
i
++
)
integrators
[
i
]
->
loadCheckpoint
(
stream
);
}
tests/TestCompoundIntegrator.h
View file @
5ee23330
...
...
@@ -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) 2015 Stanford University and the Authors.
*
* Portions copyright (c) 2015
-2020
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -33,6 +33,7 @@
#include "openmm/BrownianIntegrator.h"
#include "openmm/CompoundIntegrator.h"
#include "openmm/Context.h"
#include "openmm/CustomIntegrator.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/System.h"
...
...
@@ -208,6 +209,33 @@ void testDifferentStepSizes() {
}
}
void
testCheckpoint
()
{
// Test that member integrators get loaded correctly from checkpoints.
System
system
;
system
.
addParticle
(
1.0
);
CustomIntegrator
*
custom
=
new
CustomIntegrator
(
0.001
);
custom
->
addGlobalVariable
(
"a"
,
1.0
);
custom
->
addPerDofVariable
(
"b"
,
2.0
);
CompoundIntegrator
integrator
;
integrator
.
addIntegrator
(
custom
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
1
,
Vec3
());
context
.
setPositions
(
positions
);
custom
->
setGlobalVariable
(
0
,
5.0
);
vector
<
Vec3
>
b1
(
1
,
Vec3
(
1
,
2
,
3
));
custom
->
setPerDofVariable
(
0
,
b1
);
stringstream
checkpoint
;
context
.
createCheckpoint
(
checkpoint
);
custom
->
setGlobalVariable
(
0
,
10.0
);
vector
<
Vec3
>
b2
(
1
,
Vec3
(
4
,
5
,
6
));
custom
->
setPerDofVariable
(
0
,
b2
);
context
.
loadCheckpoint
(
checkpoint
);
ASSERT_EQUAL
(
5.0
,
custom
->
getGlobalVariable
(
0
));
vector
<
Vec3
>
b3
;
custom
->
getPerDofVariable
(
0
,
b3
);
ASSERT_EQUAL_VEC
(
b1
[
0
],
b3
[
0
],
1e-6
);
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -216,6 +244,7 @@ int main(int argc, char* argv[]) {
testChangingIntegrator
();
testChangingParameters
();
testDifferentStepSizes
();
testCheckpoint
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
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