From 443c51f90c819e704b438fd50f7777481a80ceb4 Mon Sep 17 00:00:00 2001 From: Nick Papior Date: Thu, 14 Nov 2024 13:57:43 +0100 Subject: [PATCH] added tests for checking eigenvalues between siesta and sisl Signed-off-by: Nick Papior --- files | 2 +- src/sisl/io/siesta/tests/test_hsx.py | 60 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/files b/files index d87a1944c6..034095f2e4 160000 --- a/files +++ b/files @@ -1 +1 @@ -Subproject commit d87a1944c6a3ee7bad6afc652545ea8687b45338 +Subproject commit 034095f2e4ac4512ea9d0940496862cd6bfb70c5 diff --git a/src/sisl/io/siesta/tests/test_hsx.py b/src/sisl/io/siesta/tests/test_hsx.py index 27116896c5..ff059f54ea 100644 --- a/src/sisl/io/siesta/tests/test_hsx.py +++ b/src/sisl/io/siesta/tests/test_hsx.py @@ -19,6 +19,25 @@ def si_pdos_kgrid_geom(with_orbs=True): return sisl.geom.diamond(5.43, sisl.Atom("Si")) +@pytest.mark.parametrize("order", ["HSX", "TSHS"]) +def test_si_pdos_kgrid_H_eig(sisl_files, sisl_tmp, order): + fdf = sisl.get_sile(sisl_files("siesta", "Si_pdos_k", "Si_pdos.fdf")) + H = fdf.read_hamiltonian(order=order) + + eigs = sisl.get_sile(sisl_files("siesta", "Si_pdos_k", "Si_pdos.EIG")).read_data() + bz = sisl.get_sile( + sisl_files("siesta", "Si_pdos_k", "Si_pdos.KP") + ).read_brillouinzone(H.geometry) + + # Now see if we get the same data... + for ispin in range(eigs.shape[0]): + for i, (eig, k) in enumerate(zip(eigs[ispin], bz)): + if i > 10: + break + Heig = H.eigh(k, spin=ispin) + assert np.allclose(eig, Heig) + + def test_si_pdos_kgrid_hsx_H(sisl_files, sisl_tmp): si = sisl.get_sile(sisl_files("siesta", "Si_pdos_k", "Si_pdos.HSX")) si.read_hamiltonian(geometry=si_pdos_kgrid_geom()) @@ -135,3 +154,44 @@ def test_si_pdos_kgrid_hsx_1_same_tshs(sisl_files, sisl_tmp): assert np.allclose(gx.lattice.cell, gt.lattice.cell) assert np.allclose(gx.xyz, gt.xyz) assert np.allclose(gx.nsc, gt.nsc) + + +@pytest.mark.parametrize("order", ["HSX", "TSHS"]) +def test_srti03_H_eig(sisl_files, sisl_tmp, order): + fdf = sisl.get_sile(sisl_files("siesta", "SrTiO3", "non-collinear", "SrTiO3.fdf")) + H = fdf.read_hamiltonian(order=order) + + eigs = sisl.get_sile( + sisl_files("siesta", "SrTiO3", "non-collinear", "SrTiO3.EIG") + ).read_data() + bz = sisl.get_sile( + sisl_files("siesta", "SrTiO3", "non-collinear", "SrTiO3.KP") + ).read_brillouinzone(H.geometry) + + # Now see if we get the same data... + for i, (eig, k) in enumerate(zip(eigs[0], bz)): + if i > 10: + break + Heig = H.eigh(k) + assert np.allclose(eig, Heig) + + +@pytest.mark.parametrize("order", ["HSX"]) +def test_bi_hexagonal_H_eig(sisl_files, sisl_tmp, order): + N = 20 + fdf = sisl.get_sile(sisl_files("siesta", "Bi_hexagonal", "Bi_hexagonal.fdf")) + H = fdf.read_hamiltonian(order=order) + + eigs = sisl.get_sile( + sisl_files("siesta", "Bi_hexagonal", "Bi_hexagonal.EIG") + ).read_data() + bz = sisl.get_sile( + sisl_files("siesta", "Bi_hexagonal", "Bi_hexagonal.KP") + ).read_brillouinzone(H.geometry) + + # Now see if we get the same data... + for i, (eig, k) in enumerate(zip(eigs[0], bz)): + if i > 10: + break + Heig = H.eigh(k) + assert np.allclose(eig, Heig)