# Numerical Treatment and Algorithms

## PeleC Time-stepping

PeleC supports two options for time-stepping: a second-order explicit method-of-lines approach (MOL), and an iterative scheme base on a spectral deferred correction approach (SDC). Both time-steppers share a considerable amount of code.

### Standard Time Advance

The MOL time stepper is a standard second order predictor-corrector approach with (optional) fixed point iteration to tightly couple the reaction and transport. The advection \((A)\) and diffusion \((D)\) terms are computed using a time-explicit finite-volume formulation; reaction terms are either computed explicitly or integrated (using DVODE or CVODE via SUNDIALS), with a forcing term that incorporates the (pointwise) influence of advection and diffusion (\(F_{AD}\)). The update is as follows:

On initialization, the reaction term \((I_R)\) is evaluated with \((F_{AD} = 0)\); for subsequent time steps, the initial value of \((I_R)\) is taken from the previous time step. The advection and diffusion terms (evaluated above at \(t^n\) and \(t^{n+1}\)) require grow cells to be filled at the appropriate solution time. The filling operation is orchestrated by the AMReX software framework via the FillPatch operation. Grow cells from neighboring mesh patches (and through periodic/re-entrant boundaries) are copied on intersection in index space. User-specified functions provide data at the physical boundaries as a function of space and time. Cells along the coarse-fine boundary are interpolated in space and time from available coarse data (note that this requires that the fine data be “properly nested” in the coarser levels). Also, because \((A)\) and \((D)\) are both time-explicit, they are computed together using grow cells filled by the same FillPatch operation.

With time-implicit reactions, the final update is iterated:

## Hyperbolics

Two hyperbolic treatments are available: Piecewise Parabolic Method and the Method of Lines.

### Piecewise Parabolic Method (PPM)

The unsplit piecewise parabolic method is used for regular
geometries. Currently in PeleC, there are 2 variants that can be
chosen through the `ppm_type`

flag:

`ppm_type = 0`

(default) uses a piecewise linear interpolation to reconstruct values at face. This is denoted PLM in the source code.`ppm_type = 1`

is the original PPM method presented in Colella and Woodward [JCP 1984].

For `ppm_type = 0`

, one can control the order of the construction of the slopes with the `plm_iorder`

flag:

`plm_iorder = 1`

sets the slopes to zero;`plm_iorder = 2`

uses the \(i-1\), \(i\), and \(i+1\) cells to form a slope;`plm_iorder = 4`

(default) uses the \(i-2\), \(i-1\), \(i\), \(i+1\), and \(i+2\) cells to form a slope.

Note

The following description of PPM implementations are only available in the (deprecated) Fortran source code. Efforts are ongoing to port all the PPM variants into the C++ source code.

Currently in PeleC Fortran source, there are 4 variants that can be
chosen through the `ppm_type`

flag:

`ppm_type = 0`

uses a piecewise linear interpolation to reconstruct values at face.`ppm_type = 1`

is the original PPM method presented in Colella and Woodward [JCP 1984].`ppm_type = 2`

is the “extrema preserving” variant of the PPM method.`ppm_type = 3`

is a new hybrid PPM/WENO method developed by Motheau and Wakefield [CAMCOS 2020], that replace the interpolation and slope limiting procedures by a WENO reconstruction.

In the remainder of this section, the extrema preserving PPM method, i.e `ppm_type = 2`

, is presented. Note that the implementation
in PeleC is a recollection of different extension of the PPM method published in Miller and Colella [JCP 2002] and Colella and Sekora [JCP 2008].
The actual implementation in PeleC is described in the paper Motheau and Wakefield, Investigation of finite-volume methods to capture shocks and turbulence spectra in compressible flows [CAMCOS 2020],
and the following description is taken from that paper. Note that the algorithm is presented here in 1D
for simplicity, but can be trivially extended to 2D and 3D.

Note also that the hybrid PPM/WENO method is described in the
aforementioned paper. This hybrid strategy presents far better results
in terms of capture of turbulent spectra rather than the other PPM
methods. When `ppm_type = 1`

and use_hybrid_weno = true is used, the
WENO reconstruction method can be selected with `weno_scheme`

:

`weno_scheme = 0`

is the classical 5th order WENO-JS of Jiang and Shu [JCP 1996].`weno_scheme = 1`

is the 5th order WENO-Z method of Borges et al. [JCP 2008].`weno_scheme = 2`

is the 7th order WENO-Z.`weno_scheme = 3`

is the 3rd order WENO-Z.

By default, `weno_scheme = 1`

is selected and use_hybrid_weno = false.

#### System of primitive variables

First, the system of primitive variables is recast in the following generic form:

Here \(\mathbf{Q}\) is the primitive state vector, \(\mathbf{A}=\partial \mathbf{F}/\partial \mathbf{Q}\) and \(\mathbf{S}_{\mathbf{Q}}\) are the viscous source terms reformulated in terms of the primitive variables.

In one dimension, this comes:

Note that here, the system of primitive variables has been extended to include an additional equation for the internal energy, denoted \(e\). This avoids several calls to the equation of state, especially in the Riemann solver step.

The eigenvalues of the matrix \(\mathbf{A}_x\) are given by:

The right column eigenvectors are:

The left row eigenvectors, normalized so that \(\mathbf{l}_x\cdot\mathbf{r}_x = \mathbf{I}\) are:

Note that here, \(c\) and \(h\) are the sound speed and the enthalpy, respectively.

#### Edge state prediction

The fluxes are reconstructed from time-centered edge state values. Thus, the primitive variables are first interpolated in space with the PPM method, then a characteristic tracing operation is performed to extrapolate in time their values at \(n+1/2\).

Interpolation and slope limiting

Basically the goal of the algorithm is to compute a left and a right state of the primitive variables at each edge in order to provide inputs for the Riemann problem to solve.

First, the average cross-cell difference is computed for each primitive variable with a quadratic interpolation as follows:

In order to enforce monotonicity, \(\delta q_i\) is limited with the van Leer [1979] method:

and the interpolation of the primitive values to the cell face \(q_{i+\frac{1}{2}}\) is estimated with:

In order to enforce that \(q_{i+\frac{1}{2}}\) lies between the adjacent cell averages, the following constraint is imposed:

The next step is to set the values of \(q_{R,i-\frac{1}{2}}\) and \(q_{L,i+\frac{1}{2}}\), which are the right and left state at the edges bounding a computational cell. Here, a quartic limiter is employed in order to enforce that the interpolated parabolic profile is monotone. The procedure proposed by Miller [2002] is adopted, which slightly differs from the original one proposed in Colella [1984]. In Miller [2002], this specific procedure is followed by the imposition of another limiter based on a flattening parameter to prevent artificial extrema in the reconstructed values. Here in PeleC, the order of imposition of the different limiting procedures is reversed.

First, the edge state values are defined as:

Then the flattening limiter is imposed as follows:

where \(\chi_i\) is a flattening coefficient computed from the local pressure, and its evaluation is presented below.

A non-dimensional shock resolution parameter \(\beta_{x,ijk}\) is constructed in cell \(ijk\) according to the equation given below.

If \(\beta_{x,ijk}\) is small, then any discontinuity is assumed to be well resolved. If \(\beta_{x,ijk}\) is 0.5 then the pressure \(P\) is linear across four consecutive cells in the i-th direction. A minimum value of \(\tilde \chi_{x,i,j,k}\) is now calculated using two additional parameters \(a_0\) and \(a_1\) as,

The values of \(a_0\) and \(a_1\) are fixed as \(0.75\) and \(0.85\) respectively.

The flattening parameter \(\tilde \chi_{x,ijk}\) is now defined as,

with the non-dimensional shock strength parameter \(Z_{x,ijk}\) defined as,

For the case of three-dimensional flows, the limiter \(\chi_{ijk}\) is then computed using the equation given below,

Finally, the monotonization is performed with the following procedure:

Piecewise Parabolic Reconstruction

Once the limited values \(q_{R,i-\frac{1}{2}}\) and \(q_{L,i+\frac{1}{2}}\) are known, the limited piecewise parabolic reconstruction in each cell is done by computing the average value swept out by parabola profile across a face, assuming that it moves at the speed of a characteristic wave \(\lambda_k\). The average is defined by the following integrals:

with \(\sigma_k = |\lambda_k|\Delta t / \Delta x\), where \(\lambda_k=\{u-c,u,u,u+c\}\), while \(\Delta t\) and \(\Delta x\) are the discretization step in time and space, respectively, with the assumption that \(\Delta x\) is constant in the computational domain.

The parabolic profile is defined by

with

and

Substituting (4) in (3) leads to the following explicit formulations:

Characteristic tracing and flux reconstruction

The next step is to extrapolate in time the integrals \(\mathcal{I}^{(k)}_{\pm}\) to get the left and right edge states at time \(n+1/2\). This procedure is complex, especially in multi-dimensions where transverse terms are taken into account; the complete detailed procedure can be found in Miller[2002]. In 1D, the left and right edge states are computed as follows:

where

and \(\mathbf{l}_k\) and \(\mathbf{r}_k\) are the left row and right column of the matrices defined at (1) and (2) for each eigenvalue \(k\). Note that here, \(S_i^n\) represents any source terms at time \(n\) to include in the characteristic tracing operation.

Finally, the time-centered fluxes are computed using an approximate Riemann problem solver. At the end of this procedure the primitive variables are centered in time at \(n+1/2\), and in space at the edges of a cell. This is the so-called Godunov state and the convective fluxes can be computed to create the advective source term.

### Method of Lines with Characteristic Extrapolation

An alternative formulation well suited to Embedded Boundary geometry treatment and also available for regular grids is available and based on a method of lines approach. For each direction, characteristic extrapolation is used to compute left and right states at the cell faces:

The right states are computed as:

The computations in the y- and z- direction are analogous; the flux on an EB face to apply a no-slip boundary condition at a wall is somewhat different. In that case, the left and right states are taken as the state at the cell center, except for the velocity is reflected across the EB face. That is:

and, as noted the right state is identical except for:

Once the left and right states are computed, a Riemann solver (in this case one preserving the physical constraints on the intermediate state) is used to compute fluxes that are assembled into a conservative and non-conservative update for the regular and cut cells.

The characteristic extrapolation requires (slope limited) fluxes, which computes the slope routines compute (limited) slopes as:

If cell is irregular, or neighbor to left is irregular, \(\Delta^- = 0.0\).

Again, if cell is irregular, or neighbor to right is irregular, \(\Delta^+ = 0.0\). Finally, the slopes are limited according to:

where:

The formulation of the y- and z-directions is analogous to the x-direction. One can control the order of the construction of the slopes with the `mol_iorder`

flag:

`mol_iorder = 1`

sets the slopes to zero;`mol_iorder = 2`

uses the procedure described above.

### Comparison of PPM and MOL for the decay of homogeneous isotropic turbulence

Comparison of PPM and MOL were performed using the decay of homogeneous isotropic turbulence. Initial conditions for the velocity fields were provided by an incompressible spectral simulation. The comparisons were performed at \(N=128^3\) and \(512^3\). While generally exhibiting similar results, the MOL is more dissipative that the PPM, as shown in the figure below. For the MOL at \(N = 512^3\), the maximum relative error in kinetic energy is \(0.9\%\) and \(k_{90}= 3 k_{\lambda_0}\) at \(t=5\tau\), for the PPM, these numbers are \(0.5\%\) and \(4 k_{\lambda_0}\). The dissipation rate is under-predicted for the MOL. The energy spectra at high wave-numbers for the MOL are lower than those for the PPM. Finally, the MOL has a more restrictive CFL condition (CFL=0.3), and, therefore, MOL simulations were approximately three times slower than PPM simulations.

### Advection schemes and EB

The two main advection schemes (PLM and MOL) described above support the use of complex geometry in the domain (as implemented using the Embedded Boundary (EB) formulation). While the PLM advection scheme is preferred numerically (less dissipative scheme), the PLM implementation with EB is a recent addition and has not had the same extensive testing as the MOL scheme with EB. Both PLM and MOL may also have issues when the EB intersects the boundary at an angle (this remains to be solved).

## Diffusion

One of two diffusion models is selected during the compilation of PeleC, based on the choice of the equation-of-state: a simple model for ideal gases, and a more involved model when real gases are employed. In both cases, the associated derivatives are discretized in space with a straightforward centered finite-volume approach. Transport coefficients (discussed below) are computed at cell centers from the evolving state data, and are arithmetically averaged to cell faces where they are needed to evaluate the transport fluxes. The time discretization for the transport terms is fully explicit and second-order. Although formally this approach leads to a maximum \(\Delta t\) restriction for time evolution that scales as \(\Delta x^2\), it is well known that for resolved flows the CFL constraint will provide the most restrictive time step limitation (ignoring chemical times). Note that when subgrid models are employed for advection, or stiff reactions are incorporated with an explicit treatment of chemistry, the maximum achievable \(\Delta t\) may be considerably smaller than the CFL limit, and other integration approaches might perform significantly better.

### Ideal Gas Diffusion

To close the system for a mixture of ideal gases, we adopt the definition for internal energy used in the CHEMKIN standard,

where \(e_m\) is the species \(m\) internal energy, as specified in the thermodynamics database for the mixture. For ideal gases, the transport fluxes can be written as:

The mixture-averaged transport coefficients discussed above (\(\mu\), \(\lambda\) and \(D_{m,mix}\)) can be evaluated from transport properties of the pure species. We follow the treatment used in the EGLib library, based on the theory/approximations developed by Ern and Givangigli (however, PeleC uses a recoded version of these routines that are thread safe and vectorize well on suitable processors).

The following choices are currently implemented in PeleC

The viscosity, \(\mu\), is estimated based on an empirical mixture formula (with \(\alpha = 6\)):

The conductivity, \(\lambda\), is also calculated using a similar formula as that \(\mu\) but with \(\alpha = 1/4\):

The diffusion flux is approximated using the diagonal matrix \(diag(\widetilde{ \Upsilon})\), where:

This leads to a mixture-averaged approximation that is similar to that of Hirschfelder-Curtiss:

Note that with these definitions, there is no guarantee that \(\sum \boldsymbol{\mathcal{F}}_{m} = 0\), as required for mass conservation. An arbitrary *correction flux,* consistent with the mixture-averaged diffusion approximation, is added in PeleC to enforce conservation.

The pure species and mixture transport properties are evaluated with (thread-safe, vectorized) EGLib functions, which require as input polynomial fits of the logarithm of each quantity versus the logarithm of the temperature.

\(q_m\) represents \(\eta_m\), \(\lambda_m\) or \(D_{m,j}\). These fits are generated as part of a preprocessing step managed by the tool FUEGO based on the formula (and input data) discussed above. The role of FUEGO to preprocess the model parameters for transport as well as chemical kinetics and thermodynamics, is discussed in some detail in <Section FuegoDescr>.

## Reaction

A chemical reaction network is evaluated to determine the reaction source term. The reaction network is selected at build time by setting the CHEMISTRY_MODEL flag in the makefile, where the value refers to one of the models available in PelePhysics. New models can be generated using Fuego, currently not part of PelePhysics but slated for inclusion in the near future.

## Equation of State

Several equation of state models are available based on ideal gas, gamma law gas or non-ideal equation of state. These are implemented through the PelePhysics module.