Coverage for gpaw/test/gllb/test_atomic.py: 100%

27 statements  

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

1import pytest 

2from gpaw.atom.all_electron import AllElectron 

3 

4 

5@pytest.mark.gllb 

6@pytest.mark.libxc 

7def test_gllb_atomic(): 

8 data = [] 

9 

10 def out(a, b, c, d, e, f): 

11 data.append((a, b, c, d, e, f)) 

12 

13 ETotal = {'Be': -14.572 + 0.012, 

14 'Ne': -128.548 - 0.029, 

15 'Mg': -199.612 - 0.005} 

16 EX = {'Be': -2.666 - 0.010, 

17 'Ne': -12.107 - 0.122, 

18 'Mg': -15.992 - 0.092} 

19 EHOMO = {'Be': -0.309 + 0.008, 

20 'Ne': -0.851 + 0.098, 

21 'Mg': -0.253 + 0.006} 

22 # eignum = {'Be': 0, 'Ne': 3, 'Mg': 0} 

23 

24 for xcname in ['GLLB', 'GLLBSC']: 

25 atoms = ['Be', 'Ne', 'Mg'] 

26 for atom in atoms: 

27 # Test AllElectron GLLB 

28 GLLB = AllElectron(atom, xcname=xcname, scalarrel=False, 

29 gpernode=600) 

30 GLLB.run() 

31 

32 out('Total energy', xcname + '1D', atom, ETotal[atom], GLLB.ETotal, 

33 'Ha') 

34 out('Exchange energy', xcname + '1D', atom, EX[atom], GLLB.Exc, 

35 'Ha') 

36 out('HOMO Eigenvalue', xcname + '1D', atom, EHOMO[atom], 

37 GLLB.e_j[-1], 

38 'Ha') 

39 if xcname == 'GLLB': 

40 assert GLLB.ETotal == pytest.approx(ETotal[atom], abs=1e-2) 

41 assert GLLB.Exc == pytest.approx(EX[atom], abs=1e-2) 

42 assert GLLB.e_j[-1] == pytest.approx(EHOMO[atom], abs=1e-2) 

43 

44 print(' Quanity Method Symbol Ref[1]' 

45 ' GPAW Unit ') 

46 for a, b, c, d, e, f in data: 

47 print('%20s %10s %10s %10.3f %10.3f %5s' % 

48 (a, b, c, d, e, f)) 

49 

50 print("""References: 

51 [1] Self-consistent approximation to the Kohn-Sham exchange potential 

52 Gritsenko, Oleg; Leeuwen, Robert van; Lenthe, Erik van; Baerends, Evert Jan 

53 Phys. Rev. A Vol. 51 p. 1944""")