Skip to content

Commit 2939f00

Browse files
committed
fix: use the -time flag of grompp instead of .reaction trr and edr
files closes #531 fixes #519
1 parent 4783bf1 commit 2939f00

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/kimmdy/runmanager.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ def _setup(self, files: TaskFiles) -> TaskFiles:
782782
return files
783783

784784
def _run_md(
785-
self, instance: str, files: TaskFiles, continue_md: bool = False
785+
self, instance: str, files: TaskFiles, continue_md: bool = False, time: float|None = None
786786
) -> TaskFiles:
787787
"""General MD simulation"""
788788
logger = files.logger
@@ -820,12 +820,20 @@ def _run_md(
820820
if self.latest_files.get("trr") is not None:
821821
trr = files.input["trr"]
822822
grompp_cmd += f" -t {trr}"
823-
if self.latest_files.get("edr") is not None:
824-
edr = files.input["edr"]
825-
if edr is not None and edr.exists():
826-
grompp_cmd += f" -e {edr}"
827-
else:
828-
logger.warning(f"edr file {edr} not found")
823+
if time is not None:
824+
# start the relaxation or next MD from the chosen reaction time
825+
# that is already rounded to the nearest trr frame in _decide_recipe.
826+
grompp_cmd += f" -time {time}"
827+
logger.info(f"Starting MD from time: {time} ps of the trr")
828+
829+
# TODO: remove this, edr files just do weird things.
830+
# if self.latest_files.get("edr") is not None:
831+
# edr = files.input["edr"]
832+
# if edr is not None and edr.exists():
833+
# grompp_cmd += f" -e {edr}"
834+
# else:
835+
# logger.warning(f"edr file {edr} not found")
836+
829837
logger.debug(f"grompp cmd: {grompp_cmd}")
830838

831839
mdrun_cmd = (
@@ -1124,8 +1132,9 @@ def _apply_recipe(self, files: TaskFiles) -> TaskFiles:
11241132
if ttime is not None:
11251133
write_coordinate_files_at_reaction_time(files=files, time=ttime)
11261134
self.latest_files["gro"] = files.output["gro"]
1127-
self.latest_files["trr"] = files.output["trr"]
1128-
self.latest_files["edr"] = files.output["edr"]
1135+
# don't use trr and edr, use the `-time` flag of gmx grompp instead
1136+
# self.latest_files["trr"] = files.output["trr"]
1137+
# self.latest_files["edr"] = files.output["edr"]
11291138

11301139
top_initial = deepcopy(self.top)
11311140
for step in recipe.recipe_steps:
@@ -1245,7 +1254,7 @@ def _apply_recipe(self, files: TaskFiles) -> TaskFiles:
12451254
relax_task = Task(
12461255
self,
12471256
f=self._run_md,
1248-
kwargs={"instance": md_instance},
1257+
kwargs={"instance": md_instance, "time": self.kmcresult.time_start},
12491258
out=md_instance,
12501259
)
12511260
relax_task_files = relax_task()

0 commit comments

Comments
 (0)