How to use the pyxtal.operations.apply_ops function in pyxtal

To help you get started, we’ve selected a few pyxtal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qzhu2017 / PyXtal / pyxtal / crystal.py View on Github external
cycle3 = 0
        while cycle3 < wyckoff_attempts:

            self.cycle3 = cycle3
            # Choose a random WP for given multiplicity: 2a, 2b
            if sites_list is not None:
                site = sites_list[0]
            else: # Selecting the merging 
                site = None
            
            ops = choose_wyckoff(self.group, numIon - numIon_added, site, self.dim)
            if ops is not False:
                # Generate a list of coords from ops
                pt = self.lattice.generate_point()
                proj_pt = project_point(pt, ops[0], cell_matrix, self.PBC)
                coords = apply_ops(proj_pt, ops)


                # Merge coordinates if the atoms are close
                coords_toadd, wp_index, pt = merge_coordinate(
                    coords, cell_matrix, self.group, tol
                )
                if site is not None and len(coords_toadd) < len(coords):
                    continue # break the cycle if the merge happens
                #print(coords)
                #print(coords_toadd, wp_index, pt)
                #import sys
                #sys.exit()

                if wp_index is not False:
                    # Use a Wyckoff_site object for the current site
                    current_site = atom_site(self.group[wp_index], pt, specie)
github qzhu2017 / PyXtal / pyxtal / crystal.py View on Github external
return coor, False, None
            # Calculate minimum separation for each WP
            distances = []
            for i in possible:
                wp = group[i]
                projected_point = project_point(point, wp[0], lattice=lattice, PBC=PBC)
                # NOTE Comprhys: new_coor note used?
                new_coor = apply_ops(projected_point, wp)
                d = distance(point - projected_point, lattice, PBC=PBC)
                distances.append(np.min(d))
            # Choose wp with shortest translation for generating point
            tmpindex = np.argmin(distances)
            index = possible[tmpindex]
            newwp = group[index]
            projected_point = project_point(point, newwp[0], lattice=lattice, PBC=PBC)
            coor = apply_ops(projected_point, newwp)
            point = coor[0]
            index = newwp.index
        # Distances were not too small; return True
        else:
            return coor, index, point
github qzhu2017 / PyXtal / pyxtal / wyckoff_site.py View on Github external
def get_centers(self, absolute=False):
        """
        Returns the fractional coordinates for the center of mass for each molecule in
        the Wyckoff position

        Returns:
            A numpy array of fractional 3-vectors
        """
        centers = apply_ops(self.position, self.wp.generators)
        # centers1 = filtered_coords(centers0, self.PBC)
        if absolute is False:
            return centers
        else:
            return np.dot(centers, self.lattice)
github qzhu2017 / PyXtal / pyxtal / molecular_crystal.py View on Github external
# Check that a valid orientation exists
                j, k = jk_from_i(i, orientations)
                if orientations[j][k] == []:
                    continue
                # Only allow smaller WP's that are an integer factor of the current one
                if (mult2 < mult1) and (mult1 % mult2 == 0):
                    possible.append(i)
            if possible == []:
                return coor, False, None
            # Calculate minimum separation for each WP
            distances = []
            for i in possible:
                wp = group[i]
                projected_point = project_point(point, wp[0], lattice=lattice, PBC=PBC)
                # NOTE new coor never used?
                new_coor = apply_ops(projected_point, wp)
                d = distance(point - projected_point, lattice, PBC=PBC)
                distances.append(np.min(d))
            # Choose wp with shortest translation for generating point
            tmpindex = np.argmin(distances)
            index = possible[tmpindex]
            newwp = group[index]
            projected_point = project_point(point, newwp[0], lattice=lattice, PBC=PBC)
            coor = apply_ops(projected_point, newwp)
            point = coor[0]
            index = newwp.index
        # Distances were not too small; return True
        else:
            return coor, index, point
github qzhu2017 / PyXtal / pyxtal / molecular_crystal.py View on Github external
# Choose a random WP for given multiplicity: 2a, 2b, 2c
                            # NOTE: The molecular version return wyckoff indices, not ops
                            wp = choose_wyckoff_molecular(
                                self.group,
                                numMol - numMol_added,
                                valid_ori,
                                self.select_high,
                            )
                            if wp is not False:
                                # Generate a list of coords from the wyckoff position
                                point = self.lattice.generate_point()
                                projected_point = project_point(
                                    point, wp[0], lattice=cell_matrix, PBC=self.PBC
                                )

                                coords = apply_ops(projected_point, wp)
                                # merge coordinates if the atoms are close
                                if self.check_atomic_distances:
                                    mtol = radius * 0.5
                                else:
                                    mtol = radius * 2

                                (
                                    coords_toadd,
                                    good_merge,
                                    point,
                                ) = merge_coordinate_molecular(
                                    coords, cell_matrix, self.group, mtol, valid_ori
                                )
                                if good_merge is not False:
                                    wp_index = good_merge
                                    # scale the coordinates to [0,1], very important!
github qzhu2017 / PyXtal / pyxtal / crystal.py View on Github external
# Find possible wp's to merge into
            possible = []
            for i, wp in enumerate(group):
                mult2 = wp.multiplicity
                # factor = mult2 / mult1
                if (mult2 < mult1) and (mult1 % mult2 == 0):
                    possible.append(i)
            if possible == []:
                return coor, False, None
            # Calculate minimum separation for each WP
            distances = []
            for i in possible:
                wp = group[i]
                projected_point = project_point(point, wp[0], lattice=lattice, PBC=PBC)
                # NOTE Comprhys: new_coor note used?
                new_coor = apply_ops(projected_point, wp)
                d = distance(point - projected_point, lattice, PBC=PBC)
                distances.append(np.min(d))
            # Choose wp with shortest translation for generating point
            tmpindex = np.argmin(distances)
            index = possible[tmpindex]
            newwp = group[index]
            projected_point = project_point(point, newwp[0], lattice=lattice, PBC=PBC)
            coor = apply_ops(projected_point, newwp)
            point = coor[0]
            index = newwp.index
        # Distances were not too small; return True
        else:
            return coor, index, point
github qzhu2017 / PyXtal / pyxtal / molecular_crystal.py View on Github external
return coor, False, None
            # Calculate minimum separation for each WP
            distances = []
            for i in possible:
                wp = group[i]
                projected_point = project_point(point, wp[0], lattice=lattice, PBC=PBC)
                # NOTE new coor never used?
                new_coor = apply_ops(projected_point, wp)
                d = distance(point - projected_point, lattice, PBC=PBC)
                distances.append(np.min(d))
            # Choose wp with shortest translation for generating point
            tmpindex = np.argmin(distances)
            index = possible[tmpindex]
            newwp = group[index]
            projected_point = project_point(point, newwp[0], lattice=lattice, PBC=PBC)
            coor = apply_ops(projected_point, newwp)
            point = coor[0]
            index = newwp.index
        # Distances were not too small; return True
        else:
            return coor, index, point