freegsnke.implicit_euler module
Implements implicit time integration.
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.implicit_euler.implicit_euler_solver(Mmatrix, Rmatrix, full_timestep, max_internal_timestep)[source]
Bases:
object
An implicit Euler time stepper for the linearized circuit equations. Solves an equation of type
\[M\dot{I} + RI = F\],with generic M, R and F. The internal_stepper and full_stepper solve for I(t+dt) using
\[I(t+dt) = (M + Rdt)^{-1} (Fdt + MI(t))\].The implementation actually allows for
\[I(t+dt) = (M + Rdt)^{-1} (Fdt + LI(t))\]with M != L
- __init__(Mmatrix, Rmatrix, full_timestep, max_internal_timestep)[source]
Sets up the implicit euler solver
- Parameters:
Mmatrix (np.ndarray) – (NxN) Mutual inductance matrix
Rmatrix (np.ndarray) – (NxN) Diagonal resistance matrix
full_timestep (float) – Full timestep (dt) for the stepper
max_internal_timestep (float) – Maximum size of the intermediate timesteps taken during the stepper. If max_internal_timestep < full_timestep, multiple steps are taken up to dt=full_timestep
- calc_inverse_operator()[source]
Calculates the inverse operator (M + Rdt)^-1 Note this needs done when M or R are updated
- full_stepper(It, forcing)[source]
Calculates the next full timestep I(t + self.full_timestep) by repeatedly solving for the internal timestep I(t + self.internal_timestep) for self.n_steps steps
- Parameters:
It (np.ndarray) – Length N vector of the currents, I, at time t
forcing (np.ndarray) – Lenght N vector of the forcing, F, at time t
- internal_stepper(It, dtforcing)[source]
Calculates the next internal timestep I(t + internal_timestep)
- Parameters:
It (np.ndarray) – Length N vector of the currents, I, at time t
dtforcing (np.ndarray) – Lenght N vector of the forcing F dt, at time t multiplied by self.internal_timestep
- set_Lmatrix(Lmatrix)[source]
Set a separate mutual inductance matrix L != M.
- Parameters:
Lmatrix (np.ndarray) – (NxN) Mutual inductance matrix
- set_Mmatrix(Mmatrix)[source]
Updates the mutual inductance matrix.
- Parameters:
Mmatrix (np.ndarray) – (NxN) Mutual inductance matrix
- set_Rmatrix(Rmatrix)[source]
Updates the resistance matrix.
- Parameters:
Rmatrix (np.ndarray) – (NxN) Diagonal resistance matrix
- set_timesteps(full_timestep, max_internal_timestep)[source]
Sets the timesteps for the stepper and (re)calculate the inverse operator
- Parameters:
full_timestep (float) – Full timestep (dt) for the stepper
max_internal_timestep (float) – Maximum size of the intermediate timesteps taken during the stepper. If max_internal_timestep < full_timestep, multiple steps are taken up to dt=full_timestep