Coverage for gpaw/test/generic/test_2Al.py: 100%
20 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
1from ase import Atom, Atoms
2from gpaw import GPAW
3import pytest
6def test_generic_2Al():
7 a = 4.05
8 d = a / 2**0.5
9 bulk = Atoms([Atom('Al', (0, 0, 0)),
10 Atom('Al', (0, 0, d))],
11 cell=(4 * d, 4 * d, 2 * d),
12 pbc=1)
13 n = 16
14 calc = GPAW(mode='fd',
15 gpts=(2 * n, 2 * n, 1 * n),
16 nbands=1 * 8,
17 kpts=(1, 1, 4),
18 convergence={'eigenstates': 2.3e-9})
19 bulk.calc = calc
20 e2 = bulk.get_potential_energy()
22 bulk = bulk.repeat((1, 1, 2))
23 calc = GPAW(mode='fd',
24 gpts=(2 * n, 2 * n, 2 * n),
25 nbands=16,
26 kpts=(1, 1, 2),
27 convergence={'eigenstates': 2.3e-9})
28 bulk.calc = calc
29 e4 = bulk.get_potential_energy()
31 # checks
32 energy_tolerance = 0.002
34 print(e2, e4)
35 assert e4 / 2 == pytest.approx(e2, abs=48e-6)
36 assert e2 == pytest.approx(-3.41595, abs=energy_tolerance)
37 assert e4 == pytest.approx(-6.83191, abs=energy_tolerance)