# pymatgen.analysis.magnetism.analyzer module¶

class CollinearMagneticStructureAnalyzer(structure, overwrite_magmom_mode='none', round_magmoms=False, detect_valences=False, make_primitive=True, default_magmoms=None, threshold=0.1)[source]

Bases: object

A class which provides a few helpful methods to analyze collinear magnetic structures.

If magnetic moments are not defined, moments will be taken either from default_magmoms.yaml (similar to the default magmoms in MPRelaxSet, with a few extra definitions) or from a specie:magmom dict provided by the default_magmoms kwarg.

Input magmoms can be replaced using the ‘overwrite_magmom_mode’ kwarg. This can be: * “none” to do nothing, * “respect_sign” which will overwrite existing magmoms with

those from default_magmoms but will keep sites with positive magmoms positive, negative magmoms negative and zero magmoms zero,
• “respect_zeros”, which will give a ferromagnetic structure (all positive magmoms from default_magmoms) but still keep sites with zero magmoms as zero,
• “replace_all” which will try to guess initial magmoms for all sites in the structure irrespective of input structure (this is most suitable for an initial DFT calculation),
• “replace_all_if_undefined” is the same as “replace_all” but only if no magmoms are defined in input structure, otherwise it will respect existing magmoms.
• “normalize” will normalize magmoms to unity, but will respect sign (used for comparing orderings), magmoms < theshold will be set to zero
Parameters: structure – Structure object (str) (overwrite_magmom_mode) – default “none” (int or bool) (round_magmoms) – will round input magmoms to

specified number of decimal places if integer is supplied, if set to a float will try and group magmoms together using a kernel density estimator of provided width, and extracting peaks of the estimator :param detect_valences (bool): if True, will attempt to assign valences to input structure :param make_primitive (bool): if True, will transform to primitive magnetic cell :param default_magmoms (dict): (optional) dict specifying default magmoms :param threshold (float): number (in Bohr magnetons) below which magmoms will be rounded to zero, default of 0.1 can probably be increased for many magnetic systems, depending on your application

get_exchange_group_info(symprec=0.01, angle_tolerance=5.0)[source]

Returns the information on the symmetry of the Hamiltonian describing the exchange energy of the system, taking into account relative direction of magnetic moments but not their absolute direction.

This is not strictly accurate (e.g. some/many atoms will have zero magnetic moments), but defining symmetry this way is a useful way of keeping track of distinct magnetic orderings within pymatgen.

Parameters: symprec – same as SpacegroupAnalyzer angle_tolerance – same as SpacegroupAnalyzer spacegroup_symbol, international_number
get_ferromagnetic_structure(make_primitive=True)[source]

Returns a Structure with all magnetic moments positive or zero. :param make_primitive (bool): Return a primitive structure, defaults to True. :return: Structure

get_nonmagnetic_structure(make_primitive=True)[source]

Returns a Structure without magnetic moments defined. :param make_primitive (bool): Return a primitive structure, defaults to True. :return: Structure

get_structure_with_only_magnetic_atoms(make_primitive=True)[source]

Returns a Structure with only magnetic atoms present. :return: Structure

get_structure_with_spin()[source]

Returns a Structure with species decorated with spin values instead of using magmom site properties. :return: Structure

is_magnetic

Convenience property, returns True if any non-zero magmoms present. :return:

magmoms

Convenience property, returns magmoms as a numpy array. :return: np.array

magnetic_species_and_magmoms

Returns a dict of magnetic species and the magnitude of their associated magmoms. Will return a set if there are multiple magmoms per species.

Returns: dict of magnetic species and magmoms
matches_ordering(other)[source]

Compares the magnetic orderings of one structure with another. :param other: Structure :return (bool):

number_of_magnetic_sites

return (int) – Number of magnetic sites present in structure.

number_of_unique_magnetic_sites(symprec=0.001, angle_tolerance=5)[source]
Parameters: (float) (angle_tolerance) – same as in SpacegroupAnalyzer (float) – same as in SpacegroupAnalyzer Number of symmetrically-distinct magnetic sites present

in structure.

ordering

Applies heuristics to return a magnetic ordering for a collinear magnetic structure. Result is not guaranteed for correctness. :return: Ordering Enum (‘FiM’ is used as the abbreviation for ferrimagnetic)

propagation_vector
types_of_magnetic_specie

Equivalent to Structure.types_of_specie but only returns magnetic species. :return: types of Specie

class Ordering[source]

Bases: enum.Enum

An enumeration.

AFM = 'AFM'
FM = 'FM'
FiM = 'FiM'
NM = 'NM'
Unknown = 'Unknown'
magnetic_deformation(structure_A, structure_B)[source]

Calculates ‘magnetic deformation proxy’, a measure of deformation (norm of finite strain) between ‘non-magnetic’ (non-spin-polarized) and ferromagnetic structures.

Adapted from Bocarsly et al. 2017, doi: 10.1021/acs.chemmater.6b04729

Parameters: structure_A – structure_B –