Exemple #1
0
 def make_supercell(self, disord, replace_dict, dim=(2, 2, 2)):
     """
     supercell を作成する
     サイトを埋める元素種は置き換える対象を replace dict で指定
     """
     latt_dis = np.dot(SymOp.trans(disord.brav), disord.lattice.array)
     latt = self.lattice.array
     trans = np.linalg.solve(np.array(latt_dis).T, np.array(latt).T).T
     int_trans = np.round(trans).astype(np.int)
     if (np.abs(trans - int_trans) > 0.01).any():
         print(" transration vect seems to be wrong !!!")
         exit()
     else:
         trans = int_trans
     trans = np.dot(trans, SymOp.trans(disord.brav))
     new_sites = copy.deepcopy(self.sites.sites)
     for num, t in zip(dim, trans):
         add_site = []
         for i in range(1, num):
             add_trans = i * t
             for site in new_sites:
                 try:
                     atom = replace_dict[site.atom[0]]
                 except KeyError:
                     replace_dict.update({site.atom[0]: site.atom[0]})
                     atom = site.atom[0]
                 add_site.append(CVMSite(atom, site.coord+add_trans))
         new_sites += add_site
     new_sites = CVMSites(new_sites)
     new_label = 'SC' + self.label.label
     elems = f_chain(
         self.label.elements + new_sites.elements_counter.keys(),
         lambda x: [x0[0] for x0 in x],
         set, sorted)
     new_label = CVMLabel.from_sites(new_sites, new_label, elems)
     new_latt = f_chain(latt*(np.array(dim).reshape(3, 1)),
                        CVMLattice.from_array)
     return CVMStructure(new_label, self.brav, self.disord, self.nph,
                         new_latt, new_sites) # | fnc.echo
Exemple #2
0
 def from_sites(cls, sites, label, elements=None):
     """ sites obj から生成 """
     if not elements:
         elements = f_chain(sites.elements_counter.keys(), set, sorted)
     num_atoms = [sites.elements_counter[elem] for elem in elements]
     return cls(label, elements, num_atoms)