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
23522479
Commit
23522479
authored
Feb 16, 2016
by
ChayaSt
Browse files
added postprocessSystem
parent
da4cb9b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
32 deletions
+40
-32
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+40
-32
No files found.
wrappers/python/simtk/openmm/app/forcefield.py
View file @
23522479
...
@@ -1683,7 +1683,7 @@ class NBFixGenerator(object):
...
@@ -1683,7 +1683,7 @@ class NBFixGenerator(object):
self
.
types2
=
[]
self
.
types2
=
[]
self
.
emin
=
[]
self
.
emin
=
[]
self
.
rmin
=
[]
self
.
rmin
=
[]
self
.
lj_types
=
[
f
for
f
in
forcefield
.
_forces
if
isinstance
(
f
,
NonbondedGenerator
)][
0
]
self
.
lj_types
=
[
f
for
f
in
forcefield
.
_forces
if
isinstance
(
f
,
NonbondedGenerator
)][
0
]
.
params
def
registerNBFix
(
self
,
parameters
):
def
registerNBFix
(
self
,
parameters
):
types
=
self
.
ff
.
_findAtomTypes
(
parameters
,
2
)
types
=
self
.
ff
.
_findAtomTypes
(
parameters
,
2
)
...
@@ -1718,13 +1718,13 @@ class NBFixGenerator(object):
...
@@ -1718,13 +1718,13 @@ class NBFixGenerator(object):
CustomNonbondedForce
CustomNonbondedForce
"""
"""
# NonBondedForce for 'standard' nonbonded interactions. This will be modified
# NonBondedForce for 'standard' nonbonded interactions. This will be modified
nonb
frc
=
[
f
for
f
in
sys
.
getForces
if
isinstance
(
f
,
mm
.
openmm
.
NonbondedForce
)][
0
]
nonb
onded
=
[
f
for
f
in
sys
.
getForces
()
if
isinstance
(
f
,
mm
.
openmm
.
NonbondedForce
)][
0
]
# We need a CustomNonbondedForce to implement the NBFIX functionality.
# We need a CustomNonbondedForce to implement the NBFIX functionality.
# First derive the lookup tables
# First derive the lookup tables
lj_indx_list
=
[
0
for
atom
in
data
.
atoms
]
lj_indx_list
=
[
0
for
atom
in
data
.
atoms
]
l
i
_radii
,
lj_depths
=
[],
[]
l
j
_radii
,
lj_depths
=
[],
[]
num_lj_types
=
0
num_lj_types
=
0
lj_type_list
=
[]
lj_type_list
=
[]
for
i
,
atom
in
enumerate
(
data
.
atoms
):
for
i
,
atom
in
enumerate
(
data
.
atoms
):
...
@@ -1772,50 +1772,58 @@ class NBFixGenerator(object):
...
@@ -1772,50 +1772,58 @@ class NBFixGenerator(object):
acoef
[
m
+
num_lj_types
*
n
]
=
math
.
sqrt
(
wdij
)
*
rij6
acoef
[
m
+
num_lj_types
*
n
]
=
math
.
sqrt
(
wdij
)
*
rij6
bcoef
[
m
+
num_lj_types
*
n
]
=
2
*
wdij
*
rij6
bcoef
[
m
+
num_lj_types
*
n
]
=
2
*
wdij
*
rij6
force
=
mm
.
CustomNonbondedForce
(
'(a/r6)^2-b/r6; r6=r2*r2*r2; r2=r^2; '
self
.
force
=
mm
.
CustomNonbondedForce
(
'(a/r6)^2-b/r6; r6=r2*r2*r2; r2=r^2; '
'a=acoef(type1, type2); '
'a=acoef(type1, type2); '
'b=bcoef(type1, type2)'
)
'b=bcoef(type1, type2)'
)
force
.
addTabulatedFunction
(
'acoef'
,
self
.
force
.
addTabulatedFunction
(
'acoef'
,
mm
.
Discrete2DFunction
(
num_lj_types
,
num_lj_types
,
acoef
))
mm
.
Discrete2DFunction
(
num_lj_types
,
num_lj_types
,
acoef
))
force
.
addTabulatedFunction
(
'bcoef'
,
self
.
force
.
addTabulatedFunction
(
'bcoef'
,
mm
.
Discrete2DFunction
(
num_lj_types
,
num_lj_types
,
bcoef
))
mm
.
Discrete2DFunction
(
num_lj_types
,
num_lj_types
,
bcoef
))
force
.
addPerParticleParameter
(
'type'
)
self
.
force
.
addPerParticleParameter
(
'type'
)
if
(
nonbondedMethod
is
PME
or
nonbondedMethod
is
Ewald
or
if
(
nonbondedMethod
is
PME
or
nonbondedMethod
is
Ewald
or
nonbondedMethod
is
CutoffPeriodic
):
nonbondedMethod
is
CutoffPeriodic
):
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffPeriodic
)
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffPeriodic
)
elif
nonbondedMethod
is
NoCutoff
:
elif
nonbondedMethod
is
NoCutoff
:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
NoCutoff
)
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
NoCutoff
)
elif
nonbondedMethod
is
CutoffNonPeriodic
:
elif
nonbondedMethod
is
CutoffNonPeriodic
:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
else
:
else
:
raise
AssertionError
(
'Unrecognized nonbonded method [%s]'
%
raise
AssertionError
(
'Unrecognized nonbonded method [%s]'
%
nonbondedMethod
)
nonbondedMethod
)
# Add the particles
# Add the particles
for
i
in
lj_indx_list
:
for
i
in
lj_indx_list
:
force
.
addParticle
((
i
-
1
,))
self
.
force
.
addParticle
((
i
-
1
,))
# Now wipe out the L-J parameters in the nonbonded force
# Now wipe out the L-J parameters in the nonbonded force
for
i
in
range
(
nonbfrc
.
getNumParticles
()):
for
i
in
range
(
nonbonded
.
getNumParticles
()):
chg
,
sig
,
eps
=
nonbfrc
.
getParticleParameters
(
i
)
chg
,
sig
,
eps
=
nonbonded
.
getParticleParameters
(
i
)
nonbfrc
.
setParticleParameters
(
i
,
chg
,
0.5
,
0.0
)
nonbonded
.
setParticleParameters
(
i
,
chg
,
0.5
,
0.0
)
# Now transfer the exclusions
sys
.
addForce
(
self
.
force
)
for
ii
in
range
(
nonbfrc
.
getNumExceptions
()):
i
,
j
,
qq
,
ss
,
ee
=
nonbfrc
.
getExceptionParameters
(
ii
)
def
postprocessSystem
(
self
,
sys
,
data
,
args
):
force
.
addExclusion
(
i
,
j
)
nonbonded
=
[
f
for
f
in
sys
.
getForces
()
if
isinstance
(
f
,
mm
.
NonbondedForce
)][
0
]
# transfer the exclusions from NonBonded
for
ii
in
range
(
nonbonded
.
getNumExceptions
()):
i
,
j
,
qq
,
ss
,
ee
=
nonbonded
.
getExceptionParameters
(
ii
)
self
.
force
.
addExclusion
(
i
,
j
)
# Now transfer the other properties (cutoff, switching function, etc.)
# Now transfer the other properties (cutoff, switching function, etc.)
force
.
setUseLongRangeCorrection
(
True
)
self
.
force
.
setUseLongRangeCorrection
(
True
)
if
nonbondedMethod
is
NoCutoff
:
# if nonbondedMethod is NoCutoff:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
NoCutoff
)
# self.force.setNonbondedMethod(mm.CustomNonbondedForce.NoCutoff)
elif
nonbondedMethod
is
CutoffNonPeriodic
:
# elif nonbondedMethod is CutoffNonPeriodic:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
# self.force.setNonbondedMethod(mm.CustomNonbondedForce.CutoffNonPeriodic)
elif
nonbondedMethod
in
(
PME
,
Ewald
,
CutoffPeriodic
):
# elif nonbondedMethod in (PME, Ewald, CutoffPeriodic):
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffPeriodic
)
# self.force.setNonbondedMethod(mm.CustomNonbondedForce.CutoffPeriodic)
else
:
# else:
raise
AssertionError
(
'Unsupported nonbonded method %s'
%
# raise AssertionError('Unsupported nonbonded method %s' %
nonbondedMethod
)
# nonbondedMethod)
force
.
setCutoffDistance
(
nonbfrc
.
getCutoffDistance
())
self
.
force
.
setCutoffDistance
(
nonbonded
.
getCutoffDistance
())
if
nonbfrc
.
getUseSwitchingFunction
():
if
nonbonded
.
getUseSwitchingFunction
():
force
.
setUseSwitchingFunction
(
True
)
self
.
force
.
setUseSwitchingFunction
(
True
)
force
.
setSwitchingDistance
(
nonbfrc
.
getSwitchingDistance
())
self
.
force
.
setSwitchingDistance
(
nonbonded
.
getSwitchingDistance
())
parsers
[
"NBFixForce"
]
=
NBFixGenerator
.
parseElement
parsers
[
"NBFixForce"
]
=
NBFixGenerator
.
parseElement
...
...
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