Coverage for gpaw/test/xc/test_qna_spinpol.py: 100%

14 statements  

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

1import pytest 

2from ase.atoms import Atoms 

3 

4from gpaw import GPAW, PW 

5 

6 

7@pytest.mark.old_gpaw_only 

8def test_xc_qna_spinpol(in_tmp_dir): 

9 QNA = {'alpha': 2.0, 

10 'name': 'QNA', 

11 'orbital_dependent': False, 

12 'parameters': {'H': (0.1485, 0.005)}, 

13 'setup_name': 'PBE', 

14 'type': 'qna-gga'} 

15 

16 atoms = Atoms('H', pbc=True, cell=[5, 5, 5]) 

17 atoms.set_initial_magnetic_moments([1]) 

18 

19 calc = GPAW(mode=PW(400), 

20 kpts=(1, 1, 1), 

21 xc=QNA, 

22 parallel={'domain': 1}, 

23 txt='qna_spinpol.txt') 

24 

25 atoms.calc = calc 

26 atoms.get_potential_energy() 

27 magmoms = atoms.get_magnetic_moments() 

28 

29 tol = 0.003 

30 assert 0.25374 == pytest.approx(magmoms[0], abs=tol)