Coverage for gpaw/test/response/test_gs_sym_off.py: 100%
23 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
1"""This script asserts that the chi's obtained from GS calculations using
2symmetries and GS calculations not using symmetries return the same results.
3"""
5import pytest
6import numpy as np
8from gpaw.response import ResponseGroundStateAdapter
9from gpaw.response.frequencies import FrequencyDescriptor
10from gpaw.response.chi0 import Chi0Calculator, get_omegamax
11from gpaw.test.gpwfile import response_band_cutoff
14@pytest.mark.response
15def test_symmetry_si2(gpw_files):
16 ground_states = [ResponseGroundStateAdapter.from_gpw_file(gpw_files[name])
17 for name in ['fancy_si_pw_nosym', 'fancy_si_pw']]
18 band_cutoff = response_band_cutoff['fancy_si_pw']
20 # Initialize nonlinear frequency grid
21 omegamax = get_omegamax(ground_states[0], nbands=band_cutoff)
22 omegamax_sym = get_omegamax(ground_states[1], nbands=band_cutoff)
23 assert omegamax_sym == pytest.approx(omegamax)
24 wd = FrequencyDescriptor.from_array_or_dict(
25 {'type': 'nonlinear', 'omegamax': omegamax})
27 data_s = []
28 for gs in ground_states:
29 chi0 = Chi0Calculator(gs, wd=wd, nbands=band_cutoff)
30 data = chi0.calculate([1 / 4, 0, 1 / 4])
31 data_s.append(data.chi0_WgG)
33 # With a non-Gamma q-point as input, we should therefore
34 # not have any data from the optical limit extensions
35 assert data.chi0_WxvG is None
36 assert data.chi0_Wvv is None
38 datadiff_WgG = np.abs(data_s[0] - data_s[1])
39 assert datadiff_WgG == pytest.approx(0, abs=1e-6)