Download presentation

Presentation is loading. Please wait.

Published bySilas Harrod Modified over 2 years ago

1
Intro to modeling April 22 2011

2
Part of the course: Introduction to biological modeling 1.Intro to modeling 2.Intro to biological modeling (Floor) 3.Modeling oscillators (Rob)

3
Today’s goal: Learn how to solve ODE models in MATLAB

4
Example: Heating of water

5
Set the model dT w /dt = Rate of change of temperature of the water [°C s -1 ] T w = Temperature of the water [°C] T h = Temperature of the heater [°C] T a = Temperature of the air [°C] c 1 = Heat transfer coefficient 1 [s -1 ] c 2 = Heat transfer coefficent 2 [s -1 ] We will measure T w

6
Initial parameter values From scientific literature. Decide which one(s) will be estimated from the experimental data.

7
Fit the experimental data with the model

8
P1 = 1 P2 = 1 SS = 350 P1 = 1.1 P2 = 3 SS = 55 P1 = 1.13 P2 = 4 SS = 12 Manual estimation of the parameters

9
How precise are the estimated parameters? We can look at the sum of squares surface:

10
Why modeling? Simulate the system Estimate parameters Control the system

11
Menu The math behind modeling (45 min) Break (5 min) A few words about programming (10 min) Hands-on tutorial (45 min) What’s next (5 min)

12
What’s a model?

13
Types of models Deterministic Non-deterministic Probabilistic Discrete Continuous (in time) (in variable values)

14
Grey box How do we build a model? White box: First principles Black box: Measurements

15
Modeling techniques in biology Boolean Bayesian Differential Equations – Ordinary (ODE) – Partial (PDE) – Delay (DDE) …

16
ODEs Rate of change One independent variable One or more dependent variables Order

17
True or false? TRUE Only valid when x is the independent variable.

18
Are these ODEs? YES Independent Dependent; First order YES Independent Dependent; Third order

19
How to solve ODEs? General Solution Particular Solution

20
How to solve ODEs? Analytical or Numerical solution – Euler – ode45

21
Analytical solution Solve:

22
Numerical solution The basis is Taylor’s series expansion:

23
Taylor’s series example 1

24
Taylor’s series example 2

25
Euler’s method Under which condition is this valid?

26
Euler’s method Solution in multiple time-steps. Iterate: Solution in one time-step:

27
Example # Time steps15 f(x)

28
What does it have to do with my ODE model? Model Initial value Step Time step

29
ode45 ODE solver in MATLAB Uses information from the fourth and fifth derivative How to use it: [t,x] = ode45(@function, time, x0, [], *) *You can pass whatever, for example the parameters (p) and/or the inputs (u) Mandatory. Always put in the same order. Put it here if more info will be passed.

30
What do we need to use ode45? i.Model ii.Parameter(s) values iii.Input(s) values iv.Independent variable (time) values = t o, t f and Δt v.Initial values of dependant variable(s)

31
Model Re-write in state-space form: 1.State variables(x): terms with derivative 2.Parameters(p): constants 3.Input(u): what‘s left

32
From paper to MATLAB Re-write model in state space form. Save the model as a MATLAB function. Write a script that calls ode45 and your model. Identify state variables, parameters, inputs. Define equations and parameter values. Define initial values, call functions, plot results.

33
Example: an irreversible reaction

37
Now the language details…

38
20 x0 = 300 0 time = 0.10.2…1

39
0.5 p = 0.02 Magic word: Function 20 x0 = 300 0 time = 0.10.2…1 dxdt = 3x11 t0t1t2 x1 x2 x3 t3… t10

40
20 x0 = 3000 time = 0.10.2…1 IN OUT dxdt = 11x3 x1x2x3 t0 t1 t2 t3 … t10 Summary: model function data Row vector Matrix

41
0 t = 0.10.2…1 x = 11x3 x1x2x3 t0 t1 t2 t3 … t10

42
Summary: script data 20 x0 = 3000 time = 0.10.2…1 IN OUT x = 11x3 x1x2x3 t0 t1 t2 t3 … t10 0 t = 0.10.2…1 Row vector Matrix Row vector

43
From paper to MATLAB Re-write model in state space form. Save the model as a MATLAB function. Write a script that calls ode45 and your model. Identify state variables, parameters, inputs. Define equations and parameter values. Define initial values, call functions, plot results.

44
Break

45
A few words about programming All programs run in a defined ‘vertical’ way. MATLAB is an interpreted language. Errors can be found at any time. Read the errors messages. Most errors are in manipulation of row/column vectors.

46
A few words about programming Shell/command line = type commands interactively Scripts (.m) = save commands Functions (.m) = define a command. Give same name to the function and the file. Variables – Any word/letter that stores data – They remain after the program ends Semicolon (;)

47
Hands-on Tutorial

48
Your turn! I. Biological system: Irreversible reaction (15 min)

49
Your turn! I. Physical system: Greenhouse temperature (30 min)

50
Homework III. Biological system: Bioreactor

51
What’s next Learn/Teach: Introduction to biological modeling (Floor) Modeling oscillators (Rob) Reproduce modeling by Danino et al. 2010: MATLAB 7.0 Team: Brendan, Floor, Rob, Dorett, Mariana,... May 6 th presentation

Similar presentations

Presentation is loading. Please wait....

OK

Ordinary Differential Equations

Ordinary Differential Equations

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on do's and don'ts of group discussion activities Ppt on chromosomes and genes Ppt on e-commerce websites Ppt on art of living Ppt on online shopping cart project in java Ppt on conservation of environment essays Ppt on panel discussion definition Ppt on history of atom timeline Ppt on non biodegradable waste management Ppt on economy of bangladesh