compute_b_field

Function compute_b_field 

Source
pub fn compute_b_field(
    psi: &Array2<f64>,
    grid: &Grid2D,
) -> FusionResult<(Array2<f64>, Array2<f64>)>
Expand description

Compute the poloidal magnetic field components from the flux function Ψ.

In tokamak cylindrical coordinates:

  • B_R = -(1/R) ∂Ψ/∂Z
  • B_Z = (1/R) ∂Ψ/∂R

Returns (B_R, B_Z) as [nz, nr] arrays.

NOTE: The Python code has swapped variable names (dPsi_dR is actually gradient along axis 0 = Z direction). The physics usage is correct because both assignments swap consistently. This Rust port uses correct naming from the start.