How to solve differential equation with variable in differential term?
3 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to solve differential equations with polar coordinate, the equation looks like the following:
r*dy/dr = A*r*exp(B*(C-x(r))) - y(r)
dx/dr = y(r)./D
I'm using ode45 solver with boundary conditions that y(r=0) = 0, and x(r=R) = E.
Since in ode45 tutorial guide of Matlab, I didn't see any example with "r" included in dy/dr term, I simply divide the first equation with r.
It becomes:
dy/dr = A*exp(B*(C-x(r))) - y(r)/r
And I would have a problem that when r = 0, y(0)/0 = Nan.
I understant that from the mathematical view 0/0 doesn't make sence, but from my physical view, I need y(0) = 0 at the this point. Therefore, I just ignore the last term when r = 0 by using if function:
if r == 0
dy/dr = A*exp(B*(C-x(r)));
else
dy/dr = A*exp(B*(C-x(r))) - y(r)/r;
end
Could someone tell me if there is any other solver/method can solve this r*dy/dr = A*r*exp(B*(C-x(r))) - y(r) equation? Or could the method I'm using so far would lead to some problems?
Thanks a lot!
回答 (1 件)
DUY Nguyen
2023 年 3 月 2 日
You could try to define a new variable u = r + eps ( where eps is a small positive number close to zero, should be carefully chosen) and solving the differential equation on the interval [eps, R] instead of [0, R]. This approach will effectively shift the singularity at r = 0 to u = eps, where it can be avoided.
0 件のコメント
参考
カテゴリ
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!