how to solve the problem of ode45 ?

1 visualización (últimos 30 días)
ADNAN
ADNAN el 9 de Jun. de 2023
Comentada: Walter Roberson el 9 de Jun. de 2023
Dear,
I have been working on a simple model. I used the ode45 solver, and one of my outputs doesn't make sense, I was wondering if is that due to the ode45 or a convergence-related issue. Can you please have a look at the very simple code attached here?
the question is that in the code, once I use C_n2=15*10^7, the result ("ALLACC") was supposed to be smaller than those of the C_n2=10^7 result ("ALLACC").
Is that due to ode45? or is it due to something else?
Can you please help me with that?
That would be much appreciated if you could help me.
for running the code, I attached the load file (INPUT.txt) too.
thanks again for your tuime.
Regards,
funcfile:
function [xdot]=funcfile(t,x, C_n2)
xdot=zeros(4,1);
global acc tspan m1 m2 k1 k2 c1 c2
z_t=interp1(tspan,acc,t,'spline');
%% [M]
m1=4.9814*10^6;
m2=3.4382*10^6;
%% [K]
k1=1.042585220149801*10^8;
k2=2.232017093496502*10^9;
%% [C]
c1=(1.065129353782337*10^7)+5.794706239147969*10^-4;
c2=1.443681417713320*10^7;
NOCo2=x(2)*x(4);
if NOCo2<0
NOD2=C_n2*x(4);
else
NOD2=0*x(4);
end
M=[m1 0;
0 m2];
C=[c1+c2 -c2;
-c2 c2];
K=[k1+k2 -k2;
-k2 k2];
Acc_m=[-m1 -m2]';
F=Acc_m.*z_t;
NOF=[0 NOD2]';
xdot(1:2)=x(3:end);
xdot(3:end)=inv(M)*(-C*x(3:end)-K*x(1:2)-NOF+F);
end
Mainfile:
clear all
clc
global acc tspan m2 k2 c2
dt=0.01;
load('INPUT.txt');
acc= (INPUT(:,2))';
t = (0:(length(acc)-1))*(dt);
t=(t');
u=[acc];
tspan=t';
z_t=interp1(tspan,acc,t,'spline');
x0=zeros(1,4);
C_n2=10^7; % first
% C_n2=15*10^7; % second
[t,x]=ode45(@funcfile,tspan,x0,[],C_n2 );
NOCo2 = x(:,2).*x(:,4);
NOD2 = C_n2*x(:,4).*(NOCo2 < 0) + 0*x(:,4).*(NOCo2 >= 0);
ACC2=(-m2.*z_t- NOD2-((-c2).*x(:,3)+c2.*x(:,4))- ...
((-k2).*x(:,1)+k2.*x(:,2)))./m2;
ALLACC=[ max(abs(ACC2)) ];
  6 comentarios
ADNAN
ADNAN el 9 de Jun. de 2023
thanks for your reply @Walter Roberson, can you please rewrite that part for me ? I could not figure it out. Thanks again.
Walter Roberson
Walter Roberson el 9 de Jun. de 2023
See ballode example.

Iniciar sesión para comentar.

Respuestas (0)

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by