Coverage for gpaw/test/response/test_gw_spinpol.py: 94%
16 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
1"""Test to make sure spin-polarized GW calculations don't break."""
3# General modules
4import pytest
5from gpaw.response.g0w0 import G0W0
6from gpaw.mpi import world
9@pytest.mark.response
10def test_gw_spinpol(in_tmp_dir, gpw_files):
11 if world.size > 1:
12 nblocks = 2
13 else:
14 nblocks = 1
16 gw = G0W0(gpw_files['h2_bcc_afm'],
17 nbands=4, # keep consistent with gpw nbands
18 ecut=100,
19 kpts=[(0, 0, 0)],
20 nblocks=nblocks,
21 relbands=(-1, 1))
22 result = gw.calculate()
24 # Make sure gaps in both spin-channels are the same and don't change.
25 # test values do not necessarily reflect those in literature. They simply
26 # ensure the value does not change.
27 lda_sn = result['eps'][:, 0]
28 lda_gap_s = lda_sn[:, 1] - lda_sn[:, 0]
29 assert abs(lda_gap_s - 10.5095).max() < 0.01
30 qp_sn = result['qp'][:, 0]
31 qp_gap_s = qp_sn[:, 1] - qp_sn[:, 0]
32 assert abs(qp_gap_s - 9.8156).max() < 0.01