Oliver Rübenkönig, Jan G. Korvink

Mathematica provides a unique capability for interactive learning. The possibility to combine program code and explanations in an interactive environment is well suited for teaching. The Chair of Microsystem Simulation at the University of Freiburg has developed a wide range of interactive simulation tutorials that have been distributed under the GNU Free Documentation License (FDL). The tutorials cover finite difference, finite volume and finite element methods, and multigrid and iterative solvers. Topics such as sparse matrices and derivatives recovery are also explained. Students are led through the topics assuming little or no prior knowledge. We found that the students gained a good understanding by experimenting with available parameters. In a subsequent step the tutorials are used for verifying other program code.

Introduction

The IMTEK Mathematica Supplement (IMS) is a downloadable, open source add-on package for Mathematica [1]. The supplement provides several hundred functions in about 40 packages. Additionally, about 10 tutorials from the computer simulation area and one concise introductory Mathematica programming language tutorial are available, and parts from a computer science book [2] have been ported from Scheme.

We have chosen the GNU FDL so that the documentation is easily adapted for the needs of students or teachers. Also, the motivation for students to send suggestions and improvements for the tutorials is greater than when they are confronted with a (noninteractive) closed source form. Furthermore, we put great effort in motivating students to make suggestions on how to improve the tutorials. We try to exploit the fact that students themselves can explain teaching material to each other fairly well.

In this article we describe our experiences using Mathematica as a teaching tool for our subject. We also discuss the goals and philosophy of our teaching, as well as the different media we have tried for teaching: notebooks in lectures and as tutorials, video recordings, and HTML documents.

About Teaching

“Tell me and I’ll forget;
show me and I may remember;
involve me and I’ll understand.”
(Chinese Proverb)

First, we have to determine our primary and secondary teaching goals. Primary goals are concerned with complying with the syllabus. Secondary goals are concerned with conveying to students the skills they can use outside of the classroom.

The primary goals would be that students understand the subject in such a manner and depth that they can work in the area and have learned how to learn more.

The secondary goal would be that students know how to use a programming language to solve their engineering problems—and not only in the simulation domain. Being able to program forces students to think clearly about their ideas, understand how to convert their problems in the programming language, and in the process, or better yet due to this process, they inevitably have to think about the “details.” Since programming languages are not forgiving from a syntax point of view, the formulation must be clear.

Sometimes it is necessary to move in the wrong direction—only to then change course and thus have a learning experience. Students learn by making errors and errors give the reason for making changes.

There are several different teaching media.

  1. Notebooks
  2. HTML
  3. Video

Notebooks can be used in a lecture, a lab, or at home. HTML and video are mainly used at home.

Usually the difference between lectures and tutorials is that a lecture is much more abstract than a tutorial. Additionally, when using an interactive computer algebra system (CAS) for presentation, the degree of interactivity is much less in a lecture than in a tutorial. The student has to work through a tutorial. In a lecture a student has a much more passive role. Also the difference in tone, which is much more relaxed for tutorials, helps students lose their fear of the abstract formulation of scientific facts.

Tutorials

Our tutorials come from several different areas.

  1. Simulation            (notebook, HTML, some video)
  2. Technical Mechanics         (notebook)
  3. Mathematica (notebook, HTML, some video)

Video Lectures and Formats

We have also tried different video lecture types, which have several advantages.

  1. Students can stop the lecture, think about the new material, and move on.
  2. Students can learn when it is convenient for them to learn; they are not tied to any schedule.
  3. Students can practice prior to exams. They can listen and watch the lecture over and over until they feel comfortable with the material.

Two different recording mechanisms, available at the University of Freiburg, were used to create the video lectures—first the Camtasia [3] suite and second LECTURNITY [4]. In both cases the presenter’s screen and voice are recorded via a Tablet PC, and the presenter is not visible on the recording. In this article we have focused on screen recording mechanisms. Other formats, not considered here, capture the entire lecture as done at MIT [5] or Berkeley [6].

With the Camtasia suite a TSCC codec is used, which can be converted into AVI and RealMedia. As an example of such a screen recording, you can download the RealMedia tutorial, which is in German, from Simulation1_02.rm (47.6MB). The primary advantage is that the RealMedia file format is widely distributed. Secondly, it has a slightly better quality than the AVI format considered here.

A second possibility is provided by the authoring tool LECTURNITY. Again, a recording Tablet PC is used. A Java player is presently available; however, it does not work well under Linux.

Notebook Tutorials for the Simulation Curriculum

For students it is necessary to compute simple examples by hand. At some stage, however, much more insight may be gained by computing something that could not be done before; it would be optimal for students to visualize complex real-world examples. Such a success is very motivating. Secondly, we find the visualization of time-dependant problems by an animation is equally well suited for didactical purposes.

  1. Derivatives Recovery
  2. Finite Difference
  3. Finite Volume
  4. Finite Elements
  5. Iterative Solvers
  6. Multigrid Methods
  7. Norms in Analysis
  8. Partial Differential Equations
  9. Shape Functions
  10. Sparse Matrices

The simulation tutorials comprise about 180 printed pages. We try not to introduce too many new ideas in too short a time. We start from the simplest possible example and show students the limitations of the code developed so far in order to motivate a next step that fixes the previous problem.

Notebook Tutorial Examples

Next, we present two extracts from the IMS tutorial section—first the finite difference tutorial and second the finite volume tutorial.

Parabolic Finite Differences

Derivation

We look at the equation

(1)

The right-hand side at time step can be approximated by the central difference

(2)

The left-hand side can be approximated by the forward difference. With being the current time step and the next time slice

(3)

Putting things together we get

(4)

We rearrange the equation to express explicitly the next time step

(5)

Initial conditions set the function values for the whole simulation domain for time step . Via the previous scheme we advance the initial conditions to time step . Proceeding in this manner, we compute all unknown values.

Rearranging and setting we get

(6)

This is called an explicit scheme since the value for the next time step is computed explicitly from the previous time steps.

Implementation

Let us implement this explicit scheme and play around with it. As before, for the spatial discretization, we use the variable . For the time discretization, we use the time step .

The initial conditions at the time step are set to 20°C. In other words, for any spatial point we initially have a temperature of 20°C.

A noteworthy point is that we use dynamic programming to enhance the speed at which Mathematica will find the solution. Dynamic programming means that each computed value will be stored and thus remembered for later execution.

Next, we specify Dirichlet boundary conditions: both ends of the rod at spatial coordinate and are set to 100°C. In other words, for any time step the boundary has fixed values.

The updating rule for the interior values

The solution is now found using an outer product, where we only want to see a fraction of the time steps.

We map the function that plots a time slice over some selected time steps (i.e., time step 1, 11, 21, 31), which are stored in the solution vector.

Gluing all the time slices together we obtain the following plot.

When employing dynamic programming, we need to remove the information stored during a computation. This saves memory.

The Question of Stability

Let us say we want a higher resolution in the spatial direction and less computational points in the time direction. We proceed exactly as before, however, setting an increase in the number of grid points and decreasing the time step.

The s has now increased.

We set the initial and boundary conditions.

The update rule

This produces a disastrous result. The algorithm became unstable by increasing the number of grid points and decreasing the number of time steps . In this case, for all values of the algorithm is stable. Try it. This poses a serious problem: in order for the algorithm to stay stable, the time steps have to be increased to satisfy . For 21 grid points that implies time steps.

The first question is where does this behavior come from? The second question is can we circumvent the instability problem related with explicit schemes? The first question will be answered now. The second one is dealt with in the next section, where so-called implicit schemes will emerge—a whole new class of parabolic equation solvers.

Heat Equation with 1D Finite Volume

The Problem (Derivation)

We investigate the numerical approximation to the heat conduction equation that describes the heat distribution in the wall of a pipe. This example is inspired by [7].

Imagine a pipe with a thick wall (Figure 1). Inside this pipe we have a hot liquid. Outside at radius it is cold with . In the inside at radius we have a prescribed heat flux into the pipe’s wall.

Figure 1. A pipe for transporting hot liquid in cold surroundings.

Figure 2 shows a cross-section of the pipe with the inner radius and the outer radius , the boundary conditions, and a thick line along which we compute the solution. It is assumed that this line could be any line from the inside to the outside; the solution of the PDE will not change.

Figure 2. A cross-section of the pipe with the inner radius and the outer radius , the boundary conditions, and a thick line along which the distribution of heat in the wall of the pipe is computed.

The governing PDE is

(7)

where is the inhomogeneity or load of the PDE.

The analytical solution for this is

For the numerical solution of the PDE we replace with

(8)
Meshing

We first mesh the 1D domain with equally spaced intervals of length ; the so-called control volume extends from to (Figure 3).

Figure 3. The one-dimensional simulation domain with two red boundary points. The blue points represent additional internal points at which the heat distribution is computed. The points are equally spaced with a length of . Each internal point is surrounded by a control volume. The control volume of the internal points is also of size . The control volume of the boundary points is of size .

Interior Points

Here we just suppose changes linearly between any two adjacent discretized points

(9)

Now we can apply finite difference type discretized derivatives

(10)
(11)
Boundary Conditions

The Dirichlet boundary condition:

(12)

For the Neumann boundary condition

(13)
Building the Matrix (Implementation)

Physical properties

Empty global matrix and empty global load vector

Neumann boundary conditions as in equation (13)

Dirichlet boundary conditions as in equation (12)

Assembly of the global system as in the right-hand side of equation (11)

Assembly of the global load as in the left-hand side of equation (11)

Solution

Solution of the linear system of equations

Analytical versus Numerical Solution

We prepare the data for postprocessing. The coordinates of the mesh points are joined with the result at these points. Next, an analytical solution to the problem at hand is found.

This result is informative if we need the quantitative distribution of the heat in the pipe. If we are interested in the quality of the solution, the plot is not very informative. In this case we wish to know how close the numerical solution is to the analytical solution. To this end we evaluate the analytical function at the mesh points.

We can then compute the norm.

A better graphical representation is the difference of the analytical solution at the mesh points to the computed result. The error of the numerical solution compared to the analytical solution

Experiment with a different number of grid points.

Conclusion

In a teaching environment that frequently needs to show parts of program code, we find that using Mathematica is of great use—as long as students have control over the speed of the presented material. When a notebook or video is presented, which is full of program code, students may not gain much from the presentation—more than one line of code is often tedious for students. Depending on the level of fluency in the language itself, students face two problems: understanding the contents of the lecture and understanding the program code. We have had good experience with supplementing lectures with tutorials, which may paraphrase the content of the lecture. Tutorials provide a convenient way in which the student can set his own pace of learning, possibly at home. It always fascinates students to see live graphics, and this motivation factor should not be underestimated.

Acknowledgment

The authors would like to thank Kai Kratt for investigating exporting the notebook tutorials to HTML and fine-tuning the interactive web tutorials. This project was funded by [8].

References

[1] O. Rübenkönig and J. Korvink, IMTEK Mathematica Supplement (IMS), (2002-2005) www.imtek.uni-freiburg.de/simulation/mathematica/IMSweb.
[2] H. Abelson and G. Sussman, Structure and Interpretation of Computer Programs, 2nd ed., Cambridge, Massachusetts: The MIT Press, 1996.
[3] Camtasia Studio, Version 1.0, Okemos, MI: TechSmith Corporation (Feb 2, 2006) www.techsmith.com/products/studio/default.asp.
[4] LECTURNITY, Version Player 1.6.0, Saarbrücken, Germany: imc AG (Feb 2, 2006)
www.im-c.de/lecturnity/en/index.htm.
[5] MIT OpenCourseWare (MIT OCW), Cambridge: Massachusetts Institute of Technology (Jan 1, 2007) www.ocw.mit.edu/index.html.
[6] webcast.berkeley, Berkeley: University of California (Jan 1, 2007) webcast.berkeley.edu.
[7] D. R. J. Owen and E. Hinton, A Simple Guide to Finite Elements, Swansea, UK: Pineridge Press, 1980.
[8] eLectures, Freiburg, Germany: Fakultät für Angewandte Wissenschaften, University of Freiburg (Oct 26, 2005) electures.informatik.uni-freiburg.de:8484/catalog/project/ss2005.jsp.
O. Rübenkönig, and J. G. Korvink, “Interactive Learning,” The Mathematica Journal, 2012. dx.doi.org/10.3888/tmj.10.3-9.

About the Authors

Oliver Rübenkönig is a Ph.D. student at the University of Freiburg, Germany. Rübenkönig received his Diploma in Microsystem Engineering in 2001. He uses Mathematica extensively in research and teaching and has developed many student exercises and some courses.

Jan G. Korvink obtained his M.Sc. in computational mechanics from the University of Cape Town in 1987 and his Ph.D. in applied computer science from the ETH Zurich in 1993. After his graduate studies, Korvink joined the Physical Electronics Laboratory of the ETH Zurich, where he established and led the Modeling Group. He then moved to the Albert Ludwig University in Freiburg, Germany, where he holds a Chair position in microsystem technology and runs the Laboratory for Microsystem Simulation. Currently, Korvink is dean of the Faculty of Applied Science. He has written more than 130 journal and conference papers in the area of microsystem technology and co-edits the review journal Applied Micro and Nanosystems. His research interests include the modeling, simulation, and low-cost fabrication of microsystems.

Oliver Rübenkönig
Jan G. Korvink

Lab for Simulation, Department of Microsystems Engineering (IMTEK)
University of Freiburg
Germany
ruebenko@imtek.uni-freiburg.de