def setup_dmft_calculation(p): p = copy.deepcopy(p) p.iter = 0 # -- Local Hubbard interaction from triqs.operators import n p.solve.h_int = p.U * n('up', 0) * n( 'do', 0) - 0.5 * p.U * (n('up', 0) + n('do', 0)) # -- 2D square lattice w. nearest neighbour hopping t from triqs_tprf.tight_binding import TBLattice T = -p.t * np.eye(2) H = TBLattice(units=[(1, 0, 0), (0, 1, 0)], orbital_positions=[(0, 0, 0)] * 2, orbital_names=['up', 'do'], hopping={ (0, +1): T, (0, -1): T, (+1, 0): T, (-1, 0): T }) kmesh = H.get_kmesh(n_k=(p.n_k, p.n_k, 1)) p.e_k = H.fourier(kmesh) # -- Initial zero guess for the self-energy p.sigma_w = Gf(mesh=MeshImFreq(p.init.beta, 'Fermion', p.init.n_iw), target_shape=[2, 2]) p.sigma_w.zero() return p
def calc_reference(): ref_orbs = [ '%s' % i for i in range(n_orbs * parms['N_x'] * parms['N_y']) ] ref_gf_struct = op.set_operator_structure(spin_names, ref_orbs, off_diag=off_diag) ref_index_converter = {(sn, o): ("loc", int(o), "down" if sn == "dn" else "up") for sn, o in product(spin_names, ref_orbs)} #print ref_index_converter,ref_orbs ref_ed = PomerolED(ref_index_converter, verbose=True) ref_N = sum( ops.n(sn, o) for sn, o in product(spin_names, ref_orbs)) # 2 3 # 0 1 ref_H = (parms["U"] * (ops.n('up', '0') * ops.n('dn', '0') + ops.n('up', '1') * ops.n('dn', '1')) - 2. * parms['t1'] * (ops.c_dag('up', '0') * ops.c('up', '1') + ops.c_dag('up', '1') * ops.c('up', '0') + ops.c_dag('dn', '0') * ops.c('dn', '1') + ops.c_dag('dn', '1') * ops.c('dn', '0')) - parms['chemical_potential'] * ref_N) # Run the solver ref_ed.diagonalize(ref_H) # Compute G(i\omega) ref_G_iw = ref_ed.G_iw(ref_gf_struct, parms['beta'], parms['n_iw']) return ref_G_iw
chi0_q0_ref = chi0_q0_integral(t, beta) print('chi0_q0 =', chi00_wk[Idx(0), Idx(0, 0, 0)][0, 0, 0, 0].real) print('chi0_q0_ref =', chi0_q0_ref) np.testing.assert_almost_equal( chi00_wk_analytic[Idx(0), Idx(0, 0, 0)][0, 0, 0, 0], chi0_q0_ref) # ------------------------------------------------------------------ # -- RPA tensor gf_struct = [[0, 2]] from triqs.operators import n, c, c_dag, Operator, dagger H_int = U * n(0, 0) * n(0, 1) print('H_int =', H_int) from triqs_tprf.rpa_tensor import get_rpa_tensor from triqs_tprf.rpa_tensor import fundamental_operators_from_gf_struct fundamental_operators = fundamental_operators_from_gf_struct(gf_struct) print(fundamental_operators) U_abcd = get_rpa_tensor(H_int, fundamental_operators) print('U_abcd =\n', U_abcd.reshape((4, 4))) # ------------------------------------------------------------------ # -- RPA from triqs_tprf.lattice import solve_rpa_PH
def run_test(t1, filename): dptkeys = [ 'verbosity', 'calculate_sigma', 'calculate_sigma1', 'calculate_sigma2' ] parms = { # Solver parameters 'n_iw': 100, # Physical parameters 'U': 0.5, 't1': t1, 'beta': 10, # DMFT loop control parameters 'calculate_sigma': True, 'calculate_sigma1': True, 'calculate_sigma2': True, 'measure_G2_iw_ph': True, "measure_G2_n_bosonic": 10, "measure_G2_n_fermionic": 10, "verbosity": 4, } parms["N_x"] = 2 parms["N_y"] = 1 parms["N_z"] = 1 parms["ksi_delta"] = 1.0 # Chemical potential depends on the definition of H(k) that is used parms['chemical_potential_bare'] = 0. parms['chemical_potential'] = parms['U'] / 2. + parms[ 'chemical_potential_bare'] n_orbs = 1 # Number of orbitals off_diag = True spin_names = ['up', 'dn'] # Outer (non-hybridizing) blocks orb_names = ['%s' % i for i in range(n_orbs)] # Orbital indices gf_struct = op.set_operator_structure(spin_names, orb_names, off_diag=off_diag) if haspomerol: ##### # # Reference: 4 site cluster, calculate only G, not G2 # ##### def calc_reference(): ref_orbs = [ '%s' % i for i in range(n_orbs * parms['N_x'] * parms['N_y']) ] ref_gf_struct = op.set_operator_structure(spin_names, ref_orbs, off_diag=off_diag) ref_index_converter = {(sn, o): ("loc", int(o), "down" if sn == "dn" else "up") for sn, o in product(spin_names, ref_orbs)} #print ref_index_converter,ref_orbs ref_ed = PomerolED(ref_index_converter, verbose=True) ref_N = sum( ops.n(sn, o) for sn, o in product(spin_names, ref_orbs)) # 2 3 # 0 1 ref_H = (parms["U"] * (ops.n('up', '0') * ops.n('dn', '0') + ops.n('up', '1') * ops.n('dn', '1')) - 2. * parms['t1'] * (ops.c_dag('up', '0') * ops.c('up', '1') + ops.c_dag('up', '1') * ops.c('up', '0') + ops.c_dag('dn', '0') * ops.c('dn', '1') + ops.c_dag('dn', '1') * ops.c('dn', '0')) - parms['chemical_potential'] * ref_N) # Run the solver ref_ed.diagonalize(ref_H) # Compute G(i\omega) ref_G_iw = ref_ed.G_iw(ref_gf_struct, parms['beta'], parms['n_iw']) return ref_G_iw ref_G_iw = calc_reference() ref = ref_G_iw[ref_spin] g2_blocks = set([("up", "up"), ("up", "dn"), ("dn", "up"), ("dn", "dn")]) index_converter = {(sn, o): ("loc", int(o), "down" if sn == "dn" else "up") for sn, o in product(spin_names, orb_names)} # 1 Bath degree of freedom # Level of the bath sites epsilon = [ -parms['chemical_potential_bare'], ] index_converter.update({ ("B%i_%s" % (k, sn), 0): ("bath" + str(k), 0, "down" if sn == "dn" else "up") for k, sn in product(range(len(epsilon)), spin_names) }) # Make PomerolED solver object ed = PomerolED(index_converter, verbose=True) N = sum(ops.n(sn, o) for sn, o in product(spin_names, orb_names)) H_loc = (parms["U"] * (ops.n('up', '0') * ops.n('dn', '0')) - parms['chemical_potential'] * N) # Bath Hamiltonian: levels H_bath = sum(eps * ops.n("B%i_%s" % (k, sn), 0) for sn, (k, eps) in product(spin_names, enumerate(epsilon))) # Hybridization Hamiltonian # Bath-impurity hybridization V = [ -2 * bath_prefactor * t1, ] H_hyb = ops.Operator() for k, v in enumerate(V): H_hyb += sum( v * ops.c_dag("B%i_%s" % (k, sn), 0) * ops.c(sn, '0') + np.conj(v) * ops.c_dag(sn, '0') * ops.c("B%i_%s" % (k, sn), 0) for sn in spin_names) # Obtain bath sites from Delta and create H_ED H_ED = H_loc + H_bath + H_hyb # Run the solver ed.diagonalize(H_ED) # Compute G(i\omega) G_iw = ed.G_iw(gf_struct, parms['beta'], parms['n_iw']) if parms["measure_G2_iw_ph"]: common_g2_params = { 'gf_struct': gf_struct, 'beta': parms['beta'], 'blocks': g2_blocks, 'n_iw': parms['measure_G2_n_bosonic'] } G2_iw = ed.G2_iw_inu_inup(channel="PH", block_order="AABB", n_inu=parms['measure_G2_n_fermionic'], **common_g2_params) if mpi.is_master_node(): with ar.HDFArchive(filename, 'w') as arch: arch["parms"] = parms arch["G_iw"] = G_iw arch["G2_iw"] = G2_iw arch["ref"] = ref else: # haspomerol is False with ar.HDFArchive(filename, 'r') as arch: ref = arch['ref'] G_iw = arch['G_iw'] G2_iw = arch['G2_iw'] BL = lattice.BravaisLattice(units=[ (1, 0, 0), ]) #linear lattice kmesh = gf.MeshBrillouinZone(lattice.BrillouinZone(BL), parms["N_x"]) Hk_blocks = [gf.Gf(indices=orb_names, mesh=kmesh) for spin in spin_names] Hk = gf.BlockGf(name_list=spin_names, block_list=Hk_blocks) def Hk_f(k): return -2 * parms['t1'] * (np.cos(k[0])) * np.eye(1) for spin, _ in Hk: for k in Hk.mesh: Hk[spin][k] = Hk_f(k.value) # Construct the DF2 program X = dualfermion.Dpt(beta=parms['beta'], gf_struct=gf_struct, Hk=Hk, n_iw=parms['n_iw'], n_iw2=parms["measure_G2_n_fermionic"], n_iW=parms["measure_G2_n_bosonic"]) for name, g0 in X.Delta: X.Delta[name] << gf.inverse( gf.iOmega_n + parms['chemical_potential_bare']) * bath_prefactor**2 * 4 * t1**2 X.G2_iw << G2_iw # Run the dual perturbation theory X.gimp << G_iw # Load G from impurity solver dpt_parms = {key: parms[key] for key in parms if key in dptkeys} X.run(**dpt_parms)
# Bath hamiltonian in matrix representation h_bath_mat = diag(eps_bath) - matrix([[0, t_bath, 0, 0], [t_bath, 0, 0, 0], [0, 0, 0, t_bath], [0, 0, t_bath, 0]]) # Coupling matrix V_mat = matrix([[1., 0., 0, 0], [0., 1., 0, 0], [0., 0., 1, 0], [0., 0., 0, 1]]) # ==== Local Hamiltonian ==== c_dag_vec = matrix([[c_dag('bl', o) for o in range(n_orb)]]) c_vec = matrix([[c('bl', o)] for o in range(n_orb)]) h_0 = (c_dag_vec * h_0_mat * c_vec)[0, 0] h_int = U * n('bl', up_0) * n('bl', dn_0) + \ U * n('bl', up_1) * n('bl', dn_1) + \ U * n('bl', up_0) * n('bl', dn_1) + \ U * n('bl', up_1) * n('bl', dn_0) + \ Up * n('bl', up_0) * n('bl', up_1) + \ Up * n('bl', dn_0) * n('bl', dn_1) h_imp = h_0 + h_int # ==== Bath & Coupling hamiltonian ==== c_dag_bath_vec = matrix( [[c_dag('bl', o) for o in range(n_orb, n_orb + n_orb_bath)]]) c_bath_vec = matrix([[c('bl', o)] for o in range(n_orb, n_orb + n_orb_bath)]) h_bath = (c_dag_bath_vec * h_bath_mat * c_bath_vec)[0, 0] h_coup = (c_dag_vec * V_mat * c_bath_vec +
from triqs.operators import c, c_dag, n from itertools import product # ==== System Parameters ==== beta = 5. # Inverse temperature mu = 2. # Chemical potential U = 5. # On-site density-density interaction h = 0.2 # Local magnetic field E = [ 0.0, 4.0 ] # Bath-site energies V = [ 2.0, 5.0 ] # Couplings to Bath-sites spin_names = ['up', 'dn'] orb_names = [0] # ==== Local Hamiltonian ==== h_0 = - mu*( n('up',0) + n('dn',0) ) - h*( n('up',0) - n('dn',0) ) h_int = U * n('up',0) * n('dn',0) h_imp = h_0 + h_int # ==== Bath & Coupling Hamiltonian ==== h_bath, h_coup = 0, 0 for i, E_i, V_i in zip([0, 1], E, V): for sig in ['up','dn']: h_bath += E_i * n(sig,'b_' + str(i)) h_coup += V_i * (c_dag(sig,0) * c(sig,'b_' + str(i)) + c_dag(sig,'b_' + str(i)) * c(sig,0)) # ==== Total impurity hamiltonian and fundamental operators ==== h_tot = h_imp + h_coup + h_bath # ==== Green function structure ==== gf_struct = [ [s, orb_names] for s in spin_names ]
# Construct the DF2 program X = dualfermion.Dpt(beta=parms['beta'], gf_struct=gf_struct, Hk=Hk, n_iw=parms['n_iw'], n_iw2=parms["measure_G2_n_fermionic"], n_iW=parms["measure_G2_n_bosonic"]) if haspomerol: g2_blocks = set([("up", "up"), ("up", "dn"), ("dn", "up"), ("dn", "dn")]) index_converter = {(sn, o): ("loc", int(o), "down" if sn == "dn" else "up") for sn, o in product(spin_names, orb_names)} # Make PomerolED solver object ed = PomerolED(index_converter, verbose=True) N = sum(ops.n(sn, o) for sn, o in product(spin_names, orb_names)) H = (parms["Ua"] * (ops.n('up', '0') * ops.n('dn', '0')) + parms["Ub"] * (ops.n('up', '1') * ops.n('dn', '1')) + parms['t0'] * (ops.c_dag('up', '0') * ops.c('up', '1') + ops.c_dag('up', '1') * ops.c('up', '0') + ops.c_dag('dn', '0') * ops.c('dn', '1') + ops.c_dag('dn', '1') * ops.c('dn', '0')) - parms['chemical_potential'] * N) ##### # # Reference: 4 site cluster, calculate only G, not G2 # ##### def calc_reference(): ref_orbs = ['%s' % i for i in range(n_orbs * parms['N_x'])]
from triqs.operators import c, c_dag, n from itertools import product from numpy import sign # ==== System Parameters ==== beta = 5. # Inverse temperature mu = 2. # Chemical potential U = 5. # On-site density-density interaction h = 0.2 # Local magnetic field Gamma = 1. # Hybridization energy spin_names = ['up', 'dn'] orb_names = [0] # ==== Local Hamiltonian ==== h_0 = - mu*( n('up',0) + n('dn',0) ) - h*( n('up',0) - n('dn',0) ) h_int = U * n('up',0) * n('dn',0) h_imp = h_0 + h_int # ==== Green function structure ==== gf_struct = [ [s, orb_names] for s in spin_names ] # ==== Hybridization Function ==== n_iw = int(10 * beta) iw_mesh = MeshImFreq(beta, 'Fermion', n_iw) Delta = BlockGf(mesh=iw_mesh, gf_struct=gf_struct) Delta << 0.; for iw in Delta['up'].mesh: Delta['up'][iw] = -1j * Gamma * sign(iw.imag) Delta['dn'][iw] = -1j * Gamma * sign(iw.imag)
post_process=True, ) p.version = ParameterCollection() p.version.grab_attribs(version, ['version', 'ctint_hash', 'triqs_hash']) # -- The alpha tensor p.diag = 0.5 + p.delta p.odiag = 0.5 - p.delta p.solve.alpha = [[[p.diag, p.odiag] for i in indices] for bl, indices in p.gf_struct] # -- Total impurity hamiltonian and interaction part p.H_0 = -p.mu * (n('up', 0) + n('dn', 0)) - p.h * (n('up', 0) - n('dn', 0)) p.H_int = p.U * n('up', 0) * n('dn', 0) p.H = p.H_0 + p.H_int p.solve.h_int = p.H_int # -- Non-Interacting Impurity Green function iw_mesh = MeshImFreq(p.beta, 'Fermion', p.n_iw) p.G0_iw = Gf_from_struct(mesh=iw_mesh, struct=p.gf_struct) h_field_dict = dict(up=p.h, dn=-p.h) for name, g0_iw in p.G0_iw: h_field = h_field_dict[name] g0_iw << inverse(iOmega_n + p.mu + h_field) # -- CTINT
0, ): h_loc, (+1, ): T, (-1, ): T, }, orbital_positions=[(0, 0, 0)] * 2, orbital_names=['up', 'do'], ) kmesh = t_r.get_kmesh(n_k) e_k = t_r.fourier(kmesh) # -- Local double occupancy operator gf_struct = [[0, 2]] docc = n(0, 0) * n(0, 1) Sz = 0.5 * np.diag([1., -1.]) # -- Sweep in interaction U U_vec = np.arange(9., -0.5, -1.5) h_vec = 1e-3 * np.linspace(-1., 1., num=11) res = [] M0 = np.zeros((2, 2)) M = -5.0 * Sz mu = 0. for U in U_vec:
Units = np.dot(P, Units_prim) print('Units =\n', Units) t_r = TBSuperLattice(t_r_prim, P) kmesh = t_r.get_kmesh(n_k) e_k = t_r.fourier(kmesh) print(e_k.target_shape) print('eps(k=0) =\n', e_k[Idx(0, 0, 0)]) # -- Local double occ and spin operators gf_struct = [[0, 4]] docc = n(0, 0) * n(0, 2) + n(0, 1) * n(0, 3) print('docc =', docc) sigma_x = 0.5 * np.rot90(np.diag([1., 1.])) sigma_y = 0.5 * np.rot90(np.diag([1.j, -1.j])) sigma_z = 0.5 * np.diag([1., -1.]) print('sigma_x =\n', sigma_x) print('sigma_y =\n', sigma_y) print('sigma_z =\n', sigma_z) Sx1 = np.kron(sigma_x, np.diag([1., 0.])) Sx2 = np.kron(sigma_x, np.diag([0., 1.])) Sy1 = np.kron(sigma_y, np.diag([1., 0.]))
n_iW=parms["measure_G2_n_bosonic"], ) X.Hk[spin] << Hk[spin] g2_blocks = set([("up", "up"), ("up", "dn"), ("dn", "up"), ("dn", "dn")]) index_converter = {(sn, o): ("loc", int(o), "down" if sn == "dn" else "up") for sn, o in product(spin_names, orb_names)} if haspomerol: with HDFArchive(arname, 'w') as ar: # Make PomerolED solver object ed = PomerolED(index_converter, verbose=True) N = sum(ops.n(sn, o) for sn, o in product(spin_names, orb_names)) H = (parms["U"] * (ops.n('up', '0') * ops.n('dn', '0')) - parms['chemical_potential'] * N) ##### # # Reference: 2 sites, calculate only G, not G2 # ##### def calc_reference(): ref_orbs = ['%s' % i for i in range(n_orbs * parms['N_x'])] ref_gf_struct = op.set_operator_structure(spin_names, ref_orbs, off_diag=off_diag) ref_index_converter = {(sn, o): ("loc", int(o),