Do ODE solvers use location of root of event function in its solution even if integration isn't specified to stop?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Say I want to solve an ODE with a piece-wise continuous function and I want to accrurately capture the corner point in the solution. Do I need to set the solver to stop when it reaches the corner (which is detected as an event), or can I let it keep integrating and the solver will use the presice location of the corner as a step in its solution?
0 Kommentare
Akzeptierte Antwort
Torsten
am 4 Mär. 2024
Bearbeitet: Torsten
am 4 Mär. 2024
You will have to tell the solver to return control to the calling program once the corner point is reached. From there, you can continue integration.
If the corner point is known in advance (e.g. a certain time t*), you can integrate (without the use of an event function) from tstart to t* and restart the solver from t* to tend.
5 Kommentare
Torsten
am 4 Mär. 2024
Bearbeitet: Torsten
am 4 Mär. 2024
Your understanding is correct.
Each time your equations change (in your case even discontinuously), you have to stop integration and restart from the solution obtained so far. So you should just pass a flag to your ode function that indicates if you are in the regime before or after the event. Depending on this flag, you can set f = 0 or f = 1.
So don't use an if statement concerning sin(x) < 0 or >=0 to control the value for f, but the flag you set in the calling program which indicates whether you are before or after the event location.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!