Time stepper
time_stepper
This module provides several classes to perform integration of time-dependent
equations. Users choose if they require an explicit or implicit time integrator, and
they instantiate one of the implemented algorithm class, for example, ERKEuler
, by
providing relevant parameters defined in the parent class (i.e. ERKGeneric
or
DIRKGeneric
). Then, they call the advance
method to request a solver update.
TimeIntegratorBase
Bases: ABC
Defines the API for all time integrators.
advance(t, update_forcings=None)
abstractmethod
Advances equations for one time step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
Current simulation time |
required |
update_forcings |
Optional[Function]
|
Firedrake function used to update any time-dependent boundary conditions |
None
|
Source code in g-adopt/gadopt/time_stepper.py
24 25 26 27 28 29 30 31 32 33 |
|
initialize(init_solution)
abstractmethod
Initialises the time integrator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
init_solution |
Firedrake function representing the initial solution. |
required |
Source code in g-adopt/gadopt/time_stepper.py
35 36 37 38 39 40 41 42 43 |
|
TimeIntegrator(equation, solution, dt, solution_old=None, solver_parameters=None, strong_bcs=None)
Bases: TimeIntegratorBase
Time integrator object that marches a single equation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
equation |
Equation
|
G-ADOPT equation to integrate |
required |
solution |
Function
|
Firedrake function representing the equation's solution |
required |
dt |
float
|
Integration time step |
required |
solution_old |
Optional[Function]
|
Firedrake function representing the equation's solution at the previous timestep |
None
|
solver_parameters |
Optional[dict[str, Any]]
|
Dictionary of solver parameters provided to PETSc |
None
|
strong_bcs |
Optional[list[DirichletBC]]
|
List of Firedrake Dirichlet boundary conditions |
None
|
Source code in g-adopt/gadopt/time_stepper.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
RungeKuttaTimeIntegrator(equation, solution, dt, solution_old=None, solver_parameters=None, strong_bcs=None)
Bases: TimeIntegrator
Abstract base class for all Runge-Kutta time integrators
Source code in g-adopt/gadopt/time_stepper.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
get_final_solution()
abstractmethod
Evaluates the final solution
Source code in g-adopt/gadopt/time_stepper.py
93 94 95 96 |
|
solve_stage(i_stage, t, update_forcings=None)
abstractmethod
Solves a single stage of step from t to t+dt. All functions that the equation depends on must be at right state corresponding to each sub-step.
Source code in g-adopt/gadopt/time_stepper.py
98 99 100 101 102 103 104 105 |
|
advance(t, update_forcings=None)
Advances equations for one time step.
Source code in g-adopt/gadopt/time_stepper.py
107 108 109 110 111 112 113 |
|
ERKGeneric(equation, solution, dt, solution_old=None, bnd_conditions=None, solver_parameters={}, strong_bcs=None)
Bases: RungeKuttaTimeIntegrator
Generic explicit Runge-Kutta time integrator.
Implements the Butcher form. All terms in the equation are treated explicitly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
equation |
Equation
|
G-ADOPT equation to solve |
required |
solution |
Function
|
Firedrake function reperesenting the equation's solution |
required |
dt |
float
|
Integration time step |
required |
solution_old |
Optional[Function]
|
Firedrake function representing the equation's solution at the previous timestep |
None
|
bnd_conditions |
Optional[dict[int, dict[str, Number]]]
|
Dictionary of boundary conditions passed to the equation |
None
|
solver_parameters |
Optional[dict[str, Any]]
|
Dictionary of solver parameters provided to PETSc |
{}
|
strong_bcs |
Optional[list[DirichletBC]]
|
List of Firedrake Dirichlet boundary conditions |
None
|
Source code in g-adopt/gadopt/time_stepper.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
update_solver()
Create solver objects
Source code in g-adopt/gadopt/time_stepper.py
171 172 173 174 175 176 177 178 179 |
|
update_solution(i_stage)
Computes the solution of the i-th stage
Tendencies must have been evaluated first.
Source code in g-adopt/gadopt/time_stepper.py
185 186 187 188 189 190 191 192 193 |
|
solve_tendency(i_stage, t, update_forcings=None)
Evaluates the tendency of i-th stage
Source code in g-adopt/gadopt/time_stepper.py
195 196 197 198 199 200 |
|
DIRKGeneric(equation, solution, dt, solution_old=None, bnd_conditions=None, solver_parameters={}, strong_bcs=None, terms_to_add='all')
Bases: RungeKuttaTimeIntegrator
Generic implementation of Diagonally Implicit Runge Kutta schemes.
All derived classes must define the Butcher tableau coefficients :attr:a
,
:attr:b
, :attr:c
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
equation |
Equation
|
G-ADOPT equation to solve |
required |
solution |
Function
|
Firedrake function reperesenting the equation's solution |
required |
dt |
float
|
Integration time step |
required |
solution_old |
Optional[Function]
|
Firedrake function representing the equation's solution at the previous timestep |
None
|
bnd_conditions |
Optional[dict[int, dict[str, Number]]]
|
Dictionary of boundary conditions passed to the equation |
None
|
solver_parameters |
Optional[dict[str, Any]]
|
Dictionary of solver parameters provided to PETSc |
{}
|
strong_bcs |
Optional[list[DirichletBC]]
|
List of Firedrake Dirichlet boundary conditions |
None
|
terms_to_add |
Optional[str | list[str]]
|
Defines which terms of the equation are to be added to this solver. Default 'all' implies ['implicit', 'explicit', 'source']. |
'all'
|
Source code in g-adopt/gadopt/time_stepper.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
update_solver()
Create solver objects
Source code in g-adopt/gadopt/time_stepper.py
293 294 295 296 297 298 299 300 301 302 |
|
update_solution(i_stage)
Updates solution to i_stage sub-stage.
Tendencies must have been evaluated first.
Source code in g-adopt/gadopt/time_stepper.py
308 309 310 311 312 313 314 |
|
solve_tendency(i_stage, t, update_forcings=None)
Evaluates the tendency of i-th stage
Source code in g-adopt/gadopt/time_stepper.py
316 317 318 319 320 321 322 323 324 325 326 327 |
|
AbstractRKScheme()
Bases: ABC
Abstract class for defining Runge-Kutta schemes.
Derived classes must define the Butcher tableau (arrays :attr:a
, :attr:b
,
:attr:c
) and the CFL number (:attr:cfl_coeff
).
Currently only explicit or diagonally implicit schemes are supported.
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
cfl_coeff
abstractmethod
property
CFL number of the scheme
Value 1.0 corresponds to Forward Euler time step.
a = np.array(self.a)
abstractmethod
instance-attribute
property
Runge-Kutta matrix :math:a_{i,j}
of the Butcher tableau
b = np.array(self.b)
abstractmethod
instance-attribute
property
weights :math:b_{i}
of the Butcher tableau
c = np.array(self.c)
abstractmethod
instance-attribute
property
nodes :math:c_{i}
of the Butcher tableau
ForwardEulerAbstract()
Bases: AbstractRKScheme
Forward Euler method
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
ERKLSPUM2Abstract()
Bases: AbstractRKScheme
ERKLSPUM2, 3-stage, 2nd order Explicit Runge Kutta method
From IMEX RK scheme (17) in Higureras et al. (2014).
Higueras et al (2014). Optimized strong stability preserving IMEX Runge-Kutta methods. Journal of Computational and Applied Mathematics 272(2014) 116-140. http://dx.doi.org/10.1016/j.cam.2014.05.011
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
ERKLPUM2Abstract()
Bases: AbstractRKScheme
ERKLPUM2, 3-stage, 2nd order Explicit Runge Kutta method
From IMEX RK scheme (20) in Higureras et al. (2014).
Higueras et al (2014). Optimized strong stability preserving IMEX Runge-Kutta methods. Journal of Computational and Applied Mathematics 272(2014) 116-140. http://dx.doi.org/10.1016/j.cam.2014.05.011
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
SSPRK33Abstract()
Bases: AbstractRKScheme
3rd order Strong Stability Preserving Runge-Kutta scheme, SSP(3,3).
This scheme has Butcher tableau
.. math:: \begin{array}{c|ccc} 0 & \ 1 & 1 \ 1/2 & 1/4 & 1/4 & \ \hline & 1/6 & 1/6 & 2/3 \end{array}
CFL coefficient is 1.0
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs3p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs4p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs5p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs6p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs7p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs8p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs9p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
eSSPRKs10p3Abstract()
Bases: AbstractRKScheme
Explicit SSP Runge-Kutta method with nondecreasing abscissas. See Isherwood, Grant, and Gottlieb (2018).
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
BackwardEulerAbstract()
Bases: AbstractRKScheme
Backward Euler method
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
ImplicitMidpointAbstract()
Bases: AbstractRKScheme
Implicit midpoint method, second order.
This method has the Butcher tableau
.. math:: \begin{array}{c|c} 0.5 & 0.5 \ \hline & 1.0 \end{array}
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
CrankNicolsonAbstract()
Bases: AbstractRKScheme
Crank-Nicolson scheme
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
DIRK22Abstract()
Bases: AbstractRKScheme
2-stage, 2nd order, L-stable Diagonally Implicit Runge Kutta method
This method has the Butcher tableau
.. math:: \begin{array}{c|cc} \gamma & \gamma & 0 \ 1 & 1-\gamma & \gamma \ \hline & 1/2 & 1/2 \end{array}
with :math:\gamma = (2 + \sqrt{2})/2
.
From DIRK(2,3,2) IMEX scheme in Ascher et al. (1997)
Ascher et al. (1997). Implicit-explicit Runge-Kutta methods for time-dependent partial differential equations. Applied Numerical Mathematics, 25:151-167. http://dx.doi.org/10.1137/0732037
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
DIRK23Abstract()
Bases: AbstractRKScheme
2-stage, 3rd order Diagonally Implicit Runge Kutta method
This method has the Butcher tableau
.. math:: \begin{array}{c|cc} \gamma & \gamma & 0 \ 1-\gamma & 1-2\gamma & \gamma \ \hline & 1/2 & 1/2 \end{array}
with :math:\gamma = (3 + \sqrt{3})/6
.
From DIRK(2,3,3) IMEX scheme in Ascher et al. (1997)
Ascher et al. (1997). Implicit-explicit Runge-Kutta methods for time-dependent partial differential equations. Applied Numerical Mathematics, 25:151-167. http://dx.doi.org/10.1137/0732037
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
DIRK33Abstract()
Bases: AbstractRKScheme
3-stage, 3rd order, L-stable Diagonally Implicit Runge Kutta method
From DIRK(3,4,3) IMEX scheme in Ascher et al. (1997)
Ascher et al. (1997). Implicit-explicit Runge-Kutta methods for time-dependent partial differential equations. Applied Numerical Mathematics, 25:151-167. http://dx.doi.org/10.1137/0732037
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
DIRK43Abstract()
Bases: AbstractRKScheme
4-stage, 3rd order, L-stable Diagonally Implicit Runge Kutta method
From DIRK(4,4,3) IMEX scheme in Ascher et al. (1997)
Ascher et al. (1997). Implicit-explicit Runge-Kutta methods for time-dependent partial differential equations. Applied Numerical Mathematics, 25:151-167. http://dx.doi.org/10.1137/0732037
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
DIRKLSPUM2Abstract()
Bases: AbstractRKScheme
DIRKLSPUM2, 3-stage, 2nd order, L-stable Diagonally Implicit Runge Kutta method
From IMEX RK scheme (17) in Higureras et al. (2014).
Higueras et al (2014). Optimized strong stability preserving IMEX Runge-Kutta methods. Journal of Computational and Applied Mathematics 272(2014) 116-140. http://dx.doi.org/10.1016/j.cam.2014.05.011
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
DIRKLPUM2Abstract()
Bases: AbstractRKScheme
DIRKLPUM2, 3-stage, 2nd order, L-stable Diagonally Implicit Runge Kutta method
From IMEX RK scheme (20) in Higureras et al. (2014).
Higueras et al (2014). Optimized strong stability preserving IMEX Runge-Kutta methods. Journal of Computational and Applied Mathematics 272(2014) 116-140. http://dx.doi.org/10.1016/j.cam.2014.05.011
Source code in g-adopt/gadopt/time_stepper.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
shu_osher_butcher(α_or_λ, β_or_μ)
Generate arrays composing the Butcher tableau of a Runge-Kutta method from the coefficient arrays of the equivalent, original or modified, Shu-Osher form. Code adapted from RK-Opt written in MATLAB by David Ketcheson. See also Ketcheson, Macdonald, and Gottlieb (2009).
Function arguments: α_or_λ : array_like, shape (n + 1, n) β_or_μ : array_like, shape (n + 1, n)
Source code in g-adopt/gadopt/time_stepper.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|