Ejemplo n.º 1
0
def run_slater(L, is_cubic):
    for l in L:
        orb_names = range(2 * l + 1)
        num_orbitals = len(orb_names)
        gf_struct = set_operator_structure(spin_names, orb_names, True)
        mkind = get_mkind(True, None)

        F = [3.0 * (0.3**k) for k in range(l + 1)]

        U_mat = U_matrix(l, F, basis='cubic' if is_cubic else 'spherical')
        h_int = h_int_slater(spin_names, orb_names, U_mat, True)

        h_k = np.zeros((num_orbitals, num_orbitals))

        # Quantum numbers
        QN = [
            sum([n(*mkind("up", o)) for o in orb_names], Operator()),  # N_up
            sum([n(*mkind("dn", o)) for o in orb_names], Operator())
        ]  # N_down

        eig_qn, time_qn = partition(h_int, h_k, gf_struct, QN)
        eig_ap, time_ap = partition(h_int, h_k, gf_struct)

        model = "Slater, %i orbitals" % num_orbitals
        model += (" (cubic basis)" if is_cubic else " (spherical basis)")
        print_line(model, 2**(2 * num_orbitals), (len(eig_qn), time_qn),
                   (len(eig_ap), time_ap))
Ejemplo n.º 2
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__)
Ejemplo n.º 3
0
from pytriqs.utility.comparison_tests import *

beta = 100.0
# H_loc parameters
L = 2  # angular momentum
U = 5.0
J = 0.1
F0 = U
F2 = J * (14.0 / (1.0 + 0.63))
F4 = F2 * 0.63
half_bandwidth = 1.0
mu = 32.5  # 3 electrons in 5 bands

spin_names = ("up", "down")
cubic_names = map(str, range(2 * L + 1))
U_mat = U_matrix(L, radial_integrals=[F0, F2, F4], basis="cubic")

# Parameters
p = {}
p["max_time"] = -1
p["random_name"] = ""
p["random_seed"] = 123 * mpi.rank + 567
p["length_cycle"] = 50
p["n_warmup_cycles"] = 50
p["n_cycles"] = 5000
p["measure_g_l"] = True
p["move_double"] = False

# Block structure of GF
gf_struct = set_operator_structure(spin_names, cubic_names, False)
Ejemplo n.º 4
0
from pytriqs.operators.util.U_matrix import U_matrix
from pytriqs.operators.util.hamiltonians import h_int_slater
from pytriqs.operators.util.observables import *
from pytriqs.archive import HDFArchive
from pytriqs.applications.impurity_solvers.cthyb import *
from pytriqs.gf.local import *

beta = 100.0
# H_int parameters
L = 1  # angular momentum
F0 = 4.0
F2 = 0.5

spin_names = ("up", "dn")
cubic_names = map(str, range(2 * L + 1))
U_mat = U_matrix(L, radial_integrals=[F0, F2], basis="spherical")

# Parameters
p = {}
p["verbosity"] = 0
p["length_cycle"] = 50
p["n_warmup_cycles"] = 0
p["n_cycles"] = 0

# Block structure of GF
gf_struct = set_operator_structure(spin_names, cubic_names, False)

# Local Hamiltonian
H = h_int_slater(spin_names, cubic_names, U_mat, False)

# Observables
Ejemplo n.º 5
0
def __generate_umat(p):
    """
    Add U-matrix block (Tentative)
    :param p: dictionary
        Input parameters
    :return:
    """
    # Add U-matrix block (Tentative)
    # ####  The format of this block is not fixed  ####
    #
    ncor = p["model"]['ncor']
    kanamori = numpy.zeros((ncor, 3), numpy.float_)
    slater_f = numpy.zeros((ncor, 4), numpy.float_)
    slater_l = numpy.zeros(ncor, numpy.int_)
    #
    # Read interaction from input file
    #
    if p["model"]["interaction"] == 'kanamori':
        if p["model"]["kanamori"] == "None":
            print("Error ! Parameter \"kanamori\" is not specified.")
            sys.exit(-1)
        if p["model"]["slater_f"] != "None":
            print(
                "Error ! Parameter \"slater_f\" is specified but is not used.")
            sys.exit(-1)
        if p["model"]["slater_uj"] != "None":
            print(
                "Error ! Parameter \"slater_uj\" is specified but is not used."
            )
            sys.exit(-1)

        kanamori_list = re.findall(
            r'\(\s*-?\s*\d+\.?\d*,\s*-?\s*\d+\.?\d*,\s*-?\s*\d+\.?\d*\)',
            p["model"]["kanamori"])
        if len(kanamori_list) != ncor:
            print("\nError! The length of \"kanamori\" is wrong.")
            sys.exit(-1)

        try:
            for i, _list in enumerate(kanamori_list):
                _kanamori = filter(lambda w: len(w) > 0,
                                   re.split(r'[)(,]', _list))
                for j in range(3):
                    kanamori[i, j] = float(_kanamori[j])
        except RuntimeError:
            raise RuntimeError("Error ! Format of u_j is wrong.")
    elif p["model"]["interaction"] == 'slater_uj':
        if p["model"]["slater_uj"] == "None":
            print("Error ! Parameter \"slater_uj\" is not specified.")
            sys.exit(-1)
        if p["model"]["slater_f"] != "None":
            print(
                "Error ! Parameter \"slater_f\" is specified but is not used.")
            sys.exit(-1)
        if p["model"]["kanamori"] != "None":
            print(
                "Error ! Parameter \"kanamori\" is specified but is not used.")
            sys.exit(-1)

        f_list = re.findall(
            r'\(\s*\d+\s*,\s*-?\s*\d+\.?\d*,\s*-?\s*\d+\.?\d*\)',
            p["model"]["slater_uj"])
        if len(f_list) != ncor:
            print("\nError! The length of \"slater_uj\" is wrong.")
            sys.exit(-1)

        try:
            for i, _list in enumerate(f_list):
                _slater = filter(lambda w: len(w) > 0,
                                 re.split(r'[)(,]', _list))
                slater_l[i] = int(_slater[0])
                slater_u = float(_slater[1])
                slater_j = float(_slater[2])
                if slater_l[i] == 0:
                    slater_f[i, 0] = slater_u
                else:
                    slater_f[i, 0:slater_l[i] + 1] = U_J_to_radial_integrals(
                        slater_l[i], slater_u, slater_j)
        except RuntimeError:
            raise RuntimeError("Error ! Format of u_j is wrong.")
    elif p["model"]["interaction"] == 'slater_f':
        if p["model"]["slater_f"] == "None":
            print("Error ! Parameter \"slater_f\" is not specified.")
            sys.exit(-1)
        if p["model"]["kanamori"] != "None":
            print(
                "Error ! Parameter \"kanamori\" is specified but is not used.")
            sys.exit(-1)
        if p["model"]["slater_uj"] != "None":
            print(
                "Error ! Parameter \"slater_uj\" is specified but is not used."
            )
            sys.exit(-1)

        f_list = re.findall(
            r'\(\s*\d+\s*,\s*-?\s*\d+\.?\d*,\s*-?\s*\d+\.?\d*,\s*-?\s*\d+\.?\d*,\s*-?\s*\d+\.?\d*\)',
            p["model"]["slater_f"])
        slater_f = numpy.zeros((ncor, 4), numpy.float_)
        slater_l = numpy.zeros(ncor, numpy.int_)
        if len(f_list) != ncor:
            print("\nError! The length of \"slater_f\" is wrong.")
            sys.exit(-1)

        try:
            for i, _list in enumerate(f_list):
                _slater = filter(lambda w: len(w) > 0,
                                 re.split(r'[)(,]', _list))
                slater_l[i] = int(_slater[0])
                for j in range(4):
                    slater_f[i, j] = float(_slater[j])
        except RuntimeError:
            raise RuntimeError("Error ! Format of u_j is wrong.")
    elif p["model"]["interaction"] == 'respack':
        if p["model"]["kanamori"] != "None":
            print(
                "Error ! Parameter \"kanamori\" is specified but is not used.")
            sys.exit(-1)
        if p["model"]["slater_uj"] != "None":
            print(
                "Error ! Parameter \"slater_uj\" is specified but is not used."
            )
            sys.exit(-1)
        if p["model"]["slater_f"] != "None":
            print(
                "Error ! Parameter \"slater_f\" is specified but is not used.")
            sys.exit(-1)
    else:
        print("Error ! Invalid interaction : ", p["model"]["interaction"])
        sys.exit(-1)
    #
    # Generate and Write U-matrix
    #
    print("\n  @ Write the information of interactions")
    f = HDFArchive(p["model"]["seedname"] + '.h5', 'a')

    corr_shells = f["dft_input"]["corr_shells"]
    norb = [corr_shells[icor]["dim"] for icor in range(ncor)]
    if p["model"]["spin_orbit"] or p["model"]["non_colinear"]:
        for icor in range(ncor):
            norb[icor] /= 2

    if not ("DCore" in f):
        f.create_group("DCore")
    #
    u_mat = [
        numpy.zeros((norb[icor], norb[icor], norb[icor], norb[icor]),
                    numpy.complex_) for icor in range(ncor)
    ]
    if p["model"]["interaction"] == 'kanamori':
        for icor in range(ncor):
            for iorb in range(norb[icor]):
                for jorb in range(norb[icor]):
                    u_mat[icor][iorb, jorb, iorb, jorb] = kanamori[icor, 1]
                    u_mat[icor][iorb, jorb, jorb, iorb] = kanamori[icor, 2]
                    u_mat[icor][iorb, iorb, jorb, jorb] = kanamori[icor, 2]
            for iorb in range(norb[icor]):
                u_mat[icor][iorb, iorb, iorb, iorb] = kanamori[icor, 0]
    elif p["model"]["interaction"] == 'slater_uj' or p["model"][
            "interaction"] == 'slater_f':
        for icor in range(ncor):
            if slater_l[icor] == 0:
                umat_full = numpy.zeros((1, 1, 1, 1), numpy.complex_)
                umat_full[0, 0, 0, 0] = slater_f[icor, 0]
            else:
                umat_full = U_matrix(l=slater_l[icor],
                                     radial_integrals=slater_f[icor, :],
                                     basis='cubic')
            #
            # For t2g or eg, compute submatrix
            #
            if slater_l[icor] * 2 + 1 != norb[icor]:
                if slater_l[icor] == 2 and norb[icor] == 2:
                    u_mat[icor] = eg_submatrix(umat_full)
                elif slater_l[icor] == 2 and norb[icor] == 3:
                    u_mat[icor] = t2g_submatrix(umat_full)
                else:
                    print("Error ! Unsupported pair of l and norb : ",
                          slater_l[icor], norb[icor])
                    sys.exit(-1)
            else:
                u_mat[icor] = umat_full
    elif p["model"]["interaction"] == 'respack':
        w90u = Wannier90Converter(seedname=p["model"]["seedname"])
        nr_u, rvec_u, rdeg_u, nwan_u, hamr_u = w90u.read_wannier90hr(
            p["model"]["seedname"] + "_ur.dat")
        w90j = Wannier90Converter(seedname=p["model"]["seedname"])
        nr_j, rvec_j, rdeg_j, nwan_j, hamr_j = w90j.read_wannier90hr(
            p["model"]["seedname"] + "_jr.dat")
        #
        # Read 2-index U-matrix
        #
        umat2 = numpy.zeros((nwan_u, nwan_u), numpy.complex_)
        for ir in range(nr_u):
            if rvec_u[ir, 0] == 0 and rvec_u[ir, 1] == 0 and rvec_u[ir,
                                                                    2] == 0:
                umat2 = hamr_u[ir]
        #
        # Read 2-index J-matrix
        #
        jmat2 = numpy.zeros((nwan_j, nwan_j), numpy.complex_)
        for ir in range(nr_j):
            if rvec_j[ir, 0] == 0 and rvec_j[ir, 1] == 0 and rvec_j[ir,
                                                                    2] == 0:
                jmat2 = hamr_j[ir]
        #
        # Map into 4-index U at each correlated shell
        #
        start = 0
        for icor in range(ncor):
            for iorb in range(norb[icor]):
                for jorb in range(norb[icor]):
                    u_mat[icor][iorb, jorb, iorb, jorb] = umat2[start + iorb,
                                                                start + jorb]
                    u_mat[icor][iorb, jorb, jorb, iorb] = jmat2[start + iorb,
                                                                start + jorb]
                    u_mat[icor][iorb, iorb, jorb, jorb] = jmat2[start + iorb,
                                                                start + jorb]
            for iorb in range(norb[icor]):
                u_mat[icor][iorb, iorb, iorb, iorb] = umat2[start + iorb,
                                                            start + iorb]
            start += norb[icor]
    #
    for icor in range(ncor):
        u_mat[icor][:, :, :, :].imag = 0.0
    #
    # Spin & Orb
    #
    u_mat2 = [
        numpy.zeros(
            (norb[icor] * 2, norb[icor] * 2, norb[icor] * 2, norb[icor] * 2),
            numpy.complex_) for icor in range(ncor)
    ]
    for icor in range(ncor):
        no = norb[icor]
        for i1 in range(2):
            for i2 in range(2):
                for i3 in range(2):
                    for i4 in range(2):
                        if i1 == i3 and i2 == i4:
                            u_mat2[icor][i1*no:(i1+1)*no, i2*no:(i2+1)*no, i3*no:(i3+1)*no, i4*no:(i4+1)*no]\
                                = u_mat[icor][:, :, :, :]
    f["DCore"]["Umat"] = u_mat2
    print("\n    Wrote to {0}".format(p["model"]["seedname"] + '.h5'))
    del f
Ejemplo n.º 6
0
# Input parameters #
####################

L = 2  # Angular momentum
beta = 10.0  # Inverse temperature
mu = 32.5  # Chemical potential (3 electrons in 5 bands)
# Slater parameters
U = 5.0
J = 0.1
F0 = U
F2 = J * (14.0 / (1.0 + 0.625))
F4 = F2 * 0.625

spin_names = ("up", "dn")
orb_names = range(-L, L + 1)
U_mat = U_matrix(L, radial_integrals=[F0, F2, F4], basis='spherical')

# Number of Matsubara frequencies for GF calculation
n_iw = 200

# Number of imaginary time slices for GF calculation
n_tau = 1001

# Energy window for real frequency GF calculation
energy_window = (-5, 5)
# Number of frequency points for real frequency GF calculation
n_w = 1000

# GF structure
gf_struct = set_operator_structure(spin_names, orb_names, False)
Ejemplo n.º 7
0
          spin_names,
          orb_names,
          map_operator_structure=map_operator_structure)
Lz = L_op('z',
          spin_names,
          orb_names,
          map_operator_structure=map_operator_structure,
          basis='spherical')
Jz = Sz + Lz

# LS coupling term
# LS = ls_op(spin_names, orb_names, off_diag=off_diag, basis = 'spherical')

# Hamiltonian
# U_mat = U_matrix(L, radial_integrals = [F0,F2,F4], basis='spherical')
U_mat = U_matrix(L, U_int=U, J_hund=J, basis='spherical')
H_int = h_int_slater(spin_names,
                     orb_names,
                     U_mat,
                     map_operator_structure=map_operator_structure)

# H -= mu*N
# H += ls_coupling * LS

# Double check that we are actually using integrals of motion
# h_comm = lambda op: H*op - op*H
# str_if_commute = lambda op: "= 0" if h_comm(op).is_zero() else "!= 0"

# print "Check integrals of motion:"
# print "[H, N]", str_if_commute(N)
# print "[H, Sz]", str_if_commute(Sz)
Ejemplo n.º 8
0
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)