Presentation is loading. Please wait.

Presentation is loading. Please wait.

2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian.

Similar presentations


Presentation on theme: "2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian."— Presentation transcript:

1 2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian Yu

2 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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

3 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 3 Lesson 3 - Contents  Differential Equations  Dynamical Systems  Pendulum  Lorenz attractor  Lotka-Volterra equations  Epidemics: Kermack-McKendrick model  Exercises

4 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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)

5 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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.

6 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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:

7 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 7 Pendulum: MATLAB code

8 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 8 Set time step

9 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 9 Set constants

10 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 10 Set starting point of pendulum

11 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 11 Time loop: Simulate the pendulum

12 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 12 Perform 1 st order Euler’s method

13 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 13 Plot pendulum

14 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 14 Set limits of window

15 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 15 Make a 10 ms pause

16 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 16 Pendulum: Executing MATLAB code

17 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 17 Lorenz attractor  The Lorenz attractor defines a 3-dimensional trajectory by the differential equations:  σ, r, b are parameters.

18 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 18 Lorenz attractor: MATLAB code

19 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 19 Set time step

20 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 20 Set number of iterations

21 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 21 Set initial values

22 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 22 Set parameters

23 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 23 Solve the Lorenz-attractor equations

24 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 24 Compute gradient

25 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 25 Perform 1 st order Euler’s method

26 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 26 Update time

27 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 27 Plot the results

28 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 28 Animation

29 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 29

30 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch Food chain 30

31 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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

32 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 32 Lotka-Volterra equations  The Lotka-Volterra equations describe the interaction between two species, prey vs. predators, e.g. rabbits vs. foxes.

33 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 33 Lotka-Volterra equations  The Lotka-Volterra equations describe the interaction between two species, prey vs. predators, e.g. rabbits vs. foxes.

34 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch Epidemics 34 Source: Balcan, et al. 2009

35 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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.

36 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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.

37 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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

38 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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

39 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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

40 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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: www.soms.ethz.ch/matlab (Download only possible with Firefox!)

41 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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

42 2010-03-08 A. Johansson & W. Yu / andersj@ethz.ch yuwen@ethz.ch 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.


Download ppt "2010-03-08 851-0585-04L – Modelling and Simulating Social Systems with MATLAB © ETH Zürich | Lesson 3 – Dynamical Systems Anders Johansson and Wenjian."

Similar presentations


Ads by Google