def get_vonoroi_intersitial_sites(structure, index=0, symprec=0.01): import tess from method import utilities n_shell = 4 vonoroi_points_number = 9999999 while True: points, limits = create_basic_cell_parameters(structure, index, n_shell, symprec) vonoroi_cell = tess.Container(points, limits) cell = vonoroi_cell[0] cell_vertices = vonoroi_cell_vertices(cell) face_center = vonoroi_face_center(cell) edge_center = vonoroi_edge_center(cell) sites = np.row_stack((cell_vertices, face_center, edge_center)) if len(sites) == vonoroi_points_number: break else: n_shell = n_shell * 2 vonoroi_points_number = len(sites) if n_shell > 1024: # avoid some unknown problems break positions = [] transform = structure[index].pos for site in sites: site = utilities.into_cell(site + transform, structure.cell) site = np.ndarray.tolist(site) positions.append(site) positions = sorted(positions) return positions
def inequivalent_intersitial_sites(structure, index=0, tolerance=1e-3, vnrprec=1e-3, symprec=0.1, n_shell=4): import tess import numpy as np from method import utilities points, limits = create_basic_cell_parameters(structure, index, n_shell, vnrprec) vonoroi_cell = tess.Container(points, limits) cell = vonoroi_cell[0] cell_vertices = vonoroi_cell_vertices(cell) face_center = vonoroi_face_center(cell) edge_center = vonoroi_edge_center(cell) sites = np.row_stack((cell_vertices, face_center, edge_center)) positions = [] transform = structure[index].pos for site in sites: site = utilities.into_cell(site + transform, structure.cell) site = np.ndarray.tolist(site) positions.append(site) positions = sorted(positions) ops = get_symmetrical_operations(structure, symprec=symprec) positions = remove_equivalent_sites(structure, index, positions, ops, tolerance) return positions
def setup(opt=5): RL(tess, vor, vor1, cg) ctx = TestVor() ctx.setUp() if opt == 4: return tess.Container(ctx.weighted, limits=(1., 1., 1.)) if opt == 5: return cg.WVoronoi(ctx.weighted)
def tess(self): """Get a `tess.Container` instance of this. Requires `tess`. """ import tess return tess.Container(self.rs * self.L % self.L, limits=self.L, radii=self.diameters * self.L / 2., periodic=True)
def compute_voronoi(self, points): """ Function to return the tess container having information of Voronoi cells for given points in 3D space. Args: points: numpy array of points coordinates. Returns: :tess:class:`Container`: tess container of Voronoi cells. """ P = np.array(points) cntr = tess.Container(P, self.limits, self.periodic) return cntr
def compute_voronoi(points): """ Function to return the python container having information of Voronoi cells for for given points in 3D space Parameters pts = numpy array of points coordinates Returns container = python contrainer having information of Voronoi cells """ P = np.array(points) # box limits along x, y, and z axis Lx = 50 Ly = 50 Lz = 50 cntr = tess.Container(P, ((-50, -50, -50),(50, 50, 50)), periodic=(False, False, False)) return cntr
def test_basic4(self): vr = tess.Container([[x, y, 0.0] for x, y, w in self.weighted], radii=[x[-1] for x in self.weighted], limits=((0., 0., -1.), (1., 1., 1.))) plotv(vr)
def single_config_voronoi_calculator(config, box_range, cut_off, atom_list=None, max_edge_count=8, periodic=[True,True,True],return_volume=False, tool="pyvoro"): """ this function calculates the voronoi index for atoms in atom_list config: pandas.Dataframe configuration data stored in pandas.Dataframe atom_list: list or dict list of atom item id or dict for local mode box_range: list list of simulation box range in x, y, z direction cut_off: float max distance between two points that might be adjacent, which sets voro++ block sizes max_edge_count: int an integer that specify the maximum number of edges that will be trucated in voronoi index, this can be specified from user's experience for their problems or calculated from the maximum of all max_edge_count for all particles return_volume: Boolean if True, return the voronoi cell volume of each atomic particle along with their voronoi indexes return: voronoi_index: list of lists voronoi_index for each atom in atom_list """ # read the configuration data # points = (config[['x','y','z']].values).tolist() if atom_list is None: atom_list = (config["item"].values).tolist() int_points = config.loc[config['item'].isin(atom_list)] # order int_points based on the appearance of atom in atom_list df = pd.DataFrame() for atom in atom_list: df = df.append(int_points.loc[int_points['item'] == atom]) int_points = df #int_points_item_id = (int_points["item"].values).tolist() #int_points_index = [atom-1 for atom in atom_list] dispersion = cut_off box_dim = [box_range[0][1] - box_range[0][0], box_range[1][1] - box_range[1][0], box_range[2][1] - box_range[2][0]] int_voro_results = [] for index,point in int_points.iterrows(): # calculate NN of this point # result_group = result_tree.query_ball_point(point[['x','y','z']].values, cut_off * 2.0) [x_c, y_c, z_c] = point[['x','y','z']].values config_corr = config[config.item != point['item']] NN_df = NN_cube_pbc(config_corr,[x_c, y_c, z_c], box_range, cut_off) #NN_df = config.iloc[result_group] all_df = NN_df.append(point,ignore_index=True) all_points = all_df[['x','y','z']].values # let this NN with this point to calculate voronoi indexes results if tool == "tess": limits = (box_range[0][0],box_range[1][0],box_range[2][0]),(box_range[0][1],box_range[1][1], box_range[2][1]) results = tess.Container(all_points, limits, periodic=tuple(periodic)) else: results = pyvoro.compute_voronoi(all_points, box_range, dispersion, periodic=periodic) # append the voronoi index of only this point curr_voro = results[-1] int_voro_results.append(curr_voro) if return_volume is True: voronoi_index, volumes = count_faces(int_voro_results, max_edge_count, True, tool=tool) return (voronoi_index, volumes) else: voronoi_index = count_faces(int_voro_results, max_edge_count, False,tool=tool) return voronoi_index