MacCormack method

Equation in computational fluid dynamics

In computational fluid dynamics, the MacCormack method (/məˈkɔːrmæk ˈmɛθəd/) is a widely used discretization scheme for the numerical solution of hyperbolic partial differential equations. This second-order finite difference method was introduced by Robert W. MacCormack in 1969.[1] The MacCormack method is elegant and easy to understand and program.[2]

## The algorithm

[edit]

The MacCormack method is designed to solve hyperbolic partial differential equations of the form

∂ u ∂ t + ∂ f ( u ) ∂ x = 0 {\displaystyle {\frac {\partial u}{\partial t}}+{\frac {\partial f(u)}{\partial x}}=0}

To update this equation one timestep  Δ t {\displaystyle \Delta t} on a grid with spacing  Δ x {\displaystyle \Delta x} at grid cell  i {\displaystyle i} , the MacCormack method uses a "predictor step" and a "corrector step", given below[3]

u i p = u i n − Δ t Δ x ( f i + 1 n − f i n ) u i n + 1 = 1 2 ( u i n + u i p ) − Δ t 2 Δ x ( f i p − f i − 1 p ) {\displaystyle {\begin{aligned}&u_{i}^{p}=u_{i}^{n}-{\frac {\Delta t}{\Delta x}}\left(f_{i+1}^{n}-f_{i}^{n}\right)\\\&u_{i}^{n+1}={\frac {1}{2}}(u_{i}^{n}+u_{i}^{p})-{\frac {\Delta t}{2\Delta x}}(f_{i}^{p}-f_{i-1}^{p})\end{aligned}}}

## Linear Example

[edit]

To illustrate the algorithm, consider the following first order hyperbolic equation

∂ u ∂ t + a ∂ u ∂ x = 0. {\displaystyle \qquad {\frac {\partial u}{\partial t}}+a{\frac {\partial u}{\partial x}}=0.}

The application of MacCormack method to the above equation proceeds in two steps; a predictor step which is followed by a corrector step.

Predictor step: In the predictor step, a "provisional" value of  u {\displaystyle u} at time level  n + 1 {\displaystyle n+1} (denoted by  u i p {\displaystyle u_{i}^{p}} ) is estimated as follows

u i p = u i n − a Δ t Δ x ( u i + 1 n − u i n ) {\displaystyle u_{i}^{p}=u_{i}^{n}-a{\frac {\Delta t}{\Delta x}}\left(u_{i+1}^{n}-u_{i}^{n}\right)}

The above equation is obtained by replacing the spatial and temporal derivatives in the previous first order hyperbolic equation using forward differences.

Corrector step: In the corrector step, the predicted value  u i p {\displaystyle u_{i}^{p}} is corrected according to the equation

u i n + 1 = u i n + 1 / 2 − a Δ t 2 Δ x ( u i p − u i − 1 p ) {\displaystyle u_{i}^{n+1}=u_{i}^{n+1/2}-a{\frac {\Delta t}{2\Delta x}}\left(u_{i}^{p}-u_{i-1}^{p}\right)}

Note that the corrector step uses backward finite difference approximations for spatial derivative. The time-step used in the corrector step is  Δ t / 2 {\displaystyle \Delta t/2} in contrast to the  Δ t {\displaystyle \Delta t} used in the predictor step.

Replacing the  u i n + 1 / 2 {\displaystyle u_{i}^{n+1/2}} term by the temporal average

u i n + 1 / 2 = u i n + u i p 2 {\displaystyle u_{i}^{n+1/2}={\frac {u_{i}^{n}+u_{i}^{p}}{2}}}

to obtain the corrector step as

u i n + 1 = u i n + u i p 2 − a Δ t 2 Δ x ( u i p − u i − 1 p ) {\displaystyle u_{i}^{n+1}={\frac {u_{i}^{n}+u_{i}^{p}}{2}}-a{\frac {\Delta t}{2\Delta x}}\left(u_{i}^{p}-u_{i-1}^{p}\right)}

### Some remarks

[edit]

The MacCormack method is well suited for nonlinear equations (Inviscid Burgers equation, Euler equations, etc.) The order of differencing can be reversed for the time step (i.e., forward/backward followed by backward/forward). For nonlinear equations, this procedure provides the best results. For linear equations, the MacCormack scheme is equivalent to the Lax–Wendroff method.[4]

Unlike first-order upwind scheme, the MacCormack does not introduce diffusive errors in the solution. However, it is known to introduce dispersive errors (Gibbs phenomenon) in the region where the gradient is high.

## See also

[edit]

* Lax–Wendroff method
* Upwind scheme
* Hyperbolic partial differential equations

## References

[edit]

1. ^ MacCormack, R. W., The Effect of viscosity in hypervelocity impact cratering, AIAA Paper, 69-354 (1969).
2. ^ Anderson, J. D., Jr., Computational Fluid Dynamics: The Basics with Applications, McGraw Hill (1994).
3. ^ Cameron, Maria (2011). "Notes on Burger's Equation" (PDF). University of Maryland.
4. ^ Tannehill, J. C., Anderson, D. A., and Pletcher, R. H., Computational Fluid Mechanics and Heat Transfer, 2nd ed., Taylor & Francis (1997).

* v
* t
* e

Numerical methods for partial differential equations

Finite difference|

| Parabolic|

* Forward-time central-space (FTCS)
* Crank–Nicolson

|

Hyperbolic|

* Lax–Friedrichs
* Lax–Wendroff
* MacCormack
* Upwind
* Method of characteristics

Others|

* Alternating direction-implicit (ADI)
* Finite-difference frequency-domain (FDFD)
* Finite-difference time-domain (FDTD)

Finite volume|

* Godunov
* High-resolution
* Monotonic upstream-centered (MUSCL)
* Advection upstream-splitting (AUSM)
* Riemann solver
* Essentially non-oscillatory (ENO)
* Weighted essentially non-oscillatory (WENO)

Finite element|

* hp-FEM
* Extended (XFEM)
* Discontinuous Galerkin (DG)
* Spectral element (SEM)
* Mortar
* Gradient discretisation (GDM)
* Loubignac iteration
* Smoothed (S-FEM)

Meshless/Meshfree|

* Smoothed-particle hydrodynamics (SPH)
* Peridynamics (PD)
* Moving particle semi-implicit method (MPS)
* Material point method (MPM)
* Particle-in-cell (PIC)

Domain decomposition|

* Schur complement
* Fictitious domain
* Schwarz alternating
* additive
* abstract additive
* Neumann–Dirichlet
* Neumann–Neumann
* Poincaré–Steklov operator
* Balancing (BDD)
* Balancing by constraints (BDDC)
* Tearing and interconnect (FETI)
* FETI-DP

Others|

* Spectral
* Pseudospectral (DVR)
* Method of lines
* Multigrid
* Collocation
* Level-set
* Boundary element
* Method of moments
* Immersed boundary
* Analytic element
* Isogeometric analysis
* Infinite difference method
* Infinite element method
* Galerkin method
* Petrov–Galerkin method
* Validated numerics
* Computer-assisted proof
* Integrable algorithm
* Method of fundamental solutions

Related|

* Numerical methods for ordinary differential equations
* Numerical integration

*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template