Detecting events - why are 2 events occurring when the calcuations should stop after any event ?

3 views (last 30 days)
Hi
I am solving a diff equation using ode15s. An event function is used to detect 2 events. This function stops the cal. once an event is detected and re-starts the next round of calculation using the values of the variables when the event is detected as the initial condition.
The event function is given below :
%------------------------
function [eventvalue, stopthecalc, eventdirection] = eventsFuncn8_IB(t, z, p, nj)
R = z(1); % radius of bubble
Rdot = z(2); % vel of bubble wall
eventvalue = [Rdot Rdot] ;
stopthecalc = [1 1]; % CHANGED FOR FLYNN SOLUTION FROM 1 1 to 0 0
eventdirection = [-1 1]; % stop when rdot = 0 when y' is negative OR
rdot = 0 when y' is positive
end
%---------------
My understanding is that only 1 event will occur in a given iteration because the instant the event occurs the calculation is stopped (because stopthecalc = [1 1])
But when I run the main program there are iterations when 2 events are detected. How is this possible ? Because shouldn't the calculation stop the moment an event is detected ?
TIA
  1 Comment
Dhamdhawach Horsuwan
Dhamdhawach Horsuwan on 22 Jul 2020
I face this problem too.
Based on ode45 algorithm I guess when ode45 take a step say t1 to t2 then it found 2 event at same (ode45) step
after that matlab will find exact time for each event and report it individually.
anyway I consider this situation as bug. after find which event occured first, matlab should ignore other event afterward.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!