Coverage for gpaw/test/wannier/test_h2.py: 100%
22 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-09 00:21 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-09 00:21 +0000
1import pytest
2from gpaw import GPAW
3from gpaw.wannier import calculate_overlaps
6@pytest.mark.wannier
7@pytest.mark.serial
8@pytest.mark.parametrize('mode', ['pw', 'fd', 'lcao'])
9def test_wan_h2(gpw_files, mode, in_tmp_dir):
10 calc = GPAW(gpw_files[f'h2_{mode}'])
11 overlaps = calculate_overlaps(calc, n1=0, n2=1, nwannier=1,
12 projections={0: 's'})
13 wan = overlaps.localize_er(verbose=True)
14 x = calc.atoms.positions[:, 0].mean()
15 assert wan.centers[0, 0] == pytest.approx(x, abs=1e-7)
18@pytest.mark.wannier
19@pytest.mark.serial
20@pytest.mark.parametrize('mode', ['pw', 'fd', 'lcao'])
21def test_wan90_h2(gpw_files, mode, in_tmp_dir, wannier90):
22 calc = GPAW(gpw_files[f'h2_{mode}'])
23 overlaps = calculate_overlaps(calc, n1=0, n2=1, nwannier=1,
24 projections={0: 's'})
25 wan = overlaps.localize_w90()
26 x90 = wan.centers[0, 0] % calc.atoms.cell[0, 0]
27 x = calc.atoms.positions[:, 0].mean()
28 assert x90 == pytest.approx(x, abs=1e-7)