Coverage for gpaw/test/directopt/test_orthonormalizations_lcao.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-09 00:21 +0000

1import pytest 

2 

3import numpy as np 

4 

5from gpaw import GPAW 

6 

7 

8@pytest.mark.do 

9def test_orthonormalizations_lcao(in_tmp_dir, gpw_files): 

10 """ 

11 Test Loewdin and Gram-Schmidt orthonormalization 

12 of orbitals in LCAO 

13 :param in_tmp_dir: 

14 :return: 

15 """ 

16 calc = GPAW(gpw_files['h3_orthonorm_lcao']) 

17 atoms = calc.atoms 

18 atoms.calc = calc 

19 

20 for type in ['loewdin', 'gramschmidt']: 

21 atoms.positions[0] += 0.1 

22 calc.initialize_positions(atoms) 

23 for kpt in calc.wfs.kpt_u: 

24 calc.wfs.orthonormalize(kpt, type=type) 

25 overlaps = np.dot(kpt.C_nM.conj(), 

26 np.dot(kpt.S_MM, kpt.C_nM.T)) 

27 assert overlaps == pytest.approx(np.identity(3), abs=1e-10)