josie.general.schemes.time package

Submodules

josie.general.schemes.time.euler module

class josie.general.schemes.time.euler.ExplicitEuler(problem, *args, **kwargs)

Bases: josie.scheme.time.TimeScheme

Implements the explicit euler scheme

\pdeState^{k+1} = \pdeState^k +
    \Delta t \; \vb{f}\qty(t; \pdeState^k,\pdeGradient^k)

step(mesh, dt, t)

For ExplicitEuler, we just accumulate once the fluxes at time t = t_k. So nothing to do.

time_order: float = 1

josie.general.schemes.time.rk module

Classes associated to the implementation of Runge-Kutta time schemes

class josie.general.schemes.time.rk.ButcherTableau(a_s, b_s, c_s)

Bases: object

A class to store the RK coefficients.

Generally coefficients for a generic Runge-Kutta method are stored in a mnemonic structure called Butcher Tableau.

\renewcommand\arraystretch{1.2}
\begin{array}
{c|cccc}
0\\
c_1 & a_{11} \\
c_2 & a_{12} & a_{22} \\
\vdots & \ldots \\
c_s & a_{s1} & a_{s2} & \ldots & a_{s s-1} \\
\hline
& b_1 & b_2 & \ldots & b_s
\end{array}

For example:

\renewcommand\arraystretch{1.2}
\begin{array}
{c|cccc}
0\\
\frac{1}{2} & \frac{1}{2}\\
\frac{1}{2} &0 &\frac{1}{2} \\
1& 0& 0& 1\\
\hline
& \frac{1}{6} &\frac{1}{3} &\frac{1}{3} &\frac{1}{6}
\end{array}

Parameters
  • a_s (numpy.ndarray) – The a_s coefficients stored in a np.ndarray. The order of storage is a_{11}, a_{21}, a_{22}, a_{31} \ldots

  • b_s (numpy.ndarray) – The b_s coefficients stored in a np.ndarray. The order of storage is b_1, b_2, b_3, b_4 \ldots

  • c_s (numpy.ndarray) – The c_s coefficients stored in a np.ndarray. The order of storage is c_1, c_2, c_3 ldots`

a_s

The a_s coefficients stored in a np.ndarray. The order of storage is a_{11}, a_{21}, a_{22}, a_{31} \ldots

Type

numpy.ndarray

b_s

The b_s coefficients stored in a np.ndarray. The order of storage is b_1, b_2, b_3, b_4 \ldots

Type

numpy.ndarray

c_s

The c_s coefficients stored in a np.ndarray. The order of storage is c_1, c_2, c_3 \ldots

Type

numpy.ndarray

a_s: numpy.ndarray
b_s: numpy.ndarray
c_s: numpy.ndarray
class josie.general.schemes.time.rk.RK(problem, butcher)

Bases: josie.scheme.time.TimeScheme

A generic Runge-Kutta explicit method

\rungeKutta

problem

An instance of Problem representing the physical problem that this scheme discretizes

butcher

An instance of ButcherTableau that provides the coefficient of the Runge-Kutta method

k(mesh, dt, t, step)

Recursive function that computes all the k_s coefficients from s = 0 to s = \text{step}

The highest k_s value is stored in _fluxes

post_init(cells)

A Runge-Kutta method needs to store intermediate steps. It needs s - 1 additional storage slots, where s is the number of steps of the Runge-Kutta method

Parameters

cells (MeshCellSet) – A MeshCellSet containing the state of the mesh cells

pre_step(cells)

Zero-out the array containing the k_s values

Parameters

cells (MeshCellSet) – A MeshCellSet containing the state of the mesh cells

step(mesh, dt, t)

This method implements the accumulation over all the neighbours of a specific cell of the numerical fluxes. It can be overridden by, for example, a TimeScheme in order to implement multi-step accumulation

Parameters
  • mesh (Mesh) – A Mesh containing the state of the mesh

  • dt (float) – Time step

  • t (float) – The current time instant of the simulation

time_order: float
class josie.general.schemes.time.rk.RK2(problem)

Bases: josie.general.schemes.time.rk.RK2Alpha

Implements the explicit 2nd-order Runge-Kutta scheme with \alpha =
2/3

time_order: float = 2
class josie.general.schemes.time.rk.RK2Alpha(problem, alpha)

Bases: josie.general.schemes.time.rk.RK

Implements the explicit 2nd-order Runge-Kutta scheme with a tunable \alpha parameter

\pdeState^{k+1} = \pdeState^k +
    \Delta t \;
    \vb{f}\qty(\qty(1-\frac{1}{2\alpha})k_1 + \frac{1}{2\alpha})

\renewcommand\arraystretch{1.2}
\begin{array}
{c|cccc}
0\\
\alpha & \alpha \\
\hline
& \qty(1 - \frac{1}{2\alpha}) & \frac{1}{2\alpha}
\end{array}

Parameters
  • problem (Problem) – An instance of Problem representing the physical problem that this scheme discretizes

  • alpha (float) – The value of the alpha coefficient

num_steps: int
time_order: float

Module contents