spintronics 0.3.0

Pure Rust library for simulating spin dynamics, spin current generation, and conversion phenomena in magnetic and topological materials
Documentation
//! # spintronics
//!
//! **Version 0.3.0** - Advanced physics modules, higher-order integrators, SIMD optimization
//!
//! A pure Rust library for simulating spin dynamics, spin current generation,
//! and conversion phenomena in magnetic materials and topological materials.
//!
//! **Copyright (c) 2025 COOLJAPAN OÜ (Team KitaSan)**
//!
//! Licensed under MIT OR Apache-2.0
//!
//! ## Overview
//!
//! This library implements physical models established by Prof. Eiji Saitoh's
//! research group (Univ. Tokyo/RIKEN) and the broader spintronics community:
//!
//! ### Core Physics Effects
//! - **Spin Pumping**: Generation of spin current from magnetization precession
//! - **Inverse Spin Hall Effect (ISHE)**: Conversion of spin current to charge current
//! - **Spin Seebeck Effect (SSE)**: Thermal generation of spin current
//! - **Spin-Orbit Torque (SOT)**: Current-driven magnetization switching
//! - **Dzyaloshinskii-Moriya Interaction (DMI)**: Skyrmion stabilization
//! - **Topological Hall Effect**: Berry phase from skyrmion textures
//! - **Rashba Effect**: 2DEG spin splitting and spin-momentum locking
//! - **Edelstein Effect**: Spin-to-charge conversion in non-centrosymmetric systems
//! - **Spin Nernst Effect**: Thermal gradient → transverse spin current
//!
//! ### Key Features
//! - ✅ **718 tests passing** (718 library tests, v0.3.0)
//! - ✅ **Advanced integrators** - Dormand-Prince RK5(4)/RK8(7), symplectic methods (v0.3.0)
//! - ✅ **New physics modules** - Altermagnets, Orbitronics, Frustrated magnets, Hopfions, Magnon BEC, Magnetoelastics (v0.3.0)
//! - ✅ **25 examples** organized by difficulty (v0.3.0)
//! - ✅ **Interactive web demo** - Axum + HTMX subcrate with 4 physics simulations (v0.2.0)
//! - ✅ **5 experimental validations** against landmark papers
//! - ✅ **WebAssembly support** for browser-based simulations
//! - ✅ **FEM solver** with advanced iterative methods
//! - ✅ **Performance optimized** - 21 inline attributes on hot-path functions (v0.2.0)
//! - ✅ **Memory optimized** - Pool allocator reduces allocations by 99% (v0.2.0)
//! - ✅ **Python bindings** via PyO3 (v0.2.0)
//! - ✅ **Serde serialization** for data interchange (v0.2.0)
//! - ✅ **HDF5 export** for large datasets (v0.2.0)
//! - ✅ **Unit validation** - 14 validators for physical quantities (v0.2.0)
//! - ✅ **Zero warnings** - production-quality code
//!
//! ## Key References
//!
//! - E. Saitoh et al., "Conversion of spin current into charge current at room
//!   temperature: Inverse spin-Hall effect", *Appl. Phys. Lett.* **88**, 182509 (2006)
//! - K. Uchida et al., "Observation of the spin Seebeck effect",
//!   *Nature* **455**, 778-781 (2008)
//! - I. M. Miron et al., "Perpendicular switching of a single ferromagnetic layer
//!   induced by in-plane current injection", *Nature* **476**, 189 (2011)
//! - S. Woo et al., "Observation of room-temperature magnetic skyrmions",
//!   *Nat. Mater.* **15**, 501 (2016)
//!
//! ## Architecture
//!
//! The library is organized into ~28 physics-focused modules:
//!
//! ### Core Infrastructure
//! - [`constants`]: Physical constants (ℏ, γ, e, μ_B, k_B, 20+ NIST-validated values)
//! - [`vector3`]: Optimized 3D vector operations for spin/magnetization
//! - [`units`]: Unit validation - 14 validators for physical quantities (v0.2.0)
//! - [`error`]: Error handling and result types
//!
//! ### Materials & Properties
//! - [`material`]: Material properties (ferromagnets, interfaces, 2D magnets, topological insulators, Weyl semimetals)
//!
//! ### Dynamics & Transport
//! - [`dynamics`]: Time evolution solvers (LLG equation, RK4, Heun, adaptive methods)
//! - [`transport`]: Spin transport phenomena (spin pumping, diffusion)
//!
//! ### Physical Effects
//! - [`effect`]: Spin-charge conversion (ISHE, SSE, SOT, Rashba, Edelstein, Spin Nernst, Topological Hall)
//! - [`magnon`]: Magnon propagation and spin wave dynamics
//! - [`thermo`]: Thermoelectric effects (ANE, thermal magnon transport, multilayers)
//! - [`texture`]: Magnetic textures (skyrmions, domain walls, DMI, topological charge)
//! - [`spinwave`]: Spin wave theory (dispersion, modes, quantization)
//!
//! ### Specialized Physics
//! - [`afm`]: Antiferromagnetic dynamics for THz spintronics
//! - [`stochastic`]: Thermal fluctuations and finite-temperature effects
//! - [`cavity`]: Cavity magnonics - Hybrid magnon-photon quantum systems
//! - [`altermagnet`]: Altermagnetic materials (RuO2, CrSb, MnTe; spin-splitter effect, v0.3.0)
//! - [`orbitronics`]: Orbital Hall effect, orbital torques (v0.3.0)
//! - [`frustrated`]: Frustrated magnets, spin ice, kagome (v0.3.0)
//!
//! ### Coupled Systems
//! - [`circuit`]: Spin circuit elements (resistors, networks, spin accumulation)
//! - [`fluid`]: Spin-vorticity coupling in liquid metals (Barnett effect)
//! - [`mech`]: Nanomechanical spintronics (Barnett, Einstein-de Haas, cantilever coupling)
//! - [`ai`]: Physical reservoir computing with magnon dynamics
//!
//! ### Computational Tools
//! - [`fem`]: Finite element method (Delaunay mesh, iterative solvers, micromagnetics)
//! - [`memory`]: Memory pool allocator for high-performance simulations (v0.2.0)
//! - [`simd`]: SIMD-friendly batch processing for vector operations (v0.3.0)
//! - [`parallel`]: Domain decomposition and parallel sweeps (v0.3.0, feature-gated)
//! - [`builder`]: Type-state SimulationBuilder for validated construction (v0.3.0)
//!
//! ### Data & Validation
//! - [`visualization`]: Data export (VTK, CSV, JSON, HDF5)
//! - [`validation`]: Experimental validation tests against landmark papers
//! - `python`: Python bindings via PyO3 (v0.2.0, optional feature)
//!
//! ## Quick Start
//!
//! ```rust
//! use spintronics::prelude::*;
//!
//! // Setup materials (YIG/Pt system)
//! let yig = Ferromagnet::yig();
//! let interface = SpinInterface::yig_pt();
//! let pt_strip = InverseSpinHall::platinum();
//!
//! // Initialize magnetization state
//! let m = Vector3::new(1.0, 0.0, 0.0);
//! let h_ext = Vector3::new(0.0, 0.0, 1.0);
//!
//! // Solve LLG equation
//! let dm_dt = calc_dm_dt(m, h_ext, GAMMA, yig.alpha);
//!
//! // Calculate spin pumping current
//! let js = spin_pumping_current(&interface, m, dm_dt);
//!
//! // Validate physical quantities (v0.2.0)
//! assert!(is_valid_magnetization(yig.ms));
//! assert!(is_valid_damping(yig.alpha));
//!
//! // Convert to electric field via ISHE
//! let e_field = pt_strip.convert(interface.normal, js);
//! ```

#![warn(missing_docs)]
#![warn(clippy::all)]
#![allow(clippy::doc_lazy_continuation)]
#![allow(clippy::doc_markdown)]

pub mod afm;
pub mod altermagnet;
pub mod caloritronics;

#[cfg(not(target_arch = "wasm32"))]
pub mod ai;

pub mod benchmark;
pub mod builder;
pub mod cavity;
pub mod circuit;
pub mod constants;
pub mod dynamics;
pub mod effect;
pub mod error;

#[cfg(feature = "fem")]
pub mod fem;

pub mod fluid;
pub mod frustrated;
pub mod io;
pub mod llg;

#[cfg(not(target_arch = "wasm32"))]
pub mod magnon;

pub mod material;
pub mod mech;
pub mod memory;

#[cfg(feature = "parallel")]
pub mod parallel;

pub mod orbitronics;
pub mod simd;
pub mod spinwave;

#[cfg(feature = "scirs2")]
pub mod stochastic;

pub mod texture;
pub mod thermo;
pub mod transport;
pub mod units;
pub mod validation;
pub mod vector3;
pub mod visualization;

#[cfg(feature = "wasm")]
pub mod wasm;

#[cfg(feature = "python")]
pub mod python;

pub mod prelude;

pub use vector3::Vector3;