Ejemplo n.º 1
0
    def pyscal_steinhardt_parameter(
        self,
        neighbor_method="cutoff",
        cutoff=0,
        n_clusters=2,
        q=None,
        averaged=False,
        clustering=None,
    ):
        """
        Calculate Steinhardts parameters

        Args:
            neighbor_method (str) : can be ['cutoff', 'voronoi']. (Default is 'cutoff'.)
            cutoff (float) : Can be 0 for adaptive cutoff or any other value. (Default is 0, adaptive.)
            n_clusters (int/None) : Number of clusters for K means clustering or None to not cluster. (Default is 2.)
            q (list) : Values can be integers from 2-12, the required q values to be calculated. (Default is None, which
                uses (4, 6).)
            averaged (bool) : If True, calculates the averaged versions of the parameter. (Default is False.)

        Returns:
            numpy.ndarray: (number of q's, number of atoms) shaped array of q parameters
            numpy.ndarray: If `clustering=True`, an additional per-atom array of cluster ids is also returned
        """
        return get_steinhardt_parameter_structure(
            self._structure,
            neighbor_method=neighbor_method,
            cutoff=cutoff,
            n_clusters=n_clusters,
            q=q,
            averaged=averaged,
            clustering=clustering,
        )
Ejemplo n.º 2
0
    def test_steinhardt_parameters_qs(self):
        """
        Test the calculation of Steinhardts parameters
        """
        perfect_vals = [0.00, 0.00, 0.190, 0.00, 0.575, 0.00, 0.404, 0.00,
                        0.013, 0.00, 0.600]

        qtest = np.random.randint(2, 13, size=2)

        qs, _ = pas.get_steinhardt_parameter_structure(self.structure, cutoff=0, n_clusters=2, q=qtest)
        for c, q in enumerate(qs):
            self.assertLess(np.abs(np.mean(q) - perfect_vals[qtest[c]-2]), 1E-3)
Ejemplo n.º 3
0
    def pyscal_steinhardt_parameter(self, neighbor_method="cutoff", cutoff=0, n_clusters=2,
                                            q=(4, 6), averaged=False, clustering=True):
        """
        Calculate Steinhardts parameters

        Args:
            neighbor_method (str) : can be ['cutoff', 'voronoi']
            cutoff (float) : can be 0 for adaptive cutoff or any other value
            n_clusters (int) : number of clusters for K means clustering
            q (list) : can be from 2-12, the required q values to be calculated
            averaged (bool) : If True, calculates the averaged versions of the parameter
            clustering (bool) : If True, cluster based on the q values

        Returns:
            list: calculated q parameters

        """
        return get_steinhardt_parameter_structure(
            self._structure, neighbor_method=neighbor_method, cutoff=cutoff, n_clusters=n_clusters,
            q=q, averaged=averaged, clustering=clustering
        )
Ejemplo n.º 4
0
 def test_steinhardt_parameters_clustering(self):
     noisy_structure = self.structure.copy()
     noisy_structure.positions += 0.5 * np.random.rand(*noisy_structure.positions.shape)
     n_clusters = 3
     _, inds = pas.get_steinhardt_parameter_structure(noisy_structure, n_clusters=n_clusters)
     self.assertEqual(n_clusters, len(np.unique(inds)), msg='Expected to find one label for each cluster.')
Ejemplo n.º 5
0
 def test_steinhardt_parameters_returns(self):
     self.assertEqual(2, len(pas.get_steinhardt_parameter_structure(self.structure)),
                      msg='Expected default return value to be a tuple of qs and cluster indices.')
     self.assertIsInstance(pas.get_steinhardt_parameter_structure(self.structure, n_clusters=None), np.ndarray,
                           msg='Expected just the qs when no clustering is used.')