示例#1
0
from pytriqs.base.gf_local import GfReFreq, Omega, Wilson, inverse
import numpy

a = numpy.arange(-1.99, 2.00, 0.02)  # Define the energy array
eps_d, V = 0.3, 0.2

# Create the real-frequency Green's function and initialize it
g = GfReFreq(indices=["s", "d"], beta=50, mesh_array=a, name="s+d")
g["d", "d"] = Omega - eps_d
g["d", "s"] = V
g["s", "d"] = V
g["s", "s"] = inverse(Wilson(1.0))
g.invert()

# Plot it with matplotlib. 'S' means: spectral function ( -1/pi Imag (g) )
from pytriqs.base.plot.mpl_interface import oplot

oplot(g["d", "d"], "-o", RI="S", x_window=(-1.8, 1.8), name="Impurity")
oplot(g["s", "s"], "-x", RI="S", x_window=(-1.8, 1.8), name="Bath")
示例#2
0
文件: pade.py 项目: tayral/triqs_0.x
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