def make_calc(beta=2.0, nwf=8): # ------------------------------------------------------------------ # -- Hubbard atom with two bath sites, Hamiltonian p = ParameterCollection( beta = beta, U = 5.0, nw = 1, nwf = nwf, nwf_gf = 2*nwf, ) ana = analytic_hubbard_atom(**p.dict()) p.chi = np.sum(ana.chi_m.data) / p.beta**2 # ------------------------------------------------------------------ # -- Store to hdf5 filename = 'data_dynamic_beta%6.6f_nwf%i.h5' % (p.beta, p.nwf) with HDFArchive(filename,'w') as res: res['p'] = p
plt.xlabel(r'$1/n_{w}$') plt.ylabel(r'$\max|\Gamma_{ana} - \Gamma_{num}|$') plt.ylim([0, diff_vec.max()]) plt.xlim([0, x.max()]) plt.tight_layout() plt.savefig('figure_bse_hubbard_atom_convergence.pdf') plt.show() # ---------------------------------------------------------------------- if __name__ == '__main__': p = ParameterCollection(beta=20., U=5., nw=1, nwf=20, nwf_gf=80) #ana = analytic_solution(**p.dict()) ana = analytic_hubbard_atom(**p.dict()) ana.gamma_m.data[:] -= p.U ana.gamma_m_num.data[:] -= p.U #for data in [ana.gamma_m.data, ana.gamma_m_num.data]: # #print np.max(np.abs(data.imag)) # np.testing.assert_array_almost_equal(data.imag, np.zeros_like(data)) diff = np.max(np.abs(ana.gamma_m_num.data.imag - ana.gamma_m.data.imag)) print 'max(abs(Im[diff])) =', diff diff = np.max(np.abs(ana.gamma_m_num.data.real - ana.gamma_m.data.real)) print 'max(abs(Re[diff])) =', diff #exit()
print p p.G_iw['up'].name = r'$G_{ctint, \uparrow}$' p.G_iw['dn'].name = r'$G_{ctint, \downarrow}$' p.chi_m = p.G2_iw[('up', 'up')] - p.G2_iw[('up', 'dn')] parm = ParameterCollection( U=p.U, beta=p.beta, nw=1, nwf=p.n_iw / 2, nwf_gf=p.n_iw, ) a = analytic_hubbard_atom(**parm.dict()) a.G_iw.name = r'$G_{analytic}$' plt.figure(figsize=(3.25 * 2, 3 * 2)) subp = [2, 2, 1] plt.subplot(*subp) subp[-1] += 1 oploti(p.G_iw) oploti(a.G_iw) plt.subplot(*subp) subp[-1] += 1 diff = a.G_iw.copy()
diff = np.max(np.abs(num - ref)) print 'diff =', diff parm.chi_w = chiq_sum_nu_q(parm.chi_wk) # static suscept return parm # ---------------------------------------------------------------------- if __name__ == '__main__': p = analytic_hubbard_atom( beta=1.234, U=5.0, nw=1, nwf=248, nwf_gf=2 * 248, ) p = solve_lattice_bse(p) # -- Tracing the analytic generalized susceptibility p.chi_w_analytic = np.sum(p.chi_m.data) / p.beta**2 # -- Tracing the numerical generalized susceptibility p.chi_w_ref = np.sum(p.chi_wk.data) / p.beta**2 print 'chi_w_analytic =', p.chi_w_analytic print 'chi_w.data =', p.chi_w.data.flatten() print 'chi_w_ref =', p.chi_w_ref
opt=opt, idx_labels=[r'\uparrow', r'\downarrow']) plt.show() # ---------------------------------------------------------------------- if __name__ == '__main__': filename = 'data_pomerol.h5' with HDFArchive(filename, 'r') as h5: pom = h5['p'] ana = analytic_hubbard_atom(beta=pom.beta, U=pom.U, nw=pom.nw, nwf=pom.nwf, nwf_gf=pom.nwf_gf) # -- Compare single-particle Green's functions np.testing.assert_array_almost_equal(pom.G_iw[0, 0].data, ana.G_iw[0, 0].data) # -- Compare generalized susceptibility (magnetic channel) np.testing.assert_array_almost_equal(pom.chi_m.data, ana.chi_m.data) np.testing.assert_array_almost_equal(pom.chi0_m.data, ana.chi0_m.data) print 'ok! Analytic chi_m agrees with ED (pomerol).' plot_res(ana, pom)
# ---------------------------------------------------------------------- import numpy as np from triqs.gf import * from triqs_tprf.analytic_hubbard_atom import analytic_hubbard_atom # ---------------------------------------------------------------------- if __name__ == '__main__': nwf_vec = np.array([5, 10, 20, 40, 80, 160]) diff_vec = np.zeros_like(nwf_vec, dtype=np.float) for idx, nwf in enumerate(nwf_vec): d = analytic_hubbard_atom(beta=2.0, U=5.0, nw=1, nwf=nwf, nwf_gf=2 * nwf) diff_vec[idx] = np.max(np.abs(d.gamma_m.data - d.gamma_m_num.data)) print('nwf, diff =', idx, nwf, diff_vec[idx]) # ------------------------------------------------------------------ # -- Plot from triqs.plot.mpl_interface import oplot, oplotr, oploti, plt x = 1. / nwf_vec plt.figure(figsize=(3.25, 3)) plt.plot(x, diff_vec, 'o-', alpha=0.75)