Coverage for gpaw/test/lrtddft2/test_H2O-lcao.py: 100%
16 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
1import pytest
2import numpy as np
4from gpaw import GPAW
5from gpaw.lrtddft2 import LrTDDFT2
8@pytest.mark.lrtddft
9def test_lrtddft2_H2O_lcao(gpw_files, in_tmp_dir):
10 name = 'H2O-lcao'
11 # LrTDDFT2
12 calc = GPAW(gpw_files['h20_lr2_nbands8'], txt='%s-lr.out' % name)
13 lr = LrTDDFT2(name, calc, fxc='LDA')
14 lr.calculate()
15 results = lr.get_transitions()[0:2]
17 if 0:
18 np.set_printoptions(precision=10)
19 refstr = repr(results)
20 refstr = refstr.replace('array', 'np.array')
21 # Format a pep-compatible output
22 refstr = ' '.join(refstr.split())
23 refstr = refstr.replace('[ ', '[')
24 refstr = refstr.replace(', np', ',\n np')
25 refstr = refstr.replace(', ', ',\n ')
26 print('ref = %s' % refstr)
28 ref = (np.array([6.0832418565,
29 8.8741524165,
30 13.5935582927,
31 14.291759976,
32 15.9923574087,
33 16.9926770576,
34 17.6505087373,
35 17.6924715713,
36 24.092978682,
37 25.0027646421,
38 25.6208743025,
39 26.9649406073,
40 29.5294888977,
41 29.8439220428]),
42 np.array([3.6910848669e-02,
43 5.4510953134e-24,
44 3.0995301001e-01,
45 2.1335662795e-02,
46 7.8725024176e-22,
47 6.3875174151e-02,
48 1.0288169027e-01,
49 1.7216407337e-01,
50 2.8901383040e-02,
51 3.9354412451e-01,
52 2.1917641289e-02,
53 6.7746017219e-01,
54 7.9561718249e-02,
55 1.0625830362e-02]))
57 tol = 1e-3
58 for r0, r1 in zip(results, ref):
59 assert r0 == pytest.approx(r1, abs=tol)