torus_solver.targets

class torus_solver.targets.FitResult(shift_R, scale_rho, rho_max_before_m)[source]

Bases: object

Shift/scale parameters used to fit an (R,Z) surface inside a circular torus.

Parameters:
  • shift_R (float)

  • scale_rho (float)

  • rho_max_before_m (float)

rho_max_before_m: float
scale_rho: float
shift_R: float
torus_solver.targets.RZ_and_derivatives_to_xyz_normals_weights(*, R, Z, R_theta, R_phi, Z_theta, Z_phi, phi)[source]

Build xyz, unit normals, and area weights from (R,Z) and derivatives.

Return type:

tuple[Array, Array, Array]

Parameters:
  • R (Array)

  • Z (Array)

  • R_theta (Array)

  • R_phi (Array)

  • Z_theta (Array)

  • Z_phi (Array)

  • phi (Array)

class torus_solver.targets.TargetSurface(theta, phi, xyz, normals, weights, fit)[source]

Bases: object

A target surface sampled on a (theta,phi) grid.

Parameters:
  • theta (Array)

  • phi (Array)

  • xyz (Array)

  • normals (Array)

  • weights (Array)

  • fit (FitResult)

fit: FitResult
normals: Array
phi: Array
theta: Array
weights: Array
xyz: Array
torus_solver.targets.apply_fit_to_RZ_and_derivatives(*, R, Z, R_theta, R_phi, Z_theta, Z_phi, torus_R0, fit)[source]

Apply FitResult shift/scale to (R,Z) and first derivatives.

Return type:

tuple[Array, Array, Array, Array, Array, Array]

Parameters:
  • R (Array)

  • Z (Array)

  • R_theta (Array)

  • R_phi (Array)

  • Z_theta (Array)

  • Z_phi (Array)

  • torus_R0 (float)

  • fit (FitResult)

torus_solver.targets.circular_torus_target_surface(*, R0, a, n_theta, n_phi, dtype=<class 'jax.numpy.float64'>)[source]

Return a circular torus target surface (xyz, normals, weights) on a (theta,phi) grid.

This helper is useful both for:

  • benchmarking/validation: axisymmetry implies B·n=0 on any interior torus for a purely toroidal field

  • GUI/optimization: choosing a simple reference surface inside the winding surface

Return type:

TargetSurface

Parameters:
  • R0 (float)

  • a (float)

  • n_theta (int)

  • n_phi (int)

torus_solver.targets.fit_RZ_surface_into_torus(*, R, Z, torus_R0, torus_a, fit_margin)[source]

Compute shift/scale so the (R,Z) surface fits inside the torus minor radius.

Return type:

FitResult

Parameters:
  • R (Array)

  • Z (Array)

  • torus_R0 (float)

  • torus_a (float)

  • fit_margin (float)

torus_solver.targets.vmec_target_surface(boundary, *, torus_R0, torus_a, fit_margin, n_theta, n_phi, dtype=<class 'jax.numpy.float64'>)[source]

Sample a VMEC boundary, fit it inside the torus, and return xyz/normals/weights.

Return type:

TargetSurface

Parameters:
  • boundary (VMECBoundary)

  • torus_R0 (float)

  • torus_a (float)

  • fit_margin (float)

  • n_theta (int)

  • n_phi (int)