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

Feat: add ZBL weighted DP model #3210

Merged
merged 111 commits into from
Feb 8, 2024
Merged

Conversation

anyangml
Copy link
Collaborator

@anyangml anyangml commented Feb 1, 2024

This PR is to implement general linear combination of several DPAtomicModels with user defined weights, as well as a special case ZBLModel with weights calculated based on this paper: Appl. Phys. Lett. 114, 244101 (2019); doi: 10.1063/1.5098061

Anyang Peng and others added 30 commits January 28, 2024 15:17
@anyangml anyangml requested a review from njzjz February 7, 2024 01:28
…3240)

solve some virial shape issue: should be [9] rather than [3,3]

---------

Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>
deepmd/dpmodel/model/linear_atomic_model.py Show resolved Hide resolved
deepmd/dpmodel/model/linear_atomic_model.py Outdated Show resolved Hide resolved
deepmd/dpmodel/model/linear_atomic_model.py Outdated Show resolved Hide resolved
deepmd/dpmodel/model/linear_atomic_model.py Show resolved Hide resolved
deepmd/dpmodel/model/linear_atomic_model.py Outdated Show resolved Hide resolved
deepmd/dpmodel/model/linear_atomic_model.py Outdated Show resolved Hide resolved
deepmd/dpmodel/model/linear_atomic_model.py Outdated Show resolved Hide resolved
deepmd/dpmodel/model/linear_atomic_model.py Outdated Show resolved Hide resolved
deepmd/pt/model/model/linear_atomic_model.py Show resolved Hide resolved
deepmd/pt/model/model/linear_atomic_model.py Show resolved Hide resolved
@njzjz
Copy link
Member

njzjz commented Feb 7, 2024

I haven't carefully checked - but could you first add a test for JIT?

model = torch.jit.script(inference.Tester("./model.pt", numb_test=1).model)

Have jit passed?

@anyangml
Copy link
Collaborator Author

anyangml commented Feb 8, 2024

@njzjz Jit passed, check the UTs in this file source/tests/pt/model/test_linear_atomic_model.py, I believe all the data are kept when you jit a deserialized model. Please double check this code block

def __init__(
self, tab_file: str, rcut: float, sel: Union[int, List[int]], **kwargs
):
super().__init__()
self.tab_file = tab_file
self.rcut = rcut
self.tab = self._set_pairtab(tab_file, rcut)
# handle deserialization with no input file
if self.tab_file is not None:
(
tab_info,
tab_data,
) = self.tab.get() # this returns -> Tuple[np.array, np.array]
self.tab_info = torch.from_numpy(tab_info)
self.tab_data = torch.from_numpy(tab_data)
else:
self.tab_info = None
self.tab_data = None
# self.model_type = "ener"
# self.model_version = MODEL_VERSION ## this shoud be in the parent class
if isinstance(sel, int):
self.sel = sel
elif isinstance(sel, list):
self.sel = sum(sel)
else:
raise TypeError("sel must be int or list[int]")
@torch.jit.ignore
def _set_pairtab(self, tab_file: str, rcut: float) -> PairTab:
return PairTab(tab_file, rcut)

@wanghan-iapcm wanghan-iapcm merged commit b7f1239 into deepmodeling:devel Feb 8, 2024
46 checks passed
@njzjz njzjz mentioned this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants