Ejemplo n.º 1
0
def add_magnetism(h, m):
    """ Adds magnetism to the intracell hopping"""
    intra = h.intra  # intracell hopping
    if h.has_spin:
        natoms = len(h.geometry.r)  # number of atoms
        # create the array
        out = [[None for j in range(natoms)]
               for i in range(natoms)]  # output matrix
        if checkclass.is_iterable(m):
            print(natoms)
            if checkclass.is_iterable(
                    m[0]) and len(m) == natoms:  # input is an array
                mass = m  # use as arrays
            elif len(m) == 3:  # single exchange provided
                mass = [m for i in range(natoms)]  # use as arrays
            else:
                raise
        elif callable(m):  # input is a function
            mass = [m(h.geometry.r[i])
                    for i in range(natoms)]  # call the function
        else:
            print("Wrong input in add_magnetism")
            raise
        for i in range(natoms):  # loop over atoms
            mi = mass[i]  # select the element
            # add contribution to the Hamiltonian
            out[i][i] = sx * mi[0] + sy * mi[1] + sz * mi[2]
        out = bmat(out)  # turn into a matrix
        h.intra = h.intra + h.spinful2full(out)  # Add matrix
    else:
        print("no AF for unpolarized hamiltonian")
        raise
Ejemplo n.º 2
0
def add_antiferromagnetism(h, m, axis):
    """ Adds to the intracell matrix an antiferromagnetic imbalance """
    intra = h.intra  # intracell hopping
    if h.geometry.has_sublattice: pass  # if has sublattice
    else:  # if does not have sublattice
        print("WARNING, no sublattice present")
        return 0.  # if does not have sublattice
    if h.has_spin:
        natoms = len(h.geometry.x)  # number of atoms
        out = [[None for j in range(natoms)]
               for i in range(natoms)]  # output matrix
        # create the array
        if checkclass.is_iterable(m):  # iterable, input is an array
            mass = m  # use the input array
        elif callable(m):  # input is a function
            mass = [m(h.geometry.r[i])
                    for i in range(natoms)]  # call the function
        else:  # assume it is a float
            mass = [m for i in range(natoms)]  # create list
        for i in range(natoms):  # loop over atoms
            mi = mass[i]  # select the element
            if callable(axis):
                ax = np.array(axis(h.geometry.r[i]))  # call the function
            else:
                ax = np.array(axis)  # convert to array
            ax = ax / np.sqrt(ax.dot(ax))  # normalize the direction
            # add contribution to the Hamiltonian
            out[i][i] = mi * (sx * ax[0] + sy * ax[1] +
                              sz * ax[2]) * h.geometry.sublattice[i]
        out = bmat(out)  # turn into a matrix
        h.intra = h.intra + h.spinful2full(out)  # Add matrix
    else:
        print("no AF for unpolarized hamiltonian")
        raise
Ejemplo n.º 3
0
def shift_fermi(h, fermi):
    """ Moves the fermi energy of the system, the new value is at zero"""
    r = h.geometry.r  # positions
    n = len(r)  # number of sites
    if checkclass.is_iterable(fermi):  # iterable
        if len(fermi) == n:  # same number of sites
            h.intra = h.intra + h.spinless2full(sparse_diag([fermi], [0]))
        else:
            raise
    else:
        rc = [i for i in range(n)]  # index
        datatmp = []  # data
        for i in range(n):  # loop over positions
            if callable(fermi): fshift = fermi(r[i])  # fermi shift
            else: fshift = fermi  # assume it is a number
            datatmp.append(fshift)  # append value
        m = csc_matrix((datatmp, (rc, rc)),
                       shape=(n, n))  # matrix with the shift
        h.intra = h.intra + h.spinless2full(m)  # Add matrix
        return
Ejemplo n.º 4
0
 def convert(z):
     if checkclass.is_iterable(z): return z  # iterable, input is an array
     else: return [0., 0., z]  # input is a number