# Error Analysis

### Assignment :

Finish HW4 and start HW5.

The material linked from this page, and the contents of the associated lecture provide a beginning to understanding the errors associated with the use of discrete approximations to differential equations.  This will give you a concrete understanding of what people mean by "truncation error" and "order of accuracy" for a discrete approximation.  Although the mathematics can get ugly, the steps in this process are fairly simple to remember.

Basic analysis of the error associated with a finite volume or finite difference method is relatively easy if you understand a Taylor series expansion, and have a tool like Mathematica, Maple, or Mathcad to do the tedious work for you.  Start by graphing all of the discrete points in space and time at which you will use (or generate) information.  For an explicit method it might look something like:
`      |n+1   |         *  n   |     *   *   *      |______________________           i-1  i  i+1`
The most central of the points used is located at time level "n" and volume number "i", so we declare the equation to be evaluated there, and look at everything else in terms of values obtained at that point.  This is done via Taylor series expansions about that point.  One example of this type analysis is in some work by Tony Hirt, which provides further insight into the stability of first order upwind methods.  However, the primary reason to remember Hirt's analysis is not simply error, but as a quantitative way to compare the numerical diffusion in a code like TRACE to the actual turbulent diffusion processes present in a system.  What you will find is that for mesh sizes and time steps standardly used in reactor safety analysis, numerical diffusion is significantly larger than turbulent diffusion.  Another example of error analysis can be found in the section on "Truncation Error" in this conduction equation example.

I have provided some sample Mathematica commands to do a simple error analysis on a semi-implicit mass equation.  If you want to use this as a method of error analysis, open the file under Mathematica and type the Enter key with the Shift held down to evaluate the commands.  In the final set of results you will see three terms that can be interpreted as the non-conservative differential form of the mass equation.  Everything else is error.  Note that the lowest powers of time step size and mesh length define the order of accuracy of the method.  In this case the method is first order accurate in space and time.

### So What ?

Order of accuracy tells you how much  improvement to expect if you are close to a "good" answer and want to make it better.  If my method is first order accurate in space, and I  double the number of volumes in my system by cutting every existing volume in half, I can expect my mesh induced error to drop by a factor of two.  If my method is second order accurate in space, and I split all volumes, I can expect the mesh error to drop by a factor of 4.  Similar arguments hold for accuracy in time. Be aware that the effective order of accuracy of a method determined from Richardson extrapolation incorporates effects of higher order terms in the Taylor series if the mesh is too large, and effects from boundary conditions.  TRACE for example has a second order difference approximation to the conduction equation, but incorporates a first order approximation to the convective boundary conditions.  This generally results in an effective order of accuracy that is less than 2.

You need to be aware that higher order accuracy is not without drawbacks.  If you are propagating a wave like we did in the second exercise, a basic higher order method will tend to undershoot the answer just before the correct wave front position and overshoot just behind the wave.  This link is a simple density wave, calculated with a time step equal to a tenth of the material Courant limit.  Methods piloted in addition to first order upwind are either 2nd (Leith, QUICK) or 3rd (QUICKEST) order accurate in space.  Fortunately, the problem can be mitigated.  If you learn that you're running a code with a higher order method (order > 1), and you expect waves of some sort in your calculation (slugs of liquid qualify), then make sure that the code has a "flux limiter" available and engaged.  Generally flux limiters will reduce the local spatial accuracy to first order.

Remember that codes advertising higher order methods, don't always live up to the claims.

# Back to List of Lectures / Home

Maintained by John Mahaffy : jhm@psu.edu