Do ODE solvers use location of root of event function in its solution even if integration isn't specified to stop?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Torsten
il 4 Mar 2024
Modificato: Torsten
il 4 Mar 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 Commenti
Torsten
il 4 Mar 2024
Modificato: Torsten
il 4 Mar 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.
Più 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!