Coverage for gpaw/test/sic/test_gmf_lcaosic.py: 76%
21 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
1import pytest
3from gpaw import GPAW
4import numpy as np
7@pytest.mark.old_gpaw_only
8@pytest.mark.sic
9def test_gmf_lcaosic(in_tmp_dir, gpw_files):
10 """
11 test Perdew-Zunger Self-Interaction
12 Correction in LCAO mode using DirectMin
13 :param in_tmp_dir:
14 :return:
15 """
16 calc = GPAW(gpw_files['h2o_gmf_lcaosic'])
17 H2O = calc.atoms
18 H2O.calc = calc
19 e = H2O.get_potential_energy()
20 f = H2O.get_forces()
22 f_num = np.array([[-8.01206297e+00, -1.51553367e+01, 3.60670227e-03],
23 [1.42287594e+01, -9.81724693e-01, -5.09333905e-04],
24 [-4.92299436e+00, 1.55306540e+01, 2.12438557e-03]])
26 numeric = False
27 if numeric:
28 from gpaw.test import calculate_numerical_forces
29 f_num = calculate_numerical_forces(H2O, 0.001)
30 print('Numerical forces')
31 print(f_num)
32 print(f - f_num, np.abs(f - f_num).max())
34 assert e == pytest.approx(-2.007241, abs=1.0e-3)
35 assert f == pytest.approx(f_num, abs=0.75)