Early exit instead of a warning in ODE113?

조회 수: 4 (최근 30일)
Noam Ouzana
Noam Ouzana 2021년 9월 6일
답변: Jan 2021년 9월 6일
While running a code that uses ODE113, the program will run, possibly indefinitely, until manually paused. Once paused, the error "Unable to meet integration tolerances without reducing the
step size below the smallest value allowed" appears.
Is there a way to tell ODE113 to generate an error instead of a warning (or something else that would stop the code), so the program won't be stuck in futile calculation?

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2021년 9월 6일
The brute-forciest way to do this might be to give ode113 an event that interrupts after some suitably long time, i.e. long enough to let a successful integration complete and short enough to not get on your nerves (if this is possible...). Perhaps something like:
function [position,isterminal,direction] = your_patienceEvent(t,y,t0,dt)
position = etime(datevec(t),datevec(t0))<dt; % The elapsed time that we can manage to wait?
isterminal = 1; % Halt integration
direction = 0; % The zero can be approached from either direction
Then set the eventfunction-field of the ode-options struct to something like:
ops113 = odeset;
t0 = now;
ops113.event = @(t,y) your_patienceEvent(t,y,t0,600);
That will limit the running-time of ode113 to 10 minutes after you assign t0. Perhaps you have some more appropriate diagnostic for when the integration runs into problems (some problematic values of y(t) would be more sensible to use for aborting integration).
HTH

추가 답변 (1개)

Jan
Jan 2021년 9월 6일
In the current version of Matlab ODE113 does stop, when the integration tolerance is not met. The warning is shown an the integration is stopped. This means, that the code does already, what you want.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by