Coverage for gpaw/test/spinspiral/test_h_chain.py: 100%
16 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 gpaw.new.ase_interface import GPAW
5def test_afm_h_chain(in_tmp_dir, gpw_files):
6 """Compare 2*H AFM cell with 1*H q=1/2 spin-spiral cell."""
7 h_calc = GPAW(gpw_files['h_chain'])
8 h = h_calc.atoms
9 h.calc = h_calc
10 e1 = h.get_potential_energy()
11 h1, l1 = h.calc.get_homo_lumo()
12 # print(e1, h.get_magnetic_moment())
13 # print(a1.get_potential_energy(), a1.calc.dft.magmoms())
15 h2_calc = GPAW(gpw_files['h2_chain'])
16 h2 = h2_calc.atoms
17 h2.calc = h2_calc
18 e2 = h2.get_potential_energy()
19 h2, l2 = h2.calc.get_homo_lumo()
21 assert 2 * e1 == pytest.approx(e2, abs=0.002)
22 assert h1 == pytest.approx(h2, abs=0.001)
23 assert l1 == pytest.approx(l2, abs=0.001)