Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbdmodel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tbgl
tools
arbdmodel
Commits
1578c981
Commit
1578c981
authored
5 years ago
by
cmaffeo2
Browse files
Options
Downloads
Patches
Plain Diff
Added basic support for rigid body groups made out of particles
parent
17f8c66a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arbdmodel/__init__.py
+55
-4
55 additions, 4 deletions
arbdmodel/__init__.py
with
55 additions
and
4 deletions
arbdmodel/__init__.py
+
55
−
4
View file @
1578c981
...
...
@@ -72,8 +72,9 @@ class Parent():
self
.
impropers
=
[]
self
.
exclusions
=
[]
## TODO: self.cacheInvalid = True # What will be in the cache?
self
.
rigid
=
False
## TODO: self.cacheInvalid = True # What will be in the cache?
def
add
(
self
,
x
):
## TODO: check the parent-child tree to make sure there are no cycles
...
...
@@ -252,11 +253,17 @@ class Child():
def
__getattr__
(
self
,
name
):
"""
Try to get attribute from the parent
"""
# if self.parent is not None:
if
"
parent
"
not
in
self
.
__dict__
or
self
.
__dict__
[
"
parent
"
]
is
None
or
name
is
"
children
"
:
raise
AttributeError
(
"'
{}
'
object has no attribute
'
{}
'"
.
format
(
type
(
self
).
__name__
,
name
))
excluded_attributes
=
[
'
parent
'
,
'
rigid
'
]
if
name
in
excluded_attributes
:
raise
AttributeError
(
"'
{}
'
object has no attribute
'
{}
'
and cannot look it up from the parent
"
.
format
(
type
(
self
).
__name__
,
name
))
## TODO: determine if there is a way to avoid __getattr__ if a method is being looked up
try
:
ret
=
getattr
(
self
.
parent
,
name
)
...
...
@@ -324,7 +331,7 @@ class ParticleType():
excludedAttributes
=
(
"
idx
"
,
"
type_
"
,
"
position
"
,
"
children
"
,
"
parent
"
,
"
excludedAttributes
"
,
"
parent
"
,
"
excludedAttributes
"
,
"
rigid
"
)
def
__init__
(
self
,
name
,
charge
=
0
,
parent
=
None
,
**
kargs
):
...
...
@@ -866,8 +873,32 @@ class ArbdModel(PdbModel):
data
=
data
+
[
0
,
0
,
0
]
fh
.
write
(
"
ATOM %d %s %f %f %f %f %f %f
\n
"
%
tuple
(
data
))
def
_write_rigid_group_file
(
self
,
filename
,
groups
):
with
open
(
filename
,
'
w
'
)
as
fh
:
for
g
in
groups
:
fh
.
write
(
"
#Group
\n
"
)
try
:
if
len
(
g
.
trans_damping
)
!=
3
:
raise
fh
.
write
(
"
"
.
join
(
str
(
v
)
for
v
in
g
.
trans_damping
)
+
"
"
)
except
:
raise
ValueError
(
"
Group {} lacks 3-value
'
trans_damping
'
attribute
"
)
try
:
if
len
(
g
.
rot_damping
)
!=
3
:
raise
fh
.
write
(
"
"
.
join
(
str
(
v
)
for
v
in
g
.
rot_damping
)
+
"
"
)
except
:
raise
ValueError
(
"
Group {} lacks 3-value
'
rot_damping
'
attribute
"
)
fh
.
write
(
"
{}
\n
"
.
format
(
len
(
g
)))
particles
=
[
p
for
p
in
g
]
def
chunks
(
l
,
n
):
"""
Yield successive n-sized chunks from l.
"""
for
i
in
range
(
0
,
len
(
l
),
n
):
yield
l
[
i
:
i
+
n
]
for
c
in
chunks
(
particles
,
8
):
fh
.
write
(
"
"
.
join
(
str
(
p
.
idx
)
for
p
in
c
)
+
"
\n
"
)
def
_writeArbdConf
(
self
,
prefix
,
randomSeed
=
None
,
numSteps
=
100000000
,
outputPeriod
=
10000
,
restart_file
=
None
):
## TODO: raise exception if _writeArbdPotentialFiles has not been called
filename
=
"
%s.bd
"
%
prefix
...
...
@@ -895,6 +926,26 @@ class ArbdModel(PdbModel):
params
[
'
pairlistDistance
'
]
-=
params
[
'
cutoff
'
]
"""
Find rigid groups
"""
rigid_groups
=
[]
def
get_rigid_groups
(
parent
):
ret_list
=
[]
for
c
in
parent
.
children
:
is_rigid
=
c
.
rigid
if
'
rigid
'
in
c
.
__dict__
else
False
if
is_rigid
:
rigid_groups
.
append
(
c
)
elif
isinstance
(
c
,
Group
):
get_rigid_groups
(
c
)
get_rigid_groups
(
self
)
if
len
(
rigid_groups
)
>
0
:
self
.
particle_integrator
=
'
FusDynamic
'
rb_group_filename
=
"
{}.rb-group.txt
"
.
format
(
prefix
)
params
[
'
particle_integrator
'
]
=
"""
FusDynamics
groupFileName {}
scaleFactor 0.05
"""
.
format
(
rb_group_filename
)
self
.
_write_rigid_group_file
(
rb_group_filename
,
rigid_groups
)
## Actually write the file
with
open
(
filename
,
'
w
'
)
as
fh
:
fh
.
write
(
"""
{randomSeed}
...
...
@@ -933,7 +984,7 @@ systemSize {dimX} {dimY} {dimZ}
"""
units
"
k K/(amu/ns)
"
"
AA**2/ns
"
"""
D
=
831447.2
*
self
.
temperature
/
(
pt
.
mass
*
pt
.
damping_coefficient
)
particleParams
[
'
dynamics
'
]
=
'
diffusion {D}
'
.
format
(
D
=
D
)
elif
self
.
particle_integrator
==
'
Langevin
'
:
elif
self
.
particle_integrator
in
(
'
Langevin
'
,
'
FusDynamic
'
)
:
try
:
gamma
=
pt
.
damping_coefficient
except
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment