How to solve model with different ODEs at initial conditions?
Show older comments
I am trying to solve a set of ODEs. The model has different equations for initial point,so I am using If condition in ODE function to use this specific equations to solve the model at initial point t0. The reason the model have different equations for the initial condition is that, the actual ODES are undefined at t0.
This is my function;
Lets say at from f=1 to 0.2.
------------------------------------------------------------------
function dxdf = cocurrenty(f,x,r,qA, qB, qC, xFa, xFb)
if (f>0) && (f<1.0)
dxdf(4,1)= ((xFa-f*x(1))/(1-f)) - x(4);
dxdf(5,1) = ((xFb-f*x(2))/(1-f))- x(5);
else t=10e-15; yPa= x(4);
for n=1:100
yPa(n+1)=yPa(n)-((yPa(n)+(xFb*qB/qA)/(r*...
(qB/qA-1)+(xFa/yPa(n)))+((1-xFa-xFb)*qC/qA)/(r*...
(qC/qA-1)+(xFa/yPa(n))))-1)/((xFb*xFa*qB/qA)/yPa(n)^2/...
(r*(qB/qA-1)+(xFa/yPa(n)))^2+((1-xFa-xFb)*xFa*...
qC/qA)/yPa(n)^2/(r*(qC/qA-1)+(xFa/yPa(n)))^2+1);
if abs(yPa(n+1)-yPa(n))<t
y1=yPa(n);
y2=(xFb*qB/qA)/(r*(qB/qA-1)+(xFa/yPa(n)));
y3=1-y2-y1;
x3=1-xFa-xFb;
if (1> y1) && (y1 > 0) && (1> y2) && (y2 > 0)
break
end
end
end
dxdf(4,1) = y1-x(4);
dxdf(5,1) = y2-x(5);
end
dxdf(1,1)= (qA*(x(1)-r*x(4)) - x(1) * (qA*(x(1)-r*x(4))+qB*(x(2)-r*x(5))+qC*((1-x(1)-x(2))-r*(1-x(4)-x(5)))))/... (f*(qA*(x(1)-r*x(4))+qB*(x(2)-r*x(5))+qC*((1-x(1)-x(2))-r*(1-x(4)-x(5)))));
dxdf(2,1)= (qB*(x(2)-r*x(5)) - x(2) * (qA*(x(1)-r*x(4))+qB*(x(2)-r*x(5))+qC*((1-x(1)-x(2))-r*(1-x(4)-x(5)))))/... (f*(qA*(x(1)-r*x(4))+qB*(x(2)-r*x(5))+qC*((1-x(1)-x(2))-r*(1-x(4)-x(5)))));
dxdf(3,1)= (-1/(qA*(x(1)-r*x(4))+qB*(x(2)-r*x(5))+qC*((1-x(1)-x(2))-r*(1-x(4)-x(5)))));
end
------------------------------------------------------------------
Newtons Algorithm is used to find x(4) and x(5) at t0 (f=1). The problem is when I increase the value of r (a constant in ODEs) I got this warning.
''Warning: Failure at t=1.000000e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (3.552714e-15) at time t. > In ode15s at 669 In PressureOnemli at 75 ''
Is there another way of typing ODEs with different initial conditions? Any help would be much appreciated. Thank you. Merve
1 Comment
Torsten
on 30 Mar 2016
Why don't you start with f=0.999999 ?
I mean: There can't be any effect on the solution if the values for x(4) and x(5) differ in only one single point, namely f=1.
Best wishes
Torsten.
Answers (0)
Categories
Find more on Ordinary Differential Equations 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!