How to solve differential equation with variable in differential term?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
Réponses (1)
DUY Nguyen
le 2 Mar 2023
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 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!