Is there an elegant way to find various steady-state solutions of an ODE system with a variable parameter?
Show older comments
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
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!