File: test_relax.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (26 lines) | stat: -rw-r--r-- 827 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
from ase.cluster import Icosahedron
from pytest import mark


@mark.calculator_lite
def test_relax(KIM):
    """
    Test that a static relaxation that requires multiple neighbor list
    rebuilds can be carried out successfully.  This is verified by relaxing
    an icosahedral cluster of atoms and checking that the relaxed energy
    matches a known precomputed value for an example model.
    """
    from ase.optimize import BFGS

    energy_ref = -0.56  # eV

    # Create structure and calculator
    atoms = Icosahedron("Ar", latticeconstant=3.0, noshells=2)
    calc = KIM("ex_model_Ar_P_Morse_07C")
    atoms.calc = calc

    opt = BFGS(atoms, maxstep=0.04, alpha=70.0, logfile=None)
    opt.run(fmax=0.01)  # eV/angstrom

    assert np.isclose(atoms.get_potential_energy(), energy_ref, atol=0.05)