def solve_local_bse(chi0_wnn, chi_wnn): r"""Solve the Bethe-Salpeter equation for the local vertex function :math:`\Gamma_{abcd}(\omega, \nu, \nu')`. Computes: .. math:: \Gamma_{abcd}(\omega, \nu, \nu') = [\chi^{(0)}]^{-1} - \chi^{-1} where the inverses are taken in the particle-hole channel pairing of fermionic frequencies :math:`\nu` and :math:`\nu'` and orbital indices. Parameters ---------- chi0_wnn : Gerealized local bubble susceptibility :math:`\chi^{(0)}_{abcd}(\omega, \nu, \nu')` chi_wnn : Generalized local susceptibility :math:`\chi_{abcd}(\omega, \nu, \nu')` Returns ------- gamma_wnn : Particle-hole vertex function :math:`\Gamma_{abcd}(\omega, \nu, \nu')` """ gamma_wnn = inverse_PH(chi0_wnn) - inverse_PH(chi_wnn) return gamma_wnn
def analytic_hubbard_atom(beta, U, nw, nwf, nwf_gf): d = ParameterCollection() d.beta, d.U, d.nw, d.nwf, d.nwf_gf = beta, U, nw, nwf, nwf_gf g_iw = single_particle_greens_function(beta=beta, U=U, nw=nwf_gf) d.G_iw = g_iw # make block gf of the single gf G_iw_block = BlockGf(name_list=['up', 'dn'], block_list=[g_iw, g_iw]) g_mat = block_iw_AB_to_matrix_valued(G_iw_block) d.chi_m = chi_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf) d.chi0_m = chi0_from_gg2_PH(g_mat, d.chi_m) # -- Numeric vertex from BSE d.gamma_m_num = inverse_PH(d.chi0_m) - inverse_PH(d.chi_m) # -- Analytic vertex d.gamma_m = gamma_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf) # -- Analytic magnetization expecation value # -- and static susceptibility d.Z = 2. + 2 * np.exp(-beta * 0.5 * U) d.m2 = 0.25 * (2 / d.Z) d.chi_m_static = 2. * beta * d.m2 d.label = r'Analytic' return d
def make_calc(): # ------------------------------------------------------------------ # -- Read precomputed ED data filename = "data_pomerol.tar.gz" p = read_TarGZ_HDFArchive(filename) # ------------------------------------------------------------------ # -- RPA tensor 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(p.gf_struct) p.U_abcd = get_rpa_tensor(p.H_int, fundamental_operators) # ------------------------------------------------------------------ # -- Generalized PH susceptibility loc_bse = ParameterCollection() loc_bse.chi_wnn = chi_from_gg2_PH(p.G_iw, p.G2_iw_ph) loc_bse.chi0_wnn = chi0_from_gg2_PH(p.G_iw, p.G2_iw_ph) loc_bse.gamma_wnn = inverse_PH(loc_bse.chi0_wnn) - inverse_PH( loc_bse.chi_wnn) loc_bse.chi_wnn_ref = inverse_PH( inverse_PH(loc_bse.chi0_wnn) - loc_bse.gamma_wnn) np.testing.assert_array_almost_equal(loc_bse.chi_wnn.data, loc_bse.chi_wnn_ref.data) loc_bse.chi0_w = trace_nn(loc_bse.chi0_wnn) loc_bse.chi_w = trace_nn(loc_bse.chi_wnn) # ------------------------------------------------------------------ # -- RPA, using BSE inverses and constant Gamma loc_rpa = ParameterCollection() loc_rpa.U_abcd = p.U_abcd # -- Build constant gamma loc_rpa.gamma_wnn = loc_bse.gamma_wnn.copy() loc_rpa.gamma_wnn.data[:] = loc_rpa.U_abcd[None, None, None, ...] # Nb! In the three frequency form $\Gamma \propto U/\beta^2$ loc_rpa.gamma_wnn.data[:] /= p.beta**2 loc_rpa.chi0_wnn = loc_bse.chi0_wnn loc_rpa.chi0_w = loc_bse.chi0_w # -- Solve RPA loc_rpa.chi_wnn = inverse_PH( inverse_PH(loc_rpa.chi0_wnn) - loc_rpa.gamma_wnn) loc_rpa.chi_w = trace_nn(loc_rpa.chi_wnn) # ------------------------------------------------------------------ # -- Bubble RPA on lattice lat_rpa = ParameterCollection() # -- Setup dummy lattice Green's function equal to local Green's function bz = BrillouinZone( BravaisLattice(units=np.eye(3), orbital_positions=[(0, 0, 0)])) periodization_matrix = np.diag(np.array(list([1] * 3), dtype=np.int32)) kmesh = MeshBrillouinZone(bz, periodization_matrix) wmesh = MeshImFreq(beta=p.beta, S='Fermion', n_max=p.nwf_gf) lat_rpa.g_wk = Gf(mesh=MeshProduct(wmesh, kmesh), target_shape=p.G_iw.target_shape) lat_rpa.g_wk[:, Idx(0, 0, 0)] = p.G_iw # -- chi0_wk bubble and chi_wk_rpa bubble RPA from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk lat_rpa.chi0_wk = imtime_bubble_chi0_wk(lat_rpa.g_wk, nw=1) from triqs_tprf.lattice import solve_rpa_PH lat_rpa.chi_wk = solve_rpa_PH(lat_rpa.chi0_wk, p.U_abcd) lat_rpa.chi0_w = lat_rpa.chi0_wk[:, Idx(0, 0, 0)] lat_rpa.chi_w = lat_rpa.chi_wk[:, Idx(0, 0, 0)] print '--> cf Tr[chi0] and chi0_wk' print loc_rpa.chi0_w.data.reshape((4, 4)).real print lat_rpa.chi0_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(loc_rpa.chi0_w.data, lat_rpa.chi0_w.data, decimal=2) print 'ok!' print '--> cf Tr[chi_rpa] and chi_wk_rpa' print loc_rpa.chi_w.data.reshape((4, 4)).real print lat_rpa.chi_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(loc_rpa.chi_w.data, lat_rpa.chi_w.data, decimal=2) print 'ok!' # ------------------------------------------------------------------ # -- Lattice BSE lat_bse = ParameterCollection() lat_bse.g_wk = lat_rpa.g_wk from triqs_tprf.lattice import fourier_wk_to_wr lat_bse.g_wr = fourier_wk_to_wr(lat_bse.g_wk) from triqs_tprf.lattice import chi0r_from_gr_PH lat_bse.chi0_wnr = chi0r_from_gr_PH(nw=1, nnu=p.nwf, gr=lat_bse.g_wr) from triqs_tprf.lattice import chi0q_from_chi0r lat_bse.chi0_wnk = chi0q_from_chi0r(lat_bse.chi0_wnr) # -- Lattice BSE calc from triqs_tprf.lattice import chiq_from_chi0q_and_gamma_PH lat_bse.chi_kwnn = chiq_from_chi0q_and_gamma_PH(lat_bse.chi0_wnk, loc_bse.gamma_wnn) # -- Trace results from triqs_tprf.lattice import chi0q_sum_nu_tail_corr_PH from triqs_tprf.lattice import chi0q_sum_nu lat_bse.chi0_wk_tail_corr = chi0q_sum_nu_tail_corr_PH(lat_bse.chi0_wnk) lat_bse.chi0_wk = chi0q_sum_nu(lat_bse.chi0_wnk) from triqs_tprf.lattice import chiq_sum_nu, chiq_sum_nu_q lat_bse.chi_kw = chiq_sum_nu(lat_bse.chi_kwnn) lat_bse.chi0_w_tail_corr = lat_bse.chi0_wk_tail_corr[:, Idx(0, 0, 0)] lat_bse.chi0_w = lat_bse.chi0_wk[:, Idx(0, 0, 0)] lat_bse.chi_w = lat_bse.chi_kw[Idx(0, 0, 0), :] print '--> cf Tr[chi0_wnk] and chi0_wk' print lat_bse.chi0_w_tail_corr.data.reshape((4, 4)).real print lat_bse.chi0_w.data.reshape((4, 4)).real print lat_rpa.chi0_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(lat_bse.chi0_w_tail_corr.data, lat_rpa.chi0_w.data) np.testing.assert_array_almost_equal(lat_bse.chi0_w.data, lat_rpa.chi0_w.data, decimal=2) print 'ok!' print '--> cf Tr[chi_kwnn] and chi_wk' print lat_bse.chi_w.data.reshape((4, 4)).real print loc_bse.chi_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(lat_bse.chi_w.data, loc_bse.chi_w.data) print 'ok!' # ------------------------------------------------------------------ # -- Store to hdf5 filename = 'data_bse_rpa.h5' with HDFArchive(filename, 'w') as res: res['p'] = p
def solve_local_bse(chi0_wnn, chi_wnn): gamma_wnn = inverse_PH(chi0_wnn) - inverse_PH(chi_wnn) return gamma_wnn
def analytic_hubbard_atom(beta, U, nw, nwf, nwf_gf): r""" Compute dynamical response functions for the Hubbard atom at half filling. This function returns an object that contains the single-particle Greens function :math:`G(\omega)`, the magnetic two-particle generalized susceptibility :math:`\chi_m(\omega, \nu, \nu')`, and the corresponding bare bubble :math:`\chi^{(0)}_m(\omega, \nu, \nu')`, and the magnetic vertex function :math:`\Gamma_m(\omega, \nu, \nu')`. This is implemented using analytical formulas from Thunstrom et al. [PRB 98, 235107 (2018)] please cite the paper if you use this function! In particular this is one exact solution to the Bethe-Salpeter equation, that is the infinite matrix inverse problem: .. math:: \Gamma_m = [\chi^{(0)}_m]^{-1} - \chi_m^{-1} Parameters ---------- beta : float Inverse temperature. U : float Hubbard U interaction parameter. nw : int Number of bosonic Matsubara frequencies in the computed two-particle response functions. nwf : int Number of fermionic Matsubara frequencies in the computed two-particle response functions. nwf_gf : int Number of fermionic Matsubara frequencies in the computed single-particle Greens function. Returns ------- p : ParameterCollection Object containing all the response functions and some other observables, `p.G_iw`, `p.chi_m`, `p.chi0_m`, `p.gamma_m`, `p.Z`, `p.m2`, `p.chi_m_static`. """ d = ParameterCollection() d.beta, d.U, d.nw, d.nwf, d.nwf_gf = beta, U, nw, nwf, nwf_gf g_iw = single_particle_greens_function(beta=beta, U=U, nw=nwf_gf) d.G_iw = g_iw # make block gf of the single gf G_iw_block = BlockGf(name_list=['up', 'dn'], block_list=[g_iw, g_iw]) g_mat = block_iw_AB_to_matrix_valued(G_iw_block) d.chi_m = chi_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf) d.chi0_m = chi0_from_gg2_PH(g_mat, d.chi_m) # -- Numeric vertex from BSE d.gamma_m_num = inverse_PH(d.chi0_m) - inverse_PH(d.chi_m) # -- Analytic vertex d.gamma_m = gamma_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf) # -- Analytic magnetization expecation value # -- and static susceptibility d.Z = 2. + 2 * np.exp(-beta * 0.5 * U) d.m2 = 0.25 * (2 / d.Z) d.chi_m_static = 2. * beta * d.m2 d.label = r'Analytic' return d
p = mpi.bcast(p) # -- Sample G2 p.solve.n_cycles = int(1e9 / 40.) p.solve.measure_G_l = False p.solve.measure_G_tau = False p.solve.measure_G2_iw_ph = True p.solve.measure_G2_blocks = set([('up', 'up'), ('up', 'do')]) p.solve.measure_G2_n_bosonic = 1 p.solve.measure_G2_n_fermionic = 20 cthyb = triqs_cthyb.Solver(**p.init.dict()) cthyb.G0_iw << p.G0_w cthyb.solve(**p.solve.dict()) p.G2_iw_ph = cthyb.G2_iw_ph.copy() # -- Compute DMFT impurity vertex from triqs_tprf.linalg import inverse_PH from triqs_tprf.chi_from_gg2 import chi0_from_gg2_PH p.chi_m = p.G2_iw_ph[('up', 'up')] - p.G2_iw_ph[('up', 'do')] p.chi0_m = chi0_from_gg2_PH(p.G_w['up'], p.chi_m) p.gamma_m = inverse_PH(p.chi0_m) - inverse_PH(p.chi_m) del p.solve.measure_G2_blocks if mpi.is_master_node(): with HDFArchive('data_g2.h5', 'w') as a: a['p'] = p
def make_calc(): # ------------------------------------------------------------------ # -- Read precomputed ED data filename = "bse_and_rpa_loc_vs_latt.tar.gz" p = read_TarGZ_HDFArchive(filename)['p'] # ------------------------------------------------------------------ # -- RPA tensor 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(p.gf_struct) p.U_abcd = get_rpa_tensor(p.H_int, fundamental_operators) # ------------------------------------------------------------------ # -- Generalized PH susceptibility loc_bse = ParameterCollection() loc_bse.chi_wnn = chi_from_gg2_PH(p.G_iw, p.G2_iw_ph) loc_bse.chi0_wnn = chi0_from_gg2_PH(p.G_iw, p.G2_iw_ph) loc_bse.gamma_wnn = inverse_PH(loc_bse.chi0_wnn) - inverse_PH( loc_bse.chi_wnn) loc_bse.chi_wnn_ref = inverse_PH( inverse_PH(loc_bse.chi0_wnn) - loc_bse.gamma_wnn) np.testing.assert_array_almost_equal(loc_bse.chi_wnn.data, loc_bse.chi_wnn_ref.data) from triqs_tprf.bse import solve_local_bse loc_bse.gamma_wnn_ref = solve_local_bse(loc_bse.chi0_wnn, loc_bse.chi_wnn) np.testing.assert_array_almost_equal(loc_bse.gamma_wnn.data, loc_bse.gamma_wnn_ref.data) loc_bse.chi0_w = trace_nn(loc_bse.chi0_wnn) loc_bse.chi_w = trace_nn(loc_bse.chi_wnn) # ------------------------------------------------------------------ # -- RPA, using BSE inverses and constant Gamma loc_rpa = ParameterCollection() loc_rpa.chi0_wnn = loc_bse.chi0_wnn loc_rpa.chi0_w = loc_bse.chi0_w loc_rpa.U_abcd = p.U_abcd # -- Build constant gamma from triqs_tprf.rpa_tensor import get_gamma_rpa loc_rpa.gamma_wnn = get_gamma_rpa(loc_rpa.chi0_wnn, loc_rpa.U_abcd) # -- Solve RPA loc_rpa.chi_wnn = inverse_PH( inverse_PH(loc_rpa.chi0_wnn) - loc_rpa.gamma_wnn) loc_rpa.chi_w = trace_nn(loc_rpa.chi_wnn) # ------------------------------------------------------------------ # -- Bubble RPA on lattice lat_rpa = ParameterCollection() # -- Setup dummy lattice Green's function equal to local Green's function bz = BrillouinZone( BravaisLattice(units=np.eye(3), orbital_positions=[(0, 0, 0)])) periodization_matrix = np.diag(np.array(list([1] * 3), dtype=np.int32)) kmesh = MeshBrillouinZone(bz, periodization_matrix) wmesh = MeshImFreq(beta=p.beta, S='Fermion', n_max=p.nwf_gf) lat_rpa.g_wk = Gf(mesh=MeshProduct(wmesh, kmesh), target_shape=p.G_iw.target_shape) lat_rpa.g_wk[:, Idx(0, 0, 0)] = p.G_iw # -- chi0_wk bubble and chi_wk_rpa bubble RPA from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk lat_rpa.chi0_wk = imtime_bubble_chi0_wk(lat_rpa.g_wk, nw=1) from triqs_tprf.lattice import solve_rpa_PH lat_rpa.chi_wk = solve_rpa_PH(lat_rpa.chi0_wk, p.U_abcd) lat_rpa.chi0_w = lat_rpa.chi0_wk[:, Idx(0, 0, 0)] lat_rpa.chi_w = lat_rpa.chi_wk[:, Idx(0, 0, 0)] print '--> cf Tr[chi0] and chi0_wk' print loc_rpa.chi0_w.data.reshape((4, 4)).real print lat_rpa.chi0_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(loc_rpa.chi0_w.data, lat_rpa.chi0_w.data, decimal=2) print 'ok!' print '--> cf Tr[chi_rpa] and chi_wk_rpa' print loc_rpa.chi_w.data.reshape((4, 4)).real print lat_rpa.chi_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(loc_rpa.chi_w.data, lat_rpa.chi_w.data, decimal=2) print 'ok!' # ------------------------------------------------------------------ # -- Lattice BSE lat_bse = ParameterCollection() lat_bse.g_wk = lat_rpa.g_wk lat_bse.mu = p.mu lat_bse.e_k = Gf(mesh=kmesh, target_shape=p.G_iw.target_shape) lat_bse.e_k[Idx(0, 0, 0)] = np.eye(2) lat_bse.sigma_w = p.G_iw.copy() lat_bse.sigma_w << iOmega_n + lat_bse.mu * np.eye(2) - lat_bse.e_k[Idx( 0, 0, 0)] - inverse(p.G_iw) lat_bse.g_wk_ref = lat_bse.g_wk.copy() lat_bse.g_wk_ref[:, Idx(0, 0, 0)] << inverse(iOmega_n + lat_bse.mu * np.eye(2) - lat_bse.e_k[Idx(0, 0, 0)] - lat_bse.sigma_w) np.testing.assert_array_almost_equal(lat_bse.g_wk.data, lat_bse.g_wk_ref.data) #for w in lat_bse.g_wk.mesh.components[0]: # print w, lat_bse.g_wk[w, Idx(0,0,0)][0, 0] from triqs_tprf.lattice import fourier_wk_to_wr lat_bse.g_wr = fourier_wk_to_wr(lat_bse.g_wk) from triqs_tprf.lattice import chi0r_from_gr_PH lat_bse.chi0_wnr = chi0r_from_gr_PH(nw=1, nn=p.nwf, g_nr=lat_bse.g_wr) from triqs_tprf.lattice import chi0q_from_chi0r lat_bse.chi0_wnk = chi0q_from_chi0r(lat_bse.chi0_wnr) #for n in lat_bse.chi0_wnk.mesh.components[1]: # print n.value, lat_bse.chi0_wnk[Idx(0), n, Idx(0,0,0)][0,0,0,0] # -- Lattice BSE calc from triqs_tprf.lattice import chiq_from_chi0q_and_gamma_PH lat_bse.chi_kwnn = chiq_from_chi0q_and_gamma_PH(lat_bse.chi0_wnk, loc_bse.gamma_wnn) # -- Lattice BSE calc with built in trace from triqs_tprf.lattice import chiq_sum_nu_from_chi0q_and_gamma_PH lat_bse.chi_kw_ref = chiq_sum_nu_from_chi0q_and_gamma_PH( lat_bse.chi0_wnk, loc_bse.gamma_wnn) # -- Lattice BSE calc with built in trace using g_wk from triqs_tprf.lattice import chiq_sum_nu_from_g_wk_and_gamma_PH lat_bse.chi_kw_tail_corr_ref = chiq_sum_nu_from_g_wk_and_gamma_PH( lat_bse.g_wk, loc_bse.gamma_wnn) # -- Trace results from triqs_tprf.lattice import chi0q_sum_nu_tail_corr_PH from triqs_tprf.lattice import chi0q_sum_nu lat_bse.chi0_wk_tail_corr = chi0q_sum_nu_tail_corr_PH(lat_bse.chi0_wnk) lat_bse.chi0_wk = chi0q_sum_nu(lat_bse.chi0_wnk) from triqs_tprf.lattice import chiq_sum_nu, chiq_sum_nu_q lat_bse.chi_kw = chiq_sum_nu(lat_bse.chi_kwnn) np.testing.assert_array_almost_equal(lat_bse.chi_kw.data, lat_bse.chi_kw_ref.data) from triqs_tprf.bse import solve_lattice_bse lat_bse.chi_kw_tail_corr, tmp = solve_lattice_bse(lat_bse.g_wk, loc_bse.gamma_wnn) from triqs_tprf.bse import solve_lattice_bse_e_k_sigma_w lat_bse.chi_kw_tail_corr_new = solve_lattice_bse_e_k_sigma_w( lat_bse.mu, lat_bse.e_k, lat_bse.sigma_w, loc_bse.gamma_wnn) np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr.data, lat_bse.chi_kw_tail_corr_ref.data) np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr.data, lat_bse.chi_kw_tail_corr_new.data) np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr_ref.data, lat_bse.chi_kw_tail_corr_new.data) lat_bse.chi0_w_tail_corr = lat_bse.chi0_wk_tail_corr[:, Idx(0, 0, 0)] lat_bse.chi0_w = lat_bse.chi0_wk[:, Idx(0, 0, 0)] lat_bse.chi_w_tail_corr = lat_bse.chi_kw_tail_corr[Idx(0, 0, 0), :] lat_bse.chi_w = lat_bse.chi_kw[Idx(0, 0, 0), :] print '--> cf Tr[chi0_wnk] and chi0_wk' print lat_bse.chi0_w_tail_corr.data.reshape((4, 4)).real print lat_bse.chi0_w.data.reshape((4, 4)).real print lat_rpa.chi0_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(lat_bse.chi0_w_tail_corr.data, lat_rpa.chi0_w.data) np.testing.assert_array_almost_equal(lat_bse.chi0_w.data, lat_rpa.chi0_w.data, decimal=2) print 'ok!' print '--> cf Tr[chi_kwnn] and chi_wk (without chi0 tail corr)' print lat_bse.chi_w.data.reshape((4, 4)).real print loc_bse.chi_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(lat_bse.chi_w.data, loc_bse.chi_w.data) print 'ok!' # ------------------------------------------------------------------ # -- Use chi0 tail corrected trace to correct chi_rpa cf bubble dchi_wk = lat_bse.chi0_wk_tail_corr - lat_bse.chi0_wk dchi_w = dchi_wk[:, Idx(0, 0, 0)] loc_rpa.chi_w_tail_corr = loc_rpa.chi_w + dchi_w # -- this will be the same, but it will be close to the real physical value lat_bse.chi_w_tail_corr_ref = lat_bse.chi_w + dchi_w loc_bse.chi_w_tail_corr_ref = loc_bse.chi_w + dchi_w print '--> cf Tr[chi_rpa] and chi_wk_rpa' print loc_rpa.chi_w.data.reshape((4, 4)).real print loc_rpa.chi_w_tail_corr.data.reshape((4, 4)).real print lat_rpa.chi_w.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(loc_rpa.chi_w_tail_corr.data, lat_rpa.chi_w.data, decimal=3) print '--> cf Tr[chi_kwnn] with tail corr (from chi0_wnk)' print lat_bse.chi_w_tail_corr.data.reshape((4, 4)).real print lat_bse.chi_w_tail_corr_ref.data.reshape((4, 4)).real np.testing.assert_array_almost_equal(lat_bse.chi_w_tail_corr.data, lat_bse.chi_w_tail_corr_ref.data) print 'ok!' # ------------------------------------------------------------------ # -- Store to hdf5 filename = 'data_bse_rpa.h5' with HDFArchive(filename, 'w') as res: res['p'] = p
def make_calc(): # ------------------------------------------------------------------ # -- Hubbard atom with two bath sites, Hamiltonian p = ParameterCollection( beta=1.0, U=5.0, nw=1, nwf=20, ) p.nwf_gf = 4 * p.nwf p.mu = 0.5 * p.U # ------------------------------------------------------------------ ca_up, cc_up = c('0', 0), c_dag('0', 0) ca_do, cc_do = c('0', 1), c_dag('0', 1) docc = cc_up * ca_up * cc_do * ca_do nA = cc_up * ca_up + cc_do * ca_do p.H = -p.mu * nA + p.U * docc # ------------------------------------------------------------------ # -- Exact diagonalization # Conversion from TRIQS to Pomerol notation for operator indices # TRIQS: block_name, inner_index # Pomerol: site_label, orbital_index, spin_name index_converter = { ('0', 0): ('loc', 0, 'up'), ('0', 1): ('loc', 0, 'down'), } # -- Create Exact Diagonalization instance ed = PomerolED(index_converter, verbose=True) ed.diagonalize(p.H) # -- Diagonalize H gf_struct = [['0', [0, 1]]] # -- Single-particle Green's functions p.G_iw = ed.G_iw(gf_struct, p.beta, n_iw=p.nwf_gf)['0'] # -- Particle-particle two-particle Matsubara frequency Green's function opt = dict(beta=p.beta, gf_struct=gf_struct, blocks=set([("0", "0")]), n_iw=p.nw, n_inu=p.nwf) p.G2_iw_ph = ed.G2_iw_inu_inup(channel='PH', **opt)[('0', '0')] # ------------------------------------------------------------------ # -- Generalized susceptibility in magnetic PH channel p.chi_m = Gf(mesh=p.G2_iw_ph.mesh, target_shape=[1, 1, 1, 1]) p.chi_m[0, 0, 0, 0] = p.G2_iw_ph[0, 0, 0, 0] - p.G2_iw_ph[0, 0, 1, 1] p.chi0_m = chi0_from_gg2_PH(p.G_iw, p.chi_m) p.label = r'Pomerol' # ------------------------------------------------------------------ # -- Generalized susceptibility in PH channel p.chi = chi_from_gg2_PH(p.G_iw, p.G2_iw_ph) p.chi0 = chi0_from_gg2_PH(p.G_iw, p.G2_iw_ph) p.gamma = inverse_PH(p.chi0) - inverse_PH(p.chi) # ------------------------------------------------------------------ # -- Store to hdf5 filename = 'data_pomerol.h5' with HDFArchive(filename, 'w') as res: res['p'] = p