Coverage for gpaw/test/lcao/test_gllb_si.py: 100%

20 statements  

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

1import pytest 

2from ase.build import bulk 

3from gpaw import GPAW, LCAO 

4 

5# This test calculates a GLLB quasiparticle gap with LCAO and verifies 

6# that it does not change from a reference value. Note that the 

7# calculation, physically speaking, is garbage. 

8 

9 

10@pytest.fixture 

11def calc(): 

12 return GPAW(mode=LCAO(interpolation=2), 

13 h=0.3, 

14 basis='sz(dzp)', 

15 xc='GLLBSC', 

16 kpts={'size': (2, 2, 2), 'gamma': True}, 

17 convergence={'maximum iterations': 1}, 

18 txt='si.txt') 

19 

20 

21@pytest.mark.gllb 

22@pytest.mark.libxc 

23def test_lcao_gllb_si(in_tmp_dir, calc): 

24 si = bulk('Si', 'diamond', a=5.421) 

25 si.calc = calc 

26 si.get_potential_energy() 

27 

28 homo, lumo = calc.get_homo_lumo() 

29 response = calc.hamiltonian.xc.response 

30 dxc_pot = response.calculate_discontinuity_potential(homo, lumo) 

31 EKs, Dxc = response.calculate_discontinuity(dxc_pot) 

32 refgap = 3.02333 

33 gap = EKs + Dxc 

34 print('GAP', gap) 

35 assert gap == pytest.approx(refgap, abs=1e-4)