Motivation and Goals Modelling with ODEs 24.10.01 Motivation: Ordinary Differential Equations (ODEs) are very important in all branches of Science and Engineering ODEs form the basis for the simulation of almost all continuous phenomena Goals: To introduce ODEs To give some examples of how to build simple ODE models Introduction to Simulation WS01/02 - L 02 1/39 Graham Horton Introduction to Simulation WS01/02 - L 02 2/39 Graham Horton Continuous Processes Ordinary Differential Equations Continuous processes occur everywhere. Here, we are interested in cases with discrete variables Some examples: An object falling to the ground The motion of the planets orbiting the sun The current and voltage in an electrical circuit The level of alcohol in my blood on January 1st The populations of a predator and its prey (!) In almost all cases, the relationships between the variables are defined by an ODE An Ordinary Differential Equation (ODE) describes the rate of change of a quantity y as a function of its current value and the time t : dy = f ( y, t) In addition, we usually know the value of y(0): y ( 0) = y 0 Introduction to Simulation WS01/02 - L 02 3/39 Graham Horton Introduction to Simulation WS01/02 - L 02 4/39 Graham Horton
Initial Value Problems Example for an IVP Given an ordinary differential equation... dy =... and an initial condition... f ( y, t) Differential equation and initial condition: dy = 2t y(0) = 1... find y ( 0) = y y(t) 0 Solution: y( t) = t 2 + 1 Introduction to Simulation WS01/02 - L 02 5/39 Graham Horton Introduction to Simulation WS01/02 - L 02 6/39 Graham Horton Example for an IVP Example for an IVP Differential equation and initial condition: Solution: dy = λ(1 y) y(0) = 0 y( t) =1 e λt Differential equation and initial condition: Solution: dy = t e cos( t) y y(0) = 0 t y( t) = e sin( t) Introduction to Simulation WS01/02 - L 02 7/39 Graham Horton Introduction to Simulation WS01/02 - L 02 8/39 Graham Horton
Example for an IVP Solving ODEs A system of two differential equations and initial conditions: Solution: du = v, u(0) = 0, dv = u v(0) = 1 u ( t) = sin( t), v( t) = cos( t) We were able to solve all these examples analytically These were therefore special cases Usually, there is no analytic solution for systems of ODEs We are forced to use numerical methods to perform the integration The numerical integration of ODEs forms the most important part of continuous simulation We will look at this next week Introduction to Simulation WS01/02 - L 02 9/39 Graham Horton Introduction to Simulation WS01/02 - L 02 10/39 Graham Horton Balance Equations A Falling Object Most ODEs are balance equations A balance equation basically says: Consider dropping an object from a certain height We will develop a model for the object's location and speed Change = Increase - Decrease Example: ODE for the amount of water x in a tank: I l/s dx/ = I - O Variables: p(t) : distance fallen at time t. (Units [m]) v(t) : velocity of object at time t. (Units [m/s]) O l/s Introduction to Simulation WS01/02 - L 02 11/39 Graham Horton Introduction to Simulation WS01/02 - L 02 12/39 Graham Horton
Effect of Gravity A Falling Object The Earth exerts a force F on the object. (Units [N]) Let the mass of the object be m. (Units [kg]) The situation at time t: Newton's law (F = m a) states that Force = Mass Acceleration Therefore, a = F /m p meters Parameters: a : acceleration due to gravity. (Units [m/s/s]) F Newtons Mass m v meters per second Introduction to Simulation WS01/02 - L 02 13/39 Graham Horton Introduction to Simulation WS01/02 - L 02 14/39 Graham Horton The Model Simulation Results Acceleration is the rate of change of velocity: dv/ = g = 9,81 [m/s/s] Simulation results: Velocity is the rate of change of position: dp/ = v At time t =0 we define: p(0) = 0 v(0) = 0 Introduction to Simulation WS01/02 - L 02 15/39 Graham Horton Introduction to Simulation WS01/02 - L 02 16/39 Graham Horton
Wind Resistance Wind Resistance We have assumed that the object is falling in a vacuum Now let us consider wind resistance The standard physical model states: The force due to wind resistance is proportional to the square of the velocity Result for a = 0.0033 (skydiver): We obtain dv/ = g - a v 2 for some constant a with units [1/m] Terminal velocity 56 m/s Introduction to Simulation WS01/02 - L 02 17/39 Graham Horton Introduction to Simulation WS01/02 - L 02 18/39 Graham Horton Population Biology Population Biology Consider the population x of some animal species Assume for the moment... No deaths Infinite space and food supply The birth rate is proportional to the current population: dx/ = a x 30 Now let us add deaths to the model The death rate is also proportional to the current population This gives dx/ = a x - b x = (a - b) x If a > b, we still have exponential population growth We can just set c = a - b to obtain dx/ = c x The solution of this ODE is x = e ax We have exponential population growth 25 20 15 10 5 0 0 0.5 1 1.5 Introduction to Simulation WS01/02 - L 02 19/39 Graham Horton Introduction to Simulation WS01/02 - L 02 20/39 Graham Horton
The Logistic Equation The Logistic Equation Now assume a limited food supply As the population increases, food per capita goes down This leads to decreasing birth and increasing death rates This is called crowding or competition Simulated solutions for c = 0.5, 1.0 and 2.0: One solution is to use the logistic equation dx/ = c x - d x 2 We will achieve steady state when x = c / d This is an assumption which works well in practice Introduction to Simulation WS01/02 - L 02 21/39 Graham Horton Introduction to Simulation WS01/02 - L 02 22/39 Graham Horton Predator-Prey Models Lotka-Volterra Equations Consider an area in which hares and foxes live Denote the population of hares by h and of foxes by f Observations show: Foxes must eat hares in order to survive Hares have an unlimited supply of food Without foxes, hares multiply according to dh/ = a h Without hares to eat, foxes die according to df / = -b f The probability of a meeting is proportional to h f The increase in foxes is d h f The rate at which hares are eaten is c h f The resulting equations are: dh df = a h c h f = b f + d h f These are the famous Lotka-Volterra equations Introduction to Simulation WS01/02 - L 02 23/39 Graham Horton Introduction to Simulation WS01/02 - L 02 24/39 Graham Horton
Lotka-Volterra Equations Lotka-Volterra Equations Simulation results for parameters State space representation: Plot h (t ) against f (t ) h (0) = 400 f (0) = 37 a = 0.175 b = 0.125 c = d = 0.001 0 < t < 150 Introduction to Simulation WS01/02 - L 02 25/39 Graham Horton Introduction to Simulation WS01/02 - L 02 26/39 Graham Horton Lynxes and Hares Another Example From the records of the Hudson Bay Company Number of lynx and hare skins purchased 1845-1935 Petri-dish populations of the bacteria Paramecium Aurelia (predator) Saccharomices Exiguns (prey) Introduction to Simulation WS01/02 - L 02 27/39 Graham Horton Introduction to Simulation WS01/02 - L 02 28/39 Graham Horton
The Gypsy Moth The Gypsy Moth The Gypsy moth is a pest Population of Gypsy moths in the Engadin 1954-1976: Its larvae eats the leaves of the larch This defoliates and often kills the tree Population 350 300 250 200 150 100 50 0 1954 1959 1964 1969 1974 Year Introduction to Simulation WS01/02 - L 02 29/39 Graham Horton Introduction to Simulation WS01/02 - L 02 30/39 Graham Horton The Gypsy Moth Chaos This looks very much like half of the Lotka-Volterra simulation result: Population 350 300 250 200 150 100 50 0 1954 1959 1964 1969 1974 Year Have we proved that the Gypsy moth is part of a predator-prey relationship? Chaotic behaviour is a (relatively) new discovery in ODEs Discovered by Edward Lorenz in the early 60s Three equations from meteorology Discovered by accident "Chaos" in physics means... "Sensitive dependence on initial conditions" The "Butterfly Effect" dx = a ( y x) dy = x z + b x y dz = x y c z Introduction to Simulation WS01/02 - L 02 31/39 Graham Horton Introduction to Simulation WS01/02 - L 02 32/39 Graham Horton
Types of Behaviour Lorenz's Equations What can the long-term behaviour of a system look like? Solution in the time domain: Explosion: One or more values becomes infinite Steady-state / stationary Nothing changes Periodic Values repeat indefinitely Chaotic Finite, non-stationary, non-periodic Introduction to Simulation WS01/02 - L 02 33/39 Graham Horton Introduction to Simulation WS01/02 - L 02 34/39 Graham Horton The Lorenz Attractor The Lorenz Attractor Simulation result ("Lorenz attractor"): Simulation result in the x-y, x-z and y-z planes: Introduction to Simulation WS01/02 - L 02 35/39 Graham Horton Introduction to Simulation WS01/02 - L 02 36/39 Graham Horton
Three Species Three Species Now let us build a new three-species predator-prey model: Species z preys on species x and y There is crowding between x and y The three-species result in a non-periodic 3-D state space: dx 2 = x 0.001x 0.001xy 0.01xz dy 2 = y 0.0015xy 0.001y 0.001yz dz = z + 0.005xz + 0.0005yz Introduction to Simulation WS01/02 - L 02 37/39 Graham Horton Introduction to Simulation WS01/02 - L 02 38/39 Graham Horton The Last Slide An ODE is an equation of the form dy/ = f (y,t) Almost all continuous processes are described by ODEs These are thus very important in simulation There is a 2+2 SWS course "Kontinuierliche Simulation" ODEs are usually a type of balance equation: Change = Increase - Decrease Next week: How to solve ODEs Introduction to Simulation WS01/02 - L 02 39/39 Graham Horton