Coverage for gpaw/test/directopt/test_break_instability_lcao.py: 100%
20 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
3from gpaw import GPAW
4from gpaw.directmin.derivatives import Davidson
7@pytest.mark.old_gpaw_only
8@pytest.mark.do
9def test_break_instability_lcao(in_tmp_dir, gpw_files):
10 calc = GPAW(gpw_files['h2_break_ilcao'])
11 # XXX(rg): Remove hack after tchem-gl-13
12 calc.set_positions()
13 calc.wfs.eigensolver.initialize_dm_helper(calc.wfs,
14 calc.hamiltonian,
15 calc.density,
16 calc.log)
17 atoms = calc.atoms
18 atoms.calc = calc
19 e_symm = atoms.get_potential_energy()
20 assert e_symm == pytest.approx(-2.035632, abs=1.0e-3)
22 davidson = Davidson(calc.wfs.eigensolver, None, seed=42)
23 davidson.run(calc.wfs, calc.hamiltonian, calc.density)
25 # Break the instability by displacing along the eigenvector of the
26 # electronic Hessian corresponding to the negative eigenvalue
27 C_ref = [calc.wfs.kpt_u[x].C_nM.copy()
28 for x in range(len(calc.wfs.kpt_u))]
29 davidson.break_instability(calc.wfs, n_dim=[10, 10],
30 c_ref=C_ref, number=1)
32 calc.calculate(properties=['energy'], system_changes=['positions'])
33 e_bsymm = atoms.get_potential_energy()
34 assert e_bsymm == pytest.approx(-2.418488, abs=1.0e-3)