How To Fix This MATLAB ODE23S Error: Warning: Failure at t=3.708863e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.317653e-14) at time t.

5 次查看(过去 30 天)
Hi all so I was solving a problem, which included differential equations. Because of this I decided to use the ODE23S solver.
After running my script I receive this error: Warning: Failure at t=3.708863e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.317653e-14) at time t.
I have seen this error on MATLAB Answers and across the internet; however, the answers are not very clear and do not necessarily help. I was wondering if someone could help me solve this issue. I understand that typically, this means the problem is not using an ODE solver that can solve equations that stiff; however, I have changed my solver to ODE23S as well and it still does not run properly. Furthermore, this case could mean that I have a singularity in the region over which I am attempting to integrate. However, I cannot eliminate this singularity because I have several random singularities. It would not be possible to eliminate these as they are all random and every time I run the script the error changes at t.
Below I have attached my code:
function dydt = PSIIODES (t,y,k) % 'ODE' for 'Ordinary Differential Equation'
dydt = zeros(31,1);
if mod(((t/50) - rem(t,50)),2) < 1
h = 1;
elseif mod(((t/50) - rem(t,50)),2) >= 1
h = 0;
elseif t == 0
h = 1;
end
r(1) = h*k(1)*y(1);
r(2) = k(2)*y(2)*y(3);
r(3) = k(3)*y(4)*y(5);
r(4) = k(4)*y(6)*y(7);
r(5) = k(5)*y(4)*y(8);
r(6) = k(6)*y(8)*y(9);
r(7) = k(7)*y(8)*y(10)*y(11);
r(8) = k(8)*y(11)*y(12);
r(9) = k(9)*y(13);
r(10) = k(10)*y(31)*y(21);
r(11) = h*k(11)*y(33);
r(12) = k(12)*y(15)*y(16);
r(13) = k(13)*y(17)*y(18);
r(14) = k(14)*y(19)*y(20);
r(15) = k(15)*y(20)*y(22);
r(16) = k(16)*y(22)*y(23);
r(17) = k(17)*y(25)*y(11)*(y(22))^2;
r(18) = k(18)*y(15);
r(19) = k(19)*y(2);
r(20) = k(20)*y(26);
r(21) = k(21)*y(23)*y(11);
r(22) = k(22)*y(27)*y(32);
r(23) = k(23)*y(29)*(y(28))^3*(y(26))^2;
r(24) = k(24)*y(32);
r(25) = k(25)*y(28);
r(26) = k(26)*y(30);
r(27) = k(27)*y(14);
r(28) = k(28)*y(31);
r(29) = k(29)*y(11)*y(25);
r(30) = k(30)*y(24);
dydt(1) = -r(1) + r(3) + r(5) + r(19);
dydt(2) = r(1) - r(2) - r(19);
dydt(3) = r(2) - r(3) - r(5);
dydt(4) = -r(2) + r(3);
dydt(5) = r(2) - r(3);
dydt(6) = -r(4) + r(5) + r(6) + r(7);
dydt(7) = r(3) - r(4) - r(5) - r(6);
dydt(8) = -r(6) + r(26);
dydt(9) = r(6) - r(7);
dydt(10)= r(7) - r(8);
dydt(11)= r(8) - r(9);
dydt(12)= r(9) - r(10) - r(28);
dydt(13)= -2*r(10) + r(14);
dydt(14)= 2*r(10) - r(14) + r(28);
dydt(15)= r(10) - r(24);
dydt(16)= -r(11) + r(14) + r(15) + r(18);
dydt(17)= r(11) - r(12) - r(18);
dydt(18)= r(12) - r(14) - r(15);
dydt(19)= -r(12) + r(13);
dydt(20)= r(12) - r(13);
dydt(21)= -r(13) + r(15) + r(16);
dydt(22)= r(13) - r(15) - r(16);
dydt(23)= r(16) + 2*r(17) + r(21) - r(30);
dydt(24)= r(16) - 2*r(17) + r(21) + r(30);
dydt(25)= -r(17) + r(20) - r(29) + 2*r(23);
dydt(26)= r(17) - r(20) + r(29) - 2*r(23);
dydt(27)= -r(7) - r(8) - r(17) + r(20) + r(22) + r(23) + r(26);
dydt(28)= 2*r(10) - r(22) - r(26) - r(25);
dydt(29)= -r(22) + 3*r(23) + r(25);
dydt(30)= r(22) - 3*r(23) - r(25);
dydt(31)= r(27) - 3*r(23);
dydt(32)= -r(24) + r(28);
dydt(33)= -r(27);
end
And this is the Main that I used to call my ODE function:
k = rand(30,1);
y0 = rand(33,1);
tspan = [0 200];
Sol = ode23s(@(t,y) PSIIODES(t,y,k),tspan,y0);
Any help would be greatly appreciated. Thank you!
  1 个评论
Are Mjaavatten
Are Mjaavatten 2018-6-21
I hate to be a killjoy, but it seems to me that your task is extremely difficult, if not impossible. Numerical ODE solvers cannot integrate over a singularity.
For simpler cases you may be able to use Cauchy's integral formula or singularity residues (This a bit vague to me, 45 years after my complex analysis class. Maybe some mathematician can be more specific?).
For your case, with 33 independent variables and possibly several singularities popping up in unpredictable places, the prospects seem bleak. I would go back to the original problem and try to find a special case that is much less complex. Working with this, you may gain some insights that may help you reformulate your problem.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by