Skip to content

Build a custom splitting ​

A splitting advances u′=F1(u)+F2(u) by sub-flows of each part over fractions of the step. SELAH's catalogue holds four symmetric compositions (Schemes); the stepper runs them by name with FORM_SPLITTING (Tutorial 6). A composition the catalogue lacks is a splitting_composition you build and drive yourself.

A composition of your own ​

palindrome(first, half, order) builds a symmetric composition from its half sequence, up to and including the middle flow; the flows alternate partitions from first. Suzuki's fivefold Strang composition, S(ph)S(ph)S((1−4p)h)S(ph)S(ph) with p=1/(4−41/3), merges into 11 flows, against strang and blanes-moan-s6:

fortran
type(splitting_composition) :: sc(3)
character(16)               :: names(3) = [character(16) :: 'strang', 'suzuki (own)', 'blanes-moan-s6']
real(R_P)                   :: p, err(3)
integer(I4P)                :: s, l

p = 1._R_P / (4._R_P - 4._R_P**(1._R_P/3._R_P))
sc(1) = splitting(SCHEME_STRANG)
sc(2) = palindrome(first=1, half=[p/2, p, p, p, (1 - 3*p)/2, 1 - 4*p], order=4)  ! up to the middle flow
sc(3) = splitting(SCHEME_BLANES_MOAN_S6)
print '(A)', 'composition     flows  order  sum of fractions 1, 2   error, 8 steps  16 steps  observed order'
do s=1, 3
   do l=1, 2
      err(l) = oscillate(sc(s), 8 * l)
   enddo
   print '(A16,I5,I7,2F10.4,ES17.2,ES10.2,F9.2)', names(s), sc(s)%flows, sc(s)%order, &
         sum(sc(s)%coefficient, mask=sc(s)%partition == 1), sum(sc(s)%coefficient, mask=sc(s)%partition == 2), &
         err(1:2), log(err(1) / err(2)) / log(2._R_P)
enddo

Drive any composition with its arrays: flow m advances partition sc%partition(m) over sc%coefficient(m) of the step. On the oscillator each flow is exact (the residual of each part does not depend on its own variables):

fortran
do m=1, sc%flows                                            ! flow 1 first
   select case(sc%partition(m))
   case(1) ; x = x + sc%coefficient(m) * h * v              ! exact: x' = v does not depend on x
   case(2) ; v = v - sc%coefficient(m) * h * x              ! exact: v' = -x does not depend on v
   endselect
enddo
text
$ cookbook_splittings own
composition     flows  order  sum of fractions 1, 2   error, 8 steps  16 steps  observed order
strang              3      2    1.0000    1.0000         1.29E-03  3.23E-04     2.00
suzuki (own)       11      4    1.0000    1.0000         6.14E-07  3.83E-08     4.00
blanes-moan-s6     13      4    1.0000    1.0000         2.70E-08  1.69E-09     4.00
  • The fractions of each partition sum to 1, the consistency of any composition.
  • The Suzuki composition reaches order 4 with 11 flows; blanes-moan-s6, 13 flows, has an error 23 times smaller at the same steps.
  • Each flow above is exact because neither part's residual depends on its own variables. The stepper's splitting form rests on the same assumption (its flows are forward-Euler steps of one partition), and takes the catalogue's names only.

The observed orders of the four splittings on the pendulum, against the steps

What a composition must reach: the four of the catalogue at their orders on the pendulum (A4).

Additive splittings: which run backward ​

additive_splitting composes the stepper's field step with a flow of your own (cooling, a relaxation, a particle step): Composition, Tutorial 12. Every composition of order 3 or more runs a substep backward in time, which an irreversible operator cannot do:

fortran
type(additive_splitting) :: sp
integer(I4P)             :: s, m

print '(A)', 'scheme           substeps  order  a substep backward'
do s=1, size(ADDITIVE_SCHEMES)
   call sp%initialize(trim(ADDITIVE_SCHEMES(s)), reversible=.true.)
   print '(A15,I9,I7,L12)', ADDITIVE_SCHEMES(s), sp%substeps(), sp%order(), sp%backward()
enddo
call sp%initialize(SCHEME_YOSHIDA_4, reversible=.true.)
print '(/,A)', 'yoshida-4  substep  operator  fraction  starts at'
do m=1, sp%substeps()
   print '(I17,A10,2F10.4)', m, merge('flow ', 'field', sp%substep_operator(m) == OPERATOR_FLOW), &
         sp%substep_fraction(m), sp%substep_time(m)
enddo
text
$ cookbook_splittings additive
scheme           substeps  order  a substep backward
lie                    2      1           F
strang                 3      2           F
yoshida-4              7      4           T
blanes-moan-s6        13      4           T
blanes-moan-s10       21      6           T

yoshida-4  substep  operator  fraction  starts at
                1     flow     0.6756    0.0000
                2     field    1.3512    0.0000
                3     flow    -0.1756    0.6756
                4     field   -1.7024    1.3512
                5     flow    -0.1756    0.5000
                6     field    1.3512   -0.3512
                7     flow     0.6756    0.3244
  • backward() is true for yoshida-4 and both Blanes–Moan schemes: their negative fractions are backward substeps.
  • substep_time(m) is the start of substep m in each operator's own clock, the sum of the same operator's fractions before it: a backward substep moves that clock back.
  • substep_operator(m) is OPERATOR_FIELD (a step of the stepper) or OPERATOR_FLOW (yours). The palindromes start with the flow by default (first=), so that strang runs the field step once.

Without reversible=.true., initialize refuses a composition with a backward substep:

fortran
type(additive_splitting) :: sp

call sp%initialize(SCHEME_BLANES_MOAN_S6)                      ! reversible= not given: .false.
text
$ cookbook_splittings refused
ERROR STOP selah additive splitting: "blanes-moan-s6" runs substeps backward in time: lie or strang for an irreversible field step or flow (reversible=.true. if both operators are reversible)
[exit status 1]

Use lie or strang with an upwind or limited field step, cooling, diffusion or any other irreversible operator.