-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add consistency test for ZBL between dp and pt (#4292)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced `DPZBLModel`, enhancing energy modeling capabilities. - Added `get_zbl_model` function for creating `DPZBLModel` from input data. - New `DPZBLLinearEnergyAtomicModel` class allows for complex interactions between atomic models. - **Bug Fixes** - Corrected typographical errors in multiple test classes to improve code clarity and consistency in method names. - Updated model type attributes for `DPZBLModel` and `LinearEnergyModel` to reflect accurate classifications. - **Tests** - Added comprehensive unit tests for energy models to ensure functionality across various backends. - Enhanced existing test classes with corrected method names for improved accuracy. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a468819
commit 5c32147
Showing
14 changed files
with
356 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from typing import ( | ||
Optional, | ||
) | ||
|
||
from deepmd.dpmodel.atomic_model.linear_atomic_model import ( | ||
DPZBLLinearEnergyAtomicModel, | ||
) | ||
from deepmd.dpmodel.model.base_model import ( | ||
BaseModel, | ||
) | ||
from deepmd.dpmodel.model.dp_model import ( | ||
DPModelCommon, | ||
) | ||
from deepmd.utils.data_system import ( | ||
DeepmdDataSystem, | ||
) | ||
|
||
from .make_model import ( | ||
make_model, | ||
) | ||
|
||
DPZBLModel_ = make_model(DPZBLLinearEnergyAtomicModel) | ||
|
||
|
||
@BaseModel.register("zbl") | ||
class DPZBLModel(DPZBLModel_): | ||
model_type = "zbl" | ||
|
||
def __init__( | ||
self, | ||
*args, | ||
**kwargs, | ||
): | ||
super().__init__(*args, **kwargs) | ||
|
||
@classmethod | ||
def update_sel( | ||
cls, | ||
train_data: DeepmdDataSystem, | ||
type_map: Optional[list[str]], | ||
local_jdata: dict, | ||
) -> tuple[dict, Optional[float]]: | ||
"""Update the selection and perform neighbor statistics. | ||
Parameters | ||
---------- | ||
train_data : DeepmdDataSystem | ||
data used to do neighbor statistics | ||
type_map : list[str], optional | ||
The name of each type of atoms | ||
local_jdata : dict | ||
The local data refer to the current class | ||
Returns | ||
------- | ||
dict | ||
The updated local data | ||
float | ||
The minimum distance between two atoms | ||
""" | ||
local_jdata_cpy = local_jdata.copy() | ||
local_jdata_cpy["dpmodel"], min_nbor_dist = DPModelCommon.update_sel( | ||
train_data, type_map, local_jdata["dpmodel"] | ||
) | ||
return local_jdata_cpy, min_nbor_dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.