Beispiel #1
0
from pytriqs.Base.GF_Local import GFBloc_ReFreq, 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 = GFBloc_ReFreq(Indices=['s', 'd'], Beta=50, MeshArray=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.MatplotlibInterface 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")
Beispiel #2
0
from pytriqs.Base.GF_Local import *
from pytriqs.Base.Plot.MatplotlibInterface import oplot, plt

# A Green's function on the Matsubara axis set to a semicircular
gw = GFBloc_ImFreq(Indices=[1], Beta=50)
gw <<= SemiCircular(HalfBandwidth=1)

# Create an imaginary-time Green's function and plot it
gt = GFBloc_ImTime(Indices=[1], Beta=50)
gt <<= InverseFourier(gw)
oplot(gt, '-')
Beispiel #3
0
# where n=Number_Orbitals
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 = tight_binding ( BL, hop)

# Compute the density of states
d = dos (TB, nkpts= 500, neps = 101, Name = 'dos')[0]

# Plot the dos it with matplotlib
from pytriqs.Base.Plot.MatplotlibInterface import oplot
from matplotlib import pylab as plt
oplot(d,'-o')
plt.xlim ( -5,5 )
plt.ylim ( 0, 0.4)





plt.savefig("./ex1.png") 



Beispiel #4
0
import numpy
from pytriqs.Base.GF_Local import GFBloc_ReFreq,SemiCircular
from pytriqs.Base.Plot.MatplotlibInterface import oplot

gf = GFBloc_ReFreq(Indices = [1], Beta = 50, MeshArray = numpy.arange(-30,30,0.1) , Name = "my_block")
gf[1,1] =  SemiCircular(HalfBandwidth = 2)

oplot(gf.InverseFourier().imag, '-o')   


Beispiel #5
0
from pytriqs.Base.GF_Local import *
from pytriqs.Base.Archive import *
from pytriqs.Base.Plot.MatplotlibInterface import oplot

A = HDF_Archive("solution.h5")
oplot(A['Gl']['up'], '-o', x_window=(15,45) )
Beispiel #6
0
from pytriqs.Base.GF_Local import *
from pytriqs.Base.Plot.MatplotlibInterface import oplot,plt

# A Green's function on the Matsubara axis set to a semicircular
gw = GFBloc_ImFreq(Indices = [1], Beta = 50)
gw <<= SemiCircular(HalfBandwidth = 1)

# Create a Legendre Green's function with 40 coefficients
# initialize it from gw and plot it
gl = GFBloc_ImLegendre(Indices = [1], Beta = 50, NLegendreCoeffs = 40)
gl <<= MatsubaraToLegendre(gw)
oplot(gl, '-o')
Beispiel #7
0
import numpy


class myObject(object):
    def _plot_(self, options):
        PI = numpy.pi
        xdata = numpy.arange(-PI, PI, 0.1)
        ydata1 = numpy.cos(xdata)
        ydata2 = numpy.sin(xdata)
        return ([{
            'Type': "XY",
            'xdata': xdata,
            'ydata': ydata1,
            'label': 'Cos'
        }, {
            'Type': "XY",
            'xdata': xdata,
            'ydata': ydata2,
            'label': 'Sin'
        }])


X = myObject()

from pytriqs.Base.Plot.MatplotlibInterface import oplot

oplot(X, '-o')
Beispiel #8
0
from pytriqs.Base.GF_Local import GFBloc_ImFreq, SemiCircular

g = GFBloc_ImFreq(Indices=['eg1', 'eg2'],
                  Beta=50,
                  NFreqMatsubara=1000,
                  Name="egBlock")

g['eg1', 'eg1'] = SemiCircular(HalfBandwidth=1)
g['eg2', 'eg2'] = SemiCircular(HalfBandwidth=2)

from pytriqs.Base.Plot.MatplotlibInterface import oplot, plt
oplot(g, '-o', x_window=(0, 10))
plt.ylim(-2, 1)
Beispiel #9
0
from pytriqs.Base.GF_Local import GFBloc_ReFreq, 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 = GFBloc_ReFreq(Indices = ['s','d'], Beta = 50, MeshArray = 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.MatplotlibInterface 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" )
Beispiel #10
0
import numpy

class myObject(object):
  def _plot_(self, options):
    PI = numpy.pi
    xdata = numpy.arange(-PI,PI,0.1)
    ydata1 = numpy.cos(xdata)
    ydata2 = numpy.sin(xdata)
    return( [
              {'Type' : "XY", 'xdata':xdata, 'ydata':ydata1, 'label':'Cos'},
              {'Type' : "XY", 'xdata':xdata, 'ydata':ydata2, 'label':'Sin'}
            ] )

X = myObject()

from pytriqs.Base.Plot.MatplotlibInterface import oplot
oplot(X,'-o')
Beispiel #11
0
from pytriqs.Base.Plot.MatplotlibInterface import oplot
from pytriqs.Base.GF_Local import GFBloc_ImFreq, Omega, inverse
g = GFBloc_ImFreq(Indices = [1], Beta = 300, NFreqMatsubara = 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) )
    
Beispiel #12
0
    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 = GFBloc_ImFreq(Indices = [0], Beta = beta, Name = "gm")
gm <<= Function(G)
gm._tail.zero()
gm._tail[1] = numpy.array([[1.0]])

# Real frequency GF (reference)
gr = GFBloc_ReFreq(Indices = [0], Beta = beta, MeshArray = numpy.arange(-6,6,0.01), Name = "gr")
gr <<= Function(G)
gr._tail.zero()
gr._tail[1] = numpy.array([[1.0]])

# Analytic continuation of gm
g_pade = GFBloc_ReFreq(Indices = [0], Beta = beta, MeshArray = numpy.arange(-6,6,0.01), Name = "g_pade")
g_pade.setFromPadeOf(gm, N_Matsubara_Frequencies = L, Freq_Offset = eta)

# Comparison plot
from pytriqs.Base.Plot.MatplotlibInterface import oplot
oplot(gr[0,0], '-o', RI = 'S', Name = "Original DOS")
oplot(g_pade[0,0], '-x', RI = 'S', Name = "Pade-reconstructed DOS")
Beispiel #13
0
from pytriqs.Base.GF_Local import *
from pytriqs.Base.Archive import *
from pytriqs.Base.Plot.MatplotlibInterface import oplot

A = HDF_Archive("solution.h5")
oplot(A['G']['up'], '-o', x_window = (0,10))
Beispiel #14
0
from pytriqs.Base.Plot.MatplotlibInterface import oplot
from pytriqs.Base.GF_Local import GFBloc_ImFreq, Omega, inverse
g = GFBloc_ImFreq(Indices=[1], Beta=300, NFreqMatsubara=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))
Beispiel #15
0
from pytriqs.Base.Plot.MatplotlibInterface import oplot
from pytriqs.Base.Fit.fit import Fit, linear, quadratic
from pytriqs.Base.GF_Local import *
from pytriqs.Base.GF_Local.Descriptors import iOmega_n
g = GFBloc_ImFreq(Indices = [1], Beta = 300, NFreqMatsubara = 1000, Name = "g")
g <<= inverse( iOmega_n + 0.5 )

print " van plot"
oplot (g,     '-o', x_window = (0,3) )     

print "plot done"
g<<= inverse( iOmega_n + 0.5 )
 
print "ok ----------------------"


from pytriqs.Base.Archive import HDF_Archive
R = HDF_Archive('myfile.h5', 'r')

for n, calculation in R.items() : 
    #g = calculation['g']
    g <<= inverse( iOmega_n + 0.5 )
    
    print "pokokook"

    X,Y = g.x_data_view (x_window = (0,0.2), flatten_y = True )

    #fitl = Fit ( X,Y.imag, linear )
    g <<= inverse( iOmega_n + 0.5 )

    print " van plot"
Beispiel #16
0
import numpy

class myObject(object):
  def _plot_(self, options):
    PI = numpy.pi
    xdata = numpy.arange(-PI,PI,0.1)
    phi = options.pop('phi',0)      # Crucial : removes the entry from the dict
    ydata1 = numpy.cos(xdata + phi)
    ydata2 = numpy.sin(xdata + phi)
    return( [
              {'Type' : "XY", 'xdata':xdata, 'ydata':ydata1, 'label': r'$x \rightarrow \cos (x + \phi), \quad \phi = %s$'%phi},
              {'Type' : "XY", 'xdata':xdata, 'ydata':ydata2, 'label': r'$x \rightarrow \sin (x + \phi), \quad \phi = %s$'%phi}
            ] )

X = myObject()

from pytriqs.Base.Plot.MatplotlibInterface import oplot
oplot(X,'-o')
oplot(X,'-x', phi = 0.3)

Beispiel #17
0
# Prepare a nearest neighbour hopping on BL
t = -1.00  # First neighbour Hopping
tp = 0.0 * t  # Second neighbour Hopping

# Hopping[ Displacement on the lattice] = [[t11,t12,t13....],[t21,t22,t23....],...,[....,tnn]]
# where n=Number_Orbitals
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 = tight_binding(BL, hop)

# Compute the density of states
d = dos(TB, nkpts=500, neps=101, Name='dos')[0]

# Plot the dos it with matplotlib
from pytriqs.Base.Plot.MatplotlibInterface import oplot
from matplotlib import pylab as plt
oplot(d, '-o')
plt.xlim(-5, 5)
plt.ylim(0, 0.4)

plt.savefig("./ex1.png")
Beispiel #18
0
from pytriqs.Base.GF_Local import GFBloc_ImFreq, SemiCircular

g = GFBloc_ImFreq(Indices = ['eg1','eg2'], Beta = 50, NFreqMatsubara = 1000, Name = "egBlock") 

g['eg1','eg1'] = SemiCircular(HalfBandwidth = 1)
g['eg2','eg2'] = SemiCircular(HalfBandwidth = 2)

from pytriqs.Base.Plot.MatplotlibInterface import oplot,plt
oplot(g, '-o', x_window = (0,10))
plt.ylim(-2,1)

Beispiel #19
0
    return 0.5 * GLorentz(z) + 0.5 * GSC(z)


# Matsubara GF
gm = GFBloc_ImFreq(Indices=[0], Beta=beta, Name="gm")
gm <<= Function(G)
gm._tail.zero()
gm._tail[1] = numpy.array([[1.0]])

# Real frequency GF (reference)
gr = GFBloc_ReFreq(Indices=[0],
                   Beta=beta,
                   MeshArray=numpy.arange(-6, 6, 0.01),
                   Name="gr")
gr <<= Function(G)
gr._tail.zero()
gr._tail[1] = numpy.array([[1.0]])

# Analytic continuation of gm
g_pade = GFBloc_ReFreq(Indices=[0],
                       Beta=beta,
                       MeshArray=numpy.arange(-6, 6, 0.01),
                       Name="g_pade")
g_pade.setFromPadeOf(gm, N_Matsubara_Frequencies=L, Freq_Offset=eta)

# Comparison plot
from pytriqs.Base.Plot.MatplotlibInterface import oplot

oplot(gr[0, 0], '-o', RI='S', Name="Original DOS")
oplot(g_pade[0, 0], '-x', RI='S', Name="Pade-reconstructed DOS")
Beispiel #20
0
        phi = options.pop('phi',
                          0)  # Crucial : removes the entry from the dict
        ydata1 = numpy.cos(xdata + phi)
        ydata2 = numpy.sin(xdata + phi)
        return ([{
            'Type':
            "XY",
            'xdata':
            xdata,
            'ydata':
            ydata1,
            'label':
            r'$x \rightarrow \cos (x + \phi), \quad \phi = %s$' % phi
        }, {
            'Type':
            "XY",
            'xdata':
            xdata,
            'ydata':
            ydata2,
            'label':
            r'$x \rightarrow \sin (x + \phi), \quad \phi = %s$' % phi
        }])


X = myObject()

from pytriqs.Base.Plot.MatplotlibInterface import oplot
oplot(X, '-o')
oplot(X, '-x', phi=0.3)
Beispiel #21
0
from pytriqs.Base.GF_Local import *
from pytriqs.Base.Archive import *
from pytriqs.Base.Plot.MatplotlibInterface import oplot

A = HDF_Archive("solution.h5")
oplot(A['G']['up'], '-o', x_window=(0, 10))
Beispiel #22
0
import numpy as np
from pytriqs.Base.GF_Local import GFBloc_ReFreq, SemiCircular

g = GFBloc_ReFreq(Indices=['eg1', 'eg2'],
                  Beta=50,
                  MeshArray=np.arange(-5, 5, 0.01),
                  Name="egBlock")

g['eg1', 'eg1'] = SemiCircular(HalfBandwidth=1)
g['eg2', 'eg2'] = SemiCircular(HalfBandwidth=2)

from pytriqs.Base.Plot.MatplotlibInterface import oplot
oplot(g['eg1', 'eg1'], '-o', RI='S')  # S : spectral function
oplot(g['eg2', 'eg2'], '-x', RI='S')
Beispiel #23
0
import numpy as np
from pytriqs.Base.GF_Local import GFBloc_ReFreq, SemiCircular

g = GFBloc_ReFreq(Indices=["eg1", "eg2"], Beta=50, MeshArray=np.arange(-5, 5, 0.01), Name="egBlock")

g["eg1", "eg1"] = SemiCircular(HalfBandwidth=1)
g["eg2", "eg2"] = SemiCircular(HalfBandwidth=2)

from pytriqs.Base.Plot.MatplotlibInterface import oplot

oplot(g["eg1", "eg1"], "-o", RI="S")  # S : spectral function
oplot(g["eg2", "eg2"], "-x", RI="S")
Beispiel #24
0
from pytriqs.Base.GF_Local import *
from pytriqs.Base.Plot.MatplotlibInterface import oplot,plt

# A Green's function on the Matsubara axis set to a semicircular
gw = GFBloc_ImFreq(Indices = [1], Beta = 50)
gw <<= SemiCircular(HalfBandwidth = 1)

# Create an imaginary-time Green's function
gt = GFBloc_ImTime(Indices = [1], Beta = 50)
gt <<= InverseFourier(gw)

# Plot the Legendre Green's function
oplot(gt, '-')
Beispiel #25
0
from pytriqs.Base.GF_Local import *
from pytriqs.Base.Plot.MatplotlibInterface import oplot, plt

# A Green's function on the Matsubara axis set to a semicircular
gw = GFBloc_ImFreq(Indices=[1], Beta=50)
gw <<= SemiCircular(HalfBandwidth=1)

# Create a Legendre Green's function with 40 coefficients
# and initialize it from gw
gl = GFBloc_ImLegendre(Indices=[1], Beta=50, NLegendreCoeffs=40)
gl <<= MatsubaraToLegendre(gw)

# Plot the Legendre Green's function
oplot(gl, '-o')
Beispiel #26
0
    print "Running DMFT calculation for beta=%.2f, U=%.2f, t=%.2f" % (beta,u,t)
    IPT.run(N_loops = N_loops, beta=beta, U=u, Initial_G0=Initial_G0, Self_Consistency=Self_Consistency)
    
    # The resulting local GF on the real axis
    g_real = GFBloc_ReFreq(Indices = [0], Beta = beta, MeshArray = DOSMesh, Name = '0')
    G_real = GF(NameList = ('0',), BlockList = (g_real,), Copy = True)
    
    # Analytic continuation with Pade
    G_real['0'].setFromPadeOf(IPT.S.G['0'], N_Matsubara_Frequencies=Pade_L, Freq_Offset=eta)

    # Save data to the archive
    ar['U' + str(u)] = {'G0': IPT.S.G0, 'G': IPT.S.G, 'Sigma': IPT.S.Sigma, 'G_real':G_real}
   
    # Plot the DOS
    fig = plt.figure()
    oplot(G_real['0'][0,0], RI='S', Name="DOS", figure = fig)
    
    # Adjust 'y' axis limits accordingly to the Luttinger sum rule 
    fig.axes[0].set_ylim(0,1/pi/t*1.1)
    
    # Set title of the plot
    fig_title = "Local DOS, IPT, Bethe lattice, $\\beta=%.2f$, $U=%.2f$" % (beta,u)
    plt.title(fig_title)

    # Save the figure as a PNG file
    DOS_file = "DOS_beta%.2fU%.2f.png" % (beta,u)
    fig.savefig(DOS_file, format="png", transparent=False)
    DOS_files.append(DOS_file)
    plt.close(fig)

# Create an animated GIF
Beispiel #27
0
import numpy
from pytriqs.Base.GF_Local import GFBloc_ReFreq, SemiCircular
from pytriqs.Base.Plot.MatplotlibInterface import oplot

gf = GFBloc_ReFreq(Indices=[1],
                   Beta=50,
                   MeshArray=numpy.arange(-30, 30, 0.1),
                   Name="my_block")
gf[1, 1] = SemiCircular(HalfBandwidth=2)

oplot(gf.InverseFourier().imag, '-o')