示例#1
0
    def __init__(self,Beta,GFstruct,**param):
        self.Beta = float(Beta)
        Parameters.check_no_parameters_not_in_union_of_dicts (param,self.Required, self.Optional)
        #DataTestTools.EnsureAllParametersMakeSense(self,param)
        if 'Nmsb' not in param : param['Nmsb'] = 1025
        if 'Nspin' not in param : param['Nspin'] = 2

        Solver_Base.__init__(self,GFstruct,param)

        # construct Greens functions:
        self.a_list = [a for a,al in self.GFStruct]
        glist = lambda : [ GFBloc_ImFreq(Indices = al, Beta = self.Beta, NFreqMatsubara = self.Nmsb) for a,al in self.GFStruct]
        self.G = GF(NameList = self.a_list, BlockList = glist(),Copy=False)
        self.G_Old = self.G.copy()
        self.G0 = self.G.copy()
        self.Sigma = self.G.copy()
        self.Sigma_Old = self.G.copy()
        M = [x for x in self.G.mesh]
        self.zmsb = numpy.array([x for x in M],numpy.complex_)
        
        # for the tails:
        self.tailtempl={}
        for sig,g in self.G: 
            self.tailtempl[sig] = copy.deepcopy(g._tail)
            for i in range(11): self.tailtempl[sig][i].array[:] *= 0.0
    
        self.Name=''

        # effective atomic levels:
        if self.UseSpinOrbit: self.NSpin=2

        self.ealmat = numpy.zeros([self.Nlm*self.Nspin,self.Nlm*self.Nspin],numpy.complex_)
示例#2
0
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 = GFBloc_ImFreq(Indices = [0], Beta = beta, Name = "gm")
gm <<= Function(G)
gm._tail.zero()
gm._tail[1] = array([[1.0]])

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

from pytriqs.Base.Archive import HDF_Archive
R = HDF_Archive('Pade.output.h5','w')
R['g_pade'] = g_pade
示例#3
0
    (-1, -1): [[tp]],
    (1, -1): [[tp]],
    (-1, 1): [[tp]]
}

L = Lattice(Units=[(1, 0, 0), (0, 1, 0)], Hopping=hop)
SL = SuperLattice(BaseLattice=L, SuperLatticeUnits=[(2, 0), (0, 2)])

# SumK function that will perform the sum over the BZ
SK = SumK_Discrete_From_Lattice(TheLattice=SL,
                                Number_Points_in_BZ=8,
                                Method="Riemann")

# Defines G and Sigma with a block structure compatible with the SumK function
G = GF(Name_Block_Generator=[(s,
                              GFBloc_ImFreq(Indices=SK.GFBlocIndices,
                                            Mesh=S.G.mesh))
                             for s in ['up', 'down']],
       Copy=False)
Sigma = G.copy()

# Init Sigma
for n, B in S.Sigma:
    B <<= GF_Initializers.Const(2.0)


# Now I write my DMFT loop...
class myloop(DMFT_Loop_Generic):
    def Self_Consistency(self):
        S.Transform_SymmetryBasis_toRealSpace(IN=S.Sigma,
                                              OUT=Sigma)  # Embedding
示例#4
0
文件: GF_Init.py 项目: xydeng/TRIQS
# You should have received a copy of the GNU General Public License along with
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################

from pytriqs.Base.Archive import *
from pytriqs.Base.GF_Local.GFBloc_ReFreq import *
from pytriqs.Base.GF_Local.GFBloc_ImFreq import *
from pytriqs.Base.GF_Local.GF import GF
import pytriqs.Base.GF_Local.GF_Initializers as GF_Initializers
import numpy

h = HDF_Archive('GF_Init.output.h5', 'w')

g = GFBloc_ImFreq(Indices=['eg1', 'eg2'],
                  Beta=50,
                  NFreqMatsubara=100,
                  Name="egBlock")
g['eg1', 'eg1'] <<= GF_Initializers.SemiCircular(HalfBandwidth=1)
g['eg2', 'eg2'] <<= GF_Initializers.SemiCircular(HalfBandwidth=2)

h['g1'] = g

g <<= GF_Initializers.Const(numpy.array([[1, 2], [2, 3]]))

h['g2'] = g

some_mesh = numpy.arange(-5, 5, 0.1)
g = GFBloc_ReFreq(Indices=['eg1', 'eg2'],
                  Beta=50,
                  MeshArray=some_mesh,
                  Name="egBlock")
示例#5
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))
示例#6
0
文件: tut_ex2.py 项目: xydeng/TRIQS
from pytriqs.Base.Archive import HDF_Archive
from pytriqs.Base.GF_Local import GFBloc_ImFreq

# Define a Green function 
G = GFBloc_ImFreq ( Indices = [1], Beta = 10, NFreqMatsubara = 1000) 
      
# Opens the file myfile.h5, in read/write mode
R = HDF_Archive('myfile.h5', 'w')
# Store the object G under the name 'g1' and mu
R['g1'] = G
R['mu'] = 1.29
del R # closing the files (optional : file is closed when the R reference is deleted)




示例#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.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) )