Spin physics, without the slow Python loops or the segfaulting C++.
On December 24 we released Spintronics 0.2.0 — the second release of our pure Rust library for simulating spin dynamics, spin-current generation, and spin-charge conversion in magnetic and topological materials.
No Python loops. No C++ memory bugs. No Fortran.
No micromagnetics binary to install, no OOMMF or mumax build to babysit, no LAPACK linker errors.
Just clean, memory-safe, physically grounded simulations that compile to a single static binary (or WASM) and run everywhere.
The library is inspired by the pioneering work of Prof. Eiji Saitoh’s group (University of Tokyo / RIKEN CEMS), and 0.2.0 is where it grows from a solid first release into something you can actually wire into your own tools and notebooks.
Why 0.2.0 matters
Spintronics research has long meant a choice between two kinds of pain: slow Python/NumPy scripts that take seconds per LLG run, or fragile C++/Fortran micromagnetics codebases (OOMMF, mumax, custom lab code) that segfault, lose angular momentum to silent unit bugs, and resist reproducibility.
Spintronics 0.1.0 already gave you LLG solvers, spin pumping, ISHE/SSE, skyrmions and a physics-aligned module layout in safe Rust. 0.2.0 is about making that core usable from the outside and cheaper to run in a loop:
- Call it from Python — new PyO3 bindings expose the solver and materials to your existing NumPy workflow at native speed.
- Get your data out — serde (JSON) and HDF5 export mean large simulations land in formats your analysis pipeline already speaks.
- Run it in tight loops — a memory pool allocator delivers a 99% reduction in hot-path allocations, and 21 hot-path functions are now
#[inline]for an extra ~10–30% in tight loops. - Trust your units — a runtime unit-validation module with 14 validators catches unphysical magnetizations, damping constants, fields and spin Hall angles before they corrupt a run.
This is still an early, foundation-building release — but it is a solid one: 448 tests pass (431 library = 381 unit + 50 doc, plus 17 in the demo), with zero warnings.
Technical Deep Dive: the v0.2.0 module layout
The architecture maps directly onto the physics — 18 modules across 60+ source files:
-
Core physics
constants(20+ NIST-validated values: ℏ, γ, e, μ_B, k_B …),vector3(3D spin/magnetization math, now withzero(),unit_x/y/z(),magnitude_squared(),angle_between(),project()), and the newunitsmodule with 14 runtime validators. -
Materials (
material)
Ferromagnets (YIG, Permalloy, Fe, Co, Ni, CoFeB), spin interfaces (YIG/Pt, plus new Pt/Ta/W combinations), 2D magnets (CrI₃, Fe₃GeTe₂, MnBi₂Te₄), topological insulators (Bi₂Se₃, Bi₂Te₃) and Weyl semimetals — behind a cleanMagneticMaterial/SpinChargeConverter/TopologicalMaterialtrait hierarchy. -
Dynamics & transport (
dynamics,transport,effect)
LLG solvers (RK4, Heun, adaptive), spin pumping, diffusion, and spin-charge conversion: ISHE, SSE, SOT, Rashba-Edelstein, spin Nernst, topological Hall. -
Advanced phenomena & I/O (
magnon,thermo,texture,afm,mech,cavity,ai,memory,visualization,python)
Magnon propagation and spin chains, thermoelectric effects, skyrmions / domain walls / topological charge, THz antiferromagnetics, nanomechanical coupling, cavity magnonics, magnon reservoir computing — plus the newmemory(pool allocators,Rk4Workspace/HeunWorkspace),visualization(HDF5/JSON/CSV/VTK) andpythonmodules.
Under the hood, Spintronics 0.2.0 builds on the early SciRS2 core (release candidate, scirs2-core 0.1.0-rc.4) for RNG and parallelism, behind the optional scirs2 feature — kept optional precisely so WASM builds stay lean.
Getting Started
cargo add spintronics
A minimal YIG/Pt spin-pumping + ISHE simulation, reproducing the setup of Saitoh et al. (2006):
use spintronics::prelude::*;
fn main() {
// Materials: YIG film, YIG/Pt interface, Pt detector strip
let yig = Ferromagnet::yig();
let interface = SpinInterface::yig_pt();
let pt_strip = InverseSpinHall::platinum();
// Initial magnetization along x, external field along z (FMR condition)
let mut m = Vector3::new(1.0, 0.0, 0.0);
let h_eff = Vector3::new(0.0, 0.0, 1.0) * 0.1; // 0.1 T along z
let dt = 1.0e-13; // 0.1 ps
let steps = 10_000; // 1 ns total
for _ in 0..steps {
// Landau-Lifshitz-Gilbert dynamics
let dm_dt = calc_dm_dt(m, h_eff, GAMMA, yig.alpha);
m = (m + dm_dt * dt).normalize();
// Spin current pumped across the interface...
let js = spin_pumping_current(&interface, m, dm_dt);
// ...converted to an electric field in Pt via the inverse spin Hall effect
let _e_field = pt_strip.convert(interface.normal, js);
}
println!("final magnetization: {m}");
}
What’s New in 0.2.0
- Python bindings (PyO3):
PyVector3,PyFerromagnet,PySpinInterface,PyInverseSpinHall,PyLlgSimulator,PySpinPumpingSimulation, and the core physical constants — all callable from Python. - Serialization (serde): JSON serialize/deserialize for vectors, materials, interfaces, effects and full
SimulationData. - HDF5 export:
Hdf5Writer/Hdf5Readerfor scalars, arrays and vector fields, with hierarchical groups and time-series support (graceful fallback when the feature is off). - Memory pool allocator:
VectorPool,SpinArrayPool, thread-local pools, and preallocatedRk4Workspace/HeunWorkspacebuffers for allocation-free solver loops. - Interactive web demo: an HTMX + Axum + Askama subcrate with four live demos (LLG dynamics, spin-pumping calculator, materials explorer, skyrmion visualizer) — zero JavaScript frameworks.
- More materials & builders: 8 new FM/NM interface combinations (Pt/Ta/W) and fuller builder-pattern coverage across materials, effects and textures.
- Unit validation: a
unitsmodule with 14 validators for physical-quantity sanity checks. - Ergonomics:
DisplayandDefaultimpls across the public types, plusEq/Hashon the simple enums so they work inHashMap/HashSet. - Performance:
#[inline]on 21 hot-path functions (LLG, spin pumping, ISHE, SOT, SSE, SNE, Rashba, thermal magnon transport). - Fixes: renamed
SkymionLattice→SkyrmionLattice, cleared 13 rustdoc warnings, fixed HDF5 0.8.x string conversion, and corrected WASMgetrandomandscirs2feature gating.
Tips
- Keep the defaults for science, trim them for the web. Default features are
["fem", "scirs2", "serde"]; build with--no-default-features --features wasmfor browser demos so you skip thescirs2/FEM weight. - Turn on Python only when you need it:
cargo add spintronics --features python(PyO3 + NumPy). Mix and match with--features "python,hdf5,serde". - Reuse solver workspaces in loops. For repeated RK4 / Heun integration, allocate an
Rk4WorkspaceorHeunWorkspaceonce and reuse it — that, plus theVectorPool/SpinArrayPoolpools, is where the 99% hot-path allocation reduction comes from. - Validate before you trust. Run your inputs through the
unitsvalidators (magnetization, damping, field, spin Hall angle …) to catch unphysical parameters before a long run silently produces garbage. - Prefer
magnitude_squared()tomagnitude()in inner loops to skip thesqrt, and reach for the newVector3helpers (unit_x(),angle_between(),project()) instead of hand-rolling them. - FEM micromagnetics is feature-gated. It rides on the
femfeature (Delaunay meshing + CG/BiCGSTAB/SOR solvers viascirs2-spatial); leave it on for realistic geometries, switch it off for lean single-spin or analytic work.
This is the foundation
Spintronics is young — 0.1.0 debuted only weeks ago — and so is the wider COOLJAPAN ecosystem around it. For now it leans on just the early SciRS2 core (release candidate) for RNG and parallelism, and otherwise stands on its own: pure Rust, minimal dependencies, no native binaries. The goal of 0.2.0 is simply to make that core reachable — from Python, from the browser, and from your data pipeline — so the physics can grow on a solid base.
Repository: https://github.com/cool-japan/spintronics
Star the repo if you’re tired of slow Python scripts or fragile C++ code for spintronics research.
Pure Rust spin dynamics is here — early, but already fast, safe, and sovereign.
— KitaSan at COOLJAPAN OÜ December 24, 2025