Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PuReMD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SParTA
PuReMD
Commits
e850999e
Commit
e850999e
authored
6 years ago
by
Kurt A. O'Hearn
Browse files
Options
Downloads
Patches
Plain Diff
sPuReMD: update tools/run_sim.py for running user-specified (custom) MD simulations.
parent
6ea9210e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/run_sim.py
+77
-5
77 additions, 5 deletions
tools/run_sim.py
with
77 additions
and
5 deletions
tools/run_sim.py
+
77
−
5
View file @
e850999e
...
...
@@ -108,6 +108,14 @@ class TestCase():
r
'
(?P<key>\bcompress\b\s+)\S+(?P<comment>.*)
'
,
r
'
\g<key>%s\g<comment>
'
%
x
,
l
),
\
'
press_mode
'
:
lambda
l
,
x
:
sub
(
r
'
(?P<key>\bpress_mode\b\s+)\S+(?P<comment>.*)
'
,
r
'
\g<key>%s\g<comment>
'
%
x
,
l
),
\
'
write_freq
'
:
lambda
l
,
x
:
sub
(
r
'
(?P<key>\bwrite_freq\b\s+)\S+(?P<comment>.*)
'
,
r
'
\g<key>%s\g<comment>
'
%
x
,
l
),
\
'
traj_compress
'
:
lambda
l
,
x
:
sub
(
r
'
(?P<key>\btraj_compress\b\s+)\S+(?P<comment>.*)
'
,
r
'
\g<key>%s\g<comment>
'
%
x
,
l
),
\
'
traj_format
'
:
lambda
l
,
x
:
sub
(
r
'
(?P<key>\btraj_format\b\s+)\S+(?P<comment>.*)
'
,
r
'
\g<key>%s\g<comment>
'
%
x
,
l
),
\
'
traj_title
'
:
lambda
l
,
x
:
sub
(
r
'
(?P<key>\btraj_title\b\s+)\S+(?P<comment>.*)
'
,
r
'
\g<key>%s\g<comment>
'
%
x
,
l
),
\
}
self
.
__params
[
'
geo_format
'
]
=
geo_format
self
.
__min_step
=
min_step
...
...
@@ -258,7 +266,7 @@ restart_freq 0 ! 0: do not output any restart f
def
_create_output_file_base
(
self
,
run_type
,
param_dict
):
if
run_type
==
'
serial
'
or
run_type
==
'
openmp
'
:
param_dict
[
'
name
'
]
=
path
.
basename
(
self
.
__geo_file
).
split
(
'
.
'
)[
0
]
\
name
=
path
.
basename
(
self
.
__geo_file
).
split
(
'
.
'
)[
0
]
\
+
'
_cm
'
+
param_dict
[
'
charge_method
'
]
\
+
'
_s
'
+
param_dict
[
'
nsteps
'
]
\
+
'
_q
'
+
param_dict
[
'
cm_solver_type
'
]
\
...
...
@@ -273,7 +281,7 @@ restart_freq 0 ! 0: do not output any restart f
+
'
_paji
'
+
param_dict
[
'
cm_solver_pre_app_jacobi_iters
'
]
\
+
'
_t
'
+
param_dict
[
'
threads
'
]
elif
run_type
==
'
mpi
'
or
run_type
==
'
mpi+gpu
'
:
param_dict
[
'
name
'
]
=
path
.
basename
(
self
.
__geo_file
).
split
(
'
.
'
)[
0
]
\
name
=
path
.
basename
(
self
.
__geo_file
).
split
(
'
.
'
)[
0
]
\
+
'
_cm
'
+
param_dict
[
'
charge_method
'
]
\
+
'
_s
'
+
param_dict
[
'
nsteps
'
]
\
+
'
_proc
'
+
param_dict
[
'
proc_by_dim
'
].
replace
(
'
:
'
,
'
_
'
)
\
...
...
@@ -289,8 +297,10 @@ restart_freq 0 ! 0: do not output any restart f
+
'
_pcsai
'
+
param_dict
[
'
cm_solver_pre_comp_sai_thres
'
]
\
+
'
_pa
'
+
param_dict
[
'
cm_solver_pre_app_type
'
]
\
+
'
_paji
'
+
str
(
param_dict
[
'
cm_solver_pre_app_jacobi_iters
'
])
else
:
name
=
'
default_sim
'
return
param_dict
return
name
def
run_md
(
self
,
binary
,
run_type
,
mpi_cmd
):
from
itertools
import
product
...
...
@@ -305,7 +315,9 @@ restart_freq 0 ! 0: do not output any restart f
# create Cartesian product of all supplied sets of parameter values
for
p
in
product
(
*
[
self
.
__params
[
k
]
for
k
in
self
.
__param_names
]):
param_dict
=
dict
((
k
,
v
)
for
(
k
,
v
)
in
zip
(
self
.
__param_names
,
p
))
param_dict
=
self
.
_create_output_file_base
(
run_type
,
param_dict
)
param_dict
[
'
name
'
]
=
self
.
_create_output_file_base
(
run_type
,
param_dict
)
if
not
param_dict
[
'
traj_title
'
]:
param_dict
[
'
traj_title
'
]
=
param_dict
[
'
name
'
]
+
'
.trj
'
temp_file
=
path
.
join
(
temp_dir
,
'
control
'
)
self
.
_create_control_file
(
param_dict
,
temp_file
)
...
...
@@ -407,7 +419,7 @@ restart_freq 0 ! 0: do not output any restart f
# create Cartesian product of all supplied sets of parameter values
for
p
in
product
(
*
[
self
.
__params
[
k
]
for
k
in
self
.
__param_names
]):
param_dict
=
dict
((
k
,
v
)
for
(
k
,
v
)
in
zip
(
self
.
__param_names
,
p
))
param_dict
=
self
.
_create_output_file_base
(
run_type
,
param_dict
)
param_dict
[
'
name
'
]
=
self
.
_create_output_file_base
(
run_type
,
param_dict
)
self
.
_process_result
(
fout
,
param_dict
,
self
.
__min_step
,
self
.
__max_step
)
...
...
@@ -521,6 +533,7 @@ if __name__ == '__main__':
parser
=
argparse
.
ArgumentParser
(
description
=
'
Molecular dynamics simulation tools used with specified data sets.
'
)
subparsers
=
parser
.
add_subparsers
(
help
=
"
Actions.
"
)
run_md_parser
=
subparsers
.
add_parser
(
"
run_md
"
)
run_md_custom_parser
=
subparsers
.
add_parser
(
"
run_md_custom
"
)
parse_results_parser
=
subparsers
.
add_parser
(
"
parse_results
"
)
submit_jobs_parser
=
subparsers
.
add_parser
(
"
submit_jobs
"
)
...
...
@@ -538,6 +551,22 @@ if __name__ == '__main__':
choices
=
DATA_SETS
,
help
=
'
Data set(s) used for the MD simulation(s).
'
)
run_md_parser
.
set_defaults
(
func
=
run_md
)
run_md_custom_parser
.
add_argument
(
'
-b
'
,
'
--binary
'
,
metavar
=
'
binary
'
,
default
=
None
,
nargs
=
1
,
help
=
'
Binary file used for running the MD simulation(s).
'
)
run_md_custom_parser
.
add_argument
(
'
-p
'
,
'
--params
'
,
metavar
=
'
params
'
,
action
=
'
append
'
,
default
=
None
,
nargs
=
2
,
help
=
'
Paramater name and value pairs for the simulation as defined in the control file.
'
+
'
Multiple values for a parameter can be specified using commas, and each
'
+
'
value will constitute a separate MD simulation.
'
)
run_md_custom_parser
.
add_argument
(
'
-m
'
,
'
--mpi_cmd
'
,
metavar
=
'
mpi_cmd
'
,
default
=
[
'
mpirun
'
],
nargs
=
1
,
help
=
'
MPI command type and arguments. Examples:
\'
mpirun
\'
,
\'
srun:1:32:1
\'
.
'
)
run_md_custom_parser
.
add_argument
(
'
run_type
'
,
nargs
=
1
,
choices
=
RUN_TYPES
,
help
=
'
Run type for the MD simulation(s).
'
)
run_md_custom_parser
.
add_argument
(
'
geo_file
'
,
nargs
=
1
,
help
=
'
Geometry file used for the MD simulation.
'
)
run_md_custom_parser
.
add_argument
(
'
ffield_file
'
,
nargs
=
1
,
help
=
'
Force field parameter file used for the MD simulation.
'
)
run_md_custom_parser
.
set_defaults
(
func
=
run_md_custom
)
parse_results_parser
.
add_argument
(
'
-f
'
,
'
--out_file
'
,
metavar
=
'
out_file
'
,
default
=
None
,
nargs
=
1
,
help
=
'
Output file to write results.
'
)
parse_results_parser
.
add_argument
(
'
-p
'
,
'
--params
'
,
metavar
=
'
params
'
,
action
=
'
append
'
,
default
=
None
,
nargs
=
2
,
...
...
@@ -616,6 +645,10 @@ if __name__ == '__main__':
'
pt_mass
'
:
[
'
5000.0
'
],
'
compress
'
:
[
'
0.008134
'
],
'
press_mode
'
:
[
'
0
'
],
'
write_freq
'
:
[
'
0
'
],
'
traj_format
'
:
[
'
0
'
],
'
traj_compress
'
:
[
'
0
'
],
'
traj_title
'
:
[
None
],
}
return
data_dir
,
control_params_dict
...
...
@@ -754,6 +787,45 @@ if __name__ == '__main__':
for
test
in
test_cases
:
test
.
run_md
(
binary
,
args
.
run_type
[
0
],
args
.
mpi_cmd
[
0
].
split
(
'
:
'
))
def
run_md_custom
(
args
):
if
args
.
binary
:
binary
=
args
.
binary
[
0
]
# remove executable and back up two directory levels
base_dir
=
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
path
.
abspath
(
binary
))))
else
:
base_dir
=
getcwd
()
if
args
.
run_type
[
0
]
==
'
serial
'
or
args
.
run_type
[
0
]
==
'
openmp
'
:
binary
=
path
.
join
(
base_dir
,
'
sPuReMD/bin/spuremd
'
)
elif
args
.
run_type
[
0
]
==
'
mpi
'
:
binary
=
path
.
join
(
base_dir
,
'
PuReMD/bin/puremd
'
)
elif
args
.
run_type
[
0
]
==
'
mpi+gpu
'
:
binary
=
path
.
join
(
base_dir
,
'
PG-PuReMD/bin/pg-puremd
'
)
_
,
control_params_dict
=
setup_defaults
(
base_dir
)
# overwrite default control file parameter values if supplied via command line args
if
args
.
params
:
for
param
in
args
.
params
:
if
param
[
0
]
in
control_params_dict
:
control_params_dict
[
param
[
0
]]
=
param
[
1
].
split
(
'
,
'
)
else
:
print
(
"
ERROR: Invalid parameter {0}. Terminating...
"
.
format
(
param
[
0
]))
exit
(
-
1
)
geo_base
,
geo_ext
=
path
.
splitext
(
args
.
geo_file
[
0
])
if
geo_ext
==
'
.pdb
'
:
geo_format
=
[
'
1
'
]
elif
geo_ext
==
'
.geo
'
:
geo_format
=
[
'
0
'
]
else
:
print
(
"
ERROR: unrecognized geometry format {0}. Terminating...
"
.
format
(
ext
))
exit
(
-
1
)
test_case
=
TestCase
(
geo_base
,
args
.
geo_file
[
0
],
args
.
ffield_file
[
0
],
params
=
control_params_dict
,
geo_format
=
geo_format
)
test_case
.
run_md
(
binary
,
args
.
run_type
[
0
],
args
.
mpi_cmd
[
0
].
split
(
'
:
'
))
def
parse_results
(
args
):
header_fmt_str
=
'
{:15}|{:5}|{:5}|{:5}|{:5}|{:5}|{:5}|{:5}|{:5}|{:5}|{:5}|{:5}|{:10}|{:10}|{:10}|{:10}|{:10}|{:3}|{:10}
\n
'
header_str
=
[
'
Data Set
'
,
'
Steps
'
,
'
CM
'
,
'
Solvr
'
,
'
Q Tol
'
,
'
QDS
'
,
'
PreCT
'
,
'
PreCD
'
,
'
PreCS
'
,
'
PCSAI
'
,
'
PreAT
'
,
'
PreAJ
'
,
'
Pre Comp
'
,
...
...
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