find_x_point

Function find_x_point 

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

Find the X-point (magnetic null) in the lower divertor region.

Algorithm:

  1. Compute gradient magnitude |∇Ψ| using central differences
  2. Mask upper half (only search Z < Z_min * 0.5)
  3. Find argmin of |∇Ψ| in masked region

Returns ((R, Z), psi_value) at the X-point.

NOTE: The Python code calls np.gradient(Psi, self.dR, self.dZ) which returns gradients along axis 0 (with spacing dR) and axis 1 (with spacing dZ). The Python variable names are swapped (dPsi_dR is actually along Z-axis, dPsi_dZ along R-axis), but the gradient magnitude is the same either way. In Rust we use correct naming via gradient_2d().