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 had a bug where np.gradient spacings (dR, dZ) were swapped relative to the array axes (Z=axis0, R=axis1), giving wrong magnitudes when dR!=dZ. Fixed in commit 96a9d5e+. This Rust port uses correct axis ordering.