MATLAB Answers

How to solve a set of coupled odes that depend on derivatives

3 views (last 30 days)
charlie ryan
charlie ryan on 1 Jun 2020
Edited: David Goodmanson on 5 Jun 2020
Hello,
I have a set of nine coupled ode's, which are both dependent on each other, but also on their derivatives. They are attempting to solve a simulation of a plasma, and i am attempting to use ode45 to solve them (please see "LHS_model_V6.m").
The nine equations can be found in lines 108 to 143 of the attached "trialmodelsix.m" attached. My problem is that the ode's are not only dependent on the various parameters such as ion velocity, electron temperature, etc., but also on the derivative of them. In particular ode equations for xprime_1, xprime_2 and xprime_3 are dependent on xprime_4, whilst the ode for xprime_4 is dependent on xprime_1, xprime_2, and xprime_3. So ode45 can't solve them as xprime_4 is underfined.
Is there a way to set an initial condition for xprime_4, so that in the first iteration it is calculated from this value, and then after that from it's equation?
I know the equations are solvable, as i have rearranged them through substitution of the equations into the xprime_4 equation and then solved them using ode45. But this rearrangement is very labourious, and i am concerned that i have likely made some mistakes in the rearrangement.
Any help you can give is much appreciated,
Thanks,
Charlie

  2 Comments

James Tursa
James Tursa on 4 Jun 2020
Can you post the differential equations themselves for us to look at? E.g., as an image would be fine.

Sign in to comment.

Answers (1)

David Goodmanson
David Goodmanson on 4 Jun 2020
Edited: David Goodmanson on 5 Jun 2020
HI charlie,
dx4' depends on dx2' and dx3' explicitly. But since dOmega_e_dz and dV_e_dz are also in the expression for dx4', dx4' also depends on dx1', dx2' and dx3' implicitly.
Since dB_dz is calculated independently, it can be taken as known and 'constant' for the rest of the calculation. That leaves 8 differentials to solve for The equation has the form
[c 0 0 0 0 0 0 c [dx1 [w1
0 c 0 0 0 0 0 c dx2 .
0 0 c 0 0 0 0 c dx3 .
c c 0 c 0 0 0 0 x dVe = . or M*dvars = w
0 c c 0 c 0 0 0 dei .
c 0 c 0 0 c 0 0 den .
0 0 0 0 c c c 0 dOm .
0 c c c 0 0 c c] dx4] w8]
where the c's in the matrix are known constants, as are d1..d8. (The column vector dvariables/dz above has some obvious abbreviations). You can define all the constants c1..c23, set up the matrix M and column vector w, and then solve with
dvars = M\w;
If you prefer and the process seems worth it, the odetoVectorField process is a possibility.
As you are probably well aware, the use of global variables is highly discouraged since it is susceptible to weird behavior that can be very hard to debug.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by