How to eliminate sharp surges generated in the solution using ode15s?
Mostrar comentarios más antiguos
I am using ode15s to solve a system of ODEs. In the model, I am feeding my system with a fixed quantity of mass everyday. This mass, however, is fed within few seconds. So, I defined a flow rate (q_in) and a feeding time interval (int) such that dividing both quantities will always yield the same mass I'm feeding my system, irrespective of the values of either of them.
The problem is that when setting the feeding interval to 90 seconds, which can be assumed as a valid assumption close to reality, the solution contains lots of noise, or sharp surges, and makes the actual trend of the model difficult to see. When increasing this feeding time to 10 minutes, however, those surges were lowered to an acceptable level, and the solution did not change much. How can I modify the solution using 90 seconds to produce the same result as that of 10 minutes?
I tried manipulating the relative and absolute tolerances without much of a success. I will include the part of code associated with this problem. Screenshots of both results are also included.


t_size = 2*round(t_exp(end));
t_feed = zeros(1,t_size);
for j=1:t_size
t_pulse = 90*60; %Make feeding interval a step function with width = 90 seconds%
int = t_pulse/(24*60*60);
if j==1
t_feed(1,j)= int;
else
out=~rem(j,2)*(j/2);
if out==0
t_feed(1,j)= t_feed(1,j-2)+1;
else
t_feed(1,j)= j/2;
end
end
end
for j = 1:t_size
if j==1
t_start = 0;
y_init = y_0;
end
t_end = t_feed(j);
t_int = t_end - t_start;
diff = t_int - int;
if (diff<=1e-6)
q_in = m_tot_FM(subnum)*(1E-6)*(1/int);
else
q_in = 0;
end
options=odeset('RelTol',1e-12,'AbsTol',1e-12);
[t,y] = ode15s(@adm, [t_start,t_end], y_init,options);
t_start = t_end;
y_init = y(end,:);
C{j,:} = y;
D{j,:} = t;
Q(j,:) = q_in;
T_int(j,:) = t_int;
end
3 comentarios
How can I modify the solution using 90 seconds to produce the same result as that of 10 minutes?
By stopping and restarting ODE15S each time a feeding time starts and ends.
Strong discontinuities in the differential equations are not tolerated by the ODE solvers which are built upon the assumption that the time derivatives are differentiable (or at the very least continuous) functions.
Karim Monaem
el 7 de En. de 2023
Torsten
el 7 de En. de 2023
I must admit that I don't see a difference between the simulated results in the two graphics ( disregarding that in the first graphics, the black curve goes down to zero at the injection times).
Respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!