torus_solver.fields

torus_solver.fields.cylindrical_coords(xyz)[source]

Convert Cartesian points (…,3) -> cylindrical (R, φ, Z).

Return type:

tuple[Array, Array, Array]

Parameters:

xyz (Array)

torus_solver.fields.cylindrical_unit_vectors(phi)[source]

Unit vectors (e_R, e_φ, e_Z) for cylindrical angle φ.

Return type:

tuple[Array, Array, Array]

Parameters:

phi (Array)

torus_solver.fields.ideal_toroidal_field(xyz, *, B0, R0, eps=1e-12)[source]

Ideal axisymmetric toroidal field: B = B0 * (R0/R) e_φ.

Return type:

Array

Parameters:
  • xyz (Array)

  • B0 (float)

  • R0 (float)

  • eps (float)

torus_solver.fields.tokamak_like_field(xyz, *, B_tor0, B_pol0, R0, eps=1e-12)[source]

Toy tokamak-like field with 1/R toroidal + poloidal components.

B = (B_tor0 * R0/R) e_φ + (B_pol0 * R0/R) e_θ

Return type:

Array

Parameters:
  • xyz (Array)

  • B_tor0 (float)

  • B_pol0 (float)

  • R0 (float)

  • eps (float)

torus_solver.fields.toroidal_poloidal_coords(xyz, *, R0, eps=1e-12)[source]

Return toroidal (R, φ, Z) and local poloidal (ρ, θ, e_ρ, e_θ).

The local poloidal coordinates are defined in the (R,Z) plane relative to the circle R=R0, Z=0:

  • ρ = sqrt((R-R0)^2 + Z^2)

  • θ = atan2(Z, R-R0)

  • e_ρ = cos(θ) e_R + sin(θ) e_Z

  • e_θ = -sin(θ) e_R + cos(θ) e_Z

Return type:

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

Parameters:
  • xyz (Array)

  • R0 (float)

  • eps (float)