Skip to content

Commit

Permalink
add RunLmpHDF5
Browse files Browse the repository at this point in the history
Signed-off-by: zjgemi <liuxin_zijian@163.com>
  • Loading branch information
zjgemi committed Oct 17, 2024
1 parent 336d385 commit 899aaba
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dpgen2/entrypoint/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
RunCalyModelDevi,
RunDPTrain,
RunLmp,
RunLmpHDF5,
RunRelax,
RunRelaxHDF5,
SelectConfs,
Expand Down Expand Up @@ -187,7 +188,7 @@ def make_concurrent_learning_op(
prep_run_explore_op = PrepRunLmp(
"prep-run-lmp",
PrepLmp,
RunLmp,
RunLmpHDF5 if explore_config["use_hdf5"] else RunLmp, # type: ignore
prep_config=prep_explore_config,
run_config=run_explore_config,
upload_python_packages=upload_python_packages,
Expand Down
1 change: 1 addition & 0 deletions dpgen2/op/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
)
from .run_lmp import (
RunLmp,
RunLmpHDF5,
)
from .run_relax import (
RunRelax,
Expand Down
27 changes: 26 additions & 1 deletion dpgen2/op/run_lmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Tuple,
)

import numpy as np
from dargs import (
Argument,
ArgumentEncoder,
Expand All @@ -26,6 +27,7 @@
Artifact,
BigParameter,
FatalError,
HDF5Datasets,
OPIOSign,
TransientError,
)
Expand Down Expand Up @@ -200,7 +202,7 @@ def execute(
ret_dict = {
"log": work_dir / lmp_log_name,
"traj": work_dir / lmp_traj_name,
"model_devi": work_dir / lmp_model_devi_name,
"model_devi": self.get_model_devi(work_dir / lmp_model_devi_name),
}
plm_output = (
{"plm_output": work_dir / plm_output_name}
Expand All @@ -213,13 +215,17 @@ def execute(

return OPIO(ret_dict)

def get_model_devi(self, model_devi_file):
return model_devi_file

@staticmethod
def lmp_args():
doc_lmp_cmd = "The command of LAMMPS"
doc_teacher_model = "The teacher model in `Knowledge Distillation`"
doc_shuffle_models = "Randomly pick a model from the group of models to drive theexploration MD simulation"
doc_head = "Select a head from multitask"
doc_use_ele_temp = "Whether to use electronic temperature, 0 for no, 1 for frame temperature, and 2 for atomic temperature"
doc_use_hdf5 = "Use HDF5 to store trajs and model_devis"
return [
Argument("command", str, optional=True, default="lmp", doc=doc_lmp_cmd),
Argument(
Expand All @@ -243,6 +249,13 @@ def lmp_args():
Argument(
"model_frozen_head", str, optional=True, default=None, doc=doc_head
),
Argument(
"use_hdf5",
bool,
optional=True,
default=False,
doc=doc_use_hdf5,
),
]

@staticmethod
Expand Down Expand Up @@ -374,3 +387,15 @@ def merge_pimd_files():
for model_devi_file in sorted(model_devi_files):
with open(model_devi_file, "r") as f2:
f.write(f2.read())


class RunLmpHDF5(RunLmp):
@classmethod
def get_output_sign(cls):
output_sign = super().get_output_sign()
output_sign["traj"] = Artifact(HDF5Datasets)
output_sign["model_devi"] = Artifact(HDF5Datasets)
return output_sign

Check warning on line 398 in dpgen2/op/run_lmp.py

View check run for this annotation

Codecov / codecov/patch

dpgen2/op/run_lmp.py#L395-L398

Added lines #L395 - L398 were not covered by tests

def get_model_devi(self, model_devi_file):
return np.loadtxt(model_devi_file)

Check warning on line 401 in dpgen2/op/run_lmp.py

View check run for this annotation

Codecov / codecov/patch

dpgen2/op/run_lmp.py#L401

Added line #L401 was not covered by tests

0 comments on commit 899aaba

Please sign in to comment.