Having trouble solving two second order ODEs simultaneously
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Shishir Raut
el 14 de Feb. de 2023
Comentada: Shishir Raut
el 16 de Feb. de 2023
I am trying to solve Keller Miksis equation for a double bubble system but I am having trouble breaking down the equation into two first order ODEs or solving these two equations simulatenously.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1295035/image.png)
For ease, I am omitting the terms containing (dPsi/dt) and (dPsj/dt) from both equations.
The code I used is:
syms Ri(t) Rj(t) x(t) DRi(t) DRj(t) Dx(t)
c=350
Psi = 1000
Psj = 1000
Dij = 1e-6
rho = 997
ode1= (1-(1/c)*diff(Ri,t))*Ri*(diff(Ri,t,2))+ 1.5*(1-(1/(3*c))*diff(Ri,t))*((diff(Ri,t))^2) == (1/rho)*(1+(1/c)*diff(Ri,t))*Psi - (1/Dij)*(2*diff(Rj,t)*diff(Rj,t,2)^2+ diff(Rj,t,2)*diff(Rj,t)^2 )
[ode1, var1] = reduceDifferentialOrder(ode1,Ri);
ode2 = (1-(1/c)*diff(Rj,t))*Rj*(diff(Rj,t,2))+ 1.5*(1-(1/(3*c))*diff(Rj,t))*((diff(Rj,t))^2) == (1/rho)*(1+(1/c)*diff(Rj,t))*Psj - (1/Dij)*(2*diff(Ri,t)*diff(Ri,t,2)^2+ diff(Ri,t,2)*diff(Ri,t)^2 )
[ode2, var2] = reduceDifferentialOrder(ode2,Rj);
ode = [ode1; ode2];
var = [var1; var2];
[odes, vars] = odeToVectorField(ode);
ode_fun = matlabFunction(odes, 'Vars',{'t','Y'});
y0 = [0 0];
tspan = [0 5];
[t,y] = ode45(ode_fun,tspan,y0);
plot(t,R)
The error I am getting is:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1295040/image.png)
I would really appreciate if you could help me figure out to solve these simultaenous second order ODEs.
0 comentarios
Respuesta aceptada
Torsten
el 14 de Feb. de 2023
According to your equations in the graphics, these terms in the MATLAB code are wrong:
- (1/Dij)*(2*diff(Rj,t)*diff(Rj,t,2)^2+ diff(Rj,t,2)*diff(Rj,t)^2 )
- (1/Dij)*(2*diff(Ri,t)*diff(Ri,t,2)^2+ diff(Ri,t,2)*diff(Ri,t)^2 )
10 comentarios
Torsten
el 16 de Feb. de 2023
Editada: Torsten
el 16 de Feb. de 2023
Maybe better to read.
syms Ri(t) Rj(t) psi(t) psj(t)
c = 1480;
pv = 2338;
p2 = 101325;
rho = 1000 ;
sigmaL = 0.072 ;
muL = 1.005e-3 ;
gamma = 1.4 ;
Dij = 1e-6;
P0 = 101325;
Roi = 100*1e-6;
Roj = 50*1e-6;
tau = 5;
psi = (P0+2*sigmaL/Roi)*(Roi/Ri)^(3*gamma) -2*sigmaL/Ri - 4*muL*diff(Ri,t)/Ri - (pv + ((p2-pv)*t)/tau);
psj = (P0+2*sigmaL/Roj)*(Roj/Rj)^(3*gamma) -2*sigmaL/Rj - 4*muL*diff(Rj,t)/Rj - (pv + ((p2-pv)*t)/tau);
ode1= (1-(1/c)*diff(Ri,t))*Ri*(diff(Ri,t,2))+ 1.5*(1-(1/(3*c))*diff(Ri,t))*((diff(Ri,t))^2) == 1/rho * (psi + 1/c*diff(Ri*psi,t)) - (1/Dij)*(2*Rj*diff(Rj,t)^2 + Rj^2*diff(Rj,t,2) );
ode2 = (1-(1/c)*diff(Rj,t))*Rj*(diff(Rj,t,2))+ 1.5*(1-(1/(3*c))*diff(Rj,t))*((diff(Rj,t))^2) == 1/rho *(psj + 1/c*diff(Rj*psj,t)) - (1/Dij)*(2*Ri*diff(Ri,t)^2 + Ri^2*diff(Ri,t,2) );
ode = [ode1; ode2];
[V,S] = odeToVectorField(ode);
M = matlabFunction(V,'vars',{'t','Y'});
y0 = [Roj 0 Roi 0];
tspan = [0 5];
[t,y] = ode15s(M,tspan,y0);
plot(t,[y(:,1),y(:,3)])
grid on
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!