from pytriqs.base.plot.mpl_interface import oplot from pytriqs.base.gf_local import GfImFreq, Omega, inverse g = GfImFreq(indices = [1], beta = 300, n_matsubara = 1000, name = "g") g <<= inverse( Omega + 0.5 ) # the data we want to fit... # The green function for omega \in [0,0.2] X,Y = g.x_data_view (x_window = (0,0.2), flatten_y = True ) from pytriqs.base.fit.fit import Fit, linear, quadratic fitl = Fit ( X,Y.imag, linear ) fitq = Fit ( X,Y.imag, quadratic ) oplot (g, '-o', x_window = (0,5) ) oplot (fitl , '-x', x_window = (0,0.5) ) oplot (fitq , '-x', x_window = (0,1) ) # a bit more complex, we want to fit with a one fermion level .... # Cf the definition of linear and quadratic in the lib one_fermion_level = lambda X, a,b : 1/(a * X *1j + b), r"${1}/(%f x + %f)$" , (1,1) fit1 = Fit ( X,Y, one_fermion_level ) oplot (fit1 , '-x', x_window = (0,3) )
L = 101 # Number of Matsubara frequencies used in the Pade approximation eta = 0.01 # Imaginary frequency shift ## Test Green's functions ## # Two Lorentzians def GLorentz(z): return 0.7/(z-2.6+0.3*1j) + 0.3/(z+3.4+0.1*1j) # Semicircle def GSC(z): return 2.0*(z + sqrt(1-z**2)*(log(1-z) - log(-1+z))/pi) # A superposition of GLorentz(z) and GSC(z) with equal weights def G(z): return 0.5*GLorentz(z) + 0.5*GSC(z) # Matsubara GF gm = GfImFreq(indices = [0], beta = beta, name = "gm") gm <<= Function(G) gm._tail.zero() gm._tail[1] = array([[1.0]]) # Analytic continuation of gm g_pade = GfReFreq(indices = [0], beta = beta, mesh_array = arange(-6,6,0.01), name = "g_pade") g_pade.set_from_pade(gm, N_Matsubara_Frequencies = L, Freq_Offset = eta) from pytriqs.base.archive import HDFArchive R = HDFArchive('pade.output.h5','w') R['g_pade'] = g_pade
from pytriqs.base.lattice.tight_binding import * from pytriqs.base.dos import HilbertTransform from pytriqs.base.gf_local import GfImFreq # Define a DOS (here on a square lattice) BL = BravaisLattice(Units = [(1,0,0) , (0,1,0) ], orbital_positions= {"" : (0,0,0)} ) t = -1.00 # First neighbour Hopping tp = 0.0*t # Second neighbour Hopping hop= { (1,0) : [[ t]], (-1,0) : [[ t]], (0,1) : [[ t]], (0,-1) : [[ t]], (1,1) : [[ tp]], (-1,-1): [[ tp]], (1,-1) : [[ tp]], (-1,1) : [[ tp]]} TB = TightBinding (BL, hop) d = dos(TB, n_kpts= 500, n_eps = 101, name = 'dos')[0] #define a Hilbert transform H = HilbertTransform(d) #fill a Green function G = GfImFreq(indices = ['up','down'], beta = 20) Sigma0 = GfImFreq(indices = ['up','down'], beta = 20); Sigma0.zero() G <<= H(Sigma = Sigma0,mu=0.)