Saludos,
Estoy tratando de resolver en set de ODEs usando ODE45, el problema es que algunos estados que dependen del tiempo tienes restricciones las cuales debo definir con if.
condiciones iniciales:
x0=[0.43 5 0.58 0.14 0.0024 0.01 4];
Condición inicial para el estado que no depende del tiempo
u(1)=um*((x0(3)/x0(2))/((x0(3)/x0(2))+Ksr))*(1-((x0(3)/x0(2))/Sm)^nk)*((x0(5)/(Kox*x0(1)+x0(5))));
Time definition
tsim=50;dt=0.0001;t(1)=0;i=1;Ni=round(tsim/dt);for i=1:Niif t(i)<24 F1=0; F2=0; elseif t(i)>24 && t(i)<30 F1=80*(1/1000); F2=0;%70*(1/1000);
else F1=0; F2=0;enddx=@(t,x) [u(i)*x(1)-((F1+F2)/x(7))*x(1); -((Csx*u(i)*x(1))+(Rcsx*x(1))+Csp*((k1*u(i)*x(1))+(k2*x(1))))+(F1/x(7))*Sin-((F1+F2)/x(7))*x(2); -((Cnx*u(i)*x(1))+(Rcnx*x(1)))+(F2/x(7))*Nin-((F1+F2)/x(7))*x(3); ((k1*u(i)*x(1))+(k2*x(1)))-((F1+F2)/x(7))*x(4); ((KL*(O2Leq-x(5)))-(k3*u(i)*x(1))-((k4*k1*u(i)*x(1))+(k4*k2*x(1))))+(F3/x(7))*O2in-((F1+F2)/x(7))*x(5); ((alfa1*u(i)+alfa2)*x(1))+(alfa3)-((F1+F2)/x(7))*x(6); (F1+F2)];[t,x]=ode45(dx,tspan,x0); u(i+1)=um*((x(3)/x(2))/((x(3)/x(2))+Ksr))*(1-((x(3)/x(2))/Sm)^nk)*((x(5)/(Kox*x(1)+x(4)))); if u(i+1)<0 u(i+1)=0; end t(i+1)=t(i)+dt; i=i+1; end
condiciones para los estados que dependen del tiempo
if x(3)<0.15 x(3)=0.15; end if x (5)<0.002432 x(5)=0.002432; end
aprecio su ayuda.
Gracias
Best Regards.
Best Answer