-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
257961d
commit 66009ed
Showing
17 changed files
with
353 additions
and
374 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from graph_pes.core import GraphPESModel | ||
from graph_pes.data import AtomicGraph | ||
from graph_pes.nn import PerElementParameter | ||
from torch import Tensor | ||
|
||
|
||
class EnergyOffset(GraphPESModel): | ||
r""" | ||
A model that predicts energy offsets: | ||
.. math:: | ||
E(\mathcal{G}) = \sum_i \varepsilon_{Z_i} | ||
where :math:`\varepsilon_{Z_i}` is the energy offset for atomic species | ||
:math:`Z_i`. | ||
Parameters | ||
---------- | ||
fixed_values | ||
A dictionary of fixed energy offsets for each atomic species. | ||
trainable | ||
Whether the energy offsets are trainable parameters. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
values: dict[str, float] | None = None, | ||
trainable: bool = False, | ||
): | ||
super().__init__() | ||
|
||
if values is None and trainable is False: | ||
raise ValueError("Must provide values or set trainable to True") | ||
|
||
self.offsets = PerElementParameter.of_length( | ||
1, | ||
default_value=0.0, | ||
requires_grad=trainable, | ||
) | ||
|
||
def predict_local_energies(self, graph: AtomicGraph) -> Tensor: | ||
return self.shift[graph["atomic_numbers"]] |
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.