torus_solver.current_potential

torus_solver.current_potential.add_secular_current_terms(surface, *, net_poloidal_current_A=0.0, net_toroidal_current_A=0.0)

Return a multi-valued Phi_sec(θ,φ) for visualization.

The current potential can be multi-valued; its derivatives define K.

Return type:

Array

Parameters:
  • surface (TorusSurface)

  • net_poloidal_current_A (float)

  • net_toroidal_current_A (float)

Convention (matches REGCOIL naming):
  • net_poloidal_current_A multiplies φ / (2π) and yields poloidal surface current K_θ.

  • net_toroidal_current_A multiplies θ / (2π) and yields toroidal surface current K_φ.

Warning: Do not pass this function’s output to surface_current_from_current_potential, since the secular terms are not periodic/smooth and FFT derivatives will be wrong.

torus_solver.current_potential.add_secular_current_terms_for_visualization(surface, *, net_poloidal_current_A=0.0, net_toroidal_current_A=0.0)[source]

Return a multi-valued Phi_sec(θ,φ) for visualization.

The current potential can be multi-valued; its derivatives define K.

Return type:

Array

Parameters:
  • surface (TorusSurface)

  • net_poloidal_current_A (float)

  • net_toroidal_current_A (float)

Convention (matches REGCOIL naming):
  • net_poloidal_current_A multiplies φ / (2π) and yields poloidal surface current K_θ.

  • net_toroidal_current_A multiplies θ / (2π) and yields toroidal surface current K_φ.

Warning: Do not pass this function’s output to surface_current_from_current_potential, since the secular terms are not periodic/smooth and FFT derivatives will be wrong.

torus_solver.current_potential.surface_current_from_current_potential(surface, Phi)[source]

Surface current K (A/m) from a single-valued current potential Phi (A).

Return type:

Array

Parameters:
This is the REGCOIL / “current potential” model:

K = n_hat × ∇_s Phi

On a circular torus with coordinates (θ, φ) and F=0, this can be written as:

K = (Phi_θ * r_φ - Phi_φ * r_θ) / sqrt(g)

where r_θ and r_φ are the surface tangent vectors and sqrt(g)=norm(r_θ×r_φ).

torus_solver.current_potential.surface_current_from_current_potential_with_net_currents(surface, Phi_single_valued, *, net_poloidal_current_A=0.0, net_toroidal_current_A=0.0)[source]

Surface current from current potential with net poloidal/toroidal currents.

The net-current contributions correspond to multi-valued secular terms in Phi, which must NOT be differentiated using FFTs. Instead we add their derivatives analytically: Phi_theta adds Itor/(2π) and Phi_phi adds Ipol/(2π).

Return type:

Array

Parameters:
  • surface (TorusSurface)

  • Phi_single_valued (Array)

  • net_poloidal_current_A (float)

  • net_toroidal_current_A (float)