freegsnke.simplified_solve module

Implements a ‘simplified’ set of discretised current equations (coupling metals and plasma) in which the normalised distribution of the plasma current is assumed known (but not the magnitude of the plasma current). This makes the system of current equations linear.

Copyright 2025 UKAEA, UKRI-STFC, and The Authors, as per the COPYRIGHT and README files.

This file is part of FreeGSNKE.

FreeGSNKE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

FreeGSNKE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

You should have received a copy of the GNU Lesser General Public License along with FreeGSNKE. If not, see <http://www.gnu.org/licenses/>.

class freegsnke.simplified_solve.simplified_solver_J1(eq, Lambdam1, Pm1, Rm1, Mey, plasma_norm_factor, plasma_resistance_1d, full_timestep=0.0001)[source]

Bases: object

Takes the full system of circuit equations (discretised in time and over the reduced plasma domain) and applies that

\[I_y(t+dt) = \hat{I_y}*I_p(t+dt)\]
where \(\hat{I_y}\) is assigned and such that np.sum(\hat{I_y})=1. With this hypothesis, the system can be (linearly) solved to find ALL of the extensive currents at t+dt (metal current and total plasma current).

__init__(eq, Lambdam1, Pm1, Rm1, Mey, plasma_norm_factor, plasma_resistance_1d, full_timestep=0.0001)[source]

Initialises the solver for the extensive currents.

Based on the input plasma properties and coupling matrices, it prepares:
  • an instance of the implicit Euler solver implicit_euler_solver()

  • internal time-stepper for the implicit-Euler

Parameters:
  • eq (class) – FreeGSNKE equilibrium Object

  • Lambdam1 (np.array) – State matrix of the circuit equations for the metal in normal mode form: P is the identity on the active coils and diagonalises the isolated dynamics of the passive coils, R^{-1/2}L_{passive}R^{-1/2}

  • Pm1 (np.array) – change of basis matrix, as defined above, to the power of -1

  • Rm1 (np.array) – matrix of all metal resitances to the power of -1. Diagonal.

  • Mey (np.array) – matrix of inductance values between grid points in the reduced plasma domain and all metal coils (active coils and passive-structure filaments) Calculated by the metal_currents object

  • plasma_norm_factor (float) – an overall factor to work with a rescaled plasma current, so that it’s within a comparable range with metal currents

  • plasma_resistance_1d (np.array) – plasma reistance in each (reduced domain) plasma cell, R_yy, raveled to be of the same shape as I_y, the lumped total plasma resistance is obtained by contracting hat{I_y}R_{yy}hat{I_{y}} = I_y R_{yy} I_{y} / I_{p}^2

  • full_timestep (float) – full timestep requested to the implicit-Euler solver

ceq_residuals(I_0, I_1, hatIy_left, hatIy_0, hatIy_1, active_voltage_vec)[source]

Computes and returns the set of residual for the full lumped circuit equations (all metals in normal modes plus contracted plasma eq.) given extensive currents and normalised plasma distributions at both times t and t+dt. Uses

Parameters:
  • I_0 (np.array) – vector of all extensive currents at time t: It = (all metals, plasma) with dimension self.n_independent_vars + 1. Metal currents expressed in terms of normal modes.

  • I_1 (np.array) – as above at time t+dt.

  • hatIy_left (np.array) – normalised plasma current distribution on the reduced domain. This is used to left-contract the plasma evolution equation (e.g. at time t, or t+dt, or a combination)

  • hatIy_0 (np.array) – normalised plasma current distribution on the reduced domain at time t

  • hatIy_1 (np.array) – normalised plasma current distribution on the reduced domain at time t+dt

  • active_voltage_vec (np.array) – voltages applied to the active coils

Returns:

Residual of the circuit eq, lumped for the plasma: dimensions are self.n_independent_vars + 1.

Return type:

np.array

prepare_solver(hatIy_left, hatIy_0, hatIy_1, active_voltage_vec, Myy_hatIy_left)[source]
Computes the actual matrices that are needed in the ODE for the extensive currents

and that must be passed to the implicit-Euler solver.

Parameters:
  • hatIy_left (np.array) – normalised plasma current distribution on the reduced domain. This is used to left-contract the plasma evolution equation (e.g. at time t, or t+dt, or a combination)

  • hatIy_0 (np.array) – normalised plasma current distribution on the reduced domain at time t

  • hatIy_1 (np.array) – (guessed) normalised plasma current distribution on the reduced domain at time t+dt

  • active_voltage_vec (np.array) – voltages applied to the active coils

  • Myy_hatIy_left (np.array) – The matrix product np.dot(Myy, hatIy_left) in the same reduced domain as hatIy_left This is provided by Myy_handler

reset_plasma_resistivity(plasma_resistance_1d)[source]

Resets the value of the plasma resistivity, throught the vector of ‘geometric resistances’ in the plasma domain

Parameters:

plasma_resistance_1d (ndarray) – Vector of (2pi resistivity R/dA) for all domain grid points in the reduced plasma domain

reset_timesteps(max_internal_timestep, full_timestep)[source]

Resets the integration timesteps, calling self.solver.set_timesteps

Parameters:
  • max_internal_timestep (float) – integration substep of the ciruit equation, calling an implicit-Euler solver

  • full_timestep (float) – integration timestep of the circuit equation

stepper(It, hatIy_left, hatIy_0, hatIy_1, active_voltage_vec, Myy_hatIy_left)[source]

Computes and returns the set of extensive currents at time t+dt

Parameters:
  • It (np.array) – vector of all extensive currents at time t: It = (all metals, plasma) with dimension self.n_independent_vars + 1. Metal currents expressed in terms of normal modes.

  • hatIy_left (np.array) – normalised plasma current distribution on the reduced domain. This is used to left-contract the plasma evolution equation (e.g. at time t, or t+dt, or a combination)

  • hatIy_0 (np.array) – normalised plasma current distribution on the reduced domain at time t

  • hatIy_1 (np.array) – (guessed) normalised plasma current distribution on the reduced domain at time t+dt

  • active_voltage_vec (np.array) – voltages applied to the active coils

  • Myy_hatIy_left (np.array) – The matrix product np.dot(Myy, hatIy_left) in the same reduced domain as hatIy_left This is provided by Myy_handler

Returns:

Itpdt – currents (active coils, vessel eigenmodes, total plasma current) at time t+dt

Return type:

np.array