Coverage for gpaw/test/vdw/test_libvdwxc_mbeef.py: 100%
19 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
1import pytest
2from gpaw.utilities import compiled_with_libvdwxc
4from ase.build import bulk
6from gpaw import GPAW, Davidson, Mixer, PW
7from gpaw.xc.libvdwxc import vdw_mbeef
9from gpaw.test import gen
11pytestmark = pytest.mark.skipif(not compiled_with_libvdwxc(),
12 reason='not compiled_with_libvdwxc()')
15@pytest.mark.old_gpaw_only
16@pytest.mark.mgga
17def test_vdw_libvdwxc_mbeef():
18 setup = gen('Si', xcname='PBEsol')
20 system = bulk('Si')
21 calc = GPAW(mode=PW(200), xc=vdw_mbeef(),
22 kpts=(2, 2, 2),
23 nbands=4,
24 convergence=dict(density=1e-6),
25 mixer=Mixer(1.0),
26 eigensolver=Davidson(4),
27 setups={'Si': setup})
28 system.calc = calc
29 e = system.get_potential_energy()
30 ref = -60.53662105617721
31 err = abs(e - ref)
32 print('e=%r ref=%r err=%r' % (e, ref, err))
33 # It would be reasonable to put 1e-6 as tolerance,
34 # but the value changes by 4e-4 depending on libxc version.
35 # See https://gitlab.com/gpaw/gpaw/issues/161 .
36 assert err < 1e-3, err