From 925108baed490d2a5ce0b6c9318f78ac0deb4295 Mon Sep 17 00:00:00 2001 From: zjgemi Date: Thu, 22 Aug 2024 20:14:13 +0800 Subject: [PATCH 1/4] Support keywords of pair_style for LmpTemplateTaskGroup Signed-off-by: zjgemi --- dpgen2/exploration/task/lmp_template_task_group.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dpgen2/exploration/task/lmp_template_task_group.py b/dpgen2/exploration/task/lmp_template_task_group.py index aeecde92..54117cac 100644 --- a/dpgen2/exploration/task/lmp_template_task_group.py +++ b/dpgen2/exploration/task/lmp_template_task_group.py @@ -140,10 +140,14 @@ def find_only_one_key(lmp_lines, key): def revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, deepmd_version="1"): idx = find_only_one_key(lmp_lines, ["pair_style", "deepmd"]) + keywords = "" + for arg in lmp_lines[idx].split()[2:]: + keywords += " " + arg graph_list = " ".join(task_model_list) - lmp_lines[idx] = "pair_style deepmd %s out_freq %d out_file model_devi.out" % ( + lmp_lines[idx] = "pair_style deepmd %s out_freq %d out_file model_devi.out%s" % ( graph_list, trj_freq, + keywords, ) return lmp_lines From db1e1db98c84c3cef863acc05e9614170dbf5d95 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 12:15:12 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpgen2/exploration/task/lmp_template_task_group.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dpgen2/exploration/task/lmp_template_task_group.py b/dpgen2/exploration/task/lmp_template_task_group.py index 54117cac..42f1736b 100644 --- a/dpgen2/exploration/task/lmp_template_task_group.py +++ b/dpgen2/exploration/task/lmp_template_task_group.py @@ -144,10 +144,13 @@ def revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, deepmd_version= for arg in lmp_lines[idx].split()[2:]: keywords += " " + arg graph_list = " ".join(task_model_list) - lmp_lines[idx] = "pair_style deepmd %s out_freq %d out_file model_devi.out%s" % ( - graph_list, - trj_freq, - keywords, + lmp_lines[idx] = ( + "pair_style deepmd %s out_freq %d out_file model_devi.out%s" + % ( + graph_list, + trj_freq, + keywords, + ) ) return lmp_lines From 413be9d5f6d5e4c0c9928e76dfb44d3bb089097a Mon Sep 17 00:00:00 2001 From: zjgemi Date: Fri, 23 Aug 2024 09:48:00 +0800 Subject: [PATCH 3/4] add extra_pair_style_args Signed-off-by: zjgemi --- dpgen2/exploration/task/lmp_template_task_group.py | 13 +++++++------ .../exploration/task/make_task_group_from_config.py | 10 +++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/dpgen2/exploration/task/lmp_template_task_group.py b/dpgen2/exploration/task/lmp_template_task_group.py index 54117cac..7a92c7fe 100644 --- a/dpgen2/exploration/task/lmp_template_task_group.py +++ b/dpgen2/exploration/task/lmp_template_task_group.py @@ -43,14 +43,16 @@ def set_lmp( plm_template_fname: Optional[str] = None, revisions: dict = {}, traj_freq: int = 10, + extra_pair_style_args: str = "", ) -> None: self.lmp_template = Path(lmp_template_fname).read_text().split("\n") self.revisions = revisions self.traj_freq = traj_freq + self.extra_pair_style_args = extra_pair_style_args self.lmp_set = True self.model_list = sorted([model_name_pattern % ii for ii in range(numb_models)]) self.lmp_template = revise_lmp_input_model( - self.lmp_template, self.model_list, self.traj_freq + self.lmp_template, self.model_list, self.traj_freq, self.extra_pair_style_args ) self.lmp_template = revise_lmp_input_dump(self.lmp_template, self.traj_freq) if plm_template_fname is not None: @@ -138,16 +140,15 @@ def find_only_one_key(lmp_lines, key): return found[0] -def revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, deepmd_version="1"): +def revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, extra_pair_style_args="", deepmd_version="1"): idx = find_only_one_key(lmp_lines, ["pair_style", "deepmd"]) - keywords = "" - for arg in lmp_lines[idx].split()[2:]: - keywords += " " + arg + if extra_pair_style_args: + extra_pair_style_args = " " + extra_pair_style_args graph_list = " ".join(task_model_list) lmp_lines[idx] = "pair_style deepmd %s out_freq %d out_file model_devi.out%s" % ( graph_list, trj_freq, - keywords, + extra_pair_style_args, ) return lmp_lines diff --git a/dpgen2/exploration/task/make_task_group_from_config.py b/dpgen2/exploration/task/make_task_group_from_config.py index d82f3463..ab7be4a6 100644 --- a/dpgen2/exploration/task/make_task_group_from_config.py +++ b/dpgen2/exploration/task/make_task_group_from_config.py @@ -100,6 +100,7 @@ def lmp_template_task_group_args(): doc_plm_template_fname = "The file name of plumed input template" doc_revisions = "The revisions. Should be a dict providing the key - list of desired values pair. Key is the word to be replaced in the templates, and it may appear in both the lammps and plumed input templates. All values in the value list will be enmerated." doc_traj_freq = "The frequency of dumping configurations and thermodynamic states" + doc_extra_pair_style_args = "The extra arguments for pair_style" return [ Argument("conf_idx", list, optional=False, doc=doc_conf_idx, alias=["sys_idx"]), @@ -125,7 +126,7 @@ def lmp_template_task_group_args(): doc=doc_plm_template_fname, alias=["plm_template", "plm"], ), - Argument("revisions", dict, optional=True, default={}), + Argument("revisions", dict, optional=True, default={}, doc=doc_revisions), Argument( "traj_freq", int, @@ -134,6 +135,13 @@ def lmp_template_task_group_args(): doc=doc_traj_freq, alias=["t_freq", "trj_freq", "trj_freq"], ), + Argument( + "extra_pair_style_args", + str, + optional=True, + default="", + doc=doc_extra_pair_style_args, + ) ] From 44466ea903bb9624faa760062bc5062756c90ab3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 01:49:20 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpgen2/exploration/task/lmp_template_task_group.py | 9 +++++++-- dpgen2/exploration/task/make_task_group_from_config.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dpgen2/exploration/task/lmp_template_task_group.py b/dpgen2/exploration/task/lmp_template_task_group.py index cab0896d..b82e1695 100644 --- a/dpgen2/exploration/task/lmp_template_task_group.py +++ b/dpgen2/exploration/task/lmp_template_task_group.py @@ -52,7 +52,10 @@ def set_lmp( self.lmp_set = True self.model_list = sorted([model_name_pattern % ii for ii in range(numb_models)]) self.lmp_template = revise_lmp_input_model( - self.lmp_template, self.model_list, self.traj_freq, self.extra_pair_style_args + self.lmp_template, + self.model_list, + self.traj_freq, + self.extra_pair_style_args, ) self.lmp_template = revise_lmp_input_dump(self.lmp_template, self.traj_freq) if plm_template_fname is not None: @@ -140,7 +143,9 @@ def find_only_one_key(lmp_lines, key): return found[0] -def revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, extra_pair_style_args="", deepmd_version="1"): +def revise_lmp_input_model( + lmp_lines, task_model_list, trj_freq, extra_pair_style_args="", deepmd_version="1" +): idx = find_only_one_key(lmp_lines, ["pair_style", "deepmd"]) if extra_pair_style_args: extra_pair_style_args = " " + extra_pair_style_args diff --git a/dpgen2/exploration/task/make_task_group_from_config.py b/dpgen2/exploration/task/make_task_group_from_config.py index ab7be4a6..b6b2aeb6 100644 --- a/dpgen2/exploration/task/make_task_group_from_config.py +++ b/dpgen2/exploration/task/make_task_group_from_config.py @@ -141,7 +141,7 @@ def lmp_template_task_group_args(): optional=True, default="", doc=doc_extra_pair_style_args, - ) + ), ]