-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To decouple Model from DPAtomicModel, allowing make_model on different atomic model. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b3d6c70
commit 25435c0
Showing
29 changed files
with
339 additions
and
215 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from deepmd.dpmodel.atomic_model.dp_atomic_model import ( | ||
DPAtomicModel, | ||
) | ||
from deepmd.dpmodel.model.base_model import ( | ||
BaseModel, | ||
) | ||
|
||
from .dp_model import ( | ||
DPModelCommon, | ||
) | ||
from .make_model import ( | ||
make_model, | ||
) | ||
|
||
DPEnergyModel_ = make_model(DPAtomicModel) | ||
|
||
|
||
@BaseModel.register("ener") | ||
class EnergyModel(DPModelCommon, DPEnergyModel_): | ||
def __init__( | ||
self, | ||
*args, | ||
**kwargs, | ||
): | ||
DPModelCommon.__init__(self) | ||
DPEnergyModel_.__init__(self, *args, **kwargs) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from typing import ( | ||
Dict, | ||
) | ||
|
||
import torch | ||
|
||
from deepmd.pt.model.task.dipole import ( | ||
DipoleFittingNet, | ||
) | ||
|
||
from .dp_atomic_model import ( | ||
DPAtomicModel, | ||
) | ||
|
||
|
||
class DPDipoleAtomicModel(DPAtomicModel): | ||
def __init__(self, descriptor, fitting, type_map, **kwargs): | ||
assert isinstance(fitting, DipoleFittingNet) | ||
super().__init__(descriptor, fitting, type_map, **kwargs) | ||
|
||
def apply_out_stat( | ||
self, | ||
ret: Dict[str, torch.Tensor], | ||
atype: torch.Tensor, | ||
): | ||
# dipole not applying bias | ||
return ret |
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,14 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from deepmd.pt.model.task.dos import ( | ||
DOSFittingNet, | ||
) | ||
|
||
from .dp_atomic_model import ( | ||
DPAtomicModel, | ||
) | ||
|
||
|
||
class DPDOSAtomicModel(DPAtomicModel): | ||
def __init__(self, descriptor, fitting, type_map, **kwargs): | ||
assert isinstance(fitting, DOSFittingNet) | ||
super().__init__(descriptor, fitting, type_map, **kwargs) |
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,20 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from deepmd.pt.model.task.ener import ( | ||
EnergyFittingNet, | ||
EnergyFittingNetDirect, | ||
InvarFitting, | ||
) | ||
|
||
from .dp_atomic_model import ( | ||
DPAtomicModel, | ||
) | ||
|
||
|
||
class DPEnergyAtomicModel(DPAtomicModel): | ||
def __init__(self, descriptor, fitting, type_map, **kwargs): | ||
assert ( | ||
isinstance(fitting, EnergyFittingNet) | ||
or isinstance(fitting, EnergyFittingNetDirect) | ||
or isinstance(fitting, InvarFitting) | ||
) | ||
super().__init__(descriptor, fitting, type_map, **kwargs) |
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,28 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from typing import ( | ||
Dict, | ||
) | ||
|
||
import torch | ||
|
||
from deepmd.pt.model.task.polarizability import ( | ||
PolarFittingNet, | ||
) | ||
|
||
from .dp_atomic_model import ( | ||
DPAtomicModel, | ||
) | ||
|
||
|
||
class DPPolarAtomicModel(DPAtomicModel): | ||
def __init__(self, descriptor, fitting, type_map, **kwargs): | ||
assert isinstance(fitting, PolarFittingNet) | ||
super().__init__(descriptor, fitting, type_map, **kwargs) | ||
|
||
def apply_out_stat( | ||
self, | ||
ret: Dict[str, torch.Tensor], | ||
atype: torch.Tensor, | ||
): | ||
# TODO: migrate bias | ||
return ret |
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.