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 pytriqs.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_ps(ps): subp = [2, 1, 1] plt.subplot(*subp) subp[-1] += 1 plt.plot(ps.iter, ps.dG_l, 's-', label=r'$\Delta G_l$') plt.plot(ps.iter, ps.dM, 'o-', label=r'$\Delta M$') plt.semilogy([], []) plt.ylabel('$\Delta G_l$, $\Delta M$') plt.legend(loc='best') plt.xlabel('Iteration') plt.subplot(*subp) subp[-1] += 1 plt.plot(ps.iter, ps.B, 's-', label=r'$B$') plt.plot(ps.iter, ps.M, 'o-', label=r'$M$') plt.ylabel(r'$M$, $B$') plt.legend(loc='best') plt.xlabel('Iteration') plt.tight_layout() plt.savefig('figure_field_sc.svg')
for filename in filenames: print '--> Loading:', filename with HDFArchive(filename, 'r') as s: p = s['p'] if hasattr(p, 'chi'): nw = p.solve.measure_G2_n_fermionic nc = int(np.log10(p.n_cycles)) style = styles[(nw, nc)] plt.plot(1. / p.beta, p.chi, style, alpha=0.5) for (nw, nc), style in styles.items(): plt.plot([], [], style, alpha=0.5, label='cthyb dynamic $n_w=%i$, $\log n_c=%i$' % (nw, nc)) # ------------------------------------------------------------------ plt.legend(loc='best', fontsize=6, frameon=False) plt.xlabel(r'$T$') plt.ylabel(r'$\chi_m$') plt.tight_layout() plt.savefig('figure_summary.pdf') plt.show()
plt.subplot(*subp); subp[-1] += 1 plt.plot(1./p.nwf, p.chi_G, 'o', color=color) ps.append(p) # -- 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()
# plot zeroth bosonic matsubara freq susceptibility qx = np.array([q[0] for q in q_list])/np.pi qy = np.array([q[1] for q in q_list])/np.pi data = np.squeeze(chi0w0.data[iw_zero_idx]) data = -1.0 * data 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)
from common import * from pytriqs.plot.mpl_interface import oplot, oplotr, oploti, plt with HDFArchive('data_sc.h5', 'r') as a: ps = a['ps'] p = ps.objects[-1] plt.figure(figsize=(3.25 * 2, 5)) subp = [2, 2, 1] plt.subplot(*subp) 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)
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()
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 pytriqs.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()