def __init__(self,Beta,Norb,U_interact,J_Hund) : # NB : the Hamiltonian should NOT contain the quadratic part which is in G0 Hamiltonian = U_interact * Sum( [ N('up',i)*N('down',i) for i in range(Norb) ] ) for i in range(Norb-1): for j in range(i+1,Norb): Hamiltonian += (U_interact-2*J_Hund) * ( N('up',i) * N('down',j) + N('down',i) * N('up',j) ) + \ (U_interact-3*J_Hund) * ( N('up',i) * N('up',j) + N('down',i) * N('down',j) ) #Quantum_Numbers = {} #for i in range(Norb): # Quantum_Numbers['N%sup'%(i+1)] = N('up',i) # Quantum_Numbers['N%sdown'%(i+1)] = N('down',i) Ntot = Sum( [ N(s,i) for s in ['up','down'] for i in range(Norb) ] ) Sz = Sum( [ N('up',i)-N('down',i) for i in range(Norb) ] ) Quantum_Numbers = {'Ntot' : Ntot, 'Sz' : Sz} Solver.__init__(self, Beta = Beta, GFstruct = [ ('%s'%(ud),[n for n in range(Norb)]) for ud in ['up','down'] ], H_Local = Hamiltonian, Quantum_Numbers = Quantum_Numbers ) self.N_Cycles = 10000
def __init__(self,Beta,U_interact,J_Hund) : GFstruct = [ ('1up',[1]), ('1down',[1]), ('23up',[1,2]), ('23down',[1,2]) ] # NB : the Hamiltonian should NOT contain the quadratic part which is in G0 #Hamiltonian = U_interact * Sum( [ N('%d-up'%(i+1),1)*N('%d-down'%(i+1),1) for i in range(3) ] ) Hamiltonian = U_interact * ( N('1up',1)*N('1down',1) + N('23up',1)*N('23down',1) + N('23up',2)*N('23down',2) ) Hamiltonian += (U_interact-2.0*J_Hund) * ( N('1up',1) * (N('23down',1)+N('23down',2)) + N('23up',1) * N('23down',2) ) Hamiltonian += (U_interact-2.0*J_Hund) * ( N('1down',1) * (N('23up',1)+N('23up',2)) + N('23up',2) * N('23down',1) ) for s in ['up','down']: Hamiltonian += (U_interact-3.0*J_Hund) * (N('1%s'%s,1) * (N('23%s'%s,1)+N('23%s'%s,2)) + N('23%s'%s,1)*N('23%s'%s,2) ) # for i in range(2): # for j in range(i+1,3): # Hamiltonian += (U_interact-2*J_Hund) * ( N('%d-up'%(i+1),1) * N('%d-down'%(j+1),1) + # N('%d-down'%(i+1),1) * N('%d-up'%(j+1),1) ) + \ # (U_interact-3*J_Hund) * ( N('%d-up'%(i+1),1) * N('%d-up'%(j+1),1) + # N('%d-down'%(i+1),1) * N('%d-down'%(j+1),1) ) # Quantum_Numbers = { 'N1up' : N('1-up',1), 'N1down' : N('1-down',1), # 'N2up' : N('2-up',1), 'N2down' : N('2-down',1), # 'N3up' : N('3-up',1), 'N3down' : N('3-down',1) } Quantum_Numbers = { 'N1up' : N('1up',1), 'N1down' : N('1down',1), 'N23up' : N('23up',1)+N('23up',2), 'N23down' : N('23down',1)+N('23down',2) } Solver.__init__(self, Beta = Beta, GFstruct = GFstruct, H_Local = Hamiltonian, Quantum_Numbers = Quantum_Numbers ) self.N_Cycles = 10000
def __init__(self,Beta,U_interact) : self.P = numpy.array([[1,1,1,1], [1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]])/2. self.Pinv = numpy.linalg.inv(self.P) def Cdiag(s): s= '-%s'%s return [ C('00'+s,1), C('10'+s,1), C('01'+s,1),C('11'+s,1) ] Cnat,Nnat={},{} for i in range(4) : s= 'up-%d'%(i+1) Cnat[s] = Sum( [ self.P[i,j]*c for j,c in enumerate(Cdiag('up'))] ) Nnat[s] = Cnat[s].dagger() * Cnat[s] s= 'down-%d'%(i+1) Cnat[s] = Sum( [ self.P[i,j]*c for j,c in enumerate(Cdiag('down'))] ) Nnat[s] = Cnat[s].dagger() * Cnat[s] def symm(s): s= '-%s'%s Cdag('00'+s,1).Symmetry()['kx'] = 1 Cdag('10'+s,1).Symmetry()['kx'] = -1 Cdag('01'+s,1).Symmetry()['kx'] = 1 Cdag('11'+s,1).Symmetry()['kx'] = -1 Cdag('00'+s,1).Symmetry()['ky'] = 1 Cdag('10'+s,1).Symmetry()['ky'] = 1 Cdag('01'+s,1).Symmetry()['ky'] = -1 Cdag('11'+s,1).Symmetry()['ky'] = -1 symm('up'); symm('down') # NB : the Hamiltonian should NOT contain the quadratic part which is in G0 Hamiltonian = U_interact* Sum( [ Nnat['up-%d'%(i+1)]* Nnat['down-%d'%(i+1)] for i in range (4)]) N_u = Sum( [ Nnat['up-%d'%(i+1)] for i in range(4) ] ) N_d = Sum( [ Nnat['down-%d'%(i+1)] for i in range(4) ] ) Quantum_Numbers = { 'kx' : 'kx', 'ky' : 'ky', 'N_u' : N_u, 'N_d' : N_d } Solver.__init__(self, Beta = Beta, GFstruct = [ ('00-up',[1]), ('10-up',[1]), ('01-up',[1]), ('11-up',[1]), ('00-down',[1]), ('10-down',[1]), ('01-down',[1]), ('11-down',[1]) ], H_Local = Hamiltonian, Quantum_Numbers = Quantum_Numbers, Nmax = 2000) self.N_Cycles = 100000 self.N_Frequencies_Accumulated = 4*int(0.075*Beta/(2*3.1415)) self.Fitting_Frequency_Start = 3*int(0.075*Beta/(2*3.1415)) self.Length_Cycle = 100 self.Nmax_Matrix = 200 self.Use_Segment_Picture = False
def __init__(self,Beta,U_interact) : Hamiltonian = U_interact*( N('1-up',1)*N('1-down',1) + N('1-up',1)*N('2-up',1) + N('1-up',1)*N('2-down',1) + N('1-down',1)*N('2-up',1) + N('1-down',1)*N('2-down',1) + N('2-up',1)*N('2-down',1) ) Quantum_Numbers = { 'Nup' : N('1-up',1)+N('2-up',1), 'Ndown' : N('1-down',1)+N('2-down',1), 'Lz' : N('1-up',1)+N('1-down',1)-N('2-up',1)-N('2-down',1) } Solver.__init__(self, Beta = Beta, GFstruct = [ ('1-up',[1]), ('1-down',[1]), ('2-up',[1]), ('2-down',[1]) ], H_Local = Hamiltonian, Quantum_Numbers = Quantum_Numbers ) self.N_Cycles = 1000000 self.Nmax_Matrix = 300
def __init__(self,Beta,U_interact) : self.P = numpy.array([[1,1,1,1], [1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]])/2. self.Pinv = numpy.linalg.inv(self.P) def Cdiag(s): s= '-%s'%s return [ C('00'+s,1), C('10'+s,1), C('01'+s,1),C('11'+s,1) ] Cnat,Nnat={},{} for i in range(4) : s= 'up-%d'%(i+1) Cnat[s] = Sum( [ self.P[i,j]*c for j,c in enumerate(Cdiag('up'))] ) Nnat[s] = Cnat[s].dagger() * Cnat[s] s= 'down-%d'%(i+1) Cnat[s] = Sum( [ self.P[i,j]*c for j,c in enumerate(Cdiag('down'))] ) Nnat[s] = Cnat[s].dagger() * Cnat[s] def symm(s): s= '-%s'%s Cdag('00'+s,1).Symmetry()['kx'] = 1 Cdag('10'+s,1).Symmetry()['kx'] = -1 Cdag('01'+s,1).Symmetry()['kx'] = 1 Cdag('11'+s,1).Symmetry()['kx'] = -1 Cdag('00'+s,1).Symmetry()['ky'] = 1 Cdag('10'+s,1).Symmetry()['ky'] = 1 Cdag('01'+s,1).Symmetry()['ky'] = -1 Cdag('11'+s,1).Symmetry()['ky'] = -1 symm('up'); symm('down') # NB : the Hamiltonian should NOT contain the quadratic part which is in G0 Hamiltonian = U_interact* Sum( [ Nnat['up-%d'%(i+1)]* Nnat['down-%d'%(i+1)] for i in range (4)]) #!! N_u = Sum( [ Nnat['up-%d'%(i+1)] for i in range(4) ] ) N_d = Sum( [ Nnat['down-%d'%(i+1)] for i in range(4) ] ) Quantum_Numbers = { 'kx' : 'kx', 'ky' : 'ky', 'N_u' : N_u, 'N_d' : N_d } Solver.__init__(self,Beta=Beta,GFstruct=[ ('00-up',[1]), ('10-up',[1]), ('01-up',[1]), ('11-up',[1]), ('00-down',[1]), ('10-down',[1]), ('01-down',[1]), ('11-down',[1]) ], H_Local = Hamiltonian,Quantum_Numbers= Quantum_Numbers ) self.N_Cycles = 10
def __init__(self,Beta,U_interact) : C_up_1 = (C('Up+',1) + C('Up-',1))/sqrt(2) C_up_2 = (C('Up+',1) - C('Up-',1))/sqrt(2) C_do_1 = (C('Do+',1) + C('Do-',1))/sqrt(2) C_do_2 = (C('Do+',1) - C('Do-',1))/sqrt(2) Cdag('Up+',1).Symmetry()['parity'] = 1 Cdag('Up-',1).Symmetry()['parity'] = -1 Cdag('Do+',1).Symmetry()['parity'] = 1 Cdag('Do-',1).Symmetry()['parity'] = -1 N_up_1 = C_up_1.dagger()*C_up_1 N_up_2 = C_up_2.dagger()*C_up_2 N_do_1 = C_do_1.dagger()*C_do_1 N_do_2 = C_do_2.dagger()*C_do_2 # NB : the Hamiltonian should NOT contain the quadratic part which is in G0 Hamiltonian = U_interact * ( N_up_1*N_do_1 + N_up_2*N_do_2 ) N_u = N('Up-',1)+N('Up+',1) N_d = N('Do-',1)+N('Do+',1) Quantum_Numbers = { 'parity' : 'parity', 'N_u' : N_u, 'N_d' : N_d } Solver.__init__(self, Beta = Beta, GFstruct = [ ('Up+',[1]), ('Up-',[1]), ('Do+',[1]), ('Do-',[1]) ], H_Local = Hamiltonian, Quantum_Numbers = Quantum_Numbers, Nmax = 2000) self.N_Cycles = 100000 self.N_Frequencies_Accumulated = 4*int(0.075*Beta/(2*3.1415)) self.Fitting_Frequency_Start = 3*int(0.075*Beta/(2*3.1415)) self.Length_Cycle = 100 self.Nmax_Matrix = 200 self.Use_Segment_Picture = False
e_f, Beta = -U / 2.0, 50 # The impurity solver S = Solver( Beta=Beta, # inverse temperature GFstruct=[('up', [1]), ('down', [1])], # Structure of the Green's function H_Local=U * N('up', 1) * N('down', 1), # Local Hamiltonian Quantum_Numbers={ # Quantum Numbers 'Nup': N('up', 1), # (operators commuting with H_Local) 'Ndown': N('down', 1) }, N_Cycles=500000, # Number of QMC cycles Length_Cycle=200, # Length of one cycle N_Warmup_Cycles=10000, # Warmup cycles N_Legendre_Coeffs=50, # Number of Legendre coefficients Random_Generator_Name='mt19937', # Name of the random number generator Use_Segment_Picture=True, # Use the segment picture Measured_Operators={ # Operators to be averaged 'Nimp': N('up', 1) + N('down', 1) }, Global_Moves=[ # Global move in the QMC (0.05, lambda (a, alpha, dag): ({ 'up': 'down', 'down': 'up' }[a], alpha, dag)) ], ) # Initialize the non-interacting Green's function S.G0 for spin, g0 in S.G0:
Chemical_Potential = U / 2.0 Beta = 100 # Construct a CTQMC solver from pytriqs.Solvers.Operators import * # imports the class manipulating C, C_dagger and N = C_dagger C from pytriqs.Solvers.HybridizationExpansion import Solver # imports the solver class S = Solver( Beta=Beta, # inverse temperature GFstruct=[('up', [1]), ('down', [1])], # Structure of the Green function H_Local=U * N('up', 1) * N('down', 1), # Local Hamiltonian Quantum_Numbers={ 'Nup': N('up', 1), 'Ndown': N('down', 1) }, # Quantum Numbers (operators commuting with H_Local) N_Cycles= 5000, #200000, # Number of QMC cycles Length_Cycle=500, N_Warmup_Cycles=5000, N_Time_Slices_Delta=10000, N_Time_Slices_Gtau=1000, Random_Generator_Name="", N_Legendre_Coeffs=30, #Random_Generator_Name = "mt19937", Use_Segment_Picture=True) #S.Proba_Move = 0.0 #S.Global_Moves = [ (0.01, lambda (a,alpha,dag) : (a, alpha, dag)), # (0.01, lambda (a,alpha,dag) : ({'up' : 'down', 'down' : 'up'}[a], alpha, dag)) ] # init the Green function #S.G <<= GF_Initializers.SemiCircular(Half_Bandwidth)
def __init__(self, Beta, Norb, U_interact=None, J_Hund=None, GFStruct=False, map=False, use_spinflip=False, useMatrix=True, l=2, T=None, dimreps=None, irep=None, deg_orbs=[], Sl_Int=None): self.offset = 0 self.use_spinflip = use_spinflip self.Norb = Norb if (useMatrix): if not (Sl_Int is None): Umat = Umatrix(l=l) assert len(Sl_Int) == (l + 1), "Sl_Int has the wrong length" if (type(Sl_Int) == ListType): Rcl = numpy.array(Sl_Int) else: Rcl = Sl_Int Umat(T=T, Rcl=Rcl) else: if ((U_interact == None) and (J_Hund == None)): MPI.report("Give U,J or Slater integrals!!!") assert 0 Umat = Umatrix(U_interact=U_interact, J_Hund=J_Hund, l=l) Umat(T=T) Umat.ReduceMatrix() if (Umat.N == Umat.Nmat): # Transformation T is of size 2l+1 self.U = Umat.U self.Up = Umat.Up else: # Transformation is of size 2(2l+1) self.U = Umat.U # now we have the reduced matrices U and Up, we need it for tail fitting anyways if (use_spinflip): #Take the 4index Umatrix # check for imaginary matrix elements: if (abs(Umat.Ufull.imag) > 0.0001).any(): MPI.report( "WARNING: complex interaction matrix!! Ignoring imaginary part for the moment!" ) MPI.report( "If you want to change this, look into Wien2k/Solver_MultiBand.py" ) self.U4ind = Umat.Ufull.real # this will be changed for arbitrary irep: # use only one subgroup of orbitals? if not (irep is None): #print irep, dimreps assert not (dimreps is None ), "Dimensions of the representatives are missing!" assert Norb == dimreps[ irep - 1], "Dimensions of dimrep and Norb do not fit!" for ii in range(irep - 1): self.offset += dimreps[ii] else: if ((U_interact == None) and (J_Hund == None)): MPI.report("For Kanamori representation, give U and J!!") assert 0 self.U = numpy.zeros([Norb, Norb], numpy.float_) self.Up = numpy.zeros([Norb, Norb], numpy.float_) for i in range(Norb): for j in range(Norb): if (i == j): self.Up[i, i] = U_interact + 2.0 * J_Hund else: self.Up[i, j] = U_interact self.U[i, j] = U_interact - J_Hund if (GFStruct): assert map, "give also the mapping!" self.map = map else: # standard GFStruct and map GFStruct = [('%s' % (ud), [n for n in range(Norb)]) for ud in ['up', 'down']] self.map = { 'up': ['up' for v in range(self.Norb)], 'down': ['down' for v in range(self.Norb)] } #print GFStruct,self.map if (use_spinflip == False): Hamiltonian = self.__setHamiltonian_density() else: if (useMatrix): Hamiltonian = self.__setfullHamiltonian_Slater() else: Hamiltonian = self.__setfullHamiltonian_Kanamori(J_Hund=J_Hund) Quantum_Numbers = self.__setQuantumNumbers(GFStruct) # Determine if there are only blocs of size 1: self.blocssizeone = True for ib in GFStruct: if (len(ib[1]) > 1): self.blocssizeone = False # now initialize the solver with the stuff given above: Solver.__init__(self, Beta=Beta, GFstruct=GFStruct, H_Local=Hamiltonian, Quantum_Numbers=Quantum_Numbers) #self.SetGlobalMoves(deg_orbs) self.N_Cycles = 10000 self.Nmax_Matrix = 100 self.N_Time_Slices_Delta = 10000 #if ((len(GFStruct)==2*Norb) and (use_spinflip==False)): if ((self.blocssizeone) and (use_spinflip == False)): self.Use_Segment_Picture = True else: self.Use_Segment_Picture = False
U = 2.5 Chemical_Potential = U / 2.0 Beta = 100 N_loops = 5 # Construct a CTQMC solver from pytriqs.Solvers.Operators import * # imports the class manipulating C, C_dagger and N = C_dagger C from pytriqs.Solvers.HybridizationExpansion import Solver # imports the solver class S = Solver( Beta=Beta, # inverse temperature GFstruct=[('up', [1]), ('down', [1])], # Structure of the Green function H_Local=U * N('up', 1) * N('down', 1), # Local Hamiltonian Quantum_Numbers={ 'Nup': N('up', 1), 'Ndown': N('down', 1) }, # Quantum Numbers (operators commuting with H_Local) N_Cycles=5000, # Number of QMC cycles Length_Cycle=200, # Length of a cycle N_Warmup_Cycles=1000, # How many warmup cycles N_Legendre_Coeffs=30, # Use 30 Legendre coefficients to represent G(tau) Random_Generator_Name= "mt19937", # Use the Mersenne Twister 19937 random generator Use_Segment_Picture=True) # Here we can use the segment picture # Initalize the Green's function to a semi circular S.G <<= SemiCircular(Half_Bandwidth) # Now do the DMFT loop for IterationNumber in range(N_loops): # Compute S.G0 with the self-consistency condition while imposing paramagnetism
def __init__(self, Beta, Norb, U_interact=None, J_Hund=None, GFStruct=False, map=False, use_spinflip=False, useMatrix = True, l=2, T=None, dimreps=None, irep=None, deg_orbs = [], Sl_Int = None): self.offset = 0 self.use_spinflip = use_spinflip self.Norb = Norb if (useMatrix): if not (Sl_Int is None): Umat = Umatrix(l=l) assert len(Sl_Int)==(l+1),"Sl_Int has the wrong length" if (type(Sl_Int)==ListType): Rcl = numpy.array(Sl_Int) else: Rcl = Sl_Int Umat(T=T,Rcl=Rcl) else: if ((U_interact==None)and(J_Hund==None)): MPI.report("Give U,J or Slater integrals!!!") assert 0 Umat = Umatrix(U_interact=U_interact, J_Hund=J_Hund, l=l) Umat(T=T) Umat.ReduceMatrix() if (Umat.N==Umat.Nmat): # Transformation T is of size 2l+1 self.U = Umat.U self.Up = Umat.Up else: # Transformation is of size 2(2l+1) self.U = Umat.U # now we have the reduced matrices U and Up, we need it for tail fitting anyways if (use_spinflip): #Take the 4index Umatrix # check for imaginary matrix elements: if (abs(Umat.Ufull.imag)>0.0001).any(): MPI.report("WARNING: complex interaction matrix!! Ignoring imaginary part for the moment!") MPI.report("If you want to change this, look into Wien2k/Solver_MultiBand.py") self.U4ind = Umat.Ufull.real # this will be changed for arbitrary irep: # use only one subgroup of orbitals? if not (irep is None): #print irep, dimreps assert not (dimreps is None), "Dimensions of the representatives are missing!" assert Norb==dimreps[irep-1],"Dimensions of dimrep and Norb do not fit!" for ii in range(irep-1): self.offset += dimreps[ii] else: if ((U_interact==None)and(J_Hund==None)): MPI.report("For Kanamori representation, give U and J!!") assert 0 self.U = numpy.zeros([Norb,Norb],numpy.float_) self.Up = numpy.zeros([Norb,Norb],numpy.float_) for i in range(Norb): for j in range(Norb): if (i==j): self.Up[i,i] = U_interact + 2.0*J_Hund else: self.Up[i,j] = U_interact self.U[i,j] = U_interact - J_Hund if (GFStruct): assert map, "give also the mapping!" self.map = map else: # standard GFStruct and map GFStruct = [ ('%s'%(ud),[n for n in range(Norb)]) for ud in ['up','down'] ] self.map = {'up' : ['up' for v in range(self.Norb)], 'down' : ['down' for v in range(self.Norb)]} #print GFStruct,self.map if (use_spinflip==False): Hamiltonian = self.__setHamiltonian_density() else: if (useMatrix): Hamiltonian = self.__setfullHamiltonian_Slater() else: Hamiltonian = self.__setfullHamiltonian_Kanamori(J_Hund = J_Hund) Quantum_Numbers = self.__setQuantumNumbers(GFStruct) # Determine if there are only blocs of size 1: self.blocssizeone = True for ib in GFStruct: if (len(ib[1])>1): self.blocssizeone = False # now initialize the solver with the stuff given above: Solver.__init__(self, Beta = Beta, GFstruct = GFStruct, H_Local = Hamiltonian, Quantum_Numbers = Quantum_Numbers ) #self.SetGlobalMoves(deg_orbs) self.N_Cycles = 10000 self.Nmax_Matrix = 100 self.N_Time_Slices_Delta= 10000 #if ((len(GFStruct)==2*Norb) and (use_spinflip==False)): if ((self.blocssizeone) and (use_spinflip==False)): self.Use_Segment_Picture = True else: self.Use_Segment_Picture = False
from pytriqs.Base.GF_Local import * from pytriqs.Solvers.Operators import * from pytriqs.Solvers.HybridizationExpansion import Solver D, V, U = 1.0, 0.2, 4.0 e_f, Beta = -U/2.0, 50 # The impurity solver S = Solver(Beta = Beta, # inverse temperature GFstruct = [ ('up',[1]), ('down',[1]) ], # Structure of the Green's function H_Local = U * N('up',1) * N('down',1), # Local Hamiltonian Quantum_Numbers = { # Quantum Numbers 'Nup' : N('up',1), # (operators commuting with H_Local) 'Ndown' : N('down',1) }, N_Cycles = 100000, # Number of QMC cycles Length_Cycle = 200, # Length of one cycle N_Warmup_Iteration = 10000, # Warmup cycles Use_Segment_Picture = True, # Use the segment picture Global_Moves = [ # Global move in the QMC (0.05, lambda (a,alpha,dag) : ( {'up':'down','down':'up'}[a],alpha,dag ) ) ], ) from pytriqs.Base.Archive import HDF_Archive import pytriqs.Base.Utility.MPI as MPI for random_name in ['mt11213b','lagged_fibonacci607']: # Solve using random_name as a generator S.Random_Generator_Name = random_name for spin, g0 in S.G0 : g0 <<= inverse( iOmega_n - e_f - V**2 * Wilson(D) )