Uploaded by Emad Kh

Lab-3 System dynamics

advertisement
REPORT
COURSE PROJECT
« System’s mathematical model reconstruction using incomplete data »
Course: System Dynamics
Author:
Emad Kerhily
Moscow, 2022
Recorded signal function
Option 1: у = šŸ. šŸ“ š¬š¢š§(š’™) + š’™šŸ
Mathematical Model
Form a time series: ai(iāˆ†t) = ai, I = 1, …, N, where N = 400 ÷ 500.
Line segment: t =[0;10]
ļƒ° āˆ†t = (tf-t0)/N = 0.02.
Reconstruction Options: n = 3, v = 3
State vector: š‘‹(š‘”) = [š‘Ž (š‘”),
š‘‘š‘Ž(š‘”) š‘‘2 š‘Ž(š‘”)
š‘‘š‘”
,
š‘‘š‘” 2
] = š‘“(š‘„1 , š‘„2 , š‘„3 )
Mathematical model of the system:
3
š‘“(š‘‹) =
∑
š‘™1 ,š‘™2 ,š‘™3 =0
3
3
š‘™
š‘š‘™1,š‘™2 ,š‘™3 ∏ š‘„š‘˜š‘˜ , ∑ š‘™š‘˜ ≤ 3
š‘˜=1
š‘˜=1
number of coefficients: k = (n + v)!/(n!v!) = 20
Mathematical model code <<ode45>>: systema.m
function f
global
f(1) =
f(2) =
= systema(~, x)
C;
x(2);
x(3);
f(3) = (C(1) + C(2)*x(1) + C(3)*x(2) + C(4)*x(3)+C(5)*x(1)*x(2) + C(6)* x(2)
*x(3) ...
+C(7)*x(1)*x(3) + C(8)*x(1)*x(1) + C(9)*x(2)*x(2)+C(10)*x(3)*x(3) ...
+C(11) * x(1)*x(2)*x(3) + C(12)*x(1)*x(1)*x(2) + C(13)*x(1)*x(1)*x(3) ...
+C(14)*x(1)*x(2)*x(2) + C(15)*x(2)*x(2)*x(3) + C(16)*x(1)*x(3)*x(3)...
+C(17)*x(2)*x(3)*x(3) + C(18)*x(1)*x(1)*x(1) + C(19)*x(2)*x(2)*x(2) ...
+C(20)*x(3)*x(3)*x(3));
f = f';
end
Main program code: model.m
t0 = 0;
tf = 10;
N = 500;
step = (tf-t0)/N;
syms x;
t = t0 : step : tf;
n = 3;
v = 3;
k = 20;
global C x1 x2 x3 x4;
y1 = zeros(1, N+1);
for i = 1 : N
y1(i) = 1.5 * sin(t(i)) + t(i)^2;
end
y2 = zeros(1, N+1);
y3 = zeros(1, N+1);
y4 = zeros(1, N+1);
x1
x2
x3
x4
=
=
=
=
zeros(k,1);
zeros(k,1);
zeros(k,1);
zeros(k,1);
C = zeros(1, k);
for i = 1 : N-1
y2(i) = (y1(i + 1) - y1(i)) / step;
end
for i = 1 : N-1
y3(i) = (y2(i + 1) - y2(i)) / step;
end
for i = 1 : N-1
y4(i) = (y3(i + 1) - y3(i)) / step;
end
for i = 0 : 19
x1(i+1) = y1( (i *(N/k)) + 1);
end
for i = 0 : 19
x2(i+1) = y2( (i *(N/k)) + 1);
end
for i = 0 : 19
x3(i+1) = y3( (i *(N/k)) + 1);
end
for i = 0 : 19
x4(i+1) = y4( (i *(N/k)) + 1);
end
A = zeros([k, k]);
for i = 1 : k
A(i, :) = [1 x1(i) x2(i) x3(i) x1(i)*x2(i) x2(i)*x3(i) x1(i)*x3(i) (x1(i))^2
(x2(i))^2
...
(x3(i))^2 x1(i)*x2(i)*x3(i) (x1(i))^2*x2(i) (x1(i))^2*x3(i) (x2(i))^2*x1(i)
...
(x2(i))^2*x3(i) (x3(i))^2*x1(i) (x3(i))^2*x2(i) (x1(i))^3 (x2(i))^3 (x3(i))^3];
end
C = A \ x4;
[~, s] = ode45('systema', t, [x1(1) x2(1) x3(1)]);
Y1 = s(:, 1);
figure
plot(t,Y1,'-r', t,y1,'-g');
title('The graphic of reconstructed model and original function')
legend({'reconstructed', 'original'}, 'Location', 'northeast', 'FontSize',11);
grid on;
Y2 = s(:, 2);
figure
plot(Y1,Y2,'-r', y1,y2,'-g');
title('Phase portraits')
legend({'reconstructed', 'original'}, 'Location', 'northeast', 'FontSize',11);
grid on;
By executing the programs, we get the:
1. image of the original;
2. reconstructed signals, phase portraits.
Conclusion
During the laboratory work, the following tasks were performed:
1 - model parameters are selected;
2- signal reconstruction based on the vector of state variables has been
developed.
3- system reconstruction was implemented using ode45 in MatLab and
compared with the original model.
As a result: the reconstructed signal graph has a shape and phase similar to the
original ones. The similarity of the phase portraits shows the high accuracy of the
constructed model due to the carefully selected parameters n, v and the time step āˆ†t.
Download