Beispiel #1
0
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 << InverseFourier(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 pytriqs.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 pytriqs.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()
Beispiel #2
0
def make_calc(beta=2.0, h_field=0.0):
    
    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian

    p = ParameterCollection(
        beta = beta,
        h_field = h_field,
        U = 5.0,
        ntau = 40,
        niw = 15,
        )

    p.mu = 0.5*p.U
    
    # ------------------------------------------------------------------

    print '--> Solving SIAM with parameters'
    print p
    
    # ------------------------------------------------------------------

    up, do = 'up', 'dn'
    docc = c_dag(up,0) * c(up,0) * c_dag(do,0) * c(do,0)
    mA = c_dag(up,0) * c(up,0) - c_dag(do,0) * c(do,0)
    nA = c_dag(up,0) * c(up,0) + c_dag(do,0) * c(do,0)

    p.H = -p.mu * nA + p.U * docc + p.h_field * mA
    
    # ------------------------------------------------------------------

    fundamental_operators = [c(up,0), c(do,0)]
    
    ed = TriqsExactDiagonalization(p.H, fundamental_operators, p.beta)

    g_tau = GfImTime(beta=beta, statistic='Fermion', n_points=40, indices=[0])
    g_iw = GfImFreq(beta=beta, statistic='Fermion', n_points=10, indices=[0])

    p.G_tau = BlockGf(name_list=[up,do], block_list=[g_tau]*2, make_copies=True)
    p.G_iw = BlockGf(name_list=[up,do], block_list=[g_iw]*2, make_copies=True)
    
    ed.set_g2_tau(p.G_tau[up], c(up,0), c_dag(up,0))
    ed.set_g2_tau(p.G_tau[do], c(do,0), c_dag(do,0))

    ed.set_g2_iwn(p.G_iw[up], c(up,0), c_dag(up,0))
    ed.set_g2_iwn(p.G_iw[do], c(do,0), c_dag(do,0))

    p.magnetization = ed.get_expectation_value(0.5 * mA)
    p.magnetization2 = ed.get_expectation_value(0.25 * mA * mA)
    
    # ------------------------------------------------------------------
    # -- Store to hdf5
    
    filename = 'data_pyed_h_field_%4.4f.h5' % h_field
    with HDFArchive(filename,'w') as res:
        res['p'] = p
Beispiel #3
0
 def __init__(self, g2_iw_inu_inup):
     g2 = g2_iw_inu_inup
     n1, n2 = g2._Block2Gf__indices1, g2._Block2Gf__indices2
     indices = [i for i in g2.indices]
     g2block0 = g2[indices[0]]
     self.beta = g2block0.mesh.components[0].beta
     for n, m in itt.product(n1, n2):
         assert g2[(n, m)].data.shape[3] == g2[(n, m)].data.shape[4] == g2[(
             n, m
         )].data.shape[5] == g2[(n, m)].data.shape[
             6], 'blockstructure not supported (TODO), blocksizes have to equal each other'
     Block2Gf.__init__(self, n1, n2, [[
         GfImFreq(mesh=g2[(n, m)].mesh.components[0],
                  target_shape=g2[(n, m)].data.shape[3:]) for m in n2
     ] for n in n1])
     self.perform_trace(g2)
Beispiel #4
0

def read_histo(f, type_of_col_1):
    histo = []
    for line in f:
        cols = filter(lambda s: s, line.split(' '))
        histo.append((type_of_col_1(cols[0]), float(cols[1]), float(cols[2])))
    return histo


if mpi.is_master_node():
    arch = HDFArchive('asymm_bath.h5', 'w')

# Set hybridization function
for e in epsilon:
    delta_w = GfImFreq(indices=[0], beta=beta)
    delta_w << (V**2) * inverse(iOmega_n - e)

    S.G0_iw["up"] << inverse(iOmega_n - ed - delta_w)
    S.G0_iw["dn"] << inverse(iOmega_n - ed - delta_w)

    S.solve(h_int=H, **p)

    if mpi.is_master_node():
        arch.create_group('epsilon_' + str(e))
        gr = arch['epsilon_' + str(e)]
        gr['G_tau'] = S.G_tau
        gr['beta'] = beta
        gr['U'] = U
        gr['ed'] = ed
        gr['V'] = V
Beispiel #5
0
    h_bath = np.array([
        [0, 0, V2, 0],
        [0, 0, 0, V3],
        [V2, 0, E2, 0],
        [0, V3, 0, E3],
    ])

    h_bath = np.kron(h_bath, I)
    p.H_bath = get_quadratic_operator(h_bath, p.op_full)

    # -- Weiss field of the bath

    h_tot = quadratic_matrix_from_operator(p.H_bath + p.H_loc, p.op_full)

    g0_iw = GfImFreq(beta=p.beta,
                     statistic='Fermion',
                     n_points=p.nw,
                     target_shape=(8, 8))

    g0_iw << inverse(iOmega_n - h_tot)

    p.g0_iw = g0_iw[:4, :4]  # -- Cut out impurity Gf
    p.g0t_iw = g2_single_particle_transform(p.g0_iw, p.T.H)

    p.g0_tau = GfImTime(beta=p.beta,
                        statistic='Fermion',
                        n_points=p.ntau,
                        target_shape=(4, 4))

    p.g0_tau << InverseFourier(p.g0_iw)
    p.g0t_tau = g2_single_particle_transform(p.g0_tau, p.T.H)
Beispiel #6
0
        ]
        for o in orb_names:
            dn = n(*mkind("up", o)) - n(*mkind("dn", o))
            QN.append(dn * dn)
        p["partition_method"] = "quantum_numbers"
        p["quantum_numbers"] = QN

    mpi.report("Constructing the solver...")

    # Construct the solver
    S = SolverCore(beta=beta, gf_struct=gf_struct, n_tau=n_tau, n_iw=n_iw)

    mpi.report("Preparing the hybridization function...")

    # Set hybridization function
    delta_w = GfImFreq(indices=orb_names, beta=beta, n_points=n_iw)
    delta_w_part = delta_w.copy()
    for e, v in zip(epsilon, V):
        delta_w_part << inverse(iOmega_n - e)
        delta_w_part.from_L_G_R(np.transpose(v), delta_w_part, v)
        delta_w += delta_w_part

    S.G0_iw << inverse(iOmega_n + mu - delta_w)

    mpi.report("Running the simulation...")

    # Solve the problem
    S.solve(h_int=H, **p)

    # Save the results
    if mpi.is_master_node():
Beispiel #7
0
import numpy as np

from pytriqs.gf import Gf, MeshImFreq, MeshImTime
from pytriqs.gf import GfImFreq, GfImTime
from pytriqs.gf import iOmega_n, inverse, InverseFourier

beta = 1.234
eps = 3.55
nw = 100
nt = 1000

g_iw = GfImFreq(name=r'$g(i\omega_n)$',
                beta=beta,
                statistic='Fermion',
                n_points=nw,
                indices=[1])

g_iw << inverse(iOmega_n - eps)

g_tau = GfImTime(name=r'$g(\tau)$',
                 beta=beta,
                 statistic='Fermion',
                 n_points=nt,
                 indices=[1])

g_tau << InverseFourier(g_iw)

# -- Test fourier

from pytriqs.applications.tprf.fourier import g_iw_from_tau
g_iw_ref = g_iw_from_tau(g_tau, nw)
Beispiel #8
0
from pytriqs.operators import n, c, c_dag
from pytriqs.archive import HDFArchive
from triqs_cthyb import SolverCore

cp = dict(beta=10.0,
          gf_struct=[['up', [0]], ['do', [0]]],
          n_iw=1025,
          n_tau=2500,
          n_l=20)

solver = SolverCore(**cp)

# Set hybridization function
mu = 0.5
half_bandwidth = 1.0
delta_w = GfImFreq(indices=[0], beta=cp['beta'])
delta_w << (half_bandwidth / 2.0)**2 * SemiCircular(half_bandwidth)
for name, g0 in solver.G0_iw:
    g0 << inverse(iOmega_n + mu - delta_w)

sp = dict(
    h_int=n('up', 0) * n('do', 0) + c_dag('up', 0) * c('do', 0) +
    c_dag('do', 0) * c('up', 0),
    max_time=-1,
    length_cycle=50,
    n_warmup_cycles=50,
    n_cycles=500,
    move_double=False,
)

solver.solve(**sp)
Beispiel #9
0
from pytriqs.plot.mpl_interface import oplot
from pytriqs.gf import GfImFreq, Omega, inverse

g = GfImFreq(indices=[0], beta=300, n_points=1000, name="g")
g << inverse(Omega + 0.5)

# the data we want to fit...
# The green function for omega \in [0,0.2]
X, Y = g.x_data_view(x_window=(0, 0.2), flatten_y=True)

from pytriqs.fit import Fit, linear, quadratic

fitl = Fit(X, Y.imag, linear)
fitq = Fit(X, Y.imag, quadratic)

oplot(g, '-o', x_window=(0, 5))
oplot(fitl, '-x', x_window=(0, 0.5))
oplot(fitq, '-x', x_window=(0, 1))

# a bit more complex, we want to fit with a one fermion level ....
# Cf the definition of linear and quadratic in the lib
one_fermion_level = lambda X, a, b: 1 / (a * X * 1j + b
                                         ), r"${1}/(%f x + %f)$", (1, 1)

fit1 = Fit(X, Y, one_fermion_level)
oplot(fit1, '-x', x_window=(0, 3))
Beispiel #10
0
    if use_qn:
        QN = [sum([n(*mkind("up",o)) for o in orb_names],Operator()),
              sum([n(*mkind("dn",o)) for o in orb_names],Operator())]
        for o in orb_names:
            dn = n(*mkind("up",o)) - n(*mkind("dn",o))
            QN.append(dn*dn)
        p["partition_method"] = "quantum_numbers"
        p["quantum_numbers"] = QN

    mpi.report("Constructing the solver...")

    # Construct the solver
    S = SolverCore(beta=beta, gf_struct=gf_struct, n_tau=n_tau, n_iw=n_iw)

    mpi.report("Preparing the hybridization function...")

    # Set hybridization function
    delta_w = GfImFreq(indices = [0], beta=beta, n_points=n_iw)
    delta_w << (V**2) * inverse(iOmega_n - epsilon) + (V**2) * inverse(iOmega_n + epsilon)
    S.G0_iw << inverse(iOmega_n + mu - delta_w)

    mpi.report("Running the simulation...")

    # Solve the problem
    S.solve(h_int=H, **p)

    # Save the results  
    if mpi.is_master_node():
        with HDFArchive(results_file_name,'w') as Results:
            Results['G_tau'] = S.G_tau
Beispiel #11
0
# Import the Green's functions
from pytriqs.gf import GfImFreq, iOmega_n, inverse

# Create the Matsubara-frequency Green's function and initialize it
g = GfImFreq(indices=[1], beta=50, n_points=1000, name="$G_\mathrm{imp}$")
g << inverse(iOmega_n + 0.5)

from pytriqs.plot.mpl_interface import oplot
oplot(g, '-o', x_window=(0, 10))
Beispiel #12
0
def run_calculation(use_qn=True):

    # Input parameters
    beta = 10.0
    U = 2.0
    mu = 1.0
    epsilon = 2.3
    t = 0.1

    n_iw = 1025
    n_tau = 10001

    p = {}
    p["max_time"] = -1
    p["random_name"] = ""
    p["random_seed"] = 123 * mpi.rank + 567
    p["length_cycle"] = 50
    p["n_warmup_cycles"] = 20000
    p["n_cycles"] = 1000000

    results_file_name = "spinless"
    if use_qn: results_file_name += ".qn"
    results_file_name += ".h5"

    mpi.report(
        "Welcome to spinless (spinless electrons on a correlated dimer) test.")

    H = U * n("tot", "A") * n("tot", "B")

    QN = []
    if use_qn:
        QN.append(n("tot", "A") + n("tot", "B"))
        p["partition_method"] = "quantum_numbers"
        p["quantum_numbers"] = QN

    gf_struct = [["tot", ["A", "B"]]]

    mpi.report("Constructing the solver...")

    ## Construct the solver
    S = SolverCore(beta=beta, gf_struct=gf_struct, n_iw=n_iw, n_tau=n_tau)

    mpi.report("Preparing the hybridization function...")

    ## Set hybridization function
    delta_w = GfImFreq(indices=["A", "B"], beta=beta)
    delta_w << inverse(iOmega_n - np.array([[epsilon, -t], [-t, epsilon]])
                       ) + inverse(iOmega_n -
                                   np.array([[-epsilon, -t], [-t, -epsilon]]))
    S.G0_iw["tot"] << inverse(iOmega_n - np.array([[-mu, -t], [-t, -mu]]) -
                              delta_w)

    mpi.report("Running the simulation...")

    ## Solve the problem
    S.solve(h_int=H, **p)

    ## Save the results
    if mpi.is_master_node():
        with HDFArchive(results_file_name, 'w') as Results:
            Results["tot"] = S.G_tau["tot"]
Beispiel #13
0
    ]

    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    g_tau = GfImTime(name=r'$g$',
                     beta=beta,
                     statistic='Fermion',
                     n_points=50,
                     target_shape=(1, 1))

    g_iwn = GfImFreq(name='$g$',
                     beta=beta,
                     statistic='Fermion',
                     n_points=10,
                     target_shape=(1, 1))

    ed.set_g2_tau(g_tau, c(up, 0), c_dag(up, 0))
    ed.set_g2_iwn(g_iwn, c(up, 0), c_dag(up, 0))

    # ------------------------------------------------------------------
    # -- Two particle Green's functions

    ntau = 20
    imtime = MeshImTime(beta, 'Fermion', ntau)
    prodmesh = MeshProduct(imtime, imtime, imtime)

    g40_tau = Gf(name='g40_tau', mesh=prodmesh, target_shape=[1, 1, 1, 1])
    g4_tau = Gf(name='g4_tau', mesh=prodmesh, target_shape=[1, 1, 1, 1])
Beispiel #14
0
def make_calc(beta=2.0, h_field=0.0):

    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian

    p = ParameterCollection(
        beta=beta,
        V1=2.0,
        V2=5.0,
        epsilon1=0.10,
        epsilon2=3.00,
        h_field=h_field,
        mu=0.0,
        U=5.0,
        ntau=800,
        niw=15,
    )

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

    print '--> Solving SIAM with parameters'
    print p

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

    up, do = 'up', 'dn'
    docc = c_dag(up, 0) * c(up, 0) * c_dag(do, 0) * c(do, 0)
    mA = c_dag(up, 0) * c(up, 0) - c_dag(do, 0) * c(do, 0)

    nA = c_dag(up, 0) * c(up, 0) + c_dag(do, 0) * c(do, 0)
    nB = c_dag(up, 1) * c(up, 1) + c_dag(do, 1) * c(do, 1)
    nC = c_dag(up, 2) * c(up, 2) + c_dag(do, 2) * c(do, 2)

    p.H = -p.mu * nA + p.U * docc + p.h_field * mA + \
        p.epsilon1 * nB + p.epsilon2 * nC + \
        p.V1 * (c_dag(up,0)*c(up,1) + c_dag(up,1)*c(up,0) + \
              c_dag(do,0)*c(do,1) + c_dag(do,1)*c(do,0) ) + \
        p.V2 * (c_dag(up,0)*c(up,2) + c_dag(up,2)*c(up,0) + \
              c_dag(do,0)*c(do,2) + c_dag(do,2)*c(do,0) )

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

    fundamental_operators = [
        c(up, 0), c(do, 0),
        c(up, 1), c(do, 1),
        c(up, 2), c(do, 2)
    ]

    ed = TriqsExactDiagonalization(p.H, fundamental_operators, p.beta)

    g_tau = GfImTime(beta=beta, statistic='Fermion', n_points=400, indices=[0])
    g_iw = GfImFreq(beta=beta, statistic='Fermion', n_points=10, indices=[0])

    p.G_tau = BlockGf(name_list=[up, do],
                      block_list=[g_tau] * 2,
                      make_copies=True)
    p.G_iw = BlockGf(name_list=[up, do],
                     block_list=[g_iw] * 2,
                     make_copies=True)

    ed.set_g2_tau(p.G_tau[up][0, 0], c(up, 0), c_dag(up, 0))
    ed.set_g2_tau(p.G_tau[do][0, 0], c(do, 0), c_dag(do, 0))

    ed.set_g2_iwn(p.G_iw[up][0, 0], c(up, 0), c_dag(up, 0))
    ed.set_g2_iwn(p.G_iw[do][0, 0], c(do, 0), c_dag(do, 0))

    p.magnetization = ed.get_expectation_value(0.5 * mA)

    p.O_tau = Gf(mesh=MeshImTime(beta, 'Fermion', 400), target_shape=[])
    ed.set_g2_tau(p.O_tau, n(up, 0), n(do, 0))
    p.O_tau.data[:] *= -1.

    p.exp_val = ed.get_expectation_value(n(up, 0) * n(do, 0))

    # ------------------------------------------------------------------
    # -- Store to hdf5

    filename = 'data_pyed_h_field_%4.4f.h5' % h_field
    with HDFArchive(filename, 'w') as res:
        res['p'] = p
Beispiel #15
0
def make_calc(U=10):

    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian

    params = dict(
        beta=2.0,
        V1=2.0,
        V2=5.0,
        epsilon1=0.00,
        epsilon2=4.00,
        mu=2.0,
        U=U,
        ntau=40,
        niw=15,
    )

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

    class Dummy():
        def __init__(self):
            pass

    d = Dummy()  # storage space
    d.params = params

    print '--> Solving SIAM with parameters'
    for key, value in params.items():
        print '%10s = %-10s' % (key, str(value))
        globals()[key] = value  # populate global namespace

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

    up, do = 0, 1
    docc = c_dag(up, 0) * c(up, 0) * c_dag(do, 0) * c(do, 0)
    nA = c_dag(up, 0) * c(up, 0) + c_dag(do, 0) * c(do, 0)
    nB = c_dag(up, 1) * c(up, 1) + c_dag(do, 1) * c(do, 1)
    nC = c_dag(up, 2) * c(up, 2) + c_dag(do, 2) * c(do, 2)

    d.H = -mu * nA + epsilon1 * nB + epsilon2 * nC + U * docc + \
        V1 * (c_dag(up,0)*c(up,1) + c_dag(up,1)*c(up,0) + \
              c_dag(do,0)*c(do,1) + c_dag(do,1)*c(do,0) ) + \
        V2 * (c_dag(up,0)*c(up,2) + c_dag(up,2)*c(up,0) + \
              c_dag(do,0)*c(do,2) + c_dag(do,2)*c(do,0) )

    # ------------------------------------------------------------------
    # -- Exact diagonalization

    fundamental_operators = [
        c(up, 0), c(do, 0),
        c(up, 1), c(do, 1),
        c(up, 2), c(do, 2)
    ]

    ed = TriqsExactDiagonalization(d.H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    Gopt = dict(beta=beta, statistic='Fermion', indices=[1])
    d.G_tau = GfImTime(name=r'$G(\tau)$', n_points=ntau, **Gopt)
    d.G_iw = GfImFreq(name='$G(i\omega_n)$', n_points=niw, **Gopt)

    ed.set_g2_tau(d.G_tau, c(up, 0), c_dag(up, 0))
    ed.set_g2_iwn(d.G_iw, c(up, 0), c_dag(up, 0))

    # chi2pp = + < c^+_u(\tau^+) c_u(0^+) c^+_d(\tau) c_d(0) >
    #        = - < c^+_u(\tau^+) c^+_d(\tau) c_u(0^+) c_d(0) >

    chi2opt = dict(beta=beta, statistic='Fermion', indices=[1], n_points=ntau)
    d.chi2pp_tau = GfImTime(name=r'$\chi^{(2)}_{PP}(\tau)$', **chi2opt)
    ed.set_g2_tau(d.chi2pp_tau,
                  c_dag(up, 0) * c_dag(do, 0),
                  c(up, 0) * c(do, 0))
    d.chi2pp_tau *= -1.0 * -1.0  # commutation sign and gf sign
    d.chi2pp_iw = g_iw_from_tau(d.chi2pp_tau, niw)

    # chi2ph = < c^+_u(\tau^+) c_u(\tau) c^+_d(0^+) c_d(0) >

    d.chi2ph_tau = GfImTime(name=r'$\chi^{(2)}_{PH}(\tau)$', **chi2opt)
    #d.chi2ph_tau = Gf(name=r'$\chi^{(2)}_{PH}(\tau)$', **chi2opt)
    ed.set_g2_tau(d.chi2ph_tau,
                  c_dag(up, 0) * c(up, 0),
                  c_dag(do, 0) * c(do, 0))
    d.chi2ph_tau *= -1.0  # gf sign
    d.chi2ph_iw = g_iw_from_tau(d.chi2ph_tau, niw)

    # ------------------------------------------------------------------
    # -- Two particle Green's functions

    imtime = MeshImTime(beta, 'Fermion', ntau)
    prodmesh = MeshProduct(imtime, imtime, imtime)
    G2opt = dict(mesh=prodmesh, target_shape=[1, 1, 1, 1])

    d.G02_tau = Gf(name='$G^{(2)}_0(\tau_1, \tau_2, \tau_3)$', **G2opt)
    ed.set_g40_tau(d.G02_tau, d.G_tau)
    d.G02_iw = chi4_iw_from_tau(d.G02_tau, niw)

    d.G2_tau = Gf(name='$G^{(2)}(\tau_1, \tau_2, \tau_3)$', **G2opt)
    ed.set_g4_tau(d.G2_tau, c_dag(up, 0), c(up, 0), c_dag(do, 0), c(do, 0))
    #ed.set_g4_tau(d.G2_tau, c(up,0), c_dag(up,0), c(do,0), c_dag(do,0)) # <cc^+cc^+>
    d.G2_iw = chi4_iw_from_tau(d.G2_tau, niw)

    # -- trying to fix the bug in the fft for w2

    d.G02_iw.data[:] = d.G02_iw.data[:, ::-1, ...].conj()
    d.G2_iw.data[:] = d.G2_iw.data[:, ::-1, ...].conj()

    # ------------------------------------------------------------------
    # -- 3/2-particle Green's functions (equal times)

    prodmesh = MeshProduct(imtime, imtime)
    chi3opt = dict(mesh=prodmesh, target_shape=[1, 1, 1, 1])

    # chi3pp = <c^+_u(\tau) c_u(0^+) c^+_d(\tau') c_d(0) >
    #        = - <c^+_u(\tau) c^+_d(\tau') c_u(0^+) c_d(0) >

    d.chi3pp_tau = Gf(name='$\Chi^{(3)}_{PP}(\tau_1, \tau_2, \tau_3)$',
                      **chi3opt)
    ed.set_g3_tau(d.chi3pp_tau, c_dag(up, 0), c_dag(do, 0),
                  c(up, 0) * c(do, 0))
    d.chi3pp_tau *= -1.0  # from commutation
    d.chi3pp_iw = chi3_iw_from_tau(d.chi3pp_tau, niw)

    # chi3ph = <c^+_u(\tau) c_u(\tau') c^+_d(0^+) c_d(0) >

    d.chi3ph_tau = Gf(name='$\Chi^{(3)}_{PH}(\tau_1, \tau_2, \tau_3)$',
                      **chi3opt)
    ed.set_g3_tau(d.chi3ph_tau, c_dag(up, 0), c(up, 0),
                  c_dag(do, 0) * c(do, 0))
    d.chi3ph_iw = chi3_iw_from_tau(d.chi3ph_tau, niw)

    # ------------------------------------------------------------------
    # -- Store to hdf5

    filename = 'data_ed.h5'
    with HDFArchive(filename, 'w') as res:
        for key, value in d.__dict__.items():
            res[key] = value
Beispiel #16
0
def five_plus_five(use_interaction=True):

    results_file_name = "5_plus_5.h5"

    # Block structure of GF
    L = 2  # d-orbital
    spin_names = ("up", "dn")
    orb_names = cubic_names(L)

    # Input parameters
    beta = 40.
    mu = 26

    U = 4.0
    J = 0.7
    F0 = U
    F2 = J * (14.0 / (1.0 + 0.63))
    F4 = F2 * 0.63

    # Dump the local Hamiltonian to a text file (set to None to disable dumping)
    H_dump = "H.txt"
    # Dump Delta parameters to a text file (set to None to disable dumping)
    Delta_dump = "Delta_params.txt"

    # Hybridization function parameters
    # Delta(\tau) is diagonal in the basis of cubic harmonics
    # Each component of Delta(\tau) is represented as a list of single-particle
    # terms parametrized by pairs (V_k,\epsilon_k).
    delta_params = {
        "xy": {
            'V': 0.2,
            'e': -0.2
        },
        "yz": {
            'V': 0.2,
            'e': -0.15
        },
        "z^2": {
            'V': 0.2,
            'e': -0.1
        },
        "xz": {
            'V': 0.2,
            'e': 0.05
        },
        "x^2-y^2": {
            'V': 0.2,
            'e': 0.4
        }
    }

    atomic_levels = {
        ('up_xy', 0): -0.2,
        ('dn_xy', 0): -0.2,
        ('up_yz', 0): -0.15,
        ('dn_yz', 0): -0.15,
        ('up_z^2', 0): -0.1,
        ('dn_z^2', 0): -0.1,
        ('up_xz', 0): 0.05,
        ('dn_xz', 0): 0.05,
        ('up_x^2-y^2', 0): 0.4,
        ('dn_x^2-y^2', 0): 0.4
    }

    n_iw = 1025
    n_tau = 10001

    p = {}
    p["max_time"] = -1
    p["random_name"] = ""
    p["random_seed"] = 123 * mpi.rank + 567
    p["length_cycle"] = 50
    p["n_warmup_cycles"] = 1000
    p["n_cycles"] = 30000
    p["partition_method"] = "autopartition"
    p["measure_G_tau"] = True
    p["move_shift"] = True
    p["measure_pert_order"] = False
    p["performance_analysis"] = False
    p["use_trace_estimator"] = False

    mpi.report("Welcome to 5+5 (5 orbitals + 5 bath sites) test.")

    gf_struct = set_operator_structure(spin_names, orb_names, False)
    mkind = get_mkind(False, None)

    # Local Hamiltonian
    U_mat = U_matrix(L, [F0, F2, F4], basis='cubic')
    H = h_int_slater(spin_names, orb_names, U_mat, False, H_dump=H_dump)

    p["h_int"] = H

    # Quantum numbers (N_up and N_down)
    QN = [Operator(), Operator()]
    for cn in orb_names:
        for i, sn in enumerate(spin_names):
            QN[i] += n(*mkind(sn, cn))
    if p["partition_method"] == "quantum_numbers": p["quantum_numbers"] = QN

    mpi.report("Constructing the solver...")

    # Construct the solver
    S = SolverCore(beta=beta, gf_struct=gf_struct, n_tau=n_tau, n_iw=n_iw)

    mpi.report("Preparing the hybridization function...")

    # Set hybridization function
    if Delta_dump: Delta_dump_file = open(Delta_dump, 'w')
    for sn, cn in product(spin_names, orb_names):
        bn, i = mkind(sn, cn)
        V = delta_params[cn]['V']
        e = delta_params[cn]['e']

        delta_w = GfImFreq(indices=[i], beta=beta)
        delta_w << (V**2) * inverse(iOmega_n - e)

        S.G0_iw[bn][i, i] << inverse(iOmega_n + mu - atomic_levels[(bn, i)] -
                                     delta_w)

        # Dump Delta parameters
        if Delta_dump:
            Delta_dump_file.write(bn + '\t')
            Delta_dump_file.write(str(V) + '\t')
            Delta_dump_file.write(str(e) + '\n')

    mpi.report("Running the simulation...")

    # Solve the problem
    S.solve(**p)

    # Save the results
    if mpi.is_master_node():
        Results = HDFArchive(results_file_name, 'w')
        Results['G_tau'] = S.G_tau
        Results['use_interaction'] = use_interaction
        Results['delta_params'] = delta_params
        Results['spin_names'] = spin_names
        Results['orb_names'] = orb_names

        import __main__
        Results.create_group("log")
        log = Results["log"]
        log["version"] = version.version
        log["triqs_hash"] = version.triqs_hash
        log["cthyb_hash"] = version.cthyb_hash
        log["script"] = inspect.getsource(__main__)
Beispiel #17
0
def anderson(use_qn=True, use_blocks=True):

    spin_names = ("up","dn")
    mkind = lambda spin: (spin,0) if use_blocks else ("tot",spin)

    # Input parameters
    beta = 10.0
    U = 2.0
    mu = 1.0
    h = 0.1
    V = 0.5
    epsilon = 2.3

    n_iw = 1025
    n_tau = 10001

    p = {}
    p["max_time"] = -1
    p["random_name"] = ""
    p["random_seed"] = 123 * mpi.rank + 567
    p["length_cycle"] = 50
    p["n_warmup_cycles"] = 50000
    p["n_cycles"] = 5000000
    p["measure_density_matrix"] = True
    p["use_norm_as_weight"] = True

    results_file_name = "anderson"
    if use_blocks: results_file_name += ".block"
    if use_qn: results_file_name += ".qn"
    results_file_name += ".h5"

    mpi.report("Welcome to Anderson (1 correlated site + symmetric bath) test.")

    H = U*n(*mkind("up"))*n(*mkind("dn"))

    QN = []
    if use_qn:
        for spin in spin_names: QN.append(n(*mkind(spin)))
        p["quantum_numbers"] = QN
        p["partition_method"] = "quantum_numbers"

    gf_struct = {}
    for spin in spin_names:
        bn, i = mkind(spin)
        gf_struct.setdefault(bn,[]).append(i)

    gf_struct = [ [key, value] for key, value in gf_struct.items() ] # convert from dict to list of lists
            
    mpi.report("Constructing the solver...")

    # Construct the solver
    S = SolverCore(beta=beta, gf_struct=gf_struct, n_tau=n_tau, n_iw=n_iw)

    mpi.report("Preparing the hybridization function...")

    # Set hybridization function
    delta_w = GfImFreq(indices = [0], beta=beta)
    delta_w << (V**2) * inverse(iOmega_n - epsilon) + (V**2) * inverse(iOmega_n + epsilon)
    for spin in spin_names:
        bn, i = mkind(spin)
        S.G0_iw[bn][i,i] << inverse(iOmega_n + mu - {'up':h,'dn':-h}[spin] - delta_w)

    mpi.report("Running the simulation...")

    # Solve the problem
    S.solve(h_int=H, **p)

    # Save the results
    if mpi.is_master_node():
        static_observables = {'Nup' : n(*mkind("up")), 'Ndn' : n(*mkind("dn")), 'unity' : Operator(1.0)}
        dm = S.density_matrix
        for oname in static_observables.keys():
            print oname, trace_rho_op(dm,static_observables[oname],S.h_loc_diagonalization)

        with HDFArchive(results_file_name,'w') as Results:
            Results['G_tau'] = S.G_tau
Beispiel #18
0
from pytriqs.plot.mpl_interface import oplot, oplotr, oploti, plt     

from triqs_tprf.chi_from_gg2 import chi0_from_gg2_PH
from triqs_tprf.chi_from_gg2 import chi_from_gg2_PH

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

    with HDFArchive('data_cthyb.h5', 'r') as A: 
        p = A['p']

    p.g_tau = g2_single_particle_transform(p.g_tau['0'], p.T)

    p.g_iw = GfImFreq(
        name=r'$g$', beta=p.beta,
        statistic='Fermion', n_points=400,
        target_shape=(4, 4))
    
    p.g_iw << Fourier(p.g_tau)

    p.g4_ph = g4_single_particle_transform(p.g4_ph, p.T)

    p.chi0_nn = chi0_from_gg2_PH(p.g_iw, p.g4_ph)
    p.chi_nn = chi_from_gg2_PH(p.g_iw, p.g4_ph)
    
    p.chi = np.sum(p.chi_nn.data, axis=(0, 1, 2)) / p.beta**2

    with HDFArchive('data_cthyb_chi.h5', 'w') as A: 
        A['p'] = p
Beispiel #19
0
    ]

    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    g_tau = GfImTime(name=r'$g$',
                     beta=beta,
                     statistic='Fermion',
                     n_points=50,
                     indices=[1])

    g_iwn = GfImFreq(name='$g$',
                     beta=beta,
                     statistic='Fermion',
                     n_points=10,
                     indices=[1])

    ed.set_g2_tau(g_tau, c(up, 0), c_dag(up, 0))
    ed.set_g2_iwn(g_iwn, c(up, 0), c_dag(up, 0))

    # ------------------------------------------------------------------
    # -- Two particle Green's functions

    ntau = 20
    imtime = MeshImTime(beta, 'Fermion', ntau)
    prodmesh = MeshProduct(imtime, imtime, imtime)

    g40_tau = Gf(name='g40_tau', mesh=prodmesh, target_shape=[1, 1, 1, 1])
    g4_tau = Gf(name='g4_tau', mesh=prodmesh, target_shape=[1, 1, 1, 1])
Beispiel #20
0
# Import the Green's functions
from pytriqs.gf import GfImFreq, iOmega_n, inverse

# Create the Matsubara-frequency Green's function and initialize it
g = GfImFreq(indices = [1], beta = 50, n_points = 1000, name = "imp")
g << inverse( iOmega_n + 0.5 )

import pytriqs.utility.mpi as mpi

mpi.bcast(g)



#Block

from pytriqs.gf import *
g1 = GfImFreq(indices = ['eg1','eg2'], beta = 50, n_points = 1000, name = "egBlock")
g2 = GfImFreq(indices = ['t2g1','t2g2','t2g3'], beta = 50, n_points = 1000, name = "t2gBlock")
G = BlockGf(name_list = ('eg','t2g'), block_list = (g1,g2), make_copies = False)


mpi.bcast(G)


#imtime 
from pytriqs.gf import *

# A Green's function on the Matsubara axis set to a semicircular
gw = GfImFreq(indices = [1], beta = 50)
gw << SemiCircular(half_bandwidth = 1)