L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian Yu
A. Johansson & W. Yu / 2 Projects Implementation of a model from the Social-Science literature in MATLAB. Carried out in pairs. The projects will be assigned next week: March 15, 2010
A. Johansson & W. Yu / 3 Lesson 3 - Contents Differential Equations Dynamical Systems Pendulum Lorenz attractor Lotka-Volterra equations Epidemics: Kermack-McKendrick model Exercises
A. Johansson & W. Yu / 4 Differential equations Solving differential equations numerically can be done by a number of schemes. The easiest way is by the 1 st order Euler’s Method: t x ΔtΔt x(t) x(t-Δt)
A. Johansson & W. Yu / 5 Dynamical systems A dynamical system is a mathematical description of the time dependence of a point in a space. A dynamical system is described by a set of linear/non-linear differential equations. Even though an analytical treatment of dynamical systems is often complicated, obtaining a numerical solution is straight forward.
A. Johansson & W. Yu / 6 Pendulum A pendulum is a simple dynamical system: L = length of pendulum (m) = angle of pendulum g = acceleration due to gravity (m/s 2 ) The motion is described by:
A. Johansson & W. Yu / 7 Pendulum: MATLAB code
A. Johansson & W. Yu / 8 Set time step
A. Johansson & W. Yu / 9 Set constants
A. Johansson & W. Yu / 10 Set starting point of pendulum
A. Johansson & W. Yu / 11 Time loop: Simulate the pendulum
A. Johansson & W. Yu / 12 Perform 1 st order Euler’s method
A. Johansson & W. Yu / 13 Plot pendulum
A. Johansson & W. Yu / 14 Set limits of window
A. Johansson & W. Yu / 15 Make a 10 ms pause
A. Johansson & W. Yu / 16 Pendulum: Executing MATLAB code
A. Johansson & W. Yu / 17 Lorenz attractor The Lorenz attractor defines a 3-dimensional trajectory by the differential equations: σ, r, b are parameters.
A. Johansson & W. Yu / 18 Lorenz attractor: MATLAB code
A. Johansson & W. Yu / 19 Set time step
A. Johansson & W. Yu / 20 Set number of iterations
A. Johansson & W. Yu / 21 Set initial values
A. Johansson & W. Yu / 22 Set parameters
A. Johansson & W. Yu / 23 Solve the Lorenz-attractor equations
A. Johansson & W. Yu / 24 Compute gradient
A. Johansson & W. Yu / 25 Perform 1 st order Euler’s method
A. Johansson & W. Yu / 26 Update time
A. Johansson & W. Yu / 27 Plot the results
A. Johansson & W. Yu / 28 Animation
A. Johansson & W. Yu / 29
A. Johansson & W. Yu / Food chain 30
A. Johansson & W. Yu / 31 Lotka-Volterra equations The Lotka-Volterra equations describe the interaction between two species, prey vs. predators, e.g. rabbits vs. foxes. x: number of prey y: number of predators α, β, γ, δ: parameters
A. Johansson & W. Yu / 32 Lotka-Volterra equations The Lotka-Volterra equations describe the interaction between two species, prey vs. predators, e.g. rabbits vs. foxes.
A. Johansson & W. Yu / 33 Lotka-Volterra equations The Lotka-Volterra equations describe the interaction between two species, prey vs. predators, e.g. rabbits vs. foxes.
A. Johansson & W. Yu / Epidemics 34 Source: Balcan, et al. 2009
A. Johansson & W. Yu / 35 SIR model A model for epidemics is the SIR model, which describes the interaction between Susceptible, Infected and Removed (immune) persons, for a given disease.
A. Johansson & W. Yu / 36 Kermack-McKendrick model of diseases like the plague and cholera. A popular SIR model is the Kermack-McKendrick model. The model was proposed for explaining the spreading The model assumes: A constant population size. A zero incubation period. The duration of infectivity is as long as the duration of the clinical disease.
A. Johansson & W. Yu / 37 Kermack-McKendrick model The Kermack-McKendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β : Infection rate γ : Immunity rate S I R β transmission γ recovery
A. Johansson & W. Yu / 38 Kermack-McKendrick model The Kermack-McKendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β : Infection rate γ : Immunity rate
A. Johansson & W. Yu / 39 Kermack-McKendrick model The Kermack-McKendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β : Infection rate γ : Immunity rate
A. Johansson & W. Yu / 40 Exercise 1 Implement and simulate the Kermack- McKendrick model in MATLAB. Use the starting values: S=I=500, R=0, β =0.0001, γ =0.01 Slides/exercises: (Download only possible with Firefox!)
A. Johansson & W. Yu / 41 Exercise 2 A key parameter for the Kermack-McKendrick model is the epidemiological threshold, β S/ γ. Plot the time evolution of the model and investigate the influence of the epidemiological threshold, in particular the cases: 1. β S/ γ < 1 2. β S/ γ > 1 Starting values: S=I=500, R=0, β =0.0001
A. Johansson & W. Yu / 42 Exercise 3 - optional Implement the Lotka-Volterra model and investigate the influence of the timestep, dt. How small must the timestep be in order for the 1 st order Eulter‘s method to give reasonable accuracy? Check in the MATLAB help how the functions ode23, ode45 etc, can be used for solving differential equations.