152 lines
5.0 KiB
Matlab
152 lines
5.0 KiB
Matlab
%% Clear Workspace and Close figures
|
|
clear; close all; clc;
|
|
|
|
%% Intialize Laplace variable
|
|
s = zpk('s');
|
|
|
|
%% Path for functions, data and scripts
|
|
addpath('./mat/'); % Path for data
|
|
|
|
%% Colors for the figures
|
|
colors = colororder;
|
|
|
|
%% Load frequency response matrix
|
|
load('frf_matrix.mat', 'freqs', 'frf');
|
|
|
|
%% Computation of the modal indication function
|
|
MIF = zeros(size(frf, 2), size(frf, 2), size(frf, 3));
|
|
|
|
for i = 1:length(freqs)
|
|
[~,S,~] = svd(frf(:, :, i));
|
|
MIF(:, :, i) = S'*S;
|
|
end
|
|
|
|
%% Modal Indication Function
|
|
figure;
|
|
hold on;
|
|
for i = 1:size(MIF, 1)
|
|
plot(freqs, squeeze(MIF(i, i, :)), 'DisplayName', sprintf('MIF${}_%i$', i));
|
|
end
|
|
hold off;
|
|
set(gca, 'Xscale', 'lin'); set(gca, 'Yscale', 'log');
|
|
xlabel('Frequency [Hz]'); ylabel('CMIF Amplitude');
|
|
xticks([0:20:200]);
|
|
xlim([0, 200]);
|
|
ylim([1e-6, 2e-2]);
|
|
ldg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 1);
|
|
|
|
%% Load modal parameters
|
|
shapes_m = readtable('mat/mode_shapes.txt', 'ReadVariableNames', false); % [Sign / Real / Imag]
|
|
freqs_m = table2array(readtable('mat/mode_freqs.txt', 'ReadVariableNames', false)); % in [Hz]
|
|
damps_m = table2array(readtable('mat/mode_damps.txt', 'ReadVariableNames', false)); % in [%]
|
|
modal_a = table2array(readtable('mat/mode_modal_a.txt', 'ReadVariableNames', false)); % [Real / Imag]
|
|
modal_b = table2array(readtable('mat/mode_modal_b.txt', 'ReadVariableNames', false)); % [Real / Imag]
|
|
|
|
%% Guess the number of modes identified from the length of the imported data.
|
|
acc_n = 23; % Number of accelerometers
|
|
dir_n = 3; % Number of directions
|
|
dirs = 'XYZ';
|
|
|
|
mod_n = size(shapes_m,1)/acc_n/dir_n; % Number of modes
|
|
|
|
%% Mode shapes are split into 3 parts (direction plus sign, real part and imaginary part)
|
|
% we aggregate them into one array of complex numbers
|
|
T_sign = table2array(shapes_m(:, 1));
|
|
T_real = table2array(shapes_m(:, 2));
|
|
T_imag = table2array(shapes_m(:, 3));
|
|
|
|
mode_shapes = zeros(mod_n, dir_n, acc_n);
|
|
|
|
for mod_i = 1:mod_n
|
|
for acc_i = 1:acc_n
|
|
% Get the correct section of the signs
|
|
T = T_sign(acc_n*dir_n*(mod_i-1)+1:acc_n*dir_n*mod_i);
|
|
for dir_i = 1:dir_n
|
|
% Get the line corresponding to the sensor
|
|
i = find(contains(T, sprintf('%i%s',acc_i, dirs(dir_i))), 1, 'first')+acc_n*dir_n*(mod_i-1);
|
|
mode_shapes(mod_i, dir_i, acc_i) = str2num([T_sign{i}(end-1), '1'])*complex(T_real(i),T_imag(i));
|
|
end
|
|
end
|
|
end
|
|
|
|
%% Create the eigenvalue and eigenvector matrices
|
|
eigen_val_M = diag(2*pi*freqs_m.*(-damps_m/100 + j*sqrt(1 - (damps_m/100).^2))); % Lambda = diagonal matrix
|
|
eigen_vec_M = reshape(mode_shapes, [mod_n, acc_n*dir_n]).'; % Phi, vecnorm(eigen_vec_M) = 1
|
|
|
|
% Add complex conjugate eigenvalues and eigenvectors
|
|
eigen_val_ext_M = blkdiag(eigen_val_M, conj(eigen_val_M));
|
|
eigen_vec_ext_M = [eigen_vec_M, conj(eigen_vec_M)];
|
|
|
|
%% "Modal A" and "Modal B" matrices
|
|
modal_a_M = diag(complex(modal_a(:, 1), modal_a(:, 2)));
|
|
modal_b_M = diag(complex(modal_b(:, 1), modal_b(:, 2)));
|
|
|
|
modal_a_ext_M = blkdiag(modal_a_M, conj(modal_a_M));
|
|
modal_b_ext_M = blkdiag(modal_b_M, conj(modal_b_M));
|
|
|
|
%% Synthesize the full FRF matrix from the modal model
|
|
Hsyn = zeros(acc_n*dir_n, acc_n*dir_n, length(freqs));
|
|
|
|
for i = 1:length(freqs)
|
|
Hsyn(:, :, i) = eigen_vec_ext_M*diag(1./(diag(modal_a_ext_M).*(j*2*pi*freqs(i) - diag(eigen_val_ext_M))))*eigen_vec_ext_M.';
|
|
end
|
|
|
|
%% Derivate two times to have the acceleration response
|
|
for i = 1:size(Hsyn, 1)
|
|
Hsyn(i, :, :) = squeeze(Hsyn(i, :, :)).*(j*2*pi*freqs).^2;
|
|
end
|
|
|
|
acc_o = 11; dir_o = 3;
|
|
acc_i = 11; dir_i = 3;
|
|
|
|
figure;
|
|
hold on;
|
|
plot(freqs, abs(squeeze(frf( 3*(acc_o-1)+dir_o, dir_i, :))), 'DisplayName', 'Measured');
|
|
plot(freqs, abs(squeeze(Hsyn(3*(acc_o-1)+dir_o, 3*(acc_i-1)+dir_i, :))), 'DisplayName', 'Synthesized');
|
|
hold off;
|
|
set(gca, 'xscale', 'lin');
|
|
set(gca, 'yscale', 'log');
|
|
xlabel('Frequency [Hz]');
|
|
ylabel('Magnitude [$\frac{m/s^2}{N}$]');
|
|
ldg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 1);
|
|
ldg.ItemTokenSize = [10, 1];
|
|
xticks([0:40:200]);
|
|
xlim([1, 200]);
|
|
ylim([1e-6, 1e-1]);
|
|
|
|
acc_o = 15; dir_o = 3;
|
|
acc_i = 11; dir_i = 3;
|
|
|
|
figure;
|
|
hold on;
|
|
plot(freqs, abs(squeeze(frf( 3*(acc_o-1)+dir_o, dir_i, :))), 'DisplayName', 'Measured');
|
|
plot(freqs, abs(squeeze(Hsyn(3*(acc_o-1)+dir_o, 3*(acc_i-1)+dir_i, :))), 'DisplayName', 'Synthesized');
|
|
hold off;
|
|
set(gca, 'xscale', 'lin');
|
|
set(gca, 'yscale', 'log');
|
|
xlabel('Frequency [Hz]');
|
|
ylabel('Magnitude [$\frac{m/s^2}{N}$]');
|
|
ldg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 1);
|
|
ldg.ItemTokenSize = [10, 1];
|
|
xticks([0:40:200]);
|
|
xlim([1, 200]);
|
|
ylim([1e-6, 1e-1]);
|
|
|
|
acc_o = 2; dir_o = 1;
|
|
acc_i = 11; dir_i = 2;
|
|
|
|
figure;
|
|
hold on;
|
|
plot(freqs, abs(squeeze(frf( 3*(acc_o-1)+dir_o, dir_i, :))), 'DisplayName', 'Measured');
|
|
plot(freqs, abs(squeeze(Hsyn(3*(acc_o-1)+dir_o, 3*(acc_i-1)+dir_i, :))), 'DisplayName', 'Synthesized');
|
|
hold off;
|
|
set(gca, 'xscale', 'lin');
|
|
set(gca, 'yscale', 'log');
|
|
xlabel('Frequency [Hz]');
|
|
ylabel('Magnitude [$\frac{m/s^2}{N}$]');
|
|
ldg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 1);
|
|
ldg.ItemTokenSize = [10, 1];
|
|
xticks([0:40:200]);
|
|
xlim([1, 200]);
|
|
ylim([1e-6, 1e-1]);
|