Skip to main content

Module magnetic

Module magnetic 

Source
Expand description

Magnetic field computation — Biot-Savart law, current loops, solenoids, magnetic dipoles, field line tracing, and Ampere’s law verification.

Structs§

CircularLoop
A circular current loop.
CurrentSegment
A finite straight current-carrying segment.
InfiniteWire
An infinite straight wire carrying current.
MagneticFieldRenderer
Renderer for magnetic field visualization.
Solenoid
A solenoid: many circular loops stacked along an axis.

Functions§

ampere_circulation
Verify Ampere’s law: the circulation of B around a closed path equals mu0 * I_enc. Returns the line integral ∮ B · dl.
biot_savart
Biot-Savart law for a finite current segment. dB = (mu0 / 4*pi) * I * dl × r_hat / r^2 Integrated analytically for a straight segment.
magnetic_dipole_field
Magnetic field of a magnetic dipole at a given position. B = (mu0/4*pi) * [3(m·r_hat)r_hat - m] / r^3
magnetic_field_at
Compute the total magnetic field at pos from multiple current segments (superposition).
trace_magnetic_field_line
Trace a magnetic field line from a start point. Magnetic field lines are closed loops (div B = 0).