Coverage for gpaw/test/vdw/test_quick_spin.py: 100%
15 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
1import pytest
2from ase import Atoms
3from gpaw import GPAW, FermiDirac
6@pytest.mark.libxc
7def test_vdw_quick_spin(in_tmp_dir):
8 L = 2.5
9 a = Atoms('H', cell=(L, L, L), pbc=True)
10 calc = GPAW(mode='fd',
11 xc='vdW-DF',
12 occupations=FermiDirac(width=0.001),
13 txt='H.vdW-DF.txt')
14 a.calc = calc
15 e1 = a.get_potential_energy()
17 calc = GPAW(mode='fd',
18 xc='vdW-DF',
19 txt='H.vdW-DF.spinpol.txt',
20 spinpol=True,
21 occupations=FermiDirac(width=0.001, fixmagmom=True))
22 a.calc = calc
23 e2 = a.get_potential_energy()
25 assert abs(calc.get_eigenvalues(spin=0)[0] -
26 calc.get_eigenvalues(spin=1)[0]) < 1e-10
28 assert abs(e1 - e2) < 2e-6, abs(e1 - e2)