102 lab5

Notes on Lab #5

Comparing Numerical Simulation Methods

For this lab we will return to building our own simple models, and we will compare three sorts of results: (1) analytical computation (correct value); (2) simulation in Vensim using Euler’s Method; (3) simulation in Vensim using Runge-Kutta 4. We will do this for two different models. (The lab is a variant on Excerices 6.2.1,3 and 6.4.1,3.)

Model 1

First, launch Vensim and use it to model the system dP/dt = 0.10P with P0 = 100. Have t going from 0 through 20, using Euler’s method, with Δt = 2.

Then launch Excel, and use it to compute the analytical solution to the equation for the corresponding times (0, 2, …, 18, 20).

Returning to Vensim, use the Control Panel to create a vertical table of the population over time, as you did in a previous lab. Next, use the copy-to-clipboard button in the table window to copy the table into Excel, making sure that the rows line up properly. Then use Excel to compute the relative error at each time. Then do a plot in Excel of the relative error over time for Euler. Now repeat the process with RK4 as your integration type. For the RK4 plot, do one plot with the Y axis limits as they first appear; then do another plot with the limits set to the same as the Euler-method plot, so you can see the dramatic difference between Euler and RK4.

Finally, Create a new spreadsheet (or new section of your current spreadsheet) showing the same four-way comparison (analytical, Euler error, RK4 error, RK4 error with same axes as Euler) for Δt = 0.25. Looking at the RK4 error plot on its own Y axes (zero to a very tiny amount), do you see the same orderly increase as with the Euler plot? If not, can you speculate about what might be going on?

Model 2

Now repeat this procedure for new model: dP/dt = 0.5(1-P/1000)P with P0 = 20. Do you remember what sort of model this is? The analytical solution is on page 209 (Exercise 3). Comment briefly on what you see, including the difference between the two models.

Turnin

For this lab, you only have to turn in the PDF writeup with the plots and commentary, not the model or Excel files.