The Open FUSION Toolkit 26.6
An open-source framework for fusion and plasma science and engineering
Loading...
Searching...
No Matches
OpenFUSIONToolkit.TokaMaker.util Namespace Reference

Detailed Description

General utility and supporting functions for TokaMaker.

Authors
Chris Hansen
Date
April 2024

Functions

 _inner_arc (r_x, z_x, r_inner_mid, z_inner_mid, zeta, n)
 Generate an inverted-INTOR inner arc from X-point to inner midplane.
 _intor_arc (r0, z0_arc, a, kappa_eff, theta_x, r_x, zeta, n, endpoint=False, sign=1)
 Generate one half of the INTOR outer arc.
 compute_forces_components (tMaker_obj, psi, cell_centered=False)
 Compute terms needed for evaluating forces in passively conducting regions.
 create_isoflux (npts, r0, z0, a, kappa, delta, kappaL=None, deltaL=None)
 Create isoflux points using simple analytic form.
 create_isoflux_xpts (npts, r0, z0, a, kappa_upper, delta_upper, kappa_lower=None, delta_lower=None, r_inner_mid=None, zeta_outer_upper=0.0, zeta_outer_lower=0.0, zeta_inner_upper=0.0, zeta_inner_lower=0.0)
 Create isoflux boundary points for single-null configurations with X-points.
 create_power_flux_fun (npts, alpha, gamma)
 Build power law flux function of the form \( (1-\hat{\psi}^{\alpha})^{\gamma} \).
 create_spline_flux_fun (npts, x, y, axis_bc=[1, 0.0], edge_bc=[1, 0.0], normalize=True)
 Build cubic spline flux function.
 eval_green (x, xc)
 Evaluate Green's function for a toroidal filament.
 get_jphi_from_GS (ffprime, pprime, R_avg, one_over_R_avg)
 Calculate j_phi profile from Grad-Shafranov equation.
 read_eqdsk (filename)
 Read gEQDSK file.
 read_ifile (filename)
 Read i-file inverse equilibrium file.
 read_kfile (path, machine_dict, e_coil_names=None, f_coil_names=None)
 read_mhdin (path, e_coil_names=None, f_coil_names=None)
 xpoints_from_moments (r0, z0, a, kappa_upper, delta_upper, kappa_lower=None, delta_lower=None)
 Compute X-point locations from Miller shaping moments.

Function Documentation

◆ _inner_arc()

_inner_arc ( r_x,
z_x,
r_inner_mid,
z_inner_mid,
zeta,
n )
protected

Generate an inverted-INTOR inner arc from X-point to inner midplane.

Uses \(R(\alpha) = r_x - a_\mathrm{in}\cos(\alpha - \zeta\sin 2\alpha)\), \(Z(\alpha) = z_\mathrm{mid} + a_\mathrm{in}\kappa_\mathrm{in}\sin(\alpha + \zeta\sin 2\alpha)\) with \(\alpha\) from \(\pi/2\) (X-point) to 0 (midplane, excluded). The tangent is vertical at the midplane, so joining upper and lower halves is kink-free.

Parameters
r_xR coordinate of the X-point
z_xZ coordinate of the X-point
r_inner_midR at the inner midplane
z_inner_midZ at the inner midplane
zetaINTOR squareness parameter
nNumber of points (midplane endpoint excluded)
Returns
r, z arrays for the arc segment

◆ _intor_arc()

_intor_arc ( r0,
z0_arc,
a,
kappa_eff,
theta_x,
r_x,
zeta,
n,
endpoint = False,
sign = 1 )
protected

Generate one half of the INTOR outer arc.

Arc spans \(\theta\) from 0 (outboard midplane) to \(\mathrm{sign}\cdot\theta_x\) (X-point). sign=+1 gives the upper half (Z > z0_arc); sign=-1 gives the lower half. delta_eff is solved so the arc passes exactly through r_x at theta_x.

Parameters
r0Major radial position for magnetic axis
z0_arcVertical center for this arc half (typically the magnetic axis Z)
aMinor radius
kappa_effElongation for this half
theta_xPoloidal angle at the X-point
r_xR coordinate of the X-point
zetaINTOR squareness parameter
nNumber of points to generate
endpointWhether to include the final endpoint (default: False)
sign+1 for upper half, -1 for lower half (default: +1)
Returns
r, z arrays for the arc segment

◆ compute_forces_components()

compute_forces_components ( tMaker_obj,
psi,
cell_centered = False )

Compute terms needed for evaluating forces in passively conducting regions.

Parameters
tMaker_objTokaMaker equilibrium object
psi\( \psi \) corresponding to desired currents
cell_centeredEvaluate at cell centers instead of node points?
Returns
J_cond, B_cond, mask, R

◆ create_isoflux()

create_isoflux ( npts,
r0,
z0,
a,
kappa,
delta,
kappaL = None,
deltaL = None )

Create isoflux points using simple analytic form.

Parameters
nptsNumber of points to sample (evenly spaced in \(\theta\))
r0Major radial position for magnetic axis
z0Vertical position for magnetic axis
aMinor radius
kappaElongation (upper only if kappaL is set)
deltaTriangularity (upper only if deltaL is set)
kappaLLower elongation (default: kappa)
deltaLLower triangularity (default: delta)
Returns
Point list [npts,2]

◆ create_isoflux_xpts()

create_isoflux_xpts ( npts,
r0,
z0,
a,
kappa_upper,
delta_upper,
kappa_lower = None,
delta_lower = None,
r_inner_mid = None,
zeta_outer_upper = 0.0,
zeta_outer_lower = 0.0,
zeta_inner_upper = 0.0,
zeta_inner_lower = 0.0 )

Create isoflux boundary points for single-null configurations with X-points.

Generates a closed boundary contour suitable for use with set_isoflux_constraints() and set_saddle_constraints(). The outer (low-field-side) arc uses the INTOR analytic formula centered on the magnetic axis; the inner arcs use an inverted-INTOR formula that gives a smooth vertical tangent at the inner midplane. Supports non-up-down-symmetric equilibria via independent upper and lower shaping moments and squareness values.

Use xpoints_from_moments() with the same kappa/delta arguments to obtain the matching saddle-constraint array.

Parameters
nptsTotal number of boundary points
r0Major radial position for magnetic axis
z0Vertical position for magnetic axis
aMinor radius
kappa_upperUpper elongation (sets X-point height and outer arc shape)
delta_upperUpper triangularity
kappa_lowerLower elongation (default: kappa_upper)
delta_lowerLower triangularity (default: delta_upper)
r_inner_midR at the inner midplane (default: r0 - a)
zeta_outer_upperINTOR squareness of the upper outer corner (default: 0)
zeta_outer_lowerINTOR squareness of the lower outer corner (default: 0)
zeta_inner_upperINTOR squareness of the upper inner corner (default: 0)
zeta_inner_lowerINTOR squareness of the lower inner corner (default: 0)
Returns
Point list [npts, 2]

◆ create_power_flux_fun()

create_power_flux_fun ( npts,
alpha,
gamma )

Build power law flux function of the form \( (1-\hat{\psi}^{\alpha})^{\gamma} \).

Parameters
nptsNumber of points for definition
alphaInner exponent
gammaOuter exponent
Returns
Flux function definition dictionary

◆ create_spline_flux_fun()

create_spline_flux_fun ( npts,
x,
y,
axis_bc = [1,0.0],
edge_bc = [1,0.0],
normalize = True )

Build cubic spline flux function.

Parameters
nptsNumber of points for definition
xLocation of spline "knots" in normalized flux
yValue of flux function at spline "knots"
axis_bcSciPy BC specification on axis ( \( \hat{\psi} = 0 \))
edge_bcSciPy BC specification on LCFS ( \( \hat{\psi} = 1 \))
Returns
Flux function definition dictionary

◆ eval_green()

eval_green ( x,
xc )

Evaluate Green's function for a toroidal filament.

Parameters
xObservation point [2]
xcCoil location [:,2]
Returns
\(\psi(x)\) due to a coil with unit current [A] at xc

◆ get_jphi_from_GS()

get_jphi_from_GS ( ffprime,
pprime,
R_avg,
one_over_R_avg )

Calculate j_phi profile from Grad-Shafranov equation.

Parameters
ffprimeFF'(psi_N) profile
pprimeP'(psi_N) profile
R_avg<R>(psi_N) profile
one_over_R_avg<1/R>(psi_N) profile Returns: j_phi(\psi_N) profile

◆ read_eqdsk()

read_eqdsk ( filename)

Read gEQDSK file.

Parameters
filenamePath to gEQDSK file
Returns
Dictionary containing gEQDSK information

◆ read_ifile()

read_ifile ( filename)

Read i-file inverse equilibrium file.

Parameters
filenamePath to file
Returns
Dictionary containing i-file information

◆ read_kfile()

read_kfile ( path,
machine_dict,
e_coil_names = None,
f_coil_names = None )
Read k-file.

@param path Path to file
@param e_coil_names Names of E coils (hardcoded, generates indexed names if None)
@param f_coil_names Names of F coils (hardcoded, generates indexed names if None)
@param machine_dict Result from read_mhdin (contents of mhdin.dat file)
@result probes_dict Dictionary containing probe values and weights (0 if not selected).
@result loops_dict Dictionary containing loop values and weights (0 if not selected).
@result e_coil_dict Dictionary containing E copil values and weights (0 if not selected).
@result f_coil_dict Dictionary containing F coil values and weights (0 if not selected).
@result raw Dictionary containing all other data from k-file.

◆ read_mhdin()

read_mhdin ( path,
e_coil_names = None,
f_coil_names = None )
Read mhdin.dat file.

@param path Path to file
@param e_coil_names Names of E coils (hardcoded, generates indexed names if None)
@param f_coil_names Names of F coils (hardcoded, generates indexed names if None)
@result machine_dict Dictionary containing coil coordinates and turns, loop names, and probe names and angles.
@result raw Dictionary containing all other data from mhdin.dat

◆ xpoints_from_moments()

xpoints_from_moments ( r0,
z0,
a,
kappa_upper,
delta_upper,
kappa_lower = None,
delta_lower = None )

Compute X-point locations from Miller shaping moments.

Upper: \((r_0 - a\,\delta_U,\; z_0 + a\,\kappa_U)\). Lower: \((r_0 - a\,\delta_L,\; z_0 - a\,\kappa_L)\).

Parameters
r0Major radial position for magnetic axis
z0Vertical position for magnetic axis
aMinor radius
kappa_upperUpper elongation
delta_upperUpper triangularity
kappa_lowerLower elongation (default: kappa_upper)
delta_lowerLower triangularity (default: delta_upper)
Returns
X-point array, shape (2, 2): [[R_upper, Z_upper], [R_lower, Z_lower]]