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 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.
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.
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(coil_numbers: tuple[int, int], Lambdam1: ndarray, P: ndarray, Pm1: ndarray, Rm1: ndarray, Mey: ndarray, plasma_norm_factor: float, plasma_resistance_1d: ndarray, full_timestep: float = 0.0001)[source]
Bases:
objectSolver for the extensive currents under a fixed plasma current shape.
Takes the full system of circuit equations (discretised in time and over the reduced plasma domain) and applies
\[I_y(t+dt) = \hat{I_y} I_p(t+dt),\]where \(\hat{I_y}\) is assigned and such that
np.sum(hatIy) = 1. With this hypothesis, the system can be (linearly) solved to find ALL of the extensive currents at t+dt (metal currents and total plasma current).- __init__(coil_numbers: tuple[int, int], Lambdam1: ndarray, P: ndarray, Pm1: ndarray, Rm1: ndarray, Mey: ndarray, plasma_norm_factor: float, plasma_resistance_1d: ndarray, full_timestep: float = 0.0001) None[source]
Initialise 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_solverand the internal time-stepper for the implicit Euler.- Parameters:
coil_numbers (tuple[int, int]) –
(n_active_coils, n_coils): number of active coils and total number of metal elements.Lambdam1 (np.ndarray) – 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}L_{passive}.
P (np.ndarray) – Change of basis matrix, as defined above, with modes appropriately removed.
Pm1 (np.ndarray) – Inverse of the change of basis matrix, as defined above, with modes appropriately removed.
Rm1 (np.ndarray) – Diagonal matrix of all metal resistances to the power of -1.
Mey (np.ndarray) – 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) – Overall factor to work with a rescaled plasma current, so that it is within a comparable range with metal currents.
plasma_resistance_1d (np.ndarray) – Plasma resistance 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, optional) – Full timestep requested of the implicit-Euler solver.
- ceq_residuals(I_0: ndarray, I_1: ndarray, hatIy_left: ndarray, hatIy_0: ndarray, hatIy_1: ndarray, active_voltage_vec: ndarray) ndarray[source]
Compute the residual of the full lumped circuit equations.
The equations are the metal ones (in normal modes) plus the contracted plasma one, evaluated given extensive currents and normalised plasma distributions at both times t and t+dt.
- Parameters:
I_0 (np.ndarray) – Vector of all extensive currents at time t:
(all metals, plasma), with dimensionself.n_independent_vars + 1. Metal currents are expressed in terms of normal modes.I_1 (np.ndarray) – As above, at time t+dt.
hatIy_left (np.ndarray) – 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.ndarray) – Normalised plasma current distribution on the reduced domain at time t.
hatIy_1 (np.ndarray) – Normalised plasma current distribution on the reduced domain at time t+dt.
active_voltage_vec (np.ndarray) – Voltages applied to the active coils.
- Returns:
Residual of the circuit equations, lumped for the plasma, with dimension
self.n_independent_vars + 1.- Return type:
np.ndarray
Notes
Requires the attribute
self.handleMyy(a Myy_handler) to have been set externally; it is not created in__init__.
- prepare_solver(hatIy_left: ndarray, hatIy_0: ndarray, hatIy_1: ndarray, active_voltage_vec: ndarray, Myy_hatIy_left: ndarray) None[source]
Compute the matrices needed in the ODE for the extensive currents.
The matrices are passed to the implicit-Euler solver, whose inverse operator is recalculated. Also sets
self.Rpandself.forcing.- Parameters:
hatIy_left (np.ndarray) – 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.ndarray) – Normalised plasma current distribution on the reduced domain at time t.
hatIy_1 (np.ndarray) – (Guessed) normalised plasma current distribution on the reduced domain at time t+dt.
active_voltage_vec (np.ndarray) – Voltages applied to the active coils.
Myy_hatIy_left (np.ndarray) – 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: ndarray) None[source]
Reset the plasma resistivity.
This is done through the vector of ‘geometric resistances’ in the plasma domain.
- Parameters:
plasma_resistance_1d (np.ndarray) – Vector of (2 pi resistivity R/dA) for all domain grid points in the reduced plasma domain.
- reset_timesteps(max_internal_timestep: float, full_timestep: float) None[source]
Reset the integration timesteps, calling
self.solver.set_timesteps.- Parameters:
max_internal_timestep (float) – Integration substep of the circuit equation, used by the implicit-Euler solver.
full_timestep (float) – Integration timestep of the circuit equation.
- stepper(It: ndarray, hatIy_left: ndarray, hatIy_0: ndarray, hatIy_1: ndarray, active_voltage_vec: ndarray, Myy_hatIy_left: ndarray) ndarray[source]
Compute the set of extensive currents at time t+dt.
- Parameters:
It (np.ndarray) – Vector of all extensive currents at time t:
It = (all metals, plasma), with dimensionself.n_independent_vars + 1. Metal currents are expressed in terms of normal modes.hatIy_left (np.ndarray) – 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.ndarray) – Normalised plasma current distribution on the reduced domain at time t.
hatIy_1 (np.ndarray) – (Guessed) normalised plasma current distribution on the reduced domain at time t+dt.
active_voltage_vec (np.ndarray) – Voltages applied to the active coils.
Myy_hatIy_left (np.ndarray) – The matrix product
np.dot(Myy, hatIy_left)in the same reduced domain as hatIy_left. This is provided by Myy_handler.
- Returns:
Currents (active coils, vessel eigenmodes, total plasma current) at time t+dt.
- Return type:
np.ndarray