Example: Static inverse free-boundary equilibrium calculations (in KSTAR)


Here we generate a KSTAR-like equilibrium using the machine geometry in the FUSE.jl repository.

The equilibrium/profile parameters are a mixture of number from the source files and completely made up; please experiment on your own and change them to more realistic values as you please!

Note that there are no passive conducting structures in this description!

Import packages

import matplotlib.pyplot as plt

import numpy as np

Create the machine object

# build machine

from freegsnke import build_machine

tokamak = build_machine.tokamak(
    active_coils_path="../machine_configs/KSTAR/KSTAR_active_coils.pickle",
    limiter_path="../machine_configs/KSTAR/KSTAR_limiter.pickle",
    wall_path="../machine_configs/KSTAR/KSTAR_wall.pickle",
)
Active coils --> built from pickle file.
Passive structures --> none provided.
Limiter --> built from pickle file.
Wall --> built from pickle file.
Magnetic probes --> none provided.
Resistance (R) and inductance (M) matrices --> built using actives (and passives if present).
Tokamak built.
# plot the machine

fig, ax = plt.subplots(figsize=(8, 8), dpi=80)

tokamak.plot(axis=ax, show=False)  # plots the active coils
ax.plot(tokamak.limiter.R, tokamak.limiter.Z, "k-", linewidth=1.2)  # plots the limiter

ax.grid(alpha=0.5)
ax.set_aspect("equal")
ax.set_xlim(0.4, 3.9)
ax.set_ylim(-2.6, 2.6)
ax.set_xlabel(r"Major radius, $R$ [m]")
ax.set_ylabel(r"Height, $Z$ [m]")
Text(0, 0.5, 'Height, $Z$ [m]')
../_images/8a149efb294c08c8bade112786e275deaf1ae844737dde51a4e663cd2c07ea46.png

Instantiate an equilibrium

from freegsnke import equilibrium_update

eq = equilibrium_update.Equilibrium(
    tokamak=tokamak,      # provide tokamak object
    Rmin=1.2, Rmax=2.7,  # radial range
    Zmin=-1.5, Zmax=1.5,  # vertical range
    nx=129,               # number of radial grid points (needs to be of the form 2**n + 1)
    ny=129,               # number of vertical grid points (needs to be of the form 2**n + 1)
)

Instantiate a profile object

# initialise the profiles

from freegsnke.jtor_update import ConstrainPaxisIp

profiles = ConstrainPaxisIp(
    eq=eq,         # equilibrium object
    paxis=5.0e4,   # illustrative pressure on axis [Pa]
    Ip=0.8e6,      # plasma current from the FUSE KSTAR case [A]
    fvac=3.24,     # abs(B0) * R0 from the FUSE KSTAR case [T m]
    alpha_m=1.8,   # profile function parameter
    alpha_n=1.2,   # profile function parameter
)

Load the static nonlinear solver

from freegsnke import GSstaticsolver

GSStaticSolver = GSstaticsolver.NKGSsolver(eq, seed=42)

Constraints

# set the desired lower X-point and magnetic-axis locations
Rx, Zx = 1.40, -1.05
null_points = [[Rx,Rx], [Zx, -Zx]]

# constrain boundary points to the same flux surface
isoflux_set = np.array([[
    [1.31, 2.23, Rx, Rx],
    [0.0, 0.0, Zx, -Zx],
]])

from freegsnke.inverse import Inverse_optimizer

constrain = Inverse_optimizer(
    null_points=null_points,
    isoflux_set=isoflux_set,
)

The inverse solve

GSStaticSolver.inverse_solve(
    eq=eq,
    profiles=profiles,
    constrain=constrain,
    target_relative_tolerance=1e-5,
    target_relative_psit_update=1e-3,
    max_solving_iterations=100,
    l2_reg=np.array([1e-14] * 14),
    Picard_handover=1e-4,
    force_up_down_symmetric=True,
    verbose=True,    
)
-----
Inverse static solve starting...
Successfully computed GS residual using initial plasma_psi and tokamak_psi guesses.
Initial relative error = 1.10e+00
-----
Iteration: 0
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-4.44e+03', '-4.44e+03', '-1.47e+04', '-1.47e+04', '-1.38e+03', '-1.38e+03', '6.75e+03', '6.75e+03', '4.71e+03', '4.71e+03', '-2.04e+04', '-2.04e+04', '1.58e+04', '1.58e+04']
Constraint losses = 5.27e-01
Relative update of tokamak psi (in plasma core): 9.27e+07
Handing off to forward solve (with updated currents).
Relative error =  8.47e-01
-----
Iteration: 1
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-7.10e+02', '-7.10e+02', '5.05e+03', '5.05e+03', '8.30e+02', '8.30e+02', '-1.77e+03', '-1.77e+03', '-4.84e+02', '-4.84e+02', '6.33e+03', '6.33e+03', '-7.15e+03', '-7.15e+03']
Constraint losses = 8.26e-02
Relative update of tokamak psi (in plasma core): 6.23e-02
Handing off to forward solve (with updated currents).
Relative error =  6.40e-01
-----
Iteration: 2
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-6.30e+02', '-6.30e+02', '4.24e+03', '4.24e+03', '7.07e+02', '7.07e+02', '-1.46e+03', '-1.46e+03', '-4.28e+02', '-4.28e+02', '5.29e+03', '5.29e+03', '-5.94e+03', '-5.94e+03']
Constraint losses = 6.83e-02
Relative update of tokamak psi (in plasma core): 6.36e-02
Handing off to forward solve (with updated currents).
Relative error =  4.01e-01
-----
Iteration: 3
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-5.31e+02', '-5.31e+02', '3.50e+03', '3.50e+03', '5.88e+02', '5.88e+02', '-1.21e+03', '-1.21e+03', '-3.63e+02', '-3.63e+02', '4.38e+03', '4.38e+03', '-4.89e+03', '-4.89e+03']
Constraint losses = 5.60e-02
Relative update of tokamak psi (in plasma core): 6.43e-02
Handing off to forward solve (with updated currents).
Relative error =  1.17e-01
-----
Iteration: 4
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-4.12e+02', '-4.12e+02', '2.81e+03', '2.81e+03', '4.68e+02', '4.68e+02', '-9.73e+02', '-9.73e+02', '-2.90e+02', '-2.90e+02', '3.52e+03', '3.52e+03', '-3.92e+03', '-3.92e+03']
Constraint losses = 4.50e-02
Relative update of tokamak psi (in plasma core): 6.33e-02
Handing off to forward solve (with updated currents).
Relative error =  2.30e-03
-----
Iteration: 5
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['4.35e+01', '4.35e+01', '8.10e+02', '8.10e+02', '9.06e+01', '9.06e+01', '-3.53e+02', '-3.53e+02', '-3.86e+01', '-3.86e+01', '1.06e+03', '1.06e+03', '-1.27e+03', '-1.27e+03']
Constraint losses = 1.64e-02
Relative update of tokamak psi (in plasma core): 2.25e-02
Handing off to forward solve (with updated currents).
Relative error =  2.81e-03
-----
Iteration: 6
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-5.79e+01', '-5.79e+01', '-5.25e+02', '-5.25e+02', '-5.52e+01', '-5.52e+01', '2.32e+02', '2.32e+02', '3.63e+01', '3.63e+01', '-6.08e+02', '-6.08e+02', '8.89e+02', '8.89e+02']
Constraint losses = 1.92e-02
Relative update of tokamak psi (in plasma core): 7.79e-03
Handing off to forward solve (with updated currents).
Relative error =  5.53e-03
-----
Iteration: 7
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['3.94e+02', '3.94e+02', '3.21e+02', '3.21e+02', '-7.06e+01', '-7.06e+01', '-3.13e+02', '-3.13e+02', '1.20e+02', '1.20e+02', '4.75e+02', '4.75e+02', '-9.27e+02', '-9.27e+02']
Constraint losses = 3.18e-02
Relative update of tokamak psi (in plasma core): 8.13e-03
Handing off to forward solve (with updated currents).
Relative error =  9.54e-03
-----
Iteration: 8
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-7.90e+02', '-7.90e+02', '-3.22e+02', '-3.22e+02', '1.86e+02', '1.86e+02', '5.02e+02', '5.02e+02', '-2.77e+02', '-2.77e+02', '-5.88e+02', '-5.88e+02', '1.35e+03', '1.35e+03']
Constraint losses = 5.47e-02
Relative update of tokamak psi (in plasma core): 1.24e-02
Handing off to forward solve (with updated currents).
Relative error =  1.73e-02
-----
Iteration: 9
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['1.38e+03', '1.38e+03', '6.07e+02', '6.07e+02', '-3.16e+02', '-3.16e+02', '-8.92e+02', '-8.92e+02', '4.73e+02', '4.73e+02', '1.07e+03', '1.07e+03', '-2.42e+03', '-2.42e+03']
Constraint losses = 9.68e-02
Relative update of tokamak psi (in plasma core): 2.51e-02
Handing off to forward solve (with updated currents).
Relative error =  2.97e-02
-----
Iteration: 10
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-1.84e+03', '-1.84e+03', '-1.71e+02', '-1.71e+02', '5.17e+02', '5.17e+02', '9.53e+02', '9.53e+02', '-7.40e+02', '-7.40e+02', '-7.44e+02', '-7.44e+02', '2.27e+03', '2.27e+03']
Constraint losses = 1.59e-01
Relative update of tokamak psi (in plasma core): 2.24e-02
Handing off to forward solve (with updated currents).
Relative error =  3.26e-02
-----
Iteration: 11
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['9.62e+02', '9.62e+02', '4.33e+00', '4.33e+00', '-2.81e+02', '-2.81e+02', '-4.63e+02', '-4.63e+02', '3.91e+02', '3.91e+02', '2.88e+02', '2.88e+02', '-1.05e+03', '-1.05e+03']
Constraint losses = 1.14e-01
Relative update of tokamak psi (in plasma core): 1.58e-02
Handing off to forward solve (with updated currents).
Relative error =  9.22e-03
-----
Iteration: 12
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['2.29e+02', '2.29e+02', '-2.46e+02', '-2.46e+02', '-1.04e+02', '-1.04e+02', '-1.98e+01', '-1.98e+01', '1.41e+02', '1.41e+02', '-1.94e+02', '-1.94e+02', '1.16e+02', '1.16e+02']
Constraint losses = 6.90e-03
Relative update of tokamak psi (in plasma core): 3.47e-03
Handing off to forward solve (with updated currents).
Relative error =  6.22e-03
-----
Iteration: 13
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-5.38e+02', '-5.38e+02', '-1.21e+02', '-1.21e+02', '1.40e+02', '1.40e+02', '3.03e+02', '3.03e+02', '-1.99e+02', '-1.99e+02', '-2.89e+02', '-2.89e+02', '7.64e+02', '7.64e+02']
Constraint losses = 3.52e-02
Relative update of tokamak psi (in plasma core): 7.68e-03
Handing off to forward solve (with updated currents).
Relative error =  1.07e-02
-----
Iteration: 14
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['8.04e+02', '8.04e+02', '3.11e+02', '3.11e+02', '-1.91e+02', '-1.91e+02', '-5.05e+02', '-5.05e+02', '2.82e+02', '2.82e+02', '5.79e+02', '5.79e+02', '-1.35e+03', '-1.35e+03']
Constraint losses = 5.95e-02
Relative update of tokamak psi (in plasma core): 1.37e-02
Handing off to forward solve (with updated currents).
Relative error =  1.62e-02
-----
Iteration: 15
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-9.39e+02', '-9.39e+02', '-3.06e+02', '-3.06e+02', '2.31e+02', '2.31e+02', '5.67e+02', '5.67e+02', '-3.37e+02', '-3.37e+02', '-6.12e+02', '-6.12e+02', '1.49e+03', '1.49e+03']
Constraint losses = 8.79e-02
Relative update of tokamak psi (in plasma core): 1.38e-02
Handing off to forward solve (with updated currents).
Relative error =  1.74e-02
-----
Iteration: 16
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['7.13e+02', '7.13e+02', '2.19e+02', '2.19e+02', '-1.77e+02', '-1.77e+02', '-4.25e+02', '-4.25e+02', '2.57e+02', '2.57e+02', '4.49e+02', '4.49e+02', '-1.11e+03', '-1.11e+03']
Constraint losses = 7.05e-02
Relative update of tokamak psi (in plasma core): 1.20e-02
Handing off to forward solve (with updated currents).
Relative error =  1.10e-02
-----
Iteration: 17
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-5.51e+02', '-5.51e+02', '-2.25e+02', '-2.25e+02', '1.29e+02', '1.29e+02', '3.50e+02', '3.50e+02', '-1.91e+02', '-1.91e+02', '-4.09e+02', '-4.09e+02', '9.40e+02', '9.40e+02']
Constraint losses = 3.98e-02
Relative update of tokamak psi (in plasma core): 8.68e-03
Handing off to forward solve (with updated currents).
Relative error =  1.01e-02
-----
Iteration: 18
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['5.41e+02', '5.41e+02', '2.13e+02', '2.13e+02', '-1.28e+02', '-1.28e+02', '-3.41e+02', '-3.41e+02', '1.89e+02', '1.89e+02', '3.94e+02', '3.94e+02', '-9.13e+02', '-9.13e+02']
Constraint losses = 5.47e-02
Relative update of tokamak psi (in plasma core): 9.18e-03
Handing off to forward solve (with updated currents).
Relative error =  9.99e-03
-----
Iteration: 19
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-5.48e+02', '-5.48e+02', '-2.15e+02', '-2.15e+02', '1.30e+02', '1.30e+02', '3.45e+02', '3.45e+02', '-1.92e+02', '-1.92e+02', '-3.97e+02', '-3.97e+02', '9.22e+02', '9.22e+02']
Constraint losses = 3.97e-02
Relative update of tokamak psi (in plasma core): 8.56e-03
Handing off to forward solve (with updated currents).
Relative error =  1.03e-02
-----
Iteration: 20
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['5.94e+02', '5.94e+02', '2.34e+02', '2.34e+02', '-1.40e+02', '-1.40e+02', '-3.74e+02', '-3.74e+02', '2.08e+02', '2.08e+02', '4.32e+02', '4.32e+02', '-1.00e+03', '-1.00e+03']
Constraint losses = 5.58e-02
Relative update of tokamak psi (in plasma core): 1.01e-02
Handing off to forward solve (with updated currents).
Relative error =  1.12e-02
-----
Iteration: 21
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-6.14e+02', '-6.14e+02', '-2.31e+02', '-2.31e+02', '1.47e+02', '1.47e+02', '3.83e+02', '3.83e+02', '-2.17e+02', '-2.17e+02', '-4.35e+02', '-4.35e+02', '1.02e+03', '1.02e+03']
Constraint losses = 4.92e-02
Relative update of tokamak psi (in plasma core): 9.50e-03
Handing off to forward solve (with updated currents).
Relative error =  1.15e-02
-----
Iteration: 22
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['5.21e+02', '5.21e+02', '1.94e+02', '1.94e+02', '-1.25e+02', '-1.25e+02', '-3.24e+02', '-3.24e+02', '1.84e+02', '1.84e+02', '3.66e+02', '3.66e+02', '-8.61e+02', '-8.61e+02']
Constraint losses = 5.67e-02
Relative update of tokamak psi (in plasma core): 8.79e-03
Handing off to forward solve (with updated currents).
Relative error =  8.87e-03
-----
Iteration: 23
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-3.95e+02', '-3.95e+02', '-1.64e+02', '-1.64e+02', '9.23e+01', '9.23e+01', '2.52e+02', '2.52e+02', '-1.37e+02', '-1.37e+02', '-2.97e+02', '-2.97e+02', '6.79e+02', '6.79e+02']
Constraint losses = 2.95e-02
Relative update of tokamak psi (in plasma core): 6.32e-03
Handing off to forward solve (with updated currents).
Relative error =  6.81e-03
-----
Iteration: 24
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['4.75e+02', '4.75e+02', '1.78e+02', '1.78e+02', '-1.14e+02', '-1.14e+02', '-2.96e+02', '-2.96e+02', '1.67e+02', '1.67e+02', '3.35e+02', '3.35e+02', '-7.87e+02', '-7.87e+02']
Constraint losses = 3.61e-02
Relative update of tokamak psi (in plasma core): 7.87e-03
Handing off to forward solve (with updated currents).
Relative error =  9.41e-03
-----
Iteration: 25
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-5.02e+02', '-5.02e+02', '-1.74e+02', '-1.74e+02', '1.22e+02', '1.22e+02', '3.07e+02', '3.07e+02', '-1.79e+02', '-1.79e+02', '-3.39e+02', '-3.39e+02', '8.10e+02', '8.10e+02']
Constraint losses = 4.98e-02
Relative update of tokamak psi (in plasma core): 7.63e-03
Handing off to forward solve (with updated currents).
Relative error =  9.03e-03
-----
Iteration: 26
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['4.64e+02', '4.64e+02', '1.44e+02', '1.44e+02', '-1.15e+02', '-1.15e+02', '-2.77e+02', '-2.77e+02', '1.67e+02', '1.67e+02', '2.94e+02', '2.94e+02', '-7.22e+02', '-7.22e+02']
Constraint losses = 3.42e-02
Relative update of tokamak psi (in plasma core): 7.45e-03
Handing off to forward solve (with updated currents).
Relative error =  7.99e-03
-----
Iteration: 27
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-4.68e+02', '-4.68e+02', '-1.52e+02', '-1.52e+02', '1.15e+02', '1.15e+02', '2.83e+02', '2.83e+02', '-1.68e+02', '-1.68e+02', '-3.05e+02', '-3.05e+02', '7.40e+02', '7.40e+02']
Constraint losses = 4.19e-02
Relative update of tokamak psi (in plasma core): 7.03e-03
Handing off to forward solve (with updated currents).
Relative error =  8.69e-03
-----
Iteration: 28
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['4.04e+02', '4.04e+02', '1.41e+02', '1.41e+02', '-9.82e+01', '-9.82e+01', '-2.47e+02', '-2.47e+02', '1.44e+02', '1.44e+02', '2.73e+02', '2.73e+02', '-6.53e+02', '-6.53e+02']
Constraint losses = 3.80e-02
Relative update of tokamak psi (in plasma core): 6.63e-03
Handing off to forward solve (with updated currents).
Relative error =  6.84e-03
-----
Iteration: 29
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-3.72e+02', '-3.72e+02', '-1.37e+02', '-1.37e+02', '8.94e+01', '8.94e+01', '2.30e+02', '2.30e+02', '-1.31e+02', '-1.31e+02', '-2.59e+02', '-2.59e+02', '6.12e+02', '6.12e+02']
Constraint losses = 2.81e-02
Relative update of tokamak psi (in plasma core): 5.80e-03
Handing off to forward solve (with updated currents).
Relative error =  6.87e-03
-----
Iteration: 30
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['3.73e+02', '3.73e+02', '1.40e+02', '1.40e+02', '-8.91e+01', '-8.91e+01', '-2.32e+02', '-2.32e+02', '1.31e+02', '1.31e+02', '2.63e+02', '2.63e+02', '-6.18e+02', '-6.18e+02']
Constraint losses = 3.59e-02
Relative update of tokamak psi (in plasma core): 6.17e-03
Handing off to forward solve (with updated currents).
Relative error =  6.86e-03
-----
Iteration: 31
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-3.73e+02', '-3.73e+02', '-1.40e+02', '-1.40e+02', '8.92e+01', '8.92e+01', '2.32e+02', '2.32e+02', '-1.31e+02', '-1.31e+02', '-2.64e+02', '-2.64e+02', '6.19e+02', '6.19e+02']
Constraint losses = 2.86e-02
Relative update of tokamak psi (in plasma core): 5.83e-03
Handing off to forward solve (with updated currents).
Relative error =  6.92e-03
-----
Iteration: 32
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['3.39e+02', '3.39e+02', '1.27e+02', '1.27e+02', '-8.10e+01', '-8.10e+01', '-2.11e+02', '-2.11e+02', '1.19e+02', '1.19e+02', '2.39e+02', '2.39e+02', '-5.61e+02', '-5.61e+02']
Constraint losses = 3.58e-02
Relative update of tokamak psi (in plasma core): 5.61e-03
Handing off to forward solve (with updated currents).
Relative error =  5.96e-03
-----
Iteration: 33
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-2.74e+02', '-2.74e+02', '-1.06e+02', '-1.06e+02', '6.50e+01', '6.50e+01', '1.72e+02', '1.72e+02', '-9.60e+01', '-9.60e+01', '-1.97e+02', '-1.97e+02', '4.59e+02', '4.59e+02']
Constraint losses = 2.13e-02
Relative update of tokamak psi (in plasma core): 4.35e-03
Handing off to forward solve (with updated currents).
Relative error =  4.72e-03
-----
Iteration: 34
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['3.03e+02', '3.03e+02', '1.09e+02', '1.09e+02', '-7.33e+01', '-7.33e+01', '-1.87e+02', '-1.87e+02', '1.08e+02', '1.08e+02', '2.08e+02', '2.08e+02', '-4.95e+02', '-4.95e+02']
Constraint losses = 2.40e-02
Relative update of tokamak psi (in plasma core): 4.91e-03
Handing off to forward solve (with updated currents).
Relative error =  5.87e-03
-----
Iteration: 35
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-3.00e+02', '-3.00e+02', '-1.06e+02', '-1.06e+02', '7.27e+01', '7.27e+01', '1.84e+02', '1.84e+02', '-1.07e+02', '-1.07e+02', '-2.05e+02', '-2.05e+02', '4.88e+02', '4.88e+02']
Constraint losses = 2.98e-02
Relative update of tokamak psi (in plasma core): 4.64e-03
Handing off to forward solve (with updated currents).
Relative error =  5.32e-03
-----
Iteration: 36
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['2.65e+02', '2.65e+02', '8.58e+01', '8.58e+01', '-6.52e+01', '-6.52e+01', '-1.60e+02', '-1.60e+02', '9.50e+01', '9.50e+01', '1.72e+02', '1.72e+02', '-4.18e+02', '-4.18e+02']
Constraint losses = 2.03e-02
Relative update of tokamak psi (in plasma core): 4.19e-03
Handing off to forward solve (with updated currents).
Relative error =  4.55e-03
-----
Iteration: 37
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-2.69e+02', '-2.69e+02', '-9.09e+01', '-9.09e+01', '6.58e+01', '6.58e+01', '1.64e+02', '1.64e+02', '-9.61e+01', '-9.61e+01', '-1.79e+02', '-1.79e+02', '4.30e+02', '4.30e+02']
Constraint losses = 2.30e-02
Relative update of tokamak psi (in plasma core): 4.15e-03
Handing off to forward solve (with updated currents).
Relative error =  5.04e-03
-----
Iteration: 38
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['2.41e+02', '2.41e+02', '8.66e+01', '8.66e+01', '-5.81e+01', '-5.81e+01', '-1.48e+02', '-1.48e+02', '8.54e+01', '8.54e+01', '1.66e+02', '1.66e+02', '-3.93e+02', '-3.93e+02']
Constraint losses = 2.34e-02
Relative update of tokamak psi (in plasma core): 3.89e-03
Handing off to forward solve (with updated currents).
Relative error =  4.14e-03
-----
Iteration: 39
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-2.08e+02', '-2.08e+02', '-7.58e+01', '-7.58e+01', '5.02e+01', '5.02e+01', '1.29e+02', '1.29e+02', '-7.38e+01', '-7.38e+01', '-1.44e+02', '-1.44e+02', '3.42e+02', '3.42e+02']
Constraint losses = 1.65e-02
Relative update of tokamak psi (in plasma core): 3.27e-03
Handing off to forward solve (with updated currents).
Relative error =  3.70e-03
-----
Iteration: 40
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['2.15e+02', '2.15e+02', '7.74e+01', '7.74e+01', '-5.20e+01', '-5.20e+01', '-1.33e+02', '-1.33e+02', '7.64e+01', '7.64e+01', '1.48e+02', '1.48e+02', '-3.52e+02', '-3.52e+02']
Constraint losses = 1.85e-02
Relative update of tokamak psi (in plasma core): 3.47e-03
Handing off to forward solve (with updated currents).
Relative error =  4.02e-03
-----
Iteration: 41
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-2.08e+02', '-2.08e+02', '-7.51e+01', '-7.51e+01', '5.00e+01', '5.00e+01', '1.28e+02', '1.28e+02', '-7.36e+01', '-7.36e+01', '-1.44e+02', '-1.44e+02', '3.40e+02', '3.40e+02']
Constraint losses = 1.90e-02
Relative update of tokamak psi (in plasma core): 3.25e-03
Handing off to forward solve (with updated currents).
Relative error =  3.72e-03
-----
Iteration: 42
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['1.90e+02', '1.90e+02', '6.60e+01', '6.60e+01', '-4.63e+01', '-4.63e+01', '-1.16e+02', '-1.16e+02', '6.78e+01', '6.78e+01', '1.28e+02', '1.28e+02', '-3.07e+02', '-3.07e+02']
Constraint losses = 1.60e-02
Relative update of tokamak psi (in plasma core): 3.05e-03
Handing off to forward solve (with updated currents).
Relative error =  3.35e-03
-----
Iteration: 43
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-1.84e+02', '-1.84e+02', '-6.51e+01', '-6.51e+01', '4.46e+01', '4.46e+01', '1.13e+02', '1.13e+02', '-6.55e+01', '-6.55e+01', '-1.26e+02', '-1.26e+02', '2.99e+02', '2.99e+02']
Constraint losses = 1.59e-02
Relative update of tokamak psi (in plasma core): 2.88e-03
Handing off to forward solve (with updated currents).
Relative error =  3.38e-03
-----
Iteration: 44
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['1.67e+02', '1.67e+02', '5.98e+01', '5.98e+01', '-4.03e+01', '-4.03e+01', '-1.03e+02', '-1.03e+02', '5.92e+01', '5.92e+01', '1.15e+02', '1.15e+02', '-2.72e+02', '-2.72e+02']
Constraint losses = 1.55e-02
Relative update of tokamak psi (in plasma core): 2.69e-03
Handing off to forward solve (with updated currents).
Relative error =  2.92e-03
-----
Iteration: 45
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-1.51e+02', '-1.51e+02', '-5.41e+01', '-5.41e+01', '3.66e+01', '3.66e+01', '9.33e+01', '9.33e+01', '-5.38e+01', '-5.38e+01', '-1.04e+02', '-1.04e+02', '2.47e+02', '2.47e+02']
Constraint losses = 1.23e-02
Relative update of tokamak psi (in plasma core): 2.36e-03
Handing off to forward solve (with updated currents).
Relative error =  2.72e-03
-----
Iteration: 46
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['1.48e+02', '1.48e+02', '5.28e+01', '5.28e+01', '-3.58e+01', '-3.58e+01', '-9.11e+01', '-9.11e+01', '5.25e+01', '5.25e+01', '1.01e+02', '1.01e+02', '-2.41e+02', '-2.41e+02']
Constraint losses = 1.32e-02
Relative update of tokamak psi (in plasma core): 2.38e-03
Handing off to forward solve (with updated currents).
Relative error =  2.70e-03
-----
Iteration: 47
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-1.42e+02', '-1.42e+02', '-5.12e+01', '-5.12e+01', '3.43e+01', '3.43e+01', '8.76e+01', '8.76e+01', '-5.04e+01', '-5.04e+01', '-9.80e+01', '-9.80e+01', '2.32e+02', '2.32e+02']
Constraint losses = 1.21e-02
Relative update of tokamak psi (in plasma core): 2.22e-03
Handing off to forward solve (with updated currents).
Relative error =  2.58e-03
-----
Iteration: 48
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['1.29e+02', '1.29e+02', '4.58e+01', '4.58e+01', '-3.12e+01', '-3.12e+01', '-7.93e+01', '-7.93e+01', '4.58e+01', '4.58e+01', '8.82e+01', '8.82e+01', '-2.10e+02', '-2.10e+02']
Constraint losses = 1.20e-02
Relative update of tokamak psi (in plasma core): 2.07e-03
Handing off to forward solve (with updated currents).
Relative error =  2.27e-03
-----
Iteration: 49
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-1.16e+02', '-1.16e+02', '-4.12e+01', '-4.12e+01', '2.81e+01', '2.81e+01', '7.13e+01', '7.13e+01', '-4.12e+01', '-4.12e+01', '-7.93e+01', '-7.93e+01', '1.89e+02', '1.89e+02']
Constraint losses = 9.63e-03
Relative update of tokamak psi (in plasma core): 1.81e-03
Handing off to forward solve (with updated currents).
Relative error =  2.07e-03
-----
Iteration: 50
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['1.12e+02', '1.12e+02', '3.93e+01', '3.93e+01', '-2.70e+01', '-2.70e+01', '-6.85e+01', '-6.85e+01', '3.97e+01', '3.97e+01', '7.59e+01', '7.59e+01', '-1.81e+02', '-1.81e+02']
Constraint losses = 9.81e-03
Relative update of tokamak psi (in plasma core): 1.78e-03
Handing off to forward solve (with updated currents).
Relative error =  2.03e-03
-----
Iteration: 51
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-1.06e+02', '-1.06e+02', '-3.77e+01', '-3.77e+01', '2.55e+01', '2.55e+01', '6.50e+01', '6.50e+01', '-3.75e+01', '-3.75e+01', '-7.24e+01', '-7.24e+01', '1.72e+02', '1.72e+02']
Constraint losses = 9.19e-03
Relative update of tokamak psi (in plasma core): 1.65e-03
Handing off to forward solve (with updated currents).
Relative error =  1.90e-03
-----
Iteration: 52
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['9.74e+01', '9.74e+01', '3.42e+01', '3.42e+01', '-2.36e+01', '-2.36e+01', '-5.97e+01', '-5.97e+01', '3.46e+01', '3.46e+01', '6.62e+01', '6.62e+01', '-1.58e+02', '-1.58e+02']
Constraint losses = 8.63e-03
Relative update of tokamak psi (in plasma core): 1.55e-03
Handing off to forward solve (with updated currents).
Relative error =  1.73e-03
-----
Iteration: 53
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-9.12e+01', '-9.12e+01', '-3.20e+01', '-3.20e+01', '2.21e+01', '2.21e+01', '5.60e+01', '5.60e+01', '-3.24e+01', '-3.24e+01', '-6.20e+01', '-6.20e+01', '1.48e+02', '1.48e+02']
Constraint losses = 7.72e-03
Relative update of tokamak psi (in plasma core): 1.43e-03
Handing off to forward solve (with updated currents).
Relative error =  1.65e-03
-----
Iteration: 54
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['8.34e+01', '8.34e+01', '2.93e+01', '2.93e+01', '-2.02e+01', '-2.02e+01', '-5.12e+01', '-5.12e+01', '2.97e+01', '2.97e+01', '5.67e+01', '5.67e+01', '-1.35e+02', '-1.35e+02']
Constraint losses = 7.68e-03
Relative update of tokamak psi (in plasma core): 1.33e-03
Handing off to forward solve (with updated currents).
Relative error =  1.48e-03
-----
Iteration: 55
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-7.36e+01', '-7.36e+01', '-2.57e+01', '-2.57e+01', '1.79e+01', '1.79e+01', '4.51e+01', '4.51e+01', '-2.62e+01', '-2.62e+01', '-4.99e+01', '-4.99e+01', '1.19e+02', '1.19e+02']
Constraint losses = 6.29e-03
Relative update of tokamak psi (in plasma core): 1.15e-03
Handing off to forward solve (with updated currents).
Relative error =  1.29e-03
-----
Iteration: 56
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['6.92e+01', '6.92e+01', '2.38e+01', '2.38e+01', '-1.69e+01', '-1.69e+01', '-4.23e+01', '-4.23e+01', '2.46e+01', '2.46e+01', '4.65e+01', '4.65e+01', '-1.11e+02', '-1.11e+02']
Constraint losses = 5.93e-03
Relative update of tokamak psi (in plasma core): 1.10e-03
Handing off to forward solve (with updated currents).
Relative error =  1.25e-03
-----
Iteration: 57
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-6.67e+01', '-6.67e+01', '-2.33e+01', '-2.33e+01', '1.62e+01', '1.62e+01', '4.08e+01', '4.08e+01', '-2.37e+01', '-2.37e+01', '-4.51e+01', '-4.51e+01', '1.08e+02', '1.08e+02']
Constraint losses = 5.77e-03
Relative update of tokamak psi (in plasma core): 1.04e-03
Handing off to forward solve (with updated currents).
Relative error =  1.21e-03
-----
Iteration: 58
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['6.06e+01', '6.06e+01', '2.11e+01', '2.11e+01', '-1.47e+01', '-1.47e+01', '-3.71e+01', '-3.71e+01', '2.15e+01', '2.15e+01', '4.09e+01', '4.09e+01', '-9.79e+01', '-9.79e+01']
Constraint losses = 5.50e-03
Relative update of tokamak psi (in plasma core): 9.62e-04
Handing off to forward solve (with updated currents).
Relative error =  1.06e-03
-----
Iteration: 59
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-5.27e+01', '-5.27e+01', '-1.82e+01', '-1.82e+01', '1.28e+01', '1.28e+01', '3.22e+01', '3.22e+01', '-1.87e+01', '-1.87e+01', '-3.54e+01', '-3.54e+01', '8.48e+01', '8.48e+01']
Constraint losses = 4.58e-03
Relative update of tokamak psi (in plasma core): 8.25e-04
Handing off to forward solve (with updated currents).
Relative error =  9.17e-04
-----
Iteration: 60
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['4.72e+01', '4.72e+01', '1.60e+01', '1.60e+01', '-1.15e+01', '-1.15e+01', '-2.87e+01', '-2.87e+01', '1.68e+01', '1.68e+01', '3.14e+01', '3.14e+01', '-7.56e+01', '-7.56e+01']
Constraint losses = 4.12e-03
Relative update of tokamak psi (in plasma core): 7.44e-04
Handing off to forward solve (with updated currents).
Relative error =  8.32e-04
-----
Iteration: 61
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-4.27e+01', '-4.27e+01', '-1.47e+01', '-1.47e+01', '1.04e+01', '1.04e+01', '2.60e+01', '2.60e+01', '-1.52e+01', '-1.52e+01', '-2.86e+01', '-2.86e+01', '6.86e+01', '6.86e+01']
Constraint losses = 3.75e-03
Relative update of tokamak psi (in plasma core): 6.68e-04
Handing off to forward solve (with updated currents).
Relative error =  7.53e-04
-----
Iteration: 62
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['3.81e+01', '3.81e+01', '1.30e+01', '1.30e+01', '-9.29e+00', '-9.29e+00', '-2.32e+01', '-2.32e+01', '1.36e+01', '1.36e+01', '2.54e+01', '2.54e+01', '-6.11e+01', '-6.11e+01']
Constraint losses = 3.36e-03
Relative update of tokamak psi (in plasma core): 6.01e-04
Handing off to forward solve (with updated currents).
Relative error =  6.66e-04
-----
Iteration: 63
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-3.34e+01', '-3.34e+01', '-1.14e+01', '-1.14e+01', '8.15e+00', '8.15e+00', '2.04e+01', '2.04e+01', '-1.19e+01', '-1.19e+01', '-2.23e+01', '-2.23e+01', '5.36e+01', '5.36e+01']
Constraint losses = 2.96e-03
Relative update of tokamak psi (in plasma core): 5.23e-04
Handing off to forward solve (with updated currents).
Relative error =  5.82e-04
-----
Iteration: 64
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['2.88e+01', '2.88e+01', '9.76e+00', '9.76e+00', '-7.03e+00', '-7.03e+00', '-1.75e+01', '-1.75e+01', '1.03e+01', '1.03e+01', '1.91e+01', '1.91e+01', '-4.61e+01', '-4.61e+01']
Constraint losses = 2.56e-03
Relative update of tokamak psi (in plasma core): 4.53e-04
Handing off to forward solve (with updated currents).
Relative error =  4.97e-04
-----
Iteration: 65
Using simplified Green's Jacobian (of constraints wrt coil currents) to optimise the currents.
Change in coil currents (being controlled): ['-2.43e+01', '-2.43e+01', '-8.24e+00', '-8.24e+00', '5.94e+00', '5.94e+00', '1.48e+01', '1.48e+01', '-8.67e+00', '-8.67e+00', '-1.62e+01', '-1.62e+01', '3.89e+01', '3.89e+01']
Constraint losses = 2.18e-03
Relative update of tokamak psi (in plasma core): 3.80e-04
Handing off to forward solve (with updated currents).
Relative error =  4.87e-07
-----
Inverse static solve SUCCESS. Tolerance 4.87e-07 (vs. requested 1e-05) reached in 66/100 iterations.
# refine with a forward solve (now the currents are known)
GSStaticSolver.solve(eq=eq, 
                     profiles=profiles, 
                     constrain=None, 
                     target_relative_tolerance=1e-9,
                     verbose=False, # suppress output
                     )
Forward static solve SUCCESS. Tolerance 2.40e-10 (vs. requested 1.00e-09) reached in 4/100 iterations.
fig, ax = plt.subplots(figsize=(8, 8), dpi=80)

ax.grid(zorder=0, alpha=0.75)
ax.set_aspect("equal")
eq.tokamak.plot(axis=ax, show=False)  # plots the active coils
eq.plot(axis=ax, show=False)          # plots the equilibrium
constrain.plot(axis=ax, show=False)   # plots the constraints
ax.plot(tokamak.limiter.R, tokamak.limiter.Z, "k-", linewidth=1.2)  # plots the limiter
# ax.set_xlim(1.15, 2.4)
# ax.set_ylim(-1.55, 1.55)
ax.set_xlabel(r"Major radius, $R$ [m]")
ax.set_ylabel(r"Height, $Z$ [m]")
Text(0, 0.5, 'Height, $Z$ [m]')
../_images/0cde6ebc325c1f9eb95543c59b7e40351dde49f20df1b380cd426b1993c4f5f8.png
eq.tokamak.getCurrents()
{'PF1U': np.float64(-6628.683750688479),
 'PF1L': np.float64(-6628.683750681524),
 'PF2U': np.float64(1362.6859527831498),
 'PF2L': np.float64(1362.6859527880513),
 'PF3U': np.float64(1242.3101590720244),
 'PF3L': np.float64(1242.3101590750575),
 'PF4U': np.float64(1098.237968010093),
 'PF4L': np.float64(1098.2379680039885),
 'PF5U': np.float64(3169.157944785308),
 'PF5L': np.float64(3169.157944778581),
 'PF6U': np.float64(-233.54640569441412),
 'PF6L': np.float64(-233.54640568707595),
 'PF7U': np.float64(-6859.870268227103),
 'PF7L': np.float64(-6859.870268235167)}