def window_conv_depr(): nwf_vec = np.array([5, 10, 20, 40, 80, 160, 320]) diff_vec = np.zeros_like(nwf_vec, dtype=np.float) for idx, nwf in enumerate(nwf_vec): d = analytic_solution(beta=2.0, U=5.0, nw=1, nwf=nwf) diff = np.max(np.abs(d.gamma_m.data - d.gamma_m_num.data)) diff_vec[idx] = diff print('nwf, diff =', idx, nwf, diff) print(diff_vec) 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) 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()
def plot_field(out): plt.figure(figsize=(3.25 * 2, 8)) for p in out.data: subp = [2, 1, 1] ax = plt.subplot(*subp) subp[-1] += 1 oplotr(p.G_tau['up'], 'b', alpha=0.25) oplotr(p.G_tau['dn'], 'g', alpha=0.25) ax.legend().set_visible(False) subp = [2, 1, 2] plt.subplot(*subp) subp[-1] += 1 plt.title(r'$\chi \approx %2.2f$' % out.chi) plt.plot(out.h_vec, out.m_vec, '-og', alpha=0.5) plt.plot(out.h_vec, out.m_ref_vec, 'xb', alpha=0.5) plt.plot(out.h_vec, -out.chi * out.h_vec, '-r', alpha=0.5) plt.tight_layout() plt.savefig('figure_static_field.pdf')
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) 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()
# -- Extrapolation to nwf -> oo ps = ParameterCollections(objects=ps) x, y = 1. / ps.nwf, ps.chi_G sidx = np.argsort(x) x, y = x[sidx], y[sidx] p = np.polyfit(x, y, 1) y0 = np.polyval(p, 0) X = np.linspace(0, x.max()) Y = np.polyval(p, X) subp = [1, 2, 1] plt.subplot(*subp) subp[-1] += 1 plt.plot(0, y0, 'rx') plt.plot(0, 0.3479, 'r+') plt.subplot(*subp) subp[-1] += 1 plt.plot(X, Y, '--k', lw=1.0, zorder=-100) plt.plot(0, 0.3479, 'r+', label=r'Field') plt.plot(0, y0, 'rx', label=r'BSE') plt.grid(True) plt.legend(loc='best', fontsize=8) plt.xlabel(r'$1/N_\nu$') plt.ylabel(r'$\chi(\mathbf{0})$') plt.title( r'$\lim_{n_\nu \rightarrow \infty} \, \chi(\mathbf{0}) \approx $' + \ '${:3.4f}$'.format(y0)) plt.tight_layout() plt.savefig('figure_bse.svg') plt.show()
from triqs.plot.mpl_interface import oplot, oplotr, plt with HDFArchive('data_g2.h5', 'r') as a: p = a['p'] plt.figure(figsize=(3.25 * 2.2, 2)) subp = [1, 3, 1] opt = dict(cmap=plt.get_cmap('terrain_r'), vmin=0.0, vmax=0.01) plt.subplot(*subp) subp[-1] += 1 plt.title(r'$\chi^{(0)}_m$') plt.imshow(np.squeeze(p.chi0_m.data).real, **opt) plt.colorbar() plt.subplot(*subp) subp[-1] += 1 plt.title(r'$\chi_m$') plt.imshow(np.squeeze(p.chi_m.data).real, **opt) plt.colorbar() plt.subplot(*subp) subp[-1] += 1 plt.title(r'$\Gamma_m - U$') plt.imshow((np.squeeze(p.gamma_m.data) - p.U).real, cmap=plt.get_cmap('RdBu_r'), vmin=-5, vmax=5) plt.colorbar() plt.tight_layout() plt.savefig('figure_g2.svg') plt.show()
styles = {256: '^b', 128: '>r', 64: '<g', 32: '.m', 16: '.c', 8: '.y'} for filename in filenames: print('--> Loading:', filename) with HDFArchive(filename, 'r') as s: p = s['p'] if hasattr(p, 'chi'): style = styles[p.nwf] plt.plot(1. / p.beta, p.chi, style, alpha=0.5) for nw in np.sort(list(styles.keys())): style = styles[nw] plt.plot([], [], style, alpha=0.5, label=r'Analytic Tr$[\chi_m]/\beta^2$, $n_w=%i$' % nw) # ------------------------------------------------------------------ plt.legend(loc='best', fontsize=6, frameon=False) #plt.xlabel(r'$\beta$') plt.xlabel(r'$T$') plt.ylabel(r'$\chi_m$') plt.loglog([], []) plt.tight_layout() plt.savefig('figure_hubbard_atom_static_magnetic_susceptibility.pdf') plt.show()
ps = [] filenames = np.sort(glob.glob('data_B_*.h5')) for filename in filenames: with HDFArchive(filename, 'r') as a: p = a['ps'].objects[-1] ps.append(p) ps = ParameterCollections(ps) B, M = ps.B, ps.M B = np.concatenate((-B[1:][::-1], B)) M = np.concatenate((-M[1:][::-1], M)) p = np.polyfit(M, B, 5) m = np.linspace(-0.5, 0.5, num=1000) b = np.polyval(p, m) chi = 1. / np.polyval(np.polyder(p, 1), 0.).real plt.figure(figsize=(3.25 * 1.5, 2.5 * 1.5)) plt.title(r'$\chi = \frac{dM}{dB}|_{B=0} \approx $' + '$ {:3.4f}$'.format(chi)) plt.plot(B, M, 'o', alpha=0.75, label='DMFT field') plt.plot(b, m, '-', alpha=0.75, label='Poly fit') plt.legend(loc='upper left') plt.grid(True) plt.xlabel(r'$B$') plt.ylabel(r'$M$') plt.xlim([B.min(), B.max()]) plt.ylim([-0.5, 0.5]) plt.tight_layout() plt.savefig('figure_field.svg') plt.show()
vmax = np.max(data.real) plt.title('Square-lattice ' + r'$\chi_0(q, \omega=0)$, $\beta=%2.2f$' % beta) plt.pcolor(qx.reshape((n_k, n_k)), qy.reshape((n_k, n_k)), data.reshape((n_k, n_k)).real, cmap='magma', vmin=0, vmax=vmax) plt.colorbar() plt.axis('equal') plt.xlabel('$q_x/\pi$') plt.ylabel('$q_y/\pi$') plt.tight_layout() plt.savefig('figure_chi0q_w0_square_latt.pdf') # -- Plot Gamma and M point dynamic susceptibilities opt = dict(vmin=-0.01, vmax=0.01, cmap='PuOr') plt.figure(figsize=(12, 8)) subp = [3, 4, 1] for q in [[0, 0, 0], [n_k / 2, n_k / 2, 0], [n_k / 2, 0, 0]]: qidx = bzmesh.index_to_linear(q) print('-' * 72) print('q =', q) print('qidx =', qidx)
subp[-1] += 1 plt.plot(ps.iter, ps.dG_l, 's-') plt.ylabel('$\max | \Delta G_l |$') plt.xlabel('Iteration') plt.semilogy([], []) plt.subplot(*subp) subp[-1] += 1 for b, g in p.G_l: p.G_l[b].data[:] = np.abs(g.data) oplotr(p.G_l['up'], 'o-', label=None) plt.ylabel('$| G_l |$') plt.semilogy([], []) plt.subplot(*subp) subp[-1] += 1 oplotr(p.G_tau_raw['up'], alpha=0.75, label='Binned') oplotr(p.G_tau['up'], label='Legendre') plt.legend(loc='best', fontsize=8) plt.ylabel(r'$G(\tau)$') plt.subplot(*subp) subp[-1] += 1 oploti(p.sigma_w[0, 0], '.-', label=None) plt.ylabel(r'$\Sigma(i\omega_n)$') plt.xlim([-100, 100]) plt.tight_layout() plt.savefig('figure_sc.svg') plt.show()