def test_real_space_H(setup, k_axes, semi_axis, trs, bz, unfold): if k_axes == semi_axis: return RSE = RealSpaceSE(setup.H, semi_axis, k_axes, (unfold, unfold, 1), trs=trs, dk=100, bz=bz) RSE.green(0.1) RSE.self_energy(0.1)
def test_real_space_H(setup, k_axis, semi_axis, trs, bz, unfold): if k_axis == semi_axis: return RSE = RealSpaceSE(setup.H, (unfold, unfold, 1)) RSE.update_option(semi_axis=semi_axis, k_axis=k_axis, dk=100, trs=trs, bz=bz) # Initialize and print with warnings.catch_warnings(): warnings.simplefilter('ignore') RSE.initialize() RSE.green(0.1) RSE.self_energy(0.1)
def test_real_space_HS_SE_unfold(setup): # check that calculating the real-space Green function is equivalent for two equivalent systems RSE = RealSpaceSE(setup.HS, 0, 1, (2, 2, 1), dk=100) RSE_big = RealSpaceSE(setup.HS.tile(2, 0).tile(2, 1), semi_axis=0, k_axes=1, dk=100) for E in [0.1, 1.5]: G = RSE.green(E) G_big = RSE_big.green(E) assert np.allclose(G, G_big) SE = RSE.self_energy(E) SE_big = RSE_big.self_energy(E) assert np.allclose(SE, SE_big)
def test_real_space_H_dtype(setup): RSE = RealSpaceSE(setup.H, 0, 1, (2, 2, 1), dk=100) g64 = RSE.green(0.1, dtype=np.complex64) g128 = RSE.green(0.1, dtype=np.complex128) assert g64.dtype == np.complex64 assert g128.dtype == np.complex128 assert np.allclose(g64, g128, atol=1.e-4) s64 = RSE.self_energy(0.1, dtype=np.complex64) s128 = RSE.self_energy(0.1, dtype=np.complex128) assert s64.dtype == np.complex64 assert s128.dtype == np.complex128 assert np.allclose(s64, s128, atol=1e-2) RSE.real_space_coupling() RSE.clear()
def test_real_space_H_dtype(setup): RSE = RealSpaceSE(setup.H, (2, 2, 1)) RSE.update_option(semi_axis=0, k_axis=1, dk=100) with warnings.catch_warnings(): warnings.simplefilter('ignore') RSE.initialize() g64 = RSE.green(0.1, dtype=np.complex64) g128 = RSE.green(0.1, dtype=np.complex128) assert g64.dtype == np.complex64 assert g128.dtype == np.complex128 assert np.allclose(g64, g128, atol=1.e-4) s64 = RSE.self_energy(0.1, dtype=np.complex64) s128 = RSE.self_energy(0.1, dtype=np.complex128) assert s64.dtype == np.complex64 assert s128.dtype == np.complex128 assert np.allclose(s64, s128, atol=1e-2)
def test_real_space_H_3d(): sc = SuperCell(1., nsc=[3] * 3) H = Atom(Z=1, R=[1.001]) geom = Geometry([0] * 3, atoms=H, sc=sc) H = Hamiltonian(geom) H.construct(([0.001, 1.01], (0, -1))) RSE = RealSpaceSE(H, 0, [1, 2], (3, 4, 2)) RSE.set_options(dk=100, trs=True) RSE.initialize() nk = np.ones(3, np.int32) nk[[1, 2]] = 23 bz = BrillouinZone(H, nk) RSE.set_options(bz=bz) RSE.green(0.1) # Since there is only 2 repetitions along one direction we will have the full matrix # coupled! assert np.allclose(RSE.self_energy(0.1), RSE.self_energy(0.1, coupling=True)) assert np.allclose(RSE.self_energy(0.1, bulk=True), RSE.self_energy(0.1, bulk=True, coupling=True))
def test_real_space_HS_SE_unfold_with_k(): # check that calculating the real-space Green function is equivalent for two equivalent systems sq = Geometry([0] * 3, Atom(1, 1.01), [1]) sq.set_nsc([3] * 3) H = Hamiltonian(sq) H.construct([(0.1, 1.1), (4, -1)]) RSE = RealSpaceSE(H, 0, 1, (3, 4, 1), dk=100, trs=False) k1 = [0, 0, 0.2] k2 = [0, 0, 0.3] for E in [0.1, 1.5]: G1 = RSE.green(E, k1) G2 = RSE.green(E, k2) assert not np.allclose(G1, G2) SE1 = RSE.self_energy(E, k1) SE2 = RSE.self_energy(E, k2) assert not np.allclose(SE1, SE2)