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
87df7223
Commit
87df7223
authored
Sep 21, 2012
by
Peter Eastman
Browse files
Throw exception if the user tries to compute forces without setting positions first.
parent
d8545b79
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
openmmapi/include/openmm/internal/ContextImpl.h
openmmapi/include/openmm/internal/ContextImpl.h
+1
-1
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+4
-1
No files found.
openmmapi/include/openmm/internal/ContextImpl.h
View file @
87df7223
...
...
@@ -246,7 +246,7 @@ private:
std
::
vector
<
ForceImpl
*>
forceImpls
;
std
::
map
<
std
::
string
,
double
>
parameters
;
mutable
std
::
vector
<
std
::
vector
<
int
>
>
molecules
;
bool
hasInitializedForces
;
bool
hasInitializedForces
,
hasSetPositions
;
int
lastForceGroups
;
Platform
*
platform
;
Kernel
initializeForcesKernel
,
kineticEnergyKernel
,
updateStateDataKernel
,
applyConstraintsKernel
,
virtualSitesKernel
;
...
...
openmmapi/src/ContextImpl.cpp
View file @
87df7223
...
...
@@ -48,7 +48,7 @@ using namespace OpenMM;
using
namespace
std
;
ContextImpl
::
ContextImpl
(
Context
&
owner
,
System
&
system
,
Integrator
&
integrator
,
Platform
*
platform
,
const
map
<
string
,
string
>&
properties
)
:
owner
(
owner
),
system
(
system
),
integrator
(
integrator
),
hasInitializedForces
(
false
),
lastForceGroups
(
-
1
),
platform
(
platform
),
platformData
(
NULL
)
{
owner
(
owner
),
system
(
system
),
integrator
(
integrator
),
hasInitializedForces
(
false
),
hasSetPositions
(
false
),
lastForceGroups
(
-
1
),
platform
(
platform
),
platformData
(
NULL
)
{
if
(
system
.
getNumParticles
()
==
0
)
throw
OpenMMException
(
"Cannot create a Context for a System with no particles"
);
...
...
@@ -143,6 +143,7 @@ void ContextImpl::getPositions(std::vector<Vec3>& positions) {
}
void
ContextImpl
::
setPositions
(
const
std
::
vector
<
Vec3
>&
positions
)
{
hasSetPositions
=
true
;
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
setPositions
(
*
this
,
positions
);
integrator
.
stateChanged
(
State
::
Positions
);
}
...
...
@@ -200,6 +201,8 @@ void ContextImpl::computeVirtualSites() {
}
double
ContextImpl
::
calcForcesAndEnergy
(
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
(
!
hasSetPositions
)
throw
OpenMMException
(
"Particle positions have not been set"
);
lastForceGroups
=
groups
;
CalcForcesAndEnergyKernel
&
kernel
=
initializeForcesKernel
.
getAs
<
CalcForcesAndEnergyKernel
>
();
double
energy
=
0.0
;
...
...
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