Coverage for gpaw/test/hubbard/test_hubbard_U_string.py: 100%
18 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-12 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-12 00:18 +0000
1from gpaw.hubbard import parse_hubbard_string
2from ase.units import Hartree
5def test_hubbard_u_string():
6 # Format of string = type:l,U,scale;l,U,scale
7 # U has an internal unit conversion to atomic units
9 # Simple single correction
10 string = ':d,5,0'
11 setuptype, hubbard = parse_hubbard_string(string)
12 assert setuptype == 'paw'
13 assert hubbard._tuple() == ([2], [5.0 / Hartree], [False])
16def test_single_correction_without_scale():
17 string = ':d,5'
18 setuptype, hubbard = parse_hubbard_string(string)
19 assert setuptype == 'paw'
20 assert hubbard._tuple() == ([2], [5.0 / Hartree], [True])
23def test_multi_correction():
24 string = 'ae:s,3,0;p,2.5,1;f,0.5,0'
25 expected = ([0, 1, 3],
26 [3.0 / Hartree, 2.5 / Hartree, 0.5 / Hartree],
27 [False, True, False])
28 setuptype, hubbard = parse_hubbard_string(string)
29 assert setuptype == 'ae'
30 assert hubbard._tuple() == expected