Skip to content

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 into block_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_k weight(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_k weight(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 ​

NameTypeAttributesDescription
MAGNUS_SCHEMEScharacter(len=*)parameterThe catalogue.
MAGNUS_MAX_BLOCKinteger(kind=I4P)parameterThe dense action's largest block.
MAGNUS_MAX_KRYLOVinteger(kind=I4P)parameterThe Krylov action's largest space m.
MAGNUS_DENSEinteger(kind=I4P)parameterThe exponentials per cell, dense.
MAGNUS_KRYLOVinteger(kind=I4P)parameterThe exponentials' action by Arnoldi (Lanczos), coupled operators.
MAGNUS_CALLERinteger(kind=I4P)parameterThe exponentials' action by the caller.
MAGNUS_DONEinteger(kind=I4P)parameterThe step is done: q is y^{n+1}.
MAGNUS_NODEinteger(kind=I4P)parameterA at node k = node().
MAGNUS_APPLYinteger(kind=I4P)parameterapply_out() = sum_k a_jk A(t_k) apply_in(), j = exponential().
MAGNUS_REDUCEinteger(kind=I4P)parameterSum sums(1:nsums) over the boxes and ranks.
MAGNUS_ACTIONinteger(kind=I4P)parameterThe caller applies exponential j = exponential() to q.

Derived Types ​

magnus_scheme ​

A commutator-free Magnus scheme.

Components

NameTypeAttributesDescription
namecharacter(len=16)Name.
orderinteger(kind=I4P)Order (0: unknown name).
kinteger(kind=I4P)Gauss nodes K.
jinteger(kind=I4P)Exponentials J.
creal(kind=R_P)allocatableThe nodes, fractions of the step.
areal(kind=R_P)allocatablea(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

NameTypeAttributesDescription
mstype(magnus_scheme)The scheme.
actioninteger(kind=I4P)MAGNUS_DENSE, MAGNUS_KRYLOV or MAGNUS_CALLER.
ncompinteger(kind=I4P)The dense action's block size.
minteger(kind=I4P)The Krylov action's largest space.
tolreal(kind=R_P)The Krylov action's error per unit step, relative to ||q||.
skewlogicalThe operator is skew-symmetric: the Lanczos structure imposed.
krylovinteger(kind=I4P)Krylov iterations of the step.
reductionsinteger(kind=I4P)Reductions asked in the step.
reorthogonalisationsinteger(kind=I4P)Second Gram-Schmidt passes of the step.
applicationsinteger(kind=I4P)Operator applications asked in the step.
substepsinteger(kind=I4P)Krylov sub-steps of the step (J at least).
sumsreal(kind=R_P)MAGNUS_REDUCE: the partial sums to reduce.
nsumsinteger(kind=I4P)How many.
stateinteger(kind=I4P)The Krylov action's state.
i_kryinteger(kind=I4P)The Krylov iteration within the sub-step.
betareal(kind=R_P)||q|| at the sub-step's start.
tdonereal(kind=R_P)The fraction of the active exponential done.
wwreal(kind=R_P)w.w of the current iteration.
hmreal(kind=R_P)Hessenberg matrix.
coef_dreal(kind=R_P)pointerCoefficients for the Krylov kernels (device).
reqinteger(kind=I4P)The pending request.
k_nodeinteger(kind=I4P)The node of MAGNUS_NODE.
j_expinteger(kind=I4P)The exponential of MAGNUS_APPLY and MAGNUS_ACTION.
hreal(kind=R_P)The step.
regsreal(kind=R_P)pointerThe blocks at the nodes (dense), the basis (Krylov).
a_dreal(kind=R_P)pointera, device.
qreal(kind=R_P)pointerThe caller's state.
lbinteger(kind=I4P)The field's bounds.
ubinteger(kind=I4P)The field's bounds.

Type-Bound Procedures

NameAttributesDescription
initializepass(self)The scheme, the field's bounds, the action.
destroypass(self)Free the registers.
nodespass(self)K.
exponentialspass(self)J.
node_timepass(self)c_k.
weightpass(self)a_jk.
begin_steppass(self)A step of h on q: the first request.
requestpass(self)The pending request.
advancepass(self)The request answered: on to the next.
nodepass(self)MAGNUS_NODE's k.
exponentialpass(self)MAGNUS_ACTION's j.
block_registerpass(self)MAGNUS_NODE (dense): where the caller writes the blocks.
apply_inpass(self)MAGNUS_APPLY: the operator's argument.
apply_outpass(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).

fortran
subroutine initialize(self, scheme, lb, ub, action, ncomp, m, tol, skew)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inoutStepper.
schemecharacter(len=*)inScheme name.
lbinteger(kind=I4P)inLower bounds.
ubinteger(kind=I4P)inUpper bounds.
actioninteger(kind=I4P)inMAGNUS_DENSE, MAGNUS_KRYLOV or MAGNUS_CALLER.
ncompinteger(kind=I4P)inoptionalThe dense action's block size.
minteger(kind=I4P)inoptionalThe Krylov action's largest space.
tolreal(kind=R_P)inoptionalThe Krylov action's tolerance.
skewlogicalinoptionalThe operator is skew-symmetric.

Call graph

magnus_stepper%destroy ​

Free the registers.

fortran
subroutine destroy(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inoutStepper.

magnus_stepper%nodes ​

The Gauss nodes K: the evaluations of A per step.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function nodes(self) result(k)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

magnus_stepper%exponentials ​

The exponentials J per step.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function exponentials(self) result(j)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

magnus_stepper%node_time ​

Node k's time, as a fraction of the step (c_k).

Attributes: pure

Returns: real(kind=R_P)

fortran
function node_time(self, k) result(c)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.
kinteger(kind=I4P)inNode.

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)

fortran
function weight(self, j, k) result(a)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.
jinteger(kind=I4P)inExponential.
kinteger(kind=I4P)inNode.

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.

fortran
subroutine begin_step(self, bx, h, q)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inoutStepper.
bxtype(box)inBox.
hreal(kind=R_P)inStep.
qreal(kind=R_P)inpointerState.

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)

fortran
function request(self) result(req)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

magnus_stepper%advance ​

The pending request answered: the next one (the dense action makes the step after the last node).

fortran
subroutine advance(self, bx)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inoutStepper.
bxtype(box)inBox.

Call graph

magnus_stepper%node ​

The node of MAGNUS_NODE.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function node(self) result(k)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

magnus_stepper%exponential ​

The exponential of MAGNUS_APPLY and MAGNUS_ACTION.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function exponential(self) result(j)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

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)

fortran
function block_register(self) result(blk)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

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)

fortran
function apply_in(self) result(v)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

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)

fortran
function apply_out(self) result(w)

Arguments

NameTypeIntentAttributesDescription
selfclass(magnus_stepper)inStepper.

Functions ​

magnus ​

The scheme of the catalogue named name (ms%order = 0 if unknown).

Returns: type(magnus_scheme)

fortran
function magnus(name) result(ms)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inScheme name.

Call graph