Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dynamic Systems: Ordinary Differential Equations

Similar presentations


Presentation on theme: "Dynamic Systems: Ordinary Differential Equations"— Presentation transcript:

1 Dynamic Systems: Ordinary Differential Equations
BME383J

2 Objectives Model the dynamics of bio systems with ODE
Analytical solutions (brief) Numerical solutions Accuracy and stability of numerical solutions

3 Pharmacokinetics Administration: Oral Intravenous injection
Absorption: dissolution rate Blood flow Permeation/ionization Drug affinity Distribution: Compartments Metabolism: Organ/Cell/Enzyme Elimination: Kidney

4 Ion transport through Membrane
Hodgkin-Huxley model of Na+ conduction g: conductance, V: potential difference, I: current; n gates open for K+; m and h gates for Na+

5 Classification of ODE Order n (dny/dtn) Linear or nonlinear
Nonlinear: powers of y or the derivatives, or products of y with the derivatives. Homogeneous or nonhomogeneous f(y, dny)=R(t) Second-order, linear, nonhomogeneous

6 What are these? First order, nonlinear, nonhomogeneous.
3rd order, linear, homo 3rd, nonlinear, nonhomo. 2nd order, nonlinear.

7 Boundary conditions initial-value problems boundary-value problems
the values of the y and/or dy are all known at the initial (or final) value of t boundary-value problems y and/or dy are known at more than one point of t. E.g. y(t=0) and dy/dt(t=final) are known: two-point boundary value problem. “Numerical methods for chemical engineers with MATLAB applications”, Constantinides and Mostoufi (1999)

8 Canonical Form ODE a set of n simultaneous first-order ordinary differential equations Matrix Notation When the initial conditions are given at a common point, to Solution of above eq:

9 Converting high order to 1st order ODE
First derivative of z First derivative of y1 Second derivative of z First derivative of y2 First derivative of yn

10 z=y1 y5=e-t

11 Matrix Formula Y’=AY

12 Analytical Solutions Separable variables Example: y=__________________
Ln y = lambda t + C Y= C exp (lambda t) Example: y=__________________

13 Matlab dsolve YY=dsolve('Dy=A*y')

14 Analytical solution Equations with homogeneous coefficients and same degree Replace one variable to separate variables Dt/t+vdv/(v-1)=0 W=lambert(x) is the solution to W*exp(W)=x

15 Analytical Solution Exact solution

16 Analytical Solution Exact solution

17 Analytical Solution Integrating factor Homework Compare with dsolve

18 Analytical Solution Linear homogeneous eq. with constant coeff.
Characteristic equation of D If the roots, λ are real If the roots are complex

19 Analytical Solution Show that Compare with desolve
1*D^3-9*D^2+26*D-24=0 p=[ ] roots{p} y=dsolve('D3y-9*D2y+26*Dy-24*y=0')

20 Numerical Solution of Nonlinear ODE
y at different t?

21 Euler Methods Forward marching formula

22 Mixing Forward and Backward Euler Method for Better Accuracy
Backward Taylor series Implicit or backward Euler method: unknown First apply the forward/explicit Euler to predict Forward or backward is determined by the derivative at I or i+1… O(h2) has opposite sign so they cancel! Then use the backward Euler to correct: Euler predictor-corrector method: O(h3)

23 Numerical Integration of ODE Runge-Kutta

24 Numerical Integration of ODE Runge-Kutta

25 Runge-Kutta Second order Fourth order Third order

26 Alternative: Verlet Integration
Modeling trajectories of particles after Newton’s equation of motion

27 Verlet Integration Order of magnitude more accurate than straight Taylor expansion

28 Verlet Variations

29 RK4 conserves the dxdp better
VV conserves the energy better

30 MATLAB ODE A stiff equation is a differential equation for which certain numerical methods for solving the equation are unstable, unless the step size is taken to be extremely small. ODE45 in matlab is good for nonstiff ODE23s for stiff What to use

31 ODE numerical solver in MATLAB

32 Example For a solution for and initial conditions: y1(0)=0, y2(0)=3
yprime.m function dydt=yprime(t,y) % dydt=[y(2) -0.2*y(2)-sin(y(1))]; %Or write the elements explicitly: %dydt(1,1)=y(2); dydt(2,1)=-0.2*y(2)-sin(y(1)); [t, [0 40], [0 3]); For a solution for and initial conditions: y1(0)=0, y2(0)=3 [t, y]=ode45(____ , ____ , ____)

33 ODE45 with a free parameter a
The [] in the list of arguments for yprime is an empty placeholder where certain options can be input to ode45.

34 Example of Enzyme Catalysis
Mass Balance Assuming first order reaction w.r.t. each reach reactant Assumption?

35 MATLAB Enzyme_7_2.m Enzyme_kinetics_equations.m

36 Solution to Linear ODE Method based on Eigenvalues and Eigenvectors
Recall “variable separation”

37 Solution to multiple Linear ODE
In matrix form Proof: F(x)=f(0)+(x-0)f’(0)/1!+(x-0)^2f”(x)/2!+(x=0)^ifi(0)/i!

38 Solution to multiple Linear ODE
If A has eigenvalues Λ and eigenvectors X AX=XΛ X=[x1, x2, x3, …, xn] Derivation see Constantinides and Mostoufi (1999) Numerical Methods for Chemical Engineers with MATLAB Applications.

39 Matlab Functions for matrix exponentials and eigenvalues/eigenvectors:
expm (A): Calculates the matrix exponential of A using a scaling and squaring algorithm with a Pade approximation (Burden et ai., 1981). eig (A) : Calculates the eigenvalues of matrix A. [X, LAMBDA] = eig (A) y = X*expm(LAMBDA*t)*X^-1*y0

40 Example: The dynamics of drug absorption

41 Matlab code disp('Initial concentrations: ') c0= [1; 0; 0]
disp(' '); disp('Matrix of coefficients: ') K=[-k ; k0 -k1 0; 0 k1 0] [X,lambda]=________; c=___*expm(_____)*___ *c0 t=[0:100]; c=eval(c); disp('Initial concentrations: ') c0= [1; 0; 0] disp(' '); disp('Matrix of coefficients: ') K=[-k ; k0 -k1 0; 0 k1 0] [X,lambda]=eig(K); c=X*expm(lambda*t)*X^-1*c0 t=[0:100]; c=eval(c);

42 Steady-State Solutions and Stability Analysis
Steady-state: time derivative is zero

43 Steady-State Solutions and Stability Analysis
At steady-state:

44 Introducing perturbation

45 Jacobian: Solution depends on the eigenvalues of A (J*):
Recall linear ODE: Solution depends on the eigenvalues of A (J*):

46 Stability Analysis Analogously, in 1-D, gradients inform us about minimum, maximum or saddle point.

47

48

49

50 Negative real part Positive real part Nonzero complex part

51 Numerical Stability Stability:
Inherent (positive real in eigenvalues of J matrix) Numerical (integration method) Truncation error Round off error Propagation error More terms in the expansion (smaller steps) Double precision Smaller steps

52 Stability of Euler Method
Initial value differential equation Analytical solution Is inherently stable for because Introduce a small perturbation to the initial value: If λ > 0, small changes in initial value lead to small changes in solution: unstable

53 Numerical Stability of Euler Method
Numerical solution by explicit Euler: The numerical solution is absolutely stable if This requires the growth factor Euler method is conditionally stable within the linear stability domain.

54

55 Stiff Equations A stiff equation is a differential equation for which certain numerical methods for solving the equation are numerically unstable, unless the step size is taken to be extremely small. The MATLAB functions ode23s and ode15s are suitable for stiff ordinary differential equations

56 Stiff Ratio For a set of nonlinear DE: Big SR  Stiff

57 Stiff Equation Example: The chemical reaction of Robertson
With a short interval, e.g. (0<h<40) numerical integration is stable. However, if h is very large (1011), then many standard codes fail.

58 Matlab Exercise Select one book example below, work through and present in class. Example 7.4a (or b), 7.5, 7.6, 7.7. Scanned PDF on BlackBoard.

59 Lessons Learned Molecular, cellular and bio systems can be modeled with ODE ODE classification: 1st, 2nd, 3rd order Linear, nonlear Homogenous, nonhomogeneous Initial value or boundary value 2nd or higher order ODE can be converted to a set of 1st order ODE Linear ODE solution depends on eigenvalues and eigenvectors of the ODE (expam) Nonlinear ODE can be integrated numerically using method based on FD. Integrating ODE is line climbing a mountain: move in the direction of slope (or weighted average), taking many small steps. Solve ODE using MATLAB (ode45, expam) The stability of nonlinear ODE depends on the eigenvalues and the Jacobian matrix The stability of numerical solution depends on the form of the equations, the methods, and step size.


Download ppt "Dynamic Systems: Ordinary Differential Equations"

Similar presentations


Ads by Google