Ejemplo n.º 1
0
from pytriqs.base.gf_local import *
from pytriqs.base.archive import *
from pytriqs.base.plot.mpl_interface import oplot

A = HDFArchive("solution.h5")
oplot(A["Gl"]["up"], "-o", x_window=(15, 45))
Ejemplo n.º 2
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")
Ejemplo n.º 3
0
import numpy
from pytriqs.base.gf_local import GfReFreq,SemiCircular
from pytriqs.base.plot.mpl_interface import oplot

gf = GfReFreq(indices = [1], beta = 50, mesh_array = numpy.arange(-30,30,0.1) , name = "my_block")
gf[1,1] =  SemiCircular(half_bandwidth = 2)

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


Ejemplo n.º 4
0
# Import the Green's functions 
from pytriqs.base.gf_local import GfImFreq, iOmega_n, inverse 

# Create the Matsubara-frequency Green's function and initialize it
g = GfImFreq(indices = [1], beta = 50, n_matsubara = 1000, name = "imp")
g <<= inverse( iOmega_n + 0.5 )

from pytriqs.base.plot.mpl_interface import oplot
oplot(g, '-o',  x_window  = (0,10))

Ejemplo n.º 5
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 = GfReFreq(indices = [0], beta = beta, mesh_array = DOSMesh, name = '0')
    G_real = BlockGf(name_list = ('0',), block_list = (g_real,), make_copies = True)
    
    # Analytic continuation with Pade
    G_real['0'].set_from_pade(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
Ejemplo n.º 6
0
from pytriqs.base.gf_local import *
from pytriqs.base.archive import *
from pytriqs.base.plot.mpl_interface import oplot

A = HDFArchive("solution.h5")
oplot(A['G']['up'], '-o', x_window = (0,10))
Ejemplo n.º 7
0
from pytriqs.base.gf_local import *
from pytriqs.base.plot.mpl_interface import oplot,plt

# A Green's function on the Matsubara axis set to a semicircular
gw = GfImFreq(indices = [1], beta = 50)
gw <<= SemiCircular(half_bandwidth = 1)

# Create an imaginary-time Green's function and plot it
gt = GfImTime(indices = [1], beta = 50)
gt <<= InverseFourier(gw)
oplot(gt, '-')
Ejemplo n.º 8
0
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) )
    
Ejemplo n.º 9
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.mpl_interface import oplot
oplot(X,'-o')
Ejemplo n.º 10
0
import numpy as np
from pytriqs.base.gf_local import GfReFreq, SemiCircular

g = GfReFreq(indices = ['eg1', 'eg2'], beta = 50, mesh_array = np.arange(-5,5,0.01) , name = "egBlock")

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

from pytriqs.base.plot.mpl_interface import oplot
oplot(g['eg1','eg1'], '-o', RI = 'S')  # S : spectral function 
oplot(g['eg2','eg2'], '-x', RI = 'S')   


Ejemplo n.º 11
0
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.mpl_interface import oplot

oplot(X, "-o")
oplot(X, "-x", phi=0.3)
Ejemplo n.º 12
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 = TightBinding ( BL, hop)

# Compute the density of states
d = dos (TB, n_kpts= 500, n_eps = 101, name = 'dos')[0]

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





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



Ejemplo n.º 13
0
from pytriqs.base.gf_local import *
from pytriqs.base.plot.mpl_interface import oplot,plt

# A Green's function on the Matsubara axis set to a semicircular
gw = GfImFreq(indices = [1], beta = 50)
gw <<= SemiCircular(half_bandwidth = 1)

# Create a Legendre Green's function with 40 coefficients
# and initialize it from gw
gl = GfLegendre(indices = [1], beta = 50, n_legendre_coeffs = 40)
gl <<= MatsubaraToLegendre(gw)

# Plot the Legendre Green's function
oplot(gl, '-o')
Ejemplo n.º 14
0
from pytriqs.base.gf_local import GfReFreq
from pytriqs.base.archive import HDFArchive
from math import pi

R = HDFArchive('myfile.h5', 'r') 
 
from pytriqs.base.plot.mpl_interface import oplot, plt
plt.xrange(-1,1) 
plt.yrange(0,7) 

for name, g in R.items() :  # iterate on the elements of R, like a dict ...
    oplot( (- 1/pi * g).imag, "-o", name = name)

p.savefig("./tut_ex3b.png") 

Ejemplo n.º 15
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 = GfImFreq(indices = [0], beta = beta, name = "gm")
gm <<= Function(G)
gm._tail.zero()
gm._tail[1] = numpy.array([[1.0]])

# Real frequency BlockGf(reference)
gr = GfReFreq(indices = [0], beta = beta, mesh_array = 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 = GfReFreq(indices = [0], beta = beta, mesh_array = numpy.arange(-6,6,0.01), name = "g_pade")
g_pade.set_from_pade(gm, N_Matsubara_Frequencies = L, Freq_Offset = eta)

# Comparison plot
from pytriqs.base.plot.mpl_interface import oplot
oplot(gr[0,0], '-o', RI = 'S', name = "Original DOS")
oplot(g_pade[0,0], '-x', RI = 'S', name = "Pade-reconstructed DOS")
Ejemplo n.º 16
0
from pytriqs.base.plot.mpl_interface 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 = GfImFreq(indices = [1], beta = 300, n_matsubara = 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 HDFArchive
R = HDFArchive('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"