Coverage for gpaw/test/elph/test_supercell.py: 100%
15 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"""Basic test of elph/supercell/
3"""
4import numpy as np
5import pytest
7from gpaw.elph import Supercell
8from gpaw.mpi import world
10SUPERCELL = (2, 1, 1)
12g00 = np.array([[[[-1.12259936e-06, 1.25832645e-02],
13 [1.25832645e-02, 4.04316008e-02]],
14 [[3.46964784e-02, 1.25839117e-02],
15 [1.37267189e-02, 4.76311583e-07]]],
16 [[[3.46964784e-02, 1.37267189e-02],
17 [1.25839117e-02, 4.76311583e-07]],
18 [[3.80642006e-07, -1.37265345e-02],
19 [-1.37265345e-02, -4.04323116e-02]]]])
22@pytest.mark.slow
23@pytest.mark.skipif(world.size > 2,
24 reason='world.size > 2')
25@pytest.mark.elph
26def test_supercell(module_tmp_path, supercell_cache):
27 # Generate supercell_cache
28 supercell_cache
30 # read supercell matrix
31 g_xsNNMM, basis_info = Supercell.load_supercell_matrix()
32 assert g_xsNNMM.shape == (6, 1, 2, 2, 2, 2)
33 print(g_xsNNMM[0, 0])
34 assert g_xsNNMM[0, 0] == pytest.approx(g00, rel=1e-2, abs=1e-4)