Numerical Simulation Basics: Accuracy and Model Validation for a Finite-difference Equation

Jim Boyle, Western Connecticut State University, Physics, Astronomy and Meteorology
Author Profile

Summary

This activity teaches students a few of the basic concepts for numerical simulation of physical systems by modeling the simple and well-known problem of free-fall. The recursion relation for the finite-difference scheme is derived from a Taylor Series expansion. Students program solutions in MATLAB, then investigate the accuracy of these solutions considering various time steps and both first order and second-order accurate schemes.


Learning Goals

1. Primary goal is to introduce students to the method used to convert a theoretical equation characterizing a physical process into a finite-difference equation which can be programmed to find a numerical solution,
2. Students learn that finite-difference methods are only approximate solutions and numerical (or truncation) errors exist,
3. Student learn that a proper mathematical analysis can be used to characterize the magnitude of the truncation error,
4. Students learn techniques to improve the accuracy of a numerical simulation solution,
5. Students learn that all numerical simulation models should, as far as possible, be validated against an exact theoretical solution, a closed form mathematical solution or an experimental result.

Context for Use

This activity is taught as part of the laboratory component for a junior-level physical oceanography course. Pre-requisites for this class include: calculus-based physics, introductory statistics and introductory computer science. Overall, the laboratory includes three modules: (1) introduction to scientific computer programming in MATLAB, (2) hands-on experiments in physical oceanography and (3) web-based activities associated with physical oceanography. Data processing, analysis and visualization using MATLAB are introduced in module one and reinforced in modules two and three.

This is the first activity in a set introducing students to rudimentary numerical simulation methods it is taught in association with textbook chapters on numerical models – it occurs in the last weeks of the course, so students have good basic programming skills. Other related activities include uniform and stretched grid generation. Other related assignments include: one dimensional temperature advection with diffusion, which has programming of open boundary conditions and investigates numerical stability criteria.

Description and Teaching Materials

This is the first activity in a set introducing students to rudimentary numerical simulation methods. Parts A and B are performed as a pre-laboratory assignment, Part C is performed during a 110-minute laboratory session. The pre-laboratory assignment must be submitted at the beginning of the laboratory session. Students work in pairs – as assigned by the instructor. Student have approximately 90 minutes to write a computer program as well as complete the assignment table and questions in Part C. However, the textbook: Essential MATLAB for Scientists and Engineers has a section (with example code) describing how to use MATLAB to investigate the problem of free fall. This information can be modified then used by the students.

The activity requires the College or University has a MATLAB site license, but otherwise is self-contained.


Student Assignment with Solutions (Acrobat (PDF) 343kB Oct12 23)
M-file Script (Matlab File 3kB Oct12 23)


Teaching Notes and Tips

Because this programming exercise is completed during one laboratory session, it is important to the instructor to circulate to give the students individual attention.

Assessment

For each MATLAB activity, students are given a list of Deliverables. Completion of these deliverables should ensure students meet the goals for the activity. The deliverables for the activity (Parts A, B, C) include submittal of:
1. hand-written answers to questions posed in handouts,
2. an M-file script,
3. creation of a two-panel figure (generated from the M-file), properly annotated with titles and axis labels.

Parts A, B, C and the two panel figure are manually graded, with scores based on points for each answer. The instructor has access to and runs the M-file script from each group of two students – this script must function properly.

References and Resources

Textbook: Essential MATLAB for Scientists and Engineers, Hahn and Valentine