def SIAM(U, e_f, V, D, beta, filename="qmc_results.h5"): Delta = V**2 * Flat(D) N_MC = 1e5 l_max = 10 independent_samples = 16 for l in range(l_max + 1): for i in range(independent_samples): S = Solver(beta=beta, gf_struct={'up': [0], 'down': [0]}) # Initialize the non-interacting Green's function S.G0_iw for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - Delta) # Run the solver. The results will be in S.G_tau, S.G_iw and S.G_l S.solve( h_int=U * n('up', 0) * n('down', 0), # Local Hamiltonian n_cycles=int(N_MC / 2**l), # Number of QMC cycles length_cycle=2**l, # Length of one cycle n_warmup_cycles=int(N_MC / 2**l / 100), # Warmup cycles measure_g_tau=False, # Don't measure G_tau measure_g_l=False, # Don't measure G_l perform_post_proc=False, # Don't measure G_iw use_norm_as_weight= True, # Necessary option for the measurement of the density matrix measure_density_matrix= True, # Measure reduced impurity density matrix random_seed=i * 8521 + l * 14187 + mpi.rank * 7472) # Random seed, very important! # Save the results in an HDF5 file (only on the master node) if mpi.is_master_node(): with HDFArchive(filename) as Results: Results["rho_l{}_i{}".format(l, i)] = S.density_matrix
def SIAM(U, e_f, V, D, beta, filename="qmc_results.h5"): # Create hybridization function Delta = V**2 * Flat(D) # Construct the impurity solver with the inverse temperature # and the structure of the Green's functions S = Solver(beta=beta, gf_struct={'up': [0], 'down': [0]}, n_l=50) # Initialize the non-interacting Green's function S.G0_iw for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - Delta) # Run the solver. The results will be in S.G_tau, S.G_iw and S.G_l S.solve( h_int=U * n('up', 0) * n('down', 0), # Local Hamiltonian n_cycles=2000000, # Number of QMC cycles length_cycle=50, # Length of one cycle n_warmup_cycles=20000, # Warmup cycles measure_g_l= True, # Measure G_l (representation of G in terms of Legendre polynomials) use_norm_as_weight= True, # Necessary option for the measurement of the density matrix measure_density_matrix=True, # Measure reduced impurity density matrix measure_pert_order=True) # Measure histogram of k # Save the results in an HDF5 file (only on the master node) if mpi.is_master_node(): with HDFArchive(filename, 'w') as Results: Results["G_tau"] = S.G_tau Results["G_iw"] = S.G_iw Results["G_l"] = S.G_l Results["rho"] = S.density_matrix Results["k_histogram"] = S.perturbation_order_total Results["average_sign"] = S.average_sign
def DMFT(U, e_d, t, beta, filename="dmft_results.h5"): # Construct the CT-HYB-QMC solver S = Solver(beta=beta, gf_struct={'up': [0], 'down': [0]}, n_l=50) # Initialize Delta Delta = GfImFreq(beta=beta, indices=[0]) Delta << t**2 * SemiCircular(half_bandwidth=2 * t) # Now do the DMFT loop n_iter = 8 for iter in range(n_iter): # Compute new S.G0_iw for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_d - Delta) # Run the solver S.solve( h_int=U * n('up', 0) * n('down', 0), # Local Hamiltonian n_cycles=200000, # Number of QMC cycles length_cycle=50, # Length of a cycle n_warmup_cycles=2000, # How many warmup cycles measure_g_l=True) # Compute new Delta with the self-consistency condition while imposing paramagnetism g_l = (S.G_l['up'] + S.G_l['down']) / 2. Delta.set_from_legendre(t**2 * g_l) # Intermediate saves if mpi.is_master_node(): with HDFArchive(filename) as Results: Results["G_tau_iter{}".format(iter)] = S.G_tau Results["G_iw_iter{}".format(iter)] = S.G_iw Results["G_l_iter{}".format(iter)] = S.G_l Results["Sigma_iter{}".format(iter)] = S.Sigma_iw if mpi.is_master_node(): with HDFArchive(filename) as Results: Results["G_tau"] = S.G_tau Results["G_iw"] = S.G_iw Results["G_l"] = S.G_l Results["Sigma"] = S.Sigma_iw
S = Solver(beta=beta, gf_struct=[['up', [0]], ['down', [0]]]) # Initalize the Green's function to a semi circular DOS S.G_iw << SemiCircular(half_bandwidth) # Now do the DMFT loop for i_loop in range(n_loops): # Compute new S.G0_iw with the self-consistency condition while imposing paramagnetism g = 0.5 * (S.G_iw['up'] + S.G_iw['down']) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + chemical_potential - (half_bandwidth / 2.0)**2 * g) # Run the solver S.solve( h_int=U * n('up', 0) * n('down', 0), # Local Hamiltonian n_cycles=5000, # Number of QMC cycles length_cycle=200, # Length of a cycle n_warmup_cycles=1000) # How many warmup cycles # Some intermediate saves if mpi.is_master_node(): with HDFArchive("dmft_solution.h5") as ar: ar["G_tau-%s" % i_loop] = S.G_tau ar["G_iw-%s" % i_loop] = S.G_iw ar["Sigma_iw-%s" % i_loop] = S.Sigma_iw # Here we could write some convergence test # if converged : break
logfname) WriteMatrix(Gzero_tail2_D, p.bands_T, 'D', p.offdiag, logfname) PrintAndWrite('G0(iw) tail fit: 1 / iw^3 (+)', logfname) WriteMatrix(Gzero_tail3_D, p.bands_T, 'D', p.offdiag, logfname) PrintAndWrite('G0(iw) tail fit: 1 / iw^4 (+)', logfname) WriteMatrix(Gzero_tail4_D, p.bands_T, 'D', p.offdiag, logfname) if p.measure_Gleg: PrintAndWrite('Measuring G(L).', logfname) if p.measure_Gtau: PrintAndWrite('Measuring G(tau).', logfname) # run the solver #################################################### t = time() for num_bin in range(p.PrevBins, p.PrevBins + p.NBins): p_D['random_name'] = '' p_D['random_seed'] = randint(0, 128) * mpi.rank + 567 * int(time()) S.solve(**p_D) mpi.barrier() if mpi.is_master_node(): # processing output from solver # processing the Legendre GF #################################### if p.measure_Gleg: [Gl_iw,Sl_iw,Sl_w0_D,Sl_hf_D,nl_D,ntot_leg] = \ ProcessTriqsOut(S.G0_iw,S.G_l,p.offdiag,p.NBand,FitMin,FitMax,6,p.bands_T,p.equiv_F,'leg',p.SymmS,p.SymmG,logfname) # processing the imaginary time GF ############################## if p.measure_Gtau: [Gtau_iw,Stau_iw,Stau_w0_D,Stau_hf_D,ntau_D,ntot_tau] = \ ProcessTriqsOut(S.G0_iw,S.G_tau,p.offdiag,p.NBand,FitMin,FitMax,6,p.bands_T,p.equiv_F,'tau',p.SymmS,p.SymmG,logfname) if p.NBins > 1: PrintAndWrite( 'Binning mode, bin ' + str(num_bin + 1) + '/' + str(p.PrevBins + p.NBins), logfname)
# This is a first guess for G S.G0_iw << inverse(iOmega_n + mu - t**2 * SemiCircular(2 * t)) # DMFT loop with self-consistency for i in range(n_loops): print "\n\nIteration = %i / %i" % (i + 1, n_loops) # Symmetrize the Green's function and use self-consistency if i > 0: g = 0.25 * (S.G_iw['up-0'] + S.G_iw['up-1'] + S.G_iw['down-0'] + S.G_iw['down-1']) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - t**2 * g) # Solve the impurity problem S.solve(h_int=h_int, n_cycles=30000, length_cycle=100, n_warmup_cycles=5000) # Check density for name, g in S.G_iw: print name, ": ", g.density()[0, 0].real # Save iteration in archive with HDFArchive("results_two_bands/%s-U%.2f-J%.2f.h5" % (filling, U, J)) as A: A['G-%i' % i] = S.G_iw A['Sigma-%i' % i] = S.Sigma_iw
# Construct the solver S = Solver(beta=beta, gf_struct=gf_struct) # Set the hybridization function and G0_iw for the Bethe lattice delta_iw = GfImFreq(indices=[0], beta=beta) delta_iw << (half_bandwidth / 2.0)**2 * SemiCircular(half_bandwidth) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - delta_iw) # Now start the DMFT loops for i_loop in range(n_loop): # Determine the new Weiss field G0_iw self-consistently if i_loop > 0: g_iw = GfImFreq(indices=[0], beta=beta) # Impose paramagnetism for name, g in S.G_tau: g_iw << g_iw + (0.5 / n_orbs) * Fourier(g) # Compute S.G0_iw with the self-consistency condition for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - (half_bandwidth / 2.0)**2 * g_iw) # Solve the impurity problem for the given interacting Hamiltonian and set of parameters S.solve(h_int=H, **p) # Save quantities of interest on the master node to an h5 archive if mpi.is_master_node(): with HDFArchive(filename, 'a') as Results: Results['G0_iw-%s' % i_loop] = S.G0_iw Results['G_tau-%s' % i_loop] = S.G_tau
from pytriqs.gf import * from pytriqs.operators import * from pytriqs.applications.impurity_solvers.cthyb import Solver from pytriqs.archive import HDFArchive import pytriqs.utility.mpi as mpi # Parameters D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U/2.0, 50 # Construct the impurity solver with the inverse temperature # and the structure of the Green's functions S = Solver(beta = beta, gf_struct = [ ('up',[0]), ('down',[0]) ], n_l = 100) # Initialize the non-interacting Green's function S.G0_iw for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - V**2 * Wilson(D)) # Run the solver. The results will be in S.G_tau, S.G_iw and S.G_l S.solve(h_int = U * n('up',0) * n('down',0), # Local Hamiltonian n_cycles = 500000, # Number of QMC cycles length_cycle = 200, # Length of one cycle n_warmup_cycles = 10000, # Warmup cycles measure_G_l = True) # Measure G_l # Save the results in an HDF5 file (only on the master node) if mpi.is_master_node(): with HDFArchive("aim_solution.h5",'w') as Results: Results["G_tau"] = S.G_tau Results["G_iw"] = S.G_iw Results["G_l"] = S.G_l
PrintAndWrite('G0(iw) tail fit: 1 / iw^2 (-) (local impurity levels)',logfname) WriteMatrix(Gzero_tail2_D,p.bands_T,'D',p.offdiag,logfname) PrintAndWrite('G0(iw) tail fit: 1 / iw^3 (+)',logfname) WriteMatrix(Gzero_tail3_D,p.bands_T,'D',p.offdiag,logfname) PrintAndWrite('G0(iw) tail fit: 1 / iw^4 (+)',logfname) WriteMatrix(Gzero_tail4_D,p.bands_T,'D',p.offdiag,logfname) if p.measure_Gleg: PrintAndWrite('Measuring G(L).',logfname) if p.measure_Gtau: PrintAndWrite('Measuring G(tau).',logfname) # run the solver #################################################### t = time() for num_bin in range(p.PrevBins,p.PrevBins+p.NBins): p_D['random_name'] = '' p_D['random_seed'] = randint(0,128)*mpi.rank + 567*int(time()) S.solve(**p_D) mpi.barrier() if mpi.is_master_node(): # processing output from solver # processing the Legendre GF #################################### if p.measure_Gleg: [Gl_iw,Sl_iw,Sl_w0_D,Sl_hf_D,nl_D,ntot_leg] = \ ProcessTriqsOut(S.G0_iw,S.G_l,p.offdiag,p.NBand,FitMin,FitMax,6,p.bands_T,p.equiv_F,'leg',p.SymmS,p.SymmG,logfname) # processing the imaginary time GF ############################## if p.measure_Gtau: [Gtau_iw,Stau_iw,Stau_w0_D,Stau_hf_D,ntau_D,ntot_tau] = \ ProcessTriqsOut(S.G0_iw,S.G_tau,p.offdiag,p.NBand,FitMin,FitMax,6,p.bands_T,p.equiv_F,'tau',p.SymmS,p.SymmG,logfname) if p.NBins > 1: PrintAndWrite('Binning mode, bin '+str(num_bin+1)+'/'+str(p.PrevBins+p.NBins),logfname) PrintAndWrite('{0: 3d}\t{1: .3f}'.format(num_bin+1,float(S.average_sign)),'bin_sgn.dat') if p.measure_Gleg:
H = op.h_int_slater(spin_names,orb_names,U_mat,off_diag=off_diag) # Construct the solver S = Solver(beta=beta, gf_struct=gf_struct) # Set the hybridization function and G0_iw for the Bethe lattice delta_iw = GfImFreq(indices=[0], beta=beta) delta_iw << (half_bandwidth/2.0)**2 * SemiCircular(half_bandwidth) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - delta_iw) # Now start the DMFT loops for i_loop in range(n_loop): # Determine the new Weiss field G0_iw self-consistently if i_loop > 0: g_iw = GfImFreq(indices=[0], beta=beta) # Impose paramagnetism for name, g in S.G_tau: g_iw << g_iw + (0.5/n_orbs)*Fourier(g) # Compute S.G0_iw with the self-consistency condition for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - (half_bandwidth/2.0)**2 * g_iw ) # Solve the impurity problem for the given interacting Hamiltonian and set of parameters S.solve(h_int=H, **p) # Save quantities of interest on the master node to an h5 archive if mpi.is_master_node(): with HDFArchive(filename,'a') as Results: Results['G0_iw-%s'%i_loop] = S.G0_iw Results['G_tau-%s'%i_loop] = S.G_tau
# Construct the impurity solver S = Solver(beta = beta, gf_struct = {'up':[0], 'down':[0]}) # I run for several values of U for U in np.arange(1.0, 13.0): print 'U =', U # This is a first guess for G S.G_iw << SemiCircular(2*t) # DMFT loop with self-consistency for i in range(n_loops): print "\n\nIteration = %i / %i" % (i+1, n_loops) # Symmetrize the Green's function and use self-consistency g = 0.5 * ( S.G_iw['up'] + S.G_iw['down'] ) for name, g0 in S.G0_iw: g0 << inverse( iOmega_n + U/2.0 - t**2 * g ) # Solve the impurity problem S.solve(h_int = U * n('up',0) * n('down',0), # Local Hamiltonian n_cycles = 10000, # Number of QMC cycles n_warmup_cycles = 5000, # Warmup cycles ) # Save iteration in archive with HDFArchive("results_one_band/half-U%.2f.h5"%U) as A: A['G-%i'%i] = S.G_iw A['Sigma-%i'%i] = S.Sigma_iw
beta = 50 # Inverse temperature # Construct the impurity solver with the inverse temperature # and the structure of the Green's functions S = Solver(beta = beta, gf_struct = {'up':[0], 'down':[0]}) # Initialize the non-interacting Green's function S.G0_iw # External magnetic field introduces Zeeman energy splitting between # different spin components S.G0_iw['up'] << inverse(iOmega_n - e_f + h/2 - V**2 * Wilson(D)) S.G0_iw['down'] << inverse(iOmega_n - e_f - h/2 - V**2 * Wilson(D)) # Run the solver S.solve(h_int = U * n('up',0) * n('down',0), # Local Hamiltonian n_cycles = 500000, # Number of QMC cycles length_cycle = 200, # Length of one cycle n_warmup_cycles = 10000, # Warmup cycles measure_density_matrix = True, # Measure the reduced density matrix use_norm_as_weight = True) # Required to measure the density matrix # Extract accumulated density matrix rho = S.density_matrix # Object containing eigensystem of the local Hamiltonian h_loc_diag = S.h_loc_diagonalization from pytriqs.applications.impurity_solvers.cthyb import trace_rho_op # Evaluate occupations print "<N_up> =", trace_rho_op(rho, n('up',0), h_loc_diag) print "<N_down> = ", trace_rho_op(rho, n('down',0), h_loc_diag)
from pytriqs.gf.local import * from pytriqs.operators import * from pytriqs.applications.impurity_solvers.cthyb import Solver from pytriqs.archive import HDFArchive import pytriqs.utility.mpi as mpi # Parameters D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U/2.0, 50 # Construct the impurity solver with the inverse temperature # and the structure of the Green's functions S = Solver(beta = beta, gf_struct = {'up':[0], 'down':[0]}, n_l = 100) # Initialize the non-interacting Green's function S.G0_iw for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - V**2 * Wilson(D)) # Run the solver. The results will be in S.G_tau, S.G_iw and S.G_l S.solve(h_int = U * n('up',0) * n('down',0), # Local Hamiltonian n_cycles = 500000, # Number of QMC cycles length_cycle = 200, # Length of one cycle n_warmup_cycles = 10000, # Warmup cycles measure_g_l = True) # Measure G_l # Save the results in an HDF5 file (only on the master node) if mpi.is_master_node(): with HDFArchive("aim_solution.h5",'w') as Results: Results["G_tau"] = S.G_tau Results["G_iw"] = S.G_iw Results["G_l"] = S.G_l
S = Solver(beta=beta, gf_struct={'up': [0], 'down': [0]}) # I run for several values of U for U in np.arange(1.0, 13.0): print 'U =', U # This is a first guess for G S.G_iw << SemiCircular(2 * t) # DMFT loop with self-consistency for i in range(n_loops): print "\n\nIteration = %i / %i" % (i + 1, n_loops) # Symmetrize the Green's function and use self-consistency g = 0.5 * (S.G_iw['up'] + S.G_iw['down']) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + U / 2.0 - t**2 * g) # Solve the impurity problem S.solve( h_int=U * n('up', 0) * n('down', 0), # Local Hamiltonian n_cycles=10000, # Number of QMC cycles n_warmup_cycles=5000, # Warmup cycles ) # Save iteration in archive with HDFArchive("results_one_band/half-U%.2f.h5" % U) as A: A['G-%i' % i] = S.G_iw A['Sigma-%i' % i] = S.Sigma_iw
from pytriqs.gf.local import * from pytriqs.operators import * from pytriqs.archive import HDFArchive from pytriqs.applications.impurity_solvers.cthyb import Solver 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':[0],'down':[0]}) # Loop for two random generators for random_name in ['mt11213b','lagged_fibonacci607']: for spin, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - V**2 * Wilson(D)) # Solve using random_name as a generator S.solve(h_int = U * n('up',0) * n('down',0), # Local Hamiltonian n_cycles = 100000, # Number of QMC cycles length_cycle = 200, # Length of one cycle n_warmup_cycles = 10000, # Number of warmup cycles random_name = random_name) # Name of the random generator # Save the results in an hdf5 file (only on the master node) if mpi.is_master_node(): with HDFArchive("random.h5") as Results: Results["G_iw%s"%(random_name)] = S.G_iw
# Initial guess S.Sigma_iw << mu # DMFT loop for it in range(n_loops): # DCA self-consistency - get local lattice G G.zero() for spin in ['up', 'down']: for patch in ['even', 'odd']: # Hilbert transform for i in range(n_bins): G['%s-%s'%(patch,spin)] += rho[patch][i] * delta[patch] * inverse(iOmega_n + mu - epsilon[patch][i] - S.Sigma_iw['%s-%s'%(patch,spin)]) # DCA self-consistency - find next impurity G0 for block, g0 in S.G0_iw: g0 << inverse(inverse(G[block]) + S.Sigma_iw[block]) # Run the solver. The results will be in S.G_tau, S.G_iw and S.G_l S.solve(h_int = h_loc, # Local Hamiltonian n_cycles = 200000, # Number of QMC cycles length_cycle = 50, # Length of one cycle n_warmup_cycles = 10000, # Warmup cycles measure_g_l = True) # Measure G_l if mpi.is_master_node(): with HDFArchive("results_vbdmft/doping_%s.h5"%doping) as A: A['G_iw-%i'%it] = S.G_iw A['Sigma_iw-%i'%it] = S.Sigma_iw A['G0_iw-%i'%it] = S.G0_iw
# Construct the impurity solver with the inverse temperature # and the structure of the Green's functions S = Solver(beta=beta, gf_struct=[('up', [0]), ('down', [0])]) # Initialize the non-interacting Green's function S.G0_iw # External magnetic field introduces Zeeman energy splitting between # different spin components S.G0_iw['up'] << inverse(iOmega_n - e_f + h / 2 - V**2 * Wilson(D)) S.G0_iw['down'] << inverse(iOmega_n - e_f - h / 2 - V**2 * Wilson(D)) # Run the solver S.solve( h_int=U * n('up', 0) * n('down', 0), # Local Hamiltonian n_cycles=500000, # Number of QMC cycles length_cycle=200, # Length of one cycle n_warmup_cycles=10000, # Warmup cycles measure_density_matrix=True, # Measure the reduced density matrix use_norm_as_weight=True) # Required to measure the density matrix # Extract accumulated density matrix rho = S.density_matrix # Object containing eigensystem of the local Hamiltonian h_loc_diag = S.h_loc_diagonalization from pytriqs.atom_diag import trace_rho_op # Evaluate occupations print "<N_up> =", trace_rho_op(rho, n('up', 0), h_loc_diag) print "<N_down> = ", trace_rho_op(rho, n('down', 0), h_loc_diag)
# Construct the CTQMC solver S = Solver(beta = beta, gf_struct = {'up':[0], 'down':[0]}) # Initalize the Green's function to a semi circular DOS S.G_iw << SemiCircular(half_bandwidth) # Now do the DMFT loop for i_loop in range(n_loops): # Compute new S.G0_iw with the self-consistency condition while imposing paramagnetism g = 0.5 * (S.G_iw['up'] + S.G_iw['down']) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + chemical_potential - (half_bandwidth/2.0)**2 * g) # Run the solver S.solve(h_int = U * n('up',0) * n('down',0), # Local Hamiltonian n_cycles = 5000, # Number of QMC cycles length_cycle = 200, # Length of a cycle n_warmup_cycles = 1000) # How many warmup cycles # Some intermediate saves if mpi.is_master_node(): with HDFArchive("dmft_solution.h5") as ar: ar["G_tau-%s"%i_loop] = S.G_tau ar["G_iw-%s"%i_loop] = S.G_iw ar["Sigma_iw-%s"%i_loop] = S.Sigma_iw # Here we could write some convergence test # if converged : break
h_int += -J*c_dag('up-%s'%o1,0)*c_dag('down-%s'%o2,0)*c('up-%s'%o2,0)*c('down-%s'%o1,0) # This is a first guess for G S.G0_iw << inverse(iOmega_n + mu - t**2 * SemiCircular(2*t)) # DMFT loop with self-consistency for i in range(n_loops): print "\n\nIteration = %i / %i" % (i+1, n_loops) # Symmetrize the Green's function and use self-consistency if i > 0: g = 0.25 * ( S.G_iw['up-0'] + S.G_iw['up-1'] + S.G_iw['down-0'] + S.G_iw['down-1'] ) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - t**2 * g) # Solve the impurity problem S.solve(h_int = h_int, n_cycles = 30000, length_cycle = 100, n_warmup_cycles = 5000) # Check density for name, g in S.G_iw: print name, ": ",g.density()[0,0].real # Save iteration in archive with HDFArchive("results_two_bands/%s-U%.2f-J%.2f.h5"%(filling,U,J)) as A: A['G-%i'%i] = S.G_iw A['Sigma-%i'%i] = S.Sigma_iw