-
Notifications
You must be signed in to change notification settings - Fork 26
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 RunLmpHDF5 #267
Add RunLmpHDF5 #267
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
) | ||
from .run_lmp import ( | ||
RunLmp, | ||
RunLmpHDF5, | ||
) | ||
from .run_relax import ( | ||
RunRelax, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
Tuple, | ||
) | ||
|
||
import numpy as np | ||
from dargs import ( | ||
Argument, | ||
ArgumentEncoder, | ||
|
@@ -26,6 +27,7 @@ | |
Artifact, | ||
BigParameter, | ||
FatalError, | ||
HDF5Datasets, | ||
OPIOSign, | ||
TransientError, | ||
) | ||
|
@@ -200,7 +202,7 @@ | |
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} | ||
|
@@ -213,13 +215,17 @@ | |
|
||
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( | ||
|
@@ -243,6 +249,13 @@ | |
Argument( | ||
"model_frozen_head", str, optional=True, default=None, doc=doc_head | ||
), | ||
Argument( | ||
"use_hdf5", | ||
bool, | ||
optional=True, | ||
default=False, | ||
doc=doc_use_hdf5, | ||
), | ||
Comment on lines
+252
to
+258
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement logic for The |
||
] | ||
|
||
@staticmethod | ||
|
@@ -374,3 +387,15 @@ | |
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 | ||
|
||
def get_model_devi(self, model_devi_file): | ||
return np.loadtxt(model_devi_file) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Define
__all__
indpgen2/op/__init__.py
to include RunLmpHDF5The
__all__
variable is not defined indpgen2/op/__init__.py
. To makeRunLmpHDF5
part of the public API and resolve the unused import warning, consider adding an__all__
list that includesRunLmpHDF5
along with other public classes and functions.Example:
🔗 Analysis chain
Consider adding RunLmpHDF5 to all if it's part of the public API
The addition of
RunLmpHDF5
to the imports is good, as it makes the new functionality available to other parts of the package. However, the static analysis tool has flagged this import as unused within this file.If
RunLmpHDF5
is intended to be part of the public API of this package, consider adding it to the__all__
list (if one exists) to explicitly define what should be imported when usingfrom dpgen2.op import *
.To verify if
__all__
is defined in this file and if so, what it contains, you can run the following script:If
__all__
is not defined, consider adding it to explicitly control what's exported:🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 240
Script:
Length of output: 195
🧰 Tools
🪛 Ruff