Código em MATLAB 4

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

function main

% Define simulation parameters


num_simulations = 100; % Number of Monte Carlo simulations
L = 5; % Beam span (m)
gamma_g = 1.4; % Partial safety factor for permanent loads
gamma_q = 1.4; % Partial safety factor for variable loads
exposure_times = [20, 30, 60, 90, 120]; % Exposure times in minutes
load_ratios = [0.25, 0.5, 0.75]; % Load ratios
compartment = struct('floor_width', 10, 'floor_length', 15, 'floor_area',
150, 'ceiling_area', 150, 'wall_area', [60, 60, 40, 40], 'num_doors', 2,
'door_width', 1, 'num_windows', 12, 'window_width', 1.5,
'thermal_inertia_floor_ceiling', 2034, 'thermal_inertia_walls', 1521); %
Compartment characteristics
cases = [3.2, 0.32, 4.5, 4.0; 3.2, 0.32, 3.5, 3.0; 5.0, 0.50, 4.5, 3.9;
5.0, 0.50, 3.5, 2.9; 8.0, 0.80, 4.5, 3.7; 8.0, 0.80, 3.5, 2.7; 9.45, 0.95,
4.5, 3.5; 9.45, 0.95, 3.5, 2.5]; % Cases: [As (cm^2), rho (%), d' (cm), c1
(cm)]
alpha_r_standard = [2.7, 2.41, 5.3, 4.5, 1.95, 2.12, 1.65, 8.45; 2.85,
2.25, 3.9, 2.9, 2.35, 2.17, 1.86, 5.6; 1.78, 1.2, 1.9, 1.25, 1.85, 1.21, 1.3,
1.85; 1.15, 0.735, 1.148, 0.75, 1.215, 0.76, 0.9, 0.96; 0.81, 0.515, 0.8,
0.511, 0.861, 0.525, 0.675, 0.62]; % Thermal diffusivity ratio values for
standard fire
alpha_r_parametric = [1.62, 11.5, 15.3, 11.2, 1.92, 2.1, 1.62, 8; 8.8,
5.8, 8, 5.4, 2.35, 2.15, 1.87, 5.8; 19.6, 20.1, 17.8, 17.8, 2.1, 2.5, 1.52,
20.8; 10.67, 10.96, 10.52, 10.85, 8.3, 10.4, 5.9, 11.85; 7.17, 7.32, 7.09,
7.25, 6.5, 7.45, 5.15, 8.1]; % Thermal diffusivity ratio values for
parametric fire

h = waitbar(0, 'Iniciando simulações...');

% Initialize arrays for results


reliability_indices = zeros(length(exposure_times), length(cases),
length(load_ratios), 2); % Last dimension for fire types (1: standard, 2:
parametric)
probabilities_of_failure = zeros(length(exposure_times), length(cases),
length(load_ratios), 2); % Last dimension for fire types

% Loop over exposure times, cases, and load ratios


for t = 1:length(exposure_times)
for c = 1:length(cases)
for r = 1:length(load_ratios)
% Perform Monte Carlo simulation for standard fire
[reliability_index_std, probability_of_failure_std] =
monte_carlo_simulation(num_simulations, exposure_times(t), cases(c,:),
load_ratios(r), 'standard', alpha_r_standard(t, c), compartment, L, gamma_g,
gamma_q);
reliability_indices(t, c, r, 1) = reliability_index_std;
probabilities_of_failure(t, c, r, 1) =
probability_of_failure_std;

% Perform Monte Carlo simulation for parametric fire


[reliability_index_param, probability_of_failure_param] =
monte_carlo_simulation(num_simulations, exposure_times(t), cases(c,:),
load_ratios(r), 'parametric', alpha_r_parametric(t, c), compartment, L,
gamma_g, gamma_q);
reliability_indices(t, c, r, 2) = reliability_index_param;
probabilities_of_failure(t, c, r, 2) =
probability_of_failure_param;
waitbar(((t-1)*length(cases)*length(load_ratios) + (c-
1)*length(load_ratios) + r) /
(length(exposure_times)*length(cases)*length(load_ratios)), h,
sprintf('Progresso: %d%%', floor(((t-1)*length(cases)*length(load_ratios) +
(c-1)*length(load_ratios) + r) /
(length(exposure_times)*length(cases)*length(load_ratios)) * 100)));
end
end
end

close(h);

% Plot results
plot_results(exposure_times, reliability_indices,
probabilities_of_failure, load_ratios, cases);
end

function [reliability_index, probability_of_failure] =


monte_carlo_simulation(num_simulations, exposure_time, case_params,
load_ratio, fire_type, alpha_r, compartment, L, gamma_g, gamma_q)
% Initialize variables for Monte Carlo simulation
failure_count = 0;
M_Rd = [156.4; 152.4; 239.4; 233.2; 377.1; 367.4; 435.3; 424.2]; % Design
resistant moments (M_Rd) for each case (kNm)

% Loop over the number of simulations


for i = 1:num_simulations
% Generate random samples for the random variables
As = normrnd(case_params(1), case_params(1) * 0.02); % Reinforcement
area
fy = lognrnd(1.16 * 500, (1.16 * 500)*0.07); % Steel yield stress
h = normrnd(50, 50 * 0.004); % Beam height
fc = lognrnd(1.23 * 25, (1.23 * 25)*0.15); % Concrete strength
alpha = normrnd(0.417e-6, 0.417e-6 * 0.06); % Thermal diffusivity
b = normrnd(20, 20 * 0.004); % Beam width
d_prime = lognrnd(case_params(3), (case_params(3)) * 0.1); % Cover
theta_R = lognrnd(1.10, 1.10*0.1); % Uncertainty in resistance model

% Calculate temperatures and other parameters


[Tr, Tc] = calculate_temperatures(exposure_time, alpha * alpha_r,
fire_type, case_params, compartment);
x500 = sqrt((alpha * alpha_r * exposure_time * 60) / exp(4.5 + 480 /
(0.18 * (1 - 0.0616 * (exposure_time * 60)^(-0.88)) * Tc)));
b_Tc = b - 2 * x500;
r = (720 - (Tr + 20)) / 470;
r = min(max(r, 0), 1);
fyTr = fy * r;
aTc = (As * fyTr) / (0.85 * fc * b_Tc);
MnT = theta_R * As * fyTr * (h - 2*d_prime) + (As) * fyTr * (h -
d_prime - aTc/2);
mu_LL = [15.64; 15.64; 23.94; 23.94; 37.71; 37.71; 43.53; 43.53];
mu_PL = mu_LL * (5 * (1 - load_ratio) / (load_ratio));
MPL = normrnd(mu_PL, mu_PL * 0.1);
MLL = gamrnd(0,2*mu_LL, 0.95* 0,2*mu_LL);
theta_S = lognrnd(1, 0.1);
MS = theta_S * (MPL + MLL);
gX = MnT - MS;

% Check for failure


if gX <= 0
failure_count = failure_count + 1;
end
end

% Calculate the probability of failure and reliability index


probability_of_failure = failure_count / num_simulations;
reliability_index = -norminv(probability_of_failure);
end

function [Tr, Tc] = calculate_temperatures(exposure_time, alpha, fire_type,


case_params, compartment)
% Convert exposure time to hours for the Wickstrom model
t = exposure_time / 60;

% Calculate the gas temperature (Tg) based on the fire type


if strcmp(fire_type, 'standard')
Tg = 20 + 345 * log10(8 * t + 1); % Standard fire curve (ISO 834)
else
% Parametric fire curve
time_temperature = [20, 821; 30, 840; 60, 639; 90, 333; 100, 224;
120, 20];
Tg = interp1(time_temperature(:, 1), time_temperature(:, 2),
exposure_time, 'linear', 'extrap');
end

% Calculate the temperature of the steel reinforcement (Tr) andconcrete


(Tc) using Wickstrom's model
s = case_params(3); % Distance from the steel bar axis to the concrete
face (d')
nw = 1 - 0.0616 * t^(-0.88);
nss = 0.18 * log(alpha * t / s^2) - 0.81;
nx = nss; % Assuming symmetrical heating
ny = nss; % Assuming symmetrical heating
Tr = nw * (nx + ny - 2 * nx * ny) + nx * ny * Tg;
Tc = Tg;
end

function plot_results(exposure_times, reliability_indices,


probabilities_of_failure, load_ratios, cases)
% Plot reliability indices and probabilities of failure for each case and
load ratio
for c = 1:length(cases)
% Plotar índices de confiabilidade em um único gráfico para o caso c
figure;
hold on;
for r = 1:length(load_ratios)
for f = 1:2 % Fire types (1: standard, 2: parametric)
if f == 1
fire_type = 'Standard';
line_style = '-';
else
fire_type = 'Parametric';
line_style = '--';
end
plot(exposure_times, squeeze(reliability_indices(:, c, r, f)),
line_style, 'DisplayName', ['Load Ratio ' num2str(load_ratios(r)) ' '
fire_type ' Fire']);
end
end
title(['Reliability Index for Case ' num2str(c)]);
xlabel('Exposure Time (min)');
ylabel('Reliability Index');
legend('show');

% Plotar probabilidades de falha em um único gráfico para o caso c


figure;
hold on;
for r = 1:length(load_ratios)
for f = 1:2 % Fire types (1: standard, 2: parametric)
if f == 1
fire_type = 'Standard';
line_style = '-';
else
fire_type = 'Parametric';
line_style = '--';
end
plot(exposure_times, squeeze(probabilities_of_failure(:, c, r,
f)), line_style, 'DisplayName', ['Load Ratio ' num2str(load_ratios(r)) ' '
fire_type ' Fire']);
end
end
title(['Probability of Failure for Case ' num2str(c)]);
xlabel('Exposure Time (min)');
ylabel('Probability of Failure');
legend('show');
end
end

You might also like