フィルターのクリア

Do ODE solvers use location of root of event function in its solution even if integration isn't specified to stop?

1 回表示 (過去 30 日間)
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?

採用された回答

Torsten
Torsten 2024 年 3 月 4 日
編集済み: Torsten 2024 年 3 月 4 日
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 件のコメント
Torsten
Torsten 2024 年 3 月 4 日
編集済み: Torsten 2024 年 3 月 4 日
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.
Nick
Nick 2024 年 3 月 4 日
Ok great. Thanks so much for clearing that up

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by