Skip to content

Comments

Feat: add ZBL weighted DP model#3210

Merged
wanghan-iapcm merged 111 commits intodeepmodeling:develfrom
anyangml:devel
Feb 8, 2024
Merged

Feat: add ZBL weighted DP model#3210
wanghan-iapcm merged 111 commits intodeepmodeling:develfrom
anyangml:devel

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>
@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
@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