COOLJAPAN
← All posts

Spintronics 0.3.1 Released — Faster Demagnetizing Fields and Safer Topological APIs

A focused patch on top of the production-grade 0.3.0 release. The micromagnetic demag convolution gets flat kernel indexing plus optional rayon parallelism, BbhModel::hamiltonian_at now returns Result for proper error propagation, and scirs2-core/scirs2-spatial move to 0.5.0 with lean default features. 1829 tests passing, zero warnings.

release spintronics scirs2 physics-simulation spin-dynamics micromagnetics pure-rust demagnetizing-field topological-materials magnonics

The production spintronics backend of the COOLJAPAN scientific stack just got faster in the hot loop and safer at the API edge.

On June 10 we released Spintronics 0.3.1 — an incremental patch on top of the production-grade 0.3.0 release, sharpening the micromagnetic demagnetizing-field path, tightening a topological-Hamiltonian API, and refreshing the scirs2 dependency line.

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.0 already shipped the full physics stack — LLG/LLB solvers, skyrmions and hopfions, ISHE/SSE, magnon BEC, altermagnets, the SimulationBuilder fluent API, PyO3 bindings, and WASM — validated against landmark Saitoh Group experiments. 0.3.1 polishes the parts that mattered most for large-scale micromagnetic runs.

Why 0.3.1

The demagnetizing field is the single most expensive term in any finite-size micromagnetic simulation. Its O(N²) Newell-tensor convolution dominates wall-clock time on large cubes, and in 0.3.0 that inner loop dispatched through Option-returning tensor-component helpers (get_n_xx/yy/zz) on every cell pair. 0.3.1 removes that overhead and unlocks the multi-core path:

These build on the 0.3.0 baseline — 52–100× faster than Python+NumPy across LLG, skyrmion-number and spin-chain kernels, with a memory pool allocator delivering 99% allocation reduction in hot paths. 0.3.1 keeps every one of those results and makes the demag path cheaper still.

Technical note: the changed areas

The work in 0.3.1 is concentrated in three files, and the changes are surgical:

  1. src/micromagnetics/demag.rs — the inner convolution loop was rewritten around direct flat kernel-array indexing. The old get_n_xx/yy/zz helper dispatch is gone; the kernel is read by precomputed offset. Under parallel, the per-cell loop becomes a rayon::into_par_iter, so the demag field for all target cells is assembled concurrently. A new regression test pins the output bit-for-bit against the previous implementation.

  2. src/topomagnon/hoti.rsBbhModel::hamiltonian_at graduates from returning a bare CMatrix to Result<CMatrix>. Shape errors now flow through ? rather than panicking. Breaking change: callers that consumed the return value directly must now handle the Result (propagate with ?, or .unwrap() at a call site you control).

  3. src/validation/standard_problems/sp3.rstest_large_cube_vortex_stable (µMAG Standard Problem 3) was reduced from 100 to 25 relaxation steps to stay inside the CI time budget on the O(N²) Newell-tensor demag path, with clarified comments. The physics being validated is unchanged; only the iteration count in the test fixture moved.

On the dependency side, scirs2-core and scirs2-spatial both move to 0.5.0, now pulled with default-features = false and an explicit feature list (["std", "array", "random", "parallel"] for the core), so the build no longer drags in unused optional sub-crates. The workspace also unifies version tracking: the top-level and demo/ manifests now use version.workspace = true.

Getting Started

cargo add spintronics

spintronics defaults to ["fem", "scirs2", "serde"], so the FEM helpers, the scirs2-core scientific backend, and serde I/O are on out of the box. A minimal YIG/Pt spin-pumping run through the 0.3.0 SimulationBuilder fluent API:

use spintronics::prelude::*;

fn main() -> Result<()> {
    // YIG film magnetization, with an external field along z.
    let m0 = Vector3::new(1.0, 0.0, 0.0);
    let h_ext = Vector3::new(0.0, 0.0, 1.0);

    // Build an LLG simulation with the adaptive Dormand–Prince 4(5) solver.
    let result = SimulationBuilder::new()
        .material(Ferromagnet::yig())
        .initial_magnetization(m0)
        .external_field(h_ext)
        .solver_dp45()
        .steps(1_000)
        .run()?;

    println!("final magnetization: {:?}", result.final_magnetization());
    Ok(())
}

To turn on the parallel demag path for large micromagnetic problems, add the parallel feature:

cargo add spintronics --features parallel

What’s New in 0.3.1

Tips

This is the foundation

Spintronics remains the spintronics and magnonics backend for the COOLJAPAN scientific stack:

0.3.1 keeps that surface stable while making the heaviest micromagnetic kernel cheaper and one more topological API panic-free.

Repository: https://github.com/cool-japan/spintronics

Star the repo if you want production-grade spintronics that gets faster and safer one patch at a time — without ever touching C++ or Fortran.

Pure Rust spintronics simulation is here — fast, safe, and sovereign.

KitaSan at COOLJAPAN OÜ June 10, 2026

↑ Back to all posts