def plot_p(p): xlim = [-50, 50] subp = [3, 1, 1] plt.subplot(*subp) subp[-1] += 1 oploti(p.g0_w[0, 0], label=r'$G_0(i\omega_n)$') oploti(p.g_w[0, 0], label=r'$G(i\omega_n)$') oploti(p.sigma_w[0, 0], label=r'$\Sigma(i\omega_n)$') plt.legend(loc='best') plt.xlim(xlim) plt.subplot(*subp) subp[-1] += 1 oplotr(p.G_tau_raw['up'], alpha=0.75) oplotr(p.G_tau['up']) plt.gca().legend().set_visible(False) plt.subplot(*subp) subp[-1] += 1 G_l = p.G_l.copy() for b, g in G_l: G_l[b].data[:] = np.abs(g.data) oplotr(G_l['up'], 'o-') plt.semilogy([], []) plt.gca().legend().set_visible(False) plt.tight_layout() plt.savefig('figure_field_sc_gf.svg')
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_g2(G2, cplx=None, idx_labels=None, w=Idx(0), opt={}, title=None): data = G2[w, :, :].data if cplx == 're': data = data.real elif cplx == 'im': data = data.imag n = data.shape[-1] N = n**2 subp = [N, N, 1] colorbar_flag = True import itertools for idxs in itertools.product(xrange(n), repeat=4): i1, i2, i3, i4 = idxs d = data[:, :, i1, i2, i3, i4] ax = plt.subplot(*subp) subp[-1] += 1 if idx_labels is not None: labels = [idx_labels[idx] for idx in idxs] sub_title = r'$c^\dagger_{%s} c_{%s} c^\dagger_{%s} c_{%s}$' % tuple( labels) else: sub_title = str(idxs) plt.title(sub_title, fontsize=8) #plt.pcolormesh(d, **opt) if np.max(np.abs(d)) > 1e-10: plt.imshow(d, **opt) if colorbar_flag: if title is not None: plt.title(title) plt.colorbar() colorbar_flag = False ax.set_xticks([]) ax.set_yticks([]) plt.axis('equal') plt.tight_layout()
def plot_dynamic(p): plt.figure(figsize=(3.25 * 2, 8)) subp = [3, 2, 1] G2_iw_ph = p.G2_iw_ph d = np.squeeze(p.G2_iw_ph[('up', 'up')].data) lim = np.max([np.abs(d.real), np.abs(d.imag)]) opt = dict(vmin=-lim, vmax=lim, cmap='PuOr') ax = plt.subplot(*subp) subp[-1] += 1 plt.pcolormesh(d.real, **opt) ax = plt.subplot(*subp) subp[-1] += 1 plt.pcolormesh(d.imag, **opt) d = np.squeeze(p.G2_iw_ph[('up', 'do')].data) ax = plt.subplot(*subp) subp[-1] += 1 plt.pcolormesh(d.real, **opt) ax = plt.subplot(*subp) subp[-1] += 1 plt.pcolormesh(d.imag, **opt) d = np.squeeze(p.chi_m.data) lim = np.max([np.abs(d.real), np.abs(d.imag)]) ax = plt.subplot(*subp) subp[-1] += 1 plt.pcolormesh(d.real, **opt) ax = plt.subplot(*subp) subp[-1] += 1 plt.pcolormesh(d.imag, **opt) plt.tight_layout() plt.savefig('figure_dynamic.pdf')
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) 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')
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')
ax = plt.subplot(*subp) subp[-1] += 1 plt.title('Re ' + label + ' [:,i,:]') plt.pcolormesh(s.real, **opt) plt.colorbar() ax = plt.subplot(*subp) subp[-1] += 1 plt.title('Im ' + label + ' [:,i,:]') plt.pcolormesh(s.imag) plt.colorbar() s1 = np.squeeze(g1.data[:, :, idx]) s2 = np.squeeze(g2.data[:, :, idx]) s = s1 - s2 a = plt.subplot(*subp) subp[-1] += 1 plt.title('Re ' + label + ' [:,:,i]') plt.pcolormesh(s.real, **opt) plt.colorbar() a = plt.subplot(*subp) subp[-1] += 1 plt.title('Im ' + label + ' [:,:,i]') plt.pcolormesh(s.imag) plt.colorbar() plt.tight_layout() plt.show()