Coverage for gpaw/test/zfs/test_o2.py: 100%
19 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
1from types import SimpleNamespace
3import pytest
4import numpy as np
5from ase.units import Bohr as bohr
7from gpaw import GPAW
8from gpaw.utilities.ps2ae import PS2AE
9from gpaw.zero_field_splitting import WaveFunctions, zfs1, zfs
12def test_zfs_o2(gpw_files):
13 calc = GPAW(gpw_files['o2_pw'])
14 D1 = zfs(calc) * 1e6 # ueV
15 print(D1)
16 assert D1 == pytest.approx(np.diag([117, -59, -59]), abs=1)
18 # Poor man's PAW correction:
19 converter = PS2AE(calc)
20 psit_nR = np.array([converter.get_wave_function(n, ae=True) * bohr**1.5
21 for n in [5, 6]])
22 wf2 = WaveFunctions(psit_nR, {}, 0, calc.setups, converter.gd)
23 cc = SimpleNamespace(add=lambda a, b: None)
24 D2 = zfs1(wf2, wf2, cc) * 1e6 # uev
25 print(D2 - D1)
26 assert D2 - D1 == pytest.approx(np.diag([14, -7, -7]), abs=1)