stiff ode solver with non-negative properties
7 ビュー (過去 30 日間)
古いコメントを表示
I looking to construct a model consisting of differential equations solved numerically using matlab. The results of the equations are pretty stiff, so only a stiff solver works. I am also hoping for the results to be set as non-negative to better match the empirical data. This does not seem to work with the standard ode solvers. Do you have any recommendations for this situation?
0 件のコメント
回答 (1 件)
Torsten
2022 年 9 月 12 日
編集済み: Torsten
2022 年 9 月 12 日
Do the negative solutions result from numerical inaccuracies or from the equations themselves ?
If the latter is the case, no recommendations can be given because the solution is determined by the ODEs and the initial conditions. If they turn out to be negative, then you must accept this.
Else try the NonNegative option in the ODE solver options (together with a stiff solver, e.g. ODE15S).
2 件のコメント
Torsten
2022 年 9 月 12 日
@Xinyue Liang comment moved here:
I think it results from numerical inaccuracies. The NonNegative option for the ODE solver does not seem to work for any of the stiff solvers (ode15, ode23). Is there another way to change this or maybe alter the equations to manually set it to be non-negative? Thank you so much!
Torsten
2022 年 9 月 12 日
編集済み: Torsten
2022 年 9 月 12 日
If the NonNegative option does not work usually indicates that the negative values stem from the equations themselves, not from numerical inaccuracies...
Before working with the variables, you could check them for nonnegativity in an if-statement and reset them to a small positive value if they are negative. But this only works if they are really negative due to numerical inaccuracies. Otherwise, you will get unexpected solutions or the solver will quit.
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!