How to compute the following set of ODEs with ICs

  • MATLAB
  • Thread starter JD_PM
  • Start date
  • Tags
    Odes Set
In summary, it sounds like you're trying to solve a set of first order ODEs, but you're getting an error. Are the initial conditions you're using not enough?
  • #1
JD_PM
1,131
158
TL;DR Summary
I am trying to solve the following set of 5 first order ODEs with ICs but I get an error output "invalid ICs". What am I missing?
I am trying to solve the following set of 5 first order ODEs

_4273638764614964716431694138.png


Where the variables are ##\Theta_0, \Theta_1, \Phi, \delta## and ##v##. The initial conditions (ICs) are

InitialConditions.png


(Note that there is a typo in the above ICs; it is ##v## instead of ##u##). I am following this solved sample, following the exact same steps. However I get an error

jhhfuisqhdfhuiqhdsipdqshfuqds.png

Are these 3 ICs not enough?

Thank you! :biggrin:
 

Attachments

  • jhhfuisqhdfhuiqhdsipdqshfuqds.png
    jhhfuisqhdfhuiqhdsipdqshfuqds.png
    6.5 KB · Views: 179
Physics news on Phys.org
  • #2
Your notation isn't clear, at least not to me. If [itex]\Theta_{0}[/itex] and [itex]\Theta_{1}[/itex] are the variables, what are [itex]\Theta_{r,0}[/itex] and [itex]\Theta_{r,1}[/itex]? Also, isn't a a variable as well? There is an [itex]\dot{a}[/itex] term.
 
  • Like
Likes JD_PM
  • #3
Sorry, let me clarify

phyzguy said:
Your notation isn't clear, at least not to me. If [itex]\Theta_{0}[/itex] and [itex]\Theta_{1}[/itex] are the variables, what are [itex]\Theta_{r,0}[/itex] and [itex]\Theta_{r,1}[/itex]?

I dropped the subscript ##r##. For our purpose, we can simply work with ##\Theta_{0}## and ##\Theta_{1}##.

phyzguy said:
Also, isn't a a variable as well? There is an [itex]\dot{a}[/itex] term.

Right but let us assume that the ##a## function barely changes w.r.t. time, so that ##\dot a## is a constant
 
  • #4
OK. Then I have one question and one suggestion. Your initial conditions are written as though they are true for all values of t (I'm assuming the independent variable is t). Is this right, or are they only true at t=0? If they are only true at t=0, did you specify it this way when you entered it into the code? It would be easier for us to understand if you share the code you entered. As for the suggestion, why not use the first two equations to eliminate [itex]\Phi[/itex] as a variable and get down to just four variables?
 
  • Like
Likes JD_PM
  • #5
phyzguy said:
OK. Then I have one question and one suggestion. Your initial conditions are written as though they are true for all values of t (I'm assuming the independent variable is t). Is this right, or are they only true at t=0? If they are only true at t=0, did you specify it this way when you entered it into the code? It would be easier for us to understand if you share the code you entered.

I worked with ICs at ##t=0##. Let me share the code

Matlab:
syms u(t) v(t) w(t) x(t) y(t) a b d G k %Note that u corresponds to the variable v (see #1), v to \delta, w to \Theta_0, x to \Theta_1, y to \Phi and b to \dot a%

ode1 = diff(w) + diff(y) == -k*x;
ode2 = diff(x) == (k*w)/3 - (k*y)/3;
ode3 = diff(v) + 3*diff(y) == i*k*u;
ode4 = diff(u) == i*k*y - (b*u)/a;
ode5 = (3*b*(diff(y) + (b*y)/a))/a == 4*G*a^2*d*pi*v - k^2*y + 16*G*a^2*d*pi*w;
odes = [ode1; ode2; ode3; ode4; ode5]
[uSol(t), vSol(t), wSol(t), xSol(t), ySol(t)] = dsolve(odes) %Code works, yielding quite "ugly" answers. Next we introduce ICs%

cond1 = x(0) - i*(u(0))/3 == 0;
cond2 = v(0) - 3*w(0) == 0;
cond3 = y(0) - 2*w(0) == 0;
conds = [cond1; cond2; cond3];
[uSol(t), vSol(t), wSol(t), xSol(t), ySol(t)] = dsolve(odes,conds) %Code breaks down, giving the output "Invalid initial conditions"%
 
  • #6
Hmm, I'm not sure, but I do notice two things:
(1) I think your ode3 should be diff(v) + 3*diff(y) == - i*k*u;, no? You have the sign wrong.
(2) You have used the symbol d for both [itex] \rho_{DM}[/itex] and [itex] \rho[/itex] in the last equation. Is that your untent?

I think the code is telling you that you initial conditions are inconsistent. What if you try taking the "ugly" solution you got without the initial conditions and apply the initial conditions one at a time?
 
  • #7
Thanks @phyzguy for the help, I am going to look for more material to read, understand the problem further and then come back.
 
  • #8
I'm stuggling with a similar problem! Any updates on this thread @JD_PM? or @phyzguy? I've also posted my version of this question on ths forum.

I already found that the above method won't work, because this supposes an analytical solution can be found in Matlab. We'll need to implement a numerical solution, and we'll have to use the ode45 function or similar in Matlab.
 
Last edited:

FAQ: How to compute the following set of ODEs with ICs

What are ODEs and what are ICs?

ODEs (Ordinary Differential Equations) are mathematical equations that describe the relationship between a function and its derivatives. ICs (Initial Conditions) are the values of the function and its derivatives at a specific starting time or point.

How do I compute a set of ODEs with ICs?

To compute a set of ODEs with ICs, you can use numerical methods such as Euler's method, Runge-Kutta method, or any other suitable method depending on the complexity of the equations. You can also use software programs like MATLAB or Python to solve the equations numerically.

What are the steps involved in computing a set of ODEs with ICs?

The steps involved in computing a set of ODEs with ICs include identifying the ODEs, determining the initial conditions, choosing a suitable numerical method, setting up the equations in the chosen method, and solving the equations to obtain the solution.

Are there any limitations to computing a set of ODEs with ICs?

Yes, there are limitations to computing a set of ODEs with ICs. The complexity of the equations, the choice of numerical method, and the accuracy of the initial conditions can affect the accuracy of the computed solution. In some cases, the equations may also be impossible to solve analytically or numerically.

How can I check the accuracy of the computed solution for a set of ODEs with ICs?

To check the accuracy of the computed solution, you can compare it with known analytical solutions (if available) or vary the initial conditions and observe the changes in the solution. You can also use error analysis to determine the accuracy of the numerical method used to solve the equations.

Similar threads

Replies
5
Views
2K
Replies
4
Views
3K
Replies
2
Views
1K
Replies
1
Views
3K
Replies
2
Views
5K
Replies
9
Views
2K
Replies
4
Views
4K
Replies
2
Views
3K
Back
Top