Port the magnetic exchange workflow from atomate1 (Heisenberg fit + Vampire Tc) - #1528
Draft
Luguza wants to merge 11 commits into
Draft
Port the magnetic exchange workflow from atomate1 (Heisenberg fit + Vampire Tc)#1528Luguza wants to merge 11 commits into
Luguza wants to merge 11 commits into
Conversation
added a ex_mat field to the ExchangeDocument
The pymatgen fork's HeisenbergModel replaced the ground-state unique_site_ids dict with per-ordering site_labels and dropped _get_j_exc, which crashed run_vampire (TypeError in _create_mat). _create_mat now groups sites into materials by (sublattice, spin sign) straight from site_labels[0], and _create_ucf reads the per-bond J_ij from the igraph edge weights. Also fixes the material-element lookup (it indexed the structure with a sublattice id instead of a site index) and drops the unused HeisenbergMapper construction path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…atgen and update ExchangeDocument to include vampire_settings; add tests for VampireCaller input-file writers.
…ler; update ExchangeDocument schema to include residuals and remove avg option.
Member
|
@Luguza thanks! That's great! I am on vacation at the moment and back at the beginning of September. In case I don't react then, could you please ping me again? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port of atomate1's
ExchangeWF. Closes #1404.However, this PR is part of a large refactor I did for the underlying HeisenbergMapper from pymatgen.
The following PRs are connected and potentially still ongoing:
ferri_by_motif_{wyckoff_symbol}_flipstrategy; fix dedup never-pruning bug pymatgen#4699HeisenbergMappervia a shared parent-cell sublattice definition pymatgen#4700Introduces
ExchangeMakerflow (atomate2/common/flows/exchange.py): port of atomate1'sExchangeWF. Given magnetic structures with different spin configurations andtheir energies it fits a classical Heisenberg Hamiltonian with pymatgen's
HeisenbergMapperand, optionally, runs Vampire Monte-Carlo for the critical temperature.atomate2/common/jobs/exchange.py):heisenberg_mappingandbuild_exchange_doc, replacing the atomate1HeisenbergModelMapping,HeisenbergModelToDbandVampireToDbfiretasks.ExchangeMaker.make_from_ordering_docconvenience constructor for chaining onto themagnetic-orderings workflow: it pulls structures, per-atom energies and the parent
structure out of a computed
MagneticOrderingsDocumentand re-attaches themagmomsiteproperty that
HeisenbergMapperrequires.make: structure/energy counts must match, every structure mustcarry a
magmomsite property, and orderings are sorted so the ground state is index 0.ExchangeDocumentschema (atomate2/common/schemas/exchange.py) with formula,parent structure, the
{cutoff, tol}Heisenberg settings, the Vampire settings actuallyused, the fit
residual(RMS, meV per magnetic ion - intensive in cell size and number oforderings, so comparable between materials),
ex_params,ex_mat, the serializedHeisenbergModel, andcritical_temp/ fullVampireOutputwhen Vampire was run.atomate2.vampiresubpackage vendoring pymatgen'sVampireCaller/VampireOutput, which were removed from pymatgen in 2026.3.23 (Major reorganization of pymatgen repo pymatgen#4595).Provenance and every local change are documented in the module docstring.
atomate2/vampire/jobs/run_vampire.pywraps it as a jobflow job.HeisenbergModelAPI: per-orderingsublattice_idsand theigraphinteraction graph replace the oldunique_site_idsdictand
_get_j_exclookup, and the ground-state cell is read frommagnetic_structures[0]rather than
structures[0], which now retains the non-magnetic ions. Theavgoption isgone along with the
<J>estimate (HeisenbergModel.javg) it read - the model now fitsshell-resolved
J_ijover every ordering andigraphcarries them per bond in VAMPIRE'snormalized-spin meV convention.
.ucfno longer contains non-magnetic ions, which previously entered the file asatoms and de-synchronised the interaction block's node indices.
unit-cell-category. Without that binding every material kept Vampire's default category0, all atoms collapsed into material 1, the magnetic sublattices vanished and the system
never ordered.
igraph, magnetic structure andsublattice_idsdisagree in length, instead of silently writing a broken.ucf.vampire-serialnow raises instead of being ignored.tests/vampire/test_vampire_caller.py): four tests over the.mat/.ucfwriters, guarding the
HeisenbergModelcontract the caller relies on (magnetic-only cell,in-range interaction indices,
.mat/.ucfmaterial agreement, rejection of a misalignedmodel). They monkeypatch the
vampire-serialsubprocess, so no external binary is needed.pyproject.toml: exclude the vendoredvampire_caller.pyfrom ruff so it stays afaithful copy of the upstream source, and declare the mutually incompatible
strict-forcefields-*extras as[tool.uv] conflictssouv synccan resolve thelockfile. The uv change is unrelated to the exchange workflow and can be split out if
preferred.
Additional dependencies introduced (if any)
vampire_caller.pyimportspandas(usedonly to parse Vampire's stdout), which already arrives transitively via
pymatgen; it isnot added to
dependencieshere. Say the word if it should be declared explicitly.vampire-serialbinary onPATH(https://vampire.york.ac.uk/download/). It is guarded bymonty.dev.requires, and the rest of the flow runs without it viarun_vampire=False.TODO
This is a work-in-progress; the main blocker is upstream.
reworked
HeisenbergMapper/HeisenbergModelAPI (magnetic_structures,per-ordering
sublattice_ids,igraph,residual). The pymatgen change has to land and bereleased first, and the
pymatgen>=pin here bumped accordingly, before this can merge.tests yet for
ExchangeMaker, the two jobs,make_from_ordering_doc, orExchangeDocument.from_model.VampireCallerwrites its input files into the current working directory - upstream'sScratchDirblock is still commented out, as it was in pymatgen.make_from_ordering_docneeds a resolvedMagneticOrderingsDocument(it inspects thestructures while building the flow), so it cannot yet be chained dynamically onto a running
magnetic-orderings flow via an output reference.
Checklist
for the flow, jobs and schema - two small vendored-adjacent modules are still missing
module-level docstrings.
upstream's annotations as-is).
mypyhas not been run yet.are not yet covered.
branch above).