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
ccb83f1d
Unverified
Commit
ccb83f1d
authored
Dec 02, 2025
by
Peter Eastman
Committed by
GitHub
Dec 02, 2025
Browse files
GromacsTopFile supports vsite type 3fad (#5155)
parent
b0c2c4d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
2 deletions
+63
-2
wrappers/python/openmm/app/gromacstopfile.py
wrappers/python/openmm/app/gromacstopfile.py
+6
-2
wrappers/python/tests/TestGromacsTopFile.py
wrappers/python/tests/TestGromacsTopFile.py
+12
-0
wrappers/python/tests/systems/vsite3-3.gro
wrappers/python/tests/systems/vsite3-3.gro
+7
-0
wrappers/python/tests/systems/vsite3-3.top
wrappers/python/tests/systems/vsite3-3.top
+38
-0
No files found.
wrappers/python/openmm/app/gromacstopfile.py
View file @
ccb83f1d
...
@@ -4,7 +4,7 @@ gromacstopfile.py: Used for loading Gromacs top files.
...
@@ -4,7 +4,7 @@ gromacstopfile.py: Used for loading Gromacs top files.
This is part of the OpenMM molecular simulation toolkit.
This is part of the OpenMM molecular simulation toolkit.
See https://openmm.org/development.
See https://openmm.org/development.
Portions copyright (c) 2012-202
4
Stanford University and the Authors.
Portions copyright (c) 2012-202
5
Stanford University and the Authors.
Authors: Peter Eastman
Authors: Peter Eastman
Contributors: Jason Swails
Contributors: Jason Swails
...
@@ -525,7 +525,7 @@ class GromacsTopFile(object):
...
@@ -525,7 +525,7 @@ class GromacsTopFile(object):
fields
=
line
.
split
()
fields
=
line
.
split
()
if
len
(
fields
)
<
7
:
if
len
(
fields
)
<
7
:
raise
ValueError
(
'Too few fields in [ virtual_sites3 ] line: '
+
line
)
raise
ValueError
(
'Too few fields in [ virtual_sites3 ] line: '
+
line
)
if
fields
[
4
]
not
in
(
'1'
,
'4'
):
if
fields
[
4
]
not
in
(
'1'
,
'3'
,
'4'
):
raise
ValueError
(
'Unsupported function type in [ virtual_sites3 ] line: '
+
line
)
raise
ValueError
(
'Unsupported function type in [ virtual_sites3 ] line: '
+
line
)
self
.
_currentMoleculeType
.
vsites3
.
append
(
fields
)
self
.
_currentMoleculeType
.
vsites3
.
append
(
fields
)
...
@@ -1117,6 +1117,10 @@ class GromacsTopFile(object):
...
@@ -1117,6 +1117,10 @@ class GromacsTopFile(object):
c2
=
float
(
fields
[
6
])
c2
=
float
(
fields
[
6
])
if
vsiteType
==
'1'
:
if
vsiteType
==
'1'
:
vsite
=
mm
.
ThreeParticleAverageSite
(
baseAtomIndex
+
atoms
[
1
],
baseAtomIndex
+
atoms
[
2
],
baseAtomIndex
+
atoms
[
3
],
1
-
c1
-
c2
,
c1
,
c2
)
vsite
=
mm
.
ThreeParticleAverageSite
(
baseAtomIndex
+
atoms
[
1
],
baseAtomIndex
+
atoms
[
2
],
baseAtomIndex
+
atoms
[
3
],
1
-
c1
-
c2
,
c1
,
c2
)
elif
vsiteType
==
'3'
:
theta
=
c1
*
math
.
pi
/
180
vsite
=
mm
.
LocalCoordinatesSite
(
baseAtomIndex
+
atoms
[
1
],
baseAtomIndex
+
atoms
[
2
],
baseAtomIndex
+
atoms
[
3
],
(
1
,
0
,
0
),
(
-
1
,
1
,
0
),
(
0
,
-
1
,
1
),
(
c2
*
math
.
cos
(
theta
),
c2
*
math
.
sin
(
theta
),
0
))
elif
vsiteType
==
'4'
:
elif
vsiteType
==
'4'
:
c3
=
float
(
fields
[
7
])
c3
=
float
(
fields
[
7
])
vsite
=
mm
.
OutOfPlaneSite
(
baseAtomIndex
+
atoms
[
1
],
baseAtomIndex
+
atoms
[
2
],
baseAtomIndex
+
atoms
[
3
],
c1
,
c2
,
c3
)
vsite
=
mm
.
OutOfPlaneSite
(
baseAtomIndex
+
atoms
[
1
],
baseAtomIndex
+
atoms
[
2
],
baseAtomIndex
+
atoms
[
3
],
c1
,
c2
,
c3
)
...
...
wrappers/python/tests/TestGromacsTopFile.py
View file @
ccb83f1d
...
@@ -225,6 +225,18 @@ class TestGromacsTopFile(unittest.TestCase):
...
@@ -225,6 +225,18 @@ class TestGromacsTopFile(unittest.TestCase):
self
.
assertAlmostEqual
(
0.106676721
,
vs
.
getWeight
(
1
))
self
.
assertAlmostEqual
(
0.106676721
,
vs
.
getWeight
(
1
))
self
.
assertAlmostEqual
(
0.106676721
,
vs
.
getWeight
(
2
))
self
.
assertAlmostEqual
(
0.106676721
,
vs
.
getWeight
(
2
))
def
test_Vsite3Func3
(
self
):
"""Test a three particle virtual site with function 3."""
top
=
GromacsTopFile
(
'systems/vsite3-3.top'
)
gro
=
GromacsGroFile
(
'systems/vsite3-3.gro'
)
system
=
top
.
createSystem
()
context
=
Context
(
system
,
VerletIntegrator
(
1.0
),
Platform
.
getPlatform
(
'Reference'
))
context
.
setPositions
(
gro
.
positions
)
context
.
computeVirtualSites
()
positions
=
context
.
getState
(
positions
=
True
).
getPositions
().
value_in_unit
(
nanometer
)
# Compare to the position computed by Gromacs
assert_allclose
([
2.45
,
0.7794
,
0.0
],
positions
[
3
],
atol
=
1e-4
)
def
test_Vsite3Func4
(
self
):
def
test_Vsite3Func4
(
self
):
"""Test a three particle virtual site."""
"""Test a three particle virtual site."""
top
=
GromacsTopFile
(
'systems/tip5p.top'
)
top
=
GromacsTopFile
(
'systems/tip5p.top'
)
...
...
wrappers/python/tests/systems/vsite3-3.gro
0 → 100644
View file @
ccb83f1d
Vsite test system
4
1MOL C1 1 0.000 1.000 0.000
1MOL C2 2 1.000 0.000 0.000
1MOL C3 3 2.000 0.000 0.000
1MOL H 4 3.000 0.000 0.000
8.00000 8.00000 8.00000
wrappers/python/tests/systems/vsite3-3.top
0 → 100644
View file @
ccb83f1d
[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 3 yes 0.5 0.5
[ atomtypes ]
; name bond_type mass charge ptype sigma epsilon
H 1 0.00 0.0000 A 0.00000e+00 0.00000e+00
C 6 12.00 0.0000 A 0.00000e+00 0.00000e+00
[ moleculetype ]
; molname nrexcl
MOL 3
[ atoms ]
; id at type res nr res name at name cg nr charge mass
1 C 1 MOL C1 1 0 12.00000
2 C 1 MOL C2 1 0 12.00000
3 C 1 MOL C3 1 0 12.00000
4 H 1 MOL H 1 0 0.00000
[ bonds ]
[ virtual_sites3 ]
; Vsite from funct theta d
4 3 2 1 3 120 0.9
[ exclusions ]
1 2 3 4
2 1 3 4
3 1 2 4
4 1 2 3
[ system ]
1 MOL
[ molecules ]
; Compound #mols
MOL 1
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