Presentation is loading. Please wait.

# Intro to modeling April 22 2011. Part of the course: Introduction to biological modeling 1.Intro to modeling 2.Intro to biological modeling (Floor) 3.Modeling.

## Presentation on theme: "Intro to modeling April 22 2011. Part of the course: Introduction to biological modeling 1.Intro to modeling 2.Intro to biological modeling (Floor) 3.Modeling."— Presentation transcript:

Intro to modeling April 22 2011

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

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

Example: Heating of water

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

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

Fit the experimental data with the model

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

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

Why modeling? Simulate the system Estimate parameters Control the system

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)

What’s a model?

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

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

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

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

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

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

How to solve ODEs? General Solution Particular Solution

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

Analytical solution Solve:

Numerical solution The basis is Taylor’s series expansion:

Taylor’s series example 1

Taylor’s series example 2

Euler’s method Under which condition is this valid?

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

Example # Time steps15 f(x)

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

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.

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)

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

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.

Example: an irreversible reaction

Now the language details…

20 x0 = 300 0 time = 0.10.2…1

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

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

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

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

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.

Break

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.

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 (;)

Hands-on Tutorial

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

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

Homework III. Biological system: Bioreactor

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

Download ppt "Intro to modeling April 22 2011. Part of the course: Introduction to biological modeling 1.Intro to modeling 2.Intro to biological modeling (Floor) 3.Modeling."

Similar presentations

Ads by Google