For a century, magnetism came in two flavors — ferromagnetic or antiferromagnetic. Altermagnets are a third, and Spintronics 0.3.2 gives them a real band model, a spin valve, and a quantum spin-liquid solver to keep them company.
Today we released Spintronics 0.3.2 — the largest physics expansion since the 0.3.0 debut. It adds a momentum-resolved altermagnet band model and spin valve, d-orbital orbitronics, a resonating-valence-bond (RVB) quantum-spin-liquid solver with a chirality-to-transport pipeline, hopfion stability analysis, strain-driven LLG dynamics, a streaming simulation API with binary OVF I/O, and a much larger Python test surface — alongside two correctness fixes that change real numerical output for anyone using Hermitian eigenvectors or the Kane-Mele Z2 invariant.
No Python loops. No C++ memory bugs. No Fortran. No external binaries or unsafe code in hot paths. Just clean, memory-safe, physically accurate simulations that compile to a single static binary (or WASM) and run everywhere.
This is not a debut and not a rewrite. 0.3.1 sharpened the demagnetizing-field hot loop and closed a topological API gap; 0.3.2 opens four new physics domains on top of the same SimulationBuilder, LLG/LLB, and prelude surface that shipped in 0.3.0 — and fixes two subtle bugs in the topological-materials math that every consumer of eigenvectors or Z2 invariants inherits automatically.
Why Spintronics 0.3.2 is a game changer
OOMMF, mumax³, and hand-rolled Python/Mathematica scripts remain the default tools for this kind of condensed-matter physics, and each carries a different tax:
- OOMMF and mumax³ are mature, battle-tested micromagnetic solvers — but neither models altermagnets, d-orbital orbitronics, or frustrated-lattice quantum spin liquids at all. That physics gets bolted on as a one-off script per paper, never shared, never regression-tested against the next paper’s numbers.
- Binary OVF is the format OOMMF itself defined, and the one large mumax³ runs write by default — but plenty of downstream tooling only round-trips the text variant, so “binary OVF in, binary OVF out” is still a manual, error-prone conversion step.
- The textbook Pfaffian method for a Z2 topological invariant is notoriously gauge-sensitive: get the time-reversal operator or the TRIM points subtly wrong and the result still looks like a plausible number — there’s no way to tell it’s wrong from the output alone.
- A day-long relaxation or a wide parameter sweep in a typical research codebase usually means choosing between “collect the whole trajectory in RAM until it doesn’t fit” or hand-rolling a custom streaming writer per project.
Spintronics 0.3.2 addresses all four directly:
AltermagnetBandModelandAltermagnetSpinValvegive altermagnets a tested k·p band model (MnTe, CrSb, RuO2 presets) with closed-form Berry curvature and Fermi-sea Hall integrals — zero without spin-orbit coupling, nonzero and Néel-sign-reversing with it — plus a GMR-like spin valve driven purely by the relative crystal-axis angle between two zero-net-moment layers.- Binary OVF read/write (
Binary4_1_0/Binary4_2_0/Binary8_2_0) ships with control-value validation that catches byte-order mismatches or truncated files up front, instead of silently misreading them. - The Kane-Mele Z2 invariant now comes from a gauge-invariant Wilson-loop / hybrid-Wannier-charge-center calculation, validated against the textbook phase diagram and confirmed gauge-invariant under adversarial eigenbasis remixing — the old fixed-gauge Pfaffian path is kept only as a private cross-check.
Simulation::run_streaming()gives every solver a per-step callback path that never materializes the full trajectory, so a 500,000-step run costs the same handful of stack bytes as a 1,000-step one.
Technical Deep Dive
-
Altermagnetism and orbital physics (
altermagnet/,orbitronics/).AltermagnetBandModelis a two-sublattice k·p Bloch Hamiltonian parameterized by kinetic hopping, hybridization, Néel exchange splitting, an altermagnetict_amterm, and an optional spin-orbit couplinglambda_soc;crystal_hall_conductivity()andspin_hall_conductivity()integrate Berry curvature over the Fermi sea.AltermagnetSpinValvereuses that model to compute GMR-like magnetoresistance from the relative crystal-axis angle between two altermagnetic layers. Alongside it,orbitronics::crystal_fieldbuilds real-cubic-harmonic d-orbital angular-momentum operators and octahedral/tetrahedral/tetragonal crystal-field Hamiltonians, andorbitronics::d_orbital_moment’sCrystalFieldModelderives Hund’s-rule ground states and effective moments for 12 preset 3d ions spanning Ti³⁺ to Cu²⁺. -
Frustration and topology (
frustrated/rvb,frustrated/transport,topomagnon/). The newrvbmodule enumerates the dimer-covering (valence-bond) basis, computes Sutherland loop-counting overlaps, and solves a Löwdin-canonically-orthogonalized generalized eigenproblem for the variational RVB ground state, cross-checked against dense exact diagonalization and a matrix-free Lanczos solver in the S_z=0 sector for up to 16 sites (53 tests).frustrated::transportturns per-plaquette scalar spin chirality into an emergent magnetic field and a topological Hall response for triangular, kagome, and pyrochlore lattices. This is also where the release’s two topology fixes live:CMatrix::hermitian_eigendecompositionmoved from a Householder-tridiagonalization scheme with a subtle phase/sign bug to a cyclic Jacobi algorithm verified to machine precision up to n=16, andKaneMeleModel’s Z2 invariant and Rashba block were corrected for gauge invariance and time-reversal symmetry respectively. -
Textures and mechanics (
texture/,magnon/,mech/).hopfion_stability_modesdiagonalizes the Hessian of the total energy functional around a relaxed hopfion to extract collective-coordinate eigenmodes, withHopfion::with_profile_and_offset()providing a rigidly-translated ansatz to probe the translation zero-modes directly.magnon::SdwRelaxationDynamicsrelaxes a spin-density-wave order parameter towardSdwGapSolver’s self-consistent gap via time-dependent Ginzburg-Landau (Model A) dynamics.mech::strain_driven_dynamicscouples oscillating surface-acoustic-wave or AC-piezoelectric strain into a magnetoelastic effective field, driven through the existing Dormand-Prince adaptive integrator. -
Simulation infrastructure, materials, and I/O (
builder/,material/disorder.rs,io/ovf.rs,python/).Simulation::run_streaming()executes the identical integration loop asrun()— same solver dispatch, same finite-value checks, same renormalization — but reports state through a caller-supplied callback instead of collecting a trajectory.material::disorder::GradedInterfacemodelsLinear/Exponential/ErrorFunctiongrading laws for spatially-varying Ms/A/K across a compositionally graded interface. On the Python side,LlbMaterial,LlbSolver,OnsagerMatrix,SpinCaloritronicsMaterial, and the batch RK4 helpers are now fully typed in__init__.pyiand covered by a new 168-test pytest suite.
Getting Started
cargo add spintronics
spintronics defaults to ["fem", "scirs2", "serde"]. Here’s the new altermagnet band model on the MnTe preset — a real, zero-net-moment collinear altermagnet whose two spin sublattices still see different effective masses away from the nodal directions:
use spintronics::altermagnet::AltermagnetBandModel;
use spintronics::error::Result;
fn main() -> Result<()> {
let model = AltermagnetBandModel::mnte();
let k_mag = 0.4 / model.a_lattice;
// Spin-resolved bands at a point away from the nodal directions.
let (up, down) = model.spin_bands(k_mag, 0.0);
let splitting = model.spin_splitting_at(k_mag, 0.0);
println!("spin splitting at |k|a = 0.4: {splitting:+.4} eV");
println!(" up bands: [{:+.4}, {:+.4}]", up.lower, up.upper);
println!(" down bands: [{:+.4}, {:+.4}]", down.lower, down.upper);
// Compensated altermagnet: net spin polarization integrates to ~zero,
// and the crystal Hall response vanishes without spin-orbit coupling.
let k_max = 0.8 / model.a_lattice;
let polarization = model.net_spin_polarization(41, k_max)?;
let hall = model.crystal_hall_conductivity(41, k_max)?;
println!("net spin polarization: {polarization:+.3e} (compensated)");
println!("crystal Hall (no SOC): {hall:+.3e} (vanishes without SOC)");
Ok(())
}
For long runs, swap in the streaming API instead of run():
use spintronics::prelude::*;
let mut sim = SimulationBuilder::new()
.material(Ferromagnet::yig())
.external_field(Vector3::new(0.0, 0.0, 0.1))
.solver_rk4()
.initial_magnetization(Vector3::new(1.0, 0.0, 0.0))
.time_step(1.0e-13)
.num_steps(500_000)
.build()?;
sim.run_streaming(|step, m, energy| {
if step % 100_000 == 0 {
println!("step {step}: m = {m:?}, E = {energy:.6e} J/m^3");
}
Ok(())
})?;
What’s New in 0.3.2
- Altermagnet band model & spin valve (
altermagnet::):AltermagnetBandModel(MnTe/CrSb/RuO2 presets) with closed-form Berry curvature and crystal/spin Hall conductivity;AltermagnetSpinValvefor GMR-like magnetoresistance without ferromagnetism. - Orbitronics d-orbital moments (
orbitronics::crystal_field,orbitronics::d_orbital_moment): Hund’s-rule ground states, orbital quenching/unquenching, and 12 preset 3d transition-metal ions (Ti³⁺ through Cu²⁺, high- and low-spin). - RVB quantum spin liquid + transport (
frustrated::rvb,frustrated::transport): dimer-covering enumeration, a Löwdin-orthogonalized variational ground state, exact diagonalization plus matrix-free Lanczos to 16 sites (53 tests), and a chirality → emergent field → topological Hall pipeline for triangular/kagome/pyrochlore lattices. - Hopfion stability & translation modes (
texture::hopfion_stability_modes,Hopfion::with_profile_and_offset): collective-coordinate linear-stability analysis via Hessian diagonalization. - Spin-density-wave relaxation (
magnon::SdwRelaxationDynamics,ParametricAmplification::with_supercriticality): Model-A TDGL relaxation toward the self-consistent equilibrium gap. - Strain-driven dynamics (
mech::strain_driven_dynamics): SAW and AC-piezoelectric strain-driven LLG dynamics through the Dormand-Prince adaptive solver. - Graded material interfaces (
material::disorder::GradedInterface):Linear/Exponential/ErrorFunctiongrading laws for spatially-varying Ms/A/K. - Streaming simulation + binary OVF (
Simulation::run_streaming,src/io/ovf.rs): per-step callback execution with no trajectory buffering, plusBinary4_1_0/Binary4_2_0/Binary8_2_0OVF I/O with control-value validation. - Python bindings expansion: complete
.pyitype stubs forLlbMaterial,LlbSolver,OnsagerMatrix,SpinCaloritronicsMaterial, and the batch RK4 helpers, backed by a new 168-test pytest suite. - Fixed: Hermitian eigenvectors.
CMatrix::hermitian_eigendecompositionproduced correct eigenvalues but subtly wrong eigenvectors for non-diagonal Hermitian matrices of size ≥ 3; now a cyclic Jacobi algorithm verified to machine precision up to n=16 — this transparently corrects topomagnon edge modes, Wilson-loop centers, magnonic crystals, cavity polaritons, and the new RVB/hopfion-stability code. - Fixed: Kane-Mele Z2 gauge invariance. Replaced the TRIM-point Pfaffian method (wrong TRIM points, non-antiunitary time-reversal operator, residual gauge dependence) with a gauge-invariant Wilson-loop/hybrid-Wannier-charge-center calculation; also fixed a Rashba-block time-reversal violation that made the Rashba coupling unphysically vanish at the Dirac point.
- Dependency updates:
scirs2-core/scirs2-spatial0.4.4 → 0.6.0,pyo3/numpy0.25 → 0.29 (migrated toBound<'py, T>),rayon→ 1.12,criterion→ 0.8,proptest→ 1.11,getrandom→ 0.4, plus a new[workspace.dependencies]table centralizing versions across the root crate,demo/, andpy/. - 2059 tests + 118 doc tests passing, 0 warnings.
Tips
- Start from a preset, not from scratch.
AltermagnetBandModel::mnte(),::crsb(), and::ruo2()are calibrated starting points for real materials — cheaper and less error-prone than hand-derivingt_kin/delta_hyb/exchange_m/t_amyourself. - Reach for
run_streaming()past a few thousand steps. It mirrorsrun()’s integration loop exactly — same solver, same finite-value checks, same renormalization — but never accumulates aVec<Vector3<f64>>. ReturningErrfrom the callback is also a clean way to implement “stop once converged” without knowing the step count in advance. - Binary OVF now round-trips cleanly with OOMMF/mumax³ output. Let
OvfFormat’s control-value validation surface a byte-order or truncation error rather than guessing at a file’s actual width or endianness. - Re-check any pre-0.3.2
KaneMeleModel::z2_invariantresults computed withlambda_r != 0. The old Pfaffian path was gauge-dependent; the new Wilson-loop calculation is the one validated against the textbook phase diagram. - Building small frustrated clusters for exact diagonalization? Use
RvbSolver::from_bonds()for genuinely open boundaries — the periodicFrustratedLatticeconstructors will distort dimer-covering counts on tiny clusters. - Python users get a real example set for free. The new 168-test suite under
py/tests/doubles as copy-paste-ready usage forLlbSolver,OnsagerMatrix, and the batch RK4 helpers now that they’re fully typed in__init__.pyi.
This is the foundation
Spintronics remains the spintronics and magnonics backend for the COOLJAPAN scientific stack, and 0.3.2 is squarely a physics-simulation release built on top of it:
- SciRS2 / NumRS2 — core spin dynamics and magnon calculations, now on the
scirs2-core/scirs2-spatial0.6.0 baseline - OxiMedia — visualization of magnetic textures, domain walls, and the new hopfion stability modes
- ToRSh — high-throughput spin-transport workloads
- Future integration with OxiLean for formally verified LLG solvers
0.3.2 doesn’t touch that foundation — it adds four new physics domains and two topological correctness fixes on top of it, while keeping the SimulationBuilder/prelude surface wire-compatible.
Repository: https://github.com/cool-japan/spintronics
Star the repo if you want condensed-matter physics — altermagnets, quantum spin liquids, topological invariants — that’s tested and gauge-invariant, without a single line of Python glue holding it together.
The era of a fresh one-off Python script for every new phase of matter is over. Pure Rust spintronics simulation is here — three physics domains richer, and two topological invariants more trustworthy.
— KitaSan at COOLJAPAN OÜ July 7, 2026