Why does this ODE yield two events?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have the following simple ODE:
With initial condition x(0)=5, I am interested in when x(t)==1. So I have the following events function:
function [value,isterminal,direction] = test_events(t,x)
value = x-1;
isterminal = 0;
direction = 0;
end
This should produce an event at t=4. However, if I run the following code I get two events, one at t=4, and one at t=4+5.7e-14:
options = odeset('Events',@test_events);
sol = ode45(@(t,x)-1,[0 10],5,options);
If I run smiliar codes to find when x(t)==0 or x(t)==-1 (value = x; or value = x+1; respectively), I have only one event. Why does this generate two events?
NEWER UPDATE:
Observing the sol.x and sol.y outputs (t and x, respectively), the time progresses as integers [0 1 2 3 4 5 6 7...], and x progresses as integers up until x(t=5) like so: [5 4 3 2 1 1.11e-16 -1.000 -2.000...]. This indicates that there is something that occurs between t=4 and t=5 that creates a 'bump' in the ODE solution. Why?
OLDER UPDATE:
If the relative tolerance is set to 1e-5, the solver provides a single event correctly at t=4. If the relative tolerance is set to 1e-4, the solver provides a single event, but at t=4+5.7e-14. If the relative tolerance is set to 1e-8, the solver produces the same two events as the default. If the initial condition is changed from x(0)=5 to x(0)=4, the solver yields one event. However, if the initial condition is changed to x(0)=4 and the RelTol is set to 1e-8, it generates two events.
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!