Is there an elegant way to find various steady-state solutions of an ODE system with a variable parameter?

I have a code with a set of 3 ODEs which are solved with ode45 and depend on 3 initial conditions and 9 parameters. 8 parameters are fixed values and are read out from an EXCEL-file and one parameter (D) can be a variable.
So far, the code is designed to stop integrating until steady-state condition (dydt=0) is reached within a certain tolerance (1E-4).
Since the steady-state solutions change with changing values for D, my goal is to end up with a code, that only calculates steady-state solutions that depend on D. So far I was merely able to write the following, where D is a fixed value which I change "by hand" and run the code several times (e.g. where D is between 0.1 - 0.4) before having my solutions.
1st file:
clear all, close all, clc
global y0
% 8 fixed constants
p = xlsread('import.xlsx','B3:B10')';
% Initial values for ODE
y0(1) = 0.1; %X
y0(2) = 4.0; %S
y0(3) = 0.3; %P
% ODE options with "stop at steady-state" criterion
opts = odeset('Events', @event);
% ODE solution
[t,y] = ode45(@ODE,[0 Inf],y0,opts,p);
2nd file
function dydt = ODE(~,y,p)
D = 0.3;
% Model equation
m = ((p(1)*y(2))/(p(2)+y(2)));
% Reaction rates
rX = m*y(1); %X production rate
if y(2)>0 %protect S from becoming negative
rS = -((m*y(1))/p(3))-p(4)*y(1); %S utilization rate
else
rS=0;
end
rP = p(5)*rX+p(6)*y(1)-p(7)*y(1)*y(2); %P formation rate
% ODEs
dydt(1)= rX-D*y(1);
dydt(2)= rS+D*p(8)-D*y(2);
dydt(3)= rP-D*y(3);
dydt = [dydt(1);dydt(2);dydt(3)];
3rd file
function [x,isterm,dir] = event(~,y,p)
%%%[Here dydt system is copy-pasted from the 2nd file]
x = norm(dydt) -1e-4;
isterm = 1;
dir = 0;
Ultimately, I want to generate a graph where steady-state solutions for y are plotted over D. If this is possible (even with a completely different approach to the solution) I would be more than happy to hear any of your ideas.
Steve
PS: The code provided is simplified, so I hope I did not forget anything crucial for understanding the problem.

 Accepted Answer

Set the time derivatives to zero and solve for y(1), y(2) and y(3).
My guess is that y(1)=0, y(2)=p(8) and y(3)=0 is the steady state.
Best wishes
Torsten.

6 Comments

... at least one of the possible steady-states.
Best wishes
Torsten.
You can explicitly determine the (interesting) steady-state:
(y2*) = D*p(1)/(p(1)-D)
(y1*) = D*(p(8)-(y2*))/(p(4)+p(1)*(y2*)/(p(2)+(y2*))*1/p(3))
(y3*) = (p(5)*p(1)*(y2*)/(p(2)+(y2*))*(y1*)+p(6)*(y1*)-p(7)*(y1*)*(y2*))/D
Best wishes
Torsten.
Hi Thorsten,
thanks a lot for your solution. As I already commented on Star Striders answer, I already calculated this (but in EXCEL) as a control. What I did not mention so far is that I have the same code as posted above multiple times but with different ODE systems of which some cannot be solved explicitly (and unfortunately not posted here).
So, I am currently trying to adapt the code in order to create a loop where the ODE45 is solved various times (for varying 'D') and where the steady-state solutions for each 'D' is saved. However, I am currently having a hard time to realize this and I fear that it will result in quite long calculation times. But any help would be still appreciated.
Thanks so far,
Steven
You just have to solve an algebraic system of equations because you are only interested in the steady state.
Thus you should use "fsolve" instead of "ODE45" - it should be much faster.
Best wishes
Torsten.
That did the trick! So all in all the solution was way easier than expected. If anyone is interested, I can post the code with the "fsolve-solution".
Thank you very much.
Steve
Hi Steve -
Yes, it would be really helpful for me if you could post the 'fsolve-solution'.
Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 23 Jul 2015

Commented:

on 2 Sep 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!