예제 #1
0
   def Self_Consistency(self) :
      S.Transform_SymmetryBasis_toRealSpace (IN= S.Sigma, OUT = Sigma) # Embedding     
      
      # Computes sum over BZ and returns density
      F = lambda mu : SK(mu = mu,Sigma = Sigma, Field = None ,Res = G).total_density()/4 
      
      if Density_Required :
         self.Chemical_potential = Dichotomy.Dichotomy(Function = F,
                                                       xinit = self.Chemical_potential, yvalue =Density_Required,
                                                       Precision_on_y = 0.01, Delta_x=0.5,  MaxNbreLoop = 100, 
                                                       xname="Chemical_Potential", yname= "Total Density",
                                                       verbosity = 3)[0]
      else:
         MPI.report("Total density  = %.3f"%F(self.Chemical_potential))

      S.Transform_RealSpace_to_SymmetryBasis (IN = G, OUT = S.G)       # Extraction 
      S.G0 = inverse(S.Sigma + inverse(S.G))                           # Finally get S.G0 
예제 #2
0
    def GF_realomega(self,ommin,ommax,N_om,broadening=0.01):
        """Calculates the GF and spectral function on the real axis."""

        delta_om = (ommax-ommin)/(1.0*(N_om-1))
            
        omega = numpy.zeros([N_om],numpy.complex_)
        Mesh = numpy.zeros([N_om],numpy.float_)

        for i in range(N_om): 
            omega[i] = ommin + delta_om * i + 1j * broadening
            Mesh[i] = ommin + delta_om * i

        temp = 1.0/self.Beta
        gf,tail,self.atocc,self.atmag = gf_hi_fullu(e0f=self.ealmat, ur=self.ur, umn=self.umn, ujmn=self.ujmn, 
                                                    zmsb=omega, nmom=self.Nmoments, ns=self.Nspin, temp=temp, verbosity = self.Verbosity)
        
        

        for sig in self.a_list: 
            for i in range(11): self.tailtempl[sig][i].array[:] *= 0.0

        # transfer the data to the GF class:
        if (self.UseSpinOrbit): 
            nlmtot = self.Nlm*2         # only one block in this case!
        else:
            nlmtot = self.Nlm

        M={}
        isp=-1
        for a,al in self.GFStruct:
            isp+=1
            #M[a] = gf[isp*self.Nlm:(isp+1)*self.Nlm,isp*self.Nlm:(isp+1)*self.Nlm,:]
            M[a] = gf[isp*nlmtot:(isp+1)*nlmtot,isp*nlmtot:(isp+1)*nlmtot,:]
            for i in range(min(self.Nmoments,10)):
                self.tailtempl[a][i+1].array[:] = tail[i][isp*nlmtot:(isp+1)*nlmtot,isp*nlmtot:(isp+1)*nlmtot]

        glist = lambda : [ GFBloc_ReFreq(Indices = al, Beta = self.Beta, MeshArray = Mesh, Data=M[a], Tail=self.tailtempl[a]) 
                           for a,al in self.GFStruct]       # Indices for the upfolded G
        self.G = GF(NameList = self.a_list, BlockList = glist(),Copy=False)

        # Self energy:
        self.G0 = self.G.copy()
        self.Sigma = self.G.copy()
        self.G0 <<= GF_Initializers.A_Omega_Plus_B(A=1,B=1j*broadening)
        
        M = [ self.ealmat[isp*nlmtot:(isp+1)*nlmtot,isp*nlmtot:(isp+1)*nlmtot] for isp in range((2*self.Nlm)/nlmtot) ] 
        self.G0 -= M
        self.Sigma <<= self.G0 - inverse(self.G)
        self.Sigma.Note='ReFreq'          # This is important for the put_Sigma routine!!!
예제 #3
0
    def Self_Consistency(self):
        S.Transform_SymmetryBasis_toRealSpace(IN=S.Sigma,
                                              OUT=Sigma)  # Embedding

        # Computes sum over BZ and returns density
        F = lambda mu: SK(mu=mu, Sigma=Sigma, Field=None, Res=G).total_density(
        ) / 4

        if Density_Required:
            self.Chemical_potential = Dichotomy.Dichotomy(
                Function=F,
                xinit=self.Chemical_potential,
                yvalue=Density_Required,
                Precision_on_y=0.01,
                Delta_x=0.5,
                MaxNbreLoop=100,
                xname="Chemical_Potential",
                yname="Total Density",
                verbosity=3)[0]
        else:
            MPI.report("Total density  = %.3f" % F(self.Chemical_potential))

        S.Transform_RealSpace_to_SymmetryBasis(IN=G, OUT=S.G)  # Extraction
        S.G0 = inverse(S.Sigma + inverse(S.G))  # Finally get S.G0
예제 #4
0
def Self_Consistency(G0,G):
    G0['0'] <<= inverse(Omega - (t**2)*G['0'])
예제 #5
0
# Import the Green's functions 
from pytriqs.Base.GF_Local import GFBloc_ImFreq, iOmega_n, inverse 

# Create the Matsubara-frequency Green's function and initialize it
g = GFBloc_ImFreq(Indices = [1], Beta = 50, NFreqMatsubara = 1000, Name = "imp")
g <<= inverse( iOmega_n + 0.5 )

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

예제 #6
0
파일: fit_test.py 프로젝트: xydeng/TRIQS
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))
예제 #7
0
    def Solve(self,Iteration_Number=1,Test_Convergence=0.0001):
        """Calculation of the impurity Greens function using Hubbard-I"""

        # Test all a parameters before solutions
        print Parameters.check(self.__dict__,self.Required,self.Optional)
       	#Solver_Base.Solve(self,is_last_iteration,Iteration_Number,Test_Convergence)
       
        if self.Converged :
            MPI.report("Solver %(Name)s has already converted: SKIPPING"%self.__dict__)
            return

        self.__save_eal('eal.dat',Iteration_Number)

        MPI.report( "Starting Fortran solver %(Name)s"%self.__dict__)

        self.Sigma_Old <<= self.Sigma
        self.G_Old <<= self.G

        # call the fortran solver:
        temp = 1.0/self.Beta
        gf,tail,self.atocc,self.atmag = gf_hi_fullu(e0f=self.ealmat, ur=self.ur, umn=self.umn, ujmn=self.ujmn, 
                                                    zmsb=self.zmsb, nmom=self.Nmoments, ns=self.Nspin, temp=temp, verbosity = self.Verbosity)

        #self.sig = sigma_atomic_fullu(gf=self.gf,e0f=self.eal,zmsb=self.zmsb,ns=self.Nspin,nlm=self.Nlm)

        if (self.Verbosity==0):
            # No fortran output, so give basic results here
            MPI.report("Atomic occupancy in Hubbard I Solver  : %s"%self.atocc)
            MPI.report("Atomic magn. mom. in Hubbard I Solver : %s"%self.atmag)

        # transfer the data to the GF class:
        if (self.UseSpinOrbit): 
            nlmtot = self.Nlm*2         # only one block in this case!
        else:
            nlmtot = self.Nlm

        M={}
        isp=-1
        for a,al in self.GFStruct:
            isp+=1
            #M[a] = gf[isp*self.Nlm:(isp+1)*self.Nlm,isp*self.Nlm:(isp+1)*self.Nlm,:]
            M[a] = gf[isp*nlmtot:(isp+1)*nlmtot,isp*nlmtot:(isp+1)*nlmtot,:]
            for i in range(min(self.Nmoments,10)):
                self.tailtempl[a][i+1].array[:] = tail[i][isp*nlmtot:(isp+1)*nlmtot,isp*nlmtot:(isp+1)*nlmtot]
                 
        glist = lambda : [ GFBloc_ImFreq(Indices = al, Beta = self.Beta, NFreqMatsubara = self.Nmsb, Data=M[a], Tail=self.tailtempl[a]) 
                           for a,al in self.GFStruct]
        self.G = GF(NameList = self.a_list, BlockList = glist(),Copy=False)
            
        # Self energy:
        self.G0 <<= GF_Initializers.A_Omega_Plus_B(A=1,B=0.0)
        
        M = [ self.ealmat[isp*nlmtot:(isp+1)*nlmtot,isp*nlmtot:(isp+1)*nlmtot] for isp in range((2*self.Nlm)/nlmtot) ] 
        self.G0 -= M
        self.Sigma <<= self.G0 - inverse(self.G)

        # invert G0
        self.G0.invert()
       
        def test_distance(G1,G2, dist) :
            def f(G1,G2) : 
                print abs(G1._data.array - G2._data.array)
                dS = max(abs(G1._data.array - G2._data.array).flatten())  
                aS = max(abs(G1._data.array).flatten())
                return dS <= aS*dist
            return reduce(lambda x,y : x and y, [f(g1,g2) for (i1,g1),(i2,g2) in izip(G1,G2)])

        MPI.report("\nChecking Sigma for convergence...\nUsing tolerance %s"%Test_Convergence)
        self.Converged = test_distance(self.Sigma,self.Sigma_Old,Test_Convergence)

        if self.Converged :
            MPI.report("Solver HAS CONVERGED")
        else :
            MPI.report("Solver has not yet converged")
예제 #8
0
파일: example.py 프로젝트: xydeng/TRIQS
# Import the Green's functions
from pytriqs.Base.GF_Local import GFBloc_ImFreq, iOmega_n, inverse

# Create the Matsubara-frequency Green's function and initialize it
g = GFBloc_ImFreq(Indices=[1], Beta=50, NFreqMatsubara=1000, Name="imp")
g <<= inverse(iOmega_n + 0.5)

from pytriqs.Base.Plot.MatplotlibInterface import oplot
oplot(g, '-o', x_window=(0, 10))
예제 #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" )
예제 #10
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) )
    
예제 #11
0
파일: impinbath.py 프로젝트: xydeng/TRIQS
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")