-
Notifications
You must be signed in to change notification settings - Fork 2
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
0f5930e
commit ae291d8
Showing
3 changed files
with
42 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import numpy as np | ||
from mlip_arena.models import MLIPCalculator | ||
from mlip_arena.models.classicals.zbl import ZBL | ||
|
||
from ase.build import bulk | ||
|
||
|
||
def test_zbl(): | ||
calc = MLIPCalculator(model=ZBL(), cutoff=6.0) | ||
|
||
energies = [] | ||
forces = [] | ||
stresses = [] | ||
|
||
lattice_constants = [1, 3, 5, 7] | ||
|
||
for a in lattice_constants: | ||
atoms = bulk("Cu", "fcc", a=a) * (2, 2, 2) | ||
atoms.calc = calc | ||
|
||
energies.append(atoms.get_potential_energy()) | ||
forces.append(atoms.get_forces()) | ||
stresses.append(atoms.get_stress(voigt=False)) | ||
|
||
# test energy monotonicity | ||
assert all(np.diff(energies) <= 0) | ||
|
||
# test force vectors are all zeros due to symmetry | ||
for f in forces: | ||
assert np.allclose(f, 0) | ||
|
||
# test trace of stress is monotonically increasing (less negative) and zero beyond cutoff | ||
traces = [np.trace(s) for s in stresses] | ||
|
||
assert all(np.diff(traces) >= 0) | ||
assert np.allclose(stresses[-1], 0) |