Coverage for gpaw/test/test_initial_occs.py: 100%
20 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
1import pytest
2from gpaw.setup import create_setup
5@pytest.mark.parametrize('symbol, M, n',
6 [('Pd', 1, 6), # 4d -> 5s
7 ('Fe', 3, 5),
8 ('V', 3, 5),
9 ('Ti', 2, 5)])
10def test_initial_occs(symbol, M, n):
11 s = create_setup(symbol)
12 f_si = s.calculate_initial_occupation_numbers(magmom=M,
13 hund=False,
14 charge=0,
15 nspins=2)
16 print(f_si)
17 magmom = (f_si[0] - f_si[1]).sum()
18 assert abs(magmom - M) < 1e-10
19 N = ((f_si[0] - f_si[1]) != 0).sum()
20 assert n == N, 'Wrong # of values have changed'
23def test_ca():
24 """Our Ca PAW-potential only has completely filled partial waves
25 (3s, 3p and 4s). So, a magmom of 1 can't be accomodated. GPAW
26 should still work though! Same problem for Ne.
27 """
28 from ase.data import chemical_symbols
29 for sy in chemical_symbols:
30 try:
31 s = create_setup(sy)
32 except FileNotFoundError:
33 continue
34 f_si = s.calculate_initial_occupation_numbers(
35 magmom=1, hund=False, charge=0, nspins=2)
36 print(sy, f_si)