Repository navigation
Conversation
shyuep
left a comment
There was a problem hiding this comment.
Automated PR review generated by Claude (on behalf of @shyuep)
Two distinct changes here:
- Dedup fix (
== 0→> 0): correct — the old inverted conditional made duplicate pruning a no-op. This is a real bug fix worth fast-tracking; consider splitting it into its own PR so it isn't held up by the feature. ferri_by_motif_{symbol}_flip: the global order parameternum_motif_sites / num_mag_sitesreads correctly (whole-motif flip is reachable via the global up-fraction, and the spin-inversion degeneracy makes the sign choice irrelevant). Note when a motif is exactly half the magnetic sites, this duplicates the AFM constraint (op = 0.5) — harmless once dedup works, which reinforces point 1.
Blocking: no tests yet (acknowledged in your Todos) — both the dedup regression test and flip-strategy coverage (spinel Néel case) are needed before merge. CI has not run on this branch and will need approval.
|
Automated PR review generated by Claude (scheduled routine, posted on behalf of @shyuep) The Points to address: (1) the dedup one-liner here duplicates #4702, which is a fix-only PR with its own regression tests — suggest rebasing this PR to feature-only once that lands; (2) the |
|
@shyuep what should I do with the submodule bump, it was intended on my side? |
shyuep
left a comment
There was a problem hiding this comment.
Automated PR review generated by Claude (posted on behalf of @shyuep; scheduled review routine).
Clean, focused addition. The whole-motif flip is a real gap in the current ferrimagnetic_by_motif strategies (spinel Néel orderings being the obvious case), and expressing it as a single global order parameter to avoid the _remove_dummy_species issue is a sensible workaround. The num_motif_sites * 2 == num_mag_sites guard against duplicating the global AFM constraint is correct, and the Ca3Co2O6 test covers exactly that edge. Test coverage is thorough, including the complementary-flip pruning behavior.
Comments:
- PR description is stale. The inverted-conditional dedup fix in
_generate_ordered_structuresis no longer in this diff — it landed via #4702, which merged yesterday. Please update the description/Todos and rebase; the stated merge blocker ("Ready for merge once #4702 lands") is now satisfied. - The
pymatgen-coresubmodule pointer bump (1e86cf8 → 3affe46) appears incidental to this change — confirm it's intentional or drop it from the PR. - CI has not run on the latest commits ("no checks reported"). Needs a workflow approval/trigger before merge evaluation.
Once rebased with CI green, this looks mergeable.
|
Automated PR review (generated by Claude on behalf of @shyuep). The Points to address:
|
e8c9993 to
d6cdf07
Compare
The ferri_by_motif_{symbol}_flip skip for a motif that is exactly half
the magnetic sites assumed the global "afm" constraint (order
parameter 0.5) was always present to make it a duplicate. If a caller
requests only "ferrimagnetic_by_motif" without "antiferromagnetic",
that constraint is never added, silently making the ordering
unreachable. Only skip when "antiferromagnetic" is in self.strategies.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
d6cdf07 to
159dffb
Compare
|
@shyuep Addressed the outstanding review points:
Could you approve the CI workflows on the latest commits? |
|
Automated PR review generated by Claude (posted on behalf of @shyuep by a scheduled routine; static analysis of the diff and GitHub state only, no code executed). Re-review after the 2026-09-03 rebase. All four previous points are addressed: the branch is clean on Remaining items:
None of 1–4 are blockers for correctness of the enumeration; 3 is the one I would fix before merge. |
ferri_by_motif_{wyckoff_symbol}_flip strategy; fix dedup never-pruning bugferri_by_motif_{wyckoff_symbol}_flip strategy
ferri_by_motif_{symbol}_flip expressed the flip as a single global order
parameter, num_motif_sites / num_mag_sites. That constrains only how many
spins point up, not which sites carry them, so it enumerated every
arrangement with that count: on Fe3O4 six orderings, of which one is a
whole-motif flip and the rest break a motif internally. The Neel state was
reached only by being the most symmetric of the six, so truncate_by_symmetry
or max_orderings could drop it on another structure.
A whole-motif flip needs no enumeration at all. With every motif internally
FM the magnetic cell is the crystallographic primitive cell, so the choice of
which motifs to flip fixes the ordering outright. _add_whole_motif_flips
builds them directly and appends to ordered_structures, as the fm ordering
already does.
One or more motifs may be flipped: every non-empty subset, 2**(n-1) - 1
orderings. The first motif is held pointing up, so a flip and its global spin
inversion are never both emitted instead of the pair being left to the
duplicate pruning downstream.
Drops the order parameter == 0.5 guard, which skipped a motif spanning half
the magnetic sites because the order parameter duplicated the global afm
constraint. A directly built flip costs no enumeration and is always emitted.
wyckoff_symbols is sorted by descending multiplicity so the origin labels are
reproducible; iterating a set varied with PYTHONHASHSEED.
ferri_by_motif_{wyckoff_symbol}_flip strategyMagneticStructureEnumerator
|
Thanks — points 1–4 are all addressed, but working through (1) turned up The constraint did not do what its name claimed. You flagged that The Neel state survives here only because it is the most symmetric of the six, so Whole-motif flips need no enumeration. With every motif internally FM the The strategy now covers one or more motifs flipped together, i.e. every non-empty Two of your points dissolve rather than being fixed:
(3) is fixed as before: One correction to #4698. The issue says the per-motif form (1 on the motif, 0 on (5) Title updated. (6) Could you approve the CI workflows? Locally the magnetism suite passes, |
|
Automated PR review generated by Claude (posted on behalf of @shyuep by a scheduled routine; static analysis of the diff and GitHub state only, no code executed). Re-review of Five things on the new code:
Minor: Blocking, unchanged from last time: CI has still never run on this branch ( |
_generate_transformations appends orderings that need no enumeration (fm and the whole-motif flips) directly to self.ordered_structures; say so in its docstring rather than leaving it implied by the return type. State in _add_whole_motif_flips that n motifs give 2**(n-1) - 1 orderings, bounded at 127 by max_unique_sites, and that all of them keep the full crystal symmetry and so survive truncate_by_symmetry.
Good contribution. The gap is real — Design concern: side effects inside
The existing test Combinatorial cost
Smaller points
CI hasn't reported (0 checks) — please push or rebase so the suite runs before merge. |
|
Thanks! I have personally reviewed the addition and it is great! |
Summary
MagneticStructureEnumeratorwith theferrimagnetic_by_motifstrategy could not produce orderings where one or more whole Wyckoff motifs are flipped antiparallel to the rest, with every motif staying internally ferromagnetic. The Néel ground state of a spinel ferrimagnet like Fe3O4 (4f up, 2c down) is one of these. The existingferri_by_motif_{symbol}constraints make one motif internally AFM, andafmforces equal up/down counts, so neither one reaches these orderings.This PR adds them as
ferri_by_motif_{symbols}_fliporderings, e.g.ferri_by_motif_2c_fliporferri_by_motif_b_c_flip.Implementation
_add_whole_motif_flipsbuilds these structures and appends them toordered_structures, the same way thefmordering is already handled. It does not call enumlib.num_motif_sites / num_mag_sites). That fixes only how many spins point up, not which sites carry them. On Fe3O4 it produced six orderings, and only one of them was the whole-motif flip. The Néel state survived only because it was the most symmetric, sotruncate_by_symmetry/max_orderingscould drop it on other structures. The direct construction replaces that approach, together with itsorder parameter == 0.5guard, which also made the half-multiplicity flip unreachable whenantiferromagneticwas not requested.2**(n-1) - 1orderings. Withmax_unique_sites=8that is at most 127. All of them keep the full crystal symmetry, sotruncate_by_symmetrydoes not remove them.wyckoff_symbolsis now sorted by descending multiplicity, then by symbol, instead of iterating aset. Before this change, which of two equivalent orderings survived duplicate pruning (and so which origin label was recorded) could change withPYTHONHASHSEED.Tests
ferri_by_motif_2c_flip.ferri_by_motif_4f/ferri_by_motif_2ctransformations are unchanged.2**(n-1) - 1orderings, and none is the spin inversion of another.ferrimagnetic_by_motifis requested, withoutantiferromagnetic.matches_ordering.The
TestMagneticStructureEnumeratorMotifFliptests skip__init__and do not need enumlib.