def __init__(self, structure, default_magmoms=None,
                 strategies=("ferromagnetic", "antiferromagnetic"),
                 automatic=True,
                 truncate_by_symmetry=True,
                 transformation_kwargs=None):
        """
        This class will try generated different collinear
        magnetic orderings for a given input structure.

        If the input structure has magnetic moments defined, it
        is possible to use these as a hint as to which elements are
        magnetic, otherwise magnetic elements will be guessed
        (this can be changed using default_magmoms kwarg).

        Args:
            structure: input structure
            default_magmoms: (optional, defaults provided) dict of
        magnetic elements to their initial magnetic moments in µB, generally
        these are chosen to be high-spin since they can relax to a low-spin
        configuration during a DFT electronic configuration
            strategies: different ordering strategies to use, choose from:
        ferromagnetic, antiferromagnetic, antiferromagnetic_by_motif,
        ferrimagnetic_by_motif and ferrimagnetic_by_species (here, "motif",
        means to use a different ordering parameter for symmetry inequivalent
        sites)
            automatic: if True, will automatically choose sensible strategies
            truncate_by_symmetry: if True, will remove very unsymmetrical
        orderings that are likely physically implausible
            transformation_kwargs: keyword arguments to pass to
        MagOrderingTransformation, to change automatic cell size limits, etc.
        """

        self.logger = logging.getLogger(self.__class__.__name__)

        self.structure = structure

        # decides how to process input structure, which sites are magnetic
        self.default_magmoms = default_magmoms

        # different strategies to attempt, default is usually reasonable
        self.strategies = strategies
        # and whether to automatically add strategies that may be appropriate
        self.automatic = automatic

        # and whether to discard low symmetry structures
        self.truncate_by_symmetry = truncate_by_symmetry

        # other settings
        self.num_orderings = 64
        self.max_unique_sites = 8

        # kwargs to pass to transformation (ultimately to enumlib)
        default_transformation_kwargs = {"check_ordered_symmetry": False, "timeout": 5}
        transformation_kwargs = transformation_kwargs or {}
        transformation_kwargs.update(default_transformation_kwargs)
        self.transformation_kwargs = transformation_kwargs

        # our magnetically ordered structures will be
        # stored here once generated and also store which
        # transformation created them, this is used for
        # book-keeping/user interest, and
        # is be a list of strings in ("fm", "afm",
        # "ferrimagnetic_by_species", "ferrimagnetic_by_motif",
        # "afm_by_motif", "input_structure")
        self.ordered_structures, self.ordered_structure_origins = [], []

        formula = structure.composition.reduced_formula

        # to process disordered magnetic structures, first make an
        # ordered approximation
        if not structure.is_ordered:
            raise ValueError(
                "Please obtain an ordered approximation of the "
                "input structure ({}).".format(formula)
            )

        # CollinearMagneticStructureAnalyzer is used throughout:
        # it can tell us whether the input is itself collinear (if not,
        # this workflow is not appropriate), and has many convenience
        # methods e.g. magnetic structure matching, etc.
        self.input_analyzer = CollinearMagneticStructureAnalyzer(
            structure, default_magmoms=default_magmoms, overwrite_magmom_mode="none"
        )

        # this workflow enumerates structures with different combinations
        # of up and down spin and does not include spin-orbit coupling:
        # if your input structure has vector magnetic moments, this
        # workflow is not appropriate
        if not self.input_analyzer.is_collinear:
            raise ValueError("Input structure ({}) is non-collinear.".format(formula))

        self.sanitized_structure = self._sanitize_input_structure(structure)

        # we will first create a set of transformations
        # and then apply them to our input structure
        self.transformations = self._generate_transformations(self.sanitized_structure)
        self._generate_ordered_structures(
            self.sanitized_structure, self.transformations
        )
def __init__ ( self , structure , default_magmoms = None , strategies = ( "ferromagnetic" , "antiferromagnetic" ) , automatic = True , truncate_by_symmetry = True , transformation_kwargs = None ) : self . logger = logging . getLogger ( self . __class__ . __name__ ) self . structure = structure self . default_magmoms = default_magmoms self . strategies = strategies self . automatic = automatic self . truncate_by_symmetry = truncate_by_symmetry self . num_orderings = 64 self . max_unique_sites = 8 default_transformation_kwargs = { "check_ordered_symmetry" : False , "timeout" : 5 } transformation_kwargs = transformation_kwargs or { } transformation_kwargs . update ( default_transformation_kwargs ) self . transformation_kwargs = transformation_kwargs self . ordered_structures , self . ordered_structure_origins = [ ] , [ ] formula = structure . composition . reduced_formula if not structure . is_ordered : raise ValueError ( "Please obtain an ordered approximation of the " "input structure ({})." . format ( formula ) ) self . input_analyzer = CollinearMagneticStructureAnalyzer ( structure , default_magmoms = default_magmoms , overwrite_magmom_mode = "none" ) if not self . input_analyzer . is_collinear : raise ValueError ( "Input structure ({}) is non-collinear." . format ( formula ) ) self . sanitized_structure = self . _sanitize_input_structure ( structure ) self . transformations = self . _generate_transformations ( self . sanitized_structure ) self . _generate_ordered_structures ( self . sanitized_structure , self . transformations )
This class will try generated different collinear
        magnetic orderings for a given input structure.

        If the input structure has magnetic moments defined, it
        is possible to use these as a hint as to which elements are
        magnetic, otherwise magnetic elements will be guessed
        (this can be changed using default_magmoms kwarg).

        Args:
            structure: input structure
            default_magmoms: (optional, defaults provided) dict of
        magnetic elements to their initial magnetic moments in µB, generally
        these are chosen to be high-spin since they can relax to a low-spin
        configuration during a DFT electronic configuration
            strategies: different ordering strategies to use, choose from:
        ferromagnetic, antiferromagnetic, antiferromagnetic_by_motif,
        ferrimagnetic_by_motif and ferrimagnetic_by_species (here, "motif",
        means to use a different ordering parameter for symmetry inequivalent
        sites)
            automatic: if True, will automatically choose sensible strategies
            truncate_by_symmetry: if True, will remove very unsymmetrical
        orderings that are likely physically implausible
            transformation_kwargs: keyword arguments to pass to
        MagOrderingTransformation, to change automatic cell size limits, etc.