def make_supercell(self,
                       sc_matrix=None,
                       supercell_maker=None,
                       pbc=[1, 1, 1]):
        if supercell_maker is None:
            smaker = SupercellMaker(sc_matrix)
        else:
            smaker = supercell_maker

        sc_cell = smaker.sc_cell(np.array(self.cell))
        sc_pos = np.array(smaker.sc_pos(np.array(self.pos)))
        sc_zion = smaker.sc_trans_invariant(np.array(self.zion))

        if self.index_spin is not None:
            sc_index_spin = smaker.sc_trans_invariant(self.index_spin)

        sc_Rlist = np.repeat(smaker.R_sc, self.nspin, axis=0)
        sc_iprim = smaker.sc_trans_invariant(list(range(self.nspin)))

        sc_spinat = np.array(smaker.sc_trans_invariant(self.spinat))

        sc_ham = SpinHamiltonian(cell=sc_cell,
                                 pos=sc_pos,
                                 spinat=sc_spinat,
                                 zion=sc_zion,
                                 Rlist=sc_Rlist,
                                 iprim=sc_iprim)

        sc_gyro_ratio = np.array(smaker.sc_trans_invariant(self.gyro_ratio))
        sc_ham.gyro_ratio = sc_gyro_ratio

        sc_gilbert_damping = np.array(
            smaker.sc_trans_invariant(self.gilbert_damping))
        sc_ham.gilbert_damping = sc_gilbert_damping

        if self.has_external_hfield:
            sc_Hext = smaker.sc_trans_invariant(self.H_ext)
            sc_ham.set_external_hfield(sc_Hext)

        if self.has_uniaxial_anistropy:
            sc_k1 = smaker.sc_trans_invariant(self.k1)
            sc_k1dir = smaker.sc_trans_invariant(self.k1dir)
            sc_ham.set_uniaxial_mca(sc_k1, np.array(sc_k1dir))

        if self.has_exchange:
            sc_Jdict = smaker.sc_ijR(self.exchange_Jdict,
                                     n_basis=len(self.pos))
            sc_ham.set_exchange_ijR(exchange_Jdict=sc_Jdict, pbc=pbc)

        if self.has_dmi:
            sc_dmi_ddict = smaker.sc_ijR(self.dmi_ddict, n_basis=len(self.pos))
            sc_ham.set_dmi_ijR(sc_dmi_ddict)

        return sc_ham
Beispiel #2
0
 def make_supercell(self, supercell_matrix=None, scmaker=None):
     if scmaker is None:
         scmaker = SupercellMaker(sc_matrix=supercell_matrix)
     ret = ijR(nbasis=self.nbasis * scmaker.ncell)
     if self.positions is None:
         ret.positions = None
     else:
         ret.positions = scmaker.sc_pos(self.positions)
     ret.sparse = self.sparse
     ret.double_site_energy = self.double_site_energy
     for R, mat in self.data.items():
         for i in range(self.nbasis):
             for j in range(self.nbasis):
                 for sc_i, sc_j, sc_R in scmaker.sc_ijR_only(
                         i, j, R, self.nbasis):
                     ret.data[sc_R][sc_i, sc_j] = mat[i, j]
     return ret