selah_magnus
SELAH, L2: commutator-free Magnus integrators for linear non-autonomous systems y' = A(t) y.
A commutator-free Magnus (CF) scheme advances y' = A(t) y by a product of exponentials of combinations of A at the K Gauss nodes of the step (#6; notes/magnus.md):
y^{n+1} = exp(B_J) ... exp(B_1) y^n, B_j = h sum_k a_jk A(t^n + c_k h), B_1 applied first.
The catalogue (MAGNUS_SCHEMES): of order 4, every exponential forward in time, cf4-2 (Blanes & Moan 2006, Thalhammer 2006: 2 exponentials, 2 nodes), cf4-3opt (Alvermann & Fehske 2011's CF4:3Opt: 3, 3) and cf4-4 (Blanes, Casas & Thalhammer 2017: 4, 3); of order 6, cf6-5 (Alvermann & Fehske's CF6:5: 5, 3), cf6-5b (Blanes & Moan's psi_5^[6]: 5, 3) and cf6-5opt (CF6:5Opt: 5, 4); of order 8, cf8-11 (CF8:11: 11, 4). The schemes of order 6 and 8 have an exponential backwards in time (a_j < 0): for reversible problems. notes/magnus-check.py checks every word of the Dyson series up to the order, in 80 digits, on this Gauss-node form, and writes the 40-digit coefficients below.
magnus_stepper is driven by its caller through requests (as newton_krylov): begin_step(bx, h, q), then while request() is not MAGNUS_DONE the caller answers it and calls advance(bx):
- MAGNUS_NODE (K times, k =
node()): A at t^n +node_time(k)h; with the dense action, its block per cell intoblock_register(), blk(cell, v, w) = A_vw, the components v, w of the box (first or last, as the box's layout); - MAGNUS_APPLY (the Krylov action):
apply_out()= sum_kweight(j, k)A(t^n + c_k h)apply_in(), j =exponential(): the caller's operator, its halo exchange included; - MAGNUS_REDUCE (the Krylov action): sum
sums(1:nsums)over the boxes and ranks; - MAGNUS_ACTION (the caller's action, J times, j =
exponential()): q <- exp(h sum_kweight(j, k)A_k) q in place.
Three actions of the exponential (D2 of #6: D, then C, and A): MAGNUS_DENSE, a block of ncomp x ncomp per cell (ncomp <= 16, as newton_solver's blocks): every exponential of a cell is made and applied in one kernel, by the diagonal Pade approximant of degree 8 with scaling and squaring (selah_magnus_expm.INC), orthogonal for a skew-symmetric block, so the 2-norm of a skew-symmetric system is kept to rounding; MAGNUS_KRYLOV, for an operator that couples the cells: Arnoldi on the exponential's operator M_j, classical Gram-Schmidt with one fused reduction per iteration (a second pass when the new vector keeps less than a tenth of its norm, as newton_krylov), exp(tau h H_m) on the host by the same Pade approximant, Saad's estimate h h_{m+1,m} |[exp(tau h H_m)]_{m,1}| against tol tau (relative to ||q||): the space grows to m (<= 16), then the sub-step tau shrinks on the same space; with skew, the Lanczos structure is imposed on H_m (exp(tau h H_m) orthogonal: the norm kept to the basis' orthogonality); and MAGNUS_CALLER, the caller's own. No global sum is done: the library is per box and per rank. Fields of rank 5 (lower ranks through their rank-5 view); every array device resident in a device build.
Source: src/lib/selah_magnus.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
MAGNUS_SCHEMES | character(len=*) | parameter | The catalogue. |
MAGNUS_MAX_BLOCK | integer(kind=I4P) | parameter | The dense action's largest block. |
MAGNUS_MAX_KRYLOV | integer(kind=I4P) | parameter | The Krylov action's largest space m. |
MAGNUS_DENSE | integer(kind=I4P) | parameter | The exponentials per cell, dense. |
MAGNUS_KRYLOV | integer(kind=I4P) | parameter | The exponentials' action by Arnoldi (Lanczos), coupled operators. |
MAGNUS_CALLER | integer(kind=I4P) | parameter | The exponentials' action by the caller. |
MAGNUS_DONE | integer(kind=I4P) | parameter | The step is done: q is y^{n+1}. |
MAGNUS_NODE | integer(kind=I4P) | parameter | A at node k = node(). |
MAGNUS_APPLY | integer(kind=I4P) | parameter | apply_out() = sum_k a_jk A(t_k) apply_in(), j = exponential(). |
MAGNUS_REDUCE | integer(kind=I4P) | parameter | Sum sums(1:nsums) over the boxes and ranks. |
MAGNUS_ACTION | integer(kind=I4P) | parameter | The caller applies exponential j = exponential() to q. |
Derived Types
magnus_scheme
A commutator-free Magnus scheme.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
name | character(len=16) | Name. | |
order | integer(kind=I4P) | Order (0: unknown name). | |
k | integer(kind=I4P) | Gauss nodes K. | |
j | integer(kind=I4P) | Exponentials J. | |
c | real(kind=R_P) | allocatable | The nodes, fractions of the step. |
a | real(kind=R_P) | allocatable | a(j, k): exponential j's weight of A at node k (j = 1 first applied). |
magnus_stepper
A commutator-free Magnus scheme driven by requests.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
ms | type(magnus_scheme) | The scheme. | |
action | integer(kind=I4P) | MAGNUS_DENSE, MAGNUS_KRYLOV or MAGNUS_CALLER. | |
ncomp | integer(kind=I4P) | The dense action's block size. | |
m | integer(kind=I4P) | The Krylov action's largest space. | |
tol | real(kind=R_P) | The Krylov action's error per unit step, relative to ||q||. | |
skew | logical | The operator is skew-symmetric: the Lanczos structure imposed. | |
krylov | integer(kind=I4P) | Krylov iterations of the step. | |
reductions | integer(kind=I4P) | Reductions asked in the step. | |
reorthogonalisations | integer(kind=I4P) | Second Gram-Schmidt passes of the step. | |
applications | integer(kind=I4P) | Operator applications asked in the step. | |
substeps | integer(kind=I4P) | Krylov sub-steps of the step (J at least). | |
sums | real(kind=R_P) | MAGNUS_REDUCE: the partial sums to reduce. | |
nsums | integer(kind=I4P) | How many. | |
state | integer(kind=I4P) | The Krylov action's state. | |
i_kry | integer(kind=I4P) | The Krylov iteration within the sub-step. | |
beta | real(kind=R_P) | ||q|| at the sub-step's start. | |
tdone | real(kind=R_P) | The fraction of the active exponential done. | |
ww | real(kind=R_P) | w.w of the current iteration. | |
hm | real(kind=R_P) | Hessenberg matrix. | |
coef_d | real(kind=R_P) | pointer | Coefficients for the Krylov kernels (device). |
req | integer(kind=I4P) | The pending request. | |
k_node | integer(kind=I4P) | The node of MAGNUS_NODE. | |
j_exp | integer(kind=I4P) | The exponential of MAGNUS_APPLY and MAGNUS_ACTION. | |
h | real(kind=R_P) | The step. | |
regs | real(kind=R_P) | pointer | The blocks at the nodes (dense), the basis (Krylov). |
a_d | real(kind=R_P) | pointer | a, device. |
q | real(kind=R_P) | pointer | The caller's state. |
lb | integer(kind=I4P) | The field's bounds. | |
ub | integer(kind=I4P) | The field's bounds. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
initialize | pass(self) | The scheme, the field's bounds, the action. |
destroy | pass(self) | Free the registers. |
nodes | pass(self) | K. |
exponentials | pass(self) | J. |
node_time | pass(self) | c_k. |
weight | pass(self) | a_jk. |
begin_step | pass(self) | A step of h on q: the first request. |
request | pass(self) | The pending request. |
advance | pass(self) | The request answered: on to the next. |
node | pass(self) | MAGNUS_NODE's k. |
exponential | pass(self) | MAGNUS_ACTION's j. |
block_register | pass(self) | MAGNUS_NODE (dense): where the caller writes the blocks. |
apply_in | pass(self) | MAGNUS_APPLY: the operator's argument. |
apply_out | pass(self) | MAGNUS_APPLY: where the caller writes its result. |
magnus_stepper%initialize
The scheme (MAGNUS_SCHEMES), the field's bounds (rank 5, ghosts included) and the action: MAGNUS_DENSE, with the block size ncomp <= MAGNUS_MAX_BLOCK (ncomp x K registers); MAGNUS_KRYLOV, with the largest space m <= MAGNUS_MAX_KRYLOV (default 16: m + 1 registers), the error per unit step tol relative to ||q|| (default 1000 eps) and skew (the operator is skew-symmetric: default .false.); MAGNUS_CALLER (none).
subroutine initialize(self, scheme, lb, ub, action, ncomp, m, tol, skew)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | inout | Stepper. | |
scheme | character(len=*) | in | Scheme name. | |
lb | integer(kind=I4P) | in | Lower bounds. | |
ub | integer(kind=I4P) | in | Upper bounds. | |
action | integer(kind=I4P) | in | MAGNUS_DENSE, MAGNUS_KRYLOV or MAGNUS_CALLER. | |
ncomp | integer(kind=I4P) | in | optional | The dense action's block size. |
m | integer(kind=I4P) | in | optional | The Krylov action's largest space. |
tol | real(kind=R_P) | in | optional | The Krylov action's tolerance. |
skew | logical | in | optional | The operator is skew-symmetric. |
Call graph
magnus_stepper%destroy
Free the registers.
subroutine destroy(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | inout | Stepper. |
magnus_stepper%nodes
The Gauss nodes K: the evaluations of A per step.
Attributes: pure
Returns: integer(kind=I4P)
function nodes(self) result(k)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
magnus_stepper%exponentials
The exponentials J per step.
Attributes: pure
Returns: integer(kind=I4P)
function exponentials(self) result(j)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
magnus_stepper%node_time
Node k's time, as a fraction of the step (c_k).
Attributes: pure
Returns: real(kind=R_P)
function node_time(self, k) result(c)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. | |
k | integer(kind=I4P) | in | Node. |
magnus_stepper%weight
Exponential j's weight of A at node k (a_jk; j = 1 the first applied).
Attributes: pure
Returns: real(kind=R_P)
function weight(self, j, k) result(a)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. | |
j | integer(kind=I4P) | in | Exponential. | |
k | integer(kind=I4P) | in | Node. |
magnus_stepper%begin_step
A step of h on q (the caller's state, updated in place; a pointer with the field's bounds): the first request, MAGNUS_NODE for node 1.
subroutine begin_step(self, bx, h, q)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. | |
h | real(kind=R_P) | in | Step. | |
q | real(kind=R_P) | in | pointer | State. |
Call graph
magnus_stepper%request
The pending request: MAGNUS_NODE, MAGNUS_APPLY, MAGNUS_REDUCE, MAGNUS_ACTION or MAGNUS_DONE.
Attributes: pure
Returns: integer(kind=I4P)
function request(self) result(req)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
magnus_stepper%advance
The pending request answered: the next one (the dense action makes the step after the last node).
subroutine advance(self, bx)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. |
Call graph
magnus_stepper%node
The node of MAGNUS_NODE.
Attributes: pure
Returns: integer(kind=I4P)
function node(self) result(k)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
magnus_stepper%exponential
The exponential of MAGNUS_APPLY and MAGNUS_ACTION.
Attributes: pure
Returns: integer(kind=I4P)
function exponential(self) result(j)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
magnus_stepper%block_register
MAGNUS_NODE with the dense action: where the caller writes A at the node, blk(cell, v, w) = A_vw, with the field's bounds and the columns w = 1 .. ncomp.
Returns: real(kind=R_P)
function block_register(self) result(blk)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
magnus_stepper%apply_in
MAGNUS_APPLY: the vector the operator is applied to (the basis vector v_i), with the field's bounds.
Returns: real(kind=R_P)
function apply_in(self) result(v)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
magnus_stepper%apply_out
MAGNUS_APPLY: where the caller writes sum_k a_jk A(t_k) apply_in(), with the field's bounds (its cells of the box).
Returns: real(kind=R_P)
function apply_out(self) result(w)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(magnus_stepper) | in | Stepper. |
Functions
magnus
The scheme of the catalogue named name (ms%order = 0 if unknown).
Returns: type(magnus_scheme)
function magnus(name) result(ms)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
name | character(len=*) | in | Scheme name. |
Call graph