Exemple #1
0
def solve_lattice_bse(parm, momsus=False):

    print '--> solve_lattice_bse'

    print 'nw =', parm.nw
    print 'nwf =', parm.nwf

    # ------------------------------------------------------------------
    # -- Setup lattice

    bl = BravaisLattice([(1, 0, 0), (0, 1, 0)])

    bz = BrillouinZone(bl)
    bzmesh = MeshBrillouinZone(bz, n_k=1)  # only one k-point

    e_k = Gf(mesh=bzmesh, target_shape=[1, 1])
    e_k *= 0.

    # ------------------------------------------------------------------
    # -- Lattice single-particle Green's function

    mesh = MeshImFreq(beta=parm.beta, S='Fermion', n_max=parm.nwf_gf)

    parm.Sigma_iw = parm.G_iw.copy()
    G0_iw = parm.G_iw.copy()

    G0_iw << inverse(iOmega_n + 0.5 * parm.U)
    parm.Sigma_iw << inverse(G0_iw) - inverse(parm.G_iw)

    parm.mu = 0.5 * parm.U
    g_wk = lattice_dyson_g_wk(mu=parm.mu, e_k=e_k, sigma_w=parm.Sigma_iw)
    g_wr = fourier_wk_to_wr(g_wk)

    # ------------------------------------------------------------------
    # -- Non-interacting generalized lattice susceptibility

    chi0_wr = chi0r_from_gr_PH(nw=parm.nw, nnu=parm.nwf, gr=g_wr)
    chi0_wk = chi0q_from_chi0r(chi0_wr)

    # ------------------------------------------------------------------
    # -- Solve lattice BSE

    parm.chi_wk = chiq_from_chi0q_and_gamma_PH(chi0_wk, parm.gamma_m)

    # ------------------------------------------------------------------
    # -- Store results and static results

    num = np.squeeze(parm.chi_wk.data.real)
    ref = np.squeeze(parm.chi_m.data.real)

    diff = np.max(np.abs(num - ref))
    print 'diff =', diff

    parm.chi_w = chiq_sum_nu_q(parm.chi_wk)  # static suscept

    return parm
Exemple #2
0
def compute_new_weiss_field(G_lattice_iw_list_, Sigma_iw_list_):

    G0_iw_list = []

    for g, s in zip(G_lattice_iw_list_, Sigma_iw_list_):

        G0_iw = BlockGf(mesh=iw_mesh, gf_struct=gf_struct)

        G0_iw << inverse(inverse(g) + s)

        G0_iw_list.append(G0_iw)

    return G0_iw_list
def delta_inv(beta, nw, nk=100):

    mesh = MeshImFreq(beta, 'Fermion', n_max=nw)

    Sigma0, Sigma1 = 1.337, 3.5235
    ek = 2. * np.random.random(nk) - 1.

    G = Gf(mesh=mesh, target_shape=[1, 1])
    Sig = G.copy()
    for w in Sig.mesh:
        Sig[w][:] = Sigma0 + Sigma1 / w

    for e in ek:
        G << G + inverse(iOmega_n - e - Sig)

    G /= nk

    Delta = G.copy()
    Delta << inverse(G) - iOmega_n + Sig

    sum_ek = -np.sum(ek) / nk

    Roo = np.abs(Sigma0) + 1.

    w = [w for w in mesh]
    wmax = np.abs(w[-1].value)

    tail, err = Delta.fit_tail()

    order = len(tail)

    trunc_err_anal = (Roo / (0.8 * wmax))**order

    ratio = tail[0] / sum_ek
    diff = np.abs(1 - ratio)

    print '-' * 72
    print 'beta =', beta
    print 'nw =', nw
    print 'wmax =', wmax
    print 'tail_fit order =', len(tail)
    print 'tail_fit err =', err
    print tail[:3]
    #print sum_ek
    print 'trunc_err_anal =', trunc_err_anal
    print 'ratio =', ratio
    print 'diff =', diff

    return diff[0, 0]
Exemple #4
0
def calculate_sigmas(G_iw_list_, G0_iw_list_):

    Sigma_iw_list = []

    for G_iw, G0_iw in zip(G_iw_list_, G0_iw_list_):

        print ' '
        print 'G_iw', G_iw
        print 'G0_iw', G0_iw

        Sigma = G0_iw.copy()

        Sigma << inverse(G0_iw) - inverse(G_iw)

        Sigma_iw_list.append(Sigma)

    return Sigma_iw_list
Exemple #5
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()
Exemple #6
0
def dmft_self_consistent_step(p):

    p = copy.deepcopy(p)
    p.iter += 1

    p.g_w = lattice_dyson_g_w(p.mu, p.e_k, p.sigma_w - np.diag([p.B, -p.B]))
    p.g0_w = p.g_w.copy()
    p.g0_w << inverse(inverse(p.g_w) + p.sigma_w)

    cthyb = triqs_cthyb.Solver(**p.init.dict())

    # -- set impurity from lattice
    cthyb.G0_iw['up'][0, 0] << p.g0_w[0, 0]
    cthyb.G0_iw['do'][0, 0] << p.g0_w[1, 1]

    cthyb.solve(**p.solve.dict())

    p.dG_l = np.max(np.abs(BlockGf_data(cthyb.G_l-p.G_l))) if hasattr(p,'G_l') else float('nan')
    p.G_l = cthyb.G_l

    p.G_tau, p.G_tau_raw = cthyb.G_tau.copy(), cthyb.G_tau.copy()
    p.G0_w, p.G_w, p.Sigma_w = cthyb.G0_iw.copy(), cthyb.G0_iw.copy(), cthyb.G0_iw.copy()

    p.G_tau << LegendreToMatsubara(p.G_l)
    p.G_w << Fourier(p.G_tau)
    p.Sigma_w << inverse(p.G0_w) - inverse(p.G_w)

    # -- set lattice from impurity
    p.sigma_w[0, 0] << p.Sigma_w['up'][0, 0]
    p.sigma_w[1, 1] << p.Sigma_w['do'][0, 0]

    # -- local observables
    p.rho = p.g_w.density()
    M_old = p.M if hasattr(p, 'M') else float('nan')
    p.M = 0.5*(p.rho[0, 0] - p.rho[1, 1])
    p.dM = np.abs(p.M - M_old)
    
    return p
Exemple #7
0
def partition(h_int, h_k, gf_struct, QN=None):
    p = {}
    p["verbosity"] = 0
    p["max_time"] = -1
    p["length_cycle"] = 1
    p["n_warmup_cycles"] = 0
    p["n_cycles"] = 0

    if QN is None:
        p['partition_method'] = "autopartition"
    else:
        p['partition_method'] = "quantum_numbers"
        p['quantum_numbers'] = QN

    S = SolverCore(beta=1, gf_struct=gf_struct)
    S.G0_iw << inverse(iOmega_n - h_k)

    start = time.clock()
    S.solve(h_int=h_int, **p)
    end = time.clock()

    return S.eigensystems, end - start
Exemple #8
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)

    p.g0_tau_ref = g2_single_particle_transform(p.g0t_tau, p.T)
    np.testing.assert_array_almost_equal(p.g0_tau_ref.data, p.g0_tau.data)
Exemple #9
0
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)

np.testing.assert_array_almost_equal(g_iw_ref.data, g_iw.data)
Exemple #10
0
            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():
        with HDFArchive(results_file_name, 'w') as Results:
            Results['G_tau'] = S.G_tau
Exemple #11
0
    if not use_interaction:
        #g_theor = GfImTime(indices = range(len(orb_names)), beta=beta, n_points=n_tau)
        g_theor = GfImTime(indices=range(len(orb_names)),
                           beta=beta,
                           n_points=1000)
        for nc, cn in enumerate(orb_names):
            V = delta_params[cn]['V']
            e = delta_params[cn]['e']

            e1 = e - V
            e2 = e + V

            #g_theor_w = GfImFreq(indices = [0], beta=beta, n_points=1000)
            g_theor_w = Gf(mesh=MeshImFreq(beta, 'Fermion', 100),
                           target_shape=[])
            g_theor_w << 0.5 * inverse(iOmega_n -
                                       e1) + 0.5 * inverse(iOmega_n - e2)
            g_theor[nc, nc] << Fourier(g_theor_w)

    pp = PdfPages('G%s.pdf' % ('int' if use_interaction else ''))

    for sn in spin_names:
        for nc, cn in enumerate(orb_names):
            plt.clf()

            gf = rebinning_tau(arch['G_tau'][mkind(sn, cn)[0]], 200)

            # Plot the results
            oplot(gf, name="cthyb")
            # Plot the reference curve
            if use_interaction:
                oplot(g_ref[nc, nc], name="ED")
Exemple #12
0
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)

filename = 'h5_read_write.h5'
Exemple #13
0
    # Quantum numbers (N_up and N_down)
    QN = []
    for b, idxs in gf_struct: QN.append(n(b,0))
    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
    #for m, b in enumerate(sorted(gf_struct.keys())):
    for m, (b, idxs) in enumerate(gf_struct):
        delta_w = Gf(mesh=S.G0_iw.mesh, target_shape=[])
        delta_w << (V[m]**2) * inverse(iOmega_n - e[m])
        S.G0_iw[b][0,0] << inverse(iOmega_n - e[m] - delta_w)

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

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

    # Save results
    if mpi.is_master_node():
        with HDFArchive('nonint.h5','a') as Results:
            Results[str(modes)] = {'G_tau':S.G_tau,'V':V,'e':e}
Exemple #14
0
from pytriqs.gf import GfReFreq, Omega, Wilson, inverse
import numpy

eps_d,t  = 0.3, 0.2

# Create the real-frequency Green's function and initialize it
g = GfReFreq(indices = ['s','d'], window = (-2, 2), n_points = 1000, name = "$G_\mathrm{s+d}$")
g['d','d'] = Omega - eps_d
g['d','s'] = t
g['s','d'] = t
g['s','s'] = inverse( Wilson(1.0) )
g.invert()

# Plot it with matplotlib. 'S' means: spectral function ( -1/pi Imag (g) )
from pytriqs.plot.mpl_interface import oplot, plt
oplot( g['d','d'], '-o', RI = 'S', x_window  = (-1.8,1.8), name = "Impurity" )
oplot( g['s','s'], '-x', RI = 'S', x_window  = (-1.8,1.8), name = "Bath" )
plt.show()
E_loc = np.array([
    [0.2, 0.3],
    [0.3, 0.4],
    ])

V = np.array([
    [1.0, 0.25],
    [0.25, -1.0],
    ])

h_loc = c_dag('0', 0) * E_loc[0, 0] * c('0', 0) + \
        c_dag('0', 0) * E_loc[0, 1] * c('0', 1) + \
        c_dag('0', 1) * E_loc[1, 0] * c('0', 0) + \
        c_dag('0', 1) * E_loc[1, 1] * c('0', 1)

Delta_iw << inverse( iOmega_n - Ek ) + inverse( iOmega_n + Ek )
Delta_iw.from_L_G_R(V, Delta_iw, V)

Delta_tau = Gf(mesh=tmesh, target_shape=target_shape)
Delta_tail, Delta_tail_err = Delta_iw.fit_hermitian_tail()
Delta_tau << InverseFourier(Delta_iw, Delta_tail)

G0_iw = Gf(mesh=wmesh, target_shape=target_shape)
G0_iw << inverse( iOmega_n - Delta_iw - E_loc )

S.G0_iw << G0_iw

S.solve(
    h_int = h_int,
    length_cycle = 10,
    n_warmup_cycles = 1,
Exemple #16
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))
Exemple #17
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"]
Exemple #18
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))
Exemple #19
0
    n_iw = 100
    n_tau = 1000

    from pytriqs.gf import MeshImFreq, MeshImTime
    from pytriqs.gf import BlockGf, inverse, iOmega_n, Fourier

    iw_mesh = MeshImFreq(beta, 'Fermion', n_iw)
    G0_iw = BlockGf(mesh=iw_mesh, gf_struct=gf_struct)

    debug_H = []
    for block, g0_iw in G0_iw:
        s = (3, 3)
        H = np.random.random(s) + 1.j * np.random.random(s)
        H = H + np.conjugate(H.T)

        g0_iw << inverse(iOmega_n - H - inverse(iOmega_n - 0.3 * H))

        debug_H.append(H)

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

    Delta_iw = BlockGf(mesh=iw_mesh, gf_struct=gf_struct)
    H_loc_block = []

    for block, g0_iw in G0_iw:

        tail, err = g0_iw.fit_hermitian_tail()
        H_loc = tail[2]
        Delta_iw[block] << inverse(g0_iw) + H_loc - iOmega_n

        H_loc_block.append(H_loc)
Author: Hugo U.R. Strand (2019) """

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

import pytriqs.utility.mpi as mpi
from pytriqs.gf import inverse, iOmega_n, SemiCircular, BlockGf
from pytriqs.operators import n
from pytriqs.archive import HDFArchive

from triqs_cthyb import Solver

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

    solv = Solver(beta=10., gf_struct=[['0', [0]]])
    solv.G0_iw['0'][0, 0] << inverse(iOmega_n - 0.5 - SemiCircular(2.))

    solv.solve(
        h_int=1.0 * n('0', 0),
        n_warmup_cycles=int(1e0),
        n_cycles=int(1e1 / mpi.size),
    )

    if mpi.is_master_node():

        filename = 'data.h5'

        with HDFArchive(filename, 'w') as res:
            res['solv'] = solv

        with HDFArchive(filename, 'r') as res:
Exemple #21
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)
Exemple #22
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
        gr['e'] = e
Exemple #23
0
def make_calc():

    # ------------------------------------------------------------------
    # -- Read precomputed ED data

    filename = "bse_and_rpa_loc_vs_latt.tar.gz"
    p = read_TarGZ_HDFArchive(filename)['p']

    # ------------------------------------------------------------------
    # -- RPA tensor

    from triqs_tprf.rpa_tensor import get_rpa_tensor
    from triqs_tprf.rpa_tensor import fundamental_operators_from_gf_struct

    fundamental_operators = fundamental_operators_from_gf_struct(p.gf_struct)
    p.U_abcd = get_rpa_tensor(p.H_int, fundamental_operators)

    # ------------------------------------------------------------------
    # -- Generalized PH susceptibility

    loc_bse = ParameterCollection()

    loc_bse.chi_wnn = chi_from_gg2_PH(p.G_iw, p.G2_iw_ph)
    loc_bse.chi0_wnn = chi0_from_gg2_PH(p.G_iw, p.G2_iw_ph)

    loc_bse.gamma_wnn = inverse_PH(loc_bse.chi0_wnn) - inverse_PH(
        loc_bse.chi_wnn)
    loc_bse.chi_wnn_ref = inverse_PH(
        inverse_PH(loc_bse.chi0_wnn) - loc_bse.gamma_wnn)

    np.testing.assert_array_almost_equal(loc_bse.chi_wnn.data,
                                         loc_bse.chi_wnn_ref.data)

    from triqs_tprf.bse import solve_local_bse
    loc_bse.gamma_wnn_ref = solve_local_bse(loc_bse.chi0_wnn, loc_bse.chi_wnn)

    np.testing.assert_array_almost_equal(loc_bse.gamma_wnn.data,
                                         loc_bse.gamma_wnn_ref.data)

    loc_bse.chi0_w = trace_nn(loc_bse.chi0_wnn)
    loc_bse.chi_w = trace_nn(loc_bse.chi_wnn)

    # ------------------------------------------------------------------
    # -- RPA, using BSE inverses and constant Gamma

    loc_rpa = ParameterCollection()

    loc_rpa.chi0_wnn = loc_bse.chi0_wnn
    loc_rpa.chi0_w = loc_bse.chi0_w

    loc_rpa.U_abcd = p.U_abcd

    # -- Build constant gamma
    from triqs_tprf.rpa_tensor import get_gamma_rpa
    loc_rpa.gamma_wnn = get_gamma_rpa(loc_rpa.chi0_wnn, loc_rpa.U_abcd)

    # -- Solve RPA
    loc_rpa.chi_wnn = inverse_PH(
        inverse_PH(loc_rpa.chi0_wnn) - loc_rpa.gamma_wnn)
    loc_rpa.chi_w = trace_nn(loc_rpa.chi_wnn)

    # ------------------------------------------------------------------
    # -- Bubble RPA on lattice

    lat_rpa = ParameterCollection()

    # -- Setup dummy lattice Green's function equal to local Green's function

    bz = BrillouinZone(
        BravaisLattice(units=np.eye(3), orbital_positions=[(0, 0, 0)]))
    periodization_matrix = np.diag(np.array(list([1] * 3), dtype=np.int32))
    kmesh = MeshBrillouinZone(bz, periodization_matrix)
    wmesh = MeshImFreq(beta=p.beta, S='Fermion', n_max=p.nwf_gf)

    lat_rpa.g_wk = Gf(mesh=MeshProduct(wmesh, kmesh),
                      target_shape=p.G_iw.target_shape)
    lat_rpa.g_wk[:, Idx(0, 0, 0)] = p.G_iw

    # -- chi0_wk bubble and chi_wk_rpa bubble RPA

    from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk
    lat_rpa.chi0_wk = imtime_bubble_chi0_wk(lat_rpa.g_wk, nw=1)

    from triqs_tprf.lattice import solve_rpa_PH
    lat_rpa.chi_wk = solve_rpa_PH(lat_rpa.chi0_wk, p.U_abcd)

    lat_rpa.chi0_w = lat_rpa.chi0_wk[:, Idx(0, 0, 0)]
    lat_rpa.chi_w = lat_rpa.chi_wk[:, Idx(0, 0, 0)]

    print '--> cf Tr[chi0] and chi0_wk'
    print loc_rpa.chi0_w.data.reshape((4, 4)).real
    print lat_rpa.chi0_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi0_w.data,
                                         lat_rpa.chi0_w.data,
                                         decimal=2)

    print 'ok!'

    print '--> cf Tr[chi_rpa] and chi_wk_rpa'
    print loc_rpa.chi_w.data.reshape((4, 4)).real
    print lat_rpa.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi_w.data,
                                         lat_rpa.chi_w.data,
                                         decimal=2)

    print 'ok!'

    # ------------------------------------------------------------------
    # -- Lattice BSE

    lat_bse = ParameterCollection()

    lat_bse.g_wk = lat_rpa.g_wk

    lat_bse.mu = p.mu

    lat_bse.e_k = Gf(mesh=kmesh, target_shape=p.G_iw.target_shape)
    lat_bse.e_k[Idx(0, 0, 0)] = np.eye(2)

    lat_bse.sigma_w = p.G_iw.copy()
    lat_bse.sigma_w << iOmega_n + lat_bse.mu * np.eye(2) - lat_bse.e_k[Idx(
        0, 0, 0)] - inverse(p.G_iw)

    lat_bse.g_wk_ref = lat_bse.g_wk.copy()
    lat_bse.g_wk_ref[:, Idx(0, 0, 0)] << inverse(iOmega_n +
                                                 lat_bse.mu * np.eye(2) -
                                                 lat_bse.e_k[Idx(0, 0, 0)] -
                                                 lat_bse.sigma_w)

    np.testing.assert_array_almost_equal(lat_bse.g_wk.data,
                                         lat_bse.g_wk_ref.data)

    #for w in lat_bse.g_wk.mesh.components[0]:
    #    print w, lat_bse.g_wk[w, Idx(0,0,0)][0, 0]

    from triqs_tprf.lattice import fourier_wk_to_wr
    lat_bse.g_wr = fourier_wk_to_wr(lat_bse.g_wk)

    from triqs_tprf.lattice import chi0r_from_gr_PH
    lat_bse.chi0_wnr = chi0r_from_gr_PH(nw=1, nn=p.nwf, g_nr=lat_bse.g_wr)

    from triqs_tprf.lattice import chi0q_from_chi0r
    lat_bse.chi0_wnk = chi0q_from_chi0r(lat_bse.chi0_wnr)

    #for n in lat_bse.chi0_wnk.mesh.components[1]:
    #    print n.value, lat_bse.chi0_wnk[Idx(0), n, Idx(0,0,0)][0,0,0,0]

    # -- Lattice BSE calc
    from triqs_tprf.lattice import chiq_from_chi0q_and_gamma_PH
    lat_bse.chi_kwnn = chiq_from_chi0q_and_gamma_PH(lat_bse.chi0_wnk,
                                                    loc_bse.gamma_wnn)

    # -- Lattice BSE calc with built in trace
    from triqs_tprf.lattice import chiq_sum_nu_from_chi0q_and_gamma_PH
    lat_bse.chi_kw_ref = chiq_sum_nu_from_chi0q_and_gamma_PH(
        lat_bse.chi0_wnk, loc_bse.gamma_wnn)

    # -- Lattice BSE calc with built in trace using g_wk
    from triqs_tprf.lattice import chiq_sum_nu_from_g_wk_and_gamma_PH
    lat_bse.chi_kw_tail_corr_ref = chiq_sum_nu_from_g_wk_and_gamma_PH(
        lat_bse.g_wk, loc_bse.gamma_wnn)

    # -- Trace results
    from triqs_tprf.lattice import chi0q_sum_nu_tail_corr_PH
    from triqs_tprf.lattice import chi0q_sum_nu
    lat_bse.chi0_wk_tail_corr = chi0q_sum_nu_tail_corr_PH(lat_bse.chi0_wnk)
    lat_bse.chi0_wk = chi0q_sum_nu(lat_bse.chi0_wnk)

    from triqs_tprf.lattice import chiq_sum_nu, chiq_sum_nu_q
    lat_bse.chi_kw = chiq_sum_nu(lat_bse.chi_kwnn)

    np.testing.assert_array_almost_equal(lat_bse.chi_kw.data,
                                         lat_bse.chi_kw_ref.data)

    from triqs_tprf.bse import solve_lattice_bse
    lat_bse.chi_kw_tail_corr, tmp = solve_lattice_bse(lat_bse.g_wk,
                                                      loc_bse.gamma_wnn)

    from triqs_tprf.bse import solve_lattice_bse_e_k_sigma_w
    lat_bse.chi_kw_tail_corr_new = solve_lattice_bse_e_k_sigma_w(
        lat_bse.mu, lat_bse.e_k, lat_bse.sigma_w, loc_bse.gamma_wnn)

    np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr.data,
                                         lat_bse.chi_kw_tail_corr_ref.data)
    np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr.data,
                                         lat_bse.chi_kw_tail_corr_new.data)
    np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr_ref.data,
                                         lat_bse.chi_kw_tail_corr_new.data)

    lat_bse.chi0_w_tail_corr = lat_bse.chi0_wk_tail_corr[:, Idx(0, 0, 0)]
    lat_bse.chi0_w = lat_bse.chi0_wk[:, Idx(0, 0, 0)]
    lat_bse.chi_w_tail_corr = lat_bse.chi_kw_tail_corr[Idx(0, 0, 0), :]
    lat_bse.chi_w = lat_bse.chi_kw[Idx(0, 0, 0), :]

    print '--> cf Tr[chi0_wnk] and chi0_wk'
    print lat_bse.chi0_w_tail_corr.data.reshape((4, 4)).real
    print lat_bse.chi0_w.data.reshape((4, 4)).real
    print lat_rpa.chi0_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi0_w_tail_corr.data,
                                         lat_rpa.chi0_w.data)

    np.testing.assert_array_almost_equal(lat_bse.chi0_w.data,
                                         lat_rpa.chi0_w.data,
                                         decimal=2)

    print 'ok!'

    print '--> cf Tr[chi_kwnn] and chi_wk (without chi0 tail corr)'
    print lat_bse.chi_w.data.reshape((4, 4)).real
    print loc_bse.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi_w.data,
                                         loc_bse.chi_w.data)

    print 'ok!'

    # ------------------------------------------------------------------
    # -- Use chi0 tail corrected trace to correct chi_rpa cf bubble

    dchi_wk = lat_bse.chi0_wk_tail_corr - lat_bse.chi0_wk
    dchi_w = dchi_wk[:, Idx(0, 0, 0)]

    loc_rpa.chi_w_tail_corr = loc_rpa.chi_w + dchi_w

    # -- this will be the same, but it will be close to the real physical value
    lat_bse.chi_w_tail_corr_ref = lat_bse.chi_w + dchi_w
    loc_bse.chi_w_tail_corr_ref = loc_bse.chi_w + dchi_w

    print '--> cf Tr[chi_rpa] and chi_wk_rpa'
    print loc_rpa.chi_w.data.reshape((4, 4)).real
    print loc_rpa.chi_w_tail_corr.data.reshape((4, 4)).real
    print lat_rpa.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi_w_tail_corr.data,
                                         lat_rpa.chi_w.data,
                                         decimal=3)

    print '--> cf Tr[chi_kwnn] with tail corr (from chi0_wnk)'
    print lat_bse.chi_w_tail_corr.data.reshape((4, 4)).real
    print lat_bse.chi_w_tail_corr_ref.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi_w_tail_corr.data,
                                         lat_bse.chi_w_tail_corr_ref.data)

    print 'ok!'

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

    filename = 'data_bse_rpa.h5'
    with HDFArchive(filename, 'w') as res:
        res['p'] = p
Exemple #24
0
Ek = np.array([
    [1.00,  0.5],
    [0.5, -1.20],
    ])

E_loc = np.array([
    [0.33,  0.5],
    [0.5, -0.1337],
    ])

V = np.array([
    [1.0, 0.25],
    [0.25, -1.0],
    ])

Delta_iw << inverse( iOmega_n - Ek ) + inverse( iOmega_n + Ek ) - E_loc
Delta_iw.from_L_G_R(V, Delta_iw, V)

Delta_iw_ref = Delta_iw.copy()

noise_ampl = 1e-3

def get_noise():
    return 2.*np.random.random() - 1.

for w in wmesh:
    re = Delta_iw[w].real + noise_ampl * get_noise() * np.abs(w.value)**2
    im = Delta_iw[w].imag + noise_ampl * get_noise() * np.abs(w.value)**2
    
    Delta_iw[w] = re + 1.j * im
Exemple #25
0
    # -- Total impurity hamiltonian and interaction part

    p.H_0 = -p.mu * (n('up', 0) + n('dn', 0)) - p.h * (n('up', 0) - n('dn', 0))
    p.H_int = p.U * n('up', 0) * n('dn', 0)
    p.H = p.H_0 + p.H_int
    p.solve.h_int = p.H_int

    # -- Non-Interacting Impurity Green function

    iw_mesh = MeshImFreq(p.beta, 'Fermion', p.n_iw)
    p.G0_iw = Gf_from_struct(mesh=iw_mesh, struct=p.gf_struct)

    h_field_dict = dict(up=p.h, dn=-p.h)
    for name, g0_iw in p.G0_iw:
        h_field = h_field_dict[name]
        g0_iw << inverse(iOmega_n + p.mu + h_field)

    # -- CTINT

    S = SolverCore(**p.solver_core.dict())
    S.G0_iw << p.G0_iw
    S.solve(**p.solve.dict())

    # -- Store to hdf5 archive

    p.grab_attribs(S, p.store_list)

    if mpi.is_master_node():
        with HDFArchive("data_ctint.h5", 'w') as results:
            results["p"] = p
Exemple #26
0
def five_plus_five(use_interaction=True):

    results_file_name = "5_plus_5." + ("int."
                                       if use_interaction else "") + "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"] = 5000
    p["n_warmup_cycles"] = 500
    p["n_cycles"] = int(1.e1 / mpi.size)
    #p["n_cycles"] = int(5.e5 / mpi.size)
    #p["n_cycles"] = int(5.e6 / mpi.size)
    p["partition_method"] = "autopartition"
    p["measure_G_tau"] = True
    p["move_shift"] = True
    p["move_double"] = 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)

    H = Operator()

    if use_interaction:
        # 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)
    else:
        mu = 0.

    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...")

    H_hyb = Operator()

    # 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 = Gf(mesh=MeshImFreq(beta, 'Fermion', n_iw), target_shape=[])
        delta_w << (V**2) * inverse(iOmega_n - e)

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

        cnb = cn + '_b'  # bath level
        a = sn + '_' + cn
        b = sn + '_' + cn + '_b'

        H_hyb += ( atomic_levels[(bn,i)] - mu ) * n(a, 0) + \
            n(b,0) * e + V * ( c(a,0) * c_dag(b,0) + c(b,0) * c_dag(a,0) )

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

    if mpi.is_master_node():
        filename_ham = 'data_Ham%s.h5' % ('_int' if use_interaction else '')
        with HDFArchive(filename_ham, 'w') as arch:
            arch['H'] = H_hyb + H
            arch['gf_struct'] = gf_struct
            arch['beta'] = beta

    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['G0_iw'] = S.G0_iw
        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__)
Exemple #27
0
from pytriqs.gf import GfReFreq, Omega, Wilson, inverse
import numpy

eps_d, t = 0.3, 0.2

# Create the real-frequency Green's function and initialize it
g = GfReFreq(indices=['s', 'd'],
             window=(-2, 2),
             n_points=1000,
             name="$G_\mathrm{s+d}$")
g['d', 'd'] = Omega - eps_d
g['d', 's'] = t
g['s', 'd'] = t
g['s', 's'] = inverse(Wilson(1.0))
g.invert()

# Plot it with matplotlib. 'S' means: spectral function ( -1/pi Imag (g) )
from pytriqs.plot.mpl_interface import oplot, plt
oplot(g['d', 'd'], '-o', RI='S', x_window=(-1.8, 1.8), name="Impurity")
oplot(g['s', 's'], '-x', RI='S', x_window=(-1.8, 1.8), name="Bath")
plt.show()
Exemple #28
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
Exemple #29
0
}
gm_swap_atoms = {
    'swap_atoms': {
        mkind("up", 1): mkind("up", 2),
        mkind("dn", 1): mkind("dn", 2),
        mkind("up", 2): mkind("up", 1),
        mkind("dn", 2): mkind("dn", 1)
    }
}

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

# Set hybridization function
delta_w = GfImFreq(indices=[1, 2], beta=beta)
delta_w << (V**2) * (inverse(iOmega_n - epsilon) + inverse(iOmega_n + epsilon))
for sn in spin_names:
    S.G0_iw[sn] << inverse(iOmega_n - np.matrix([[-mu, t], [t, -mu]]) -
                           delta_w)

if mpi.is_master_node():
    arch = HDFArchive(
        "move_global_beta%.0f_prob%.2f.h5" % (beta, move_global_prob), 'w')
    arch['beta'] = beta
    arch['move_global_prob'] = move_global_prob

static_observables = {
    "N1_up": n(*mkind("up", 1)),
    "N1_dn": n(*mkind("dn", 1)),
    "N2_up": n(*mkind("up", 2)),
    "N2_dn": n(*mkind("dn", 2))
Exemple #30
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
Exemple #31
0
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()]

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

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

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

# Set hybridization function
delta_w = Gf(mesh=S.G0_iw.mesh, target_shape=[])
delta_w << (V**2) * inverse(iOmega_n - epsilon1) + (V**2) * inverse(iOmega_n -
                                                                    epsilon2)
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():