Skip to content

Commit

Permalink
Add tokamak option psi_divide_twopi
Browse files Browse the repository at this point in the history
Some equilibrium codes write GEQDSK files with a factor of 2pi
in the poloidal flux, resulting in poloidal fields that are 2pi
too large. If this option `psi_divide_twopi` is set to `true`
then the input poloidal flux is divided by 2pi.
  • Loading branch information
bendudson committed Aug 15, 2023
1 parent b17d4f2 commit da7c163
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions hypnotoad/cases/tokamak.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class TokamakEquilibrium(Equilibrium):
doc="Reverse the sign of the poloidal field",
value_type=bool,
),
psi_divide_twopi=WithMeta(
False,
doc="Divide poloidal flux, and so poloidal field, by 2pi",
value_type=bool,
),
extrapolate_profiles=WithMeta(
False,
doc=(
Expand Down Expand Up @@ -364,6 +369,16 @@ def __init__(
psi2D *= -1.0
psi1D *= -1.0

if self.user_options.psi_divide_twopi:
warnings.warn("Dividing poloidal flux by 2pi")
twopi = 2 * np.pi
psi2D /= twopi
psi1D /= twopi
if psi_axis_gfile is not None:
psi_axis_gfile /= twopi
if psi_bdry_gfile is not None:
psi_bdry_gfile /= twopi

if self.user_options.reverse_Bt:
warnings.warn("Reversing the sign of the toroidal field")
fpol1D *= -1.0
Expand Down Expand Up @@ -1679,6 +1694,7 @@ def read_geqdsk(
* ``reverse_current = bool`` - Changes the sign of poloidal flux psi
* ``extrapolate_profiles = bool`` - Extrapolate pressure using exponential
* ``psi_divide_twopi = bool`` - Divide poloidal flux, and so poloidal field, by 2pi
"""

if settings is None:
Expand Down

0 comments on commit da7c163

Please sign in to comment.