Coverage for gpaw/test/xc/test_revPBE.py: 100%
22 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
1from ase import Atoms
2from gpaw import GPAW, PoissonSolver
3import pytest
4from ase.units import Bohr, Hartree
7def test_xc_revPBE():
8 a = 7.5 * Bohr
9 n = 16
10 atoms = Atoms('He', [(0.0, 0.0, 0.0)], cell=(a, a, a), pbc=True)
11 params = dict(mode='fd',
12 gpts=(n, n, n),
13 nbands=1,
14 xc={'name': 'PBE', 'stencil': 1},
15 poissonsolver=PoissonSolver('fd'))
16 atoms.calc = GPAW(**params)
17 e1 = atoms.get_potential_energy()
18 e1a = atoms.calc.get_reference_energy()
19 params['xc'] = {'name': 'revPBE', 'stencil': 1}
20 atoms.calc = GPAW(**params)
21 e2 = atoms.get_potential_energy()
22 e2a = atoms.calc.get_reference_energy()
24 assert e1a == pytest.approx(-2.893 * Hartree, abs=8e-3)
25 assert e2a == pytest.approx(-2.908 * Hartree, abs=9e-3)
26 assert e1 == pytest.approx(e2, abs=4e-3)
28 energy_tolerance = 0.0005
29 assert e1 == pytest.approx(-0.0790449962, abs=energy_tolerance)
30 assert e2 == pytest.approx(-0.08147563, abs=energy_tolerance)