Integrating two ODE'S

2 次查看(过去 30 天)
Ian DSouza
Ian DSouza 2017-12-28
评论: Ian DSouza 2017-12-30
I'm trying to integrate these two equations: d/da(rho*a^3) = -3*w*rho*a^2; ((da/dt)/a)^2 + k/a^2 = 8*pi*G/3*rho
where a==a(t), rho==rho(a),w=w(rho).
For now, I am taking 'w' to b a constant. I found out d(rho)/dt = d(rho)/da * da/dt to get 'ode1' and expressed rhoas a function of time 't'. 'ode2' is just the second equation.
Code:
---------------------
syms a(t) rho(t) w(rho)
G=1;
w=1/3;
k=0;
ode1 = diff(rho) == -3*rho*(w+1)*sqrt(8*pi*G/3*rho);
ode2 = (diff(a)/a)^2 + k/a^2 == 8*pi*G/3*rho;
odes = [ode1;ode2];
Sol = dsolve(odes)
aSol(t) = Sol.a;
rhoSol(t) = Sol.rho
---------------------------- Output:
Sol =
struct with fields:
a: [1×1 sym]
rho: [1×1 sym]
aSol(t) =
C5
rhoSol(t) =
0
K>>
This is of course not the solution. Can someone please tell me where I'm going wrong. Thanks.
I am open to numerically integrating these as well
  2 个评论
David Goodmanson
David Goodmanson 2017-12-30
Hello Ian, For w = constant, since rho = rho(a) only depends on time implicitly through a(t), it appears that the solution to the first equation is simply
rho = C*a^(-3(w+1))
and then a(t) can be calculated from the second equation.
Ian DSouza
Ian DSouza 2017-12-30
Thanks David. Yes,that is the solution for w=constant. I decided to keep the ODE because I wanted to eventually vary 'w' as a function of rho. But I got it to work using ODE45 now.

请先登录,再进行评论。

回答(0 个)

类别

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