Exemplo n.º 1
0
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')
Exemplo n.º 2
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)

    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')
Exemplo n.º 3
0
#assert( diff == Operator() )

diff = np.max(np.abs(Delta_tau.data - Delta_tau_ref.data))
print 'Delta_tau diff =', diff
np.testing.assert_array_almost_equal(Delta_tau.data, Delta_tau_ref.data)
assert( diff < 1e-8 )

diff = np.max(np.abs(Delta_iw.data - Delta_iw_ref.data))
print 'Delta_iw diff =', diff
np.testing.assert_array_almost_equal(Delta_iw.data, Delta_iw_ref.data)
assert( diff < 1e-7 )

if False:
    from pytriqs.plot.mpl_interface import oplot, oplotr, oploti, plt
    plt.figure()
    oplotr(Delta_tau - Delta_tau_ref)
    plt.show()
    
    plt.figure()
    oplotr(Delta_tau)
    oplotr(Delta_tau_ref)

    plt.figure()
    oplotr(Delta_iw)
    oplotr(Delta_iw_ref)

    plt.figure()
    oploti(Delta_iw)
    oploti(Delta_iw_ref)
    
    plt.show()
Exemplo n.º 4
0
    a['Delta_iw'] = Delta_iw
    a['Delta_iw_ref'] = Delta_iw_ref
    a['Delta_iw_fit'] = Delta_iw_fit

# -- Plot 

from pytriqs.plot.mpl_interface import oplot, oplotr, oploti, plt
plt.figure(figsize=(10, 10))

ylim = [-4, 4]

plt.plot([w_min.imag]*2, ylim, 'sr-', lw=0.5)
plt.plot([w_max.imag]*2, ylim, 'sr-', lw=0.5)
         
for i1, i2 in itertools.product(range(2), repeat=2):
    oplotr(Delta_iw[i1, i2], alpha=0.1)
    oploti(Delta_iw[i1, i2], alpha=0.1)

    oplotr(Delta_iw_ref[i1, i2], lw=4, alpha=0.25)
    oploti(Delta_iw_ref[i1, i2], lw=4, alpha=0.25)

    oplotr(Delta_iw_fit[i1, i2])
    oploti(Delta_iw_fit[i1, i2])

ax = plt.gca()
ax.legend_ = None

plt.ylim([-1, 1])
plt.tight_layout()
plt.savefig(figure_filename)
plt.show(); exit()
Exemplo n.º 5
0
    filename = 'data_pyed_h_field_0.0000.h5'
    print '--> Loading:', filename
    with HDFArchive(filename, 'r') as s:
        pyed = s['p']

    plt.figure(figsize=(3.25 * 2, 8))

    subp = [3, 1, 1]
    plt.subplot(*subp)
    subp[-1] += 1

    #oplotr(O_tau_regr, '-', label=r'cthyb regr $-\langle n_\uparrow(\tau) n_\downarrow \rangle$ (should be bad)', alpha=1.0, lw=1.0, zorder=100)
    oplotr(cthyb.O_tau,
           '-',
           label=r'cthyb $\langle n_\uparrow(\tau) n_\downarrow \rangle$',
           alpha=0.5,
           lw=0.5)
    oplotr(pyed.O_tau,
           label=r'pyed $\langle n_\uparrow(\tau) n_\downarrow \rangle$')

    plt.plot(0, cthyb.exp_val, 'or', alpha=0.25, clip_on=False)
    plt.plot(0, pyed.exp_val, 'xg', alpha=0.25, clip_on=False)

    plt.subplot(*subp)
    subp[-1] += 1
    tau = np.array([float(t) for t in cthyb.O_tau.mesh])

    tau_ref = np.array([float(t) for t in pyed.O_tau.mesh])
    O_ref = pyed.O_tau.data.copy()
    O_interp = np.interp(tau, tau_ref, O_ref)
print 'h_loc =\n', h_loc
print 'h_loc_ref =\n', h_loc_ref

Delta_tau_ref = S.Delta_tau['0']
Delta_iw_ref = Delta_iw.copy()
Delta_iw_ref << Fourier(Delta_tau_ref)

diff = h_loc - h_loc_ref
print 'h_loc diff =', diff
for ops, prefactor in diff:
    assert (np.abs(prefactor) < 1e-12)
#assert( diff == Operator() )

diff = np.max(np.abs(Delta_tau.data - Delta_tau_ref.data))
print 'Delta_tau diff =', diff
np.testing.assert_array_almost_equal(Delta_tau.data, Delta_tau_ref.data)
assert (diff < 1e-8)

diff = np.max(np.abs(Delta_iw.data - Delta_iw_ref.data))
print 'Delta_iw diff =', diff
np.testing.assert_array_almost_equal(Delta_iw.data, Delta_iw_ref.data)
assert (diff < 1e-7)

if False:
    from pytriqs.plot.mpl_interface import oplot, oplotr, oploti, plt
    oplotr(Delta_tau)
    oplotr(Delta_tau_ref)
    plt.show()
    exit()
Exemplo n.º 7
0
Arquivo: plot.py Projeto: yuechm/pyed
# ----------------------------------------------------------------------

import itertools
import numpy as np

# ----------------------------------------------------------------------

import matplotlib.pyplot as plt

# ----------------------------------------------------------------------

from pytriqs.gf import Gf
from pytriqs.archive import HDFArchive
from pytriqs.plot.mpl_interface import oplotr

# ----------------------------------------------------------------------
if __name__ == '__main__':

    with HDFArchive('data_ed.h5', 'r') as res:
        oplotr(res['tot'], name='pyed')

    with HDFArchive('spinless.ed.h5', 'r') as res:
        oplotr(res['tot'], name='ed')

    plt.savefig('figure_ed_vs_pyed.pdf')
    plt.show()
Exemplo n.º 8
0
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)
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])