def plot_output(g0_wk, gamma): from triqs.plot.mpl_interface import oplot, plt initial_delta = semi_random_initial_delta(g0_wk) next_delta_summation = eliashberg_product(gamma_big, g0_wk, initial_delta) gamma_dyn_tr, gamma_const_r = preprocess_gamma_for_fft(gamma) next_delta_fft = eliashberg_product_fft(gamma_dyn_tr, gamma_const_r, g0_wk, initial_delta) deltas = [initial_delta, next_delta_summation, next_delta_fft] warnings.filterwarnings("ignore") #ignore some matplotlib warnings subp = [4, 3, 1] fig = plt.figure(figsize=(18, 15)) titles = ['Input', 'Summation', 'FFT'] for k_point in [Idx(0, 0, 0), Idx(1, 0, 0)]: ax = plt.subplot(*subp) subp[-1] += 1 oplot(g0_wk[:, k_point]) plt.title('GF') ax = plt.subplot(*subp) subp[-1] += 1 oplot(gamma[:, k_point]) plt.title('Gamma') ax = plt.subplot(*subp) subp[-1] += 1 oplot(gamma_dyn_tr[:, k_point]) plt.title('Gamma dyn tr') for delta, title in zip(deltas, titles): ax = plt.subplot(*subp) subp[-1] += 1 oplot(delta[:, k_point]) plt.title(title) ax.legend_ = None 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')
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(range(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()
plt.gca().set_xticks(K_plot) plt.gca().set_xticklabels(K_labels) plt.grid(True) plt.ylabel(r'$\chi(\mathbf{Q})$') plt.legend(loc='best', fontsize=8) return line[0].get_color() plt.figure(figsize=(3.25 * 2, 3)) ps, color = [], None for filename in np.sort(glob.glob('data_bse_nwf*.h5')): with HDFArchive(filename, 'r') as a: p = a['p'] subp = [1, 2, 1] plt.subplot(*subp) subp[-1] += 1 color = plot_chi_k(p) 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())
from triqs.plot.mpl_interface import oplot, oplotr, oploti, plt plt.figure(figsize=(6 * 2, 8)) #subp = [3, 6, 1] subp = [4, 1, 1] #idx = 20 idx = 0 vmax = np.max(np.abs(ana.gamma_m.data.real)) opt = dict(vmin=-vmax, vmax=vmax, cmap='PuOr') #opt = dict(vmin=-10., vmax=10., cmap='PuOr') #opt = dict(cmap='PuOr') ax = plt.subplot(*subp) subp[-1] += 1 oplot(ana.G_iw) if True: g2 = ana.gamma_m label = 'gamma ana' s = np.squeeze(g2.data[0, :, :]) ax = plt.subplot(*subp) subp[-1] += 1 plt.title('Re ' + label + ' [i,:,:]') plt.pcolormesh(s.real, **opt) plt.colorbar()
def test_cf_G_tau_and_G_iw_nonint(verbose=False): beta = 3.22 eps = 1.234 niw = 64 ntau = 2 * niw + 1 H = eps * c_dag(0, 0) * c(0, 0) fundamental_operators = [c(0, 0)] ed = TriqsExactDiagonalization(H, fundamental_operators, beta) # ------------------------------------------------------------------ # -- Single-particle Green's functions G_tau = GfImTime(beta=beta, statistic='Fermion', n_points=ntau, target_shape=(1, 1)) G_iw = GfImFreq(beta=beta, statistic='Fermion', n_points=niw, target_shape=(1, 1)) G_iw << inverse(iOmega_n - eps) G_tau << Fourier(G_iw) G_tau_ed = GfImTime(beta=beta, statistic='Fermion', n_points=ntau, target_shape=(1, 1)) G_iw_ed = GfImFreq(beta=beta, statistic='Fermion', n_points=niw, target_shape=(1, 1)) ed.set_g2_tau(G_tau_ed[0, 0], c(0, 0), c_dag(0, 0)) ed.set_g2_iwn(G_iw_ed[0, 0], c(0, 0), c_dag(0, 0)) # ------------------------------------------------------------------ # -- Compare gfs from triqs.utility.comparison_tests import assert_gfs_are_close assert_gfs_are_close(G_tau, G_tau_ed) assert_gfs_are_close(G_iw, G_iw_ed) # ------------------------------------------------------------------ # -- Plotting if verbose: from triqs.plot.mpl_interface import oplot, plt subp = [3, 1, 1] plt.subplot(*subp) subp[-1] += 1 oplot(G_tau.real) oplot(G_tau_ed.real) plt.subplot(*subp) subp[-1] += 1 diff = G_tau - G_tau_ed oplot(diff.real) oplot(diff.imag) plt.subplot(*subp) subp[-1] += 1 oplot(G_iw) oplot(G_iw_ed) plt.show()
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 << p.G_iw['up'] - a.G_iw diff.name = r'$G_{ctint} - G_{analytic}$' oplot(diff) plt.subplot(*subp); subp[-1] += 1 vmax = np.max(np.abs(p.chi_m.data.real)) opt = dict(vmax=vmax, vmin=-vmax, cmap='PuOr') data = np.squeeze(p.chi_m.data.real) plt.pcolormesh(data, **opt)
G, Sigma = {}, {} for solver in solver_lst: dat = HDFArchive('results/' + solver + '.h5', 'r') G[solver] = dat['G'] Sigma[solver] = G0_iw.copy() Sigma[solver] << inverse(G0_iw) - inverse(G[solver]) # === For every block and solver, plot Green function and Self energy block_lst = list(G[solver_lst[0]].indices) n_blocks = len(block_lst) for g, name in [[G, 'G'], [Sigma, '$\Sigma$']]: plt.subplots(n_blocks, 1, figsize=(10, 6 * n_blocks)) for i, block in enumerate(block_lst, 1): fig = plt.subplot(n_blocks, 1, i) fig.set_title(name + "[" + block + "]") for solver in solver_lst: marker = marker_lst[solver_lst.index(solver)] oplot(g[solver][block][0, 0], marker, name=name + "[0,0]_%s" % solver) plt.xlabel("$\omega_n$") plt.ylabel(name + "[" + block + "]$(i\omega_n)$") plt.tight_layout() plt.show()