def interpolate(self, point, cart=False): """ Calculates the value at `point` using trilinear interpolation. Arguments: point: point to evaluate the value at. Keyword Arguments: cart: If True, the point is taken as a cartesian coordinate. If not, it is assumed to be in fractional coordinates. default=False. """ if cart: point = self.cart_to_coord(point) point = utils.wrap(point) x0, y0, z0 = (int(np.floor(point[0] * self.mesh[0])), int(np.floor(point[1] * self.mesh[1])), int(np.floor(point[2] * self.mesh[2]))) x, y, z = ((point[0] * self.mesh[0]) % 1, (point[1] * self.mesh[1]) % 1, (point[2] * self.mesh[2]) % 1) x1, y1, z1 = ((x0 + 1) % self.mesh[0], (y0 + 1) % self.mesh[1], (z0 + 1) % self.mesh[2]) interp_val = (self.data[x0, y0, z0] * (1 - x) * (1 - y) * (1 - z) + self.data[x1, y0, z0] * x * (1 - y) * (1 - z) + self.data[x0, y1, z0] * (1 - x) * y * (1 - z) + self.data[x0, y0, z1] * (1 - x) * (1 - y) * z + self.data[x1, y1, z0] * x * y * (1 - z) + self.data[x1, y0, z1] * x * (1 - y) * z + self.data[x0, y1, z1] * (1 - x) * y * z + self.data[x1, y1, z1] * x * y * z) return interp_val
def interpolate(self, point, cart=False): """ Calculates the value at `point` using trilinear interpolation. Arguments: point: point to evaluate the value at. Keyword Arguments: cart: If True, the point is taken as a cartesian coordinate. If not, it is assumed to be in fractional coordinates. default=False. """ if cart: point = self.cart_to_coord(point) point = utils.wrap(point) x0,y0,z0 = ( int(np.floor(point[0]*self.mesh[0])), int(np.floor(point[1]*self.mesh[1])), int(np.floor(point[2]*self.mesh[2])) ) x,y,z = ( (point[0]*self.mesh[0]) % 1, (point[1]*self.mesh[1]) % 1, (point[2]*self.mesh[2]) % 1) x1,y1,z1 = ( (x0+1) % self.mesh[0], (y0+1) % self.mesh[1], (z0+1) % self.mesh[2] ) interp_val = ( self.data[x0,y0,z0]*(1-x)*(1-y)*(1-z) + self.data[x1,y0,z0]*x*(1-y)*(1-z) + self.data[x0,y1,z0]*(1-x)*y*(1-z) + self.data[x0,y0,z1]*(1-x)*(1-y)*z + self.data[x1,y1,z0]*x*y*(1-z) + self.data[x1,y0,z1]*x*(1-y)*z + self.data[x0,y1,z1]*(1-x)*y*z + self.data[x1,y1,z1]*x*y*z ) return interp_val
def equivalent_sites(self, point, tol=1e-3): equiv = [] for rot, trans in zip(self.rotations, self.translations): new = utils.wrap(np.dot(rot, point) + trans) if not any([ all([ abs(o-n) < tol for o,n in zip(old, new)]) for old in equiv]): equiv.append(new) return equiv
def cart_to_coord(self, cart): return utils.wrap(np.dot(self.inv.T, cart))
def ind_to_coord(self, ind): """ Converts an [i,j,k] index to [x,y,z] frational coordinate. """ return utils.wrap(self.spacing * ind)
def ind_to_coord(self, ind): """ Converts an [i,j,k] index to [x,y,z] frational coordinate. """ return utils.wrap(self.spacing*ind)