def solve(self, U_interact=None, J_hund=None, use_spinflip=False, use_matrix = True, l=2, T=None, dim_reps=None, irep=None, deg_orbs = [], sl_int = None, **params): self.use_spinflip = use_spinflip self.U, self.Up, self.U4ind, self.offset = set_U_matrix(U_interact,J_hund,self.n_orb,l,use_matrix,T,sl_int,use_spinflip,dim_reps,irep) # define mapping of indices: self.map_ind={} for nm in self.map: bl_names = self.map[nm] block = [] for a,al in self.gf_struct: if a in bl_names: block.append(al) self.map_ind[nm] = range(self.n_orb) i = 0 for al in block: cnt = 0 for a in range(len(al)): self.map_ind[nm][i] = cnt i = i+1 cnt = cnt+1 # set the Hamiltonian if (use_spinflip==False): Hamiltonian = self.__set_hamiltonian_density() else: if (use_matrix): #Hamiltonian = self.__set_full_hamiltonian_slater() Hamiltonian = self.__set_spinflip_hamiltonian_slater() else: Hamiltonian = self.__set_full_hamiltonian_kanamori(J_hund = J_hund) # set the Quantum numbers Quantum_Numbers = self.__set_quantum_numbers(self.gf_struct) # Determine if there are only blocs of size 1: self.blocssizeone = True for ib in self.gf_struct: if (len(ib[1])>1): self.blocssizeone = False nc = params.pop("n_cycles",10000) if ((self.blocssizeone) and (self.use_spinflip==False)): use_seg = True else: use_seg = False #gm = self.set_global_moves(deg_orbs) Solver.solve(self,H_local = Hamiltonian, quantum_numbers = Quantum_Numbers, n_cycles = nc, use_segment_picture = use_seg, **params)
S.G <<= SemiCircular(Half_Bandwidth) # Impose Paramagnetism g = 0.5*(S.G['up']+S.G['down']) for name, bloc in S.G : bloc <<= g # Compute G0 for sig,g0 in S.G0 : g0 <<= inverse( iOmega_n + Chemical_Potential - (Half_Bandwidth/2.0)**2 * S.G[sig] ) # Solve #from pytriqs.applications.impurity_solvers.operators import * from pytriqs.operators import * S.solve(H_local = U * N('up',1) * N('down',1), quantum_numbers = { 'Nup' : N('up',1), 'Ndown' : N('down',1) }, n_cycles = 5000, length_cycle = 500, n_warmup_cycles = 5000, n_tau_delta = 10000, n_tau_g = 1000, random_name = "", n_legendre = 30, use_segment_picture = True) # Calculation is done. Now save a few things # Save into the shelve Results = HDFArchive("single_site_bethe.output.h5",'w') Results["G"] = S.G Results["Gl"] = S.G_legendre
# Construct the impurity solver with the inverse temperature # and the structure of the Green's functions S = Solver(beta = beta, gf_struct = [ ('up',[1]), ('down',[1]) ]) # Initialize the non-interacting Green's function S.G0 for spin, g0 in S.G0 : g0 <<= inverse( iOmega_n - e_f - V**2 * Wilson(D) ) # Run the solver. The result will be in S.G S.solve(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 = 50, # Number of Legendre coefficients random_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) } ) # Save the results in an hdf5 file (only on the master node) from pytriqs.archive import HDFArchive import pytriqs.utility.mpi as mpi if mpi.is_master_node(): Results = HDFArchive("solution.h5",'w') Results["G"] = S.G Results["Gl"] = S.G_legendre
D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U / 2.0, 50 # Construct the impurity solver S = Solver(beta=beta, gf_struct=[('up', [1]), ('down', [1])]) # Loop for two random generators for random_name in ['mt11213b', 'lagged_fibonacci607']: for spin, g0 in S.G0: g0 <<= inverse(iOmega_n - e_f - V**2 * Wilson(D)) # Solve using random_name as a generator S.solve( 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_cycles=10000, # Warmup cycles random_name=random_name, # Name of the random generator use_segment_picture=True) # Use the segment picture # Save the results in an hdf5 file (only on the master node) if mpi.is_master_node(): Results = HDFArchive("random.h5") Results["G_%s" % (random_name)] = S.G del Results
# Now do the DMFT loop for IterationNumber in range(n_loops): # Compute S.G0 with the self-consistency condition while imposing paramagnetism g = 0.5 * (S.G['up'] + S.G['down']) for name, g0block in S.G0: g0block <<= inverse(iOmega_n + chemical_potential - (half_bandwidth / 2.0)**2 * g) # Run the solver S.solve( 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=30, # Use 30 Legendre coefficients to represent G(tau) random_name="mt19937", # Use the Mersenne Twister 19937 random generator use_segment_picture=True) # Here we can use the segment picture # Some intermediate saves if mpi.is_master_node(): R = HDFArchive("single_site_bethe.h5") R["G-%s" % IterationNumber] = S.G del R # Here we would usually write some convergence test # if Converged : break
for n2 in range(n1+1, SPINS*NCOR): f1 = n1 / SPINS; sp1 = spins[n1 % SPINS]; f2 = n2 / SPINS; sp2 = spins[n2 % SPINS]; Measured_Operators['nn_%d_%d'%(n2,n1)] = N('%s%d'%(sp1, f1), 0) * N('%s%d'%(sp2, f2), 0); solver_parms['measured_operators'] = Measured_Operators; solver_parms['measured_time_correlators'] = {} if int(val_def(parms, 'MEASURE', 0)) > 0: if 'Sztot' in Quantum_Numbers: solver_parms['measured_time_correlators'] = { 'Sztot' : [ Quantum_Numbers['Sztot'], 300 ] } # run solver solver.solve(**solver_parms); # save data NfileMax = 100; if mpi.is_master_node(): R = HDFArchive(parms['HDF5_OUTPUT'], 'w'); if accumulation == 'legendre': for s, gl in solver.G_legendre: solver.G[s] <<= LegendreToMatsubara(gl); R['G_Legendre'] = solver.G_legendre; Gl_out = None; for f in range(NCOR): for sp in spins: tmp = solver.G_legendre['%s%d'%(sp, f)]._data.array[0, 0, :]; Gl_out = tmp if Gl_out is None else c_[Gl_out, tmp]; for n in range(1,NfileMax):
# Now do the DMFT loop for IterationNumber in range(n_loops): # Compute S.G0 with the self-consistency condition while imposing paramagnetism g = 0.5 * (S.G["up"] + S.G["down"]) for name, g0block in S.G0: g0block <<= inverse(iOmega_n + chemical_potential - (half_bandwidth / 2.0) ** 2 * g) # Run the solver S.solve( 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=30, # Use 30 Legendre coefficients to represent G(tau) random_name="mt19937", # Use the Mersenne Twister 19937 random generator use_segment_picture=True, ) # Here we can use the segment picture # Some intermediate saves if mpi.is_master_node(): R = HDFArchive("single_site_bethe.h5") R["G-%s" % IterationNumber] = S.G del R # Here we would usually write some convergence test # if Converged : break
import pytriqs.utility.mpi as mpi D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U/2.0, 50 # Construct the impurity solver S = Solver(beta = beta, gf_struct = [ ('up',[1]), ('down',[1]) ]) # Loop for two random generators for random_name in ['mt11213b','lagged_fibonacci607']: for spin, g0 in S.G0 : g0 <<= inverse( iOmega_n - e_f - V**2 * Wilson(D) ) # Solve using random_name as a generator S.solve(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_cycles = 10000, # Warmup cycles random_name = random_name, # Name of the random generator use_segment_picture = True) # Use the segment picture # Save the results in an hdf5 file (only on the master node) if mpi.is_master_node(): Results = HDFArchive("random.h5") Results["G_%s"%(random_name)] = S.G del Results
for name, bloc in S.G: bloc <<= g # Compute G0 for sig, g0 in S.G0: g0 <<= inverse(iOmega_n + Chemical_Potential - (Half_Bandwidth / 2.0)**2 * S.G[sig]) # Solve #from pytriqs.applications.impurity_solvers.operators import * from pytriqs.operators import * S.solve(H_local=U * N('up', 1) * N('down', 1), quantum_numbers={ 'Nup': N('up', 1), 'Ndown': N('down', 1) }, n_cycles=5000, length_cycle=500, n_warmup_cycles=5000, n_tau_delta=10000, n_tau_g=1000, random_name="", n_legendre=30, use_segment_picture=True) # Calculation is done. Now save a few things # Save into the shelve Results = HDFArchive("single_site_bethe.output.h5", 'w') Results["G"] = S.G Results["Gl"] = S.G_legendre
# Initialize the non-interacting Green's function S.G0 for spin, g0 in S.G0: g0 <<= inverse(iOmega_n - e_f - V**2 * Wilson(D)) # run the solver. The result will be in S.G S.solve( 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=20000, # Number of QMC cycles length_cycle=20, # Length of one cycle n_warmup_cycles=1000, # Warmup cycles n_legendre=50, # Number of Legendre coefficients random_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=[(0.05, lambda (a, alpha, dag): ({ 'up': 'down', 'down': 'up' }[a], alpha, dag))]) # Save the results in an hdf5 file (only on the master node) from pytriqs.archive import HDFArchive import pytriqs.utility.mpi as mpi if mpi.is_master_node():