def _atoms_too_close(self, iatom): """Check if any two atoms are too close, i.e. closer then the sum of their covalent radii, scaled by self.close_scale. Minimum image distances are used. Parameters ---------- iatom : int Index into self.coords_frac, defining the number of atoms currently in there (iatom +1). """ # dist: min image dist correct only up to rmax_smith(), but we check if # atoms are too close; too big dists are no problem; choose only upper # triangle from array `dist` natoms_filled = iatom + 1 coords_frac = self.coords_frac[:natoms_filled,:] # This part is 10x slower than the fortran version -------- # distvecs_frac: (natoms_filled, natoms_filled, 3) # distvecs: (natoms_filled, natoms_filled, 3) # dist: (natoms_filled, natoms_filled) ##distvecs_frac = coords_frac[:,None,:] - coords_frac[None,:,:] ##distvecs_frac = min_image_convention(sij) ##distvecs = np.dot(sij, self.cell) ##dist = np.sqrt((rij**2.0).sum(axis=2)) #----------------------------------------------------------- nn = natoms_filled # XXX For maximum speed: dummy1 and dummy2 may be big and are allocated # each time this method is called, which may be *many* times. Either # re-write the fortran code to not require them as input or allocate # them in __init__(). distsq,dummy1,dummy2 = fempty((nn,nn)), fempty((nn,nn,3)), \ fempty((nn,nn,3)) distsq, dummy1, dummy2 = _flib.distsq_frac(coords_frac, self.cell, 1, distsq, dummy1, dummy2) dist = np.sqrt(distsq) # This part is fast dij_min_filled = self.dij_min[:natoms_filled,:natoms_filled] return np.triu(dist < dij_min_filled, k=1).any()
def _atoms_too_close(self, iatom): """Check if any two atoms are too close, i.e. closer then the sum of their covalent radii, scaled by self.close_scale. Minimum image distances are used. Parameters ---------- iatom : int Index into self.coords_frac, defining the number of atoms currently in there (iatom +1). """ # dist: min image dist correct only up to rmax_smith(), but we check if # atoms are too close; too big dists are no problem; choose only upper # triangle from array `dist` natoms_filled = iatom + 1 coords_frac = self.coords_frac[:natoms_filled, :] # This part is 10x slower than the fortran version -------- # distvecs_frac: (natoms_filled, natoms_filled, 3) # distvecs: (natoms_filled, natoms_filled, 3) # dist: (natoms_filled, natoms_filled) ##distvecs_frac = coords_frac[:,None,:] - coords_frac[None,:,:] ##distvecs_frac = min_image_convention(sij) ##distvecs = np.dot(sij, self.cell) ##dist = np.sqrt((rij**2.0).sum(axis=2)) #----------------------------------------------------------- nn = natoms_filled # XXX For maximum speed: dummy1 and dummy2 may be big and are allocated # each time this method is called, which may be *many* times. Either # re-write the fortran code to not require them as input or allocate # them in __init__(). distsq,dummy1,dummy2 = fempty((nn,nn)), fempty((nn,nn,3)), \ fempty((nn,nn,3)) distsq, dummy1, dummy2 = _flib.distsq_frac(coords_frac, self.cell, 1, distsq, dummy1, dummy2) dist = np.sqrt(distsq) # This part is fast dij_min_filled = self.dij_min[:natoms_filled, :natoms_filled] return np.triu(dist < dij_min_filled, k=1).any()
def fdist(arr, cell, pbc=0): natoms = arr.shape[0] distsq = num.fempty((natoms,natoms)) dummy1 = num.fempty((natoms,natoms,3)) dummy2 = num.fempty((natoms,natoms,3)) return _flib.distsq_frac(arr, cell, pbc, distsq, dummy1, dummy2)
def fdist(arr, cell, pbc=0): natoms = arr.shape[0] distsq = num.fempty((natoms, natoms)) dummy1 = num.fempty((natoms, natoms, 3)) dummy2 = num.fempty((natoms, natoms, 3)) return _flib.distsq_frac(arr, cell, pbc, distsq, dummy1, dummy2)