The Open FUSION Toolkit 26.9
An open-source framework for fusion and plasma science and engineering
Loading...
Searching...
No Matches
TokaMaker Example: Plasma-Breakdown Assessment for the CUTE Tokamak

Ohmic start-up needs three things to line up at the same place and time:

(a) A poloidal-field null. The central solenoid (CS) ramps down to drive a toroidal loop voltage \(V_{loop} = 2\pi R\,E_\phi\). The CS and PF coils also make a stray poloidal field; where it cancels, \(|B_{pol}|\to 0\) (a field null) and field lines become nearly purely toroidal. A freshly-ionized electron then stays in the chamber for a long connection length \(\)L_c \approx 0.25\,a\,\frac{B_\phi}{B_T}, \(\) where \(a\) is the size of the low-field region, \(B_\phi\) the toroidal field, and \(B_T\) the (average) stray poloidal field over the null region. A good null keeps \(B_T\) small here (~1 mT).

(b) Townsend avalanche. Seed electrons accelerated by \(E_\phi\) ionize the prefill gas, and then the the electron density grows via Townsend avalance. Requiring at least one e-folding, \(\alpha L_c \ge 1\), gives a Paschen-type minimum field \(E_{min}(p)=Bp/\ln(A\,p\,L_c)\), which is smallest at a particular prefill pressure (the Paschen minimum).

(c) Loop voltage and the engineering criterion. The CS flux swing must supply \(V_{loop}=2\pi R\,E_\phi\). The tokamak start-up community compresses (a)–(b) into two experimentally-calibrated rules (Leuer et al. 2010): \(E_\phi \ge 0.3\) V/m (ohmic, 0.15 with ECRF) and \(E_\phi B_\phi / B_T \ge 10^{3}\) V/m.

In this notebook, we:

  1. Set up TokaMaker with the CUTE mesh and coils.
  2. Solve a small post-breakdown seed plasma and maximize the boundary flux \(\psi_{LCFS}\) (the volt-second budget).
  3. Solve the vacuum field null the coils can make and check \(|B_{pol}|\) against a threshold.
  4. Add the Townsend/Paschen breakdown physics and find the prefill window.
  5. Optimize the null location.
  6. Evaluate the Leuer "Etanga" figure of merit \(E_\phi B_\phi/B_T\).
import os
import sys
import time
import json
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
plt.rcParams['figure.figsize']=(6,6)
plt.rcParams['font.weight']='bold'
plt.rcParams['axes.labelweight']='bold'
plt.rcParams['lines.linewidth']=2
plt.rcParams['lines.markeredgewidth']=2
%matplotlib inline
%config InlineBackend.figure_format = "retina"
tokamaker_python_path = os.getenv('OFT_ROOTPATH')
if tokamaker_python_path is not None:
sys.path.append(os.path.join(tokamaker_python_path,'python'))
from OpenFUSIONToolkit import OFT_env
from OpenFUSIONToolkit.TokaMaker import TokaMaker
from OpenFUSIONToolkit.TokaMaker.meshing import load_gs_mesh
from OpenFUSIONToolkit.TokaMaker.util import create_isoflux, create_power_flux_fun
TokaMaker utilities for mesh generation and manipulation.
Definition meshing.py:1
General utility and supporting functions for TokaMaker.
Definition util.py:1
Python interface for TokaMaker Grad-Shafranov functionality.
Definition __init__.py:1
myOFT = OFT_env(nthreads=2)
mygs = TokaMaker(myOFT)
#----------------------------------------------
Open FUSION Toolkit Initialized
Development branch:    arc_v3a
Revision id:           04589ca
Parallelization Info:
  Not compiled with MPI
  # of OpenMP threads =    2
Integer Precisions    =    4   8
Float Precisions      =    4   8  16
Complex Precisions    =    4   8
LA backend            = native
#----------------------------------------------
mesh_pts,mesh_lc,mesh_reg,coil_dict,cond_dict = load_gs_mesh('CUTE_mesh.h5')
mygs.setup_mesh(mesh_pts, mesh_lc, mesh_reg)
mygs.setup_regions(cond_dict=cond_dict,coil_dict=coil_dict)
mygs.settings.lim_zmax = 0.38 # Prevent limiting in upper/lower divertor areas
mygs.setup(order=2,F0=0.17)
**** Loading OFT surface mesh

**** Generating surface grid level  1
  Generating boundary domain linkage
  Mesh statistics:
    Area         =  1.301E+00
    # of points  =    5796
    # of edges   =   17283
    # of cells   =   11488
    # of boundary points =     102
    # of boundary edges  =     102
    # of boundary cells  =     102
  Resolution statistics:
    hmin =  3.994E-03
    hrms =  1.721E-02
    hmax =  7.410E-02
  Surface grounded at vertex     761


**** Creating Lagrange FE space
  Order  =    2
  Minlev =   -1

 Computing flux BC matrix 
 Inverting real matrix
   Time =    4.9899999999999999E-004

Coil Limits

For breakdown studies, the coil limits set the maximum availble flux (described below).

coil_bounds = {key: [-1.E3, 1.E3] for key in mygs.coil_sets}
mygs.set_coil_bounds(coil_bounds)
# Set profiles
ffp_prof = create_power_flux_fun(40,1.5,2.0)
pp_prof = create_power_flux_fun(40,4.0,1.0)
mygs.set_profiles(ffp_prof=ffp_prof,pp_prof=pp_prof)

Compute initial post-breakdown equilibrium

coil_mirrors = {'CS{0:02d}'.format(2*i+1): 'CS{0:02d}'.format(2*i+2) for i in range(7)}
coil_mirrors.update({'PF{0:02d}'.format(i): 'PF{0:02d}'.format(15-i) for i in range(1,8)})
disable_list = ['PF01']
# Set regularization weights
regularization_terms = []
for name, coil in mygs.coil_sets.items():
if name not in coil_mirrors:
continue
if name in disable_list:
# Set zero target current and high weight on coil and mirror
regularization_terms.append(mygs.coil_reg_term({name: 1.0},target=0.0,weight=1.E5))
regularization_terms.append(mygs.coil_reg_term({coil_mirrors[name]: 1.0},target=0.0,weight=1.E5))
else:
# Set zero target current and small weight to help conditioning of fit
if name.startswith('CS'):
regularization_terms.append(mygs.coil_reg_term({name: 1.0},target=1.E3,weight=1.E-2))
else:
regularization_terms.append(mygs.coil_reg_term({name: 1.0},target=0.0,weight=1.E-2))
# Set zero target for the difference of currents for coil and its mirror to ensure up-down symmetry
regularization_terms.append(mygs.coil_reg_term({name: 1.0, coil_mirrors[name]: -1.0},target=0.0,weight=1.E0))
# Pass regularization terms to TokaMaker
mygs.set_coil_reg(reg_terms=regularization_terms)
Ip_target = 1.E3
beta_approx = 0.1
mygs.set_targets(Ip=Ip_target,Ip_ratio=(1.0/beta_approx - 1.0))
isoflux_pts = create_isoflux(80,0.2,0.0,0.08,1.0,0.0)
mygs.set_isoflux_constraints(isoflux_pts)
mygs.set_saddle_constraints(None)
mygs.init_psi(0.2,0.0,0.08,1.0,0.0)
mygs.solve()
coil_currents, _ = mygs.get_coil_currents()
Starting non-linear GS solver
     1  4.8509E-02  3.6569E-02  1.7441E-05  2.0845E-01 -4.8889E-06 -0.0000E+00
     2  5.4935E-02  3.8654E-02  4.0467E-06  2.0778E-01 -2.3793E-06 -0.0000E+00
     3  5.7506E-02  3.9451E-02  1.2647E-06  2.0756E-01 -1.7281E-06 -0.0000E+00
     4  5.8597E-02  3.9771E-02  4.9556E-07  2.0749E-01 -1.5233E-06 -0.0000E+00
 Timing:   3.8020999636501074E-002
   Source:     1.6634999774396420E-002
   Solve:      7.0819999091327190E-003
   Boundary:   1.3500000350177288E-003
   Other:      1.2953999917954206E-002
fig, ax = plt.subplots(1,1)
mygs.plot_machine(fig,ax,coil_colormap='seismic',coil_symmap=True,coil_scale=1.0E-3,coil_clabel=r'$I_{coil}$ [kA]')
mygs.plot_psi(fig,ax,xpoint_color='k',vacuum_nlevels=0,plasma_nlevels=6)
# mygs.plot_constraints(fig,ax,isoflux_color='tab:red',isoflux_marker='.')

We want this value to be as high as possible

\(\psi_{LCFS}\) is the poloidal flux on the plasma boundary. The central solenoid (CS) acts as the primary of a transformer: its changing flux drives the loop voltage \(V_{loop} = -d\psi/dt\) that ionizes the gas and sustains \(I_p\). The total volt-second budget for the discharge is the availailible flux swing \(\Delta\psi\) between the fully-biased CS state at breakdown and the most negative \(\psi\) reachable at the end of the ramp.

The more boundary flux we can establish at breakdown, more flux swing we have availible for the pulse. Effectively this means that we want to bias the CS stack as hard as the coil-current limits allow. Here we scans the CS bias current, re-solve the equilibrium at each value, and keep the bias that gives the largest \(\psi_{LCFS}\) (then re-solves there so the rest of the notebook uses that state).

# --- Maximize the available flux swing ---------------------------------------
# Bias the CS stack harder to store more poloidal flux (higher psi_LCFS = bigger
# volt-second budget). We scan the CS bias current, re-solve the equilibrium at
# each value, and keep the bias that maximizes psi_LCFS within the coil bounds.
cs_coils = [k for k in mygs.coil_sets if k.startswith('CS')]
cs_bound = coil_bounds[cs_coils[0]][1] # per-coil current limit set above
def solve_with_cs_bias(cs_target):
"""Re-solve the post-breakdown equilibrium with the CS biased to cs_target."""
reg = []
for name, coil in mygs.coil_sets.items():
if name not in coil_mirrors:
continue
if name in disable_list:
reg.append(mygs.coil_reg_term({name: 1.0}, target=0.0, weight=1.E5))
reg.append(mygs.coil_reg_term({coil_mirrors[name]: 1.0}, target=0.0, weight=1.E5))
else:
tgt = cs_target if name.startswith('CS') else 0.0
reg.append(mygs.coil_reg_term({name: 1.0}, target=tgt, weight=1.E-2))
reg.append(mygs.coil_reg_term({name: 1.0, coil_mirrors[name]: -1.0},
target=0.0, weight=1.E0))
mygs.set_coil_reg(reg_terms=reg)
mygs.set_targets(Ip=Ip_target, Ip_ratio=(1.0/beta_approx - 1.0))
mygs.set_isoflux(isoflux_pts)
mygs.set_saddles(None)
mygs.init_psi(0.2, 0.0, 0.08, 1.0, 0.0)
mygs.solve()
return mygs.psi_bounds[0]
cs_scan = np.linspace(0.0, cs_bound, 8)
psi_scan = np.array([solve_with_cs_bias(t) for t in cs_scan])
ibest = int(np.argmax(psi_scan))
print('psi_LCFS: zero-bias = {0:10.3E} maximized = {1:10.3E} [mWb/rad]'.format(
psi_scan[0]*1.E3, psi_scan[ibest]*1.E3))
print('best CS bias current = {0:10.3E}'.format(cs_scan[ibest]))
# Re-solve at the best bias so downstream cells use the maximized equilibrium
solve_with_cs_bias(cs_scan[ibest])
coil_currents, _ = mygs.get_coil_currents()
fig, ax = plt.subplots(1, 1)
ax.plot(cs_scan, psi_scan*1.E3, 'o-')
ax.axvline(cs_scan[ibest], color='k', ls=':')
ax.set_xlabel('CS bias current'); ax.set_ylabel(r'$\psi_{LCFS}$ [mWb/rad]')
_ = ax.set_title('Flux-swing maximization')
Starting non-linear GS solver
     1  4.8418E-02  3.6506E-02  1.5653E-05  2.0844E-01 -9.9305E-06 -0.0000E+00


/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/988288092.py:24: DeprecationWarning: `set_isoflux()` is deprecated, use `set_isoflux_constraints()` instead. This function will be removed in a future version.
  mygs.set_isoflux(isoflux_pts)
/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/988288092.py:25: DeprecationWarning: `set_saddles()` is deprecated, use `set_saddle_constraints()` instead. This function will be removed in a future version.
  mygs.set_saddles(None)


     2  5.4828E-02  3.8589E-02  4.2606E-06  2.0777E-01 -7.5875E-06 -0.0000E+00
     3  5.7395E-02  3.9384E-02  1.3790E-06  2.0755E-01 -7.0146E-06 -0.0000E+00
     4  5.8483E-02  3.9704E-02  5.1992E-07  2.0747E-01 -6.8365E-06 -0.0000E+00
 Timing:   3.8477999623864889E-002
   Source:     1.6958001069724560E-002
   Solve:      8.0989999696612358E-003
   Boundary:   9.1899931430816650E-004
   Other:      1.2501999270170927E-002
Starting non-linear GS solver
     1  4.8431E-02  3.6515E-02  1.5904E-05  2.0844E-01 -9.2441E-06 -0.0000E+00
     2  5.4843E-02  3.8598E-02  4.2324E-06  2.0777E-01 -6.8762E-06 -0.0000E+00
     3  5.7410E-02  3.9393E-02  1.3613E-06  2.0755E-01 -6.2918E-06 -0.0000E+00
     4  5.8499E-02  3.9714E-02  5.1522E-07  2.0747E-01 -6.1098E-06 -0.0000E+00
 Timing:   3.6767000332474709E-002
   Source:     1.6302999574691057E-002
   Solve:      7.0689995773136616E-003
   Boundary:   8.7000103667378426E-004
   Other:      1.2525000143796206E-002
Starting non-linear GS solver
     1  4.8444E-02  3.6524E-02  1.6158E-05  2.0844E-01 -8.5578E-06 -0.0000E+00
     2  5.4858E-02  3.8607E-02  4.2044E-06  2.0777E-01 -6.1650E-06 -0.0000E+00
     3  5.7426E-02  3.9402E-02  1.3442E-06  2.0755E-01 -5.5693E-06 -0.0000E+00
     4  5.8515E-02  3.9723E-02  5.1091E-07  2.0748E-01 -5.3832E-06 -0.0000E+00
 Timing:   3.6133000161498785E-002
   Source:     1.5830000396817923E-002
   Solve:      6.7030000500380993E-003
   Boundary:   9.2900078743696213E-004
   Other:      1.2670998927205801E-002
Starting non-linear GS solver
     1  4.8456E-02  3.6532E-02  1.6414E-05  2.0844E-01 -7.8718E-06 -0.0000E+00
     2  5.4873E-02  3.8616E-02  4.1767E-06  2.0778E-01 -5.4542E-06 -0.0000E+00
     3  5.7442E-02  3.9412E-02  1.3280E-06  2.0756E-01 -4.8471E-06 -0.0000E+00
     4  5.8531E-02  3.9732E-02  5.0718E-07  2.0748E-01 -4.6569E-06 -0.0000E+00
 Timing:   3.6399000324308872E-002
   Source:     1.5922999475151300E-002
   Solve:      6.7830001935362816E-003
   Boundary:   9.6800085157155991E-004
   Other:      1.2724999804049730E-002
Starting non-linear GS solver
     1  4.8469E-02  3.6541E-02  1.6671E-05  2.0844E-01 -7.1860E-06 -0.0000E+00
     2  5.4888E-02  3.8625E-02  4.1494E-06  2.0778E-01 -4.7437E-06 -0.0000E+00
     3  5.7457E-02  3.9421E-02  1.3126E-06  2.0756E-01 -4.1253E-06 -0.0000E+00
     4  5.8547E-02  3.9742E-02  5.0389E-07  2.0748E-01 -3.9310E-06 -0.0000E+00
 Timing:   3.5846000071614981E-002
   Source:     1.5581999905407429E-002
   Solve:      6.7280000075697899E-003
   Boundary:   9.1900071129202843E-004
   Other:      1.2616999447345734E-002
Starting non-linear GS solver
     1  4.8482E-02  3.6550E-02  1.6930E-05  2.0844E-01 -6.5002E-06 -0.0000E+00
     2  5.4903E-02  3.8635E-02  4.1221E-06  2.0778E-01 -4.0332E-06 -0.0000E+00
     3  5.7473E-02  3.9430E-02  1.2980E-06  2.0756E-01 -3.4031E-06 -0.0000E+00
     4  5.8562E-02  3.9751E-02  5.0109E-07  2.0748E-01 -3.2050E-06 -0.0000E+00
 Timing:   3.6028000060468912E-002
   Source:     1.5740000177174807E-002
   Solve:      6.7010000348091125E-003
   Boundary:   1.1560004204511642E-003
   Other:      1.2430999428033829E-002
Starting non-linear GS solver
     1  4.8495E-02  3.6559E-02  1.7191E-05  2.0845E-01 -5.8144E-06 -0.0000E+00
     2  5.4918E-02  3.8644E-02  4.0952E-06  2.0778E-01 -3.3224E-06 -0.0000E+00
     3  5.7488E-02  3.9440E-02  1.2843E-06  2.0756E-01 -2.6806E-06 -0.0000E+00
     4  5.8578E-02  3.9761E-02  4.9872E-07  2.0748E-01 -2.4789E-06 -0.0000E+00
 Timing:   3.5980999935418367E-002
   Source:     1.5635999385267496E-002
   Solve:      6.5390006639063358E-003
   Boundary:   1.0919999331235886E-003
   Other:      1.2713999953120947E-002
Starting non-linear GS solver
     1  4.8509E-02  3.6569E-02  1.7441E-05  2.0845E-01 -4.8889E-06 -0.0000E+00
     2  5.4935E-02  3.8654E-02  4.0467E-06  2.0778E-01 -2.3793E-06 -0.0000E+00
     3  5.7506E-02  3.9451E-02  1.2647E-06  2.0756E-01 -1.7281E-06 -0.0000E+00
     4  5.8597E-02  3.9771E-02  4.9556E-07  2.0749E-01 -1.5233E-06 -0.0000E+00
 Timing:   3.6410999950021505E-002
   Source:     1.5786000527441502E-002
   Solve:      6.6389995627105236E-003
   Boundary:   1.2759994715452194E-003
   Other:      1.2710000388324261E-002
psi_LCFS:  zero-bias =  2.977E-02   maximized =  4.870E+00 [mWb/rad]
best CS bias current =  1.000E+03
Starting non-linear GS solver
     1  4.8509E-02  3.6569E-02  1.7441E-05  2.0845E-01 -4.8889E-06 -0.0000E+00
     2  5.4935E-02  3.8654E-02  4.0467E-06  2.0778E-01 -2.3793E-06 -0.0000E+00
     3  5.7506E-02  3.9451E-02  1.2647E-06  2.0756E-01 -1.7281E-06 -0.0000E+00
     4  5.8597E-02  3.9771E-02  4.9556E-07  2.0749E-01 -1.5233E-06 -0.0000E+00
 Timing:   3.6464999895542860E-002
   Source:     1.5893999952822924E-002
   Solve:      6.5440000034868717E-003
   Boundary:   1.2300000526010990E-003
   Other:      1.2796999886631966E-002

Compute coils for vacuum null

# Set regularization weights
regularization_terms = []
for name, coil in mygs.coil_sets.items():
regularization_terms.append(mygs.coil_reg_term({name: 1.0},target=coil_currents[name],weight=1.E1))
# Pass regularization terms to TokaMaker
mygs.set_coil_reg(reg_terms=regularization_terms)
mygs.set_targets()
mygs.set_isoflux(None)
zero_field_pts = np.array([
[0.2,0.0],
[0.25,0.0],
[0.15,0.0],
[0.2,0.05],
[0.2,-0.05]
])
mygs.set_saddles(zero_field_pts)
mygs.solve(vacuum=True)
null_coil_currents, _ = mygs.get_coil_currents()
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  3.5791E-05  2.0552E-01  1.6438E-05 -0.0000E+00
     2  5.8597E-02  3.9771E-02  7.1582E-06  1.8841E-01  3.1520E-05 -0.0000E+00
     3  5.8597E-02  3.9771E-02  1.4316E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     4  5.8597E-02  3.9771E-02  2.8633E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   1.9315999932587147E-002
   Source:     0.0000000000000000     
   Solve:      6.7680003121495247E-003
   Boundary:   0.0000000000000000     
   Other:      1.2547999620437622E-002


/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/498142008.py:2: DeprecationWarning: `set_isoflux()` is deprecated, use `set_isoflux_constraints()` instead. This function will be removed in a future version.
  mygs.set_isoflux(None)
/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/498142008.py:10: DeprecationWarning: `set_saddles()` is deprecated, use `set_saddle_constraints()` instead. This function will be removed in a future version.
  mygs.set_saddles(zero_field_pts)
fig, ax = plt.subplots(1,1)
mygs.plot_machine(fig,ax,coil_colormap='seismic',coil_symmap=True,coil_scale=1.0E-3,coil_clabel=r'$I_{coil}$ [kA]')
mygs.plot_psi(fig,ax,normalized=False,xpoint_color=None,vacuum_nlevels=0,plasma_nlevels=60)
mygs.plot_constraints(fig,ax,saddle_color='tab:blue',saddle_marker='o')

We want these values to be below some threshold

These are the residual poloidal field magnitudes \(|B_{pol}|\) at the constraint points in the null region. They set the connection length \(L_c \propto B_\phi/|B_{pol}|\) — how far a freshly-ionized electron streams along the (nearly toroidal) field before drifting into a wall. A long connection length lets electrons circulate many times and ionize enough neutral gas to start the Townsend avalanche; a stray field that is too large short-circuits that and breakdown fails.

So a good null must stay below a threshold at every point in the region, typically \(|B_{pol}| \lesssim 1\)– \(2\) mT (10–20 G). The cell below sets that threshold explicitly, checks each constraint point against it, prints a pass/fail per point, and outlines any violating point in red.

# --- Threshold check on the null field ---------------------------------------
B_THRESHOLD = 2.0E-3 # max acceptable |B_pol| in the null region [T] (~20 G)
field_eval = mygs.get_field_eval('B')
Bp = []
for i in range(zero_field_pts.shape[0]):
B_tmp = field_eval.eval(zero_field_pts[i, :])
Bp.append(np.linalg.norm(B_tmp[[0, 2]]))
Bp = np.array(Bp)
passes = Bp <= B_THRESHOLD
print('Null-field threshold check (B_threshold = {0:.2f} mT):'.format(B_THRESHOLD*1.E3))
for i, (pt, b, ok) in enumerate(zip(zero_field_pts, Bp, passes)):
print(' pt {0} R={1:.3f} Z={2:+.3f} |B_pol| = {3:6.3f} mT {4}'.format(
i, pt[0], pt[1], b*1.E3, 'ok' if ok else 'ABOVE THRESHOLD'))
print('=> ' + ('ALL POINTS PASS' if passes.all() else 'SOME POINTS EXCEED THRESHOLD'))
fig, ax = plt.subplots(1, 1)
clf = ax.scatter(zero_field_pts[:, 0], zero_field_pts[:, 1], c=Bp*1.E3, marker='o',
s=160, cmap='viridis',
edgecolors=['k' if ok else 'red' for ok in passes], linewidths=2.5)
cb = fig.colorbar(clf); cb.set_label(r'$|B_{pol}|$ [mT]')
ax.set_xlabel('R [m]'); ax.set_ylabel('Z [m]')
_ = ax.set_title('Null field vs threshold = {0:.1f} mT'.format(B_THRESHOLD*1.E3))
Null-field threshold check  (B_threshold = 2.00 mT):
  pt 0  R=0.200  Z=+0.000   |B_pol| =  0.045 mT   ok
  pt 1  R=0.250  Z=+0.000   |B_pol| =  0.026 mT   ok
  pt 2  R=0.150  Z=+0.000   |B_pol| =  0.107 mT   ok
  pt 3  R=0.200  Z=+0.050   |B_pol| =  0.101 mT   ok
  pt 4  R=0.200  Z=-0.050   |B_pol| =  0.101 mT   ok
=> ALL POINTS PASS
print("Coil current change null -> plasma")
for key in coil_currents:
print(' {0} {1:12.3E}'.format(key, coil_currents[key]-null_coil_currents[key]))
Coil current change null -> plasma
  CS01   -4.246E-04
  CS02    0.000E+00
  CS03   -8.087E-04
  CS04    0.000E+00
  CS05   -1.712E-03
  CS06    0.000E+00
  CS07   -4.132E-03
  CS08    0.000E+00
  CS09   -5.844E-01
  CS10   -5.852E-01
  CS11   -5.274E-01
  CS12   -5.302E-01
  CS13    2.060E+00
  CS14    2.064E+00
  PF01   -2.243E-01
  PF02   -1.207E+00
  PF03   -1.181E+00
  PF04   -1.624E+00
  PF05   -2.057E+00
  PF06   -2.340E+00
  PF07   -2.516E+00
  PF08   -2.519E+00
  PF09   -2.346E+00
  PF10   -2.057E+00
  PF11   -1.627E+00
  PF12   -1.191E+00
  PF13   -1.185E+00
  PF14   -1.923E-01

Breakdown physics: will the gas actually break down?

A small \(|B_{pol}|\) at the null is necessary but not sufficient. Whether the prefilled gas avalanches into a plasma depends on two more things:

  • Connection length \(L_c \approx 0.25\,a\,B_\phi/B_{pol}\) — how far an ionized electron travels along the nearly-toroidal field before drifting to a wall. A small null field gives a long \(L_c\).
  • Townsend avalanche — driven by the toroidal loop-voltage field \(E_\phi\). For hydrogen the electron density grows as \(e^{\alpha L_c}\) with \(\alpha = A\,p\,e^{-Bp/E}\) ( \(A=510\ \mathrm{m^{-1}Pa^{-1}}\), \(B=1.25\times10^4\ \mathrm{V\,m^{-1}Pa^{-1}}\)). Requiring at least one e-folding, \(\alpha L_c \ge 1\), sets a minimum E-field (a Paschen-type curve): \(\)E_{min}(p) = \frac{B\,p}{\ln(A\,p\,L_c)}. \(\)

Breakdown succeeds when the available \(E_\phi = V_{loop}/(2\pi R)\) clears \(E_{min}\) for some prefill pressure near the Paschen minimum.

# --- Townsend / Paschen breakdown physics for hydrogen (Lloyd et al.) ---
TOWNSEND_A = 510.0 # m^-1 Pa^-1
TOWNSEND_B = 1.25e4 # V m^-1 Pa^-1
TORR_TO_PA = 133.322
F0_CUTE = 0.17 # R*B_phi [T*m] (matches the F0 passed to mygs.setup)
a_null = 0.08 # size of the low-field region ~ minor radius [m]
E_phi = 0.5 # toroidal E-field available from the OH ramp [V/m]
# (SHARED by the Paschen and Leuer/Etanga cells below)
def connection_length(B_pol, R, a=a_null):
"""Effective connection length L_c ~ 0.25 a (B_phi/B_pol) [m]."""
Bphi = F0_CUTE / R
return 0.25 * a * abs(Bphi) / max(float(B_pol), 1e-9)
def paschen_Emin(p_pa, L_c):
"""Minimum toroidal E-field for avalanche (alpha*L_c >= 1) [V/m]."""
arg = TOWNSEND_A * p_pa * L_c
return np.inf if arg <= 1.0 else TOWNSEND_B * p_pa / np.log(arg)
# Connection length from the WORST (largest) residual null field -> conservative.
L_c = connection_length(Bp.max(), 0.2)
# Operate at the Paschen-minimum prefill for this L_c (where arg = A*p*L_c = e),
# i.e. the pressure that minimises the required E-field. This is the fair point at
# which to compare against the (pressure-independent) Leuer criterion below.
p_min_pa = np.e / (TOWNSEND_A * L_c)
prefill_torr = p_min_pa / TORR_TO_PA
E_min = paschen_Emin(p_min_pa, L_c)
print('max |B_pol| at null = {0:.3f} mT -> connection length L_c = {1:.0f} m'.format(
Bp.max()*1e3, L_c))
print('Paschen-min prefill = {0:.2e} Torr E_min = {1:.2f} V/m (available E_phi = {2:.1f} V/m)'.format(
prefill_torr, E_min, E_phi))
print('=> ' + ('BREAKS DOWN' if E_phi >= E_min else 'NO breakdown: lower |B_pol| or raise E_phi'))
# --- Paschen curve: minimum E vs prefill pressure for a few connection lengths ---
p = np.logspace(-7, -3, 200)
fig, ax = plt.subplots(1, 1)
for Lc in [10, 50, 200]:
ax.plot(p*1e3, [paschen_Emin(pp*TORR_TO_PA, Lc) for pp in p], label='$L_c$ = {0} m'.format(Lc))
ax.axhline(E_phi, color='k', ls='--', label=r'$E_\phi$ = {0} V/m'.format(E_phi))
ax.axvline(prefill_torr*1e3, color='grey', ls=':')
ax.set_xscale('log'); ax.set_yscale('log'); ax.set_ylim(0.1, 500)
ax.set_xlabel('prefill pressure [mTorr]'); ax.set_ylabel('$E_{min}$ [V/m]')
_ = ax.legend()
max |B_pol| at null = 0.107 mT  ->  connection length L_c = 158 m
Paschen-min prefill = 2.52e-07 Torr   E_min = 0.42 V/m   (available E_phi = 0.5 V/m)
=> BREAKS DOWN

**Caveat on \(L_c\):** the factor \(0.25\) is a rough geometric constant. It makes the estimateb conservative (it under-predicts \(L_c\)): integrating an actual field line in the solved vacuum field gives a connection length several times longer. The breakdown verdict is unchanged, but treat the analytic \(L_c\) as a safe lower bound.

# --- Integrate the connection length along a field line ---
# The analytic L_c above uses the rough geometric factor 0.25. Here we follow an
# actual field line through the solved vacuum field, accumulating toroidal length
# until it drifts out of a region of radius a_null around the null.
def trace_Lc(R0, Z0, a_region=a_null, ds=5e-4, nmax=200000):
R, Z, Ltor = R0, Z0, 0.0
for _ in range(nmax):
B = field_eval.eval([R, Z]); BR, Bphi, BZ = B[0], B[1], B[2]
Bpol = np.hypot(BR, BZ)
if Bpol < 1e-12:
break
R += ds * BR / Bpol # step along the poloidal field direction
Z += ds * BZ / Bpol
Ltor += ds * abs(Bphi) / Bpol # toroidal (connection) length per step
if np.hypot(R - R0, Z - Z0) > a_region or R <= 0.02:
break
return Ltor
field_eval = mygs.get_field_eval('B')
starts = [(0.22, 0.0), (0.18, 0.0), (0.20, 0.02), (0.20, -0.02)] # ~2 cm off-null
Lc_traced = np.mean([trace_Lc(R, Z) for R, Z in starts])
print('connection length L_c:')
print(' analytic 0.25*a*Bphi/Bpol = {0:6.0f} m'.format(L_c))
print(' field-line integrated = {0:6.0f} m (mean of 4 starts ~2 cm off-null)'.format(Lc_traced))
connection length L_c:
  analytic  0.25*a*Bphi/Bpol =    158 m
  field-line integrated      =   1016 m   (mean of 4 starts ~2 cm off-null)

Optimizing the null location

The solver already finds the coil currents that null the field at the points we ask for. The remaining design freedom is where to put the null. Below we sweep the null center in \(R\) and re-solve, looking for the location where the coils make the smallest residual \(|B_{pol}|\) (and hence the longest connection length). This is a minimal 1-D version of what could be a full \((R,Z)\) grid-scan.

# Scan the null location: where can the coils make the cleanest null?
# (Re-solve the vacuum null with the stencil centered at a range of R; the coil
# regularization target is kept fixed from the plasma solve above — a simple,
# pedagogical 1-D version of the (R,Z) optimization done in production scripts.)
R_scan = np.linspace(0.16, 0.24, 9)
bpmax_scan, Lc_scan = [], []
for R0n in R_scan:
stencil = np.array([[R0n, 0.0], [R0n+0.05, 0.0], [R0n-0.05, 0.0],
[R0n, 0.05], [R0n, -0.05]])
mygs.set_targets()
mygs.set_isoflux(None)
mygs.set_saddles(stencil)
mygs.solve(vacuum=True)
fe = mygs.get_field_eval('B')
bp = np.array([np.linalg.norm(fe.eval(p)[[0, 2]]) for p in stencil])
bpmax_scan.append(bp.max())
Lc_scan.append(connection_length(bp.max(), R0n))
bpmax_scan, Lc_scan = np.array(bpmax_scan), np.array(Lc_scan)
ibest = int(np.argmin(bpmax_scan))
fig, ax1 = plt.subplots(1, 1)
ax1.plot(R_scan, bpmax_scan*1e3, 'o-', color='tab:red')
ax1.set_xlabel('null-center R [m]')
ax1.set_ylabel(r'max $|B_{pol}|$ [mT]', color='tab:red')
ax2 = ax1.twinx()
ax2.plot(R_scan, Lc_scan, 's--', color='tab:blue')
ax2.set_ylabel(r'connection length $L_c$ [m]', color='tab:blue')
ax1.axvline(R_scan[ibest], color='k', ls=':')
print('Cleanest null at R = {0:.3f} m: |B_pol| = {1:.2f} mT, L_c = {2:.0f} m'.format(
R_scan[ibest], bpmax_scan[ibest]*1e3, Lc_scan[ibest]))
# Restore the original null so later cells see the baseline state
mygs.set_targets(); mygs.set_isoflux(None)
mygs.set_saddles(zero_field_pts); mygs.solve(vacuum=True)
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  4.3088E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  8.6175E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   1.0154999792575836E-002
   Source:     0.0000000000000000     
   Solve:      3.3490001223981380E-003
   Boundary:   0.0000000000000000     
   Other:      6.8059996701776981E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  1.8125E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  3.6250E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   9.7640003077685833E-003
   Source:     0.0000000000000000     
   Solve:      3.2509998418390751E-003
   Boundary:   0.0000000000000000     
   Other:      6.5130004659295082E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  8.4874E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   5.8800000697374344E-003
   Source:     0.0000000000000000     
   Solve:      1.6509997658431530E-003
   Boundary:   0.0000000000000000     
   Other:      4.2290003038942814E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  9.4498E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   5.3199999965727329E-003
   Source:     0.0000000000000000     
   Solve:      1.4720000326633453E-003
   Boundary:   0.0000000000000000     
   Other:      3.8479999639093876E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  1.0791E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  2.1583E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   9.7759999334812164E-003
   Source:     0.0000000000000000     
   Solve:      3.1599998474121094E-003
   Boundary:   0.0000000000000000     
   Other:      6.6160000860691071E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  1.0360E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  2.0719E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   9.4190002419054508E-003
   Source:     0.0000000000000000     
   Solve:      2.9840003699064255E-003
   Boundary:   0.0000000000000000     
   Other:      6.4349998719990253E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  1.1228E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  2.2456E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   9.5569998957216740E-003
   Source:     0.0000000000000000     
   Solve:      3.0269999988377094E-003
   Boundary:   0.0000000000000000     
   Other:      6.5299998968839645E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  1.1782E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  2.3565E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   9.2670000158250332E-003
   Source:     0.0000000000000000     
   Solve:      2.9649999924004078E-003
   Boundary:   0.0000000000000000     
   Other:      6.3020000234246254E-003
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  1.2097E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  2.4193E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   9.6599999815225601E-003
   Source:     0.0000000000000000     
   Solve:      3.0609997920691967E-003
   Boundary:   0.0000000000000000     
   Other:      6.5990001894533634E-003
Cleanest null at R = 0.180 m:  |B_pol| = 0.10 mT,  L_c = 194 m
Starting non-linear GS solver
     1  5.8597E-02  3.9771E-02  4.3092E-06  5.0000E-01  0.0000E+00 -0.0000E+00
     2  5.8597E-02  3.9771E-02  8.6184E-07  5.0000E-01  0.0000E+00 -0.0000E+00
 Timing:   9.7829997539520264E-003
   Source:     0.0000000000000000     
   Solve:      3.0930000357329845E-003
   Boundary:   0.0000000000000000     
   Other:      6.6899997182190418E-003


/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/7961170.py:11: DeprecationWarning: `set_isoflux()` is deprecated, use `set_isoflux_constraints()` instead. This function will be removed in a future version.
  mygs.set_isoflux(None)
/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/7961170.py:12: DeprecationWarning: `set_saddles()` is deprecated, use `set_saddle_constraints()` instead. This function will be removed in a future version.
  mygs.set_saddles(stencil)
/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/7961170.py:33: DeprecationWarning: `set_isoflux()` is deprecated, use `set_isoflux_constraints()` instead. This function will be removed in a future version.
  mygs.set_targets(); mygs.set_isoflux(None)
/var/folders/77/9hnl3h2d5jq7v8mv35f7n_z40000gn/T/ipykernel_42417/7961170.py:34: DeprecationWarning: `set_saddles()` is deprecated, use `set_saddle_constraints()` instead. This function will be removed in a future version.
  mygs.set_saddles(zero_field_pts); mygs.solve(vacuum=True)





<OpenFUSIONToolkit.TokaMaker._core.TokaMaker_equilibrium at 0x1116317c0>

The Leuer breakdown criterion: \(E_\phi B_\phi / B_T\)

The connection-length picture above has a compact engineering form that is often applied in the tokamak-startup community (from Leuer, J. A., et al. "Plasma startup design of fully superconducting tokamaks EAST and KSTAR with implications for ITER." IEEE transactions on plasma science 38.3 (2010): 333-340). Two experimentally-calibrated conditions must hold in the breakdown region:

\(\)E_\phi \ge 0.3\ \mathrm{V/m\ (ohmic)},\qquad E_\phi \ge 0.15\ \mathrm{V/m\ (ECRF\text{-}assisted)} \tag{1} \(\) \(\)\frac{E_\phi\, B_\phi}{B_T} \ge 10^3\ \mathrm{V/m} \tag{2} \(\)

where \(E_\phi\) is the toroidal electric field (loop voltage \(V_{loop} = E_\phi\,2\pi R\)), \(B_\phi\) the toroidal field, and \(B_T\) the average stray poloidal field over the breakdown region. Criterion (2) is essentially \(E_\phi\) times the normalized connection length, since \(B_\phi/B_T \propto L_c/a\). It rewards both a strong loop voltage and a clean null at once. Below we evaluate both criteria at our null (using the same \(E_\phi\) as the Townsend/Paschen cell) and show how clean the null must be to pass (2).

Note: here \(B_T\) denotes the average stray poloidal field, computed as an area-average over the null region (not just the five constraint points, which the solver pins toward zero).

# --- Leuer / ITER breakdown criteria ("Etanga" = E_phi * B_phi / B_T) --------
# Uses the SAME E_phi defined in the Townsend/Paschen cell above.
ECRF_assist = False # True lowers the ohmic floor from 0.3 to 0.15 V/m
R_null = 0.2
# B_T = AVERAGE stray poloidal field over the null region. Average over an AREA
# (a disk of radius a_reg), not just the 5 saddle points, which the solver pins
# toward zero and therefore under-sample the field between them.
fe = mygs.get_field_eval('B')
a_reg = 0.05
B_T = float(np.mean([np.linalg.norm(fe.eval([r, z])[[0, 2]])
for r in np.linspace(R_null - a_reg, R_null + a_reg, 21)
for z in np.linspace(-a_reg, a_reg, 21)
if (r - R_null)**2 + z**2 <= a_reg**2 and r > 0]))
B_phi = F0_CUTE / R_null # toroidal field at the null [T]
V_loop = E_phi * 2*np.pi * R_null # loop voltage [V]
E_floor = 0.15 if ECRF_assist else 0.30
etanga = E_phi * B_phi / B_T # criterion (2) figure of merit [V/m]
E_phi_req = max(E_floor, 1.0e3 * B_T / B_phi) # min E_phi to satisfy BOTH criteria
print('Breakdown region: B_phi = {0:.3f} T B_T (avg stray) = {1:.3f} mT'.format(B_phi, B_T*1.E3))
print('(1) E_phi floor: {0:.2f} V/m (have {1:.2f}) -> {2}'.format(
E_floor, E_phi, 'OK' if E_phi >= E_floor else 'FAIL'))
print('(2) E_phi*B_phi/B_T = {0:7.0f} V/m (>= 1000 V/m) -> {1}'.format(
etanga, 'OK' if etanga >= 1.0E3 else 'FAIL'))
print(' V_loop = {0:.2f} V minimum E_phi for breakdown = {1:.2f} V/m'.format(V_loop, E_phi_req))
# Sensitivity / design target: how clean must the null (B_T) be to pass (2)?
B_T_scan = np.logspace(np.log10(B_T/10), np.log10(B_T*10), 100)
fig, ax = plt.subplots(1, 1)
ax.loglog(B_T_scan*1.E3, E_phi*B_phi/B_T_scan,
label=r'$E_\phi B_\phi/B_T$ at $E_\phi$={0} V/m'.format(E_phi))
ax.axhline(1.E3, color='k', ls='--', label=r'Leuer limit $10^3$ V/m')
ax.axvline(B_T*1.E3, color='tab:red', ls=':', label='this null')
ax.set_xlabel(r'$B_T$ (avg stray PF) [mT]'); ax.set_ylabel(r'$E_\phi B_\phi/B_T$ [V/m]')
_ = ax.legend()
Breakdown region:   B_phi = 0.850 T    B_T (avg stray) = 0.067 mT
(1) E_phi floor:    0.30 V/m  (have 0.50)        -> OK
(2) E_phi*B_phi/B_T =    6362 V/m  (>= 1000 V/m)  -> OK
    V_loop = 0.63 V    minimum E_phi for breakdown = 0.30 V/m