Coverage for gpaw/test/sic/test_nscfsic.py: 100%
25 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
1import numpy as np
2import pytest
3from ase import Atoms
5from gpaw import GPAW
6from gpaw.utilities.sic import NSCFSIC
9@pytest.mark.old_gpaw_only
10@pytest.mark.sic
11@pytest.mark.serial
12def test_sic_nscfsic(in_tmp_dir):
13 atoms = ['He', 'Be'] # ,'Ne'] # Ne deviates already 2.5 eV
14 EE = []
15 EREF = [-79.4, -399.8, -3517.6]
16 rng = np.random.default_rng(42)
18 for a in atoms:
19 s = Atoms(a)
20 s.center(vacuum=4.0)
21 calc = GPAW(mode='fd', h=0.15, txt=a + '.txt')
22 s.calc = calc
23 s.get_potential_energy()
24 EE.append(NSCFSIC(calc, rng=rng).calculate())
26 print("Difference to table VI of Phys. Rev. B 23, 5048 in eV")
27 # https://journals.aps.org/prb/abstract/10.1103/PhysRevB.23.5048
28 print("%10s%10s%10s%10s" % ("atom", "ref.", "gpaw", "diff"))
29 for a, er, e in zip(atoms, EREF, EE):
30 print("%10s%10.2f%10.2f%10.2f" % (a, er, e, er - e))
31 assert er == pytest.approx(e, abs=0.1)
32 # Arbitrary 0.1 eV tolerance for non-self consistent SIC
33 # Note that Ne already deviates 2.5 eV