Coverage for gpaw/test/xc/test_tb09.py: 100%
24 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
1"""Test Tran Blaha potential."""
2import warnings
4import pytest
5from ase.build import bulk
6from ase.dft.bandgap import bandgap
8from gpaw import GPAW, PW, Mixer
11@pytest.mark.old_gpaw_only
12@pytest.mark.libxc
13@pytest.mark.mgga
14def test_xc_tb09(in_tmp_dir):
15 def xc(name):
16 return {'name': name, 'stencil': 1}
18 k = 8
19 atoms = bulk('Si')
20 atoms.calc = GPAW(mode=PW(300),
21 mixer=Mixer(0.8, 10, 50.0),
22 kpts={'size': (k, k, k), 'gamma': True},
23 xc=xc('TB09'),
24 convergence={'bands': -3},
25 txt='si.txt')
26 with warnings.catch_warnings():
27 warnings.filterwarnings('ignore', module='gpaw.xc.libxc')
28 atoms.get_potential_energy()
29 gap, (sv, kv, nv), (sc, kc, nc) = bandgap(atoms.calc)
30 c = atoms.calc.hamiltonian.xc.c
31 print(gap, kv, kc)
32 print('c:', c)
33 assert abs(gap - 1.246) < 0.01
34 assert kv == 0 and kc == 12
35 assert abs(c - 1.135) < 0.01