-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
7 changed files
with
75 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
::: beignet.lennard_jones_potential | ||
::: beignet.morse_potential |
Empty file.
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,46 @@ | ||
import torch | ||
from torch import Tensor | ||
|
||
|
||
def morse_potential( | ||
input: Tensor, | ||
sigma: Tensor | None = 1.0, | ||
epsilon: Tensor | None = 5.0, | ||
alpha: Tensor | None = 5.0, | ||
**_, | ||
) -> Tensor: | ||
""" | ||
Morse interaction between particles with a minimum at `sigma`. | ||
Parameters | ||
---------- | ||
input : Tensor, shape=[n, m] | ||
Pairwise distances between particles. | ||
sigma : Tensor, optional | ||
Distance between particles where the energy has a minimum. Should | ||
either be a floating-point scalar or a Tensor of shape `[n, m]`. | ||
epsilon : Tensor, optional | ||
Interaction energy scale. Should either be a floating-point scalar or | ||
a Tensor of shape `[n, m]`. | ||
alpha : Tensor, optional | ||
Range parameter. Should either be a floating-point scalar or a Tensor | ||
of shape `[n, m]`. | ||
Returns | ||
------- | ||
output : Tensor, shape=[n, m] | ||
Energies. | ||
""" | ||
if sigma is None: | ||
sigma = torch.tensor(1.0, dtype=input.dtype) | ||
|
||
if epsilon is None: | ||
epsilon = torch.tensor(5.0, dtype=input.dtype) | ||
|
||
if alpha is None: | ||
alpha = torch.tensor(5.0, dtype=input.dtype) | ||
|
||
return epsilon * (1.0 - torch.exp(-alpha * (input - sigma))) ** 2.0 - epsilon |