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
"platforms/opencl/vscode:/vscode.git/clone" did not exist on "cfa7ab82e453c2ee4b4067ff66e51f35f25dce9c"
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):
self
.
types2
=
[]
self
.
emin
=
[]
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
):
types
=
self
.
ff
.
_findAtomTypes
(
parameters
,
2
)
...
...
@@ -1718,13 +1718,13 @@ class NBFixGenerator(object):
CustomNonbondedForce
"""
# 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.
# First derive the lookup tables
lj_indx_list
=
[
0
for
atom
in
data
.
atoms
]
l
i
_radii
,
lj_depths
=
[],
[]
l
j
_radii
,
lj_depths
=
[],
[]
num_lj_types
=
0
lj_type_list
=
[]
for
i
,
atom
in
enumerate
(
data
.
atoms
):
...
...
@@ -1772,50 +1772,58 @@ class NBFixGenerator(object):
acoef
[
m
+
num_lj_types
*
n
]
=
math
.
sqrt
(
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); '
'b=bcoef(type1, type2)'
)
force
.
addTabulatedFunction
(
'acoef'
,
self
.
force
.
addTabulatedFunction
(
'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
))
force
.
addPerParticleParameter
(
'type'
)
self
.
force
.
addPerParticleParameter
(
'type'
)
if
(
nonbondedMethod
is
PME
or
nonbondedMethod
is
Ewald
or
nonbondedMethod
is
CutoffPeriodic
):
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffPeriodic
)
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffPeriodic
)
elif
nonbondedMethod
is
NoCutoff
:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
NoCutoff
)
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
NoCutoff
)
elif
nonbondedMethod
is
CutoffNonPeriodic
:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
else
:
raise
AssertionError
(
'Unrecognized nonbonded method [%s]'
%
nonbondedMethod
)
# Add the particles
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
for
i
in
range
(
nonbfrc
.
getNumParticles
()):
chg
,
sig
,
eps
=
nonbfrc
.
getParticleParameters
(
i
)
nonbfrc
.
setParticleParameters
(
i
,
chg
,
0.5
,
0.0
)
# Now transfer the exclusions
for
ii
in
range
(
nonbfrc
.
getNumExceptions
()):
i
,
j
,
qq
,
ss
,
ee
=
nonbfrc
.
getExceptionParameters
(
ii
)
force
.
addExclusion
(
i
,
j
)
for
i
in
range
(
nonbonded
.
getNumParticles
()):
chg
,
sig
,
eps
=
nonbonded
.
getParticleParameters
(
i
)
nonbonded
.
setParticleParameters
(
i
,
chg
,
0.5
,
0.0
)
sys
.
addForce
(
self
.
force
)
def
postprocessSystem
(
self
,
sys
,
data
,
args
):
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.)
force
.
setUseLongRangeCorrection
(
True
)
if
nonbondedMethod
is
NoCutoff
:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
NoCutoff
)
elif
nonbondedMethod
is
CutoffNonPeriodic
:
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
elif
nonbondedMethod
in
(
PME
,
Ewald
,
CutoffPeriodic
):
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffPeriodic
)
else
:
raise
AssertionError
(
'Unsupported nonbonded method %s'
%
nonbondedMethod
)
force
.
setCutoffDistance
(
nonbfrc
.
getCutoffDistance
())
if
nonbfrc
.
getUseSwitchingFunction
():
force
.
setUseSwitchingFunction
(
True
)
force
.
setSwitchingDistance
(
nonbfrc
.
getSwitchingDistance
())
self
.
force
.
setUseLongRangeCorrection
(
True
)
# if nonbondedMethod is NoCutoff:
# self.force.setNonbondedMethod(mm.CustomNonbondedForce.NoCutoff)
# elif nonbondedMethod is CutoffNonPeriodic:
# self.force.setNonbondedMethod(mm.CustomNonbondedForce.CutoffNonPeriodic)
# elif nonbondedMethod in (PME, Ewald, CutoffPeriodic):
# self.force.setNonbondedMethod(mm.CustomNonbondedForce.CutoffPeriodic)
# else:
# raise AssertionError('Unsupported nonbonded method %s' %
# nonbondedMethod)
self
.
force
.
setCutoffDistance
(
nonbonded
.
getCutoffDistance
())
if
nonbonded
.
getUseSwitchingFunction
():
self
.
force
.
setUseSwitchingFunction
(
True
)
self
.
force
.
setSwitchingDistance
(
nonbonded
.
getSwitchingDistance
())
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