Coverage for gpaw/test/lcao/test_h2o.py: 100%
18 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-09 00:21 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-09 00:21 +0000
1import pytest
2from ase import Atoms
4from gpaw import GPAW, LCAO
5from gpaw.poisson import FDPoissonSolver
8def test_lcao_h2o():
9 a = 6.0
10 b = a / 2
11 mol = Atoms('OHH',
12 [(b, b, 0.1219 + b),
13 (b, 0.7633 + b, -0.4876 + b),
14 (b, -0.7633 + b, -0.4876 + b)],
15 pbc=False, cell=[a, a, a])
16 calc = GPAW(gpts=(32, 32, 32),
17 nbands=4,
18 mode='lcao',
19 poissonsolver=FDPoissonSolver())
20 mol.calc = calc
21 e = mol.get_potential_energy()
22 niter = calc.get_number_of_iterations()
24 assert e == pytest.approx(-10.271, abs=2e-3)
25 assert niter == pytest.approx(8, abs=1)
27 # Check that complex wave functions are allowed with
28 # gamma point calculations
29 calc = GPAW(gpts=(32, 32, 32),
30 nbands=4,
31 mode=LCAO(force_complex_dtype=True),
32 poissonsolver=FDPoissonSolver())
33 mol.calc = calc
34 ec = mol.get_potential_energy()
35 assert e == pytest.approx(ec, abs=1e-5)