qmat.qcoeff.butcher

\(Q\)-coefficients based on Butcher tables of Runge-Kutta in the literature.

Examples

>>> from qmat.qcoeff.butcher import RK_SCHEMES
>>> c, b, A = RK_SCHEMES["RK4"]().genCoeffs()
>>> c, (b1, b2), A = RK_SCHEMES["ESDIRK53"]().genCoeffs(embedded=True)
>>> from qmat.qcoeff.butcher import CashKarp
>>> gen = CashKarp()
>>> c, b, A = gen.c, gen.b, gen.A

Attributes

RK_SCHEMES

Dictionary storing all the implemented RK methods

Classes

RK

Base class for Runge-Kutta generators

FE

Forward Euler method (cf Wikipedia)

RK21

Explicit Runge-Kutta in 2 steps of order 1 from [Wang & Spiteri, 2007]

RK2

Classical Runge-Kutta method of order 2 (cf Wikipedia)

HEUN2

Heun method of order 2 (cf Wikipedia)

RK32

Explicit Runge-Kutta in 3 steps of order 2 from [Wang & Spiteri, 2007]

RK33

Explicit Runge-Kutta in 3 steps of order 3 from [Wang & Spiteri, 2007]

RK53

Explicit Runge-Kutta in 5 steps of order 3 from [Wang & Spiteri, 2007]

RK4

Classical Runge Kutta method of order 4 (cf Wikipedia)

RK4_38

The 3/8-rule due to Kutta, order 4 (cf Wikipedia)

RK65

Explicit Runge-Kutta in 6 steps of order 5, (236a) from [Butcher, 2016]

CashKarp

Fifth order explicit embedded Runge-Kutta from [Cash & Karp, 1990].

BE

Backward Euler method (also SDIRK1, see [Alexander, 1977])

MidPoint

Implicit Mid-Point Rule, see Wikipedia.

TRAP

Trapeze method, see Wikipedia.

SDIRK2

First S-stable Diagonally Implicit Runge Kutta method of order 2 in two stages from [Alexander, 1977].

SDIRK2_2

Second S-stable Diagonally Implicit Runge Kutta method of order 2 in two stages from [Alexander, 1977].

SDIRK3

S-stable Diagonally Implicit Runge Kutta method of order 3 in three stages from [Alexander, 1977].

DIRK43

L-stable Diagonally Implicit RK method with four stages of order 3 from Wikipedia.

GAUSS_LG

Gauss-Legendre method of order 4 (cf Wikipedia).

SDIRK54

S-stable Diagonally Implicit Runge Kutta method of order 4 in five stages from [Hairer & Wanner, 1996].

EDIRK43

Embedded A-stable diagonally implicit RK pair of order 3 and 4 from [Norsett & Thomsen, 1984].

EDIRK4

Stiffly accurate, fourth-order EDIRK with four stages, taken from [Kennedy & Carpenter, 2016], second one in eq. (216).

ESDIRK43

A-stable embedded RK pair of orders 4 and 3, ESDIRK4(3)6L[2]SA, from [Kennedy & Carpenter, 2016].

ESDIRK53

A-stable embedded RK pair of orders 5 and 3, ESDIRK5(3)6L[2]SA, from [Kennedy & Carpenter, 2016].

ARK548L2SAERK

Explicit part of the ARK54 scheme.

ARK548L2SAESDIRK

Implicit part of the ARK54 scheme.

ARK548L2SAESDIRK2

Stiffly accurate singly diagonally L-stable implicit embedded Runge-Kutta pair of orders 5 and 4 with explicit first stage from [Kennedy & Carpenter, 2019].

ARK548L2SAERK2

Explicit embedded pair of Runge-Kutta methods of orders 5 and 4 from [Kennedy & Carpenter, 2019].

ARK324L2SAERK

Explicit part of embedded additive Runge-Kutta pair of orders 3 and 2 from [Kennedy & Carpenter, 2003].

ARK324L2SAESDIRK

Implicit part of embedded additive Runge-Kutta pair of orders 3 and 2 from [Kennedy & Carpenter, 2003].

ARK222EDIRK

2nd-order 2-stages EDIRK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.6].

ARK222ERK

2nd-order 2-stages ERK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.6].

ARK443ESDIRK

3rd-order 4-stages ESDIRK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.8].

ARK443ERK

3rd-order 4-stages ERK scheme [Ascher, Ruuth & Spiteri, 1997 - sec 2.8].

ARK343ESDIRK

3rd-order 3-stages ESDIRK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.7].

ARK343ERK

4rd-order 4-stages ERK scheme [Ascher, Ruuth & Spiteri, 1997 - sec 2.7].

ARK4EDIRK

A stable 7-stages fourth order diagonally implicit stiffly accurate Runge-Kutta method with explicit first stage.

ARK4ERK

7-stages fourth order explicit stiffly accurate Runge-Kutta method.

Functions

checkAndStore(→ RK)

Check that a RK-inherited class is correctly implemented (and store it into the RK_SCHEMES dict)

registerRK(→ RK)

Class decorator registering a RK method in qmat

Module Contents

class RK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK

Base class for Runge-Kutta generators

Parameters:

padding (str, optional) – Eventually add padding to the Butcher table. Can be

  • LEFT : add padding corresponding to an additional node at t=0

  • RIGHT : add padding corresponding to an additional node at t=1

  • BOTH : add both LEFT and RIGHT padding

The default is None.

A = None

\(A\) matrix of the Butcher table

b = None

\(b\) coefficients of the Butcher table

c = None

\(c\) coefficients of the Butcher table

b2 = None

\(b_2\) coefficients for the embedded methods

property nodes: numpy.ndarray

Nodes \(\tau\) (\(c\) coefficients in Butcher table)

property weights: numpy.ndarray

Weights \(\omega\) (\(b\) coefficients in Butcher table)

property weightsEmbedded: numpy.ndarray

Weights for a secondary lower order method from the same stages.

property Q: numpy.ndarray

\(Q\) coefficients (\(A\) Butcher table)

property hCoeffs: numpy.ndarray

\(h\) interpolation coefficients for the right boundary

RK_SCHEMES

Dictionary storing all the implemented RK methods

checkAndStore(cls: RK) RK[source]

Check that a RK-inherited class is correctly implemented (and store it into the RK_SCHEMES dict)

registerRK(cls: RK) RK[source]

Class decorator registering a RK method in qmat

class FE(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.FE

Forward Euler method (cf Wikipedia)

aliases = ['EE']
A = [[0]]

\(A\) matrix of the Butcher table

b = [1]

\(b\) coefficients of the Butcher table

c = [0]

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class RK21(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK21

Explicit Runge-Kutta in 2 steps of order 1 from [Wang & Spiteri, 2007]

aliases = ['ERK21']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class RK2(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK2

Classical Runge-Kutta method of order 2 (cf Wikipedia)

aliases = ['ERK2', 'ExplicitMidPoint', 'EMP']
A

\(A\) matrix of the Butcher table

b = [0, 1]

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class HEUN2(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.HEUN2

Heun method of order 2 (cf Wikipedia)

aliases = ['HEUN', 'HeunEuler']
A = [[0, 0], [1, 0]]

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c = [0, 1.0]

\(c\) coefficients of the Butcher table

b2 = [1, 0]

\(b_2\) coefficients for the embedded methods

property order: int

Global convergence order of the method

class RK32(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK32

Explicit Runge-Kutta in 3 steps of order 2 from [Wang & Spiteri, 2007]

aliases = ['ERK32', 'RK32-SSP']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class RK33(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK33

Explicit Runge-Kutta in 3 steps of order 3 from [Wang & Spiteri, 2007]

aliases = ['ERK33', 'RK33-SSP']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class RK53(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK53

Explicit Runge-Kutta in 5 steps of order 3 from [Wang & Spiteri, 2007]

aliases = ['ERK53']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class RK4(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK4

Classical Runge Kutta method of order 4 (cf Wikipedia)

aliases = ['ERK4']
A = [[0, 0, 0, 0], [0.5, 0, 0, 0], [0, 0.5, 0, 0], [0, 0, 1, 0]]

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class RK4_38(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK4_38

The 3/8-rule due to Kutta, order 4 (cf Wikipedia)

aliases = ['ERK4_38']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class RK65(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.RK65

Explicit Runge-Kutta in 6 steps of order 5, (236a) from [Butcher, 2016]

aliases = ['ERK65']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c = [0, 0.25, 0.25, 0.5, 0.75, 1]

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class CashKarp(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.CashKarp

Fifth order explicit embedded Runge-Kutta from [Cash & Karp, 1990].

aliases = ['Cash_Karp']
c

\(c\) coefficients of the Butcher table

b

\(b\) coefficients of the Butcher table

b2

\(b_2\) coefficients for the embedded methods

A

\(A\) matrix of the Butcher table

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [32, 64, 128]
class BE(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.BE

Backward Euler method (also SDIRK1, see [Alexander, 1977])

aliases = ['IE', 'SDIRK1']
A = [[1]]

\(A\) matrix of the Butcher table

b = [1]

\(b\) coefficients of the Butcher table

c = [1]

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class MidPoint(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.MidPoint

Implicit Mid-Point Rule, see Wikipedia.

aliases = ['IMP', 'ImplicitMidPoint']
A

\(A\) matrix of the Butcher table

b = [1]

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class TRAP(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.TRAP

Trapeze method, see Wikipedia.

aliases = ['TRAPZ', 'CN', 'CrankNicolson']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c = [0, 1]

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class SDIRK2(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.SDIRK2

First S-stable Diagonally Implicit Runge Kutta method of order 2 in two stages from [Alexander, 1977].

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class SDIRK2_2(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.SDIRK2_2

Second S-stable Diagonally Implicit Runge Kutta method of order 2 in two stages from [Alexander, 1977].

aliases = ['SDIRK2-2']
A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [64, 128, 256]
class SDIRK3(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.SDIRK3

S-stable Diagonally Implicit Runge Kutta method of order 3 in three stages from [Alexander, 1977].

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c = [0.43586652150845967, 0.7179332607542298, 1.0]

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class DIRK43(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.DIRK43

L-stable Diagonally Implicit RK method with four stages of order 3 from Wikipedia.

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class GAUSS_LG(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.GAUSS_LG

Gauss-Legendre method of order 4 (cf Wikipedia).

aliases = ['GAUSS-LG']
A

\(A\) matrix of the Butcher table

b = [0.5, 0.5]

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class SDIRK54(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.SDIRK54

S-stable Diagonally Implicit Runge Kutta method of order 4 in five stages from [Hairer & Wanner, 1996].

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class EDIRK43(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.EDIRK43

Embedded A-stable diagonally implicit RK pair of order 3 and 4 from [Norsett & Thomsen, 1984].

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

b2

\(b_2\) coefficients for the embedded methods

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [32, 64, 128]
class EDIRK4(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.EDIRK4

Stiffly accurate, fourth-order EDIRK with four stages, taken from [Kennedy & Carpenter, 2016], second one in eq. (216).

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [32, 64, 128]
class ESDIRK43(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ESDIRK43

A-stable embedded RK pair of orders 4 and 3, ESDIRK4(3)6L[2]SA, from [Kennedy & Carpenter, 2016].

s2 = 1.4142135623730951
c

\(c\) coefficients of the Butcher table

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

b2

\(b_2\) coefficients for the embedded methods

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [64, 128, 256]
class ESDIRK53(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ESDIRK53

A-stable embedded RK pair of orders 5 and 3, ESDIRK5(3)6L[2]SA, from [Kennedy & Carpenter, 2016].

c

\(c\) coefficients of the Butcher table

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

b2

\(b_2\) coefficients for the embedded methods

property orderEmbedded: int

Global convergence order of the associated embedded method

property order: int

Global convergence order of the method

class ARK548L2SAERK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK548L2SAERK

Explicit part of the ARK54 scheme.

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

c

\(c\) coefficients of the Butcher table

b2

\(b_2\) coefficients for the embedded methods

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [32, 64, 128]
class ARK548L2SAESDIRK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK548L2SAESDIRK

Implicit part of the ARK54 scheme. Be careful with the embedded scheme : it seems that both schemes are order 5 as opposed to 5 and 4 as claimed. This may cause issues when doing adaptive time-stepping.

A

\(A\) matrix of the Butcher table

property orderEmbedded: int

Global convergence order of the associated embedded method

class ARK548L2SAESDIRK2(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK548L2SAESDIRK2

Stiffly accurate singly diagonally L-stable implicit embedded Runge-Kutta pair of orders 5 and 4 with explicit first stage from [Kennedy & Carpenter, 2019]. This method is part of the IMEX method ARK548L2SA.

gamma = 0.2222222222222222
c

\(c\) coefficients of the Butcher table

b

\(b\) coefficients of the Butcher table

A

\(A\) matrix of the Butcher table

b2

\(b_2\) coefficients for the embedded methods

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [16, 32, 64]
class ARK548L2SAERK2(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK548L2SAERK2

Explicit embedded pair of Runge-Kutta methods of orders 5 and 4 from [Kennedy & Carpenter, 2019]. This method is part of the IMEX method ARK548L2SA.

A

\(A\) matrix of the Butcher table

class ARK324L2SAERK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK324L2SAERK

Explicit part of embedded additive Runge-Kutta pair of orders 3 and 2 from [Kennedy & Carpenter, 2003].

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

b2

\(b_2\) coefficients for the embedded methods

c

\(c\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class ARK324L2SAESDIRK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK324L2SAESDIRK

Implicit part of embedded additive Runge-Kutta pair of orders 3 and 2 from [Kennedy & Carpenter, 2003].

A

\(A\) matrix of the Butcher table

CONV_TEST_NSTEPS = [120, 100, 80]
class ARK222EDIRK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK222EDIRK

2nd-order 2-stages EDIRK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.6]. Use as implicit part for ARK scheme in combination with ARK222ERK.

gamma
delta
c

\(c\) coefficients of the Butcher table

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class ARK222ERK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK222ERK

2nd-order 2-stages ERK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.6]. Use as explicit part for ARK scheme in combination with ARK222EDIRK.

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

class ARK443ESDIRK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK443ESDIRK

3rd-order 4-stages ESDIRK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.8]. Use as implicit part for ARK scheme in combination with ARK443ERK.

c

\(c\) coefficients of the Butcher table

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class ARK443ERK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK443ERK

3rd-order 4-stages ERK scheme [Ascher, Ruuth & Spiteri, 1997 - sec 2.8]. Use as explicit part for ARK scheme in combination with ARK443ESDIRK.

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

class ARK343ESDIRK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK343ESDIRK

3rd-order 3-stages ESDIRK scheme from [Ascher, Ruuth & Spiteri, 1997 - sec 2.7]. Use as implicit part for ARK scheme in combination with ARK443ERK.

c

\(c\) coefficients of the Butcher table

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

property order: int

Global convergence order of the method

class ARK343ERK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK343ERK

4rd-order 4-stages ERK scheme [Ascher, Ruuth & Spiteri, 1997 - sec 2.7]. Use as explicit part for ARK scheme in combination with ARK343ESDIRK.

A

\(A\) matrix of the Butcher table

property order: int

Global convergence order of the method

class ARK4EDIRK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK4EDIRK

A stable 7-stages fourth order diagonally implicit stiffly accurate Runge-Kutta method with explicit first stage. Implicit part of Additive RK.4.A.2 from [Liu & Zou, 2006]. Use with ARK4ERK to get fourth order stiffly accurate IMEX method.

c

\(c\) coefficients of the Butcher table

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table

property order: int

Global convergence order of the method

CONV_TEST_NSTEPS = [60, 40, 20, 10]
class ARK4ERK(padding=None)[source]
Inheritance diagram of qmat.qcoeff.butcher.ARK4ERK

7-stages fourth order explicit stiffly accurate Runge-Kutta method. Explicit part of Additive RK.4.A.2 from [Liu & Zou, 2006]. Use with ARK4EDIRK to get fourth order stiffly accurate IMEX method.

A

\(A\) matrix of the Butcher table

b

\(b\) coefficients of the Butcher table