Professional Documents
Culture Documents
Discreption: ............................................................................................................... 1
Specification of Number of Boundary, force & measurement nodes ...................................... 1
Elimination of fixed points ............................................................................................ 2
Guyan Reduction of the massless rotational DOFs ............................................................. 2
Generating (A,B,C,D)of the Full Sys. .............................................................................. 2
Butterworth Filter Design ............................................................................................. 3
Response of Orginal .................................................................................................... 4
Balanced Truncation .................................................................................................... 6
Frequency Weighted Truncation .................................................................................... 8
Further Reduction Based on Akaike-like Criterion ........................................................... 11
Speedy Model Reduction ............................................................................................ 13
Bal. Trunc. For Distributed Load .................................................................................. 15
Appendix- subfunctions .............................................................................................. 19
Discreption:
This function is Written By Majid Khorsand Vakilzadeh
function Main
clc
clear
load Aluminum_Plate.mat
NDOFN = 6;
Ts = 1e-4;
Tf = (size(u0,2)-1)*1e-4;
%--------------------------------------------------------------------------
boundary
boundary
boundary
boundary
condition
condition
condition
condition
%Should be Verified
NdForce = cor2node([.125,.25,0],XYZ)-4;
% Node# of force
% ------------------------------------------------------------------------1
% -------------------------------------------------------------------------
% -------------------------------------------------------------------------
NuDOF = size(Kgr,1);
% Number of Degrees of freedom
[A,B1,Z]=kcm2ab(Kgr,Vgr,Mgr,NuDOF);
Tu = zeros(size(B1,2),1);Tu(NdForce*3,1) = 1; B = B1*Tu; % Tu is a map between for
C1 = zeros(3,size(B,1)); C1(1,NuDOF+NdA(1)*3)=1;
C1(2,NuDOF+NdA(2)*3)=1; C1(3,NuDOF+NdA(3)*3)=1;
C = C1 * A;
D = C1 * B;
EigA = sort(eig(full(A)));
disp(['The first five eigenvalues of the Full system is: '...
,num2str(EigA(1)),' ',num2str(EigA(2)),' ',num2str(EigA(3))...
,' ',num2str(EigA(4)),' ',num2str(EigA(5)),'.'])
disp(' ')
2
% -------------------------------------------------------------------------
The first five eigenvalues of the Full system is: -0.00148178-44.3121i -0.00148178+
Response of Orginal
-------------------
Osys = ss(A,B,C,D);
tic
Osysd = c2d(Osys,Ts);
% Discretization of the Full system
td = toc;
disp(['The simulation time for discretization of Full system is: ',num2str(td),' Se
tic
Y_Or = RespDisSys(Osysd.a,Osysd.b,Osysd.c,Osysd.d,u1,Ts);
t_or = toc;
disp(['The simulation time to obtain Y (response of full Sys.): ',num2str(t_or),' S
for i=1:3
% Computation of
FNY_Or(i) = norm(Y_Or(i,:),'fro');
end
disp(['The Frobenius norm of y1 (Full Sys.) is:
disp(['The Frobenius norm of y2 (Full Sys.) is:
disp(['The Frobenius norm of y3 (Full Sys.) is:
TotFNY_Or = norm(Y_Or,'fro');
figure
subplot(3,1,1);plot(T,Y_Or(1,:));ylabel('y1');
title('The response of the full system of order 1710')
subplot(3,1,2);plot(T,Y_Or(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_Or(3,:));ylabel('y3');xlabel('time(sec)')
figure
4
bode(Osysd)
title('The Bode plot of the discretized Full System')
% ------------------------------------------------------------------------Warning: The "a" matrix was converted from sparse to full.
The simulation time for discretization of Full system is: 3.5593 Sec
The simulation time to obtain Y (response of full Sys.): 16.3461 Sec
The Frobenius norm of y1 (Full Sys.) is: 8058.0612.
The Frobenius norm of y2 (Full Sys.) is: 6704.0235.
The Frobenius norm of y3 (Full Sys.) is: 4133.3353.
Balanced Truncation
------------------Coef = 1e-4;
% The ratio of the cutting gramian and the biggest gramian
tic
[Tsys, tre] = BalTrunc(Osysd,Coef,Ts);
t_b = toc;
fprintf('The number of retained states is: %4.1f ',size(Tsys.a,1))
tic
[Y_BTr] = RespDisSys(Tsys.a,Tsys.b,Tsys.c,Tsys.d,u1,Ts);
t_BTTr = toc;
disp(['The simulation time to obtain Y (response of Bal. Trunc. Sys.): ',num2str(t_
for i=1:3
% Computation
FNY_BTr(i) = norm(Y_BTr(i,:),'fro');
end
disp(['The Frobenius norm of y1 (Bal. Trunc.
disp(['The Frobenius norm of y2 (Bal. Trunc.
disp(['The Frobenius norm of y3 (Bal. Trunc.
TotFNY_BTr = norm(Y_BTr,'fro');
BTerr = Y_Or - Y_BTr;
% Computation of Error
for i=1:3
% Computation of Frobenius norm of full Sys.
FN_BTerr(i) = norm(BTerr(i,:),'fro');
end
disp(['The Frobenius norm of error1 is: ',num2str(FNY_BTr(1)),'.'])
6
tic
OutSysW = ss(-.8*eye(16),zeros(16,3),zeros(3,16),eye(3),1e-4);
FWBSys = Dis_FWBalancing(Tsys,BuSys,OutSysW,Ts);
% Frequency Weighted Balance
TFWBSys = FWBSys;
FNFWerr = 0;
while FNFWerr < .02 * TotFNY_Or
ind1 = [size(TFWBSys.a,2)-1,size(TFWBSys.a,2)];
% Indices for model reductio
TFWBSys = modred(TFWBSys,ind1,'MatchDC');
% Model order reduction using t
[Y_FWred] = RespDisSys(TFWBSys.a,TFWBSys.b,TFWBSys.c,TFWBSys.d,u1,Ts); %Resp o
FWerr = Y_Or - Y_FWred;
% Computation of Error
FNFWerr = norm(FWerr,'fro'); % Frobenius Norm of Balanced Truncated Sys.
end
t_FWBT = toc;
disp(['The simulation time for Further reduction with FWB method & to obtain its Y
figure
bode(TFWBSys)
title('The Bode plot of the FWBSystem')
% --- Plot of response of Full Sys.,Trun. Sys. --T = 0:1e-4:Tf;
figure
subplot(3,1,1);plot(T,Y_FWred(1,:));ylabel('y1');
title('The response of the Fre. Wieghted Bal. Trunc. system of order 182')
8
subplot(3,1,2);plot(T,Y_FWred(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_FWred(3,:));ylabel('y3');xlabel('Time(sec)')
figure
subplot(3,1,1);plot(T,FWerr(1,:));ylabel('e1');
title('The Error between Full Sys. & Fre. Weighted Bal. Trunc. Sys.')
subplot(3,1,2);plot(T,FWerr(2,:));ylabel('e2');
subplot(3,1,3);plot(T,FWerr(3,:));ylabel('e3');xlabel('Time(sec)')
% ------------------------------------------------------------------------%
Analyzing the performance of FWBT Sys.
%
---------------------------------------
G1 = [size(TFWBSys.a,2)+1:size(Tsys.a,1)];
FurTofBSys = modred(Tsys,G1,'MatchDC');
TFWBSys_Cont = d2c(TFWBSys);
FurTofBSys_Cont = d2c(FurTofBSys);
Tsys_Cont = d2c(Tsys);
Eval_1 = sort(imag(eig(FurTofBSys_Cont.a)))./2./pi;G_1 = find(Eval_1>500);
Eval_2 = sort(imag(eig(TFWBSys_Cont.a)))./2./pi;G_2 = find(Eval_2>500);
Eval_3 = sort(imag(eig(Tsys_Cont)))./2./pi;G_3 = find(Eval_3>500);
figure
stem(Eval_3(length(Eval_3)/2+1:end),1.1*ones(length(Eval_3(length(Eval_3)/2+1:end))
stem(Eval_1(length(Eval_1)/2+1:end),1*ones(length(Eval_1(length(Eval_1)/2+1:end))),
stem(Eval_2(length(Eval_2)/2+1:end),.9*ones(length(Eval_2(length(Eval_2)/2+1:end)))
title(['# of eigs above 500Hz: ', 'black-Full Sys.: ',num2str(length(G_3)),'green,B
% -------------------------------------------------------------------------
The simulation time for Further reduction with FWB method & to obtain its Y is: 4.1
10
Akaike_Cost =[];
i = 0;
for j = length(TFWBSys.a(:,1)):-2:4
i = i+1;
ind2 = [size(TFWBSys_A.a,2)-1,size(TFWBSys_A.a,2)];
TFWBSys_A = modred(TFWBSys_A,ind2,'MatchDC');
% Model order reduction usi
[Y_FWredA] = RespDisSys(TFWBSys_A.a,TFWBSys_A.b,TFWBSys_A.c,TFWBSys_A.d,u1,Ts);
FWerrA = Y_Or - Y_FWredA;
FNFWerrA(i) = norm(FWerrA,'fro'); % Frobenius Norm of Balanced Truncated Sys.
Akaike_Cost(i) = W_y*FNFWerrA(i) + W_n*size(TFWBSys_A.a,1)^2; % Akaike like cr
end
t_FWA = toc;
disp(['The simulation time for computation of the series of akaike-like criterion i
ir = length(TFWBSys.a(:,1)):-2:4;
figure
plot(ir,Akaike_Cost(:),'r *')
xlabel('State Number');ylabel('Value of Akaike-like criterion')
11
Min_A = min(Akaike_Cost);
Min_ind = find(Akaike_Cost==Min_A);
L_order = ir(Min_ind);
disp(['Order of system with min Akaike-like criterion: ', num2str(L_order)]);
ind2 = [L_order+1:size(TFWBSys.a,2)];
TFWBSys_A = modred(TFWBSys,ind2,'MatchDC');% Model order red. using MatchDC
[Y_FWredA]= RespDisSys(TFWBSys_A.a,TFWBSys_A.b,TFWBSys_A.c,TFWBSys_A.d,u1,Ts);
figure
subplot(3,1,1);plot(T,Y_FWredA(1,:));ylabel('y1');
title('The response of truncated Sys. With min Akaike-like criterion')
subplot(3,1,2);plot(T,Y_FWredA(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_FWredA(3,:));ylabel('y3');xlabel('Time(sec)')
% -------------------------------------------------------------------------
The simulation time for computation of the series of akaike-like criterion is: 3.68
Order of system with min Akaike-like criterion: 142
12
tic
[Evec,Eval] = eigs(Kgr,Mgr,200,'SM');
% 200 lowest frequency eigenmodes
t_Eig = toc;
disp(['The simulation time to solve eigenvalue problem is: ',num2str(t_Eig),' s.'])
subplot(3,1,1);plot(T,Y_S(1,:));ylabel('y1');
title('The response of Bal. Trunc. Sys. of the modally reduced system & the order i
subplot(3,1,2);plot(T,Y_S(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_S(3,:));ylabel('y3');xlabel('Time(sec)')
% ------------------------------------------------------------------------The simulation time to solve eigenvalue problem is: 0.66206 s.
The simulation time to balance the full system: 1.2775 Sec
Time for balancing&truncation of the modally reduced system is: 1.2993 Sec
Warning: Imaginary parts of complex X and/or Y arguments ignored
Warning: Imaginary parts of complex X and/or Y arguments ignored
Warning: Imaginary parts of complex X and/or Y arguments ignored
14
subplot(3,1,3);plot(T,Y2(3,:)); ylabel('y3');
xlabel('time(sec)')
figure
subplot(3,1,1);plot(T,TBY2(1,:));ylabel('y1');
title(['Response of truncated system of order: ',TSOrd,'(Distributed Load'])
subplot(3,1,2);plot(T,TBY2(2,:));ylabel('y2');
subplot(3,1,3);plot(T,TBY2(3,:));ylabel('y3');
xlabel('time(sec)')
16
17
18
end
% -------------------------------------------------------------------------
Appendix- subfunctions
---------------------function NdI = cor2node(NdC,XYZ)
NdI = 0;
for i = 1:size(XYZ,1)
NdN = find(NdC==XYZ(i,:));
if size(NdN,2) == 3
NdI = i;
end
end
if NdI == 0
fprintf('The Coordination matrix does not contain this node')
end
end
function [Y1] = RespDisSys(A,B,C,D,u,Ts)
X = ltitr(A,B,u'); % Response of Original
Y1 = C*X'+D*u;
end
system to u0
zeros(size(SYS.a,1),size(OutW.a,2))
OutW.a
];
OutW.c];
20