Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model_devi | sort models in default&support user-defined order #610

Merged
merged 3 commits into from
Dec 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def make_model_devi (iter_index,
iter_name = make_iter_name(iter_index)
train_path = os.path.join(iter_name, train_name)
train_path = os.path.abspath(train_path)
models = glob.glob(os.path.join(train_path, "graph*pb"))
models = sorted(glob.glob(os.path.join(train_path, "graph*pb")))
work_path = os.path.join(iter_name, model_devi_name)
create_path(work_path)
for mm in models :
Expand Down Expand Up @@ -890,7 +890,7 @@ def _make_model_devi_revmat(iter_index, jdata, mdata, conf_systems):
iter_name = make_iter_name(iter_index)
train_path = os.path.join(iter_name, train_name)
train_path = os.path.abspath(train_path)
models = glob.glob(os.path.join(train_path, "graph*pb"))
models = sorted(glob.glob(os.path.join(train_path, "graph*pb")))
task_model_list = []
for ii in models:
task_model_list.append(os.path.join('..', os.path.basename(ii)))
Expand Down Expand Up @@ -947,7 +947,23 @@ def _make_model_devi_revmat(iter_index, jdata, mdata, conf_systems):
# revise input of lammps
with open('input.lammps') as fp:
lmp_lines = fp.readlines()
lmp_lines = revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, deepmd_version = deepmd_version)
# only revise the line "pair_style deepmd" if the user has not written the full line (checked by then length of the line)
template_has_pair_deepmd=1
for line_idx,line_context in enumerate(lmp_lines):
if (line_context[0] != "#") and ("pair_style" in line_context) and ("deepmd" in line_context):
template_has_pair_deepmd=0
template_pair_deepmd_idx=line_idx
if template_has_pair_deepmd == 0:
if LooseVersion(deepmd_version) < LooseVersion('1'):
if len(lmp_lines[template_pair_deepmd_idx].split()) != (len(models) + len(["pair_style","deepmd","10", "model_devi.out"])):
lmp_lines = revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, deepmd_version = deepmd_version)
else:
if len(lmp_lines[template_pair_deepmd_idx].split()) != (len(models) + len(["pair_style","deepmd","out_freq", "10", "out_file", "model_devi.out"])):
lmp_lines = revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, deepmd_version = deepmd_version)
#use revise_lmp_input_model to raise error message if "part_style" or "deepmd" not found
else:
lmp_lines = revise_lmp_input_model(lmp_lines, task_model_list, trj_freq, deepmd_version = deepmd_version)

lmp_lines = revise_lmp_input_dump(lmp_lines, trj_freq)
lmp_lines = revise_by_keys(
lmp_lines, total_rev_keys[:total_num_lmp], total_rev_item[:total_num_lmp]
Expand Down