matlab - Simultaneous differential equations with conditional change of a coefficient -
i want model chemostat (a kind of bioreactor). setup following system can solved ode45 method:
%chemostat model, based on: %dcc=-v0*cc/v + umax*cs*cc/(ks+cs)-rd -->change of cell concentration on time %dcs=(v0/v)*(cs0-cs) - cc*(ys*umax*cs/(ks+cs)-m) -->change of substrate concentration on time function dydt=sys(t,y,v0,v,umax,ks,rd,cs0,ys,m) dydt=[-(v0/v)*y(1)+(umax*y(1)*y(2))/(ks+y(2))-rd; (v0/v)*(cs0-y(2))-(ys*umax*y(2)*y(1))/(ks+y(2))];
i call function with:
[t,y]=ode45(@systemequations, [0 40],[1 100],[],**v0**, v,umax,ks,rd,cs0,ys,m);
the values of additional coefficients set before running calculation. far works. v0 dependent on system state. e.g. v0 = 0 , when cell concentration surpasses value want change.
the problem is, absolutely have no idea how implement this. matlab of ode solver wasn't of either...
thanks or suggestions!
cheers, dahlai
use differential system function take care of you! first formulate v0 function of time , state:
function v0 = funv0( t, y ) v0 = 1; if y(1) > 5 v0 = y(2); % example, if [y1] > 5, set v0 = [y2] end end
then utilize function in differential system. can either pass @funv0 parameter, or let differential system function execute directly. treat parameter now.
function dydt=sys(t,y,v0,v,umax,ks,rd,cs0,ys,m) dydt=[-(v0(t,y)/v)*y(1)+(umax*y(1)*y(2))/(ks+y(2))-rd; (v0(t,y)/v)*(cs0-y(2))-(ys*umax*y(2)*y(1))/(ks+y(2))];
called using:
[t,y]=ode45(@systemequations, [0 40],[1 100],[],@funv0, v,umax,ks,rd,cs0,ys,m);
of course, principle can applied time or state dependent parameter. style allows try various parameter functions let's approximating parameter function of state: can trial out different approximations passing in different v0 functions.
Comments
Post a Comment