magba 0.1.1

Magnetic computation library for Rust
Documentation

Magba is a performant analytical magnetic computation library for Rust.

Quick Start

To install, simply: cargo add magba.

Compute the B-field of a cylindrical magnet at a point:

use magba::{CylinderMagnet, Field};
use nalgebra::{Point3, UnitQuaternion, Vector3};

let magnet = CylinderMagnet::new(
    Point3::origin(), // position
    UnitQuaternion::identity(), // orientation
    Vector3::new(0.0, 0.0, 1.0), // polarization
    0.005, // radius
    0.020, // height
);

let b = magnet.get_B(&[Point3::new(0.01, 0.0, 0.0)]).unwrap();
println!("B-field: {:?}", b[0]);

Features

  • Analytical magnetic field computation for:
    • Cylindrical magnets (axial and diametric)
    • Source collections (grouping magnets)
  • Transformations: Move and rotate sources in 3D space
  • Parallel computation (optional, via Rayon)
  • Tested against MagpyLib and reference data
  • Python bindings available via Pymagba

Testing

Results are validated against MagpyLib and reference data. See /tests/test-data and the accuracy report for details.

Documentation


Learn more at docs.rs/magba.