Differential algebraic eqn solving using ode15s

2 Ansichten (letzte 30 Tage)
Jagadeesh Korukonda
Jagadeesh Korukonda am 27 Feb. 2022
I've a 6Differential_Equations's and 6Algebraic_Equations's, with initial condition.
when I'm excecuting the code i'm getting error, which is given in the below image.
Thanks in advance😁
global G0 N0 v0;
G0 = 1; N0 = 1; v0 = 1;
L10 = 1; L20 = 2; L30 = 3;
w10 = 0.1; w20 = 0.2; w30 = 1- w10 -w20;
for i = 1:6
mu0(i) = w10*L10^i + w20*L20^i + w30*L30^i;
end
y0 = [mu0 w10 w20 w30 L10 L20 L30];
M = [eye(6),zeros(6);zeros(6,12)];
options = odeset('Mass',M,'RelTol',1e-4,'AbsTol',1e-6*ones(1,12));
tspan = linspace(0,1,10000);
[t,m] = ode15s(@myfun,tspan,y0,options);
Warning: Failure at t=7.186798e-01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.776357e-15) at time t.
function F = myfun(~,y)
global G0
mu0 = y(1); mu1 = y(2); mu2 = y(3); mu3 = y(4); mu4 = y(5); mu5 = y(6);
w1 = y(7); w2 = y(8); w3 = y(9); l1 = y(10); l2 = y(11); l3 = y(12);
F = zeros(12,1);
%Differential Equations
F(1) = 0;
F(2) = G0*(w1/l1 + w2/l2 + w3/l3);
F(3) = 2*G0*(w1 + w2 + w3);
F(4) = 3*G0*(l1*w1 + l2*w2 + l3*w3);
F(5) = 4*G0*(w1*l1^2 + w2*l2^2 + w3*l3^2);
F(6) = 5*G0*(w1*l1^3 + w2*l2^3 + w3*l3^3);
%Algebraic equations
F(7) = w1 + w2 + w3 - mu0;
F(8) = l1*w1 + l2*w2 + l3*w3 - mu1;
F(9) = w1*l1^2 + w2*l2^2 + w3*l3^2 - mu2;
F(10) = w1*l1^3 + w2*l2^3 + w3*l3^3 - mu3;
F(11) = w1*l1^4 + w2*l2^4 + w3*l3^4 - mu4;
F(12) = w1*l1^5 + w2*l2^5 + w3*l3^5 - mu5;
end

Antworten (1)

Torsten
Torsten am 27 Feb. 2022
for i = 0:5
mu0(i+1) = w10*L10^i + w20*L20^i + w30*L30^i;
end
instead of
for i = 1:6
mu0(i) = w10*L10^i + w20*L20^i + w30*L30^i;
end
  3 Kommentare
Torsten
Torsten am 27 Feb. 2022
By the way your suggestion is not valid in my problem because,
Mu0(1) = W1 + W2 + W3,
IF I change according to your response it will be different
Mu0(1) = W1*L1 + W2*L2 + W3*L3
Wrong. You get
Mu0(1) = W1*L1 + W2*L2 + W3*L3
if you don't make the change according to my suggestion.
And for me, your code is working fine after the correction.
Jagadeesh Korukonda
Jagadeesh Korukonda am 27 Feb. 2022
Really, can you please send data file in .mat format.
My mail address is kjagadeesh817@gmail.com
But, I'm surprised why it is not working in my matlab?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by