Prediction of Dynamic Magnification factor (DMF) and acceleration transfer function (Tf_tf) curves based on data provided from the numerical model using neural networks.

22 views (last 30 days)
So This is the code which i used to produce data of Dynamic magnification factor (DMF) and acceleration transfer functions (Tf_tf) in graph format/curves for different pairs of wtd and zeta_td for a SDOF with a Tuned Mass Damper System. I've take just 101 data just to understand the behavior. Now I need to make a neural network model which can predict the curves for a different pair of wtd and zeta_td. How can I do it? The input data should be wtd, zeta_td and output should be DMF and Tf_tf curves.
% Data for SDOF Structure with TMD - Frequency response analysis
clc;
clear all;
% Number of Data Required to extract
l=101
l = 101
% Structure information
M_str = 10^3*[179]; % Kg % Structure Mass
K_str = 10^6*[62.47]; % N/m % Structure Stiffness
C_str = 10^6*[0.81]; % Ns/m % Structure Damping coefficient
% TMD information
mass_ratio = 0.03; % Mass ratio for TMD
mtd = mass_ratio*sum(M_str); % TMD Mass
mtd = 5370
wtd = linspace(0,100,l); % natural frequency range for TMD in rad/s
zeta_td = linspace(0,0.1,l); % Damping ratio range for TMD
ktd = mtd.*wtd.^2; % Stiffness of the TMD
ctd = 2*zeta_td.*sqrt(ktd*mtd); % Damping Coefficient of the TMD
% Initialize empty arrays for m_data, k_data and c_data
m_data = zeros(l, length(M_str) + 1); % Matrix to store m values
k_data = zeros(l, length(K_str) + 1); % Matrix to store k values
c_data = zeros(l, length(C_str) + 1); % Matrix to store c values
% Loop to add mtd, ktd and ctd values to m, k and c lists
for i = 1:l
m_data(i, :) = [M_str, mtd]; % Add each mtd to the m list
k_data(i, :) = [K_str, ktd(i)]; % Add each ktd(i) to the k list
c_data(i, :) = [C_str, ctd(i)]; % Add each ctd(i) to the c list
end
% % Display the results
% disp('m_data:');
% disp(m_data);
% disp('k_data:');
% disp(k_data);
% disp('c_data:');
% disp(c_data);
% Mass, Stiffness and Damping Matrices
% Initialize a cell array to store the stiffness matrices
M_matrices = cell(l, 1); % Cell array to store l mass matrices
K_matrices = cell(l, 1); % Cell array to store l stiffness matrices
C_matrices = cell(l, 1); % Cell array to store l damping matrices
% Loop to generate the stiffness, damping, and mass matrices for each row
for row = 1:l
m_row = m_data(row, :); % Get the m values for the current row
k_row = k_data(row, :); % Get the k values for the current row
c_row = c_data(row, :); % Get the c values for the current row
% Number of degrees of freedom (n x n matrix size)
n_m = length(m_row);
n_k = length(k_row);
n_c = length(c_row);
% Initialize mass matrix for the current row (n x n)
M = diag(m_row); % Mass matrix as a diagonal matrix using m_data
M_matrices{row} = M; % Store the mass matrix in the cell array
% Initialize stiffness matrix for the current row (n x n)
K = zeros(n_k);
% Fill the stiffness matrix for the current row
for i = 1:n_k
if i < n_k
K(i, i) = k_row(i) + k_row(i+1); % Diagonal element
K(i, i+1) = -k_row(i+1); % Upper off-diagonal
K(i+1, i) = -k_row(i+1); % Lower off-diagonal
else
K(i, i) = k_row(i); % Last diagonal element
end
end
K_matrices{row} = K; % Store the stiffness matrix in the cell array
% Initialize damping matrix for the current row (n x n)
C = zeros(n_c);
% Fill the damping matrix for the current row
for i = 1:n_c
if i < n_c
C(i, i) = c_row(i) + c_row(i+1); % Diagonal element
C(i, i+1) = -c_row(i+1); % Upper off-diagonal
C(i+1, i) = -c_row(i+1); % Lower off-diagonal
else
C(i, i) = c_row(i); % Last diagonal element
end
end
C_matrices{row} = C; % Store the damping matrix in the cell array
end
% % Display the mass, stiffness, damping, matrices
% for row = 1:l
% disp(['Mass Matrix (M) for row ', num2str(row), ':']);
% disp(M_matrices{row});
%
% disp(['Stiffness Matrix (K) for row ', num2str(row), ':']);
% disp(K_matrices{row});
%
% disp(['Damping Matrix (C) for row ', num2str(row), ':']);
% disp(C_matrices{row});
% end
%Natural frequencies
% Initialize arrays to store natural frequencies and time periods for each configuration
natural_frequencies_all = cell(l, 1); % Cell array to store natural frequencies for each configuration
time_periods_all = cell(l, 1); % Cell array to store time periods for each configuration
% Loop through each set of K and M matrices in the cell arrays
for row = 1:l
K = K_matrices{row}; % Get the stiffness matrix for the current row
M = M_matrices{row}; % Get the mass matrix for the current row
[eigenvectors, eigenvalues] = eig(K, M);
natural_frequencies = sqrt(diag(eigenvalues)); % rad/s
natural_frequencies_all{row} = natural_frequencies; % Store the natural frequencies in the cell array
time_periods = 2 * pi ./ natural_frequencies; % s
time_periods_all{row} = time_periods; % Store the time periods in the cell array
%
% % Display Natural frequencies
% disp(['Natural Frequencies for Configuration ', num2str(row), ':']);
% disp(natural_frequencies);
%
% % Display Time periods
% disp(['Time Periods for Configuration ', num2str(row), ':']);
% disp(time_periods);
end
critical_time_periods = cellfun(@max, time_periods_all); % critical time periods (lowest natural frequency) for each configuration
% % Display the critical time periods for each configuration
% disp('Critical Time Periods for Each Configuration:');
% disp(critical_time_periods);
% Excitation frequency range
omega_range = linspace(5,100, 100000); % rad/s
frequency_range = omega_range/(2*pi); % Hz
first_natural_frequencies = cellfun(@(x) x(1), natural_frequencies_all); % Extract the first natural frequency for each configuration
% Dynamic Magnification Factor for top floor (DMF) with frequency ratio (r)
DMF_cells = cell(l, 1); % Cell array to store DMF for each configuration
frequency_ratios = cell(l, 1); % Cell array to store frequency ratios for each configuration
% Loop to calculate DMF and frequency ratio for each configuration
for row = 1:l
K = K_matrices{row}; % Get the stiffness matrix for the current row
C = C_matrices{row}; % Get the damping matrix for the current row
M = M_matrices{row}; % Get the mass matrix for the current row
% Get the first natural frequency for the current row
first_natural_frequency = first_natural_frequencies(row);
% Calculate the frequency ratio (r) for the current row
r = omega_range / first_natural_frequency; % Frequency ratio (r) for the current configuration
% Initialize DMF array for the current row
DMF = zeros(1, length(omega_range));
% Loop to calculate DMF for each frequency ratio
for i = 1:length(omega_range)
omega = omega_range(i);
H_d = (K - M * omega^2 + 1j * C * omega)\K;
DMF(i) = abs(H_d(length(M_str), 1)); % DMF for the top floor displacement
end
DMF_cells{row} = DMF; % Store the DMF array in the cell array
frequency_ratios{row} = r; % Store the frequency ratio array in the cell array
end
% Plot each DMF against the frequency ratio stored in frequency_ratios
figure;
for row = 1:l % l is the number of configurations
DMF = DMF_cells{row}; % DMF array for the current row
r = frequency_ratios{row}; % Frequency ratio for the current row
plot(r, DMF, 'LineWidth', 1.5); % Plot DMF against frequency ratio
hold on;
end
xlabel('Frequency Ratio (r = \omega / \omega_1)');
ylabel('Dynamic Magnification Factor (DMF)');
title('DMF vs Frequency Ratio for Different Configurations');
legend(arrayfun(@(x) ['Configuration ', num2str(x)], 1:l, 'UniformOutput', false));
grid on;
hold off;
% Excitation frequency range
omega_range = linspace(5,100, 100000); % rad/s
frequency_range = omega_range/(2*pi); % Hz
% Acceleration Transfer Function for top floor
TF_tf_cells = cell(l, 1); % Cell array to store Tf for each configuration
l_vector = ones(length(M_str)+1,1);
% Loop to calculate Tf for each set of M, K, and C matrices
for row = 1:l
K = K_matrices{row}; % Get the stiffness matrix for the current row
C = C_matrices{row}; % Get the damping matrix for the current row
M = M_matrices{row}; % Get the mass matrix for the current row
% Initialize Tf array for the current row
TF_tf = zeros(1, length(omega_range));
% Loop over frequency range to calculate Tf
for i = 1:length(omega_range)
omega = omega_range(i);
H_a = (K - M * omega^2 + 1j * C * omega) \ (-M*omega^2*l_vector);
TF_tf(i) = 20*log10(abs(H_a(length(M_str), 1))); % dB
end
TF_tf_cells{row} = TF_tf; % Store the Tf array in the cell array
end
% Plot each Tf stored in Tf_tf_cells
figure;
% Loop through each Tf in the cell array
for row = 1:l
TF_tf = TF_tf_cells{row}; % Tf_tf array for the current row
% Plot DMF vs Frequency_range(Hz) curve
semilogx(frequency_range, TF_tf, 'LineWidth', 1.5);
hold on;
end
xlabel('Frequency (Hz)');
ylabel('Acceleration Transfer Function Tf(dB)');
title('Tf for Different Configurations');
legend(arrayfun(@(x) ['Configuration ', num2str(x)], 1:l, 'UniformOutput', false)); % Dynamic legend
grid on;
hold off;
Warning: Limiting legend entries to 50. Specify a vector of graphics objects to display more than 50 entries.
Warning: Limiting legend entries to 50. Specify a vector of graphics objects to display more than 50 entries.

Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!