Expand description
Magnetic field computation — Biot-Savart law, current loops, solenoids, magnetic dipoles, field line tracing, and Ampere’s law verification.
Structs§
- Circular
Loop - A circular current loop.
- Current
Segment - A finite straight current-carrying segment.
- Infinite
Wire - An infinite straight wire carrying current.
- Magnetic
Field Renderer - 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
posfrom 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).