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

Add parameter 'srtab_file_path' so that one can use DP-ZBL potential successfully #918

Merged
merged 22 commits into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dpgen/generator/arginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def training_args() -> List[Argument]:
doc_training_reuse_start_pref_e = "The prefactor of energy loss at the start of the training." + doc_reusing
doc_training_reuse_start_pref_f = "The prefactor of force loss at the start of the training." + doc_reusing
doc_model_devi_activation_func = "The activation function in the model. The shape of list should be (N_models, 2), where 2 represents the embedding and fitting network. This option will override default parameters."
doc_srtab_file_path = 'The path of the table for the short-range pairwise interaction which is needed when using DP-ZBL potential'

return [
Argument("numb_models", int, optional=False, doc=doc_numb_models),
Expand All @@ -97,6 +98,8 @@ def training_args() -> List[Argument]:
Argument("training_reuse_start_pref_e", [None, float, int], optional=True, default=0.1, doc=doc_training_reuse_start_pref_e),
Argument("training_reuse_start_pref_f", [None, float, int], optional=True, default=100, doc=doc_training_reuse_start_pref_f),
Argument("model_devi_activation_func", [None, list], optional=True, doc=doc_model_devi_activation_func),
Argument("srtab_file_path",str,optional=True,
doc=doc_srtab_file_path),
]


Expand Down
16 changes: 15 additions & 1 deletion dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ def make_train (iter_index,
training_init_model = jdata.get('training_init_model', False)
training_reuse_iter = jdata.get('training_reuse_iter')
training_reuse_old_ratio = jdata.get('training_reuse_old_ratio', None)


#if you want to use DP-ZBL potential , you have to give the path of your energy potential file
if 'srtab_file_path' in jdata.keys():
srtab_file_path = os.path.abspath(jdata.get("srtab_file_path", None))

if 'training_reuse_stop_batch' in jdata.keys():
training_reuse_stop_batch = jdata['training_reuse_stop_batch']
elif 'training_reuse_numb_steps' in jdata.keys():
Expand Down Expand Up @@ -384,6 +388,10 @@ def make_train (iter_index,
task_path = os.path.join(work_path, train_task_fmt % ii)
create_path(task_path)
os.chdir(task_path)

if 'srtab_file_path' in jdata.keys():
shutil.copyfile(srtab_file_path,os.path.basename(srtab_file_path))

for jj in init_data_sys :
# HDF5 path contains #
if not (os.path.isdir(jj) if "#" not in jj else os.path.isfile(jj.split("#")[0])):
Expand Down Expand Up @@ -486,6 +494,10 @@ def run_train (iter_index,
train_input_file = default_train_input_file
training_reuse_iter = jdata.get('training_reuse_iter')
training_init_model = jdata.get('training_init_model', False)

if 'srtab_file_path' in jdata.keys():
zbl_file=os.path.basename(jdata.get("srtab_file_path", None))

if training_reuse_iter is not None and iter_index >= training_reuse_iter:
training_init_model = True
try:
Expand Down Expand Up @@ -543,6 +555,8 @@ def run_train (iter_index,
run_tasks = [os.path.basename(ii) for ii in all_task]

forward_files = [train_input_file]
if 'srtab_file_path' in jdata.keys():
forward_files.append(zbl_file)
if training_init_model:
forward_files += [os.path.join('old', 'model.ckpt.meta'),
os.path.join('old', 'model.ckpt.index'),
Expand Down