[breaking] Support mixed-supercell orderings in HeisenbergMapper via a shared parent-cell sublattice definition - #4700
Conversation
…improve ex_mat serialization according to PR materialsproject#4664
…parent once and with the nonmagnetic ions present. Orderings are mapped onto parent to determine what magnetic sublattice each site belongs to.
…itioned fit warning, correct units in docstrings
…arentOrdering classes
…ultiplying with the absolute magmoms at both ends of the edge
…bug and fix deprecation warnings. Remove TestHeisenbergMapper and move relevant tests from it to TestHeisenbergMapperHamiltonian
…t being labeled at all
shyuep
left a comment
There was a problem hiding this comment.
Automated PR review generated by Claude (on behalf of @shyuep)
Substantial, well-motivated refactor (parent-cell sublattice definition + StructureMatcher mapping + least-squares fit) with unusually thorough docstrings and new test coverage. Main comments:
- Attribution: don't comment out the original
__author__block (ncfrey). Either keep both authors or drop the dunder metadata entirely — git history carries attribution. raise SystemExit(...)was carried over from the old code — please useValueErrorinstead;SystemExitkills interactive sessions and notebooks.- This is a significant API break for
HeisenbergMapper(attributes likesgraphs,unique_site_ids,wyckoff_idsare gone;estimate_exchange/get_mft_temperaturedeprecated). A short migration note in the PR description / docs would help downstream users. - CI has not run on this branch (first-time contributor — needs a maintainer to approve workflows). Please rebase on master and a maintainer should trigger CI before merge.
- Default-parent inference from the lowest-energy ordering is a documented footgun; consider emitting a
UserWarningwhenparent=Noneso users can't miss it.
Nice work overall — the shell-midpoint interaction labeling and pooled magnetic species are clear improvements.
|
@shyuep @mkhorton As per the discussion in materialsproject/atomate2#1528, should I restore the vampire caller into pymatgen, because it is written to be specific to this workflow and relevant to local execution? |
…per-mixed-supercells-4667
|
Automated PR review generated by Claude (scheduled routine, posted on behalf of @shyuep) Substantial and well-motivated refactor — defining sublattices once on a parent cell and mapping orderings via
|
HeisenbergMapper via a shared parent-cell sublattice definitionHeisenbergMapper via a shared parent-cell sublattice definition
HeisenbergMapper via a shared parent-cell sublattice definitionHeisenbergMapper via a shared parent-cell sublattice definition
|
Agreed on the title, I'll mark it [breaking] so it shows up in the compatibility log. On the deprecation shims, I'd rather not add them here, and it's not only about cost. Taking them one at a time:
get_exchange is breaking regardless of the return type. The There's also one break no shim can cover: Given that, I think the honest version is a hard break with a good migration path rather than a half-compatible surface. The module docstring already carries a migration guide covering every renamed and removed attribute, the constructor order, the |
Summary
Refactors
HeisenbergMapperso magnetic sublattices are defined once on a common parent cell, and every DFT-relaxed ordering is mapped onto it by structure matching rather than by direct index comparison. This decouples exchange-parameter fitting from any single ordering's cell size/shape, so orderings that were relaxed in different-sized supercells of the same parent can now be combined in one fit.Closes #4667.
Motivation
The old implementation identified "unique sites" from the geometry of
ordered_structures[0]and assumed every other ordering shared that exact indexing/cell. Orderings enumerated by aMagneticOrderingsWF-style workflow frequently don't: different orderings can relax into different (but commensurate) supercells of the same parent, and the mapper had no way to reconcile them. This branch introduces an explicit parent cell as the single source of truth for sublattice identity, with each ordering's sites matched onto it viaStructureMatcher(attempt_supercell=True).Key changes
Testing
All tests pass locally, including new coverage added on this branch:
TestHeisenbergMapperKnownHamiltonian- exchange recovery, RMS residual, degenerate-ordering dropping, Wyckoff-orbit sublattices, ill-conditioned-fit warning, shell counting per sublattice pair, interaction-graph consistency, incompatible (non-supercell) ordering rejectionTestHeisenbergMeanFieldTemperature- single/multi-sublattice MFT, exchange sign vs. ground stateTestHeisenbergMapperFullCellSymmetry- nonmagnetic ions splitting sublattices, symmetry-equivalent sites sharing oneTestHeisenbergMapperZeroMomentIon- quenched-moment species staying on the magnetic lattice