Magba is a performant analytical magnetic computation library for Rust.
>> cargo
Learn more at docs.rs/magba.
Features
- Compute magnetic fields analytically for various source geometries.
- Create magnetic sources and group them as source collections.
- Move and rotate objects in 3D space.
- Increase performance using parallelization with Rayon.
- Support calculation with [f32] and [f64].
- Python bindings available via Pymagba
Quick Start
To install, simply: cargo add magba.
use *;
use *;
use PI;
// Define magnetic sources
let cylinder = Boxnew;
let cuboid = Boxnew;
//!
// Grouping sources as collection
let mut collection = from_sources;
collection.add;
// Observer positions
let points = ;
// Compute B-field (Magnetic flux density [T])
let b_fields = collection.get_B;
// [
// [ -2.7063724257464133e-5, -3.533949646070574e-17, 0.4715809600578704 ],
// [ -3.381192498299282e-5 , 0.0, 0.4592848558923018 ],
// [ -4.0548326050340215e-5, 0.0, 0.45377483361434284 ],
// ]
// Move and Rotate
collection.translate;
collection.rotate;
let b_fields = collection.get_B;
// [
// [ -9.575129388363597e-6 , -0.24516787434696088, 0.4573303607411665 ],
// [ -1.4358446356125264e-5, -0.2948988353221851 , 0.3578212873125478 ],
// [ -1.9136669915278972e-5, -0.30697154302354923, 0.33360985034592394 ],
// ]
Testing
Results are validated against MagpyLib and reference data.
See /tests/test-data and the accuracy report for details.
Learn more at docs.rs/magba.