selah_nordsieck
SELAH, L2: the Nordsieck form, variable-step Adams and BDF methods driven stage by stage.
The Nordsieck array of order q holds the scaled derivatives z_j = h^j y^(j) / j!, j = 0 .. q, of the solution at t^n (Nordsieck 1962; Gear 1971): z_0 is q itself (the caller's array), z_1 .. z_q are registers. A step
- predicts by the Pascal matrix, z_j <- sum_{i >= j} C(i, j) z_i, in place (one fused kernel, which also makes the predicted value y_p = sum_i z_i, the first stage's state, and E = y_p - l_0 z_1);
- corrects: z_j <- z_j + l_j Delta, Delta = h R(y) - z_1 (the predicted z_1), the new solution q = E + gamma R(y), gamma = h l_0: y = E + gamma R(y) is the implicit stage, solved by fixed-point stages (the caller's residual at each, as the stepper's implicit multistep schemes) or by a solver of the caller's in stage 2 (
stage_gamma,explicit_part: newton_solver, anderson_mixing, newton_krylov).
The coefficients are fixed per order (Byrne & Hindmarsh 1975): Adams of order q (1 .. 12) l = the coefficients of int_{-1}^{x} prod_{i=1}^{q-1} (s + i) ds / (q - 1)!, BDF of order q (1 .. 5) those of prod_{i=1}^{q} (1 + x/i) divided by their x coefficient (l_1 = 1 in both). A change of step is a rescaling of the columns, z_j <- eta^j z_j (set_step: local, no reduction, decision D5 of #11), a change of order one column more or less (set_order). The method is exact on polynomials of degree <= q whatever the step sequence, and at a constant step it is am-(q-1) (Adams) or bdf-q (BDF) (notes/nordsieck-check.py, in exact rationals).
Registers: z_1 .. z_qmax, the last correction Delta (the next step's estimate at order q + 1), the stage state, the stage's residual, E: qmax + 4 of the field's size. Fields of rank 5 (a field of lower rank as its rank-5 view, selah_box); every array device resident in a device build.
A step, the caller's loop (t the caller's):
call ns%begin_step(bx, q) ! the prediction
do k=1, ns%stages()
call ns%begin_stage(k, bx) ! stage k's state (k >= 2: E + gamma R of the previous one)
... R(t + h, ns%stage_state()) into ns%rhs_register() ...
call ns%end_stage(k)
enddo
call ns%finish_step(bx, q) ! the correction: q = y^{n+1}
Source: src/lib/selah_nordsieck.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
NORDSIECK_ADAMS | character(len=*) | parameter | The Adams family (orders 1 .. 12). |
NORDSIECK_BDF | character(len=*) | parameter | The BDF family (orders 1 .. 5). |
NORDSIECK_ADAMS_MAX_ORDER | integer(kind=I4P) | parameter | Adams' highest order. |
NORDSIECK_BDF_MAX_ORDER | integer(kind=I4P) | parameter | BDF's highest order. |
Derived Types
nordsieck_stepper
A variable-step, variable-order Adams or BDF method in the Nordsieck form.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
family | character(len=5) | NORDSIECK_ADAMS or NORDSIECK_BDF. | |
qmax | integer(kind=I4P) | The highest order (registers allocated for it). | |
q | integer(kind=I4P) | The current order. | |
m | integer(kind=I4P) | Stages per step (residual evaluations). | |
h | real(kind=R_P) | The current step. | |
l | real(kind=R_P) | allocatable | l(0:qmax, q): the corrector's vector of each order. |
cerr | real(kind=R_P) | allocatable | cerr(q) = C_{q+1}: the error constant of order q (1 .. qmax+1). |
l_d | real(kind=R_P) | pointer | The current order's l(0:q), device resident. |
regs | real(kind=R_P) | pointer | z_1 .. z_qmax, Delta, state, residual, E. |
lb | integer(kind=I4P) | The field's bounds. | |
ub | integer(kind=I4P) | The field's bounds. | |
k_active | integer(kind=I4P) | The active stage (0 outside a step). | |
started | logical | The array holds a solution (start called). | |
in_step | logical | Between begin_step and finish_step / reject_step. | |
beta | real(kind=R_P) | allocatable | The imaginary-axis bound of each order's step (stability cap). |
rho | real(kind=R_P) | The caller's spectral-radius estimate (0: no cap). | |
since | integer(kind=I4P) | Steps accepted since the last change of order. | |
failures | integer(kind=I4P) | Consecutive rejections. | |
accepted | integer(kind=I4P) | Steps accepted (statistics). | |
rejected | integer(kind=I4P) | Steps rejected (statistics). | |
stability_detection | logical | BDF: detect steps limited by stability (orders 3-5). | |
q_stable | integer(kind=I4P) | The highest order allowed after a detection (0: qmax). | |
detections | integer(kind=I4P) | Detections (statistics). | |
zq_norm | real(kind=R_P) | ||z_q|| of the last steps at a constant step and order. | |
nz | integer(kind=I4P) | How many. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
initialize | pass(self) | Family, highest order, field bounds, stages. |
destroy | pass(self) | Free the registers. |
start | pass(self) | The array from q^0, h F(t^0, q^0) and the first step (order 1). |
begin_step | pass(self) | The prediction. |
stages | pass(self) | Stages per step. |
begin_stage | pass(self) | A stage's state. |
end_stage | pass(self) | A stage done. |
finish_step | pass(self) | The correction. |
reject_step | pass(self) | The prediction undone (a step to retry). |
set_step | pass(self) | A new step: the columns rescaled. |
set_order | pass(self) | A new order: a column more or less. |
stage_state | pass(self) | The active stage's state (rank-5 view). |
rhs_register | pass(self) | Where the caller writes the active stage's residual. |
explicit_part | pass(self) | E (from begin_step to finish_step). |
stage_gamma | pass(self) | l_0 for the implicit stages (k >= 2), 0 for stage 1. |
column | pass(self) | z_j, j = 1 .. q (rank-5 view). |
error_constant | pass(self) | C_{p+1} of order p. |
error_sums | pass(self) | The local error estimates at q - 1, q, q + 1: the box's sums. |
select | pass(self) | Accept or reject; the next step and order (host). |
set_spectral_radius | pass(self) | The caller's spectral-radius estimate: the stability cap. |
stability_bound | pass(self) | The imaginary-axis bound of order p's step. |
nordsieck_stepper%initialize
family NORDSIECK_ADAMS or NORDSIECK_BDF, the field's bounds (rank 5, ghosts included), the highest order (default the family's), the stages per step (default 2: the prediction's residual, then one implicit stage).
subroutine initialize(self, family, lb, ub, qmax, stages)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
family | character(len=*) | in | Family. | |
lb | integer(kind=I4P) | in | Lower bounds. | |
ub | integer(kind=I4P) | in | Upper bounds. | |
qmax | integer(kind=I4P) | in | optional | Highest order. |
stages | integer(kind=I4P) | in | optional | Stages per step (>= 1). |
Call graph
nordsieck_stepper%destroy
Free the registers.
subroutine destroy(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. |
nordsieck_stepper%start
The array at t^0 from q^0 (the caller's q, z_0) and hf0 = h F(t^0, q^0): z_1 = hf0, the higher columns 0; h the first step, order the starting order (default 1; a higher one needs its columns written by the caller, column(j), before the first step).
subroutine start(self, bx, h, hf0, order)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. | |
h | real(kind=R_P) | in | First step. | |
hf0 | real(kind=R_P) | in | h F(t^0, q^0). | |
order | integer(kind=I4P) | in | optional | Starting order. |
Call graph
nordsieck_stepper%begin_step
The prediction: the Pascal matrix on z_1 .. z_q in place, the predicted value (stage 1's state) and E.
subroutine begin_step(self, bx, q)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. | |
q | real(kind=R_P) | in | Solution, q^n (z_0). |
Call graph
nordsieck_stepper%stages
Stages (residual evaluations) per step.
Attributes: pure
Returns: integer(kind=I4P)
function stages(self) result(s)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. |
nordsieck_stepper%begin_stage
Stage k's state: the prediction for k = 1, E + gamma R(the previous state) after (in place).
subroutine begin_stage(self, k, bx)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
k | integer(kind=I4P) | in | Stage. | |
bx | type(box) | in | Box. |
Call graph
nordsieck_stepper%end_stage
Stage k done (its residual written).
subroutine end_stage(self, k)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
k | integer(kind=I4P) | in | Stage. |
nordsieck_stepper%finish_step
The correction from the last stage's residual R: Delta = h R - z_1, q = E + gamma R, z_j += l_j Delta, Delta kept.
subroutine finish_step(self, bx, q)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. | |
q | real(kind=R_P) | inout |
Call graph
nordsieck_stepper%reject_step
The prediction undone (the inverse Pascal matrix on z_1 .. z_q): the array of t^n again, to rounding, for a step retried with another step or order (set_step, set_order). q was never written.
subroutine reject_step(self, bx)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. |
Call graph
nordsieck_stepper%set_step
The next step h: z_j <- eta^j z_j, Delta <- eta^(q+1) Delta, eta = h / the current step. Between steps.
subroutine set_step(self, bx, h)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. | |
h | real(kind=R_P) | in | New step. |
Call graph
nordsieck_stepper%set_order
The next order, the current one +- 1 (between steps, after an accepted step): up, z_{q+1} = l_q Delta / (q + 1) (h^{q+1} y^(q+1) / (q+1)! from the last correction); down, z_q dropped.
subroutine set_order(self, bx, q)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. | |
q | integer(kind=I4P) | in | New order. |
Call graph
nordsieck_stepper%stage_state
The active stage's state, with the field's bounds.
Returns: real(kind=R_P)
function stage_state(self) result(u)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. |
nordsieck_stepper%rhs_register
Where the caller writes the active stage's residual, with the field's bounds.
Returns: real(kind=R_P)
function rhs_register(self) result(r)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. |
nordsieck_stepper%explicit_part
E = y_p - l_0 z_1 (from begin_step to finish_step): the implicit stage is U = E + gamma R(U), gamma = h l_0.
Returns: real(kind=R_P)
function explicit_part(self) result(e)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. |
nordsieck_stepper%stage_gamma
The implicit coefficient of stage k as a fraction of the step: l_0 for k >= 2, 0 for stage 1 (the prediction).
Attributes: pure
Returns: real(kind=R_P)
function stage_gamma(self, k) result(g)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. | |
k | integer(kind=I4P) | in | Stage. |
nordsieck_stepper%column
The column z_j = h^j y^(j) / j!, j = 1 .. qmax, with the field's bounds (its Delta: j = qmax + 1).
Returns: real(kind=R_P)
function column(self, j) result(z)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. | |
j | integer(kind=I4P) | in | Column. |
nordsieck_stepper%error_constant
C_{p+1}, the local error constant of the family's method of order p (LTE = C_{p+1} h^{p+1} y^(p+1)).
Attributes: pure
Returns: real(kind=R_P)
function error_constant(self, p) result(c)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. | |
p | integer(kind=I4P) | in | Order. |
nordsieck_stepper%error_sums
After the last stage, before finish_step: the local error estimates of the step at the orders q - 1, q and q + 1, scaled by atol + rtol |y| (y the corrected value), summed over the box: sums(1:3) their squares, sums(4) the values counted, sums(5) the squares of the last stage's residual (unscaled: the stability-limit detection's measure of the solution's growth). The caller sums them over its boxes and ranks, then select. With h^{q+1} y^(q+1) = q! l_q Delta (z_q's correction) and C_{p+1} the error constant of order p: e_{q-1} = C_q q! z_q, e_q = C_{q+1} q! l_q Delta, e_{q+1} = C_{q+2} q! l_q (Delta - Delta_{n-1}).
subroutine error_sums(self, bx, q, atol, rtol, sums)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
bx | type(box) | in | Box. | |
q | real(kind=R_P) | in | Solution (q^n: unused but for the bounds). | |
atol | real(kind=R_P) | in | Tolerances. | |
rtol | real(kind=R_P) | in | Tolerances. | |
sums | real(kind=R_P) | out | Sums of squares at q - 1, q, q + 1; count; R. |
Call graph
nordsieck_stepper%select
From the reduced sums: the step is accepted when the RMS estimate at q is <= 1; the next step and order. After q + 1 accepted steps at an order, the order of the largest step among q - 1, q, q + 1 is chosen (biases 1.3, 1.2, 1.4 on the estimates), and the step changes only when it grows by 10 % or shrinks; in between the step stays. Each candidate is capped at 0.9 beta(p) / rho when the caller gave a spectral radius rho, and an order whose step has no imaginary-axis interval (beta = 0: Adams 3, 4, 7, 8, 11, 12 with 2 stages) is then never moved to. A rejection shrinks the step (0.2 to 0.9 of it), and the order too from the third in a row.
subroutine select(self, sums, accept, h_next, q_next)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
sums | real(kind=R_P) | in | Reduced sums. | |
accept | logical | out | The step is accepted. | |
h_next | real(kind=R_P) | out | The next step. | |
q_next | integer(kind=I4P) | out | The next order. |
Call graph
nordsieck_stepper%set_spectral_radius
The caller's estimate of the largest |lambda| of its residual's Jacobian, on the imaginary axis (an advection's a / dx): each order's step is capped at 0.9 beta(p) / rho (stability_bound), and select prefers the order with the largest capped step. 0 removes the cap.
subroutine set_spectral_radius(self, rho)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | inout | Stepper. | |
rho | real(kind=R_P) | in | Spectral radius. |
nordsieck_stepper%stability_bound
The imaginary-axis bound of order p's step (in h |lambda|): Adams, the P(EC)^m step from ab-p's prediction (selah_lmm fixed_point_imag_axis_bound, m the stages); BDF, the scheme's own (100: the scan's end, unbounded).
Attributes: pure
Returns: real(kind=R_P)
function stability_bound(self, p) result(b)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(nordsieck_stepper) | in | Stepper. | |
p | integer(kind=I4P) | in | Order. |