pyna.toroidal.coils.coil_system#

External coil systems for stellarator island control.

Provides: - CoilSet: a collection of current-carrying coils - StellaratorControlCoils: standard external island control coil geometry - Biot_Savart_field: numerical Biot-Savart computation on a cylindrical grid

The Biot-Savart integration is parallelized over coils and grid points.

Attributes#

Classes#

CoilSet

Collection of coils with individual currents.

StellaratorControlCoils

Standard external island control coil array for a stellarator.

CoilFieldBiotSavart

Vacuum field from a numerically-defined coil via Biot-Savart law.

Functions#

Biot_Savart_field(coil_pts, coil_current, R_grid, Z_grid)

Compute magnetic field from a current-carrying coil via Biot-Savart.

Module Contents#

pyna.toroidal.coils.coil_system.MU0_OVER_4PI = 1e-07[source]#
pyna.toroidal.coils.coil_system.Biot_Savart_field(coil_pts, coil_current, R_grid, Z_grid, Phi_grid=None)[source]#

Compute magnetic field from a current-carrying coil via Biot-Savart.

Parameters:
  • coil_pts (ndarray, shape (N, 3)) – XYZ coordinates of coil points (meters).

  • coil_current (float) – Current in amperes (positive = right-hand rule along coil_pts direction).

  • R_grid (ndarray, shape (nR, nZ) or 1D) – Cylindrical coordinate grid.

  • Z_grid (ndarray, shape (nR, nZ) or 1D) – Cylindrical coordinate grid.

  • Phi_grid (ndarray or None) – If None, compute on the (R, Z) plane at phi=0. If provided, compute on the full 3D (R, Z, Phi) grid.

Returns:

BR, BZ, BPhi (ndarray) – Field components on the grid (Tesla).

class pyna.toroidal.coils.coil_system.CoilSet[source]#

Collection of coils with individual currents.

Each coil is defined by a list of 3D points (forming a closed loop).

coils = [][source]#
add_coil(pts_xyz, current=1.0)[source]#

Add a coil defined by XYZ points.

field_on_grid(R_1d, Z_1d, phi_1d=None, n_workers=None)[source]#

Compute total field from all coils on a cylindrical grid.

If phi_1d is None: compute on (R,Z) at phi=0. If phi_1d provided: full 3D computation (R, Z, Phi grid).

Returns:

BR, BZ, BPhi (ndarray) – Shape (nR, nZ) if phi_1d is None, else (nR, nZ, nPhi).

to_vector_field(R_1d, Z_1d, phi_1d=None, *, phi: float = 0.0, n_workers=None, label: str = '')[source]#

Compute total coil field as VectorFieldCylind.

field_on_grid is retained for legacy tuple callers. This helper is the preferred high-level API because component access is named.

scale_currents(scale)[source]#

Scale all currents by a factor.

set_current(idx, current)[source]#
get_currents()[source]#

Return array of all currents.

set_currents(currents)[source]#

Set all currents from an array.

class pyna.toroidal.coils.coil_system.StellaratorControlCoils(R0, r_coil, N_coils, m_target, n_target, I0=1.0)[source]#

Bases: CoilSet

Standard external island control coil array for a stellarator.

Creates a set of saddle coils around the torus designed to produce a resonant (m_target, n_target) perturbation.

The coils are phased as I_k = I0 * cos(n_target * phi_k) to produce a dominant (m=0, n=n_target) or combined (m_target, n_target) response.

Parameters:
  • R0 (float) – Major radius and coil minor radius (slightly outside plasma, m).

  • r_coil (float) – Major radius and coil minor radius (slightly outside plasma, m).

  • N_coils (int) – Total number of saddle coils around the torus.

  • m_target (int) – Target resonant mode to control.

  • n_target (int) – Target resonant mode to control.

  • I0 (float) – Reference current (A).

R0[source]#
r_coil[source]#
m_target[source]#
n_target[source]#
I0[source]#
set_phase(phase_offset)[source]#

Re-phase all coil currents by adding a toroidal phase offset (rad).

set_amplitude(I0_new)[source]#

Set a new reference amplitude for all coil currents.

class pyna.toroidal.coils.coil_system.CoilFieldBiotSavart(coil_pts: numpy.ndarray, current: float = 1.0)[source]#

Bases: pyna.toroidal.coils.base.CoilFieldVacuum

Vacuum field from a numerically-defined coil via Biot-Savart law.

Parameters:
  • coil_pts (ndarray, shape (N, 3)) – XYZ coordinates of coil vertices (meters).

  • current (float) – Coil current in amperes.

property current: float[source]#
B_at(R, Z, phi)[source]#

Evaluate (B_R, B_Z, B_phi) at given coordinates.

Parameters:
  • R (scalar or array-like, broadcast-compatible)

  • Z (scalar or array-like, broadcast-compatible)

  • phi (scalar or array-like, broadcast-compatible)

Returns:

(BR, BZ, Bphi) (tuple of ndarray, same shape as broadcast(R, Z, phi))

divergence_free() bool[source]#

Return True if this field is guaranteed to satisfy ∇·B = 0.