Coverage for gpaw/test/corehole/test_h2o_recursion.py: 100%
25 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
1from math import cos, pi, sin
3import pytest
4from ase import Atom, Atoms
6from gpaw import GPAW, Davidson, Mixer, PoissonSolver
7from gpaw.test import gen
10@pytest.mark.old_gpaw_only
11def test_corehole_h2o_recursion(in_tmp_dir):
12 # Generate setup for oxygen with half a core-hole:
13 s = gen('O', name='hch1s', corehole=(1, 0, 0.5))
15 a = 5.0
16 d = 0.9575
17 t = pi / 180 * 104.51
18 H2O = Atoms([Atom('O', (0, 0, 0)),
19 Atom('H', (d, 0, 0)),
20 Atom('H', (d * cos(t), d * sin(t), 0))],
21 cell=(a, a, a), pbc=False)
22 H2O.center()
23 calc = GPAW(mode='fd', nbands=10, h=0.2, setups={'O': s},
24 eigensolver=Davidson(4),
25 mixer=Mixer(0.5),
26 xc='oldLDA',
27 poissonsolver=PoissonSolver(use_charge_center=True))
28 H2O.calc = calc
29 e = H2O.get_potential_energy()
30 niter = calc.get_number_of_iterations()
32 from gpaw.xas import RecursionMethod
34 if 1:
35 r = RecursionMethod(calc)
36 r.run(400)
37 r.write('h2o.pckl')
38 else:
39 r = RecursionMethod(filename='h2o.pckl')
41 print(e, niter)
42 energy_tolerance = 0.002
43 assert e == pytest.approx(-17.980, abs=energy_tolerance)