MacCormack method explained

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

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

on a grid with spacing

\Deltax

at grid cell

i

, the MacCormack method uses a "predictor step" and a "corrector step", given below[3]
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}

Linear Example

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

  

\partialu
\partialt

+a

\partialu
\partialx

=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

at time level

n+1

(denoted by
p
u
i
) is estimated as follows
p
u
i

=

n
u
i

-a

\Deltat
\Deltax

\left(

n
u
i+1

-

n
u
i

\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

p
u
i
is corrected according to the equation
n+1
u
i

=

n+1/2
u
i

-a

\Deltat
2\Deltax

\left(

p
u
i

-

p
u
i-1

\right)

Note that the corrector step uses backward finite difference approximations for spatial derivative. The time-step used in the corrector step is

\Deltat/2

in contrast to the

\Deltat

used in the predictor step.

Replacing the

n+1/2
u
i
term by the temporal average
n+1/2
u
i

=

n
u+
p
u
i
i
2

to obtain the corrector step as
n+1
u
i

=

n
u+
p
u
i
i
2

-a

\Deltat
2\Deltax

\left(

p
u
i

-

p
u
i-1

\right)

Some remarks

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

Notes and References

  1. MacCormack, R. W., The Effect of viscosity in hypervelocity impact cratering, AIAA Paper, 69-354 (1969).
  2. [John D. Anderson|Anderson, J. D., Jr.]
  3. https://www.math.umd.edu/~mariakc/burgers.pdf#page=13
  4. Tannehill, J. C., Anderson, D. A., and Pletcher, R. H., Computational Fluid Mechanics and Heat Transfer, 2nd ed., Taylor & Francis (1997).