Exemple #1
0
 def get_basis_set(self, atoms, spin=0):
     bset = BasisSet()
     sdict = symbol_number(atoms.get_chemical_symbols())
     for b in self.basis.keys():
         sn, label, _, _ = b.split('|')
         site = sdict[sn]
         bset.append(Basis(site=site, label=label, spin=spin, index=0))
     return bset
Exemple #2
0
    def __init__(self, sisl_hamiltonian, shift_fermi=None, spin=None):
        self.ham = sisl_hamiltonian
        self.shift_fermi = shift_fermi
        self.spin = spin
        self.orbs = []
        self.orb_dict = defaultdict(lambda: [])
        g = self.ham._geometry
        _atoms = self.ham._geometry._atoms
        atomic_numbers = []
        atom_positions = g.xyz
        self.cell = np.array(g.sc.cell)
        for ia, a in enumerate(_atoms):
            atomic_numbers.append(a.Z)
        self.atoms = Atoms(numbers=atomic_numbers,
                           cell=self.cell,
                           positions=atom_positions)
        xred = self.atoms.get_scaled_positions()
        sdict = list(symbol_number(self.atoms).keys())
        if self.ham.spin.is_colinear:
            if spin is None:
                raise ValueError("For colinear spin, spin must be given")
        else:
            if spin is not None:
                raise ValueError(
                    "For non-colinear spin and unpolarized spin, spin should be None"
                )

        self.positions = []
        if self.ham.spin.is_colinear:
            for ia, a in enumerate(_atoms):
                symnum = sdict[ia]
                orb_names = []
                for x in a.orbital:
                    name = f"{symnum}|{x.name()}|{spin}"
                    orb_names.append(name)
                    self.positions.append(xred[ia])
                self.orbs += orb_names
                self.orb_dict[ia] += orb_names
            self.norb = len(self.orbs)
            self.nbasis = self.norb
        elif self.ham.spin.is_spinorbit:
            for spin in ['up', 'down']:
                for ia, a in enumerate(_atoms):
                    symnum = sdict[ia]
                    orb_names = []
                    for x in a.orbital:
                        name = f"{symnum}|{x.name()}|{spin}"
                        orb_names.append(name)
                        self.positions.append(xred[ia])
                    self.orbs += orb_names
                    self.orb_dict[ia] += orb_names
            self.norb = len(self.orbs) / 2
            self.nbasis = len(self.orbs)
        else:
            raise ValueError(
                "The hamiltonian should be either spin-orbit or colinear")
        self.positions = np.array(self.positions, dtype=float)