def test_hf_fast_updatecond_complex(chempot, u_int, updater): """Test over the fast update after a spin flip""" w_n = cgf.matsubara_freq(20, 20) SO_N1 = np.array([[0, 1j, -1], [-1j, 0, 1j], [-1, -1j, 0]]) / 2 # Semi circle GF by iteration H_loc = SO_N1 + chempot * np.eye(3) g_0_1 = [1j * wn * np.eye(3) - H_loc for wn in w_n] g_0 = [la.inv(g) for g in g_0_1] for i in range(40): g_0_1 = [ 1j * wn * np.eye(3) - H_loc - 0.25 * g for wn, g in zip(w_n, g_0) ] g_0 = [la.inv(g) for g in g_0_1] G_tail = [np.eye(3).reshape(3, 3, 1), H_loc.reshape(3, 3, 1), 0] tau = np.arange(0, 20, 20 / len(w_n)) g_0 = np.array(g_0) g0t = cgf.gw_invfouriertrans(np.rollaxis(g_0, 0, 3), tau, w_n, G_tail) v = hf.ising_v(tau[1], u_int, len(tau) * 3) v = np.squeeze(v) g0ttp = hf.retarded_weiss(g0t) kroneker = np.eye(v.size) groot = hf.gnewclean(g0ttp, v, kroneker) g_fast_flip = np.copy(groot) flip = randrange(v.size) v[flip] *= -1 g_flip = hf.gnewclean(g0ttp, v, kroneker) updater(g_fast_flip, 2 * v[flip], flip) assert np.allclose(g_flip, g_fast_flip)
def generate_random_gf(beta, size): """Generates a gf in a bethe lattice with a random Hamiltonian""" w_n = cgf.matsubara_freq(beta=beta, pos_size=beta) tau = np.arange(0, beta, beta / len(w_n)) H_loc = np.random.randn(size, size) + 1j * np.random.randn(size, size) H_loc = H_loc + H_loc.T.conj() # Make Hermitian hamiltonian g_0_1 = [1j * wn * np.eye(size) - H_loc for wn in w_n] g_0 = [la.inv(g) for g in g_0_1] for i in range(40): g_0_1 = [1j * wn * np.eye(size) - H_loc - 0.25 * g for wn, g in zip(w_n, g_0)] g_0 = [la.inv(g) for g in g_0_1] g_tail = [np.eye(size).reshape(size, size, 1), H_loc.reshape(size, size, 1), 0.25 * np.eye(size).reshape(size, size, 1)] return np.rollaxis(np.array(g_0), 0, 3), g_tail, w_n, tau
def test_greenf(beta): wn = cgf.matsubara_freq(beta, 2 * beta) semicirc = cgf.greenF(wn) assert np.allclose(semicirc.real, semicirc.real[::-1]) assert np.allclose(semicirc.imag, -semicirc.imag[::-1])
def test_matsubara_axis(beta): wn = cgf.matsubara_freq(beta, 2 * beta) assert len(wn) % 2 == 0 assert np.allclose(wn, -wn[::-1])