Expand description
§use-magnetism
Magnetism-specific scalar helpers for RustUse.
§Install
[dependencies]
use-magnetism = "0.0.1"§Foundation
use-magnetism provides small magnetism-specific scalar helpers for magnetic force, magnetic flux, magnetic flux density, solenoid and loop fields, magnetic pressure, and simple magnetic field primitives.
Inputs are expected to be SI-style numeric values:
- teslas for magnetic flux density
- webers for magnetic flux
- square meters for area
- coulombs for charge
- meters per second for velocity
- amperes for current
- meters for length, radius, and distance
- newtons for force
- joules per cubic meter for energy density
- pascals for magnetic pressure
The crate does not define a full unit system.
More general units and constants belong in the top-level use-units and use-constants sets. Vector operations should live in or compose with use-vector. Combined electric and magnetic relations should live in a separate use-electromagnetism crate.
§Example
use std::f64::consts::FRAC_PI_2;
use use_magnetism::{MagneticField, magnetic_field_inside_solenoid, magnetic_flux};
assert_eq!(magnetic_flux(2.0, 3.0, 0.0), Some(6.0));
assert!(magnetic_field_inside_solenoid(1_000.0, 2.0, 0.5).unwrap() > 0.0);
let field = MagneticField::new(3.0).expect("valid field");
assert_eq!(field.force_on_charge(1.0, 2.0, FRAC_PI_2), Some(6.0));§When to use directly
Choose use-magnetism when you need reusable scalar magnetism formulas without bringing in a broader unit, vector, or electromagnetism system.
§Scope
- APIs stay
f64-first and deliberately small. - The crate keeps only one local convenience constant for magnetism-specific helpers.
- Full unit systems, waveform models, signal processing, and general vector operations are out of scope.
§Status
use-magnetism is a pre-1.0 crate with a deliberately small API.
Magnetism-specific scalar helpers.
Modules§
Structs§
- Magnetic
Field - A simple magnetic field described by flux density.
Constants§
- VACUUM_
PERMEABILITY - Vacuum permeability in newtons per ampere squared.
Functions§
- magnetic_
energy_ density - Computes magnetic energy density.
- magnetic_
field_ around_ long_ straight_ wire - Computes magnetic flux density around a long straight wire.
- magnetic_
field_ at_ center_ of_ loop - Computes magnetic flux density at the center of a circular current loop.
- magnetic_
field_ inside_ solenoid - Computes magnetic flux density inside an ideal long solenoid.
- magnetic_
flux - Computes magnetic flux through an area.
- magnetic_
flux_ degrees - Computes magnetic flux through an area using an angle in degrees.
- magnetic_
flux_ density_ from_ flux - Computes magnetic flux density from magnetic flux, area, and orientation.
- magnetic_
force_ magnitude_ on_ charge - Computes the magnitude of magnetic force on a moving charge.
- magnetic_
force_ on_ charge - Computes magnetic force on a moving charge.
- magnetic_
force_ on_ charge_ degrees - Computes magnetic force on a moving charge using an angle in degrees.
- magnetic_
force_ on_ wire - Computes magnetic force on a current-carrying wire.
- magnetic_
force_ on_ wire_ degrees - Computes magnetic force on a current-carrying wire using an angle in degrees.
- magnetic_
pressure - Computes magnetic pressure.