# pymatgen.analysis.magnetism.heisenberg module

This module implements a simple algorithm for extracting nearest neighbor exchange parameters by mapping low energy magnetic orderings to a Heisenberg model.

class HeisenbergMapper(ordered_structures, energies, cutoff=0.0, tol=0.02)

  Bases: `object`

  Class to compute exchange parameters from low energy magnetic orderings.

  Exchange parameters are computed by mapping to a classical Heisenberg model. Strategy is the scheme for generating neighbors. Currently only MinimumDistanceNN is implemented. n+1 unique orderings are required to compute n exchange parameters.

  First run a MagneticOrderingsWF to obtain low energy collinear magnetic orderings and find the magnetic ground state. Then enumerate magnetic states with the ground state as the input structure, find the subset of supercells that map to the ground state, and do static calculations for these orderings.

  Parameters

    - ordered_structures (list) – Structure objects with magmoms.

    - energies (list) – Total energies of each relaxed magnetic structure.

    - cutoff (float) – Cutoff in Angstrom for nearest neighbor search. Defaults to 0 (only NN, no NNN, etc.)

    - tol (float) – Tolerance (in Angstrom) on nearest neighbor distances being equal.

    - strategy (object) – Class from pymatgen.analysis.local_env for constructing graphs.

    - sgraphs (list) – StructureGraph objects.

    - unique_site_ids (dict) – Maps each site to its unique numerical identifier.

    - wyckoff_ids (dict) – Maps unique numerical identifier to wyckoff position.

    - nn_interacations (dict) – {i: j} pairs of NN interactions between unique sites.

    - dists (dict) – NN, NNN, and NNNN interaction distances

    - ex_mat (DataFrame) – Invertible Heisenberg Hamiltonian for each graph.

    - ex_params (dict) – Exchange parameter values (meV/atom)

  estimate_exchange(fm_struct=None, afm_struct=None, fm_e=None, afm_e=None)

    Estimate <J> for a structure based on low energy FM and AFM orderings.

    Parameters

      - fm_struct (Structure) – fm structure with ‘magmom’ site property

      - afm_struct (Structure) – afm structure with ‘magmom’ site property

      - fm_e (float) – fm energy/atom

      - afm_e (float) – afm energy/atom

    Returns

      Average exchange parameter (meV/atom)

    Return type

      j_avg (float)

  get_exchange()

    Take Heisenberg Hamiltonian and corresponding energy for each row and solve for the exchange parameters.

    Returns

      Exchange parameter values (meV/atom).

    Return type

      ex_params (dict)

  get_heisenberg_model()

    Save results of mapping to a HeisenbergModel object.

    Returns

      MSONable object.

    Return type

      hmodel (HeisenbergModel)

  get_interaction_graph(filename=None)

    Get a StructureGraph with edges and weights that correspond to exchange interactions and J_ij values, respectively.

    Parameters

      filename (str) – if not None, save interaction graph to filename.

    Returns

      Exchange interaction graph.

    Return type

      igraph (StructureGraph)

  get_low_energy_orderings()

    Find lowest energy FM and AFM orderings to compute E_AFM - E_FM.

    Returns

      fm structure with ‘magmom’ site property afm_struct (Structure): afm structure with ‘magmom’ site property fm_e (float): fm energy afm_e (float): afm energy

    Return type

      fm_struct (Structure)

  get_mft_temperature(j_avg)

    Crude mean field estimate of critical temperature based on <J> for one sublattice, or solving the coupled equations for a multisublattice material.

    Parameters

      j_avg (float) – j_avg (float): Average exchange parameter (meV/atom)

    Returns

      Critical temperature (K)

    Return type

      mft_t (float)

class HeisenbergModel(formula=None, structures=None, energies=None, cutoff=None, tol=None, sgraphs=None, unique_site_ids=None, wyckoff_ids=None, nn_interactions=None, dists=None, ex_mat=None, ex_params=None, javg=None, igraph=None)

  Bases: `monty.json.MSONable`

  Store a Heisenberg model fit to low-energy magnetic orderings. Intended to be generated by HeisenbergMapper.get_heisenberg_model().

  Parameters

    - formula (str) – Reduced formula of compound.

    - structures (list) – Structure objects with magmoms.

    - energies (list) – Energies of each relaxed magnetic structure.

    - cutoff (float) – Cutoff in Angstrom for nearest neighbor search.

    - tol (float) – Tolerance (in Angstrom) on nearest neighbor distances being equal.

    - sgraphs (list) – StructureGraph objects.

    - unique_site_ids (dict) – Maps each site to its unique numerical identifier.

    - wyckoff_ids (dict) – Maps unique numerical identifier to wyckoff position.

    - nn_interacations (dict) – {i: j} pairs of NN interactions between unique sites.

    - dists (dict) – NN, NNN, and NNNN interaction distances

    - ex_mat (DataFrame) – Invertible Heisenberg Hamiltonian for each graph.

    - ex_params (dict) – Exchange parameter values (meV/atom).

    - javg (float) – <J> exchange param (meV/atom).

    - igraph (StructureGraph) – Exchange interaction graph.

  as_dict()

    Because some dicts have tuple keys, some sanitization is required for json compatibility.

  classmethod from_dict(d)

    Create a HeisenbergModel from a dict.

class HeisenbergScreener(structures, energies, screen=False)

  Bases: `object`

  Class to clean and screen magnetic orderings.

  This class pre-processes magnetic orderings and energies for HeisenbergMapper. It prioritizes low-energy orderings with large and localized magnetic moments.

  Parameters

    - structures (list) – Structure objects with magnetic moments.

    - energies (list) – Energies/atom of magnetic orderings.

    - screen (bool) – Try to screen out high energy and low-spin configurations.

  screened_structures

    Sorted structures.

    Type

      list

  screened_energies

    Sorted energies.

    Type

      list