Example: Symmetry-reduced Pulse Design Tool (MAST-U-like)


This notebook demonstrates how to use SymmetryReducedSolver with the FreeGSNKE Pulse Design Tool (FPDT) on a MAST-U-like tokamak, evolving the coupled plasma/metal system strictly in the even-in-\(Z\) subspace. It repeats the closed-loop simulation of Example 12b on the MAST-U-like machine with the plasma-control-system (PCS) settings of Example 11, and adds a feedback-controlled sweep of the lower outer divertor strikepoint radius from a conventional position (\(R_{\mathrm{sp}} \approx 0.74\text{ m}\)) out to a Super-X configuration (\(R_{\mathrm{sp}} = 1.40\text{ m}\)).

This enables large timesteps to be taken (\(5\times\) larger than the \(0.5\text{ ms}\) timestep used in Example 11) for rapid prototyping of plasma scenarios.

In this notebook, we:

  1. Prepare an exactly up-down symmetric version of the MAST-U-like machine.

  2. Construct a symmetric initial Grad-Shafranov equilibrium.

  3. Build the virtual circuits for the PCS (including the lower outer strikepoint radius) and configure it with the settings of Example 11.

  4. Inspect the even and odd passive structure modes.

  5. Run a closed-loop FPDT simulation using SymmetryReducedSolver in place of nl_solver.

Note: the MAST-U-like machine is only approximately up-down symmetric, so symmetrising it changes the machine slightly. The vertical-control circuit P6 is electrically odd and is removed in the process, so this simulation has no active vertical control: the plasma is held on the midplane by the symmetry itself, and the vertical instability cannot be studied (see Example 11 for that).

1. Build the symmetrised MAST-U-like machine

We load the same MAST-U-like description as Example 11 and use prepare_up_down_symmetric_machine (see Example 12a) to turn it into an exactly up-down symmetric one. Three things are worth noting:

  • The active coils are series-connected upper/lower pairs, so each is already a single even circuit. The exception is P6, whose lower bundle has the opposite polarity: it is electrically odd, so we exclude it explicitly (exclude_odd_active=True).

  • The upper and lower passive structures, limiter, and wall agree only to a few millimetres, with a small common vertical offset. With z_midplane="auto" the offset is fitted and removed, and the paired elements are then averaged. Pairs are found automatically from their names and reflected geometry.

  • The limiter and wall are intersected with their reflections, which removes a small area (below 0.3%) from each.

import pickle
import time

import matplotlib.pyplot as plt
import numpy as np

from freegsnke import GSstaticsolver, build_machine, equilibrium_update
from freegsnke.jtor_update import Lao85
from freegsnke.up_down_symmetry import prepare_up_down_symmetric_machine
# load the (approximately symmetric) MAST-U-like machine description used in Example 11
machine_path = "../machine_configs/MAST-U/MAST-U_like_"
machine_data = {}
for part in ("active_coils", "passive_coils", "limiter", "wall"):
    with open(f"{machine_path}{part}.pickle", "rb") as file:
        machine_data[part] = pickle.load(file)

# exactly up-down symmetric machine data (the odd circuit P6 is excluded)
symmetric_machine = prepare_up_down_symmetric_machine(
    machine_data["active_coils"],
    machine_data["passive_coils"],
    limiter_data=machine_data["limiter"],
    wall_data=machine_data["wall"],
    z_midplane="auto",
    exclude_odd_active=True,
    verbose=True,
)
Retained active coil circuits (even): ('Solenoid', 'PX', 'D1', 'D2', 'D3', 'Dp', 'D5', 'D6', 'D7', 'P4', 'P5')
Explicitly excluded active circuits (odd): ('P6',)
Passive structure pairs (69):
  vessel_5 / vessel_4
  vessel_6 / vessel_3
  vessel_7 / vessel_2
  vessel_8 / vessel_1
  vessel_10 / vessel_9
  vessel_11 / vessel_17
  vessel_12 / vessel_18
  vessel_13 / vessel_19
  vessel_14 / vessel_20
  vessel_15 / vessel_21
  vessel_16 / vessel_22
  centrecolumn_2 / centrecolumn_1
  centrecolumn_4 / centrecolumn_3
  centrecolumn_7 / centrecolumn_6
  centrecolumn_8 / centrecolumn_5
  centrecolumn_10 / centrecolumn_9
  colosseum_upper_1 / colosseum_lower_1
  colosseum_upper_2 / colosseum_lower_2
  colosseum_upper_3 / colosseum_lower_3
  colosseum_outer_upper_1 / colosseum_outer_lower_1
  colosseum_outer_upper_2 / colosseum_outer_lower_2
  ring_plate_minor_upper_1 / ring_plate_minor_lower_1
  ring_plate_minor_upper_2 / ring_plate_minor_lower_2
  ring_plate_major_upper_1 / ring_plate_major_lower_1
  psp_upper_1 / psp_lower_1
  gas_baffle_upper_1 / gas_baffle_lower_1
  gas_baffle_upper_2 / gas_baffle_lower_2
  gas_baffle_upper_3 / gas_baffle_lower_3
  d1_case_upper_0 / d1_case_lower_0
  d1_case_upper_1 / d1_case_lower_2
  d1_case_upper_2 / d1_case_lower_1
  d1_case_upper_3 / d1_case_lower_3
  d2_case_upper_0 / d2_case_lower_0
  d2_case_upper_1 / d2_case_lower_2
  d2_case_upper_2 / d2_case_lower_1
  d2_case_upper_3 / d2_case_lower_3
  d3_case_upper_0 / d3_case_lower_0
  d3_case_upper_1 / d3_case_lower_2
  d3_case_upper_2 / d3_case_lower_1
  d3_case_upper_3 / d3_case_lower_3
  d5_case_upper_0 / d5_case_lower_0
  d5_case_upper_1 / d5_case_lower_2
  d5_case_upper_2 / d5_case_lower_1
  d5_case_upper_3 / d5_case_lower_3
  d6_case_upper_0 / d6_case_lower_0
  d6_case_upper_1 / d6_case_lower_1
  d6_case_upper_2 / d6_case_lower_2
  d6_case_upper_3 / d6_case_lower_3
  d7_case_upper_0 / d7_case_lower_0
  d7_case_upper_1 / d7_case_lower_1
  d7_case_upper_2 / d7_case_lower_2
  d7_case_upper_3 / d7_case_lower_3
  dp_case_upper_0 / dp_case_lower_0
  dp_case_upper_1 / dp_case_lower_1
  dp_case_upper_2 / dp_case_lower_2
  dp_case_upper_3 / dp_case_lower_3
  p4_case_upper_0 / p4_case_lower_0
  p4_case_upper_1 / p4_case_lower_1
  p4_case_upper_2 / p4_case_lower_2
  p4_case_upper_3 / p4_case_lower_3
  p5_case_upper_0 / p5_case_lower_1
  p5_case_upper_1 / p5_case_lower_0
  p5_case_upper_2 / p5_case_lower_2
  p5_case_upper_3 / p5_case_lower_3
  p6_case_upper_0 / p6_case_lower_0
  p6_case_upper_1 / p6_case_lower_1
  p6_case_upper_2 / p6_case_lower_2
  p6_case_upper_3 / p6_case_lower_3
  p6_case_upper_4 / p6_case_lower_4

Source midplane:             -1.292 mm
Applied whole-machine shift: +1.292 mm
Midplane fit RMS:            2.060 mm
Matched fit samples:         714
Active reflected pairs:      0
Component discrepancies (pre-averaging reflected RMS):
  passive  vessel_16          / vessel_22         :   9.667 mm
  passive  centrecolumn_7     / centrecolumn_6    :   9.417 mm
  passive  centrecolumn_8     / centrecolumn_5    :   9.417 mm
  passive  centrecolumn_10    / centrecolumn_9    :   9.417 mm
  passive  d1_case_upper_0    / d1_case_lower_0   :   9.417 mm
  passive  d1_case_upper_1    / d1_case_lower_2   :   9.417 mm
  passive  d1_case_upper_2    / d1_case_lower_1   :   9.417 mm
  passive  d1_case_upper_3    / d1_case_lower_3   :   9.417 mm
  passive  centrecolumn_2     / centrecolumn_1    :   9.417 mm
  passive  centrecolumn_4     / centrecolumn_3    :   9.416 mm
  passive  vessel_11          / vessel_17         :   8.632 mm
  passive  colosseum_upper_1  / colosseum_lower_1 :   8.582 mm
  passive  colosseum_upper_2  / colosseum_lower_2 :   8.582 mm
  passive  colosseum_upper_3  / colosseum_lower_3 :   8.582 mm
  passive  vessel_10          / vessel_9          :   8.267 mm
  passive  d2_case_upper_0    / d2_case_lower_0   :   7.416 mm
  passive  d2_case_upper_1    / d2_case_lower_2   :   7.416 mm
  passive  d2_case_upper_2    / d2_case_lower_1   :   7.416 mm
  passive  d2_case_upper_3    / d2_case_lower_3   :   7.416 mm
  passive  colosseum_outer_upper_2 / colosseum_outer_lower_2:   7.178 mm
  passive  colosseum_outer_upper_1 / colosseum_outer_lower_1:   7.177 mm
  passive  p4_case_upper_0    / p4_case_lower_0   :   7.117 mm
  passive  p4_case_upper_1    / p4_case_lower_1   :   7.117 mm
  passive  p4_case_upper_2    / p4_case_lower_2   :   7.117 mm
  passive  p4_case_upper_3    / p4_case_lower_3   :   7.117 mm
  passive  p5_case_upper_0    / p5_case_lower_1   :   7.117 mm
  passive  p5_case_upper_1    / p5_case_lower_0   :   7.117 mm
  passive  p5_case_upper_2    / p5_case_lower_2   :   7.116 mm
  passive  p5_case_upper_3    / p5_case_lower_3   :   7.116 mm
  passive  d3_case_upper_0    / d3_case_lower_0   :   5.416 mm
  passive  d3_case_upper_1    / d3_case_lower_2   :   5.416 mm
  passive  d3_case_upper_2    / d3_case_lower_1   :   5.416 mm
  passive  d3_case_upper_3    / d3_case_lower_3   :   5.416 mm
  passive  vessel_12          / vessel_18         :   5.355 mm
  passive  p6_case_upper_2    / p6_case_lower_2   :   2.902 mm
  passive  p6_case_upper_0    / p6_case_lower_0   :   2.722 mm
  passive  p6_case_upper_1    / p6_case_lower_1   :   2.722 mm
  passive  p6_case_upper_3    / p6_case_lower_3   :   2.722 mm
  passive  p6_case_upper_4    / p6_case_lower_4   :   2.722 mm
  active   Solenoid           / Solenoid          :   2.583 mm
  active   P5                 / P5                :   2.583 mm
  active   PX                 / PX                :   2.583 mm
  active   D1                 / D1                :   2.583 mm
  active   Dp                 / Dp                :   2.583 mm
  active   D5                 / D5                :   2.583 mm
  passive  d5_case_upper_0    / d5_case_lower_0   :   2.583 mm
  passive  d5_case_upper_1    / d5_case_lower_2   :   2.583 mm
  passive  d5_case_upper_2    / d5_case_lower_1   :   2.583 mm
  passive  d5_case_upper_3    / d5_case_lower_3   :   2.583 mm
  active   D2                 / D2                :   2.583 mm
  active   D3                 / D3                :   2.583 mm
  active   D6                 / D6                :   2.583 mm
  active   D7                 / D7                :   2.583 mm
  active   P4                 / P4                :   2.583 mm
  passive  vessel_13          / vessel_19         :   2.396 mm
  passive  vessel_14          / vessel_20         :   2.393 mm
  passive  vessel_15          / vessel_21         :   2.388 mm
  passive  gas_baffle_upper_1 / gas_baffle_lower_1:   2.017 mm
  passive  ring_plate_minor_upper_1 / ring_plate_minor_lower_1:   2.017 mm
  passive  ring_plate_minor_upper_2 / ring_plate_minor_lower_2:   2.017 mm
  passive  ring_plate_major_upper_1 / ring_plate_major_lower_1:   2.017 mm
  passive  psp_upper_1        / psp_lower_1       :   2.017 mm
  passive  gas_baffle_upper_2 / gas_baffle_lower_2:   2.017 mm
  passive  gas_baffle_upper_3 / gas_baffle_lower_3:   2.017 mm
  passive  d6_case_upper_0    / d6_case_lower_0   :   2.017 mm
  passive  d6_case_upper_1    / d6_case_lower_1   :   2.017 mm
  passive  d6_case_upper_2    / d6_case_lower_2   :   2.017 mm
  passive  d6_case_upper_3    / d6_case_lower_3   :   2.017 mm
  passive  d7_case_upper_0    / d7_case_lower_0   :   2.017 mm
  passive  d7_case_upper_1    / d7_case_lower_1   :   2.017 mm
  passive  d7_case_upper_2    / d7_case_lower_2   :   2.017 mm
  passive  d7_case_upper_3    / d7_case_lower_3   :   2.017 mm
  passive  dp_case_upper_0    / dp_case_lower_0   :   2.017 mm
  passive  dp_case_upper_1    / dp_case_lower_1   :   2.017 mm
  passive  dp_case_upper_2    / dp_case_lower_2   :   2.017 mm
  passive  dp_case_upper_3    / dp_case_lower_3   :   2.017 mm
  limiter  upper path         / lower path        :   1.987 mm
  wall     upper path         / lower path        :   1.938 mm
  passive  vessel_7           / vessel_2          :   1.584 mm
  passive  vessel_5           / vessel_4          :   1.584 mm
  passive  vessel_6           / vessel_3          :   1.584 mm
  passive  vessel_8           / vessel_1          :   1.583 mm
/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/freegsnke/up_down_symmetry.py:978: UserWarning: Limiter changed by intersection with its reflection about Z=0 m: removed 0.00584049 m² (0.187%); 47 -> 65 vertices.
  _warn_boundary_change(original, symmetric, target_midplane, name)
/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/freegsnke/up_down_symmetry.py:978: UserWarning: Wall changed by intersection with its reflection about Z=0 m: removed 0.0110878 m² (0.288%); 91 -> 115 vertices.
  _warn_boundary_change(original, symmetric, target_midplane, name)
# build machine
tokamak = build_machine.tokamak(
    active_coils_data=symmetric_machine.even_active_coils_data,
    passive_coils_data=symmetric_machine.passive_coils_data,
    limiter_data=symmetric_machine.limiter_data,
    wall_data=symmetric_machine.wall_data,
)
Active coils --> built from user-provided data.
Passive structures --> built from user-provided data.
Limiter --> built from user-provided data.
Wall --> built from user-provided data.
Magnetic probes --> none provided.
Resistance (R) and inductance (M) matrices --> built using actives (and passives if present).
Tokamak built.
/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/freegsnke/build_machine.py:575: UserWarning: Overlapping coil elements detected:
  - Solenoid[0] and Solenoid[1] (R=0.195 m, Z=-1.576 m, area=0.9853 cm^2)
  - Solenoid[1] and Solenoid[2] (R=0.195 m, Z=-1.566 m, area=0.9853 cm^2)
  - Solenoid[2] and Solenoid[3] (R=0.195 m, Z=-1.557 m, area=0.9853 cm^2)
  - Solenoid[3] and Solenoid[4] (R=0.195 m, Z=-1.547 m, area=0.9853 cm^2)
  - Solenoid[4] and Solenoid[5] (R=0.195 m, Z=-1.537 m, area=0.9853 cm^2)
  - Solenoid[5] and Solenoid[6] (R=0.195 m, Z=-1.527 m, area=0.9853 cm^2)
  - Solenoid[6] and Solenoid[7] (R=0.195 m, Z=-1.517 m, area=0.9853 cm^2)
  - Solenoid[7] and Solenoid[8] (R=0.195 m, Z=-1.508 m, area=0.9853 cm^2)
  - Solenoid[8] and Solenoid[9] (R=0.195 m, Z=-1.498 m, area=0.9853 cm^2)
  - Solenoid[9] and Solenoid[10] (R=0.195 m, Z=-1.488 m, area=0.9853 cm^2)
  - Solenoid[10] and Solenoid[11] (R=0.195 m, Z=-1.478 m, area=0.9853 cm^2)
  - Solenoid[11] and Solenoid[12] (R=0.195 m, Z=-1.468 m, area=0.9853 cm^2)
  - Solenoid[12] and Solenoid[13] (R=0.195 m, Z=-1.459 m, area=0.9853 cm^2)
  - Solenoid[13] and Solenoid[14] (R=0.195 m, Z=-1.449 m, area=0.9853 cm^2)
  - Solenoid[14] and Solenoid[15] (R=0.195 m, Z=-1.439 m, area=0.9853 cm^2)
  - Solenoid[15] and Solenoid[16] (R=0.195 m, Z=-1.429 m, area=0.9853 cm^2)
  - Solenoid[16] and Solenoid[17] (R=0.195 m, Z=-1.419 m, area=0.9853 cm^2)
  - Solenoid[17] and Solenoid[18] (R=0.195 m, Z=-1.410 m, area=0.9853 cm^2)
  - Solenoid[18] and Solenoid[19] (R=0.195 m, Z=-1.400 m, area=0.9853 cm^2)
  - Solenoid[19] and Solenoid[20] (R=0.195 m, Z=-1.390 m, area=0.9853 cm^2)
  - Solenoid[20] and Solenoid[21] (R=0.195 m, Z=-1.380 m, area=0.9853 cm^2)
  - Solenoid[21] and Solenoid[22] (R=0.195 m, Z=-1.371 m, area=0.9853 cm^2)
  - Solenoid[22] and Solenoid[23] (R=0.195 m, Z=-1.361 m, area=0.9853 cm^2)
  - Solenoid[23] and Solenoid[24] (R=0.195 m, Z=-1.351 m, area=0.9853 cm^2)
  - Solenoid[24] and Solenoid[25] (R=0.195 m, Z=-1.341 m, area=0.9853 cm^2)
  - Solenoid[25] and Solenoid[26] (R=0.195 m, Z=-1.331 m, area=0.9853 cm^2)
  - Solenoid[26] and Solenoid[27] (R=0.195 m, Z=-1.322 m, area=0.9853 cm^2)
  - Solenoid[27] and Solenoid[28] (R=0.195 m, Z=-1.312 m, area=0.9853 cm^2)
  - Solenoid[28] and Solenoid[29] (R=0.195 m, Z=-1.302 m, area=0.9853 cm^2)
  - Solenoid[29] and Solenoid[30] (R=0.195 m, Z=-1.292 m, area=0.9853 cm^2)
  - Solenoid[30] and Solenoid[31] (R=0.195 m, Z=-1.282 m, area=0.9853 cm^2)
  - Solenoid[31] and Solenoid[32] (R=0.195 m, Z=-1.273 m, area=0.9853 cm^2)
  - Solenoid[32] and Solenoid[33] (R=0.195 m, Z=-1.263 m, area=0.9853 cm^2)
  - Solenoid[33] and Solenoid[34] (R=0.195 m, Z=-1.253 m, area=0.9853 cm^2)
  - Solenoid[34] and Solenoid[35] (R=0.195 m, Z=-1.243 m, area=0.9853 cm^2)
  - Solenoid[35] and Solenoid[36] (R=0.195 m, Z=-1.233 m, area=0.9853 cm^2)
  - Solenoid[36] and Solenoid[37] (R=0.195 m, Z=-1.224 m, area=0.9853 cm^2)
  - Solenoid[37] and Solenoid[38] (R=0.195 m, Z=-1.214 m, area=0.9853 cm^2)
  - Solenoid[38] and Solenoid[39] (R=0.195 m, Z=-1.204 m, area=0.9853 cm^2)
  - Solenoid[39] and Solenoid[40] (R=0.195 m, Z=-1.194 m, area=0.9853 cm^2)
  - Solenoid[40] and Solenoid[41] (R=0.195 m, Z=-1.185 m, area=0.9853 cm^2)
  - Solenoid[41] and Solenoid[42] (R=0.195 m, Z=-1.175 m, area=0.9853 cm^2)
  - Solenoid[42] and Solenoid[43] (R=0.195 m, Z=-1.165 m, area=0.9853 cm^2)
  - Solenoid[43] and Solenoid[44] (R=0.195 m, Z=-1.155 m, area=0.9853 cm^2)
  - Solenoid[44] and Solenoid[45] (R=0.195 m, Z=-1.145 m, area=0.9853 cm^2)
  - Solenoid[45] and Solenoid[46] (R=0.195 m, Z=-1.136 m, area=0.9853 cm^2)
  - Solenoid[46] and Solenoid[47] (R=0.195 m, Z=-1.126 m, area=0.9853 cm^2)
  - Solenoid[47] and Solenoid[48] (R=0.195 m, Z=-1.116 m, area=0.9853 cm^2)
  - Solenoid[48] and Solenoid[49] (R=0.195 m, Z=-1.106 m, area=0.9853 cm^2)
  - Solenoid[49] and Solenoid[50] (R=0.195 m, Z=-1.096 m, area=0.9853 cm^2)
  - Solenoid[50] and Solenoid[51] (R=0.195 m, Z=-1.087 m, area=0.9853 cm^2)
  - Solenoid[51] and Solenoid[52] (R=0.195 m, Z=-1.077 m, area=0.9853 cm^2)
  - Solenoid[52] and Solenoid[53] (R=0.195 m, Z=-1.067 m, area=0.9853 cm^2)
  - Solenoid[53] and Solenoid[54] (R=0.195 m, Z=-1.057 m, area=0.9853 cm^2)
  - Solenoid[54] and Solenoid[55] (R=0.195 m, Z=-1.047 m, area=0.9853 cm^2)
  - Solenoid[55] and Solenoid[56] (R=0.195 m, Z=-1.038 m, area=0.9853 cm^2)
  - Solenoid[56] and Solenoid[57] (R=0.195 m, Z=-1.028 m, area=0.9853 cm^2)
  - Solenoid[57] and Solenoid[58] (R=0.195 m, Z=-1.018 m, area=0.9853 cm^2)
  - Solenoid[58] and Solenoid[59] (R=0.195 m, Z=-1.008 m, area=0.9853 cm^2)
  - Solenoid[59] and Solenoid[60] (R=0.195 m, Z=-0.999 m, area=0.9853 cm^2)
  - Solenoid[60] and Solenoid[61] (R=0.195 m, Z=-0.989 m, area=0.9853 cm^2)
  - Solenoid[61] and Solenoid[62] (R=0.195 m, Z=-0.979 m, area=0.9853 cm^2)
  - Solenoid[62] and Solenoid[63] (R=0.195 m, Z=-0.969 m, area=0.9853 cm^2)
  - Solenoid[63] and Solenoid[64] (R=0.195 m, Z=-0.959 m, area=0.9853 cm^2)
  - Solenoid[64] and Solenoid[65] (R=0.195 m, Z=-0.950 m, area=0.9853 cm^2)
  - Solenoid[65] and Solenoid[66] (R=0.195 m, Z=-0.940 m, area=0.9853 cm^2)
  - Solenoid[66] and Solenoid[67] (R=0.195 m, Z=-0.930 m, area=0.9853 cm^2)
  - Solenoid[67] and Solenoid[68] (R=0.195 m, Z=-0.920 m, area=0.9853 cm^2)
  - Solenoid[68] and Solenoid[69] (R=0.195 m, Z=-0.910 m, area=0.9853 cm^2)
  - Solenoid[69] and Solenoid[70] (R=0.195 m, Z=-0.901 m, area=0.9853 cm^2)
  - Solenoid[70] and Solenoid[71] (R=0.195 m, Z=-0.891 m, area=0.9853 cm^2)
  - Solenoid[71] and Solenoid[72] (R=0.195 m, Z=-0.881 m, area=0.9853 cm^2)
  - Solenoid[72] and Solenoid[73] (R=0.195 m, Z=-0.871 m, area=0.9853 cm^2)
  - Solenoid[73] and Solenoid[74] (R=0.195 m, Z=-0.861 m, area=0.9853 cm^2)
  - Solenoid[74] and Solenoid[75] (R=0.195 m, Z=-0.852 m, area=0.9853 cm^2)
  - Solenoid[75] and Solenoid[76] (R=0.195 m, Z=-0.842 m, area=0.9853 cm^2)
  - Solenoid[76] and Solenoid[77] (R=0.195 m, Z=-0.832 m, area=0.9853 cm^2)
  - Solenoid[77] and Solenoid[78] (R=0.195 m, Z=-0.822 m, area=0.9853 cm^2)
  - Solenoid[78] and Solenoid[79] (R=0.195 m, Z=-0.813 m, area=0.9853 cm^2)
  - Solenoid[79] and Solenoid[80] (R=0.195 m, Z=-0.803 m, area=0.9853 cm^2)
  - Solenoid[80] and Solenoid[81] (R=0.195 m, Z=-0.793 m, area=0.9853 cm^2)
  - Solenoid[81] and Solenoid[82] (R=0.195 m, Z=-0.783 m, area=0.9853 cm^2)
  - Solenoid[82] and Solenoid[83] (R=0.195 m, Z=-0.773 m, area=0.9853 cm^2)
  - Solenoid[83] and Solenoid[84] (R=0.195 m, Z=-0.764 m, area=0.9853 cm^2)
  - Solenoid[84] and Solenoid[85] (R=0.195 m, Z=-0.754 m, area=0.9853 cm^2)
  - Solenoid[85] and Solenoid[86] (R=0.195 m, Z=-0.744 m, area=0.9853 cm^2)
  - Solenoid[86] and Solenoid[87] (R=0.195 m, Z=-0.734 m, area=0.9853 cm^2)
  - Solenoid[87] and Solenoid[88] (R=0.195 m, Z=-0.724 m, area=0.9853 cm^2)
  - Solenoid[88] and Solenoid[89] (R=0.195 m, Z=-0.715 m, area=0.9853 cm^2)
  - Solenoid[89] and Solenoid[90] (R=0.195 m, Z=-0.705 m, area=0.9853 cm^2)
  - Solenoid[90] and Solenoid[91] (R=0.195 m, Z=-0.695 m, area=0.9853 cm^2)
  - Solenoid[91] and Solenoid[92] (R=0.195 m, Z=-0.685 m, area=0.9853 cm^2)
  - Solenoid[92] and Solenoid[93] (R=0.195 m, Z=-0.675 m, area=0.9853 cm^2)
  - Solenoid[93] and Solenoid[94] (R=0.195 m, Z=-0.666 m, area=0.9853 cm^2)
  - Solenoid[94] and Solenoid[95] (R=0.195 m, Z=-0.656 m, area=0.9853 cm^2)
  - Solenoid[95] and Solenoid[96] (R=0.195 m, Z=-0.646 m, area=0.9853 cm^2)
  - Solenoid[96] and Solenoid[97] (R=0.195 m, Z=-0.636 m, area=0.9853 cm^2)
  - Solenoid[97] and Solenoid[98] (R=0.195 m, Z=-0.627 m, area=0.9853 cm^2)
  - Solenoid[98] and Solenoid[99] (R=0.195 m, Z=-0.617 m, area=0.9853 cm^2)
  - Solenoid[99] and Solenoid[100] (R=0.195 m, Z=-0.607 m, area=0.9853 cm^2)
  - Solenoid[100] and Solenoid[101] (R=0.195 m, Z=-0.597 m, area=0.9853 cm^2)
  - Solenoid[101] and Solenoid[102] (R=0.195 m, Z=-0.587 m, area=0.9853 cm^2)
  - Solenoid[102] and Solenoid[103] (R=0.195 m, Z=-0.578 m, area=0.9853 cm^2)
  - Solenoid[103] and Solenoid[104] (R=0.195 m, Z=-0.568 m, area=0.9853 cm^2)
  - Solenoid[104] and Solenoid[105] (R=0.195 m, Z=-0.558 m, area=0.9853 cm^2)
  - Solenoid[105] and Solenoid[106] (R=0.195 m, Z=-0.548 m, area=0.9853 cm^2)
  - Solenoid[106] and Solenoid[107] (R=0.195 m, Z=-0.538 m, area=0.9853 cm^2)
  - Solenoid[107] and Solenoid[108] (R=0.195 m, Z=-0.529 m, area=0.9853 cm^2)
  - Solenoid[108] and Solenoid[109] (R=0.195 m, Z=-0.519 m, area=0.9853 cm^2)
  - Solenoid[109] and Solenoid[110] (R=0.195 m, Z=-0.509 m, area=0.9853 cm^2)
  - Solenoid[110] and Solenoid[111] (R=0.195 m, Z=-0.499 m, area=0.9853 cm^2)
  - Solenoid[111] and Solenoid[112] (R=0.195 m, Z=-0.489 m, area=0.9853 cm^2)
  - Solenoid[112] and Solenoid[113] (R=0.195 m, Z=-0.480 m, area=0.9853 cm^2)
  - Solenoid[113] and Solenoid[114] (R=0.195 m, Z=-0.470 m, area=0.9853 cm^2)
  - Solenoid[114] and Solenoid[115] (R=0.195 m, Z=-0.460 m, area=0.9853 cm^2)
  - Solenoid[115] and Solenoid[116] (R=0.195 m, Z=-0.450 m, area=0.9853 cm^2)
  - Solenoid[116] and Solenoid[117] (R=0.195 m, Z=-0.441 m, area=0.9853 cm^2)
  - Solenoid[117] and Solenoid[118] (R=0.195 m, Z=-0.431 m, area=0.9853 cm^2)
  - Solenoid[118] and Solenoid[119] (R=0.195 m, Z=-0.421 m, area=0.9853 cm^2)
  - Solenoid[119] and Solenoid[120] (R=0.195 m, Z=-0.411 m, area=0.9853 cm^2)
  - Solenoid[120] and Solenoid[121] (R=0.195 m, Z=-0.401 m, area=0.9853 cm^2)
  - Solenoid[121] and Solenoid[122] (R=0.195 m, Z=-0.392 m, area=0.9853 cm^2)
  - Solenoid[122] and Solenoid[123] (R=0.195 m, Z=-0.382 m, area=0.9853 cm^2)
  - Solenoid[123] and Solenoid[124] (R=0.195 m, Z=-0.372 m, area=0.9853 cm^2)
  - Solenoid[124] and Solenoid[125] (R=0.195 m, Z=-0.362 m, area=0.9853 cm^2)
  - Solenoid[125] and Solenoid[126] (R=0.195 m, Z=-0.352 m, area=0.9853 cm^2)
  - Solenoid[126] and Solenoid[127] (R=0.195 m, Z=-0.343 m, area=0.9853 cm^2)
  - Solenoid[127] and Solenoid[128] (R=0.195 m, Z=-0.333 m, area=0.9853 cm^2)
  - Solenoid[128] and Solenoid[129] (R=0.195 m, Z=-0.323 m, area=0.9853 cm^2)
  - Solenoid[129] and Solenoid[130] (R=0.195 m, Z=-0.313 m, area=0.9853 cm^2)
  - Solenoid[130] and Solenoid[131] (R=0.195 m, Z=-0.303 m, area=0.9853 cm^2)
  - Solenoid[131] and Solenoid[132] (R=0.195 m, Z=-0.294 m, area=0.9853 cm^2)
  - Solenoid[132] and Solenoid[133] (R=0.195 m, Z=-0.284 m, area=0.9853 cm^2)
  - Solenoid[133] and Solenoid[134] (R=0.195 m, Z=-0.274 m, area=0.9853 cm^2)
  - Solenoid[134] and Solenoid[135] (R=0.195 m, Z=-0.264 m, area=0.9853 cm^2)
  - Solenoid[135] and Solenoid[136] (R=0.195 m, Z=-0.255 m, area=0.9853 cm^2)
  - Solenoid[136] and Solenoid[137] (R=0.195 m, Z=-0.245 m, area=0.9853 cm^2)
  - Solenoid[137] and Solenoid[138] (R=0.195 m, Z=-0.235 m, area=0.9853 cm^2)
  - Solenoid[138] and Solenoid[139] (R=0.195 m, Z=-0.225 m, area=0.9853 cm^2)
  - Solenoid[139] and Solenoid[140] (R=0.195 m, Z=-0.215 m, area=0.9853 cm^2)
  - Solenoid[140] and Solenoid[141] (R=0.195 m, Z=-0.206 m, area=0.9853 cm^2)
  - Solenoid[141] and Solenoid[142] (R=0.195 m, Z=-0.196 m, area=0.9853 cm^2)
  - Solenoid[142] and Solenoid[143] (R=0.195 m, Z=-0.186 m, area=0.9853 cm^2)
  - Solenoid[143] and Solenoid[144] (R=0.195 m, Z=-0.176 m, area=0.9853 cm^2)
  - Solenoid[144] and Solenoid[145] (R=0.195 m, Z=-0.166 m, area=0.9853 cm^2)
  - Solenoid[145] and Solenoid[146] (R=0.195 m, Z=-0.157 m, area=0.9853 cm^2)
  - Solenoid[146] and Solenoid[147] (R=0.195 m, Z=-0.147 m, area=0.9853 cm^2)
  - Solenoid[147] and Solenoid[148] (R=0.195 m, Z=-0.137 m, area=0.9853 cm^2)
  - Solenoid[148] and Solenoid[149] (R=0.195 m, Z=-0.127 m, area=0.9853 cm^2)
  - Solenoid[149] and Solenoid[150] (R=0.195 m, Z=-0.117 m, area=0.9853 cm^2)
  - Solenoid[150] and Solenoid[151] (R=0.195 m, Z=-0.108 m, area=0.9853 cm^2)
  - Solenoid[151] and Solenoid[152] (R=0.195 m, Z=-0.098 m, area=0.9853 cm^2)
  - Solenoid[152] and Solenoid[153] (R=0.195 m, Z=-0.088 m, area=0.9853 cm^2)
  - Solenoid[153] and Solenoid[154] (R=0.195 m, Z=-0.078 m, area=0.9853 cm^2)
  - Solenoid[154] and Solenoid[155] (R=0.195 m, Z=-0.069 m, area=0.9853 cm^2)
  - Solenoid[155] and Solenoid[156] (R=0.195 m, Z=-0.059 m, area=0.9853 cm^2)
  - Solenoid[156] and Solenoid[157] (R=0.195 m, Z=-0.049 m, area=0.9853 cm^2)
  - Solenoid[157] and Solenoid[158] (R=0.195 m, Z=-0.039 m, area=0.9853 cm^2)
  - Solenoid[158] and Solenoid[159] (R=0.195 m, Z=-0.029 m, area=0.9853 cm^2)
  - Solenoid[159] and Solenoid[160] (R=0.195 m, Z=-0.020 m, area=0.9853 cm^2)
  - Solenoid[160] and Solenoid[161] (R=0.195 m, Z=-0.010 m, area=0.9853 cm^2)
  - Solenoid[161] and Solenoid[162] (R=0.195 m, Z=0.000 m, area=0.9853 cm^2)
  - Solenoid[162] and Solenoid[163] (R=0.195 m, Z=0.010 m, area=0.9853 cm^2)
  - Solenoid[163] and Solenoid[164] (R=0.195 m, Z=0.020 m, area=0.9853 cm^2)
  - Solenoid[164] and Solenoid[165] (R=0.195 m, Z=0.029 m, area=0.9853 cm^2)
  - Solenoid[165] and Solenoid[166] (R=0.195 m, Z=0.039 m, area=0.9853 cm^2)
  - Solenoid[166] and Solenoid[167] (R=0.195 m, Z=0.049 m, area=0.9853 cm^2)
  - Solenoid[167] and Solenoid[168] (R=0.195 m, Z=0.059 m, area=0.9853 cm^2)
  - Solenoid[168] and Solenoid[169] (R=0.195 m, Z=0.069 m, area=0.9853 cm^2)
  - Solenoid[169] and Solenoid[170] (R=0.195 m, Z=0.078 m, area=0.9853 cm^2)
  - Solenoid[170] and Solenoid[171] (R=0.195 m, Z=0.088 m, area=0.9853 cm^2)
  - Solenoid[171] and Solenoid[172] (R=0.195 m, Z=0.098 m, area=0.9853 cm^2)
  - Solenoid[172] and Solenoid[173] (R=0.195 m, Z=0.108 m, area=0.9853 cm^2)
  - Solenoid[173] and Solenoid[174] (R=0.195 m, Z=0.117 m, area=0.9853 cm^2)
  - Solenoid[174] and Solenoid[175] (R=0.195 m, Z=0.127 m, area=0.9853 cm^2)
  - Solenoid[175] and Solenoid[176] (R=0.195 m, Z=0.137 m, area=0.9853 cm^2)
  - Solenoid[176] and Solenoid[177] (R=0.195 m, Z=0.147 m, area=0.9853 cm^2)
  - Solenoid[177] and Solenoid[178] (R=0.195 m, Z=0.157 m, area=0.9853 cm^2)
  - Solenoid[178] and Solenoid[179] (R=0.195 m, Z=0.166 m, area=0.9853 cm^2)
  - Solenoid[179] and Solenoid[180] (R=0.195 m, Z=0.176 m, area=0.9853 cm^2)
  - Solenoid[180] and Solenoid[181] (R=0.195 m, Z=0.186 m, area=0.9853 cm^2)
  - Solenoid[181] and Solenoid[182] (R=0.195 m, Z=0.196 m, area=0.9853 cm^2)
  - Solenoid[182] and Solenoid[183] (R=0.195 m, Z=0.206 m, area=0.9853 cm^2)
  - Solenoid[183] and Solenoid[184] (R=0.195 m, Z=0.215 m, area=0.9853 cm^2)
  - Solenoid[184] and Solenoid[185] (R=0.195 m, Z=0.225 m, area=0.9853 cm^2)
  - Solenoid[185] and Solenoid[186] (R=0.195 m, Z=0.235 m, area=0.9853 cm^2)
  - Solenoid[186] and Solenoid[187] (R=0.195 m, Z=0.245 m, area=0.9853 cm^2)
  - Solenoid[187] and Solenoid[188] (R=0.195 m, Z=0.255 m, area=0.9853 cm^2)
  - Solenoid[188] and Solenoid[189] (R=0.195 m, Z=0.264 m, area=0.9853 cm^2)
  - Solenoid[189] and Solenoid[190] (R=0.195 m, Z=0.274 m, area=0.9853 cm^2)
  - Solenoid[190] and Solenoid[191] (R=0.195 m, Z=0.284 m, area=0.9853 cm^2)
  - Solenoid[191] and Solenoid[192] (R=0.195 m, Z=0.294 m, area=0.9853 cm^2)
  - Solenoid[192] and Solenoid[193] (R=0.195 m, Z=0.303 m, area=0.9853 cm^2)
  - Solenoid[193] and Solenoid[194] (R=0.195 m, Z=0.313 m, area=0.9853 cm^2)
  - Solenoid[194] and Solenoid[195] (R=0.195 m, Z=0.323 m, area=0.9853 cm^2)
  - Solenoid[195] and Solenoid[196] (R=0.195 m, Z=0.333 m, area=0.9853 cm^2)
  - Solenoid[196] and Solenoid[197] (R=0.195 m, Z=0.343 m, area=0.9853 cm^2)
  - Solenoid[197] and Solenoid[198] (R=0.195 m, Z=0.352 m, area=0.9853 cm^2)
  - Solenoid[198] and Solenoid[199] (R=0.195 m, Z=0.362 m, area=0.9853 cm^2)
  - Solenoid[199] and Solenoid[200] (R=0.195 m, Z=0.372 m, area=0.9853 cm^2)
  - Solenoid[200] and Solenoid[201] (R=0.195 m, Z=0.382 m, area=0.9853 cm^2)
  - Solenoid[201] and Solenoid[202] (R=0.195 m, Z=0.392 m, area=0.9853 cm^2)
  - Solenoid[202] and Solenoid[203] (R=0.195 m, Z=0.401 m, area=0.9853 cm^2)
  - Solenoid[203] and Solenoid[204] (R=0.195 m, Z=0.411 m, area=0.9853 cm^2)
  - Solenoid[204] and Solenoid[205] (R=0.195 m, Z=0.421 m, area=0.9853 cm^2)
  - Solenoid[205] and Solenoid[206] (R=0.195 m, Z=0.431 m, area=0.9853 cm^2)
  - Solenoid[206] and Solenoid[207] (R=0.195 m, Z=0.441 m, area=0.9853 cm^2)
  - Solenoid[207] and Solenoid[208] (R=0.195 m, Z=0.450 m, area=0.9853 cm^2)
  - Solenoid[208] and Solenoid[209] (R=0.195 m, Z=0.460 m, area=0.9853 cm^2)
  - Solenoid[209] and Solenoid[210] (R=0.195 m, Z=0.470 m, area=0.9853 cm^2)
  - Solenoid[210] and Solenoid[211] (R=0.195 m, Z=0.480 m, area=0.9853 cm^2)
  - Solenoid[211] and Solenoid[212] (R=0.195 m, Z=0.489 m, area=0.9853 cm^2)
  - Solenoid[212] and Solenoid[213] (R=0.195 m, Z=0.499 m, area=0.9853 cm^2)
  - Solenoid[213] and Solenoid[214] (R=0.195 m, Z=0.509 m, area=0.9853 cm^2)
  - Solenoid[214] and Solenoid[215] (R=0.195 m, Z=0.519 m, area=0.9853 cm^2)
  - Solenoid[215] and Solenoid[216] (R=0.195 m, Z=0.529 m, area=0.9853 cm^2)
  - Solenoid[216] and Solenoid[217] (R=0.195 m, Z=0.538 m, area=0.9853 cm^2)
  - Solenoid[217] and Solenoid[218] (R=0.195 m, Z=0.548 m, area=0.9853 cm^2)
  - Solenoid[218] and Solenoid[219] (R=0.195 m, Z=0.558 m, area=0.9853 cm^2)
  - Solenoid[219] and Solenoid[220] (R=0.195 m, Z=0.568 m, area=0.9853 cm^2)
  - Solenoid[220] and Solenoid[221] (R=0.195 m, Z=0.578 m, area=0.9853 cm^2)
  - Solenoid[221] and Solenoid[222] (R=0.195 m, Z=0.587 m, area=0.9853 cm^2)
  - Solenoid[222] and Solenoid[223] (R=0.195 m, Z=0.597 m, area=0.9853 cm^2)
  - Solenoid[223] and Solenoid[224] (R=0.195 m, Z=0.607 m, area=0.9853 cm^2)
  - Solenoid[224] and Solenoid[225] (R=0.195 m, Z=0.617 m, area=0.9853 cm^2)
  - Solenoid[225] and Solenoid[226] (R=0.195 m, Z=0.627 m, area=0.9853 cm^2)
  - Solenoid[226] and Solenoid[227] (R=0.195 m, Z=0.636 m, area=0.9853 cm^2)
  - Solenoid[227] and Solenoid[228] (R=0.195 m, Z=0.646 m, area=0.9853 cm^2)
  - Solenoid[228] and Solenoid[229] (R=0.195 m, Z=0.656 m, area=0.9853 cm^2)
  - Solenoid[229] and Solenoid[230] (R=0.195 m, Z=0.666 m, area=0.9853 cm^2)
  - Solenoid[230] and Solenoid[231] (R=0.195 m, Z=0.675 m, area=0.9853 cm^2)
  - Solenoid[231] and Solenoid[232] (R=0.195 m, Z=0.685 m, area=0.9853 cm^2)
  - Solenoid[232] and Solenoid[233] (R=0.195 m, Z=0.695 m, area=0.9853 cm^2)
  - Solenoid[233] and Solenoid[234] (R=0.195 m, Z=0.705 m, area=0.9853 cm^2)
  - Solenoid[234] and Solenoid[235] (R=0.195 m, Z=0.715 m, area=0.9853 cm^2)
  - Solenoid[235] and Solenoid[236] (R=0.195 m, Z=0.724 m, area=0.9853 cm^2)
  - Solenoid[236] and Solenoid[237] (R=0.195 m, Z=0.734 m, area=0.9853 cm^2)
  - Solenoid[237] and Solenoid[238] (R=0.195 m, Z=0.744 m, area=0.9853 cm^2)
  - Solenoid[238] and Solenoid[239] (R=0.195 m, Z=0.754 m, area=0.9853 cm^2)
  - Solenoid[239] and Solenoid[240] (R=0.195 m, Z=0.764 m, area=0.9853 cm^2)
  - Solenoid[240] and Solenoid[241] (R=0.195 m, Z=0.773 m, area=0.9853 cm^2)
  - Solenoid[241] and Solenoid[242] (R=0.195 m, Z=0.783 m, area=0.9853 cm^2)
  - Solenoid[242] and Solenoid[243] (R=0.195 m, Z=0.793 m, area=0.9853 cm^2)
  - Solenoid[243] and Solenoid[244] (R=0.195 m, Z=0.803 m, area=0.9853 cm^2)
  - Solenoid[244] and Solenoid[245] (R=0.195 m, Z=0.813 m, area=0.9853 cm^2)
  - Solenoid[245] and Solenoid[246] (R=0.195 m, Z=0.822 m, area=0.9853 cm^2)
  - Solenoid[246] and Solenoid[247] (R=0.195 m, Z=0.832 m, area=0.9853 cm^2)
  - Solenoid[247] and Solenoid[248] (R=0.195 m, Z=0.842 m, area=0.9853 cm^2)
  - Solenoid[248] and Solenoid[249] (R=0.195 m, Z=0.852 m, area=0.9853 cm^2)
  - Solenoid[249] and Solenoid[250] (R=0.195 m, Z=0.861 m, area=0.9853 cm^2)
  - Solenoid[250] and Solenoid[251] (R=0.195 m, Z=0.871 m, area=0.9853 cm^2)
  - Solenoid[251] and Solenoid[252] (R=0.195 m, Z=0.881 m, area=0.9853 cm^2)
  - Solenoid[252] and Solenoid[253] (R=0.195 m, Z=0.891 m, area=0.9853 cm^2)
  - Solenoid[253] and Solenoid[254] (R=0.195 m, Z=0.901 m, area=0.9853 cm^2)
  - Solenoid[254] and Solenoid[255] (R=0.195 m, Z=0.910 m, area=0.9853 cm^2)
  - Solenoid[255] and Solenoid[256] (R=0.195 m, Z=0.920 m, area=0.9853 cm^2)
  - Solenoid[256] and Solenoid[257] (R=0.195 m, Z=0.930 m, area=0.9853 cm^2)
  - Solenoid[257] and Solenoid[258] (R=0.195 m, Z=0.940 m, area=0.9853 cm^2)
  - Solenoid[258] and Solenoid[259] (R=0.195 m, Z=0.950 m, area=0.9853 cm^2)
  - Solenoid[259] and Solenoid[260] (R=0.195 m, Z=0.959 m, area=0.9853 cm^2)
  - Solenoid[260] and Solenoid[261] (R=0.195 m, Z=0.969 m, area=0.9853 cm^2)
  - Solenoid[261] and Solenoid[262] (R=0.195 m, Z=0.979 m, area=0.9853 cm^2)
  - Solenoid[262] and Solenoid[263] (R=0.195 m, Z=0.989 m, area=0.9853 cm^2)
  - Solenoid[263] and Solenoid[264] (R=0.195 m, Z=0.999 m, area=0.9853 cm^2)
  - Solenoid[264] and Solenoid[265] (R=0.195 m, Z=1.008 m, area=0.9853 cm^2)
  - Solenoid[265] and Solenoid[266] (R=0.195 m, Z=1.018 m, area=0.9853 cm^2)
  - Solenoid[266] and Solenoid[267] (R=0.195 m, Z=1.028 m, area=0.9853 cm^2)
  - Solenoid[267] and Solenoid[268] (R=0.195 m, Z=1.038 m, area=0.9853 cm^2)
  - Solenoid[268] and Solenoid[269] (R=0.195 m, Z=1.047 m, area=0.9853 cm^2)
  - Solenoid[269] and Solenoid[270] (R=0.195 m, Z=1.057 m, area=0.9853 cm^2)
  - Solenoid[270] and Solenoid[271] (R=0.195 m, Z=1.067 m, area=0.9853 cm^2)
  - Solenoid[271] and Solenoid[272] (R=0.195 m, Z=1.077 m, area=0.9853 cm^2)
  - Solenoid[272] and Solenoid[273] (R=0.195 m, Z=1.087 m, area=0.9853 cm^2)
  - Solenoid[273] and Solenoid[274] (R=0.195 m, Z=1.096 m, area=0.9853 cm^2)
  - Solenoid[274] and Solenoid[275] (R=0.195 m, Z=1.106 m, area=0.9853 cm^2)
  - Solenoid[275] and Solenoid[276] (R=0.195 m, Z=1.116 m, area=0.9853 cm^2)
  - Solenoid[276] and Solenoid[277] (R=0.195 m, Z=1.126 m, area=0.9853 cm^2)
  - Solenoid[277] and Solenoid[278] (R=0.195 m, Z=1.136 m, area=0.9853 cm^2)
  - Solenoid[278] and Solenoid[279] (R=0.195 m, Z=1.145 m, area=0.9853 cm^2)
  - Solenoid[279] and Solenoid[280] (R=0.195 m, Z=1.155 m, area=0.9853 cm^2)
  - Solenoid[280] and Solenoid[281] (R=0.195 m, Z=1.165 m, area=0.9853 cm^2)
  - Solenoid[281] and Solenoid[282] (R=0.195 m, Z=1.175 m, area=0.9853 cm^2)
  - Solenoid[282] and Solenoid[283] (R=0.195 m, Z=1.185 m, area=0.9853 cm^2)
  - Solenoid[283] and Solenoid[284] (R=0.195 m, Z=1.194 m, area=0.9853 cm^2)
  - Solenoid[284] and Solenoid[285] (R=0.195 m, Z=1.204 m, area=0.9853 cm^2)
  - Solenoid[285] and Solenoid[286] (R=0.195 m, Z=1.214 m, area=0.9853 cm^2)
  - Solenoid[286] and Solenoid[287] (R=0.195 m, Z=1.224 m, area=0.9853 cm^2)
  - Solenoid[287] and Solenoid[288] (R=0.195 m, Z=1.233 m, area=0.9853 cm^2)
  - Solenoid[288] and Solenoid[289] (R=0.195 m, Z=1.243 m, area=0.9853 cm^2)
  - Solenoid[289] and Solenoid[290] (R=0.195 m, Z=1.253 m, area=0.9853 cm^2)
  - Solenoid[290] and Solenoid[291] (R=0.195 m, Z=1.263 m, area=0.9853 cm^2)
  - Solenoid[291] and Solenoid[292] (R=0.195 m, Z=1.273 m, area=0.9853 cm^2)
  - Solenoid[292] and Solenoid[293] (R=0.195 m, Z=1.282 m, area=0.9853 cm^2)
  - Solenoid[293] and Solenoid[294] (R=0.195 m, Z=1.292 m, area=0.9853 cm^2)
  - Solenoid[294] and Solenoid[295] (R=0.195 m, Z=1.302 m, area=0.9853 cm^2)
  - Solenoid[295] and Solenoid[296] (R=0.195 m, Z=1.312 m, area=0.9853 cm^2)
  - Solenoid[296] and Solenoid[297] (R=0.195 m, Z=1.322 m, area=0.9853 cm^2)
  - Solenoid[297] and Solenoid[298] (R=0.195 m, Z=1.331 m, area=0.9853 cm^2)
  - Solenoid[298] and Solenoid[299] (R=0.195 m, Z=1.341 m, area=0.9853 cm^2)
  - Solenoid[299] and Solenoid[300] (R=0.195 m, Z=1.351 m, area=0.9853 cm^2)
  - Solenoid[300] and Solenoid[301] (R=0.195 m, Z=1.361 m, area=0.9853 cm^2)
  - Solenoid[301] and Solenoid[302] (R=0.195 m, Z=1.371 m, area=0.9853 cm^2)
  - Solenoid[302] and Solenoid[303] (R=0.195 m, Z=1.380 m, area=0.9853 cm^2)
  - Solenoid[303] and Solenoid[304] (R=0.195 m, Z=1.390 m, area=0.9853 cm^2)
  - Solenoid[304] and Solenoid[305] (R=0.195 m, Z=1.400 m, area=0.9853 cm^2)
  - Solenoid[305] and Solenoid[306] (R=0.195 m, Z=1.410 m, area=0.9853 cm^2)
  - Solenoid[306] and Solenoid[307] (R=0.195 m, Z=1.419 m, area=0.9853 cm^2)
  - Solenoid[307] and Solenoid[308] (R=0.195 m, Z=1.429 m, area=0.9853 cm^2)
  - Solenoid[308] and Solenoid[309] (R=0.195 m, Z=1.439 m, area=0.9853 cm^2)
  - Solenoid[309] and Solenoid[310] (R=0.195 m, Z=1.449 m, area=0.9853 cm^2)
  - Solenoid[310] and Solenoid[311] (R=0.195 m, Z=1.459 m, area=0.9853 cm^2)
  - Solenoid[311] and Solenoid[312] (R=0.195 m, Z=1.468 m, area=0.9853 cm^2)
  - Solenoid[312] and Solenoid[313] (R=0.195 m, Z=1.478 m, area=0.9853 cm^2)
  - Solenoid[313] and Solenoid[314] (R=0.195 m, Z=1.488 m, area=0.9853 cm^2)
  - Solenoid[314] and Solenoid[315] (R=0.195 m, Z=1.498 m, area=0.9853 cm^2)
  - Solenoid[315] and Solenoid[316] (R=0.195 m, Z=1.508 m, area=0.9853 cm^2)
  - Solenoid[316] and Solenoid[317] (R=0.195 m, Z=1.517 m, area=0.9853 cm^2)
  - Solenoid[317] and Solenoid[318] (R=0.195 m, Z=1.527 m, area=0.9853 cm^2)
  - Solenoid[318] and Solenoid[319] (R=0.195 m, Z=1.537 m, area=0.9853 cm^2)
  - Solenoid[319] and Solenoid[320] (R=0.195 m, Z=1.547 m, area=0.9853 cm^2)
  - Solenoid[320] and Solenoid[321] (R=0.195 m, Z=1.557 m, area=0.9853 cm^2)
  - Solenoid[321] and Solenoid[322] (R=0.195 m, Z=1.566 m, area=0.9853 cm^2)
  - Solenoid[322] and Solenoid[323] (R=0.195 m, Z=1.576 m, area=0.9853 cm^2)
  _report_overlaps(deferred_overlaps, strict_overlap_check=False)
# plot machine (notice the P6 coils now missing, around (R,Z)=(1.25, +/-1.1))
fig, ax = plt.subplots(figsize=(4, 8), dpi=80)
tokamak.plot(axis=ax, show=False)
ax.plot(tokamak.limiter.R, tokamak.limiter.Z, "k-", linewidth=1.2)
ax.set(xlabel="Major radius, R [m]", ylabel="Height, Z [m]", aspect="equal")
ax.grid(zorder=0, alpha=0.75)
plt.show()
../_images/c3c7d6798abf51f9e6a37a42d761a83805f3fbd99bbfa5b2a1d6b4826851e7cc.png

2. Construct a symmetric initial equilibrium

Symmetrising the machine changes it slightly, so the initial equilibrium of Example 11 must be solved again on the new machine. The upper and lower coils of every retained circuit are in series, so the circuit currents of Example 11 (and hence the PCS current limits defined for them) apply unchanged, and we simply repeat its forward solve with the same currents and plasma profiles, forcing the solution to be even in \(Z\). (An inverse solve would also work, but would need new shape constraints and would give different coil currents.) The tiny current in P6 is dropped with the circuit.

# initialise eq (same grid as Example 11)
eq = equilibrium_update.Equilibrium(
    tokamak=tokamak,
    Rmin=0.1,
    Rmax=2.0,
    Zmin=-2.2,
    Zmax=2.2,
    nx=65,
    ny=65,
)

# initialise profiles (same as Example 11)
profiles = Lao85(
    eq=eq,
    Ip=7.59e5,
    fvac=-0.52,
    alpha=[362685, 17696],
    beta=[0.103, 0.753],
    alpha_logic=True,
    beta_logic=True,
)

# initial coil currents (same as Example 11; the passive structures start with no current)
coil_currents = np.array(
    [
        2766.10782056, 193.12768191, 4019.86873871, 4857.42357466,
        -726.99282376, -1696.92521166, -77.7252396, 266.38207493,
        -73.01483716, -4169.86874271, -4518.28147417,
    ]
)
active_coils = list(tokamak.coils_list[: tokamak.n_active_coils])
for name, current in zip(active_coils, coil_currents):
    tokamak.set_coil_current(coil_label=name, current_value=current)

# static solver
static_solver = GSstaticsolver.NKGSsolver(eq)
# the numerical operators need exactly up-down symmetric resistances and inductances, so these calls enforce this
eq._vgreen = symmetric_machine.symmetrise_even_machine_greens(eq._vgreen)
tokamak.coil_resist = symmetric_machine.symmetrise_even_machine_resistances(
    tokamak.coil_resist
)
tokamak.coil_self_ind = symmetric_machine.symmetrise_even_machine_square_operator(
    tokamak.coil_self_ind
)
# solve for the equilibrium (even in Z)
static_solver.solve(
    eq=eq,
    profiles=profiles,
    constrain=None,
    target_relative_tolerance=1e-8,
    force_up_down_symmetric=True,
    verbose=False,
)
Forward static solve SUCCESS. Tolerance 2.79e-09 (vs. requested 1.00e-08) reached in 24/100 iterations.

We should have a nice up-down symmetric, diverted equilibrium in the symmetric machine, with the same X-point radius, inner/outer radii, and coil currents as Example 11.

# plot the equilibrium
fig1, ax1 = plt.subplots(1, 1, figsize=(4, 8), dpi=80)
ax1.grid(zorder=0, alpha=0.75)
ax1.set_aspect("equal")
eq.tokamak.plot(axis=ax1, show=False)                                                          # plots the active coils and passive structures
ax1.fill(tokamak.wall.R, tokamak.wall.Z, color="k", linewidth=1.2, facecolor="w", zorder=0)    # plots the limiter
eq.plot(axis=ax1, show=False)                                                                  # plots the equilibrium
ax1.set_xlim(0.1, 2.15)
ax1.set_ylim(-2.25, 2.25)
plt.tight_layout()
plt.show()
../_images/3accdd3260e2fc3f2e4918cd93b9e87ea74902fe276c25047f5ecbe92e33d12a.png

If needed we can do some checks to ensure everything is fully up-down symmetric (i.e. machine operators commute with the metal-current reflection, the limiter mask is reflection-invariant, and the initial plasma fields and metal currents are even to round-off).

passive_reflection_operator = symmetric_machine.passive_reflection_operator
reflection_operator = symmetric_machine.even_machine_reflection_operator


def relative_reflection_error(values, parity=1):
    denominator = np.linalg.norm(values)
    if denominator == 0:
        return 0.0
    return np.linalg.norm(values - parity * values[:, ::-1]) / denominator


def relative_commutator_error(matrix):
    numerator = np.linalg.norm(
        reflection_operator @ matrix - matrix @ reflection_operator
    )
    return numerator / np.linalg.norm(matrix)


reflected_greens = np.einsum(
    "ij,jrz->irz", reflection_operator, eq._vgreen[:, :, ::-1]
)
resistance_matrix = np.diag(tokamak.coil_resist)
initial_currents = tokamak.getCurrentsVec()
symmetry_errors = {
    "sampled Green functions": (
        np.linalg.norm(eq._vgreen - reflected_greens)
        / np.linalg.norm(eq._vgreen)
    ),
    "inductance operator": relative_commutator_error(tokamak.coil_self_ind),
    "resistance operator": relative_commutator_error(resistance_matrix),
    "plasma flux": relative_reflection_error(eq.plasma_psi),
    "toroidal current density": relative_reflection_error(profiles.jtor),
    "metal currents": (
        np.linalg.norm(reflection_operator @ initial_currents - initial_currents)
        / np.linalg.norm(initial_currents)
    ),
}
limiter_defects = np.count_nonzero(
    eq.limiter_handler.mask_inside_limiter
    != eq.limiter_handler.mask_inside_limiter[:, ::-1]
)

for name, error in symmetry_errors.items():
    print(f"{name:27s}: {error:.3e}")
print(f"{'limiter-mask defects':27s}: {limiter_defects}")
assert max(symmetry_errors.values()) < 1e-12
assert limiter_defects == 0
sampled Green functions    : 0.000e+00
inductance operator        : 0.000e+00
resistance operator        : 0.000e+00
plasma flux                : 0.000e+00
toroidal current density   : 0.000e+00
metal currents             : 0.000e+00
limiter-mask defects       : 0

3. Build the virtual circuits for the PCS

We use FreeGSNKE’s VirtualCircuitHandling class (see Example 09) to build the virtual circuits (VCs) for the ten shaping circuits (all circuits except the solenoid). It computes, by finite differences of static GS solves, the shape sensitivity matrix

\[ S_{kj} = \frac{\partial s_k}{\partial I_j}, \]

where \(s_k\) are the shape targets (Rin, Rout, Rx, Zx, Rsp, defined below) and \(I_j\) the shaping-circuit currents, and its pseudo-inverse \(S^+\) (the VCs), which maps requested shape corrections to coil-current commands. The solenoid is excluded because it is reserved for plasma-current control.

In addition to the four shape targets of Example 11 (Rin, Rout, Rx, Zx), we include the radial position of the lower outer divertor strikepoint, Rsp. To extract it from an equilibrium object, lower_outer_strikepoint(equilibrium) calls equilibrium.strikepoints(), which returns the \((R, Z)\) intersections of the \(\psi_{\mathrm{boundary}}\) contour with tokamak.wall. For a symmetric double-null diverted plasma this returns four points (inner and outer strikepoints in the lower and upper divertors); filtering to the lower divertor (\(Z < 0\)) and taking the point with largest \(R\) selects the lower outer divertor tile intersection.

def lower_outer_strikepoint(equilibrium):
    """Return the (R, Z) coordinates of the lower outer divertor strikepoint."""
    strikes = np.atleast_2d(equilibrium.strikepoints())
    lower_strikes = strikes[strikes[:, 1] < 0.0]
    return lower_strikes[np.argmax(lower_strikes[:, 0])]


# functions for the plasma descriptors (shape functions), extending Example 11 with Rsp
def plasma_descriptors(equilibrium):
    """Return the five shape measurements used by the controller: Rin, Rout, Rx, Zx, Rsp."""
    # inboard/outboard midplane radii
    rin_rout = equilibrium.innerOuterSeparatrix()

    # find the lower X-point: define a "box" in which to search for it
    xpt_box = [[0.33, -0.88], [0.95, -1.38]]
    xpt_mask = (
        (equilibrium.xpt[:, 0] >= xpt_box[0][0])
        & (equilibrium.xpt[:, 0] <= xpt_box[1][0])
        & (equilibrium.xpt[:, 1] <= xpt_box[0][1])
        & (equilibrium.xpt[:, 1] >= xpt_box[1][1])
    )
    xpts = equilibrium.xpt[xpt_mask, 0:2].reshape(-1, 2)
    # if there is more than one candidate, take the one closest to the O-point
    nearest = np.argmin(np.linalg.norm(xpts - equilibrium.opt[0, 0:2], axis=1))
    rx, zx = xpts[nearest]

    # lower outer divertor strikepoint radius
    rsp, _ = lower_outer_strikepoint(equilibrium)

    return np.array([rin_rout[0], rin_rout[1], rx, zx, rsp])


# names of the shape targets
ctrl_targets = ["Rin", "Rout", "Rx", "Zx", "Rsp"]

# calculate initial values
baseline_descriptors = plasma_descriptors(eq)

print("Active circuit order:", active_coils)
print("Shape parameters:", ctrl_targets)
print("Initial descriptors [m]:", baseline_descriptors)
Active circuit order: ['Solenoid', 'PX', 'D1', 'D2', 'D3', 'Dp', 'D5', 'D6', 'D7', 'P4', 'P5']
Shape parameters: ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp']
Initial descriptors [m]: [ 0.27669134  1.34637225  0.56703207 -1.24545327  0.74024081]
from freegsnke import virtual_circuits

# build the VCs (all shape targets are included in the calculation, the solenoid is excluded)
shape_coils = active_coils[1:]
VCs = virtual_circuits.VirtualCircuitHandling()
VCs.define_solver(static_solver)
VCs.calculate_VC(
    eq=eq,
    profiles=profiles,
    coils=shape_coils,
    target_names=ctrl_targets,
    target_calculator=plasma_descriptors,
    n_vc_workers=2,
    verbose=True,
    name="VC_shape",
)

shape_matrix = VCs.VC_shape.shape_matrix  # [no. of targets x no. of coils], units m/A
shape_vcs = VCs.VC_shape.VCs_matrix  # [no. of coils x no. of targets], units A/m
--- Stage one ---
Re-sizing each initial coil current shift so that it produces a 0.1% change in plasma current density from the input equilibrium.
Building shape matrix columns with 2 worker processes.
Forward static solve SUCCESS. Tolerance 7.70e-08 (vs. requested 1.00e-07) reached in 4/100 iterations.

Forward static solve SUCCESS. Tolerance 2.13e-08 (vs. requested 1.00e-07) reached in 6/100 iterations.

Forward static solve SUCCESS. Tolerance 6.77e-09 (vs. requested 1.00e-07) reached in 5/100 iterations.

Forward static solve SUCCESS. Tolerance 1.98e-08 (vs. requested 1.00e-07) reached in 5/100 iterations.

Forward static solve SUCCESS. Tolerance 9.71e-08 (vs. requested 1.00e-07) reached in 4/100 iterations.

Forward static solve SUCCESS. Tolerance 6.58e-08 (vs. requested 1.00e-07) reached in 6/100 iterations.

Forward static solve SUCCESS. Tolerance 2.11e-08 (vs. requested 1.00e-07) reached in 6/100 iterations.

Forward static solve SUCCESS. Tolerance 4.57e-08 (vs. requested 1.00e-07) reached in 5/100 iterations.

Forward static solve SUCCESS. Tolerance 6.23e-08 (vs. requested 1.00e-07) reached in 7/100 iterations.

Forward static solve SUCCESS. Tolerance 2.47e-08 (vs. requested 1.00e-07) reached in 8/100 iterations.

Forward static solve SUCCESS. Tolerance 1.45e-08 (vs. requested 1.00e-07) reached in 7/100 iterations.

Forward static solve SUCCESS. Tolerance 4.29e-08 (vs. requested 1.00e-07) reached in 6/100 iterations.

Forward static solve SUCCESS. Tolerance 2.44e-08 (vs. requested 1.00e-07) reached in 11/100 iterations.

Forward static solve SUCCESS. Tolerance 2.31e-08 (vs. requested 1.00e-07) reached in 7/100 iterations.

Forward static solve SUCCESS. Tolerance 1.12e-08 (vs. requested 1.00e-07) reached in 16/100 iterations.

Forward static solve SUCCESS. Tolerance 5.28e-08 (vs. requested 1.00e-07) reached in 7/100 iterations.

Forward static solve SUCCESS. Tolerance 3.17e-08 (vs. requested 1.00e-07) reached in 14/100 iterations.

Forward static solve SUCCESS. Tolerance 7.37e-08 (vs. requested 1.00e-07) reached in 6/100 iterations.

Forward static solve SUCCESS. Tolerance 4.02e-08 (vs. requested 1.00e-07) reached in 16/100 iterations.

Forward static solve SUCCESS. Tolerance 2.86e-08 (vs. requested 1.00e-07) reached in 6/100 iterations.

Coil PX (original current shift = 50.0 [A] --> scaled current shift 9.63 [A]).
Coil D1 (original current shift = 50.0 [A] --> scaled current shift 5.48 [A]).
Coil D2 (original current shift = 50.0 [A] --> scaled current shift 6.85 [A]).
Coil D3 (original current shift = 50.0 [A] --> scaled current shift 6.69 [A]).
Coil Dp (original current shift = 50.0 [A] --> scaled current shift 2.52 [A]).
Coil D5 (original current shift = 50.0 [A] --> scaled current shift 1.98 [A]).
Coil D6 (original current shift = 50.0 [A] --> scaled current shift 1.98 [A]).
Coil D7 (original current shift = 50.0 [A] --> scaled current shift 1.7 [A]).
Coil P4 (original current shift = 50.0 [A] --> scaled current shift 1.14 [A]).
Coil P5 (original current shift = 50.0 [A] --> scaled current shift 0.62 [A]).
--- Stage three ---
Inverting the shape matrix to get the virtual circuit matrix.
VC object stored under name: 'VC_shape'.
VC computing using Moore-Penrose pseudoinverse.

4. Configure the plasma-control loop

Here we set up the FPDT controllers as in Example 11 (with the same references, gains, limits, and time window), adding feedback control of the lower outer strikepoint radius Rsp, and omitting the vertical-control circuit. The controllers:

  • hold the plasma current at its initial value (\(7.59 \times 10^5\text{ A}\)), counteracting its resistive decay;

  • hold Rin and Rout at \(0.28\text{ m}\) and \(1.35\text{ m}\);

  • ramp the lower X-point radius, \(R_x\), from \(0.57\text{ m}\) inwards to \(0.50\text{ m}\) and back again;

  • leave the lower X-point height, \(Z_x\), uncontrolled (its blend is zero, so its virtual circuit is set to zero, as in Example 11);

  • hold the lower outer strikepoint radius, \(R_{\mathrm{sp}}\), at its initial value (\(0.74\text{ m}\)) for \(50\text{ ms}\), sweep it linearly over \(150\text{ ms}\) out to a Super-X position at \(1.40\text{ m}\) (\(t = 200\text{ ms}\)), and hold it there for the remainder of the simulation.

The shape controllers use proportional-only control (k_int = 0), as in Example 11. Note that the equilibrium starts a few millimetres away from the Rin, Rout, and Rx references.

from freegsnke.control_loop.pcs import PlasmaControlSystem

# simulation window (as in Example 11)
tmin = 0.0
tmax = 0.25
n_active = tokamak.n_active_coils
zeros = {"times": np.array([tmin, tmax]), "vals": np.zeros(2)}

# PLASMA CATEGORY (as in Example 11): hold Ip at its initial value with PID feedback only
plasma_data = {
    "ip_ref": {"times": np.array([tmin, tmax]), "vals": np.full(2, profiles.Ip)},
    "vloop_ff": zeros,
    "ip_blend": {"times": np.array([tmin, tmax]), "vals": np.ones(2)},
    "k_prop": {"times": np.array([tmin]), "vals": np.array([-5 * 4])},
    "k_int": {"times": np.array([tmin]), "vals": np.array([-50 * 2])},
    "k_deriv": {"times": np.array([tmin]), "vals": np.array([0])},
    "M_solenoid": {"times": np.array([tmin]), "vals": np.array([1.0])},
}


# SHAPE CATEGORY (as in Example 11, plus Rsp sweep to Super-X)
def shape_waveforms(ref_times, ref_values, k_prop, blend=1.0):
    """Return the waveforms of one shape target (a proportional-only controller)."""
    return {
        "ff": zeros,
        "ref": {"times": np.array(ref_times), "vals": np.array(ref_values)},
        "blend": {"times": np.array([tmin, tmax]), "vals": np.full(2, blend)},
        "k_prop": {"times": np.array([tmin]), "vals": np.array([k_prop])},
        "k_int": {"times": np.array([tmin]), "vals": np.array([0.0])},
        "k_deriv": {"times": np.array([tmin]), "vals": np.array([0.0])},
    }


rsp_initial = np.round(baseline_descriptors[ctrl_targets.index("Rsp")], 2)
shape_data = {
    "Rin": shape_waveforms([tmin, tmax], [0.28, 0.28], 120),
    "Rout": shape_waveforms([tmin, tmax], [1.35, 1.35], 170),
    "Rx": shape_waveforms(
        [tmin, 0.025, 0.075, 0.175, 0.225, tmax],
        [0.57, 0.57, 0.5, 0.5, 0.57, 0.57],
        120,
    ),
    "Zx": shape_waveforms([tmin, tmax], [-1.24, -1.24], 120, blend=0.0),  # uncontrolled
    "Rsp": shape_waveforms(
        [tmin, 0.05, 0.20, tmax],
        [rsp_initial, rsp_initial, 1.40, 1.40],
        120,
    ),
}

Virtual circuits and electrical limits

The shape virtual circuits are the columns of \(S^+\) (padded with zero on the solenoid), while the plasma-current virtual circuit acts solely on the solenoid. As in Example 11, the Zx virtual circuit is zero. The PCS current and voltage limits are copied from Example 11 (the same eleven circuits in the same order), including its limits that keep the P4 and P5 currents negative. Resistances and inductances are taken directly from the symmetrised tokamak object.

# VIRTUAL CIRCUITS CATEGORY
circuits_data = {"coil_order": active_coils}
for target_index, target in enumerate(ctrl_targets):
    circuit = np.zeros(n_active)
    if target != "Zx":  # Zx is not controlled
        circuit[1:] = shape_vcs[:, target_index]
    circuits_data[target] = {"times": np.array([tmin]), "vals": [circuit]}
circuits_data["plasma"] = {
    "times": np.array([tmin]),
    "vals": [np.r_[1.0, np.zeros(n_active - 1)]],
}
for coil_name in active_coils:  # no feedforward coil-current drives
    circuits_data[f"{coil_name}_ref"] = zeros

# SYSTEMS CATEGORY (limits as in Example 11)
initial_active = tokamak.getCurrentsVec()[:n_active]
min_current_lims = np.array([-10000, -7000, -9000, -9000, -9000, -9000, -9000, -9000, -9000, -10000, -10000], dtype=float)
max_current_lims = np.array([10000, 7000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 0, 0], dtype=float)
systems_data = {
    "min_coil_curr_lims": {"times": [tmin], "vals": [min_current_lims]},
    "max_coil_curr_lims": {"times": [tmin], "vals": [max_current_lims]},
    "max_coil_curr_ramp_lims": {"times": [tmin], "vals": [1e12 * np.ones(n_active)]},
}
for coil_name in active_coils:
    systems_data[f"{coil_name}_pert"] = zeros

# PF CATEGORY (gains and voltage limits as in Example 11)
voltage_lims = np.array([2000.0] + [750.0] * (n_active - 1))
pf_data = {
    "R_matrix": {"times": [tmin], "vals": [tokamak.coil_resist[:n_active]]},
    "M_FF_matrix": {
        "times": [tmin],
        "vals": [tokamak.coil_self_ind[:n_active, :n_active]],
    },
    "M_FB_matrix": {
        "times": [tmin],
        "vals": [tokamak.coil_self_ind[:n_active, :n_active]],
    },
    "coil_gains": {"times": [tmin], "vals": [0.015 * np.ones(n_active)]},
    "coil_voltage_lims": {"times": np.array([tmin]), "vals": [voltage_lims]},
    "coil_voltage_slew_lims": {"times": [tmin], "vals": [1e12 * np.ones(n_active)]},
}

# VERTICAL CATEGORY: no vertical-control circuit (P6 is odd and was excluded), so no vertical feedback
vertical_data = {
    "z_ref": {"times": np.array([tmin, tmax]), "vals": np.zeros(2)},
    "k_prop": {"times": np.array([tmin]), "vals": np.array([0.0])},
    "k_deriv": {"times": np.array([tmin]), "vals": np.array([0.0])},
}

# COIL ACTIVATIONS CATEGORY: all coils active throughout
activation_data = {
    f"{name}_activation": {"times": np.array([tmin]), "vals": np.array([1.0])}
    for name in active_coils
}

Assemble the PCS

The standard PCS interface is unchanged: symmetry reduction is handled entirely by the evolutive solver.

# build
pcs = PlasmaControlSystem(
    plasma_data=plasma_data,
    shape_data=shape_data,
    shape_control_mode="PID",
    circuits_data=circuits_data,
    systems_data=systems_data,
    pf_data=pf_data,
    vertical_data=vertical_data,
    coil_activation_data=activation_data,
    active_coils=active_coils,
    ctrl_coils=active_coils,
    vertical_coils=[],
    ctrl_targets=ctrl_targets,
    plasma_target=["plasma"],
)

5. Initialise the reduced evolutive solver

In Example 10 we showed that the metals and the plasma are governed by the circuit equation (2) and the plasma equation (3). Linearising the plasma current density about the current equilibrium (equation (4)) gives the state-matrix system

\[\begin{split} \mathbf{M}\dot{\mathbf{x}} + \mathbf{R}\mathbf{x} = \mathbf{c}, \qquad \mathbf{x} = \begin{bmatrix} \vec{I}_m \\ I_p \end{bmatrix}, \qquad A = -\mathbf{R}^{-1}\mathbf{M}, \end{split}\]

where the eigenvalues of \(A\) are the timescales \(\tau_i\) of the system (\(\tau_i > 0\) unstable, \(\tau_i < 0\) stable). The nl_solver used in Examples 05 and 11 evolves all of these modes (or a subset if needed). This includes the fast, vertically unstable mode, whose short timescale forces a small timestep (\(0.5\text{ ms}\) in Example 11).

SymmetryReducedSolver removes that mode by exploiting the up-down symmetry of the machine and the equilibrium. Let \(S_m\) be the reflection operator for the metal currents (it swaps each upper/lower partner) and \(S_y\) the reflection of the plasma grid about \(Z = 0\). For an exactly symmetric machine and equilibrium, reflected partners have equal resistances and inductances, and the Jacobians in equation (4) are even fields. The linearised system then commutes with reflection, \(SA = AS\) with \(S = \mathrm{diag}(S_m, 1)\), so the even and odd parts of the state evolve independently: an even perturbation never drives an odd response. The vertical instability is a vertical displacement of the plasma, which is odd, so it lives in the odd part and is removed by keeping only the even part.

How the passive modes are calculated

The passive structures obey the circuit equation (2) with no plasma and no applied voltage:

\[ M_{p,p}\dot{\vec{I}}_p + R_{p,p}\vec{I}_p = 0. \]

We form \(A_p = -R_{p,p}^{-1}M_{p,p}\) and solve the eigenproblem

\[ A_p\vec{v}_i = \tau_i\vec{v}_i. \]

Each eigenvector \(\vec{v}_i\) is a pattern of passive currents that decays as \(e^{t/\tau_i}\). All \(\tau_i\) are negative because the passive structures only dissipate energy. The modes are stored with their decay rates \(1/|\tau_i|\) and sorted from lowest rate (slowest decay) upwards.

For \(n=138\) passive elements, we obtain \(n/2 = 69\) up-down symmetric pairs. The passive reflection operator \(S_p\) is a permutation matrix, built from the pairing found by prepare_up_down_symmetric_machine, that swaps each upper/lower partner. For a pair \((u, l)\):

  • the \(S_p = +1\) eigenvector is \((e_u + e_l)/\sqrt{2}\): both partners carry the same current, giving flux that is even in \(Z\).

  • the \(S_p = -1\) eigenvector is \((e_u - e_l)/\sqrt{2}\): the partners carry opposite currents, giving a field that is odd in \(Z\). This is the kind of current that responds to vertical plasma motion.

The 69 pairs therefore give a 69-dimensional even subspace and a 69-dimensional odd subspace. A passive element on the midplane has no partner and contributes to the even subspace only (there is none in this machine).

We solve the eigenproblem separately in each subspace, so every mode has a definite parity, even when eigenvalues are degenerate. This requires \(S_pA_p = A_pS_p\), which holds when the resistances and inductances are reflection-symmetric. The solver checks this and raises an error if it fails.

What the reduced solver evolves

We keep only (a subset of) the even modes. The metal currents are written as \(\vec{I}_m = P\vec{\alpha}\), where the columns of \(P\) are the active-coil unit vectors and the retained even passive modes (in the following cell, we will retain 30 of the 69 even modes, chosen by their coupling to the plasma as in Example 11). The odd modes are removed before the plasma coupling is built. The reduced state is then

\[\begin{split} \mathbf{x}_+ = \begin{bmatrix} \vec{\alpha} \\ I_p \end{bmatrix} \qquad (11 \text{ active circuits} + 30 \text{ passive modes} + I_p = 42 \text{ values}). \end{split}\]

Substituting \(\vec{I}_m = P\vec{\alpha}\) into equation (5), multiplying by \(P^{-1}R_{m,m}^{-1}\), and dividing equation (6) by the lumped plasma resistance \(R_p\) gives the same equations as Example 10 in the reduced state:

\[ \mathbf{M}_+\dot{\mathbf{x}}_+ + \mathbf{x}_+ = \mathbf{f}, \]
\[\begin{split} \mathbf{M}_+ = \begin{bmatrix} P^{-1}R_{m,m}^{-1}\left( M_{m,m}P + M_{m,y}\dfrac{\partial \vec{I}_y}{\partial \vec{\alpha}} \right) & P^{-1}R_{m,m}^{-1}M_{m,y}\dfrac{\partial \vec{I}_y}{\partial I_p} \\[2ex] \dfrac{\hat{\vec{I}}_y^{T}}{R_p}\left( M_{y,m}P + M_{y,y}\dfrac{\partial \vec{I}_y}{\partial \vec{\alpha}} \right) & \dfrac{\hat{\vec{I}}_y^{T}}{R_p}M_{y,y}\dfrac{\partial \vec{I}_y}{\partial I_p} \end{bmatrix}, \end{split}\]
\[\begin{split} \mathbf{f} = \begin{bmatrix} P^{-1}R_{m,m}^{-1}\vec{V}_m \\ 0 \end{bmatrix} - \begin{bmatrix} P^{-1}R_{m,m}^{-1}M_{m,y} \\[1ex] \dfrac{\hat{\vec{I}}_y^{T}}{R_p}M_{y,y} \end{bmatrix} \dfrac{\partial \vec{I}_y}{\partial \vec{\theta}}\dot{\vec{\theta}}. \end{split}\]

The Jacobians \(\partial\vec{I}_y/\partial\vec{\alpha}\), \(\partial\vec{I}_y/\partial I_p\) and \(\partial\vec{I}_y/\partial\vec{\theta}\) come from Grad-Shafranov solves forced to be even in \(Z\), and are projected with \(\Pi_+ = \tfrac{1}{2}(I + S_y)\) to remove odd round-off. The system is advanced with implicit Euler,

\[ \mathbf{x}_+(t + \Delta t) = (\mathbf{M}_+ + \Delta t\,\mathbf{I})^{-1}\left(\Delta t\,\mathbf{f} + \mathbf{M}_+\mathbf{x}_+(t)\right). \]

After each step the equilibrium is updated with a Grad-Shafranov solve, and the Jacobians are rebuilt if the plasma current density has changed by more than the relinearisation threshold.

Note: Without the odd modes, the fastest remaining timescales are resistive, which allows a much larger timestep to be taken (recall the small timesteps used in Examples 05 and 11). This is exact only for the linearisation about an even equilibrium in an even machine: the plasma cannot move vertically, so it cannot be used for vertical displacement events or asymmetric scenarios. The timestep cannot be arbitrarily large, however: it must still resolve the retained dynamics, keep the linearisation accurate (the Jacobians are rebuilt whenever the plasma has changed significantly), and be small compared with the timescales and gains used in the virtual PCS.

from freegsnke.symmetry_reduced_solve import SymmetryReducedSolver

# plasma resistivity [Ohm m] (as in Example 11)
plasma_resistivity = 1e-7

# initialise the solver object
stepping = SymmetryReducedSolver(
    eq=eq,
    profiles=profiles,
    GSStaticSolver=static_solver,
    full_timestep=2.5e-3,      # <-- 2.5 ms timestep (5x that of Example 11)!
    max_internal_timestep=2.5e-3,
    plasma_resistivity=plasma_resistivity,
    mode_selection="coupling",
    fix_n_vessel_modes=30,     # <-- 30/69 retained even modes
    plasma_descriptor_function=plasma_descriptors,
    passive_reflection_operator=passive_reflection_operator,
    n_linearization_workers=4,
    verbose=False,
)
-----
Checking that the provided 'eq' and 'profiles' are a GS solution...
Forward static solve SUCCESS. Tolerance 2.79e-09 (vs. requested 1.00e-08) reached in 0/100 iterations.
-----
Instantiating nonlinear solver objects...
done.
-----
Identifying mode selection criteria...
      'fix_n_vessel_modes' option selected --> passive structure modes that couple most to the strongest passive structure mode are being selected.
-----
Initial mode selection:
   Active coils
      total selected = 11 (out of 11)
   Passive structures
      30 selected using 'fix_n_vessel_modes'
   Total number of modes = 41 (11 active coils + 30 passive structures)
      (Note: some additional modes may be removed after Jacobian calculation if 'mode_removal=True')
-----
Building the 1510 x 42 Jacobian (dIy/dI) of plasma current density (inside the LCFS) with respect to all metal currents and the total plasma current.
Building the 1510 x 4 Jacobian (dIy/dtheta) of plasma current density (inside the LCFS) with respect to all plasma current density profile parameters within Jtor.
Built the 5 x 42 Jacobian (ds/dI) of plasma descriptors with respect to all metal currents and the total plasma current.
Built the 5 x 4 Jacobian (ds/dtheta) of plasma descriptors with respect to all plasma current density profile parameters within Jtor.
-----
Stability paramters:
      No unstable modes found in the retained even-in-Z subspace.
-----
Evolutive solver timestep:
      Solver timestep 'dt_step' has been set to 0.0025 as requested.
      Odd-in-Z modes are excluded; ensure the timestep resolves the retained even dynamics.
-----

Inspect passive-mode parity and truncation

Open markers show the discarded passive modes (even in blue, odd in orange); filled markers show the even modes retained after parity and mode-count selection (we keep the 30 even modes that couple most strongly to the plasma). The spatial panels show representative even and odd mode current patterns.

normal_modes = stepping.evol_metal_curr.normal_modes
passive_parity = normal_modes.passive_mode_parity
passive_frequency = normal_modes.w_passive
retained_passive = stepping.evol_metal_curr.selected_modes_mask[n_active:]
passive_centres = np.array(
    [
        [np.mean(element["R"]), np.mean(element["Z"])]
        for element in symmetric_machine.passive_coils_data
    ]
)

representative_modes = {
    "even mode": np.flatnonzero(passive_parity > 0)[0],
    "odd mode": np.flatnonzero(passive_parity < 0)[0],
}
fig, axes = plt.subplots(1, 3, figsize=(13, 5))

for parity, label, colour in ((1, "even", "tab:blue"), (-1, "odd", "tab:orange")):
    parity_mask = (passive_parity == parity) & ~retained_passive
    axes[0].scatter(
        np.flatnonzero(parity_mask),
        passive_frequency[parity_mask],
        facecolors="none",
        edgecolors=colour,
        label=f"{label}, discarded",
    )
retained_indices = np.flatnonzero(retained_passive)
axes[0].scatter(
    retained_indices,
    passive_frequency[retained_passive],
    color="tab:blue",
    label="even, retained",
)
axes[0].set_yscale("log")
axes[0].set_xlabel("passive-mode index")
axes[0].set_ylabel("frequency [s$^{-1}$]")
axes[0].set_title("Parity-aware mode selection")
axes[0].grid(True)
axes[0].legend()

for axis, (title, mode_index) in zip(axes[1:], representative_modes.items()):
    amplitudes = normal_modes.Pmatrix[
        n_active:, n_active + mode_index
    ]
    scale = np.max(np.abs(amplitudes))
    points = axis.scatter(
        passive_centres[:, 0],
        passive_centres[:, 1],
        c=amplitudes,
        cmap="coolwarm",
        vmin=-scale,
        vmax=scale,
        s=30,
        edgecolor="k",
    )
    axis.axhline(0.0, color="0.6", linewidth=1)
    axis.set_aspect("equal")
    axis.set_xlabel("R [m]")
    axis.set_ylabel("Z [m]")
    axis.set_title(title)
    fig.colorbar(points, ax=axis, label="relative mode current", shrink=0.6)

fig.tight_layout()
plt.show()
../_images/ee5b8fcc71d833bf265f1c870c95959964ca61269798bd39d8be37a98e64f9d3.png

6. Run the controlled evolution

Next, we’ll run the simulation with a \(2.5\text{ ms}\) solver step and a \(1.25\text{ ms}\) PCS timestep (Example 11 used \(0.5\text{ ms}\) and \(0.25\text{ ms}\)).

The virtual PCS will return the voltages to be applied to the active coils, which the reduced solver will use to advance the retained metal modes, plasma current, and profile response (and equilibrium!).

The PCS holds the plasma current at its initial value, ramps \(R_x\) inwards and back, sweeps the lower outer strikepoint radius \(R_{\mathrm{sp}}\) out to \(1.40\text{ m}\) (Super-X), and holds Rin and Rout constant as described in Section 4. The plasma resistivity is set to \(10^{-7}\,\Omega\,\mathrm{m}\), as in Example 11.

# setup and storage
dt = stepping.dt_step
n_steps = int(round((tmax - tmin) / dt)) + 1  # simulate from tmin to tmax
dt_pcs = dt / 2
times = tmin + np.arange(n_steps) * dt

# keep four equilibrium snapshots, evenly spaced in time, for plotting later
snapshot_indices = np.linspace(0, n_steps - 1, 4).astype(int)
snapshots = {0: stepping.eq1.create_auxiliary_equilibrium()}

# re-linearisation: the solver re-linearises when the relative change in the toroidal current density
# since the last linearisation reaches this threshold (we store this criterion at every step)
relinearise_threshold = 0.05
relinearise_criterion = np.zeros(n_steps - 1)

dynamic_currents = np.zeros((len(stepping.vessel_currents_vec), n_steps))
dynamic_ip = np.zeros(n_steps)
dynamic_shape = np.zeros((len(ctrl_targets), n_steps))
dynamic_z = np.zeros(n_steps)
dynamic_limited = np.zeros(n_steps, dtype=bool)  # is the plasma limited (not diverted)?
voltages = np.zeros((n_active, n_steps - 1))
step_times = np.zeros(n_steps - 1)

dynamic_currents[:, 0] = stepping.vessel_currents_vec
dynamic_ip[0] = stepping.profiles1.Ip
dynamic_shape[:, 0] = plasma_descriptors(stepping.eq1)
dynamic_z[0] = stepping.eq1.Zcurrent()
dynamic_limited[0] = bool(stepping.profiles1.flag_limiter)

ip_hist_prev = 0.0
ip_err_prev = 0.0
shape_error_prev = np.zeros(len(ctrl_targets))
shape_history_prev = np.zeros(len(ctrl_targets))
approved_current_prev = initial_active.copy()
approved_voltage_prev = np.zeros(n_active)
# simulate!
for index, time_value in enumerate(times[:-1]):

    print("-----")
    print(f"t = {np.round(time_value,5)}s (step {index+1}/{n_steps-1})")

    result = pcs.calculate_ctrl_voltages(
        t=time_value,
        dt=dt_pcs,
        dt_simulator=dt,
        ip_meas=dynamic_ip[index],
        ip_hist_prev=ip_hist_prev,
        ip_err_prev=ip_err_prev,
        T_meas=dynamic_shape[:, index],
        T_err_prev=shape_error_prev,
        T_hist_prev=shape_history_prev,
        I_approved_prev=approved_current_prev,
        I_meas=dynamic_currents[:n_active, index],
        V_approved_prev=approved_voltage_prev,
        zip_meas=dynamic_z[index] * dynamic_ip[index],
        zipv_meas=0.0,
        active_coil_resists=tokamak.coil_resist[:n_active],
        verbose=False,
    )
    (
        approved_voltage,
        ip_hist_prev,
        ip_err_prev,
        shape_error_prev,
        shape_history_prev,
        approved_current_prev,
        active_resistances,
    ) = result
    voltages[:, index] = approved_voltage
    approved_voltage_prev = approved_voltage.copy()

    start = time.perf_counter()
    stepping.nlstepper(
        plasma_resistivity=plasma_resistivity,
        active_voltage_vec=approved_voltage,
        # Lao logic adds one dependent closure coefficient to each stored
        # array; the evolutive interface accepts the independent values only.
        profiles_parameters={
            "alpha": profiles.alpha[:-1].copy(),
            "beta": profiles.beta[:-1].copy(),
        },
        custom_active_coil_resistances=active_resistances,
        linear_only=True,
        target_relative_tol_currents=1e-2,
        target_relative_tol_GS=1e-2,
        working_relative_tol_GS=5e-2,
        max_solving_iterations=20,
        relinearise_threshold=relinearise_threshold,
        no_GS=False,
        verbose=False,
    )
    step_times[index] = time.perf_counter() - start
    relinearise_criterion[index] = stepping.relinearise_criteria

    dynamic_currents[:, index + 1] = stepping.vessel_currents_vec
    dynamic_ip[index + 1] = stepping.profiles1.Ip
    dynamic_shape[:, index + 1] = plasma_descriptors(stepping.eq1)
    dynamic_z[index + 1] = stepping.eq1.Zcurrent()
    dynamic_limited[index + 1] = bool(stepping.profiles1.flag_limiter)
    if index + 1 in snapshot_indices:
        snapshots[index + 1] = stepping.eq1.create_auxiliary_equilibrium()

    # print some stuff to track solve
    print(f"      PLASMA QUANTITIES")
    print(f"        Ip = {np.round(dynamic_ip[index+1]/1000,1)} [kA]")
    print(f"        Shape parameters {ctrl_targets} = {np.round(dynamic_shape[:,index+1],3)}")
    print(f"        Z position = {np.round(dynamic_z[index+1],5)} [m]")
-----
t = 0.0s (step 1/100)
      PLASMA QUANTITIES
        Ip = 757.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.277  1.346  0.567 -1.245  0.74 ]
        Z position = -0.0 [m]
-----
t = 0.0025s (step 2/100)
      PLASMA QUANTITIES
        Ip = 757.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.278  1.346  0.568 -1.244  0.741]
        Z position = -0.0 [m]
-----
t = 0.005s (step 3/100)
      PLASMA QUANTITIES
        Ip = 756.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.279  1.347  0.569 -1.244  0.741]
        Z position = -0.0 [m]
-----
t = 0.0075s (step 4/100)
      PLASMA QUANTITIES
        Ip = 757.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.28   1.348  0.57  -1.244  0.742]
        Z position = -0.0 [m]
-----
t = 0.01s (step 5/100)
      PLASMA QUANTITIES
        Ip = 757.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.35   0.571 -1.244  0.742]
        Z position = -0.0 [m]
-----
t = 0.0125s (step 6/100)
      PLASMA QUANTITIES
        Ip = 757.3 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.572 -1.244  0.743]
        Z position = -0.0 [m]
-----
t = 0.015s (step 7/100)
      PLASMA QUANTITIES
        Ip = 757.6 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.573 -1.244  0.743]
        Z position = -0.0 [m]
-----
t = 0.0175s (step 8/100)
      PLASMA QUANTITIES
        Ip = 757.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.573 -1.245  0.743]
        Z position = -0.0 [m]
-----
t = 0.02s (step 9/100)
      PLASMA QUANTITIES
        Ip = 758.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.356  0.574 -1.245  0.743]
        Z position = -0.0 [m]
-----
t = 0.0225s (step 10/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.357  0.574 -1.246  0.743]
        Z position = -0.0 [m]
-----
t = 0.025s (step 11/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.285  1.357  0.574 -1.246  0.742]
        Z position = -0.0 [m]
-----
t = 0.0275s (step 12/100)
      PLASMA QUANTITIES
        Ip = 758.7 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.357  0.572 -1.247  0.742]
        Z position = -0.0 [m]
-----
t = 0.03s (step 13/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.357  0.57  -1.248  0.742]
        Z position = -0.0 [m]
-----
t = 0.0325s (step 14/100)
      PLASMA QUANTITIES
        Ip = 759.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.356  0.567 -1.248  0.741]
        Z position = -0.0 [m]
-----
t = 0.035s (step 15/100)
      PLASMA QUANTITIES
        Ip = 759.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.355  0.564 -1.249  0.741]
        Z position = -0.0 [m]
-----
t = 0.0375s (step 16/100)
      PLASMA QUANTITIES
        Ip = 759.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.561 -1.249  0.741]
        Z position = -0.0 [m]
-----
t = 0.04s (step 17/100)
      PLASMA QUANTITIES
        Ip = 759.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.557 -1.25   0.74 ]
        Z position = -0.0 [m]
-----
t = 0.0425s (step 18/100)
      PLASMA QUANTITIES
        Ip = 759.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.351  0.553 -1.25   0.74 ]
        Z position = -0.0 [m]
-----
t = 0.045s (step 19/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.35   0.549 -1.249  0.74 ]
        Z position = -0.0 [m]
-----
t = 0.0475s (step 20/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.35   0.545 -1.249  0.74 ]
        Z position = -0.0 [m]
-----
t = 0.05s (step 21/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.28   1.35   0.541 -1.249  0.74 ]
        Z position = -0.0 [m]
-----
t = 0.0525s (step 22/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.28   1.35   0.537 -1.249  0.745]
        Z position = -0.0 [m]
-----
t = 0.055s (step 23/100)
      PLASMA QUANTITIES
        Ip = 759.3 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.28   1.35   0.533 -1.249  0.75 ]
        Z position = -0.0 [m]
-----
t = 0.0575s (step 24/100)
      PLASMA QUANTITIES
        Ip = 759.6 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.28   1.349  0.529 -1.25   0.757]
        Z position = -0.0 [m]
-----
t = 0.06s (step 25/100)
      PLASMA QUANTITIES
        Ip = 759.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.279  1.349  0.524 -1.25   0.766]
        Z position = -0.0 [m]
-----
t = 0.0625s (step 26/100)
      PLASMA QUANTITIES
        Ip = 760.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.278  1.348  0.519 -1.25   0.777]
        Z position = -0.0 [m]
-----
t = 0.065s (step 27/100)
      PLASMA QUANTITIES
        Ip = 760.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.277  1.347  0.514 -1.25   0.792]
        Z position = -0.0 [m]
-----
t = 0.0675s (step 28/100)
      PLASMA QUANTITIES
        Ip = 759.8 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.276  1.346  0.509 -1.25   0.808]
        Z position = -0.0 [m]
-----
t = 0.07s (step 29/100)
      PLASMA QUANTITIES
        Ip = 759.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.276  1.345  0.505 -1.249  0.825]
        Z position = -0.0 [m]
-----
t = 0.0725s (step 30/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.276  1.345  0.502 -1.249  0.84 ]
        Z position = -0.0 [m]
-----
t = 0.075s (step 31/100)
      PLASMA QUANTITIES
        Ip = 758.6 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.276  1.344  0.5   -1.25   0.857]
        Z position = -0.0 [m]
-----
t = 0.0775s (step 32/100)
      PLASMA QUANTITIES
        Ip = 758.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.276  1.344  0.499 -1.249  0.867]
        Z position = -0.0 [m]
-----
t = 0.08s (step 33/100)
      PLASMA QUANTITIES
        Ip = 757.7 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.277  1.344  0.499 -1.248  0.882]
        Z position = -0.0 [m]
-----
t = 0.0825s (step 34/100)
      PLASMA QUANTITIES
        Ip = 757.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.278  1.345  0.499 -1.246  0.89 ]
        Z position = -0.0 [m]
-----
t = 0.085s (step 35/100)
      PLASMA QUANTITIES
        Ip = 757.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.279  1.346  0.5   -1.245  0.906]
        Z position = -0.0 [m]
-----
t = 0.0875s (step 36/100)
      PLASMA QUANTITIES
        Ip = 757.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.279  1.347  0.501 -1.244  0.912]
        Z position = -0.0 [m]
-----
t = 0.09s (step 37/100)
      PLASMA QUANTITIES
        Ip = 757.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.28   1.348  0.502 -1.244  0.926]
        Z position = -0.0 [m]
-----
t = 0.0925s (step 38/100)
      PLASMA QUANTITIES
        Ip = 757.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.349  0.502 -1.243  0.936]
        Z position = -0.0 [m]
-----
t = 0.095s (step 39/100)
      PLASMA QUANTITIES
        Ip = 757.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.351  0.503 -1.243  0.947]
        Z position = -0.0 [m]
-----
t = 0.0975s (step 40/100)
      PLASMA QUANTITIES
        Ip = 757.7 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.353  0.503 -1.243  0.955]
        Z position = -0.0 [m]
-----
t = 0.1s (step 41/100)
      PLASMA QUANTITIES
        Ip = 758.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.504 -1.243  0.964]
        Z position = 0.0 [m]
-----
t = 0.1025s (step 42/100)
      PLASMA QUANTITIES
        Ip = 758.3 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.504 -1.244  0.974]
        Z position = -0.0 [m]
-----
t = 0.105s (step 43/100)
      PLASMA QUANTITIES
        Ip = 758.6 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.503 -1.245  0.985]
        Z position = -0.0 [m]
-----
t = 0.1075s (step 44/100)
      PLASMA QUANTITIES
        Ip = 758.7 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.503 -1.246  0.995]
        Z position = -0.0 [m]
-----
t = 0.11s (step 45/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.503 -1.246  1.007]
        Z position = -0.0 [m]
-----
t = 0.1125s (step 46/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.502 -1.247  1.017]
        Z position = -0.0 [m]
-----
t = 0.115s (step 47/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.502 -1.25   1.026]
        Z position = -0.0 [m]
-----
t = 0.1175s (step 48/100)
      PLASMA QUANTITIES
        Ip = 758.8 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.353  0.502 -1.251  1.036]
        Z position = -0.0 [m]
-----
t = 0.12s (step 49/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.353  0.501 -1.252  1.046]
        Z position = -0.0 [m]
-----
t = 0.1225s (step 50/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.501 -1.253  1.057]
        Z position = -0.0 [m]
-----
t = 0.125s (step 51/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.351  0.5   -1.253  1.068]
        Z position = -0.0 [m]
-----
t = 0.1275s (step 52/100)
      PLASMA QUANTITIES
        Ip = 758.8 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.351  0.5   -1.254  1.079]
        Z position = -0.0 [m]
-----
t = 0.13s (step 53/100)
      PLASMA QUANTITIES
        Ip = 758.7 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.351  0.5   -1.255  1.092]
        Z position = -0.0 [m]
-----
t = 0.1325s (step 54/100)
      PLASMA QUANTITIES
        Ip = 758.6 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.35   0.5   -1.255  1.102]
        Z position = -0.0 [m]
-----
t = 0.135s (step 55/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.35   0.5   -1.256  1.113]
        Z position = -0.0 [m]
-----
t = 0.1375s (step 56/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.35   0.5   -1.256  1.125]
        Z position = 0.0 [m]
-----
t = 0.14s (step 57/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.35   0.501 -1.256  1.136]
        Z position = -0.0 [m]
-----
t = 0.1425s (step 58/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.351  0.501 -1.257  1.147]
        Z position = -0.0 [m]
-----
t = 0.145s (step 59/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.351  0.501 -1.257  1.159]
        Z position = -0.0 [m]
-----
t = 0.1475s (step 60/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.351  0.501 -1.257  1.17 ]
        Z position = -0.0 [m]
-----
t = 0.15s (step 61/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.351  0.501 -1.258  1.182]
        Z position = -0.0 [m]
-----
t = 0.1525s (step 62/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.351  0.501 -1.258  1.193]
        Z position = -0.0 [m]
-----
t = 0.155s (step 63/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.281  1.351  0.501 -1.258  1.205]
        Z position = -0.0 [m]
-----
t = 0.1575s (step 64/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.501 -1.259  1.216]
        Z position = -0.0 [m]
-----
t = 0.16s (step 65/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.502 -1.259  1.228]
        Z position = -0.0 [m]
-----
t = 0.1625s (step 66/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.502 -1.26   1.24 ]
        Z position = -0.0 [m]
-----
t = 0.165s (step 67/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.502 -1.26   1.251]
        Z position = -0.0 [m]
-----
t = 0.1675s (step 68/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.352  0.502 -1.261  1.263]
        Z position = -0.0 [m]
-----
t = 0.17s (step 69/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.353  0.502 -1.262  1.275]
        Z position = -0.0 [m]
-----
t = 0.1725s (step 70/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.282  1.353  0.503 -1.262  1.287]
        Z position = -0.0 [m]
-----
t = 0.175s (step 71/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.353  0.503 -1.263  1.299]
        Z position = -0.0 [m]
-----
t = 0.1775s (step 72/100)
      PLASMA QUANTITIES
        Ip = 758.4 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.353  0.504 -1.258  1.31 ]
        Z position = -0.0 [m]
-----
t = 0.18s (step 73/100)
      PLASMA QUANTITIES
        Ip = 758.3 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.353  0.507 -1.258  1.321]
        Z position = -0.0 [m]
-----
t = 0.1825s (step 74/100)
      PLASMA QUANTITIES
        Ip = 758.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.352  0.51  -1.257  1.332]
        Z position = -0.0 [m]
-----
t = 0.185s (step 75/100)
      PLASMA QUANTITIES
        Ip = 758.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.353  0.514 -1.257  1.343]
        Z position = -0.0 [m]
-----
t = 0.1875s (step 76/100)
      PLASMA QUANTITIES
        Ip = 758.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.353  0.518 -1.257  1.352]
        Z position = -0.0 [m]
-----
t = 0.19s (step 77/100)
      PLASMA QUANTITIES
        Ip = 758.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.522 -1.257  1.358]
        Z position = -0.0 [m]
-----
t = 0.1925s (step 78/100)
      PLASMA QUANTITIES
        Ip = 758.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.354  0.525 -1.257  1.365]
        Z position = -0.0 [m]
-----
t = 0.195s (step 79/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.529 -1.257  1.373]
        Z position = -0.0 [m]
-----
t = 0.1975s (step 80/100)
      PLASMA QUANTITIES
        Ip = 758.8 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.532 -1.258  1.383]
        Z position = -0.0 [m]
-----
t = 0.2s (step 81/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.355  0.533 -1.255  1.393]
        Z position = -0.0 [m]
-----
t = 0.2025s (step 82/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.536 -1.255  1.4  ]
        Z position = -0.0 [m]
-----
t = 0.205s (step 83/100)
      PLASMA QUANTITIES
        Ip = 758.5 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.54  -1.255  1.405]
        Z position = -0.0 [m]
-----
t = 0.2075s (step 84/100)
      PLASMA QUANTITIES
        Ip = 758.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.544 -1.254  1.408]
        Z position = -0.0 [m]
-----
t = 0.21s (step 85/100)
      PLASMA QUANTITIES
        Ip = 757.8 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.354  0.548 -1.253  1.41 ]
        Z position = -0.0 [m]
-----
t = 0.2125s (step 86/100)
      PLASMA QUANTITIES
        Ip = 757.7 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.355  0.552 -1.253  1.411]
        Z position = -0.0 [m]
-----
t = 0.215s (step 87/100)
      PLASMA QUANTITIES
        Ip = 757.7 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.285  1.357  0.557 -1.253  1.411]
        Z position = -0.0 [m]
-----
t = 0.2175s (step 88/100)
      PLASMA QUANTITIES
        Ip = 757.8 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.286  1.359  0.561 -1.253  1.411]
        Z position = -0.0 [m]
-----
t = 0.22s (step 89/100)
      PLASMA QUANTITIES
        Ip = 758.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.287  1.361  0.564 -1.252  1.41 ]
        Z position = -0.0 [m]
-----
t = 0.2225s (step 90/100)
Re-linearising around current equilibrium!
   Relative relinearisation criteria change = 5.116% (threshold = 5.0%) 
Building the 1510 x 42 Jacobian (dIy/dI) of plasma current density (inside the LCFS) with respect to all metal currents and the total plasma current.
Building the 1510 x 4 Jacobian (dIy/dtheta) of plasma current density (inside the LCFS) with respect to all plasma current density profile parameters within Jtor.
Built the 5 x 42 Jacobian (ds/dI) of plasma descriptors with respect to all metal currents and the total plasma current.
Built the 5 x 4 Jacobian (ds/dtheta) of plasma descriptors with respect to all plasma current density profile parameters within Jtor.
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.289  1.364  0.569 -1.253  1.41 ]
        Z position = -0.0 [m]
-----
t = 0.225s (step 91/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.289  1.363  0.572 -1.253  1.407]
        Z position = -0.0 [m]
-----
t = 0.2275s (step 92/100)
      PLASMA QUANTITIES
        Ip = 759.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.289  1.363  0.574 -1.255  1.405]
        Z position = -0.0 [m]
-----
t = 0.23s (step 93/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.288  1.359  0.574 -1.255  1.402]
        Z position = -0.0 [m]
-----
t = 0.2325s (step 94/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.287  1.357  0.574 -1.256  1.401]
        Z position = -0.0 [m]
-----
t = 0.235s (step 95/100)
      PLASMA QUANTITIES
        Ip = 758.9 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.286  1.355  0.574 -1.257  1.4  ]
        Z position = -0.0 [m]
-----
t = 0.2375s (step 96/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.285  1.354  0.574 -1.257  1.4  ]
        Z position = -0.0 [m]
-----
t = 0.24s (step 97/100)
      PLASMA QUANTITIES
        Ip = 759.0 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.353  0.573 -1.258  1.4  ]
        Z position = -0.0 [m]
-----
t = 0.2425s (step 98/100)
      PLASMA QUANTITIES
        Ip = 759.1 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.353  0.573 -1.258  1.401]
        Z position = -0.0 [m]
-----
t = 0.245s (step 99/100)
      PLASMA QUANTITIES
        Ip = 759.2 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.284  1.354  0.573 -1.259  1.402]
        Z position = 0.0 [m]
-----
t = 0.2475s (step 100/100)
      PLASMA QUANTITIES
        Ip = 759.3 [kA]
        Shape parameters ['Rin', 'Rout', 'Rx', 'Zx', 'Rsp'] = [ 0.283  1.355  0.573 -1.259  1.403]
        Z position = -0.0 [m]

7. Inspect the results

Below we plot the plasma current, the plasma vertical position \(Z_{\mathrm{current}}\) (held on the midplane by symmetry), and the five shape quantities (Rin, Rout, Rx, Zx, and the lower outer strikepoint radius Rsp) against their reference targets, followed by the active coil currents and voltages (with the PCS limits), snapshots of the equilibrium as it evolves into the Super-X configuration, and finally the passive structure currents.

t_ms = 1e3 * times
shape_reference = np.array(  # reference waveform of each shape target, evaluated at the simulation times
    [
        np.interp(
            times,
            pcs.ShapeController.data[target]["ref"]["times"],
            pcs.ShapeController.data[target]["ref"]["vals"],
        )
        for target in ctrl_targets
    ]
)
t_voltage_ms = 1e3 * times[:-1]  # each voltage request is applied from the start of its step
colours = {name: f"C{index}" for index, name in enumerate(active_coils)}

# plasma current, vertical position, and shape: evolved values against their reference targets
ip_reference = np.interp(times, plasma_data["ip_ref"]["times"], plasma_data["ip_ref"]["vals"])
z_reference = np.interp(times, vertical_data["z_ref"]["times"], vertical_data["z_ref"]["vals"])
fig, axes = plt.subplots(2, 4, figsize=(15, 6), dpi=80, sharex=True, constrained_layout=True)
ip_axis = axes[0, 0]
z_axis = axes[0, 1]
shape_axes = [axes[0, 2], axes[0, 3], axes[1, 0], axes[1, 1], axes[1, 2]]
axes[1, 3].axis("off")  # unused

ip_axis.plot(t_ms, dynamic_ip / 1e3, color="k", label="evolved")
ip_axis.plot(t_ms, ip_reference / 1e3, color="tab:red", linestyle="--", label="reference")
ip_axis.set_ylabel(r"Plasma current, $I_p$ [kA]")
ip_axis.legend()

z_axis.plot(t_ms, dynamic_z, color="k", label="evolved")
z_axis.plot(t_ms, z_reference, color="tab:red", linestyle="--", label="reference")
z_axis.set_ylabel(r"Vertical position, $Z$ [m]")

for target_index, (axis, target) in enumerate(zip(shape_axes, ctrl_targets)):
    axis.plot(t_ms, dynamic_shape[target_index], color="k", label="evolved")
    if shape_data[target]["blend"]["vals"][0] > 0:  # the reference of an uncontrolled target is not followed
        axis.plot(t_ms, shape_reference[target_index], color="tab:red", linestyle="--", label="reference")
        axis.set_ylabel(f"{target} [m]")
    else:
        axis.set_ylabel(f"{target} [m] (uncontrolled)")

for axis in [ip_axis, z_axis] + shape_axes:
    axis.grid(alpha=0.5)
for axis in (axes[0, 3], axes[1, 0], axes[1, 1], axes[1, 2]):
    axis.tick_params(labelbottom=True)
    axis.set_xlabel("Time [ms]")
fig.suptitle("Plasma current, vertical position, and shape: evolved against reference")
plt.show()

# active coil currents and voltages (solenoid and shape coils are shown separately)
solenoid = active_coils.index("Solenoid")
shape_coil_indices = [index for index in range(n_active) if index != solenoid]
voltage_limits = pf_data["coil_voltage_lims"]["vals"][0]

fig, axes = plt.subplots(2, 3, figsize=(15, 6), dpi=80, sharex=True, constrained_layout=True)

axes[0, 0].plot(t_ms, dynamic_currents[solenoid] / 1e3, color=colours["Solenoid"], label="Solenoid")
axes[0, 0].axhline(max_current_lims[solenoid] / 1e3, color="tab:red", linestyle="--", linewidth=1, label="PCS limits")
axes[0, 0].axhline(min_current_lims[solenoid] / 1e3, color="tab:red", linestyle="--", linewidth=1)
axes[0, 0].set_ylabel("Solenoid current [kA]")
axes[0, 0].legend()

axes[1, 0].step(t_voltage_ms, voltages[solenoid], where="post", color=colours["Solenoid"])
axes[1, 0].axhline(voltage_limits[solenoid], color="tab:red", linestyle="--", linewidth=1, label="PCS limits")
axes[1, 0].axhline(-voltage_limits[solenoid], color="tab:red", linestyle="--", linewidth=1)
axes[1, 0].set_ylabel("Solenoid voltage [V]")
axes[1, 0].legend()

for index in shape_coil_indices:
    name = active_coils[index]
    axes[0, 1].plot(t_ms, dynamic_currents[index] / 1e3, color=colours[name], label=name)
    axes[0, 2].plot(t_ms, (dynamic_currents[index] - dynamic_currents[index, 0]) / 1e3, color=colours[name], label=name)
    axes[1, 1].step(t_voltage_ms, voltages[index], where="post", color=colours[name], label=name)
    axes[1, 2].step(t_voltage_ms, voltages[index], where="post", color=colours[name], label=name)
axes[1, 1].axhline(voltage_limits[shape_coil_indices[0]], color="tab:red", linestyle="--", linewidth=1)
axes[1, 1].axhline(-voltage_limits[shape_coil_indices[0]], color="tab:red", linestyle="--", linewidth=1)
axes[0, 1].set_ylabel("Shape-coil currents [kA]")
axes[0, 2].set_ylabel("Shape-coil current change [kA]")
axes[1, 1].set_ylabel("Shape-coil voltages [V] (limits: dashed)")
axes[1, 2].set_ylabel("Shape-coil voltages [V] (zoom)")
axes[1, 2].set_ylim(-250, 250)
axes[0, 1].legend(ncol=2, fontsize="small")

for axis in axes.ravel():
    axis.grid(alpha=0.5)
for axis in axes[1]:
    axis.set_xlabel("Time [ms]")
fig.suptitle("Active coil currents and voltages")
plt.show()
../_images/b5006e9c9ef394463305c0ea1e3dbbd871be242d0c2f649540d82fa96cb1d440.png ../_images/487befec15a3eedc34326180495e8e4125bbbafe32091736f0212b59bba65d3a.png

The next cell quantifies how closely the controllers follow their references (the shape errors are measured against the reference waveforms, and the initial offsets of a few millimetres in Rin, Rout, and Rx are included), and whether the coil currents and voltages stay within the PCS limits.

# tracking errors against the reference waveforms
ip_error = 100 * np.abs(dynamic_ip - ip_reference) / ip_reference
print(f"Ip: maximum deviation {np.max(ip_error):.2f}% (final {ip_error[-1]:.2f}%)")
for target_index, target in enumerate(ctrl_targets):
    if shape_data[target]["blend"]["vals"][0] > 0:
        error = np.abs(dynamic_shape[target_index] - shape_reference[target_index])
        print(f"{target}: maximum error {1e3 * np.max(error):.1f} mm, rms {1e3 * np.sqrt(np.mean(error**2)):.1f} mm")
    else:
        drift = 1e3 * np.max(np.abs(dynamic_shape[target_index] - dynamic_shape[target_index, 0]))
        print(f"{target} (uncontrolled): drift from the initial value {drift:.1f} mm")
print(f"Vertical position of the plasma: maximum |Z| = {np.max(np.abs(dynamic_z)):.1e} m")
print(f"Plasma limited at any time: {bool(np.any(dynamic_limited))}")

# limits (the metal currents of the active coils are the first n_active entries)
active_currents = dynamic_currents[:n_active]
current_ok = np.all((active_currents >= min_current_lims[:, None]) & (active_currents <= max_current_lims[:, None]))
margin = np.minimum(max_current_lims[:, None] - active_currents, active_currents - min_current_lims[:, None]).min(axis=1)
print(f"Coil currents within PCS limits: {current_ok} (smallest margin: {active_coils[np.argmin(margin)]}, {margin.min():.0f} A)")
print(f"Coil voltages within PCS limits: {bool(np.all(np.abs(voltages) <= voltage_limits[:, None] + 1e-9))}")
saturated = np.any(np.isclose(np.abs(voltages), voltage_limits[:, None]), axis=1)
print(f"Coils whose voltage saturates at some time: {[name for name, flag in zip(active_coils, saturated) if flag]}")
Ip: maximum deviation 0.28% (final 0.04%)
Rin: maximum error 8.8 mm, rms 3.4 mm
Rout: maximum error 14.3 mm, rms 4.6 mm
Rx: maximum error 12.2 mm, rms 4.6 mm
Zx (uncontrolled): drift from the initial value 17.2 mm
Rsp: maximum error 28.5 mm, rms 9.6 mm
Vertical position of the plasma: maximum |Z| = 4.0e-17 m
Plasma limited at any time: False
Coil currents within PCS limits: True (smallest margin: D2, 270 A)
Coil voltages within PCS limits: True
Coils whose voltage saturates at some time: []
from matplotlib.lines import Line2D

# pre-compute outer strikepoints before creating the figure, because
# equilibrium.strikepoints() internally calls plt.contour(...) and plt.close(),
# which would close the active figure if called inside the plotting loop
snapshot_strikepoints = {
    index: lower_outer_strikepoint(snapshots[index])
    for index in snapshot_indices
}

# evolution of the equilibrium: four snapshots, evenly spaced in time
fig, axes = plt.subplots(1, 4, figsize=(13, 7), dpi=80, sharex=True, sharey=True, constrained_layout=True)
for axis, index in zip(axes, snapshot_indices):
    snapshot = snapshots[index]
    snapshot.tokamak.plot(axis=axis, show=False)  # plots the active coils and passive structures
    snapshot.plot(axis=axis, show=False)  # plots the equilibrium and its separatrix
    rsp_snap, zsp_snap = snapshot_strikepoints[index]
    axis.plot([rsp_snap, rsp_snap], [zsp_snap, -zsp_snap], "ko", markersize=5, zorder=5)
    axis.set_title(f"t = {1e3 * times[index]:.0f} ms")
    axis.grid(alpha=0.5)
for axis in axes[1:]:
    axis.set_ylabel("")
axes[0].set_xlim(0.1, 2.15)
axes[0].set_ylim(-2.25, 2.25)
axes[-1].legend(
    handles=[
        Line2D([], [], color="r", label="separatrix"),
        Line2D([], [], color="r", marker="x", linestyle="", label="X-points"),
        Line2D([], [], color="g", marker="2", linestyle="", label="O-point"),
        Line2D([], [], color="k", marker="o", linestyle="", label="outer strikepoints"),
    ],
    loc="lower right",
    fontsize="small",
)

plt.show()
../_images/714ae0b9b7cc99d76025a493a60e81b0ad4b3012e6713ed5a433b02e24d8dced.png
# passive structure currents (the passive elements follow the active coils in the stored current vector)
passive_currents = dynamic_currents[n_active:]
passive_names = list(symmetric_machine.passive_names)
upper = np.array([passive_names.index(pair.upper_name) for pair in symmetric_machine.passive_pairs])
lower = np.array([passive_names.index(pair.lower_name) for pair in symmetric_machine.passive_pairs])
passive_centres = np.array([[np.mean(element["R"]), np.mean(element["Z"])] for element in symmetric_machine.passive_coils_data])
scale, unit = (1e-3, "kA") if np.max(np.abs(passive_currents)) > 1e3 else (1.0, "A")

fig, (time_axis, space_axis) = plt.subplots(1, 2, figsize=(13, 6), dpi=80, constrained_layout=True)

# time evolution: reflected partners carry identical currents, so only one element of each pair is drawn
largest = np.argsort(np.max(np.abs(passive_currents[upper]), axis=1))[::-1]
for rank, pair_index in enumerate(largest):
    label = passive_names[upper[pair_index]] if rank < 8 else None  # label the eight largest only
    time_axis.plot(t_ms, scale * passive_currents[upper[pair_index]], linewidth=1, label=label)
time_axis.set_xlabel("Time [ms]")
time_axis.set_ylabel(f"Passive structure current [{unit}]")
time_axis.set_title("Passive currents (one element per pair; the partners are identical)")
time_axis.legend(ncol=2, fontsize="small")
time_axis.grid(alpha=0.5)

# spatial distribution at the end of the simulation
limit = scale * np.max(np.abs(passive_currents[:, -1]))
points = space_axis.scatter(
    passive_centres[:, 0],
    passive_centres[:, 1],
    c=scale * passive_currents[:, -1],
    cmap="coolwarm",
    vmin=-limit,
    vmax=limit,
    s=40,
    edgecolor="k",
    zorder=3,
)
space_axis.plot(tokamak.limiter.R, tokamak.limiter.Z, "k-", linewidth=1.2)
space_axis.set_aspect("equal")
space_axis.set_xlabel("Major radius [m]")
space_axis.set_ylabel("Height [m]")
space_axis.set_title(f"Passive currents at t = {t_ms[-1]:.0f} ms")
space_axis.grid(alpha=0.5)
fig.colorbar(points, ax=space_axis, label=f"Passive structure current [{unit}]", shrink=0.6)
plt.show()

upper_lower_difference = np.max(np.abs(passive_currents[upper] - passive_currents[lower]))
print(f"Maximum upper/lower passive current difference: {upper_lower_difference:.2e} A")
../_images/e75a5b6b5efe4e81eb0d164c2cd90b157f43954b208affaa7d3f4508296729b1.png
Maximum upper/lower passive current difference: 1.42e-14 A

The passive structure currents are even in \(Z\): each upper element carries exactly the same current as its lower partner. The largest changes occur when the \(R_x\) and \(R_{\mathrm{sp}}\) ramps start and end, and the largest currents flow in the vessel, divertor coil cases, and structures closest to the plasma and divertor legs.

Finally, we look at the wall-clock time taken by each step of the evolutive solver (this excludes the virtual PCS calculation). The red markers show the steps in which the solver re-linearised, i.e. where the relative change in the toroidal current density since the last linearisation reached the threshold (5%). Re-linearisations are expensive because the Jacobians are rebuilt, and steps where the equilibrium changes rapidly during the \(R_x\) and \(R_{\mathrm{sp}}\) ramps also require more Newton-Krylov iterations in the inner Grad-Shafranov solve.

# wall-clock time of each evolutive solver step (the virtual PCS calculation is not included)
median_step = np.median(step_times)
t_step_ms = 1e3 * times[1:]  # time at the end of each step
relin_steps = np.flatnonzero(relinearise_criterion >= relinearise_threshold)  # steps in which the solver re-linearised

fig, (step_axis, total_axis) = plt.subplots(1, 2, figsize=(13, 4.5), dpi=80, constrained_layout=True)

step_axis.semilogy(t_step_ms, step_times, color="k", linewidth=0.8, label="all steps")
step_axis.semilogy(t_step_ms[relin_steps], step_times[relin_steps], "v", color="tab:red", markersize=7, label=f"re-linearisations ({len(relin_steps)})")
step_axis.axhline(median_step, color="tab:blue", linestyle="--", linewidth=1, label=f"median step ({1e3 * median_step:.0f} ms)")
step_axis.set_xlabel("Time [ms]")
step_axis.set_ylabel("Wall-clock time per solver step [s]")
step_axis.set_title("Time per step")
step_axis.legend(loc="lower right")
step_axis.grid(alpha=0.5, which="both")

total_axis.plot(t_step_ms, np.cumsum(step_times), color="k")
for step in relin_steps:
    total_axis.axvline(t_step_ms[step], color="tab:red", linestyle=":", linewidth=1)
total_axis.plot([], [], color="tab:red", linestyle=":", label="re-linearisation")
total_axis.set_xlabel("Simulated time [ms]")
total_axis.set_ylabel("Cumulative wall-clock time [s]")
total_axis.set_title(f"Total: {np.sum(step_times):.0f} s for {t_step_ms[-1]:.0f} ms of plasma evolution")
total_axis.legend()
total_axis.grid(alpha=0.5)
plt.show()

print(f"{len(step_times)} steps of {1e3 * dt:.1f} ms | median {1e3 * median_step:.0f} ms | total {np.sum(step_times):.0f} s")
print(f"{len(relin_steps)} re-linearisations, at t = {np.round(1e3 * times[relin_steps], 1)} ms")
../_images/2f6b756282cedbb4da4717eafb5c054b4a0df47a4e2a0ad58d3eb463d849b617.png
100 steps of 2.5 ms | median 27 ms | total 25 s
1 re-linearisations, at t = [222.5] ms