-
Notifications
You must be signed in to change notification settings - Fork 542
consistent energy model #3306
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
Merged
wanghan-iapcm
merged 8 commits into
deepmodeling:devel
from
njzjz:consistent-energy-model
Feb 21, 2024
Merged
consistent energy model #3306
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
30f1051
checkpoint
njzjz e8e4f99
atype must be sorted
njzjz 5f74ac1
fix errors
njzjz 9da94ef
fix dipole fitting
njzjz 47c4099
Merge branch 'devel' into consistent-energy-model
njzjz 79371fb
use deepmd.pt.utils.utils
njzjz ab080f7
rewrite the typing of to_numpy_array and to_torch_tensor
njzjz 83fd5b2
move get_model to dpmodel
njzjz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,41 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from deepmd.dpmodel.descriptor.se_e2_a import ( | ||
DescrptSeA, | ||
) | ||
from deepmd.dpmodel.fitting.ener_fitting import ( | ||
EnergyFittingNet, | ||
) | ||
from deepmd.dpmodel.model.dp_model import ( | ||
DPModel, | ||
) | ||
|
||
|
||
def get_model(data: dict) -> DPModel: | ||
"""Get a DPModel from a dictionary. | ||
|
||
Parameters | ||
---------- | ||
data : dict | ||
The data to construct the model. | ||
""" | ||
descriptor_type = data["descriptor"].pop("type") | ||
fitting_type = data["fitting_net"].pop("type") | ||
if descriptor_type == "se_e2_a": | ||
descriptor = DescrptSeA( | ||
**data["descriptor"], | ||
) | ||
else: | ||
raise ValueError(f"Unknown descriptor type {descriptor_type}") | ||
if fitting_type == "ener": | ||
fitting = EnergyFittingNet( | ||
ntypes=descriptor.get_ntypes(), | ||
dim_descrpt=descriptor.get_dim_out(), | ||
**data["fitting_net"], | ||
) | ||
else: | ||
raise ValueError(f"Unknown fitting type {fitting_type}") | ||
return DPModel( | ||
descriptor=descriptor, | ||
fitting=fitting, | ||
type_map=data["type_map"], | ||
) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Statement has no effect