def _expandAsymmetricUnit(self): """Perform symmetry expansion of self.stru using self.spacegroup. This method updates data in stru and eau. No return value. """ from diffpy.structure.symmetryutilities import ExpandAsymmetricUnit # get reverse-ordered unique indices corepos = [a.xyz for a in self.stru] coreUijs = [a.U for a in self.stru] self.eau = ExpandAsymmetricUnit(self.spacegroup, corepos, coreUijs, eps=self.eps) # build a nested list of new atoms: newatoms = [] for i, ca in enumerate(self.stru): eca = [] # expanded core atom for j in range(self.eau.multiplicity[i]): a = Atom(ca) a.xyz = self.eau.expandedpos[i][j] if j > 0: a.label += '_' + str(j + 1) if a.anisotropy: a.U = self.eau.expandedUijs[i][j] eca.append(a) newatoms.append(eca) # insert new atoms where they belong self.stru[:] = sum(newatoms, []) return
def expandAsymmetricUnit(self, spacegroup, indices, sgoffset=[0,0,0]): """Perform symmetry expansion for atoms at given indices. Temperature factors may be corrected to reflect the symmetry. All constraints for expanded atoms are erased with the exception of the occupancy("occ". Constraints of unaffected atoms are adjusted for new positions self.initial. spacegroup -- instance of SpaceGroup from diffpy.structure indices -- list of integer indices of atoms to be expanded sgoffset -- optional offset of space group origin [0,0,0] """ from diffpy.structure.symmetryutilities import ExpandAsymmetricUnit acd = self._popAtomConstraints() # get unique, reverse sorted indices ruindices = dict.fromkeys(indices).keys() ruindices.sort() ruindices.reverse() coreatoms = [self.initial[i] for i in ruindices] corepos = [a.xyz for a in coreatoms] coreUijs = [a.U for a in coreatoms] eau = ExpandAsymmetricUnit(spacegroup, corepos, coreUijs, sgoffset=sgoffset, eps=self.symposeps) # build a nested list of new atoms: newatoms = [] for i in range(len(coreatoms)): ca = coreatoms[i] caocc_con = None if ca in acd and "occ" in acd[ca]: caocc_con = acd[ca]["occ"] eca = [] # expanded core atom for j in range(eau.multiplicity[i]): a = Atom(ca) a.xyz = eau.expandedpos[i][j] a.U = eau.expandedUijs[i][j] eca.append(a) if caocc_con is None: continue # make a copy of occupancy constraint acd[a] = {"occ" : copy.copy(caocc_con)} newatoms.append(eca) # insert new atoms where they belong for i, atomlist in zip(ruindices, newatoms): self.initial[i:i+1] = atomlist # remember this spacegroup as the last one used self.initial.pdffit["spcgr"] = spacegroup.short_name self.initial.pdffit["sgoffset"] = list(sgoffset) # tidy constraints self._restoreAtomConstraints(acd) return
def _expandAsymmetricUnit(self, block): """Perform symmetry expansion of self.stru using self.spacegroup. This method updates data in stru and eau. Parameters ---------- block : CifBlock The top-level block containing crystal structure data. """ from diffpy.structure.symmetryutilities import ExpandAsymmetricUnit corepos = [a.xyz for a in self.stru] coreUijs = [a.U for a in self.stru] self.eau = ExpandAsymmetricUnit(self.spacegroup, corepos, coreUijs, eps=self.eps) # setup anisotropy according to symmetry requirements # unless it was already explicitly set for ca, uisotropy in zip(self.stru, self.eau.Uisotropy): if not ca.label in self.anisotropy: ca.anisotropy = not uisotropy self.anisotropy[ca.label] = ca.anisotropy # build a nested list of new atoms: newatoms = [] for i, ca in enumerate(self.stru): eca = [] # expanded core atom for j in range(self.eau.multiplicity[i]): a = Atom(ca) a.xyz = self.eau.expandedpos[i][j] if j > 0: a.label += '_' + str(j + 1) if a.anisotropy: a.U = self.eau.expandedUijs[i][j] eca.append(a) newatoms.append(eca) # insert new atoms where they belong self.stru[:] = sum(newatoms, []) return