def __init__(self, *args, **kwargs): super(TestMethods, self).__init__(*args, **kwargs) if stat in ['F', 'B']: self._b = irbasis.load(stat, Lambda) elif stat == 'barB': self._b = augmented_basis_b(irbasis.load('B', Lambda)) self._B = Basis(self._b, beta)
def test_sampling_point_y(self): for stat in ['F', 'B']: b = irbasis.load(stat, Lambda, "../irbasis.h5") dim = b.dim() whichl = dim - 1 sp = irbasis.sampling_points_y(b, whichl) sp2 = b.sampling_points_y(whichl) assert numpy.all(sp==sp2) #print(len(sp), whichl) #print(sp) assert len(sp) == whichl+1
def test_sampling_point_x(self): for stat in ['F', 'B']: b = irbasis.load(stat, Lambda, "../irbasis.h5") dim = b.dim() whichl = dim - 1 sp = irbasis.sampling_points_x(b, whichl) sp2 = b.sampling_points_x(whichl) assert numpy.all(sp==sp2) assert len(sp) == whichl+1 uxl = numpy.array([b.ulx(l, x) for l in range(dim) for x in sp]).reshape((dim, dim)) U, S, Vh = scipy.linalg.svd(uxl, full_matrices=False) cond_num = S[0] / S[-1] print("cond_num ", cond_num) self.assertLessEqual(cond_num, 1E+4)
def test_sampling_point_tau(self): for stat in ['F', 'B']: if stat == 'barB': b = Basis(augmented_basis_b(Lambda), beta) else: b = Basis(irbasis.load(stat, Lambda), beta) dim = b.dim whichl = dim - 1 sp = sampling_points_tau(b, whichl) assert len(sp) == whichl+1 Utaul = numpy.array([b.Ultau(l, tau) for l in range(dim) for tau in sp]).reshape((dim, dim)) Utaul_real = from_complex_to_real_coeff_matrix(Utaul) U, S, Vh = scipy.linalg.svd(Utaul_real, full_matrices=False) cond_num = S[0] / S[-1] print("cond_num ", cond_num) self.assertLessEqual(cond_num, 1E+4)
def test_sampling_point_matsubara(self): for stat in ['F', 'B']: b = irbasis.load(stat, Lambda, "../irbasis.h5") dim = b.dim() whichl = dim - 1 sp = irbasis.sampling_points_matsubara(b, whichl) sp2 = b.sampling_points_matsubara(whichl) assert numpy.all(sp==sp2) if stat == 'F': assert numpy.all([-s-1 in sp for s in sp]) elif stat in ['B']: assert numpy.all([-s in sp for s in sp]) assert len(sp) >= whichl + 1 Unl = b.compute_unl(sp)[:, :dim] U, S, Vh = scipy.linalg.svd(Unl, full_matrices=False) cond_num = S[0] / S[-1] print("cond_num ", cond_num) self.assertLessEqual(cond_num, 1E+4)
def test_sampling_point_matsubara(self): for stat in ['F', 'B']: if stat == 'barB': b = Basis(augmented_basis_b(Lambda), beta) else: b = Basis(irbasis.load(stat, Lambda), beta) dim = b.dim - 4 whichl = dim - 1 sp = sampling_points_matsubara(b, whichl) if stat == 'F': assert numpy.all([-s-1 in sp for s in sp]) elif stat in ['B', 'bB']: assert numpy.all([-s in sp for s in sp]) assert len(sp) == whichl+1 Unl = b.compute_Unl(sp)[:, :dim] Unl_real = from_complex_to_real_coeff_matrix(Unl) U, S, Vh = scipy.linalg.svd(Unl_real, full_matrices=False) cond_num = S[0] / S[-1] print("cond_num ", cond_num) self.assertLessEqual(cond_num, 1E+4)
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt matplotlib.rcParams['font.family'] = 'serif' matplotlib.rcParams['mathtext.fontset'] = 'cm' matplotlib.rcParams['mathtext.rm'] = 'serif' import numpy import irbasis if __name__ == '__main__': Lambda = 1000.0 statistics = 'F' # Fermion. use 'B' for bosons basis = irbasis.load(statistics, Lambda) linst = ['solid', 'dashed', 'dashdot', 'dotted'] mi = numpy.linspace(-1, 1, 10000) #plt.figure(1, figsize=(8,6)) #plt.figure(2, figsize=(8,6)) idx = 0 for l in [0, 1, 2]: plt.figure(1) plt.plot(mi, numpy.array([basis.ulx(l, x) for x in mi]), linestyle=linst[idx], label="$l = {}$".format(l))
return numpy.sqrt(self._beta / 2) * numpy.dot( gtau_smpl[:, :], self._u_smpl[:, 0:nl]).reshape((nl)) if __name__ == '__main__': stat = 'F' # 'F' for Fermionic or 'B' for Bosonic wmax = 10.0 Lambda = 1000.0 beta = Lambda / wmax pole = 2.0 assert numpy.abs(pole) <= wmax basis = irbasis.load(stat, Lambda) Nl = basis.dim() # Initialize a transformer trans = transformer(basis, beta) # G(tau) generated by a pole at "pole = 2.0" if stat == 'B': gtau = lambda tau: -numpy.exp(-pole * tau) / (1 - numpy.exp(-beta * pole)) elif stat == 'F': gtau = lambda tau: -numpy.exp(-pole * tau) / (1 + numpy.exp(-beta * pole)) #Compute expansion coefficients in IR by numerical integration Gl = trans.compute_gl(gtau, Nl)
from __future__ import print_function import numpy import irbasis # By default, Lambda = 10, 100, 1000, 10000 are available. Lambda = 1000.0 # Fermionic # If you has not installed the irbasis package via pip, # you must specify the location of a data file as follows. # irbasis.load('F', Lambda, './irbasis.h5') basis = irbasis.load('F', Lambda) l = 0 print("l =", l, ",Lambda =", Lambda) x = 1 y = 1 # Dimensions of basis print("Dim ", basis.dim()) # u_0(x = 1) and v_0(y = 1) print("ulx ", basis.ulx(l, x)) print("vly ", basis.vly(l, y)) # Singular value s_0 print("sl ", basis.sl(l)) # The k-th derivative of u_l(x) and v_l(y) (k = 1,2,3) for k in [1, 2, 3]: