Skip to content

Commit 19bdd46

Browse files
committed
add support for gromacs + deepmd-kit-2.0
1 parent 6537a72 commit 19bdd46

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

dpgen/generator/run.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,9 @@ def _make_model_devi_native(iter_index, jdata, mdata, conf_systems):
10731073
sys_counter += 1
10741074

10751075
def _make_model_devi_native_gromacs(iter_index, jdata, mdata, conf_systems):
1076+
# only support for deepmd v2.0
1077+
if LooseVersion(mdata['deepmd_version']) < LooseVersion('2.0'):
1078+
raise RuntimeError("Only support deepmd-kit 2.x for model_devi_engine='gromacs'")
10761079
model_devi_jobs = jdata['model_devi_jobs']
10771080
if (iter_index >= len(model_devi_jobs)) :
10781081
return False
@@ -1172,7 +1175,7 @@ def run_model_devi (iter_index,
11721175
mdata) :
11731176
#rmdlog.info("This module has been run !")
11741177
lmp_exec = mdata['lmp_command']
1175-
# Angus: lmp_exec name should be changed to model_devi_exec.
1178+
# Anguse: lmp_exec name should be changed to model_devi_exec.
11761179
# We should also change make_dispatcher
11771180
# For now, I will use this name for gromacs command
11781181

@@ -1232,16 +1235,20 @@ def run_model_devi (iter_index,
12321235
deffnm = gromacs_settings.get("deffnm", "deepmd")
12331236
maxwarn = gromacs_settings.get("maxwarn", 1)
12341237
traj_filename = gromacs_settings.get("traj_filename", "deepmd_traj.gro")
1238+
grp_name = gromacs_settings.get("group_name", "Other")
12351239
nsteps = cur_job["nsteps"]
1240+
trj_freq = cur_job.get("trj_freq", 10)
12361241

12371242
command = "%s grompp -f %s -p %s -c %s -o %s -maxwarn %d" % (lmp_exec, mdp_filename, topol_filename, conf_filename, deffnm, maxwarn)
12381243
command += "&& %s mdrun -deffnm %s -nsteps %d" %(lmp_exec, deffnm, nsteps)
1239-
command += "&& echo -e \"MOL\nMOL\n\" | %s trjconv -s %s -f %s.trr -o %s -pbc mol -ur compact -center" % (lmp_exec, ref_filename, deffnm, traj_filename)
1240-
command += "&& python model_devi.py %s" % traj_filename
1244+
command += "&& echo -e \"%s\n%s\n\" | %s trjconv -s %s -f %s.trr -o %s -pbc mol -ur compact -center" % (grp_name, grp_name, lmp_exec, ref_filename, deffnm, traj_filename)
1245+
command += "&& if [ ! -d traj ]; then \n mkdir traj; fi\n"
1246+
command += f"python -c \"import dpdata;system = dpdata.System('{traj_filename}', fmt='gromacs/gro'); [system.to_gromacs_gro('traj/%d.gromacstrj' % (i * {trj_freq}), frame_idx=i) for i in range(system.get_nframes())]; system.to_deepmd_npy('traj_deepmd')\""
1247+
command += "&& dp model-devi -m ../graph.000.pb ../graph.001.pb ../graph.002.pb ../graph.003.pb -s traj_deepmd -o model_devi.out"
12411248
commands = [command]
12421249

1243-
forward_files = [mdp_filename, topol_filename, conf_filename, index_filename, ref_filename, "input.json", "model_devi.py", "job.json" ]
1244-
backward_files = ["%s.tpr" % deffnm, "%s.log" %deffnm , traj_filename, 'model_devi.out', 'model_devi.log', "traj" ]
1250+
forward_files = [mdp_filename, topol_filename, conf_filename, index_filename, ref_filename, "input.json", "job.json" ]
1251+
backward_files = ["%s.tpr" % deffnm, "%s.log" %deffnm , traj_filename, 'model_devi.out', "traj", "traj_deepmd" ]
12451252

12461253

12471254
cwd = os.getcwd()

0 commit comments

Comments
 (0)