Exemple #1
0
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()
Exemple #2
0
def plot_chi_k(p, color=None):

    chi_k = p.chi_kw[:, Idx(0)]

    k_vecs, k_plot, K_plot, K_labels = get_path()
    kx, ky, kz = k_vecs.T

    interp = np.vectorize(
        lambda kx, ky, kz: np.squeeze(chi_k([kx, ky, kz]).real))
    interp = interp(kx, ky, kz)
    p.chi_G = np.squeeze(chi_k[Idx(0, 0, 0)].real)

    line = plt.plot(k_plot,
                    interp,
                    '-',
                    label=r'$N_{\nu} = $' + '${:d}$'.format(p.nwf))

    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()
Exemple #3
0
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')
Exemple #4
0
    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()
Exemple #5
0
    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())
Y = np.polyval(p, X)

subp = [1, 2, 1]
plt.subplot(*subp)
subp[-1] += 1
Exemple #6
0
              r'half-filled Hubbard atom $U=%2.2f$' % U)

    # ------------------------------------------------------------------
    # -- Analytic result

    T = np.logspace(-3, 2, num=400)
    beta = 1. / T

    # -- Analytic magnetization expecation value
    # -- and static susceptibility

    Z = 2. + 2 * np.exp(-beta * 0.5 * U)
    m2 = 0.25 * (2 / Z)
    chi_m = 2. * beta * m2

    plt.plot(1. / beta, chi_m, '-k', lw=0.5)

    # ------------------------------------------------------------------
    # -- external field pyed

    filenames = glob.glob('pyed_beta*/data_pyed_extrap*.h5')

    style = 'sk'
    for filename in filenames:
        print('--> Loading:', filename)

        with HDFArchive(filename, 'r') as s:
            field = s['field']

        plt.plot(1. / field.beta, field.chi, style, alpha=0.25)
        plt.plot(1. / field.beta, field.chi_exp, '.r', alpha=0.25)
Exemple #7
0
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()
Exemple #8
0
    qidx = bzmesh.index_to_linear(q)

    print('-' * 72)
    print('q =', q)
    print('qidx =', qidx)
    print('q_list[qidx] =', q_list[qidx])
    print('q_list[qidx]/np.pi =', np.array(q_list[qidx]) / np.pi)

    data = np.squeeze(chi0w0.data[:, qidx])
    print(data.shape)

    plt.subplot(*subp)
    subp[-1] += 1
    plt.title(r'$q = \pi \times$ %s' % str(np.array(q_list[qidx]) / np.pi))
    plt.plot(data.real)
    plt.ylabel(r'Re[$\chi_0(i\omega)$]')
    plt.ylim([-vmax, 0.1 * vmax])

    plt.subplot(*subp)
    subp[-1] += 1
    plt.plot(data.imag)
    plt.ylabel(r'Im[$\chi_0(i\omega)$]')

    plt.subplot(*subp)
    subp[-1] += 1
    plt.pcolormesh(chi0q.data[:, :, qidx, 0, 0, 0, 0].real, **opt)
    plt.colorbar()
    plt.axis('equal')
    plt.title(r'Re[$\chi_0(i\omega, i\nu)$]')
    plt.xlabel(r'$\nu$')
Exemple #9
0
#
################################################################################

from common import *
from triqs.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')