Example #1
0
    def unique_configurations( self, site_distribution, verbose=False, show_progress=False ):
        """
        Find the symmetry inequivalent configurations for a given population of objects.

        Args:
            site_distribution (dict): A dictionary that defines the number of each object 
                                      to be arranged in this system.

                                      e.g. for a system with four sites, with two occupied (denoted `1`)
                                      and two unoccupied (denoted `0`)::

                                          { 1: 2, 0: 2 }
            verbose (opt:default=False): Print verbose output.
            show_progress (opt:default=False): Show a progress bar.
                                      Setting to `True` gives a simple progress bar.
                                      Setting to `"notebook"` gives a Jupyter notebook compatible progress bar.

        Returns:
            unique_configurations (list): A list of :any:`Configuration` objects, for each symmetry 
                                          inequivalent configuration. 
        """
        s = flatten_list( [ [ key ] * site_distribution[ key ] for key in site_distribution ] )
        total_permutations = number_of_unique_permutations( s )
        if verbose:
            print( 'total number of sites: ' + str( sum( site_distribution.values() ) ) )
            print( 'using {:d} symmetry operations.'.format( len( self.symmetry_group.symmetry_operations ) ) )
            print( 'evaluating {:d} unique permutations.'.format( total_permutations ) )
        generator = unique_permutations( s )
        if show_progress:
            if show_progress=='notebook':
                generator = tqdm_notebook( generator, total=total_permutations, unit=' permutations' )
            else:
                generator = tqdm( generator, total=total_permutations, unit=' permutations' )
        return self.enumerate_configurations( generator, verbose=verbose )
Example #2
0
    def unique_configurations(self, site_distribution, verbose=False):
        """
        Find the symmetry inequivalent configurations for a given population of objects.

        Args:
            site_distribution (dict): A dictionary that defines the number of each object 
                                      to be arranged in this system.

                                      e.g. for a system with four sites, with two occupied (denoted `1`)
                                      and two unoccupied (denoted `0`)::

                                          { 1: 2, 0: 2 }
            verbose (opt:default=False): Print verbose output.

        Returns:
            unique_configurations (list): A list of :any:`Configuration` objects, for each symmetry 
                                          inequivalent configuration. 
        """
        if verbose:
            print('total number of sites: ' +
                  str(sum(site_distribution.values())))
            print('using {:d} symmetry operations: '.format(
                len(self.symmetry_group.symmetry_operations)))
        s = flatten_list([[key] * site_distribution[key]
                          for key in site_distribution])
        generator = unique_permutations(s)
        return self.enumerate_configurations(generator, verbose=verbose)
Example #3
0
 def test_unique_permuations(self):
     all_permutations = [[1, 1, 0, 0], [1, 0, 1, 0], [1, 0, 0, 1],
                         [0, 1, 1, 0], [0, 1, 0, 1], [0, 0, 1, 1]]
     for p in all_permutations:
         unique_permutations = list(permutations.unique_permutations(p))
         self.assertEqual(len(all_permutations), len(unique_permutations))
         # check that every list in all_permutations has been generated
         for p2 in all_permutations:
             self.assertEqual(p2 in unique_permutations, True)
Example #4
0
 def test_unique_permuations( self ):
     all_permutations = [ [ 1, 1, 0, 0 ],
                          [ 1, 0, 1, 0 ],
                          [ 1, 0, 0, 1 ],
                          [ 0, 1, 1, 0 ],
                          [ 0, 1, 0, 1 ],
                          [ 0, 0, 1, 1 ] ]
     for p in all_permutations:
         unique_permutations = list( permutations.unique_permutations( p ) )
         self.assertEqual( len( all_permutations ), len( unique_permutations ) )
         # check that every list in all_permutations has been generated
         for p2 in all_permutations:
             self.assertEqual( p2 in unique_permutations, True )
Example #5
0
    def unique_configurations(self, site_distribution, verbose=False):
        """
        Find the symmetry inequivalent configurations for a given population of objects.

        Args:
            site_distribution (dict): A dictionary that defines the number of each object 
                                      to be arranged in this system.

                                      e.g. for a system with four sites, with two occupied (denoted `1`)
                                      and two unoccupied (denoted `0`)::

                                          { 1 : 2, 2 : 1 }
            verbose (opt:default=False): Print verbose output.

        Returns:
            unique_configurations (list): A list of :any:`Configuration` objects, for each symmetry 
                                          inequivalent configuration. 
        """
        if verbose:
            print('total number of sites: ' +
                  str(sum(site_distribution.values())))
            print('using {:d} symmetry operations: '.format(
                len(self.symmetry_group.symmetry_operations)))
        permutations = []
        working = True
        seen = set()
        unique_configurations = []
        s = flatten_list([[key] * site_distribution[key]
                          for key in site_distribution])
        for new_permutation in unique_permutations(s):
            if permutation_as_config_number(new_permutation) not in seen:
                config = Configuration.from_tuple(new_permutation)
                numeric_equivalents = set(
                    config.numeric_equivalents(
                        self.symmetry_group.symmetry_operations))
                config.count = len(numeric_equivalents)
                [seen.add(i) for i in numeric_equivalents]
                unique_configurations.append(config)
                if verbose:
                    print("found {:d}, screened {:d}".format(
                        len(unique_configurations), len(seen)))
        if verbose:
            print('unique configurations: ' + str(len(unique_configurations)))
        return (unique_configurations)
Example #6
0
def colourings_generator( colours, dim ):
    for s in combinations_with_replacement( colours, dim ):
        for new_permutation in unique_permutations( s ):
            yield new_permutation