magnetic_field_current_free#

greensfield.algorithms.magnetic_field_current_free(phi: Unit('G cm'), delta: Unit('cm'))[source]#

Compute vector magnetic field.

Calculate the vector magnetic field using the current-free approximation,

\[\begin{split}\\vec{B} = -\\nabla\phi\end{split}\]

The gradient is computed numerically using a five-point stencil,

\[\begin{split}\\frac{\partial B}{\partial x_i} \\approx -\left(\\frac{-B_{x_i}(x_i + 2\Delta x_i) + 8B_{x_i}(x_i + \Delta x_i) - 8B_{x_i}(x_i - \Delta x_i) + B_{x_i}(x_i - 2\Delta x_i)}{12\Delta x_i}\\right)\end{split}\]
Parameters:
  • phi (Quantity) – Scalar magnetic potential as a function of \(x\), \(y\), and \(z\) with shape (n_x,n_y,n_z).

  • delta (Quantity) – Size of each grid cell in \(x\), \(y\), and \(z\) with shape (3,).

Returns:

B_field\(x\), \(y\), and \(z\) components of the vector magnetic field with shape (n_x,n_y,n_z,3).

Return type:

Quantity