Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tbgl
tools
mrdna
Commits
d3c116bf
Commit
d3c116bf
authored
Feb 18, 2020
by
cmaffeo2
Browse files
Sync with arbdmodel 4784882; syntax changes have not yet been propogated to SegmentModel
parent
28067c6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
mrdna/arbdmodel/__init__.py
View file @
d3c116bf
...
...
@@ -674,11 +674,13 @@ class PdbModel(Transformable, Parent):
class
ArbdModel
(
PdbModel
):
def
__init__
(
self
,
children
,
dimensions
=
(
1000
,
1000
,
1000
),
temperature
=
291
,
timestep
=
50e-6
,
particle_integrator
=
'Brown'
,
cutoff
=
50
,
decomp
P
eriod
=
1000
,
pairlist
D
istance
=
None
,
nonbonded
R
esolution
=
0.1
,
def
__init__
(
self
,
children
,
origin
=
None
,
dimensions
=
(
1000
,
1000
,
1000
),
temperature
=
291
,
timestep
=
50e-6
,
particle_integrator
=
'Brown'
,
cutoff
=
50
,
decomp
_p
eriod
=
1000
,
pairlist
_d
istance
=
None
,
nonbonded
_r
esolution
=
0.1
,
remove_duplicate_bonded_terms
=
True
,
extra_bd_file_lines
=
""
):
PdbModel
.
__init__
(
self
,
children
,
dimensions
,
remove_duplicate_bonded_terms
)
self
.
origin
=
origin
self
.
temperature
=
temperature
self
.
timestep
=
timestep
...
...
@@ -686,11 +688,11 @@ class ArbdModel(PdbModel):
self
.
particle_integrator
=
particle_integrator
if
pairlist
D
istance
==
None
:
pairlist
D
istance
=
cutoff
+
30
if
pairlist
_d
istance
==
None
:
pairlist
_d
istance
=
cutoff
+
30
self
.
decomp
P
eriod
=
decomp
P
eriod
self
.
pairlist
D
istance
=
pairlist
D
istance
self
.
decomp
_p
eriod
=
decomp
_p
eriod
self
.
pairlist
_d
istance
=
pairlist
_d
istance
self
.
extra_bd_file_lines
=
extra_bd_file_lines
...
...
@@ -752,9 +754,12 @@ class ArbdModel(PdbModel):
# self.initialCoords = np.array([p.initialPosition for p in self.particles])
def
useNonbondedScheme
(
self
,
nbScheme
,
typeA
=
None
,
typeB
=
None
):
self
.
nbSchemes
.
append
(
(
nbScheme
,
typeA
,
typeB
)
)
self
.
add_nonbonded_scheme
(
nbScheme
,
typeA
,
typeB
)
def
add_nonbonded_scheme
(
self
,
nonbonded_scheme
,
typeA
=
None
,
typeB
=
None
):
self
.
nbSchemes
.
append
(
(
nonbonded_scheme
,
typeA
,
typeB
)
)
if
typeA
!=
typeB
:
self
.
nbSchemes
.
append
(
(
n
bS
cheme
,
typeB
,
typeA
)
)
self
.
nbSchemes
.
append
(
(
n
onbonded_s
cheme
,
typeB
,
typeA
)
)
def
simulate
(
self
,
output_name
,
output_directory
=
'output'
,
num_steps
=
100000000
,
timestep
=
None
,
gpu
=
0
,
output_period
=
1e4
,
arbd
=
None
,
directory
=
'.'
,
restart_file
=
None
,
replicas
=
1
,
log_file
=
None
,
dry_run
=
False
):
assert
(
type
(
gpu
)
is
int
)
...
...
@@ -932,10 +937,16 @@ class ArbdModel(PdbModel):
params
[
'outputPeriod'
]
=
outputPeriod
for
k
,
v
in
zip
(
'XYZ'
,
self
.
dimensions
):
params
[
'origin'
+
k
]
=
-
v
*
0.5
params
[
'dim'
+
k
]
=
v
if
self
.
origin
is
None
:
for
k
,
v
in
zip
(
'XYZ'
,
self
.
dimensions
):
params
[
'origin'
+
k
]
=
-
v
*
0.5
else
:
for
k
,
v
in
zip
(
'XYZ'
,
self
.
origin
):
params
[
'origin'
+
k
]
=
v
params
[
'pairlist
D
istance'
]
-=
params
[
'cutoff'
]
params
[
'pairlist
_d
istance'
]
-=
params
[
'cutoff'
]
""" Find rigid groups """
rigid_groups
=
[]
...
...
@@ -975,9 +986,9 @@ outputEnergyPeriod {outputPeriod}
outputFormat dcd
## Infrequent domain decomposition because this kernel is still very slow
decompPeriod {decomp
P
eriod}
decompPeriod {decomp
_p
eriod}
cutoff {cutoff}
pairlistDistance {pairlist
D
istance}
pairlistDistance {pairlist
_d
istance}
origin {originX} {originY} {originZ}
systemSize {dimX} {dimY} {dimZ}
...
...
@@ -1313,7 +1324,7 @@ if {{$nLast == 0}} {{
run {num_steps:d}
"""
.
format
(
**
format_data
))
def
atomic_simulate
(
self
,
output_name
,
output_directory
=
'output'
):
def
atomic_simulate
(
self
,
output_name
,
output_directory
=
'output'
,
dry_run
=
False
,
namd2
=
None
,
log_file
=
None
,
num_procs
=
None
,
gpu
=
None
):
if
self
.
cacheUpToDate
==
False
:
# TODO: remove cache?
self
.
_countParticleTypes
()
self
.
_updateParticleOrder
()
...
...
@@ -1325,3 +1336,44 @@ run {num_steps:d}
self
.
write_namd_configuration
(
output_name
,
output_directory
=
output_directory
)
os
.
sync
()
if
not
dry_run
:
if
namd2
is
None
:
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
path
=
path
.
strip
(
'"'
)
fname
=
os
.
path
.
join
(
path
,
"namd2"
)
if
os
.
path
.
isfile
(
fname
)
and
os
.
access
(
fname
,
os
.
X_OK
):
namd2
=
fname
break
if
namd2
is
None
:
raise
Exception
(
"NAMD2 was not found"
)
if
not
os
.
path
.
exists
(
namd2
):
raise
Exception
(
"NAMD2 was not found"
)
if
not
os
.
path
.
isfile
(
namd2
):
raise
Exception
(
"NAMD2 was not found"
)
if
not
os
.
access
(
namd2
,
os
.
X_OK
):
raise
Exception
(
"NAMD2 is not executable"
)
if
not
os
.
path
.
exists
(
output_directory
):
os
.
makedirs
(
output_directory
)
elif
not
os
.
path
.
isdir
(
output_directory
):
raise
Exception
(
"output_directory '%s' is not a directory!"
%
output_directory
)
if
num_procs
is
None
:
import
multiprocessing
num_procs
=
max
(
1
,
multiprocessing
.
cpu_count
()
-
1
)
cmd
=
[
namd2
,
'+p{}'
.
format
(
num_procs
),
"%s.namd"
%
output_name
]
cmd
=
tuple
(
str
(
x
)
for
x
in
cmd
)
print
(
"Running NAMD2 with: %s"
%
" "
.
join
(
cmd
))
if
log_file
is
None
or
(
hasattr
(
log_file
,
'write'
)
and
callable
(
log_file
.
write
)):
fd
=
sys
.
stdout
if
log_file
is
None
else
log_file
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
universal_newlines
=
True
)
for
line
in
process
.
stdout
:
fd
.
write
(
line
)
fd
.
flush
()
else
:
with
open
(
log_file
,
'w'
)
as
fd
:
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
log_file
,
universal_newlines
=
True
)
process
.
communicate
()
mrdna/arbdmodel/interactions.py
View file @
d3c116bf
...
...
@@ -25,14 +25,14 @@ class NonbondedScheme():
class
LennardJones
(
NonbondedScheme
):
def
potential
(
self
,
r
,
typeA
,
typeB
):
epsilon
=
sqrt
(
typeA
.
epsilon
**
2
+
typeB
.
epsilon
**
2
)
epsilon
=
np
.
sqrt
(
typeA
.
epsilon
**
2
+
typeB
.
epsilon
**
2
)
r0
=
0.5
*
(
typeA
.
radius
+
typeB
.
radius
)
r6
=
(
r0
/
r
)
**
6
r12
=
r6
**
2
u
=
epsilon
*
(
r12
-
2
*
r6
)
u
[
0
]
=
u
[
1
]
# Remove NaN
return
u
LennardJones
=
LennardJones
()
#
LennardJones = LennardJones()
class
HalfHarmonic
(
NonbondedScheme
):
def
potential
(
self
,
r
,
typeA
,
typeB
):
...
...
@@ -41,7 +41,7 @@ class HalfHarmonic(NonbondedScheme):
u
=
0.5
*
k
*
(
r
-
r0
)
**
2
u
[
r
>
r0
]
=
np
.
zeros
(
np
.
shape
(
u
[
r
>
r0
])
)
return
u
HalfHarmonic
=
HalfHarmonic
()
#
HalfHarmonic = HalfHarmonic()
class
TabulatedPotential
(
NonbondedScheme
):
def
__init__
(
self
,
tableFile
,
typesA
=
None
,
typesB
=
None
,
resolution
=
0.1
,
rMin
=
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