Пример #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()
Пример #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')
Пример #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()
Пример #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()
Пример #5
0
def plot_res(ana, pom):

    from triqs_tprf.plot import plot_g2, get_g2_opt
    from triqs.plot.mpl_interface import oplot, oplotr, oploti, plt

    opt = get_g2_opt(pom.chi, cplx='re', cut=0.1)

    plt.figure(figsize=(6, 6))
    plot_g2(pom.G2_iw_ph,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(6, 6))
    plot_g2(pom.chi0,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(6, 6))
    plot_g2(pom.chi,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(3, 3))
    plot_g2(pom.chi_m,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(3, 3))
    plot_g2(pom.chi0_m,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    opt = get_g2_opt(pom.gamma, cplx='re', cut=0.1)
    opt['vmin'] = -5.
    opt['vmax'] = +5.

    plt.figure(figsize=(6, 6))
    plot_g2(pom.gamma,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(3, 3))
    plot_g2(ana.gamma_m,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.show()
Пример #6
0
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# 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$')
Пример #7
0
    ana.gamma_m_num.data[:] -= p.U

    #for data in [ana.gamma_m.data, ana.gamma_m_num.data]:
    #    #print np.max(np.abs(data.imag))
    #    np.testing.assert_array_almost_equal(data.imag, np.zeros_like(data))

    diff = np.max(np.abs(ana.gamma_m_num.data.imag - ana.gamma_m.data.imag))
    print('max(abs(Im[diff])) =', diff)

    diff = np.max(np.abs(ana.gamma_m_num.data.real - ana.gamma_m.data.real))
    print('max(abs(Re[diff])) =', diff)

    #exit()

    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)
Пример #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()
Пример #9
0
Файл: plot.py Проект: TRIQS/tprf
    p.G_iw['dn'].name = r'$G_{ctint, \downarrow}$'

    p.chi_m = p.G2_iw[('up', 'up')] - p.G2_iw[('up', 'dn')]
    
    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
Пример #10
0
           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

opt = dict(vmin=-0.01, vmax=0.01, cmap='PuOr')
plt.figure(figsize=(12, 8))

subp = [3, 4, 1]

for q in [[0, 0, 0], [n_k / 2, n_k / 2, 0], [n_k / 2, 0, 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)
Пример #11
0
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# TPRF. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################

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 |$')