How to solve differential equation with variable in differential term?

4 次查看(过去 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
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.

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by