Coverage for gpaw/test/dscf/test_dscf_lcao.py: 100%
19 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-12 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-12 00:18 +0000
1import pytest
2from ase.build import molecule
3from gpaw import GPAW
4import gpaw.dscf as dscf
6# Ground state calculation
9@pytest.mark.dscf
10def test_dscf_dscf_lcao():
11 calc = GPAW(mode='lcao',
12 basis='dzp',
13 nbands=8,
14 h=0.2,
15 xc='PBE',
16 spinpol=True,
17 convergence={'energy': 100,
18 'density': 1e-3,
19 'bands': -1})
21 CO = molecule('CO')
22 CO.center(vacuum=3)
23 CO.calc = calc
25 E_gs = CO.get_potential_energy()
27 # Excited state calculation
29 calc_es = GPAW(mode='lcao',
30 basis='dzp',
31 nbands=8,
32 h=0.2,
33 symmetry='off',
34 xc='PBE',
35 spinpol=True,
36 convergence={'energy': 100,
37 'density': 1e-3,
38 'bands': -1})
40 CO.calc = calc_es
41 lumo = dscf.MolecularOrbital(calc,
42 weights={0: [0, 0, 0, 1], 1: [0, 0, 0, -1]})
43 dscf.dscf_calculation(calc_es, [[1.0, lumo, 1]], CO)
45 E_es = CO.get_potential_energy()
46 dE = E_es - E_gs
47 print(dE)
48 assert dE == pytest.approx(5.7595110076, abs=0.011)