Example #1
0
File: plot.py Project: TRIQS/tprf
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()
Example #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)

    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')
Example #3
0
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()
Example #4
0
# -- 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()
Example #5
0
# TPRF. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################

from common import *
from triqs.plot.mpl_interface import oplot, oplotr, plt

with HDFArchive('data_g2.h5', 'r') as a:
    p = a['p']

plt.figure(figsize=(3.25 * 2.2, 2))
subp = [1, 3, 1]
opt = dict(cmap=plt.get_cmap('terrain_r'), vmin=0.0, vmax=0.01)
plt.subplot(*subp)
subp[-1] += 1
plt.title(r'$\chi^{(0)}_m$')
plt.imshow(np.squeeze(p.chi0_m.data).real, **opt)
plt.colorbar()
plt.subplot(*subp)
subp[-1] += 1
plt.title(r'$\chi_m$')
plt.imshow(np.squeeze(p.chi_m.data).real, **opt)
plt.colorbar()
plt.subplot(*subp)
subp[-1] += 1
plt.title(r'$\Gamma_m - U$')
plt.imshow((np.squeeze(p.gamma_m.data) - p.U).real,
           cmap=plt.get_cmap('RdBu_r'),
           vmin=-5,
           vmax=5)
plt.colorbar()
Example #6
0
    #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()

    if False:
        g2 = ana.gamma_m
        label = 'gamma ana'

        s = np.squeeze(g2.data[idx, :, :])

        ax = plt.subplot(*subp)
        subp[-1] += 1
        plt.title('Re ' + label + ' [i,:,:]')
        plt.pcolormesh(s.real, **opt)
        plt.colorbar()
Example #7
0
from triqs.operators import n
from triqs.operators.util.op_struct import set_operator_structure

from triqs.plot.mpl_interface import oplot, oplotr, oploti, plt

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

from brew_dmft.ParameterCollection import ParameterCollection

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

    U = 5.0

    plt.figure(figsize=(3.25, 2 * 3))
    plt.title('Static Magnetic Susceptibility' + '\n' +
              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)
Example #8
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()
Example #9
0
        chi0w0[qidx_lin] = chiw

# -- Plot static w=0 susceptibility in k-space

from triqs.plot.mpl_interface import oplot, oploti, oplotr, plt

# 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
Example #10
0
    from triqs.applications.susceptibility.fourier import chi4_iw_from_tau
    chi4_iw = chi4_iw_from_tau(chi4_tau, nw)

    from triqs.applications.susceptibility.fourier import chi4_tau_from_iw
    chi4_tau_ref = chi4_tau_from_iw(chi4_iw, nt)

    np.testing.assert_array_almost_equal(chi4_tau_ref.data, chi4_tau.data)

    # ------------------------------------------------------------------
    if False:
        from triqs.plot.mpl_interface import oplot, plt

        subp = [2, 2, 1]
        plt.subplot(*subp)
        subp[-1] += 1
        plt.title('chi4_tau')
        cut = chi4_tau[[0, all, all]]
        plt.pcolormesh(cut.data[:, :, 0, 0, 0, 0].real)
        plt.axis('square')

        plt.subplot(*subp)
        subp[-1] += 1
        plt.title('chi4_tau_ref')
        cut = chi4_tau_ref[[0, all, all]]
        plt.pcolormesh(cut.data[:, :, 0, 0, 0, 0].real)
        plt.axis('square')

        cidx = 5  # cut idx
        cut = chi4_iw[[cidx, all, all]]

        plt.subplot(*subp)