Extension: Matrix functions
#include "dg/matrix/matrix.h"
|
Exponential Runge-Kutta fixed-step time-integration for \( \dot y = A y + g(t,y)\). More...
Public Types | |
using | value_type = get_value_type< ContainerType > |
the value type of the time variable (float or double) More... | |
using | container_type = ContainerType |
the type of the vector class in use More... | |
Public Member Functions | |
ExponentialERKStep ()=default | |
ExponentialERKStep (ConvertsToFunctionalButcherTableau< value_type > tableau, const ContainerType ©able) | |
Reserve internal workspace for the integration. More... | |
const ContainerType & | copyable () const |
template<class ExplicitRHS , class MatrixFunction > | |
void | step (const std::tuple< ExplicitRHS, MatrixFunction > &ode, value_type t0, const ContainerType &u0, value_type &t1, ContainerType &u1, value_type dt, ContainerType &delta) |
Advance one step with error estimate. More... | |
template<class ExplicitRHS , class MatrixFunction > | |
void | step (const std::tuple< ExplicitRHS, MatrixFunction > &ode, value_type t0, const ContainerType &u0, value_type &t1, ContainerType &u1, value_type dt) |
Advance one step ignoring error estimate and embedded method. More... | |
unsigned | order () const |
global order of the method given by the current Butcher Tableau More... | |
unsigned | embedded_order () const |
global order of the embedding given by the current Butcher Tableau More... | |
unsigned | num_stages () const |
number of stages of the method given by the current Butcher Tableau More... | |
Exponential Runge-Kutta fixed-step time-integration for \( \dot y = A y + g(t,y)\).
We follow Hochbruck and Ostermann, Exponential Integrators, Acta Numerica (2010)
\[ \begin{align} u^{n+1} = \exp(\Delta t A) u^n + \Delta t \sum_{i=1}^s b_i(\Delta t A) g(t^n + c_i \Delta t, U_{ni}) \\ U_{ni} = \exp(c_i\Delta t A) u^n + \Delta t \sum_{j=1}^{i-1} a_{ij}(\Delta t A) g(t^n + c_j \Delta t, U_{nj}) \end{align} \]
The method is defined by the coefficient matrix functions \(a_{ij}(z),\ b_i(z),\ c_i = \sum_{j=1}^{i-1} a_{ij}(0)\) and s
is the number of stages. For \( A=0\) the underlying Runge-Kutta method with Butcher Tableau \( a_{ij} = a_{ij}(0),\ b_i=b_i(0)\) is recovered. We introduce the functions
\[ \begin{align} \varphi_{k+1}(z) := \frac{\varphi_k(z) - \varphi_k(0)}{z} \\ \varphi_0(z) = \exp(z) \end{align} \]
and the shorthand notation \( \varphi_{j,k} := \varphi_j(-c_k\Delta t A),\ \varphi_j := \varphi_j(-\Delta tA)\).
You can provide your own coefficients or use one of our predefined methods:
We follow the naming convention of the ARKode library http://runge.math.smu.edu/arkode_dev/doc/guide/build/html/Butcher.html (They also provide nice stability plots for their methods) as NAME-S-P-Q or NAME-S-Q, where
Name | Identifier | Description |
---|---|---|
Euler | dg::mat::EXPLICIT_EULER_1_1 | Hochbruck and Ostermann, Exponential Integrators, Acta Numerica (2010) |
Midpoint-2-2 | dg::mat::MIDPOINT_2_2 | Hochbruck and Ostermann, Exponential Integrators, Acta Numerica (2010) |
Runge-Kutta-4-4 | dg::mat::CLASSIC_4_4 | Cox and Matthews, J. Comput. Phys., 176 (2002) |
Hochbruck-3-3-4 | dg::mat::HOCHBRUCK_3_3_4 | Hochbruck and Ostermann, Exponential Integrators, Acta Numerica (2010) (The exprb43 method) |
This class is usable in the dg::SinglestepTimeloop
and dg::AdaptiveTimeloop
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
ContainerTypes in the argument list, then TensorTraits must exist for all of them |
using dg::mat::ExponentialERKStep< ContainerType >::container_type = ContainerType |
the type of the vector class in use
using dg::mat::ExponentialERKStep< ContainerType >::value_type = get_value_type<ContainerType> |
the value type of the time variable (float or double)
|
default |
|
inline |
Reserve internal workspace for the integration.
tableau | Tableau, name or identifier that ConvertsToFunctionalButcherTableau |
copyable | vector of the size that is later used in step ( it does not matter what values copyable contains, but its size is important; the step method can only be called with vectors of the same size) |
|
inline |
|
inline |
global order of the embedding given by the current Butcher Tableau
|
inline |
number of stages of the method given by the current Butcher Tableau
|
inline |
global order of the method given by the current Butcher Tableau
|
inline |
Advance one step ignoring error estimate and embedded method.
ExplicitRHS | The explicit (part of the) right hand side is a functor type with no return value (subroutine) of signature void operator()(value_type, const ContainerType&, ContainerType&) The first argument is the time, the second is the input vector, which the functor may not override, and the third is the output, i.e. y' = E(t, y) translates to E(t, y, y'). The two ContainerType arguments never alias each other in calls to the functor. The functor can throw to indicate failure. Exceptions should derive from std::exception . |
MatrixFunction | The exponential of the (part of the) right hand side is a functor type with no return value (subroutine) of signature void operator()(UnaryOp, const ContainerType&, ContainerType&) The first argument is the matrix function to compute, the second is the input vector, which the functor may not override, and the third is the output. The timestepper will call MatrixFunction(f, y, yp) where f typically is the exponential or dg::mat::phi1 , dg::mat::phi2 , etc. The FunctionalButcherTableau determines which matrix functions are used. The timestepper expects that MatrixFunction(f, y, yp) computes \( y' = f( A) y\). The two ContainerType arguments never alias each other in calls to the functor. The functor can throw to indicate failure. Exceptions should derive from std::exception . |
ode | the <explicit rhs, matrix_function> functor. Typically std::tie(explicit_rhs, matrix_function) |
t0 | start time |
u0 | value at t0 |
t1 | (write only) end time ( equals t0+dt on return, may alias t0 ) |
u1 | (write only) contains result on return (may alias u0) |
dt | timestep |
explicit_rhs(t1, u1)
will be the last call to explicit_rhs
(this is useful if ExplicitRHS
holds state, which is thus updated to the current timestep)
|
inline |
Advance one step with error estimate.
ExplicitRHS | The explicit (part of the) right hand side is a functor type with no return value (subroutine) of signature void operator()(value_type, const ContainerType&, ContainerType&) The first argument is the time, the second is the input vector, which the functor may not override, and the third is the output, i.e. y' = E(t, y) translates to E(t, y, y'). The two ContainerType arguments never alias each other in calls to the functor. The functor can throw to indicate failure. Exceptions should derive from std::exception . |
MatrixFunction | The exponential of the (part of the) right hand side is a functor type with no return value (subroutine) of signature void operator()(UnaryOp, const ContainerType&, ContainerType&) The first argument is the matrix function to compute, the second is the input vector, which the functor may not override, and the third is the output. The timestepper will call MatrixFunction(f, y, yp) where f typically is the exponential or dg::mat::phi1 , dg::mat::phi2 , etc. The FunctionalButcherTableau determines which matrix functions are used. The timestepper expects that MatrixFunction(f, y, yp) computes \( y' = f( A) y\). The two ContainerType arguments never alias each other in calls to the functor. The functor can throw to indicate failure. Exceptions should derive from std::exception . |
ode | the <explicit rhs, matrix_function> functor. Typically std::tie(explicit_rhs, matrix_function) |
t0 | start time |
u0 | value at t0 |
t1 | (write only) end time ( equals t0+dt on return, may alias t0 ) |
u1 | (write only) contains result on return (may alias u0) |
dt | timestep |
explicit_rhs(t1, u1)
will be the last call to explicit_rhs
(this is useful if ExplicitRHS
holds state, which is thus updated to the current timestep) delta | Contains error estimate (u1 - tilde u1) on return (must have equal size as u0 ) |