Upcoming SlideShare
Loading in …5
×

# Intro to modelling_wur

625 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

No Downloads
Views
Total views
625
On SlideShare
0
From Embeds
0
Number of Embeds
189
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
• Lumped parameters
• I’ll give an example on using experimental data.
• White box: Derive a model from first principles. If not possible then we have to do system identification: Black box: No prior model available. Grey box: you understand the physics of your system: you can specify an explicit mathematical model but you don’t know the parameters values
• An ODE describes the rate of change of a dependant variable with respect to an independent variable. The unknown element is a function. The information we have is on its derivatives.
• An analytical method gives the solution as a mathematical formula, which is an advantage. From this we can gain insight in the behavior and the properties of the solution, and with a numerical solution (that gives the function as a table) this is not the case
• Write it on the blackboard
• Show in blackboard how it would be if passing individual variables.
• Interested?
• ### Intro to modelling_wur

1. 1. Intro to modeling April 22 2011
2. 2. Part of the course: Introduction to biological modeling <ul><li>Intro to modeling </li></ul><ul><li>Intro to biological modeling (Floor) </li></ul><ul><li>Modeling oscillators (Rob) </li></ul>
3. 3. Today’s goal: Learn how to solve ODE models in MATLAB
4. 4. Example: Heating of water
5. 5. Set the model <ul><li>dT w /dt = Rate of change of temperature of the water [°C s -1 ] </li></ul><ul><li>T w = Temperature of the water [°C] </li></ul><ul><li>T h = Temperature of the heater [°C] </li></ul><ul><li>T a = Temperature of the air [°C] </li></ul><ul><li>c 1 = Heat transfer coefficient 1 [s -1 ] </li></ul><ul><li>c 2 = Heat transfer coefficent 2 [s -1 ] </li></ul><ul><li>We will measure T w </li></ul>
6. 6. Initial parameter values <ul><li>From scientific literature. </li></ul><ul><li>Decide which one(s) will be estimated from the experimental data. </li></ul>
7. 7. Fit the experimental data with the model
8. 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. 9. How precise are the estimated parameters? <ul><li>We can look at the sum of squares surface: </li></ul>
10. 10. Why modeling? <ul><li>Simulate the system </li></ul><ul><li>Estimate parameters </li></ul><ul><li>Control the system </li></ul>
11. 11. Menu <ul><li>The math behind modeling (45 min) </li></ul><ul><li>Break (5 min) </li></ul><ul><li>A few words about programming (10 min) </li></ul><ul><li>Hands-on tutorial (45 min) </li></ul><ul><li>What’s next (5 min) </li></ul>
12. 12. What’s a model?
13. 13. Types of models <ul><li>Deterministic </li></ul><ul><li>Non-deterministic </li></ul><ul><li>Probabilistic </li></ul><ul><li>Discrete </li></ul><ul><li>Continuous </li></ul>(in time) (in variable values)
14. 14. How do we build a model? Grey box White box: First principles Black box: Measurements
15. 15. Modeling techniques in biology <ul><li>Boolean </li></ul><ul><li>Bayesian </li></ul><ul><li>Differential Equations </li></ul><ul><ul><li>Ordinary (ODE) </li></ul></ul><ul><ul><li>Partial (PDE) </li></ul></ul><ul><ul><li>Delay (DDE) </li></ul></ul><ul><li>… </li></ul>
16. 16. ODEs <ul><li>Rate of change </li></ul>One independent variable One or more dependent variables Order
17. 17. True or false? TRUE Only valid when x is the independent variable.
18. 18. Are these ODEs? YES YES Independent Dependent; Third order Independent Dependent; First order
19. 19. How to solve ODEs? General Solution Particular Solution
20. 20. How to solve ODEs? <ul><li>Analytical or </li></ul><ul><li>Numerical solution </li></ul><ul><ul><li>Euler </li></ul></ul><ul><ul><li>ode45 </li></ul></ul>
21. 21. Analytical solution Solve:
22. 22. Numerical solution <ul><li>The basis is Taylor’s series expansion: </li></ul>
23. 23. Taylor’s series example 1
24. 24. Taylor’s series example 2
25. 25. Euler’s method Under which condition is this valid?
26. 26. Euler’s method Solution in multiple time-steps. Iterate: Solution in one time-step:
27. 27. Example # Time steps 1 5 f(x)
28. 28. What does it have to do with my ODE model? Model Initial value Step Time step
29. 29. ode45 <ul><li>ODE solver in MATLAB </li></ul><ul><li>Uses information from the fourth and fifth derivative </li></ul><ul><li>How to use it: </li></ul><ul><li>[t,x] = ode45(@function, time, x0, [] , * ) </li></ul><ul><li>*You can pass whatever, for example the parameters (p) and/or the inputs (u) </li></ul>Mandatory. Always put in the same order. Put it here if more info will be passed.
30. 30. What do we need to use ode45? <ul><li>Model </li></ul><ul><li>Parameter(s) values </li></ul><ul><li>Input(s) values </li></ul><ul><li>Independent variable (time) values = t o , t f and Δ t </li></ul><ul><li>Initial values of dependant variable(s) </li></ul>
31. 31. Model <ul><li>Re-write in state-space form : </li></ul><ul><li>State variables(x): terms with derivative </li></ul><ul><li>Parameters(p): constants </li></ul><ul><li>Input(u): what‘s left </li></ul>
32. 32. From paper to MATLAB Identify state variables, parameters, inputs. Define equations and parameter values. Define initial values, call functions, plot results.
33. 33. Example: an irreversible reaction
34. 37. Now the language details…
35. 38. 20 x0 = 30 0 0 time = 0.1 0.2 … 1
36. 39. Magic word: Function 0.5 p = 0.02 20 x0 = 30 0 0 time = 0.1 0.2 … 1 dxdt = 3x11 t0 t1 t2 x1 x2 x3 t3 … t10
37. 40. Summary: model function data IN OUT Row vector Row vector Matrix 20 x0 = 30 0 0 time = 0.1 0.2 … 1 dxdt = 11x3 x1 x2 x3 t0 t1 t2 t3 … t10
38. 41. 0 t = 0.1 0.2 … 1 x = 11x3 x1 x2 x3 t0 t1 t2 t3 … t10
39. 42. Summary: script data IN OUT Row vector Row vector Matrix Row vector 20 x0 = 30 0 0 time = 0.1 0.2 … 1 x = 11x3 x1 x2 x3 t0 t1 t2 t3 … t10 0 t = 0.1 0.2 … 1
40. 43. From paper to MATLAB Identify state variables, parameters, inputs. Define equations and parameter values. Define initial values, call functions, plot results.
41. 44. Break
42. 45. A few words about programming <ul><li>All programs run in a defined ‘vertical’ way. </li></ul><ul><li>MATLAB is an interpreted language. </li></ul><ul><ul><li>Errors can be found at any time. </li></ul></ul><ul><li>Read the errors messages. </li></ul><ul><ul><li>Most errors are in manipulation of row/column vectors. </li></ul></ul>
43. 46. A few words about programming <ul><li>Shell/command line = type commands interactively </li></ul><ul><li>Scripts (.m) = save commands </li></ul><ul><li>Functions (.m) = define a command. Give same name to the function and the file. </li></ul><ul><li>Variables </li></ul><ul><ul><li>Any word/letter that stores data </li></ul></ul><ul><ul><li>They remain after the program ends </li></ul></ul><ul><li>Semicolon ( ; ) </li></ul>
44. 47. Hands-on Tutorial
45. 48. Your turn! <ul><li>I. Biological system: Irreversible reaction (15 min) </li></ul>
46. 49. Your turn! <ul><li>I. Physical system: Greenhouse temperature (30 min) </li></ul>
47. 50. Homework <ul><li>III. Biological system: Bioreactor </li></ul>
48. 51. What’s next <ul><li>Learn/Teach: </li></ul><ul><li>Introduction to biological modeling (Floor) </li></ul><ul><li>Modeling oscillators (Rob) </li></ul><ul><li>Reproduce modeling by Danino et al. 2010: </li></ul><ul><li>MATLAB 7.0 </li></ul><ul><li>Team: Brendan, Floor, Rob, Dorett, Mariana, ... </li></ul><ul><li>May 6 th presentation </li></ul>