File: test_potential_energies.py

package info (click to toggle)
python-ase 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,344 kB
  • sloc: python: 126,379; xml: 946; makefile: 111; javascript: 47
file content (23 lines) | stat: -rw-r--r-- 666 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from numpy.testing import assert_allclose
import ase.build
from ase.calculators.emt import EMT


def test_potential_energies():
    TOL = 1E-8

    atoms = ase.build.bulk("Ni", crystalstructure="fcc", cubic=1)
    atoms *= (2, 2, 2)
    atoms.calc = EMT()
    energies = atoms.get_potential_energies()
    energy = atoms.get_potential_energy()

    # energy sums should be identical
    assert abs(energies.sum() - energy) < TOL

    # in ideal FCC crystal per-atom energies should be identical
    assert_allclose(energies, energies[0], rtol=TOL)

    # rattle the system and check energy sums again
    atoms.rattle()
    assert abs(energies.sum() - energy) < TOL