MCIF¶
Write a pymatgen magnetic structure as a symmetrized magnetic CIF in the BNS/MAGNDATA convention.
mcif
¶
Write magnetic structures as mcif files (BNS/MAGNDATA convention).
For single-species sites, pymatgen.core.Structure.from_file handles mcif,
and its symmetry expansion of _atom_site_moment.crystalaxis_*
components is correct as of pymatgen-core v2026.7.16
(materialsproject/pymatgen-core#76): moments are converted to Cartesian before
applying an operation, so |m| is preserved even when an operation mixes
unequal or non-orthogonal axes (e.g. hexagonal settings; see
materialsproject/pymatgen-core#76 for the old failure mode).
Mixed-species files use constituent atom rows, which pymatgen's magnetic
structure reader does not currently support.
:class:MCifWriter has no upstream equivalent (CifWriter(write_magmoms=True)
dumps every atom in P1 with no magnetic operations).
MCifWriter
¶
A pymatgen-style writer for symmetrized magnetic CIF (BNS/MAGNDATA).
Mirrors :class:pymatgen.io.cif.CifWriter: str(writer) returns the mcif
text and writer.write_file(path) writes it. Unlike
CifWriter(write_magmoms=True) -- which dumps every atom in P1 with no
magnetic operations -- this finds the magnetic space group of struct with
moyopy and writes the asymmetric unit plus the
_space_group_symop_magn_operation.xyz /
_space_group_symop_magn_centering.xyz loops.
The structure is symmetrized in its own input setting (the basis is not
standardized). struct must carry a magmom site property (pymatgen
Magmom or a Cartesian 3-vector per site). Moment components are written as
_atom_site_moment.crystalaxis_* in the unit-axis convention read back by
CifParser (m = mx*a_hat + my*b_hat + mz*c_hat).
Each constituent is written as an atom row with its occupancy and full species
identity, including oxidation state. Compositions and magnetic flags enter
the moyopy equivalence labels, so symmetry cannot exchange chemically distinct
sites. Selected constituents share the site's occupied-atom moment; unselected
constituents have zero moment. Occupancy never scales the written moment.
The optional boolean magnetic site property defaults to true. A false
flag requires a zero moment; a true flag retains a moment row even for zero.
A mixed site applies its moment and flag to all its species. Use coincident
constituent rows for partial magnetic selection. Their selected moments must
agree within mag_symprec (which defaults to symprec as in moyopy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
struct
|
Structure
|
Magnetic structure with a |
required |
symprec
|
float
|
moyopy symmetry-search tolerances (basis units / moment units).
|
0.0001
|
mag_symprec
|
float
|
moyopy symmetry-search tolerances (basis units / moment units).
|
0.0001
|