class plasmapy.formulary.magnetostatics.GeneralWire(parametric_eq, t1, t2, current: Quantity)[source]

Bases: Wire

General wire class described by its parametric vector equation.

  • parametric_eq (Callable) – A vector-valued (with units of position) function of a single real parameter.

  • t1 (float) – Lower bound of the parameter, smaller than t2.

  • t2 (float) – Upper bound of the parameter, larger than t1.

  • current (Quantity) – Electric current.

Methods Summary

magnetic_field(p[, n])

Calculate magnetic field generated by this wire at position p.

Methods Documentation

magnetic_field(p: Quantity, n: int = 1000) Quantity[source]

Calculate magnetic field generated by this wire at position p.

  • p (Quantity) – Three-dimensional position vector.

  • n (int, optional) – Number of segments for Wire calculation (defaults to 1000).


B – Magnetic field at the specified position.

Return type:



The magnetic field generated by a wire with constant electric current is found at a point in 3D space by approximating the Biot–Savart law.

Let the point where the magnetic field will be calculated be represented by the point \(p\) (with associated position vector \(\vec{p}\)) and the curve \(C\) defining the wire by the parametric vector equation \(\vec{l}(t)\) with \(t_{\min} \leq t \leq t_{\max}\). Further, let the displacement vector from the wire to the point \(p\) be written as \(\vec{r}(t) = \vec{p} - \vec{l}(t)\).

The magnetic field \(\vec{B}\) generated by the wire with constant current \(I\) at point \(p\) can then be expressed using the Biot–Savart law, which takes the form

\[\vec B = \frac{\mu_0 I}{4\pi} \int_C \frac{d\vec{l} \times \vec{r}}{|\vec{r}|^3}\]

where \(\mu_0\) is the permeability of free space.

This line integral is approximated by segmenting the wire into \(n\) straight pieces of equal length. The \(i\text{th}\) wire element can be written as \(\Delta\vec{l}_i = \vec{l}(t_i) - \vec{l}(t_{i - 1})\) where \(t_i = t_{\min} + i(t_{\max}-t_{\min})/n\). Further, the displacement vector from the center of the \(i\text{th}\) wire element to the position \(\vec{p}\) is \(\vec{r}_i = \vec{p} - \frac{\vec{l}(t_i) + \vec{l}(t_{i-1})}{2}\).

The integral is then approximated as

\[\vec B \approx \frac{\mu_0 I}{4\pi} \sum_{i=1}^{n}\frac{\vec{\Delta l}_i \times \vec{r}_i}{\left| \vec{r}_i \right|^3}.\]