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
c096fa02
Commit
c096fa02
authored
Jun 10, 2015
by
peastman
Browse files
Merge pull request #959 from kyleabeauchamp/intsegfault
Add check for null context inside integrator.step()
parents
d557fa41
8be6e843
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
32 additions
and
10 deletions
+32
-10
openmmapi/src/BrownianIntegrator.cpp
openmmapi/src/BrownianIntegrator.cpp
+2
-0
openmmapi/src/CustomIntegrator.cpp
openmmapi/src/CustomIntegrator.cpp
+2
-0
openmmapi/src/LangevinIntegrator.cpp
openmmapi/src/LangevinIntegrator.cpp
+2
-0
openmmapi/src/VariableLangevinIntegrator.cpp
openmmapi/src/VariableLangevinIntegrator.cpp
+4
-0
openmmapi/src/VariableVerletIntegrator.cpp
openmmapi/src/VariableVerletIntegrator.cpp
+4
-0
openmmapi/src/VerletIntegrator.cpp
openmmapi/src/VerletIntegrator.cpp
+2
-0
plugins/drude/openmmapi/src/DrudeLangevinIntegrator.cpp
plugins/drude/openmmapi/src/DrudeLangevinIntegrator.cpp
+2
-0
plugins/drude/openmmapi/src/DrudeSCFIntegrator.cpp
plugins/drude/openmmapi/src/DrudeSCFIntegrator.cpp
+2
-0
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
+12
-10
No files found.
openmmapi/src/BrownianIntegrator.cpp
View file @
c096fa02
...
@@ -72,6 +72,8 @@ double BrownianIntegrator::computeKineticEnergy() {
...
@@ -72,6 +72,8 @@ double BrownianIntegrator::computeKineticEnergy() {
}
}
void
BrownianIntegrator
::
step
(
int
steps
)
{
void
BrownianIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
...
openmmapi/src/CustomIntegrator.cpp
View file @
c096fa02
...
@@ -94,6 +94,8 @@ double CustomIntegrator::computeKineticEnergy() {
...
@@ -94,6 +94,8 @@ double CustomIntegrator::computeKineticEnergy() {
}
}
void
CustomIntegrator
::
step
(
int
steps
)
{
void
CustomIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
globalsAreCurrent
=
false
;
globalsAreCurrent
=
false
;
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
execute
(
*
context
,
*
this
,
forcesAreValid
);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
execute
(
*
context
,
*
this
,
forcesAreValid
);
...
...
openmmapi/src/LangevinIntegrator.cpp
View file @
c096fa02
...
@@ -72,6 +72,8 @@ double LangevinIntegrator::computeKineticEnergy() {
...
@@ -72,6 +72,8 @@ double LangevinIntegrator::computeKineticEnergy() {
}
}
void
LangevinIntegrator
::
step
(
int
steps
)
{
void
LangevinIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
...
openmmapi/src/VariableLangevinIntegrator.cpp
View file @
c096fa02
...
@@ -75,6 +75,8 @@ double VariableLangevinIntegrator::computeKineticEnergy() {
...
@@ -75,6 +75,8 @@ double VariableLangevinIntegrator::computeKineticEnergy() {
}
}
void
VariableLangevinIntegrator
::
step
(
int
steps
)
{
void
VariableLangevinIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
@@ -83,6 +85,8 @@ void VariableLangevinIntegrator::step(int steps) {
...
@@ -83,6 +85,8 @@ void VariableLangevinIntegrator::step(int steps) {
}
}
void
VariableLangevinIntegrator
::
stepTo
(
double
time
)
{
void
VariableLangevinIntegrator
::
stepTo
(
double
time
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
while
(
time
>
context
->
getTime
())
{
while
(
time
>
context
->
getTime
())
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
...
openmmapi/src/VariableVerletIntegrator.cpp
View file @
c096fa02
...
@@ -70,6 +70,8 @@ double VariableVerletIntegrator::computeKineticEnergy() {
...
@@ -70,6 +70,8 @@ double VariableVerletIntegrator::computeKineticEnergy() {
}
}
void
VariableVerletIntegrator
::
step
(
int
steps
)
{
void
VariableVerletIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
@@ -78,6 +80,8 @@ void VariableVerletIntegrator::step(int steps) {
...
@@ -78,6 +80,8 @@ void VariableVerletIntegrator::step(int steps) {
}
}
void
VariableVerletIntegrator
::
stepTo
(
double
time
)
{
void
VariableVerletIntegrator
::
stepTo
(
double
time
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
while
(
time
>
context
->
getTime
())
{
while
(
time
>
context
->
getTime
())
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
...
openmmapi/src/VerletIntegrator.cpp
View file @
c096fa02
...
@@ -69,6 +69,8 @@ double VerletIntegrator::computeKineticEnergy() {
...
@@ -69,6 +69,8 @@ double VerletIntegrator::computeKineticEnergy() {
}
}
void
VerletIntegrator
::
step
(
int
steps
)
{
void
VerletIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
...
plugins/drude/openmmapi/src/DrudeLangevinIntegrator.cpp
View file @
c096fa02
...
@@ -89,6 +89,8 @@ double DrudeLangevinIntegrator::computeKineticEnergy() {
...
@@ -89,6 +89,8 @@ double DrudeLangevinIntegrator::computeKineticEnergy() {
}
}
void
DrudeLangevinIntegrator
::
step
(
int
steps
)
{
void
DrudeLangevinIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
...
plugins/drude/openmmapi/src/DrudeSCFIntegrator.cpp
View file @
c096fa02
...
@@ -86,6 +86,8 @@ double DrudeSCFIntegrator::computeKineticEnergy() {
...
@@ -86,6 +86,8 @@ double DrudeSCFIntegrator::computeKineticEnergy() {
}
}
void
DrudeSCFIntegrator
::
step
(
int
steps
)
{
void
DrudeSCFIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
context
->
calcForcesAndEnergy
(
true
,
false
);
...
...
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
View file @
c096fa02
...
@@ -100,7 +100,7 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
...
@@ -100,7 +100,7 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
// Call setPositions() on the Context so it doesn't think the user is trying to
// 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
// run a simulation without setting positions first. These positions will
// immediately get overwritten by the ones stored in this integrator.
// immediately get overwritten by the ones stored in this integrator.
vector
<
Vec3
>
p
(
context
->
getSystem
().
getNumParticles
(),
Vec3
());
vector
<
Vec3
>
p
(
context
->
getSystem
().
getNumParticles
(),
Vec3
());
context
->
getOwner
().
setPositions
(
p
);
context
->
getOwner
().
setPositions
(
p
);
isFirstStep
=
false
;
isFirstStep
=
false
;
...
@@ -110,7 +110,7 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
...
@@ -110,7 +110,7 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
if
(
enforcePeriodicBox
&&
copy
>
0
&&
(
types
&
State
::
Positions
)
!=
0
)
{
if
(
enforcePeriodicBox
&&
copy
>
0
&&
(
types
&
State
::
Positions
)
!=
0
)
{
// Apply periodic boundary conditions based on copy 0. Otherwise, molecules might end
// Apply periodic boundary conditions based on copy 0. Otherwise, molecules might end
// up in different places for different copies.
// up in different places for different copies.
kernel
.
getAs
<
IntegrateRPMDStepKernel
>
().
copyToContext
(
0
,
*
context
);
kernel
.
getAs
<
IntegrateRPMDStepKernel
>
().
copyToContext
(
0
,
*
context
);
State
state2
=
context
->
getOwner
().
getState
(
State
::
Positions
,
false
,
groups
);
State
state2
=
context
->
getOwner
().
getState
(
State
::
Positions
,
false
,
groups
);
vector
<
Vec3
>
positions
=
state
.
getPositions
();
vector
<
Vec3
>
positions
=
state
.
getPositions
();
...
@@ -144,9 +144,9 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
...
@@ -144,9 +144,9 @@ State RPMDIntegrator::getState(int copy, int types, bool enforcePeriodicBox, int
pos
[
2
]
-=
dz
;
pos
[
2
]
-=
dz
;
}
}
}
}
// Construct the new State.
// Construct the new State.
State
::
StateBuilder
builder
(
state
.
getTime
());
State
::
StateBuilder
builder
(
state
.
getTime
());
builder
.
setPositions
(
positions
);
builder
.
setPositions
(
positions
);
builder
.
setPeriodicBoxVectors
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
]);
builder
.
setPeriodicBoxVectors
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
]);
...
@@ -168,16 +168,18 @@ double RPMDIntegrator::computeKineticEnergy() {
...
@@ -168,16 +168,18 @@ double RPMDIntegrator::computeKineticEnergy() {
}
}
void
RPMDIntegrator
::
step
(
int
steps
)
{
void
RPMDIntegrator
::
step
(
int
steps
)
{
if
(
context
==
NULL
)
throw
OpenMMException
(
"This Integrator is not bound to a context!"
);
if
(
!
hasSetPosition
)
{
if
(
!
hasSetPosition
)
{
// Initialize the positions from the context.
// Initialize the positions from the context.
State
s
=
context
->
getOwner
().
getState
(
State
::
Positions
);
State
s
=
context
->
getOwner
().
getState
(
State
::
Positions
);
for
(
int
i
=
0
;
i
<
numCopies
;
i
++
)
for
(
int
i
=
0
;
i
<
numCopies
;
i
++
)
setPositions
(
i
,
s
.
getPositions
());
setPositions
(
i
,
s
.
getPositions
());
}
}
if
(
!
hasSetVelocity
)
{
if
(
!
hasSetVelocity
)
{
// Initialize the velocities from the context.
// Initialize the velocities from the context.
State
s
=
context
->
getOwner
().
getState
(
State
::
Velocities
);
State
s
=
context
->
getOwner
().
getState
(
State
::
Velocities
);
for
(
int
i
=
0
;
i
<
numCopies
;
i
++
)
for
(
int
i
=
0
;
i
<
numCopies
;
i
++
)
setVelocities
(
i
,
s
.
getVelocities
());
setVelocities
(
i
,
s
.
getVelocities
());
...
@@ -186,7 +188,7 @@ void RPMDIntegrator::step(int steps) {
...
@@ -186,7 +188,7 @@ void RPMDIntegrator::step(int steps) {
// Call setPositions() on the Context so it doesn't think the user is trying to
// 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
// run a simulation without setting positions first. These positions will
// immediately get overwritten by the ones stored in this integrator.
// immediately get overwritten by the ones stored in this integrator.
vector
<
Vec3
>
p
(
context
->
getSystem
().
getNumParticles
(),
Vec3
());
vector
<
Vec3
>
p
(
context
->
getSystem
().
getNumParticles
(),
Vec3
());
context
->
getOwner
().
setPositions
(
p
);
context
->
getOwner
().
setPositions
(
p
);
isFirstStep
=
false
;
isFirstStep
=
false
;
...
@@ -212,12 +214,12 @@ double RPMDIntegrator::getTotalEnergy() {
...
@@ -212,12 +214,12 @@ double RPMDIntegrator::getTotalEnergy() {
State
prevState
=
getState
(
numCopies
-
1
,
State
::
Positions
);
State
prevState
=
getState
(
numCopies
-
1
,
State
::
Positions
);
for
(
int
i
=
0
;
i
<
numCopies
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numCopies
;
i
++
)
{
// Add the energy of this copy.
// Add the energy of this copy.
State
state
=
getState
(
i
,
State
::
Positions
|
State
::
Energy
);
State
state
=
getState
(
i
,
State
::
Positions
|
State
::
Energy
);
energy
+=
state
.
getKineticEnergy
()
+
state
.
getPotentialEnergy
();
energy
+=
state
.
getKineticEnergy
()
+
state
.
getPotentialEnergy
();
// Add the energy from the springs connecting it to the previous copy.
// Add the energy from the springs connecting it to the previous copy.
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
Vec3
delta
=
state
.
getPositions
()[
j
]
-
prevState
.
getPositions
()[
j
];
Vec3
delta
=
state
.
getPositions
()[
j
]
-
prevState
.
getPositions
()[
j
];
energy
+=
0.5
*
wn
*
wn
*
system
.
getParticleMass
(
j
)
*
delta
.
dot
(
delta
);
energy
+=
0.5
*
wn
*
wn
*
system
.
getParticleMass
(
j
)
*
delta
.
dot
(
delta
);
...
...
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