Coverage for gpaw/test/ps2ae/test_ae_k.py: 70%
20 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 ase.units import Bohr
4from gpaw.calculator import GPAW as GPAW1
5from gpaw.mpi import size
6from gpaw.new.ase_interface import GPAW as GPAW2
7from gpaw.utilities.ps2ae import PS2AE
10@pytest.mark.parametrize('name, tol',
11 [('bcc_li_pw', 3e-5),
12 ('bcc_li_fd', 4e-4)])
13def test_ae_k(gpw_files, name, tol, gpaw_new):
14 """Test normalization of non gamma-point wave functions."""
16 if gpaw_new:
17 # New API:
18 if size > 1:
19 return
20 calc = GPAW2(gpw_files[name])
21 ae = calc.dft.ibzwfs.get_all_electron_wave_function(
22 0, kpt=1, grid_spacing=0.1)
23 assert ae.norm2() == pytest.approx(1.0, abs=tol)
24 return
26 # Old API:
27 calc = GPAW1(gpw_files[name])
28 converter = PS2AE(calc)
29 ae = converter.get_wave_function(n=0, k=1, ae=True) * Bohr**1.5
30 norm = converter.gd.integrate((ae * ae.conj()).real)
31 assert norm == pytest.approx(1.0, abs=tol)