Model Validation

Site: Saylor Academy
Course: BUS250: Introduction to Business Intelligence and Analytics
Book: Model Validation
Printed by: Guest user
Date: Wednesday, July 2, 2025, 5:28 PM

Description

1. Introducing Mathematical Modelling

Why mathematical modelling?

Before you start to make a mathematical model, of course you first want to know what a mathematical model is and then you want to consider carefully why you would build one. What are the alternatives? When is a mathematical model a good tool to help solve a problem?


Source: Marleen Keijzer, Dennis den Ouden-vander Horst, and Kees Vuik, https://ocw.tudelft.nl/courses/mathematical-modeling-basics/
Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.

1.1 Why mathematical modelling?


Why make a mathematical model?


1.2 Real life examples (with professionals)

What can you do with a mathematical model?

In this section we invite you to explore two advanced examples of mathematical models developed by professionals:

  • Example 1: Wind gusts around a building
  • Example 2: Sediment in an estuary

Although we'll be working with simpler models in this course, these examples give a clear idea of the potential of mathematical modelling.

Move on to the next pages to explore what can be done with mathematical modelling and start thinking about what you want to model in the future!


Example 1: Wind gusts around a building

One of the buildings of the Delft University of Technology is the EWI building. It houses the faculty of Electrical Engineering, Mathematics and Computer Science. The 1960s' building is slender and 22 stories high, as high as possible to allow for good antenna reception on the roof. Unfortunately, in stormy weather, there are very strong winds around the building. Below you see videos of this dangerous situation. Nowadays, when the wind is too strong, attendants tell bikers to dismount and walk.




Would planting more trees help to reduce the wind speeds?

Saša Kenjereš and Benjamin ter Kuile made a mathematical model that describes wind velocities over a city landscape. With that model, they simulated the wind gusts around the EWI building, with and without extra plants and trees. It turns out that extra vegetation does decrease the wind speeds significantly!


Note that this model is way more complicated than the model you are going to make in this course. The differential equations used here are partial differential equations instead of the ordinary differential equations of the course (partial differential equations contain partial derivatives instead of 'just' ordinary derivatives).  And also advanced numerical methods and computer graphics have been used to produce these results.


Example 2: Sediment in an estuary

Ems

Photo: Martina Nolte: Creative Commons CC-by-sa-3.0 de

The Ems is a river in the North of Germany and the Netherlands. The last 100 km of the Ems form an estuary: the transition zone between a river and the sea. The tide transports salty seawater into the estuary, where it mixes with the fresh water from the river.

The Ems runs through a beautiful green landscape. If you visit the estuary however, you will see that the water is oddly brown and muddy. You might also miss an abundance of fish and water plants. Why is it so muddy? Can something be done to remedy this?

Background

The water carries a lot of sediment: suspended particles of a few micrometer, consisting of clay, silt, sand and organic matter. The sediment is eroded from the river bed and transported by the water, but also settles again on the river bed.

The Ems is used intensively for shipping. Additionally, in Papenburg, a city 90 km inland, a ship yard builds large cruise ships that have to be conveyed to the sea. To accommodate all those ships, the Ems has been deepened many times. This unnatural depth and narrowness of the river has had a number of effects. Compared to 1980, the river now flows much faster, and the sea tide influences the water level in the river much more, resulting in a larger risk of flooding.

The sediment concentrations in the estuary have increased at an alarming speed as well, resulting in brown water, layers of silt on the river banks, decreased fish and plant populations, and high costs to keep the deeper channel dredged.


Would moving the weir help?

tidal weir is a low horizontal barrier across the width of a channel. It acts as a barrier for the salty sea water, but the fresh river water can flow over it. There is now a weir at 100 km inland. Would moving this weir to another position in the Ems help to reduce the sediment concentrations?

Measurements in the estuary

To predict the effects of a weir, you first have to measure the current water motion and the sediment concentrations. Ideally you want measurements at many spots in the estuary, at enough depths, and you also want to cover at least the whole tidal cycle of half a day. Either from a boat, or from a special buoy or pole, those measurements are very expensive, and never complete. Furthermore, you do not understand which mechanisms are essential and you can not investigate the impact of moving a weir.


Measurements in scale models

Real-life measurements can be complemented by measurements in a scale model: a large sand box, with a scaled freshwater inflow and a tidal wave (with a much shorter tidal cycle). A lot can be learned this way, but scaling such a long, shallow estuary is difficult, and scaling sediment particles is even more challenging.

Scale model at the Waterloopkundig Laboratorium in Delft ~1960.

Scale model at the Waterloopkundig Laboratorium in Delft ~1960.

Very recently a clever kind of scale model has been built in Utrecht: the Metronome: the sand box is tilted back and forth to simulate the tidal movement: The Metronome.

Mathematical modelling

Researchers have built mathematical models for the Ems as well. The models have to be carefully calibrated with measurements, but then they can be used to quickly simulate many scenarios: extreme weather or spring tides, but also simulations of what would happen with extra barriers or increased or decreased dredging.

With a so-called exploratory model, the effects were estimated of positioning a new tidal weir at different places in the estuary. The sediment concentrations were simulated with this model.

Simulations with an exploratory model

In the next video you see the results of these simulations of the sediment concentrations in the Ems. The horizontal axis shows the distance from approximately 50 km inland. The current weir lies near Herbrum, which is a city 100 km inland. Before you start the video, the position of the weir is at its current position. The results of the model reflect the current high concentrations of sediment in roughly the right place.

In the video you can see the effect of rebuilding the tidal barrier at a different place. It turns out that the position of the weir has a large effect on the quality of the water. Moving the barrier inland would help lower the sediment concentrations considerably. Unfortunately, moving the weir has, apart from the costs, more consequences, such as a higher risk of flooding and salty water that will penetrate deeper into fertile farmland. So this problem does not have an easy solution.


Other mathematical models

The exploratory model above gives good qualitative results for the Ems estuary. And now you think, well, I know of another river with sediment problems. Could this model be used for this river as well? Unfortunately no, probably not. The simplifications used to derive this model are reasonable for (some phenomena in) the Ems, but not for all other estuaries. For example, the estuary of the Elbe (in Germany) is so much wider with so much more detail in the channels that you can not used a width-averaged model.

An exploratory model is a relatively small model, in which some variables have been simplified. For example the geometry of this model estuary is not three-dimensional, but two-dimensional: the width of the river has been averaged out. Because of these simplifications, the results can be calculated quickly, and many options and parameters can be explored in a few hours. To calculate results also quantitatively with a reasonable precision, they have to be calculated with a so-called simulation model that does not simplify as much and incorporates many more details. Those programs however can take a few days for one simulation.

Conclusion: the sedimentation of tidal rivers is a complicated problem, and still there are many open questions. Real measurements, measurements in scale models, exploratory models and simulation models all have their advantages and disadvantages and compliment each other. Before building a new expensive barrier, one needs to know how much it will improve the water quality. Accurate mathematical models are essential to make those predictions.

Now that you have seen some examples of mathematical models, maybe you'd like to share your thoughts on the usefulness of mathematical modelling. You can participate in the discussion in the next section.

1.3 Modelling cycle (fish!)

Modelling cycle

In the video below you will learn about the process of mathematical modelling:  the modelling cycle.


The modelling cycle in this course

In the next video, you will see what problem we will use to explain the mathematical techniques. And you will get an overview of the modelling project in this course.


1.4 Population growth (Design a differential equation)

Problem definition

The problem that we are going to work on throughout this course is the following:


You want to breed rainbowfish to sell to pet stores. You start with a nice big aquarium and 30 fish, half of them male, half of them female. You want to predict the number of fish after a number of days, to see how many you can sell.


Mathematical model

In the previous section the question became:

Can you predict the number of rainbowfish in the aquarium after any number of days?

In the following video we are going to derive a mathematical model.
The first mathematical model



Calculation

In the previous section you have derived the differential equation and the intitial condition:

\(\dfrac{dP}{dt} = 0.7 P(t)\),

\(P(0) = 30\).

Is there a function P(t) that satisfies this initial value problem?


Validation

In the previous section you have seen that the solution of the differential equation

\(\dfrac{dP}{dt} = 0.7 P(t)\),

with the initial condition P(0)=30 is given by

\(P(t) = 30e^{0.7t}\).

Now you will validate this solution. Or in other words: does this solution represent a realistic solution to our problem?

1.5 Practice problem (Sunscreen lotion)

Problem

In this practice problem you will derive a differential equation and complete a first modelling cycle. But first, the problem!


A daycare center for two- to four-year-olds has acquired a new outside playground with grass, plants and a sandbox. Summer is coming and everyone is looking forward to let the children play outside. However, then the staff starts to worry about sun protection. Can they let the children play outside in the middle of the day? Is the sun screen they use sufficient?

First, information is collected:

  • Sunburn is considered a long term health risk, especially in small children.
  • In this country, without protection, lighter skinned children can be in the sun on a summers day between noon and 3 PM for only 10 minutes before their skin reddens and starts to get sunburned. Darker skinned children can stay out somewhat longer (20 to 30 minutes), but also not indefinitely before they develop sunburn as well.
  • The daycare center uses sunscreen lotion with a Sun Protection Factor (SPF) of 30.  This means that if the cream is applied in a thickness of 2 mg per square cm skin, you can stay out in the sun 30 times as long as without sunscreen.
  • Most people apply a much thinner sunscreen layer than 2 mg per square cm skin. Most people apply the suncream unevenly, and with an averagethickness of only 0.5 mg per square cm.

The daycare center instructs the staff to apply the suncream carefully, generously and often, on all exposed skin of all the children when they play outside. But, to be on the safe side, they estimate that their layers are only 0.5 mg per square cm skin.

They first want to know how this thinner layer affects the Sun Protection Factor of their suncream. And then, they want estimates for how long the children can safely play outside midday on a summers day.


Mathematical model

The problem is: when a sunscreen lotion of SPF 30, is applied in a layer of only 5μm instead of the calibration layer of 20 μm, how long can children stay out in the sun, when their skin would start to redden after 10 minutes without suncream?

Define the independent variable x in μm, as the depth in the suncream layer. x=0 is at the top side exposed to the sun, and x=20μm (or x=5μm ) is on the skin side of the suncream layer.

The intensity of the UV light is I(x), and I(0)=Ifull, the intensity that is such that unprotected, light skinned children can tolerate 10 minutes of it midday on a summers day.

In the next section, you will solve this differential equation for I(x): you will integrate the differential equation for I(x).

1.6 Removal (Phase line, Unstable equilibrium)

Problem

Back to the rainbowfish for a second modelling cycle.

Selling rainbowfish

In section 1.4 you encountered the problem of predicting the number of rainbowfish when you are breeding them.

A mathematical model was formulated in the form of a differential equation and a solution was found. However, this solution is unrealistic: the number of rainbowfish grows very large very quickly.

In this section we will add one sentence to the problem, in the hope that this will limit the growth. We have chosen the following addition:

The aquarium owner expects to sell 20 rainbowfish every day.

In the following pages of this section, you will incorporate this into the model, investigate the long-term solutions and validate them.


Mathematical model

is the number of rainbowfish in the aquarium, with t in days.

The birth rate of the fish is b=0.7 per day. The death rate is ignored: d≈0.

Now, 20 fish per day are sold.

In the exercises, you will derived the second mathematical model.


Calculation 1: Direction field & Equilibrium solution

In the previous section you have derived the differential equation

\(\dfrac{dP}{dt} = 0.7 P(t) - 20\),

still with the initial condition P(0)=30.

Can you estimate the number of rainbowfish P(t) over time?

To answer this question, we will first construct a direction field, which is a special type of graph. In the next video, you will see how you can do this. In the video also some solutions are estimated. See for yourself!

Direction fields


Calculation 2: Phase line & Stability

Now that you can find equilibrium solutions of a differential equation, it is time to investigate what kinds of equilibrium solutions can occur. In the next video you will learn about this.

Note: in the video an example of an unstable equilibrium point is given. However, the definition of an unstable equilibrium point is not in the video. That you can find below, in the text.

Phase line & Stability of equilibrium points



Validation

In the previous sections you have seen the differential equation

\(\dfrac{dP}{dt} = 0.7 P(t) - 20\),

the initial condition P(0)=30. The phase line for this differential equation is

 The phase line for this differential equation

and the direction field with some possible solutions is like this:

direction field with some possible solutions

Now you will validate these solutions. Do these solutions represent realistic solutions to our problem?


1.7 Practice problem (Mixing problem)

Problem

In this practice problem you derive a differential equation for yet another problem. This time, we do not specify the values of the different quantities, so the model and the results stay general. First, the problem.

Mixing problem


A small river, the Riverin, feeds into a lake and at the other side of the lake, the water flows through into another river, the Riverout, that flows on to the sea. The water of the Riverin contains a certain pollutant. A factory along the lake shore is planning to dump more of the same pollutant into the lake.

How much would the factory contribute to the pollution of the lake? Does it add only a few percent, or much more?

Quantifying time and amount of pollutant

The amount of pollution can be quantified in various ways: in kg, in mol, in a concentration of either…. Here we will simply choose kg. An appropriate unit for the time t is days. So we define:

t: time, with [t]= day.

Z(t): the total mass of the pollution dissolved in the lake, with [Z]= kg.

We assume that the water in the lake mixes well, so the pollution of the factory is distributed quickly over the lake. With quickly, we do not actually mean in a nano-second, but say, in half an hour or so: much quicker than in a day, so we can assume that the water in the lake is ideally mixed, i.e. on the timescale of the mathematical model, instantaniously.

First, we define the quantities for the river feeding into the lake, for the lake itself, and for the river flowing out of the lake:

  • \(Q_{in}\): the volumetic flow rate of \(River_{in}\) in \(\dfrac{m^3}{day}\).
  • \(C_{in}\): the concentration of pollution of \(River_{in}\) in \(\dfrac{kg}{m^3}\).
  • \(V_{lake}\): the volume of the lake in \(m^3\).
  • \(Q_{out}\): the volumetric flow rate of \(River_{out}\) in \(\dfrac{m^3}{day}\).
  • \(C_{out}\): the concentration of pollution of \(River_{out}\) in \(\dfrac{kg}{m^3}\).


Mathematical model

In the last section we formulated the mixing problem, and defined the relevant quantities. The question we want to answer is:

A factory wants to start discharging waste material in a lake. The river that feeds into the lake is already polluted somewhat. How much would this new contamination increase the pollution in the lake?

Mathematical model

We want to calculate Z, the mass of the pollutant in the lake. The relevant quantities are shown in the schematic above.

Which quantities are constant?

We are investigating the change caused by the factory, so the simplest case is then to take all other variables constant.

Take \(C_{in}\) constant. Assume also that \(Q_{in}\) and \(Q_{out}\) are equal and constant in time, so just name both \(Q: Q_{in} = Q_{out} = Q\). With equal rates in and out, \(V_{lake}\) is also constant (assuming that the volume of the discharge of the factory is negligible).

To see what influence the discharge of the factory has, we will assume that before t=0 the factory is not polluting so U = 0 for t < 0, and that U > 0 for t ≥ 0. So U does change in time. The nice thing is however, that our calculations start from t=0, so in calculations U can be a constant as well!

Without the discharge of the factory, the pollution concentration in the lake is (after some time) the same as the concentration in \(River_{in}: Z/V_{lake} = C_{in}\). So we will take that as the initial condition for Z: 

Define Δt as the length of a small time interval \([t, t + Δt]\).

Define ΔZ as the change in Z during that time interval, so

\(ΔZ = Z(t+Δt) - Z(t)\).

Construct the balance equation for ΔZ. The expression for ΔZ should have three terms: one for the inflow, one for the factory discharge and one for the outflow.

If you are done, check that the unit of each of the terms in the same as the unit for ΔZ.


Calculation

In the previous section, you have derived a mathematical model for Z(t), the mass of the pollutant in the lake:

\(\dfrac{dZ}{dt} = - \dfrac{Q}{V_{lake}} Z(t) + C_{in}Q + U\), \(Z(0) = C_{in} V_{lake}\),

where Q, Vlake, Cin and U all have constant values.

In this section, you will not solve the differential equation analytically (which is not that difficult, but it is beyond the scope of this course). You will also not approximate the solution numerically (as you will learn to do in the next section). In this section, you are going to investigate the solution just by using the phase line.


Validation

In this section, we first summarise the results up till now for you, then you answer the question of the factory, and finally, you will predict what happens when the situation is reversed.

For your convenience: a summary of the results up till now:

Validation

A factory wants to start discharging waste material in a lake. The river that feeds into the lake is already polluted somewhat. How much would this new contamination increase the pollution in the lake?

A mathematical model for Z(t), the mass of the pollutant in the lake, when the factory starts discharging a pollutant at t=0:

\(\dfrac{dZ}{dt} = - \dfrac{Q}{V_{lake}} Z(t) + C_{in}Q + U\), \(Z(0) = C_{in} V_{lake}\),

The solution Z(t) will increase to

\(Z_e=\lim _{t \rightarrow \infty} Z(t)=V_{\text {lake }}\left(C_{\text {in }}+\dfrac{U}{Q}\right)\).

To quantify the pollution increase caused by the factory, we define:

Ce: The concentration of the pollution in the lake for t→∞ when the factory discharges U kilo of pollutant per day.

C0: The final concentration of the pollution in the lake for t→∞ when the factory does not pollute the lake.

The waste of the factory increases the pollution concentration in the lake with the factor:  Ce/C0.

2. Bounded growth (Phase line, Stable equilibrium)

Welcome to Module 2

In Module 2 again the project runs parallel to the theory. This module is scheduled in two weeks, so when you have not completely finished module 1 yet, you can catch up first.

For the project, you and your teammate are going to collect information and specify your problem. On the next pages you’ll first get general instructions. Then you can go to the page of the problem you chose and get more information and specific instructions.

Parallel to working on the project you study more theory. In Section 2.1 we will show how bounded growth can be modelled. In Section 2.2 you get to practice with another model, a simple model for an epidemic. In Section 2.3 you will learn to approximate the solutions numerically, and you are going to simulate the solutions on a computer. In Section 2.4 you will practice doing the simulations with the epidemic model of Section 2.2. The last section contains a summary of Module 2.

But first, on the next page, the project. Welcome to Module 2!

2.1 Specify your problem

In real life, someone else would have a specific problem and would hire you as consultants to solve it. For example, a steel mill wants to improve the quality of their rolled steel, and asks your engineering company how the settings of the steel rolls can be optimized. So in real life, there is already a specific problem, and you only have to ask the right questions to formulate the problem, and you can start modelling.

In this course, you are primarily meant to learn and practice and experiment, so you will start differently. You do not start with a specific problem; you start with a simple, general model. You and your team mate have already chosen one of the four problem areas. Below you will find the basic model you are going to start with, the starting set of differential equations.

Then you and your partner choose a context that interests  you. For example, if you have chosen the interacting populations, you could choose antelopes and lions in the Serengeti. For this context you specify the model: find parameter values that are appropriate for antelopes and lions in the Serengeti. And if you cannot find them readily, make an educated guess. On the page with your model, you’ll find some specific starting questions.

In Module 3 you will be working with part of the model (one of the differential equations), and in module 4, you will simulate the whole model. Keep in the back of your mind that after that, you should come up with an interesting practical problem that can be solved with this model.

In the next video, you see how Hans and Esmeé collected information and specified their problem.



Project tasks for Module 2

Your tasks for the project are to choose a context for the model, to collect information on that context, and do some preliminary calculations. Communicate throughout with your teammate, and make the important choices together or decide who chooses what. Document everything in your joint logbook.

In the next pages you find the basic model of your choice and a list of specific tasks to specify your model.

2.1 Epidemic model

Model of an epidemic

Simulate the spread of an epidemic, for example of an illness. The basic model describes three populations: a susceptible population, an infected population, and a recovered population. Instead of a disease you could also model the spread of an idea or a rumour.


Epidemic model

The starting model for an epidemic is the so-called SIR model, where S stands for susceptible population, the people that can be infected. I is the already infected population, the people that are contagious, and R stands for the recovered population, people who are not contagious any more.

\( \dfrac{dS(t)}{dt} = - \beta S (t) I(t) \)

\(\dfrac{dI(t)}{dt} =\beta S (t) I(t) - \alpha I (t) \)

\(\dfrac{dR(t)}{dt} = \alpha I (t)\)

The parameters α and β you will have to choose appropriately.


Simplified epidemic model

In Module 2 (starting from question 7 below) and in Module 3, you use a simplified model: assume that α=0 and that R=0, so once infected, a person stays contagious for ever.


Tasks for the project in Module 2

  1. Decide on what disease (or other infectious item) you want to model and in what population.
  2. Collect quantitative information about intial values and about the spread of the disease. If you cannot find enough information, make educated guesses. Do not forget to write down where you found the information!
  3. Can you explain the meaning of the terms of the differential equations in words? What does a high or low value of α mean in words? And β?
  4. Consider the sum of the three populations: S+I+R. Show that in this mathematical model ddt(S+I+R)=0, so the sum is constant. What effects have been neglected in this model?
  5. Choose appropriate units for S, I and R. You can count in individuals, or in millions of people, etc.. Another convenient choice might be to work with fractions of the whole population, so the sum equals 1.
  6. After you have chosen units for S, I and R, derive the units for α and β from the differential equations.
  7. In Modules 2 and 3, start with α=0 and R(t)=0. Because then S+I=C, with C either the total population size, or C=1, you get the relation S=C−I. Substitute this expression into the differential equation for I. Show that this yields a differential equation in I only.
  8. With α=0 and R(t)=0, suppose you have found the solution I(t). How would you then calculate S(t)? Conclusion: for the simplified epidemic model you can just concentrate on the differential equation for I.
  9. With α=0 and R(t)=0, what are the equilibrium points for I? What can you say about their stability?
  10. Now, you can try to find an appropriate value for β, by considering what happens when you start with a small number of infected people. Some of you might have learned the techniques necessary to solve the differential equation for I analytically. Then you could use that analytical solution to find an appropriate value of β for your epidemic. You could also wait until you have programmed the simulations at the end of this module, and choose the value of β then.

Throughout, do communicate well with your teammate, so you make the different choices together. Document every result and decision in your logbook. That will help in the communication between you two, and when you are writing the report later on, you can find all your previous results easily.

After the pages for the other problems, you will find a page for questions you might have about the project.

2.1 Glider model

The trajectory of a glider

A simple model to describe the flight of a glider.


Glider model

The glider flies under an angle θ with the horizon and with (scalar) velocity V. The glider has no engine, and there are three forces working on the glider: gravity, drag and lift. In this simple model, both the drag and the lift are proportional to V2.

Glider model

In aerodynamics the socalled angle of attack is the angle between the wings and the oncoming airflow. We assume in this model that there is no wind and that the angle of attack is constant, so parameters cD and cL are assumed to have constant values.


Tasks for the project in Module 2

In this module,  try to get a feeling for this model. The questions below should help you with that.

  1. Choose a glider, and collect information about it: its mass, how many passengers besides the pilot, a typical speed. In particular, you want to know its lift-to-drag ratio. On a steady, unperturbed flight, that is the distance travelled by the glider divided by the height lost during that flight. Do not forget to write down where you found the information!
  2. You will soon see, that these two differential equations very crudely simplify the complicated aerodynamics of a glider. You might choose just to stay with this model, or you could go somewhat deeper. When you decide to do the latter, first assess what aspects of this model might be too crude. Later in Module 5, you could decide to improve the model.
  3. Is angle θ in this model calculated in degrees or in radians? Name the other quantities in the model, and decide on their units.
  4. Estimate an approximate value for θ when the glider flies in a long, stable flight.
  5. Describe what happens with the plane when θ goes from 0 via π4 to π2. And when θ grows further to 3π4, π, 3π2, 2π?
  6. Describe the physical meaning of the terms of the model in words and explain why some are included positively and some negatively. Derive both equations yourself by balancing the forces on the glider. This requires some knowledge of physics.
  7. Consider the differential equation for V. What happens with V when the speed is too high? What happens to V when the θ is too negative and aiming too steeply to the ground?
  8. Consider the differential equation for θ. What happens to the angle, when the speed becomes too low or the angle becomes too negative?
  9. Is there a minimum speed to take off from the ground?

Thoughout, do communicate well with your teammate, so you make the different choices together. Document every result and decision in your logbook. That will help in the communication between you two, and when you are writing the report later on, you can find all your previous results easily.

After the page for the fourth problem, you will find a page for questions you might have about the project.

2.1 Medicine model

Medicine concentrations

Simulate how the medicine in a pill someone takes enters into the bloodstream, does its work and is filtered out again.


Medicine model

Medication that you take orally, first dissolves in the contents of your stomach and intestines. Together those are called your gastrointestinal tract, or GItract for short. Then the medicine passes from the GI tract through the liver into the bloodstream. From the blood the medicine can reach the organ that needs it and do its work there. The kidney then clears the medicine out of the blood again. For many medicines it is best when the concentration in the blood is constant for a longer time.

In the following equations the quantities of medicine in the GI tract at time t are given by MGI(t) and Mblood(t) respectively. VGI is the volume of the contents in the GI tract and Vblood is the volume of blood of the person taking the medicine. In this model, the medicine passes from the GI tract to the blood (and from the blood to the kidney) by passive diffusion. So if the concentration of the medicine in the GI tract is higher than the concentration in the blood, the medicine diffuses with diffusion rate d1 from the GI tract to the blood.

\( \dfrac{dM_{GI}}{dt} = - d_1 (\dfrac{M_{GI}(t)}{V_{GI}} - \dfrac{M_{blood}(t)}{V_{blood}}) \)

\( \dfrac{dM_{blood}}{dt} = d_1 (C_{GI} - \dfrac{M_{blood}(t)}{V_{blood}}) - d_2 \dfrac{M_{blood}(t)}{V_{blood}} \)

The parameters d1 and d2 you will have to choose appropriately.

In Module 2 (starting from question 7 below) and in Module 3, use a simplified model. Take the concentration of the medicine in the stomach CGI=MGIV/GI constant. The model for Mblood(t) then reduces to:

\( \dfrac{dM_{blood}}{dt} = d_1 (C_{GI} - \dfrac{M_{blood}(t)}{V_{blood}}) - d_2 \dfrac{M_{blood}(t)}{V_{blood}} \)


Tasks for the project in Module 2
  1. Choose a medicine which you want to model. It should be a medicine that you take orally.
  2. Try to find quantitative information on the dosage. How long after you take a pill does it start working? How long does it keep working? How much of it are you advised to take? Do not forget to write down where you found the information!
  3. Describe in words the physical meaning of each quantity and term in the model.
  4. Decide on the unit you are going to use for MGI and Mblood: (m)mol or mg? Decide also on the unit for time t and the unit for volumes VGI and Vblood.
  5. Choose appropriate values for VGI and Vblood.
  6. Use the differential equations and determine the unit for diffusion constants d1 and d2.
  7. Now start with the simplified model: assume that MGI(t) is constant. Construct a phase line. Determine the equilibrium point. Is it stable?
  8. Some of you might have learned elsewhere how you can solve the simplified differential equation analytically. Then you could try to determine an appropriate value for d1 by first setting d2=0 and then adjusting d1 until solution is reasonable. You can also postpone determining d1 until you are able to simulate the solutions numerically.

Throughout, do communicate well with your teammate, so you make the different choices together. Document every result and decision in your logbook. That will help in the communication between you two, and when you are writing the report later on, you can find all your previous results easily.

The next page is for the questions you might have about the project.

2.1 Problem

Bounded growth for the rainbowfish

In the first module, we tried to predict the size of a rainbowfish population in an aquarium. Unfortunately, the growth of the population in the model of Section 1.4 was unbounded, and that of the improved model in Section 1.6 as well.

In this section, we will incorporate the limited capacity of the aquarium. When an aquarium gets crowded, the fish will lay fewer eggs, fewer young fish will survive and the fish may die earlier, so the growth of the population slows down. The problem statement is now:

An aquarium owner is breeding a population of rainbowfish. He starts with 30 rainbowfish and expects to sell 20 rainbowfish every day. The aquarium is large enough for a healthy population of 750. Predict the development of the size of the population.

Next, bounded growth will be incorporated into the model, you will investigate the long-term solutions and validate them.


Mathematical model

The number of rainbowfish in the aquarium will limit itself to the capacity of the aquarium of 750. In the next video this bounded growth is incorporated into the mathematical model.

Bounded growth in a mathematical model


In the next section you will investigate the solutions of the new differential equation

\(\dfrac{dP}{dt}=0.7(1-\dfrac{P(t)}{750}) \; P(t) - 20)\).


Calculation

In the mathematical model for the number of fish in the aquarium, the growth factor is now bounded:

\( \dfrac{dP}{dt}=0.7(1-\dfrac{P}{750}) - 20) \),

with the initial condition P(0)=30.

In the next exercises, you are going to calculate whether the resulting population stays bounded as well.


Validation

The initial value problem describing the fish population with bounded growth is:

\( \dfrac{dP}{dt}=0.7(1-\dfrac{P}{750}) - 20) \), \(P(0) = 30\).

The phase line of this autonomous differential equation is:

The phase line of this autonomous differential equation

2.1 Population model

Honey Bee Honeycomb Queen Cup CC0

Honey Bee Honeycomb Queen Cup CC0

Red-bearded Bee-eater by J.J. Harrison CC BY-SA 3.0

Red-bearded Bee-eater by J.J. Harrison CC BY-SA 3.0


Interacting populations

Choose your own set of populations: animals, plants, bacteria… and model the size of the populations. One population might feed on the other, as with the gouramis and rainbowfish we use in the course in Module 3, but you can also choose two populations that compete for the same resources, such as rabbits and deer competing for the same grass. A third option is that the two species benefit from each other such as cleaner fishes and groupers.


Population model

The number of members in the first population is called u(t) and the number of members of the second population v(t).

\( \dfrac{d u}{d t}=\alpha\left(1-\dfrac{u(t)}{k} \pm \dfrac{\beta v(t)}{1+\gamma u(t)}\right) u(t) \)

\(\dfrac{d v}{d t}=\left(-\delta \pm \dfrac{\beta u(t)}{1+\gamma u(t)}\right) v(t)\)

The parameters α,k,β,γ, and δ you will have to choose appropriately, as well as the signs some of the terms.


Simplified population model

After Module 3, you will let the populations interact, but for now, investigate the case of no interaction: β=0. For example, how does the antilope population grow when there are no lions, and how would the lion population fare, if there were no antilopes? So start with:

\( \dfrac{du}{d t}=\alpha (1-\dfrac{u(t)}{k}) u(t) \) and separately: \( \dfrac{d v}{d t}= - \delta v(t) \)

Tasks for the project in Module 2

  1. Decide on what two populations you want to model.
  2. Decide on a unit for the time t.
  3. Decide on units for u and v. If you are modelling the ants and anteaters in a large area, maybe units of 1000 ants are easier to work with. If it is grass and cows you are modelling, the unit of grass could be in kilograms per km2.
  4. With the units for u and v and the differential equations, you can determine the units for α, k, and δ.
  5. Try to find quantitative information on both populations. How large is a typical population, how old do they get, how many young do they raise, etc. If you cannot find that information, make an educated guess. Do not forget to write down where you found the information!
  6. Draw a phase line for v. Solve the equation for v analytically.
  7. Choose a value for δ such that the solution v(t) develops in a realistic way, not too fast, not too slow. You might not have enough information for a very precise value, so make a reasonable guess.
  8. Draw a phase line for u. Which of the equilibrium points are stable? Sketch also a direction field.
  9. Set the value of k to an appropriate value, such that the equilibrium values for u are appropriate. Again, you might not have enough information, so make a guess.
  10. You can try to give α a value, by considering the growth of the u‘s for a very small population, like we did for the rainbowfish. Some of you may have learned elsewhere the techniques to solve the differential equation for u analytically, and then you can use the analytical solution to adjust the value of α to fit your population u. You can also wait until the end of this module, when you will be able to approximate the solutions numerically.

Throughout, do communicate well with your teammate, so you make the different choices together. Document every result and decision in your logbook. That will help in the communication between you two, and when you are writing the report later on, you can find all your previous results easily.

After the pages for the other problems, you will find a page for questions you might have about the project.

2.2 Practice problem (Flu!)

Problem

For this practice problem, you remember a story your favorite history teacher once told in class about a faraway island.

Flu on Ledom island

Ledom Island is inhabited by the native Htam. The island and its people was discovered in the 15th century by a group of 20 explorers. The explorers recorded that when they reached the island there were 980 Htam.

Unfortunately, the explorers all were sick with the flu when they arrived. They decided to stay for some time on the island and only to continue their travels after they had recovered.

The explorers infected the Htam people and all of them got the flu as well. In no time, the whole island was ill with the flu. Fortunately, no one died.

Problem statement

Now that you know a little about mathematical modelling, you want to impress your history teacher by building a mathematical model for the flu epidemic on Ledom Island. How could the number of sick people have grown from 20 to a full-blown epidemic?


Mathematical model

When the 20 sick explorers arrived, they infected the 980 Htam people on Ledom Island with the flu. You want to investigate how the resulting flu epidemic might have developed. So, now you construct a mathematical model. (Surprise!)

First define the variables:

t: the time in days after the arrival of the explorers in the 15th century.
F(t): the number of people infected with the flu.
X(t)=F(t)/1000: the fraction of the infected people relative to the entire population.

Just after the explorers arrived, 2 percent of the population on Ledom Island was sick with the flu, so X(0)=0.02.

In this model, we will assume that the flu epidemic spreads so quickly, that everyone has been infected before the first people get better again.


Calculation

The differential equation for the fraction of people X(t) on Ledom Island infected with the flu virus is

\(\dfrac{dX}{dt} = kX(t) (1-X(t))\),

where k is a positive parameter. The initial condition is X(0)=0.02.

2.3 Reaction time (Euler's Method)

Problem

Back to the rainbowfish for another modelling cycle. Now we want to know how long it takes to breed them. Do you have to invest years to grow a good-sized population, or can it be done in a few weeks?

In section 1 the number of rainbowfish in the aquarium was modelled with a limited growth rate. At last, the solution is plausible, also after an infinitely long time.

In this section we focus on answering the following question:

How long does it take for the rainbowfish population to get into its equilibrium state?

Do you have to invest years to grow a good-sized population, or is the business up and running in a few weeks?


Mathematical model

To recapitulate, the new problem is:

How long does it take for the rainbowfish population to get into its equilibrium state?

Earlier modelling cycles have resulted in the following information:

  • P(t) is the number of rainbowfish in the aquarium, with t in days.
  • We start with 30 fish. The unbounded birth rate of the fish is b=0.7 per day.
  • The death rate is ignored: d≈0.
  • The tank can sustain a population of  750 rainbowfish.
  • Each day 20 fish are sold.

The resulting initial value problem is:

\(\dfrac{dP}{dt} = 0.7 P (1 - \dfrac{P}{750} - 20\), \(P(0) = 30\).

The differential equation has two equilibrium solutions, namely an unstable one of approximately 29.75 and a stable one of approximately 720.25. The second one is relevant for the new problem.

How long does it take to reach that equilibrium? Mathematically, the answer is: "infinitely long" ;-). The nearer P gets to the equilibrium, the lower the value of the derivative (but it stays positive), so the growth will keep slowing down, never reaching zero growth, and P will never reach its equilibrium value.

Luckily, living fish come in units, so we rephrase the question:

How long does it take for the rainbowfish population to reach the last integer before the mathematical equilibrium?

This means that we want to find time teq such that P(teq)=720.

The direction field of P and some possible solutions are shown below.

The direction field of P and some possible solutions

As you can see, many solutions are possible, each of which reaches 720 at a different time. In an exercise of § 2.1 you have estimated the value of teq by imagining one of the solution curves. As you can see, it is rather easy to guess how quickly P rises in the middle. It is much more difficult to guess how long the beginning and the end phase take.

On the following pages, you will learn a method to approximate the solutions in a computer simulation, and then you can estimate much more precisely how long everything will take.


Calculation (Euler's method)

The differential equation for the rainbowfish that we have now, could still be solved by hand. It would give you the analytical solution, which is exact. However, we are not doing that in this course, as we want to focus on the modelling, and not on analytical solution methods. We also do not want to limit our models to equations that can be solved analytically.

So, we will approximate the solutions of the differential equation with a numerical method, and we choose Euler's method. In the next video, this method is explained.

Euler's method



Calculation (with Python)

Python program for Euler's Method

In the previous section Euler's Method was introduced, and now you can approximate the solution of a differential equation. Of course calculations by hand are inefficient. The method is very suitable to implement in a computer program: much faster and probably more accurate. So in this section, you will use Python to simulate the same solutions.

The basic code for Euler's method is:

# Program      : Euler's method
# Author       : MOOC team Mathematical Modelling Basics
# Created      : April, 2017

import numpy as np
import matplotlib.pyplot as plt

print("Solution for dP/dt = 0.7*P")	# in Python 2.7: use no brackets

# Initializations

Dt = 0.1                                # timestep Delta t
P_init = 10                             # initial population 
t_init = 0                              # initial time
t_end = 5                               # stopping time
n_steps = int(round((t_end-t_init)/Dt)) # total number of timesteps

t_arr = np.zeros(n_steps + 1)           # create an array of zeros for t
P_arr = np.zeros(n_steps + 1)           # create an array of zeros for P
t_arr[0] = t_init                       # add the initial P to the array
P_arr[0] = P_init                       # add the initial t to the array

# Euler's method

for i in range (1, n_steps + 1):
    P = P_arr[i-1]
    t = t_arr[i-1]
    dPdt = 0.7*P                        # calculate the derivative 
    P_arr[i] = P + Dt*dPdt              # calculate P on the next time step
    t_arr[i] = t + Dt                   # adding the new t-value to the list

# Plot the results

fig = plt.figure()                      # create figure
plt.plot(t_arr, P_arr, linewidth = 4)   # plot population vs. time

plt.title('dP/dt = 0.7P, P(0)=10', fontsize = 25)  
plt.xlabel('t (in days)', fontsize = 20)
plt.ylabel('P(t)', fontsize = 20)

plt.xticks(fontsize = 15)
plt.yticks(fontsize = 15)
plt.grid(True)                          # show grid 
plt.axis([0, 5, 0, 200])                # define the axes
plt.show()                              # show the plot
# save the figure as .jpg
fig.savefig('Rainbowfish.jpg', dpi=fig.dpi, bbox_inches = "tight")


Run it, and see what it does!

Basic_Euler.py: header and initialisations

# Program      : Euler's Method
# Author       : MOOC team Mathematical Modelling Basics
# Created      : April, 2017

import numpy as np
import matplotlib.pyplot as plt

print("Solution for dP/dt = 0.7*P")

Dt = 0.1         # timestep Delta t  
P_init = 10      # initial population
t_init = 0       # initial time
t_end = 5        # stopping time
n_steps = int(round((t_end-t_init)/Dt)) # total number of timesteps

P_arr = np.zeros(n_steps + 1)   # create an array of zeros for P
t_arr = np.zeros(n_steps + 1)   # create an array of zeros for t
t_arr[0] = t_init               # add the initial t to the array
P_arr[0] = P_init               # add the initial P to the array

Basic_Euler.py: Iterations Euler's Method

for i in range (1, n_steps + 1):
    P = P_arr[i-1]
    t = t_arr[i-1]
    dPdt = 0.7*P              # calculate the derivative
    P_arr[i] = P + Dt*dPdt    # calculate P on the next time step
    t_arr[i] = t + Dt         # adding the new t-value to the list

Basic_Euler.py: Plotting the results

fig = plt.figure()                      # create figure
plt.plot(t_arr, P_arr, linewidth = 4)   # plot population vs. time

plt.title('dP/dt = 0.7P, P(0)=10', fontsize = 25)
plt.xlabel('t (in days)', fontsize = 20)
plt.ylabel('P(t)', fontsize = 20)

plt.xticks(fontsize = 15)
plt.yticks(fontsize = 15)
plt.grid(True)                          # show grid
plt.axis([0, 5, 0, 200])                # define the axes
plt.show()                              # show the plot
# save the figure as .jpg
fig.savefig('Rainbowfish.jpg', dpi=fig.dpi, bbox_inches = "tight")

As you have seen in the previous section, a large time step of 7 days leads to results that are not valid for the rainbowfish population. In the next video you will see what happens when the stepsize is reduced.

Euler's method


2.3 Calculation (accuracy)

Now you have working code, it is time to investigate the stepsize further.

In the next figure you can see the approximate solutions for Δt=1, Δt=12 and Δt=14 day. As you can see the graphs of the biggest two stepsizes differ more than the graphs of the two smallest stepsizes. This behavior is called numerical convergence: The smaller you take Δt, the better your approximation becomes and it will look more and more like the exact solution.

Calculation (accuracy)

In the figure you can also see that the largest differences in the value of P occur around 13 days:

In the figure you can also see that the largest differences in the value of P occur around 13 days:

So when you want to know the number of fish at 13 days, the stepsize is very important. The difference between Δt=1 day and Δt=0.5 day is more than 112 fish! And between the two smaller stepsizes, the difference is still more than 81 fish. So the results clearly change a lot, when the stepsize is halved.


Error of an approximation with Euler's method

We will not give any theoretical background here for the estimation of the error of a result with Euler's method. That would go too far for this course. So, without any proof:

For differential equation \(\dfrac{dy}{dt} = f(t, y (t))\) (and an initial condition), the exact solution at a specific time t is y(t). With Euler's method and step-sizes Δt and 2Δt, that exact solution can be approximated by wΔt and w2Δt, respectively. Than EΔt, the error in wΔt, can estimated as the difference between wΔt and w2Δt:

\( E_{Δt} = y(t) - w_{Δt} \approx w _{Δt} - w_{2Δt} \).

So an estimate of the error in the result with Δt=0.5 is 281.64−169.24=112.40 fish. And an estimate of the error in the result for Δt=0.25 is 81.45 fish.


Validation

In the previous section you have found an answer to the problem

Find teq such that P(teq)=720, where

\( \left\{\begin{aligned}\dfrac{dP}{dt} & =0.7P\;(1-\dfrac{P}{750}) - 20, \\P(0) & =30\end{aligned}\right. \).

which turned out to be teq=24.63. You did this by using Euler's Method with Δt=132.

We can now state that for our problem, the rainbowfish population is close to the equilibrium size within 25 days.

2.4 Practice problem (Flu!)

Problem

Flu on Ledom island

In the previous section  you encountered the Htam people on Ledom Island:

Ledom Island is inhabited by the native Htam. The island and its people was discovered in the 15th century by a group of 20 explorers. The explorers recorded that when they reached the island there were 980 Htam.

Unfortunately, the explorers all were sick with the flu when they arrived. They decided to stay for some time on the island and only to continue their travels after they'd have recovered.

The explorers infected the Htam people and all of them got the flu as well. In no time, the whole island was ill with the flu. Fortunately, no one died.

Some years ago, a group of modern-day explorers went to Ledom Island, and found evidence of the flu epidemic recorded on the wall of a cave deep in the forest. Translated from the language Relue, this text read:

Twenty days after the foreigners arrived, already 730 Htami have fallen ill to this strange sickness.


Mathematical model

In Section 2.2 you derived the differential equation for the fraction of people X(t) on Ledom Island infected with the flu virus

\(\dfrac{dX}{dt} = kX (t) (1 - X(t))\),

with the initial condition

X(0)=0.02.

Unfortunately, the parameter k  was at that time unknown. However, because of the text in the cave you can now find a value for k!

Calculation

In the previous section you formulated a new problem:

Find a value for k such that

\(\left\{\begin{aligned}
\frac{d X}{d t} & =k X(1-X), \\
X(0) & =0.02, \\
X(20) & =0.75
\end{aligned}\right.\)

To solve this problem, you are going to use Euler's Method. Make a new copy of Basic_Euler_program.py and adapt it for this problem. First, we have to find an appropriate stepsize.


Validation

In this section you have found that the model dX/dt=kX(1−X) with k=0.25 can describe the two historical datapoints in this story: X(0)=0.02and X(20)=0.75.

So now you can tell your teacher that you have a model for the epidemic. The red lines in the graph indicate X(11)≈0.25 and X(20)=0.75. You could summarize this epidemic by saying that it probably had three phases of approximately 10 days each. The first and the third phases were relatively slow: a quarter of the people got infected. The second phase was fast: half of the population got infected.

Validation

In searching for the right value for k, you have experienced the sensitivity of the results to parameter k. You could also consider the reverse: what happens with your k-value, when one of the two datapoints used is a little off, for example because of a measurement error. A model fitted to just two datapoints is probably not very robust in that sense. On the next page, we would like you to think further about what you could do when you have more datapoints.