Exemple #1
0
    def test_TBLattice(self):

        tbl = TBLattice(units=self.units,
                        hoppings=self.hoppings,
                        orbital_positions=self.orbital_positions,
                        orbital_names=self.orbital_names)
        print(tbl)

        self.assertEqual(list(self.hoppings.keys()), list(tbl.hoppings.keys()))
        self.assertTrue(
            all(
                map(np.array_equal, self.hoppings.values(),
                    tbl.hoppings.values())))

        # Make sure manual BravaisLattice / TightBinding / BrillouinZone
        # construction yields same objects

        bl = BravaisLattice(self.units, self.orbital_positions,
                            self.orbital_names)
        bz = BrillouinZone(bl)
        tb = TightBinding(bl, self.hoppings)

        self.assertEqual(bl, tbl.bl)
        self.assertEqual(bz, tbl.bz)
        self.assertEqual(tb, tbl.tb)

        # Test H5 Read / Write

        with HDFArchive("tbl.h5", 'w') as arch:
            arch['tbl'] = tbl

        with HDFArchive("tbl.h5", 'r') as arch:
            tbl_read = arch['tbl']

        self.assertEqual(tbl, tbl_read)
Exemple #2
0
def TB_from_wannier90(seed, path='./', extend_to_spin=False, add_local=None):
    r"""
    read wannier90 output and convert to TBLattice object

    reads wannier90 real space lattice vectors from seed.wout file.
    reads wannier90 hoppings from seed_hr.dat file

    Parameters
    ----------
    seed : str
        seedname of wannier90 run, name of *_hr.dat
    path : str, default = './'
        path to wannier90 output dir
    extend_to_spin: bool, default= False
        extend hopping Hamiltonian with spin indices
    add_local: numpy array , default = None
        add a local term to hopping[0,0,0] of shape Norb x Norb

    Returns
    -------
    TBL : triqs TBLattice object
        triqs tight binding object

    """

    from triqs.lattice.tight_binding import TBLattice

    hopp_dict, num_wann = parse_hopping_from_wannier90_hr_dat(path + seed +
                                                              '_hr.dat')
    units = parse_lattice_vectors_from_wannier90_wout(path + seed + '.wout')

    if extend_to_spin:
        hopp_dict, num_wann = extend_wannier90_to_spin(hopp_dict, num_wann)

    if add_local is not None:
        hopp_dict[(0, 0, 0)] += add_local

    # Should we use hopp_dict or hopping?
    TBL = TBLattice(units=units,
                    hoppings=hopp_dict,
                    orbital_positions=[(0, 0, 0)] * num_wann,
                    orbital_names=[str(i) for i in range(num_wann)])
    return TBL
Exemple #3
0
def TB_from_pythTB(ptb):
    r"""
    convert pythTB model to TBLattice object

    Parameters
    ----------
    ptb : pythtb.tb_model
        pythTB tight-binding object

    Returns
    -------
    TBL : triqs TBLattice object
        triqs tight binding object

    """

    from triqs.lattice.tight_binding import TBLattice

    # initialize objects
    hopp_dict = {}
    m_zero = np.zeros((ptb.get_num_orbitals(), ptb.get_num_orbitals()),
                      dtype=complex)

    # fill on-site energies
    hopp_dict[(0, 0, 0)] = np.eye(ptb.get_num_orbitals(),
                                  dtype=complex) * ptb._site_energies

    # fill hoppings
    for hopp, orb_from, orb_to, displacement in ptb._hoppings:
        if tuple(displacement) not in hopp_dict:
            hopp_dict[tuple(displacement)] = m_zero.copy()
        hopp_dict[tuple(displacement)][orb_from, orb_to] = hopp

    TBL = TBLattice(
        units=ptb.get_lat(),
        hopping=hopp_dict,
        orbital_positions=ptb.get_orb(),
        orbital_names=[str(i) for i in range(ptb.get_num_orbitals())])

    return TBL
Exemple #4
0
def get_tb_model(t, U, n, m, mu=0., vanilla_tb=False):
    
    h_loc = -U*m*np.diag([+1., -1.]) + (0.5*U*n - mu) * np.eye(2)
    T = - t * np.eye(2)

    if vanilla_tb:
        from triqs.lattice.tight_binding import TBLattice
    else:
        from triqs_tprf.tight_binding import TBLattice
        
    t_r = TBLattice(
        units = [(1, 0, 0)],
        hopping = {
            # nearest neighbour hopping -t
            (0,): h_loc,
            (+1,): T,
            (-1,): T,
            },
        orbital_positions = [(0,0,0)] * 2,
        orbital_names = ['up', 'do'],
        )

    return t_r
Exemple #5
0
def create_model_for_tests(norb, dim, t=0, t1=0, t2=0, t12=0, t21=0, **kwargs):
    full_units = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
    units = full_units[:dim]

    import numpy as np
    if norb == 1:
        t_matrix = -t * np.eye(norb)
    elif norb == 2:
        t_matrix = -np.array([[t1, t12], [t21, t2]])
    else:
        raise NotImplementedError

    all_nn_hoppings = list(itertools.product([-1, 0, 1], repeat=dim))
    non_diagonal_hoppings = [
        hopping for hopping in all_nn_hoppings if sum(np.abs(hopping)) == 1
    ]
    hoppings = {hopping: t_matrix for hopping in non_diagonal_hoppings}

    orbital_positions = [(0, 0, 0)] * norb

    model_for_tests = TBLattice(units, hoppings, orbital_positions)

    return model_for_tests
def tight_binding_model(crystal_field=0., lambda_soc=0.):

    paths = [os.getcwd(), os.path.dirname(__file__)]
    for p in paths:
        if os.path.isfile(p + '/w2w_hr.dat'):
            path = p
            break

    # -- Read Wannier90 results

    hopping, num_wann = parse_hopping_from_wannier90_hr_dat(path +
                                                            '/w2w_hr.dat')
    orbital_names = [str(i) for i in range(num_wann)]
    units = parse_lattice_vectors_from_wannier90_wout(path + '/w2w.wout')

    # -- Extend to spinful model from non-spin polarized Wannier90 result
    hopping_spin, num_wann_spin = extend_wannier90_to_spin(hopping, num_wann)
    #orbital_names_spin = ["".join(reversed(tup)) for tup in itertools.product(orbital_names, ['up_', 'do_'])]
    orbital_names_spin = [
        "".join(tup)
        for tup in itertools.product(['up_', 'do_'], orbital_names)
    ]

    # ------------------------------------------------------------------
    # order is xy_up, xz_up, yz_up, xy_dn, xz_dn, yz_dn

    def lambda_matrix_pavarini(
            lam_xy,
            lam_z):  # according to https://arxiv.org/pdf/1612.03060.pdf
        lam_loc = np.zeros((6, 6), dtype=complex)
        lam_loc[0, 5] = lam_xy / 2.0
        lam_loc[0, 4] = 1j * lam_xy / 2.0
        lam_loc[1, 2] = -1j * lam_z / 2.0
        lam_loc[2, 3] = -lam_xy / 2.0
        lam_loc[1, 3] = -1j * lam_xy / 2.0
        lam_loc[4, 5] = 1j * lam_z / 2.0
        lam_loc = lam_loc + np.transpose(np.conjugate(lam_loc))
        return lam_loc

    def lambda_matrix(lam_xy, lam_z):
        lam_loc = np.zeros((6, 6), dtype=complex)
        lam_loc[0, 4] = 1j * lam_xy / 2.0
        lam_loc[0, 5] = lam_xy / 2.0
        lam_loc[1, 2] = 1j * lam_z / 2.0
        lam_loc[1, 3] = -1j * lam_xy / 2.0
        lam_loc[2, 3] = -lam_xy / 2.0
        lam_loc[4, 5] = -1j * lam_z / 2.0
        lam_loc = lam_loc + np.transpose(np.conjugate(lam_loc))
        return lam_loc

    def cf_matrix(cf_xy, cf_z):
        cf_loc = np.zeros((6, 6), dtype=complex)
        cf_loc[0, 0] = cf_xy
        cf_loc[1, 1] = cf_z
        cf_loc[2, 2] = cf_z
        cf_loc[3, 3] = cf_xy
        cf_loc[4, 4] = cf_z
        cf_loc[5, 5] = cf_z
        return cf_loc

    #lam_loc = lambda_matrix(0.11,0.11)
    #print 'Lambda Matrix: \n', lam_loc

    #lam_loc_pavarini = lambda_matrix_pavarini(0.11,0.11)
    #print 'Lambda Matrix Pavarini: \n', lam_loc_pavarini

    #d_lam_loc = lambda_matrix(0.20,0.20)
    #print 'Lambda + dLambda Matrix: \n', d_lam_loc

    #cf_loc = cf_matrix(-0.01,+0.01)

    cf_loc = cf_matrix(-crystal_field, +crystal_field)
    d_lam_loc = lambda_matrix(lambda_soc, lambda_soc)

    # add soc and cf terms
    hopping = copy.deepcopy(hopping_spin)
    hopping[(0, 0, 0)] += d_lam_loc + cf_loc

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

    #print '--> tight binding model'

    tb_lattice = TBLattice(
        units=units,
        hopping=hopping,
        orbital_positions=[(0, 0, 0)] * num_wann_spin,
        orbital_names=orbital_names_spin,
    )

    tb_lattice.lambda_soc = lambda_soc
    tb_lattice.crystal_field = crystal_field

    return tb_lattice
Exemple #7
0
def create_square_lattice(norb, t, tp=0.0, zeeman=0.0, spin=False, **kwargs):
    r"""Retuns TBLattice that represents a model on a square lattice
    
    The model is described by the Hamiltonian

    .. math:: 
        H=-t \sum_{\langle j, l\rangle \sigma}\left(c_{j \sigma}^{\dagger}
        c_{l \sigma}+c_{l \sigma}^{\dagger} c_{j \sigma}\right) -
        t' \sum_{\langle\langle j, l\rangle\rangle \sigma}\left(c_{j \sigma}^{\dagger}
        c_{l \sigma}+c_{l \sigma}^{\dagger} c_{j \sigma}\right) +
        \xi \sum_j \left(n_{j \uparrow} - n_{j \downarrow} \right)\,,

    where the angular bracket describes a sum over nearest neighbors and the double
    angular bracket over next-nearest neighbors.


    Parameters
    ----------
    norb : int,
           Number of orbitals excluding spin
    t : complex,
        Kinetic energy of nearest neighbor hopping.
        Corresponds to :math:`t`.
    tp : complex, optional
         Kinetic energy of next-nearest neighbor hopping.
         Corresponds to :math:`t'`.
    zeeman : complex, optional
             Strength of Zeeman term.
             Corresponds to :math:`\xi`.
    spin : bool,
           True if spin index should be used explicitly, False otherwise.
           The Zeeman term can only be applied if spin=True.

    Returns
    -------
    square_lattice : TBLattice
    """

    if zeeman != 0.0 and not spin:
        raise AttributeError(
            'There can not be a Zeeman term in a spinless model.')
    if spin:
        norb *= 2

    import numpy as np
    t_matrix = -t * np.eye(norb)
    tp_matrix = -tp * np.eye(norb)
    zeeman_matrix = zeeman * np.diag([(-1)**orb for orb in range(norb)])

    hopping = {
        # Zeeman term
        (0, 0): zeeman_matrix,

        # nearest neighbour hopping
        (0, +1): t_matrix,
        (0, -1): t_matrix,
        (+1, 0): t_matrix,
        (-1, 0): t_matrix,

        # next-nearest neighbour hopping
        (+1, +1): tp_matrix,
        (-1, -1): tp_matrix,
        (+1, -1): tp_matrix,
        (-1, +1): tp_matrix,
    }

    units = [(1, 0, 0), (0, 1, 0)]
    orbital_positions = [(0, 0, 0)] * norb

    square_lattice = TBLattice(units, hopping, orbital_positions)

    return square_lattice