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 MacCormack method is designed to solve hyperbolic partial differential equations of the form
\partialu | |
\partialt |
+
\partialf(u) | |
\partialx |
=0
To update this equation one timestep
\Deltat
\Deltax
i
p | |
\begin{align} &u | |
i |
=
n | |
u | |
i |
-
\Deltat | |
\Deltax |
n | |
\left(f | |
i+1 |
-
n | |
f | |
i\right) |
\\
n+1 | |
&u | |
i |
=
1 | |
2 |
n | |
(u | |
i |
+
p | |
u | |
i) |
-
\Deltat | |
2\Deltax |
p | |
(f | |
i |
-
p | |
f | |
i-1 |
) \end{align}
To illustrate the algorithm, consider the following first order hyperbolic equation
\partialu | |
\partialt |
+a
\partialu | |
\partialx |
=0.
Predictor step: In the predictor step, a "provisional" value of
u
n+1
p | |
u | |
i |
p | |
u | |
i |
=
n | |
u | |
i |
-a
\Deltat | |
\Deltax |
\left(
n | |
u | |
i+1 |
-
n | |
u | |
i |
\right)
Corrector step: In the corrector step, the predicted value
p | |
u | |
i |
n+1 | |
u | |
i |
=
n+1/2 | |
u | |
i |
-a
\Deltat | |
2\Deltax |
\left(
p | |
u | |
i |
-
p | |
u | |
i-1 |
\right)
\Deltat/2
\Deltat
Replacing the
n+1/2 | |
u | |
i |
n+1/2 | |
u | |
i |
=
| ||||||||||||||||
2 |
n+1 | |
u | |
i |
=
| ||||||||||||||||
2 |
-a
\Deltat | |
2\Deltax |
\left(
p | |
u | |
i |
-
p | |
u | |
i-1 |
\right)
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.