solving differential equation system with ode45

2 ビュー (過去 30 日間)
sars sabina
sars sabina 2022 年 9 月 17 日
編集済み: sars sabina 2022 年 9 月 17 日
I have a system of second order diferential equations:
I would like to solve this system using ode45.
here is what i tried for solving the system:
function dYdt = odefcn(t,Y)
load STIFF_VALUES
load THETA
A=6.58e5;B=1.8;C_1=0.3083e-3;C_2=0.4439e-3;D=6.58e5;E=1.8;F=60e3;
G=51.6831;H=0.96e-1;I=F*30/25;J=70.4769;K=2e-1;M=67e-3;
L = interp1(THETA,STIFF_VALUES,t);
N=L*((Y(1)-Y(3))-(G*Y(5)-J*Y(7)))+M*((Y(2)-Y(4))-...
(G*Y(6)-J*Y(8)));
dYdt = [ Y(2);
1/C_1*(A*Y(1)+ B*Y(2)-N);
Y(4);
1/C_2*(-D*Y(3)- E*Y(4)+N);
Y(6);
1/H*(F+G*N);
Y(8);
1/K*(-I-J*N)];
end
init_cond = [0,0,0,0,0,2400,0,2000]';
t_interval=[0 10];
[t,y]=ode45(@(t,Y) odefcn(t,Y) , t_interval , init_cond);
I got NaN values for y(:,1).
*I tried "ode15s" which returns the following warning!
Warning: Failure at t=1.451171e-02. Unable to meet integration tolerances without reducing the
step size below the smallest value allowed (2.775558e-17) at time t.
  1 件のコメント
Torsten
Torsten 2022 年 9 月 17 日
The setup of the system for ODE45 looks correct.
So it remains to check the initial conditions and the model parameters.
You should load THETA and STIFF_VALUES in the program where you call ode45 and pass the arrays to the solver as
[t,y]=ode45(@(t,Y) odefcn(t,Y,THETA,STIFF_VALUES) , t_interval , init_cond);
...
function dYdt = odefcn(t,Y,THETA,STIFF_VALUES)
...
end
This saves time.
Further, take care that THETA(1) <= t <= THETA(end). Otherwise, interp1 will return NaN for L.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by