Skip to main content

Crate use_magnetism

Crate use_magnetism 

Source
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§

prelude

Structs§

MagneticField
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.