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 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 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
from pytriqs.gf import * from pytriqs.operators import * from pytriqs.archive import * import pytriqs.utility.mpi as mpi from pytriqs.applications.impurity_solvers.cthyb import Solver # Set up a few parameters U = 2.5 half_bandwidth = 1.0 chemical_potential = U / 2.0 beta = 100 n_loops = 5 # 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
if p.offdiag: # off-diagonal solver, 1 block NBand x NBand gf_struct = {'0': p.bands_T} else: # diagonal solver, NBand blocks 1 x 1 gf_struct = {} for band in p.bands_T: gf_struct[band] = [0] if mpi.is_master_node() and p.NBins == 1: stars = '**********************************************************' PrintAndWrite( '\n' + stars + '\n* CT_HYB solver START, iteration ' + str(NLoop) + '.\n' + stars + '\n', logfname) S = Solver(beta=p.beta, gf_struct=gf_struct, n_iw=p.NMats, n_l=p.NLeg, n_tau=p.NTau) if p.offdiag: # off-diagonal solver, 1 block NBand x NBand for block, gw0 in S.G0_iw: gw0 << GF else: # diagonal solver, NBand blocks 1 x 1 for block, gw0 in S.G0_iw: gw0 << GF[block, block] # reading the Coulomb matrix from file #################### U_M = sp.loadtxt('Umm.dat') # model Hamiltonian and other operators ################### h_int = Operator()
import os if not os.path.exists('results_two_bands'): os.makedirs('results_two_bands') # Parameters of the model t = 1.0 beta = 10.0 n_loops = 10 filling = 'half' # or 'quarter' n_orbitals = 2 # Construct the solver S = Solver(beta=beta, gf_struct={ 'up-0': [0], 'up-1': [0], 'down-0': [0], 'down-1': [0] }) for coeff in [0.0, 0.1, 0.2]: # Run for several values of U for U in np.arange(1.0, 13.0, 1.0): J = coeff * U # Expression of mu for half and quarter filling if filling == 'half': mu = 0.5 * U + 0.5 * (U - 2 * J) + 0.5 * (U - 3 * J) elif filling == 'quarter':
gf_struct = op.set_operator_structure(spin_names, orb_names, off_diag=off_diag) # Construct the 4-index U matrix U_{ijkl} # The spherically-symmetric U matrix is parametrised by the radial integrals # F_0, F_2, F_4, which are related to U and J. We use the functions provided # in the TRIQS library to construct this easily: U_mat = op.U_matrix(l=l, U_int=U, J_hund=J, basis='spherical') # Set the interacting part of the local Hamiltonian # Here we use the full rotationally-invariant interaction parametrised # by the 4-index tensor U_{ijkl}. # The TRIQS library provides a function to build this Hamiltonian from the U tensor: 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:
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
from itertools import product import numpy as np import os if not os.path.exists('results_two_bands'): os.makedirs('results_two_bands') # Parameters of the model t = 1.0 beta = 10.0 n_loops = 10 filling = 'half' # or 'quarter' n_orbitals = 2 # Construct the solver S = Solver(beta = beta, gf_struct = {'up-0':[0], 'up-1':[0], 'down-0':[0], 'down-1':[0]}) for coeff in [0.0, 0.1, 0.2]: # Run for several values of U for U in np.arange(1.0, 13.0, 1.0): J = coeff * U # Expression of mu for half and quarter filling if filling == 'half': mu = 0.5*U + 0.5*(U-2*J) + 0.5*(U-3*J) elif filling == 'quarter': mu = -0.81 + (0.6899-1.1099*coeff)*U + (-0.02548+0.02709*coeff-0.1606*coeff**2)*U**2 # Set the interacting Kanamori hamiltonian
gf_struct = op.set_operator_structure(spin_names,orb_names,off_diag=off_diag) # Construct the 4-index U matrix U_{ijkl} # The spherically-symmetric U matrix is parametrised by the radial integrals # F_0, F_2, F_4, which are related to U and J. We use the functions provided # in the TRIQS library to construct this easily: U_mat = op.U_matrix(l=l, U_int=U, J_hund=J, basis='spherical') # Set the interacting part of the local Hamiltonian # Here we use the full rotationally-invariant interaction parametrised # by the 4-index tensor U_{ijkl}. # The TRIQS library provides a function to build this Hamiltonian from the U tensor: 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
from pytriqs.operators import * from pytriqs.archive import * from pytriqs.applications.impurity_solvers.cthyb import Solver import numpy as np import os if not os.path.exists('results_one_band'): os.makedirs('results_one_band') # Parameters of the model t = 1.0 beta = 10.0 n_loops = 10 # 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'] )
from pytriqs.gf.local import * from pytriqs.operators import * from pytriqs.applications.impurity_solvers.cthyb import Solver # Parameters D = 1.0 # Half-bandwidth of the bath V = 0.2 # Hybridisation amplitude U = 4.0 # Coulomb interaction e_f = -U/2 # Local energy level h = 0.01 # External field 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
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
from pytriqs.operators import * from pytriqs.archive import * from pytriqs.applications.impurity_solvers.cthyb import Solver import numpy as np import os if not os.path.exists('results_one_band'): os.makedirs('results_one_band') # Parameters of the model t = 1.0 beta = 10.0 n_loops = 10 # 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'])
#GF = ReadGW(NLoop,p.NBand,p.NMats,p.beta,p.bands_T,FitMin,FitMax,mpi.rank,p.offdiag,logfname) #GF = FitTailGreen(GF,p.NBand,FitMin,FitMax,6) GF = ReadGW2(NLoop,p.NBand,p.NMats,p.beta,p.bands_T,FitMin,FitMax,p.NFit,mpi.rank,p.offdiag,1,logfname) if p.offdiag: # off-diagonal solver, 1 block NBand x NBand gf_struct = { '0': p.bands_T } else: # diagonal solver, NBand blocks 1 x 1 gf_struct = {} for band in p.bands_T: gf_struct[band] = [0] if mpi.is_master_node() and p.NBins == 1: stars = '**********************************************************' PrintAndWrite('\n'+stars+'\n* CT_HYB solver START, iteration '+str(NLoop)+'.\n'+stars+'\n',logfname) S = Solver(beta = p.beta, gf_struct = gf_struct, n_iw = p.NMats, n_l = p.NLeg, n_tau = p.NTau) if p.offdiag: # off-diagonal solver, 1 block NBand x NBand for block, gw0 in S.G0_iw: gw0 << GF else: # diagonal solver, NBand blocks 1 x 1 for block, gw0 in S.G0_iw: gw0 << GF[block,block] # reading the Coulomb matrix from file #################### U_M = sp.loadtxt('Umm.dat') # model Hamiltonian and other operators ################### h_int = Operator() N_tot = Operator() for b1 in range(p.NBand): N_tot = N_tot + n('0',p.bands_T[b1])
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
# A mask giving the k points inside the central patch in_central_patch = (np.abs(kx) < np.pi/np.sqrt(2)) & (np.abs(ky) < np.pi/np.sqrt(2)) # Find the partial densities of states associated to the patches energies, epsilon, rho, delta = {},{}, {}, {} energies['even'] = np.extract(in_central_patch, epsk) energies['odd'] = np.extract(np.invert(in_central_patch), epsk) for patch in ['even','odd']: h = np.histogram(energies[patch], bins=n_bins, normed=True) epsilon[patch] = 0.5 * (h[1][0:-1] + h[1][1:]) rho[patch] = h[0] delta[patch] = h[1][1]-h[1][0] # Construct the impurity solver S = Solver(beta = beta, gf_struct = {'even-up':[0], 'odd-up':[0], 'even-down':[0], 'odd-down':[0]}, n_l = 100) # The local lattice Green's function G = S.G0_iw.copy() # Rotation cn, cn_dag, nn = {}, {}, {} for spin in ['up','down']: cn['1-%s'%spin] = (c('even-%s'%spin,0) + c('odd-%s'%spin,0)) / np.sqrt(2) cn['2-%s'%spin] = (c('even-%s'%spin,0) - c('odd-%s'%spin,0)) / np.sqrt(2) nn['1-%s'%spin] = dagger(cn['1-%s'%spin]) * cn['1-%s'%spin] nn['2-%s'%spin] = dagger(cn['2-%s'%spin]) * cn['2-%s'%spin] # Local Hamiltonian h_loc = U * (nn['1-up'] * nn['1-down'] + nn['2-up'] * nn['2-down'])
from pytriqs.gf import * from pytriqs.operators import * from pytriqs.applications.impurity_solvers.cthyb import Solver # Parameters D = 1.0 # Half-bandwidth of the bath V = 0.2 # Hybridisation amplitude U = 4.0 # Coulomb interaction e_f = -U / 2 # Local energy level h = 0.01 # External field 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
from pytriqs.gf.local import * from pytriqs.operators import * from pytriqs.archive import * import pytriqs.utility.mpi as mpi from pytriqs.applications.impurity_solvers.cthyb import Solver # Set up a few parameters U = 2.5 half_bandwidth = 1.0 chemical_potential = U/2.0 beta = 100 n_loops = 5 # 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
def __init__(self, seedname, params): """ Initialize solver at each inequivalent correlation shell Parameters ---------- seedname : string seedname params : dict Input parameters """ self._params = copy.deepcopy(params) # Construct a SumKDFT object self.SK = SumkDFT(hdf_file=seedname + '.h5', use_dft_blocks=False, h_field=0.0) u_file = HDFArchive(seedname + '.h5', 'r') self.Umat = u_file["DCore"]["Umat"] # Construct an impurity solver beta = float(params['system']['beta']) n_iw = int(params['system']['n_iw']) # Number of Matsubara frequencies n_tau = int(params['system']['n_tau']) # Number of tau points self.solver_name = params['impurity_solver']['name'] self._solver_params = create_solver_params(params['impurity_solver']) if 'verbosity' in self._solver_params.keys(): if not mpi.is_master_node(): del self._solver_params['verbosity'] self.S = [] for ish in range(self.SK.n_inequiv_shells): # Use GF structure determined by DFT blocks gf_struct = self.SK.gf_struct_solver[ish] if self.solver_name == "TRIQS/cthyb": from pytriqs.applications.impurity_solvers.cthyb import Solver if params['system']['n_l'] > 0: self._solver_params['measure_g_l'] = True self._solver_params['measure_g_tau'] = False self.S.append( Solver(beta=beta, gf_struct=gf_struct, n_iw=n_iw, n_tau=n_tau, n_l=params['system']['n_l'])) else: self.S.append( Solver(beta=beta, gf_struct=gf_struct, n_iw=n_iw, n_tau=n_tau)) elif self.solver_name == "TRIQS/hubbard-I": n_orb = self.SK.corr_shells[ self.SK.inequiv_to_corr[ish]]['dim'] / (self.SK.SO + 1) from hubbard_solver_matrix import Solver self.S.append( Solver(beta=beta, norb=n_orb, n_msb=n_iw, use_spin_orbit=self.SK.SO)) elif self.solver_name == "ALPS/cthyb": from pytriqs.applications.impurity_solvers.alps_cthyb import Solver if params['system']['n_l'] > 0: self.S.append( Solver(beta=beta, gf_struct=gf_struct, assume_real=False, n_iw=n_iw, n_tau=n_tau, n_l=params['system']['n_l'])) else: self.S.append( Solver(beta=beta, gf_struct=gf_struct, assume_real=False, n_iw=n_iw, n_tau=n_tau)) else: raise RuntimeError("Unknown solver " + self.solver_name)