def average_structure(self, force_update=False): """ Calculates the atom positions of the average structure of the aligned clusters in the group. """ if not force_update and self._average is not None: return self._average nsuccessful = sum(self.successful) avg_coords = [[0.0, 0.0, 0.0] for i in range(self.natoms)] for cluster in self.clusters: if not cluster.successful: continue # The order of atoms in aligned_targets is the same for every target so we don't need to reorder by result.ind. That has been done during the alignment. for i,atom in enumerate(cluster.aligned_target): if i == len(cluster.aligned_target): break # This is a weird bug... avg_coords[i][0] += atom.coord[0]/nsuccessful avg_coords[i][1] += atom.coord[1]/nsuccessful avg_coords[i][2] += atom.coord[2]/nsuccessful m = Cluster(center_included=False, comment='averaged structure', xsize=100.,ysize=100.,zsize=100., atoms=[Atom(i, 'Si', *coord) for i,coord in enumerate(avg_coords)]) m.add(Atom(m.natoms, 'Si', *[0., 0., 0.])) # Add a center atom at (0,0,0) m.center = m.atoms[-1] m.center.neighs = m.atoms[:-1] #m.rescale_bond_distances(3.5) VT.calculate_atom(m, atom=m.center, cutoff=max(m.dist(m.atoms[-1],atom) for atom in m.atoms[:-1])+0.1) #VP calculation #print(" Center atom's VP index is {0}".format(m.center.vp)) self._average = m return m
def voronoi(self, atom=None, atoms=None, cutoff=None, atol=0.03, tol=0.03, tltol=0.03): if atoms is not None and isinstance(atoms, list): for atom in atoms: if atom.neighs is None: raise Exception("Atom {0} does not have neighbors.".format(atom)) voronoi_3d.calculate_atom(self, atom, cutoff, atol=0.03, tol=0.03, tltol=0.03) elif atom is not None: if atom.neighs is None: raise Exception("Atom {0} does not have neighbors.".format(atom)) voronoi_3d.calculate_atom(self, atom, cutoff, atol=0.03, tol=0.03, tltol=0.03) else: self.voronoi(atoms=self.atoms, atol=atol, tol=tol, tltol=tltol) return None