How to implement tightly coupled nonlinear odes using ode45 in matlab?

4 ビュー (過去 30 日間)
Vikash Pandey
Vikash Pandey 2018 年 11 月 12 日
コメント済み: Huy Nguyen 2022 年 12 月 7 日
I am solving a problem from fluid dynamics; in particular tightly coupled nonlinear ordinary differential equations. The following is a scaled-down version of my actual problem. I have solved system of coupled odes many times in the past but this case is different since double derivatives of one variable depends on the double derivative of another variable. How do I implement it in ode45? I need 3 x 2 = 6 plots of x, x-dot and x-ddot versus time for t, 0 to 2. All required initial conditions have zero values at t = 0 How do I store the updated value of the double derivatives as the ode45 code runs? The way ode45 works, I get x and x-dot as output but not the double derivatives. Any help will be highly appreciated.
  8 件のコメント
Torsten
Torsten 2018 年 11 月 12 日
ydot(3)=y(3) and ydot(6)=y(6) ? Looks wrong to me.
Vikash Pandey
Vikash Pandey 2018 年 11 月 12 日
編集済み: Vikash Pandey 2018 年 11 月 12 日
@ Torsten, you may be correct. How do I fix that? What worries me is that if I change the initial conditions to initial_conditions = [2 1 0 4 3 0]; which means acceleration is zero for both x1 and x2 at t= 0. Then I get the following plots. x1,2 and x1,2-dot plots change, but x1,2-ddot plots do not show any sign of change at all. How is that possible? Velocity is changing but not the acceleration? There must be some bug in the code.
I cannot post more images, so I am putting up the links below.
https://postimg.cc/xJJknsmz
https://postimg.cc/DJ9SZqQY

サインインしてコメントする。

採用された回答

Torsten
Torsten 2018 年 11 月 12 日
Solve the equations
t*x2 - x1*x2' = t^2*x1 + x2*x1'
x1'' + x2'' = t*x2 - x1*x2'
Setting
y1 = x1
y2 = x1'
y3 = x2
y4 = x2'
you arrive at the system
y1' = y2
y2' + y4' = t*y3 - y1*y4
y3' = y4
y1'*y3 + y1*y3' = t*y3 - t^2*y1
Now either solve for y1', y2, y3' and y4' in each time step or use the mass matrix facility of the ODE solvers by writing your system as
M(t,y)*y' = F(t,y)
with
M = [1 0 0 0; 0 1 0 1; 0 0 1 0; y3 0 y1 0]
F = [y2;t*y3-y1*y4;y4;t*y3-t^2*y1]
Best wishes
Torsten.

その他の回答 (1 件)

Vikash Pandey
Vikash Pandey 2018 年 11 月 12 日
@ Torsent, Thanks. May be I should have formulated the problem little different as in this case, the double derivatives can be brought into one side. What if the equation was like this: Modified problem
  12 件のコメント
Sam Chak
Sam Chak 2022 年 12 月 6 日
Would advise you to post your specific problem in a New Question. Also to clarify whether it's a math-related problem or a technical problem in MATLAB code.
Huy Nguyen
Huy Nguyen 2022 年 12 月 7 日
hi, thanks for your reply. I fix the problem.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by