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
a4bf2ceb
Commit
a4bf2ceb
authored
Apr 23, 2012
by
Peter Eastman
Browse files
Reporters check for NaNs or infinities in output
parent
4e480ff6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
wrappers/python/simtk/openmm/app/dcdfile.py
wrappers/python/simtk/openmm/app/dcdfile.py
+7
-2
wrappers/python/simtk/openmm/app/pdbfile.py
wrappers/python/simtk/openmm/app/pdbfile.py
+6
-1
wrappers/python/simtk/openmm/app/statedatareporter.py
wrappers/python/simtk/openmm/app/statedatareporter.py
+10
-0
No files found.
wrappers/python/simtk/openmm/app/dcdfile.py
View file @
a4bf2ceb
...
...
@@ -35,7 +35,8 @@ import array
import
os
import
time
import
struct
from
simtk.unit
import
picoseconds
,
nanometers
,
angstroms
,
is_quantity
import
math
from
simtk.unit
import
picoseconds
,
nanometers
,
angstroms
,
is_quantity
,
norm
class
DCDFile
(
object
):
"""DCDFile provides methods for creating DCD files.
...
...
@@ -89,6 +90,10 @@ class DCDFile(object):
raise
ValueError
(
'The number of positions must match the number of atoms'
)
if
is_quantity
(
positions
):
positions
=
positions
.
value_in_unit
(
nanometers
)
if
any
(
math
.
isnan
(
norm
(
pos
))
for
pos
in
positions
):
raise
ValueError
(
'Particle position is NaN'
)
if
any
(
math
.
isinf
(
norm
(
pos
))
for
pos
in
positions
):
raise
ValueError
(
'Particle position is infinite'
)
file
=
self
.
_file
# Update the header.
...
...
wrappers/python/simtk/openmm/app/pdbfile.py
View file @
a4bf2ceb
...
...
@@ -33,12 +33,13 @@ __version__ = "1.0"
import
os
import
sys
import
math
import
xml.etree.ElementTree
as
etree
from
copy
import
copy
from
simtk.openmm
import
Vec3
from
simtk.openmm.app.internal.pdbstructure
import
PdbStructure
from
simtk.openmm.app
import
Topology
from
simtk.unit
import
nanometers
,
angstroms
,
is_quantity
from
simtk.unit
import
nanometers
,
angstroms
,
is_quantity
,
norm
import
element
as
elem
try
:
import
numpy
...
...
@@ -240,6 +241,10 @@ class PDBFile(object):
raise
ValueError
(
'The number of positions must match the number of atoms'
)
if
is_quantity
(
positions
):
positions
=
positions
.
value_in_unit
(
angstroms
)
if
any
(
math
.
isnan
(
norm
(
pos
))
for
pos
in
positions
):
raise
ValueError
(
'Particle position is NaN'
)
if
any
(
math
.
isinf
(
norm
(
pos
))
for
pos
in
positions
):
raise
ValueError
(
'Particle position is infinite'
)
atomIndex
=
1
posIndex
=
0
if
modelIndex
is
not
None
:
...
...
wrappers/python/simtk/openmm/app/statedatareporter.py
View file @
a4bf2ceb
...
...
@@ -34,6 +34,7 @@ __version__ = "1.0"
import
simtk.openmm
as
mm
import
simtk.unit
as
unit
from
simtk.openmm.app
import
PDBFile
import
math
class
StateDataReporter
(
object
):
"""StateDataReporter outputs information about a simulation, such as energy and temperature, to a file.
...
...
@@ -136,6 +137,15 @@ class StateDataReporter(object):
print
>>
self
.
_out
,
'#"%s"'
%
(
'"'
+
self
.
_separator
+
'"'
).
join
(
headers
)
self
.
_hasInitialized
=
True
# Check for errors.
if
self
.
_needEnergy
:
energy
=
(
state
.
getKineticEnergy
()
+
state
.
getPotentialEnergy
()).
value_in_unit
(
unit
.
kilojoules_per_mole
)
if
math
.
isnan
(
energy
):
raise
ValueError
(
'Energy is NaN'
)
if
math
.
isinf
(
energy
):
raise
ValueError
(
'Energy is infinite'
)
# Write the values.
values
=
[]
...
...
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