Coverage for gpaw/test/lcao/test_lcao_projections.py: 100%
18 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
1import numpy as np
2import pytest
3from ase.build import molecule
5from gpaw import GPAW
6from gpaw.lcao.projected_wannier import get_lcao_projections_HSP
7from gpaw.poisson import FDPoissonSolver
10@pytest.mark.legacy
11def test_lcao_lcao_projections():
12 atoms = molecule('C2H2')
13 atoms.center(vacuum=3.0)
14 calc = GPAW(mode='fd',
15 gpts=(32, 32, 48),
16 poissonsolver=FDPoissonSolver(),
17 eigensolver='rmm-diis')
18 atoms.calc = calc
19 atoms.get_potential_energy()
21 V_qnM, H_qMM, S_qMM, P_aqMi = get_lcao_projections_HSP(
22 calc, bfs=None, spin=0, projectionsonly=False)
24 # Test H and S
25 eig = sorted(np.linalg.eigvals(np.linalg.solve(S_qMM[0], H_qMM[0])).real)
26 eig_ref = np.array([-17.87913099255579, -13.24870583835115,
27 -11.431118704888123, -7.125564231198733,
28 -7.1255642311987195, 0.5929813570452659,
29 0.5929813570454503, 3.925217670277378,
30 7.451140780537926, 26.734705668744386])
31 print(eig)
32 assert np.allclose(eig, eig_ref)