RC-SRP / matlab /simple_RC_SRP.m
algorembrant's picture
Upload 89 files
a8ced59 verified
% Simple RC-SRP Script Calculator
clear; clc;
disp('--- Simple RC-SRP Calculator ---');
disp('Follow the steps to enter the given variables.');
% Get inputs from the user through the command window
fc = input('Enter concrete compressive strength f_c'' (psi): ');
fy = input('Enter steel yield strength f_y (psi): ');
b = input('Enter beam width b (in): ');
h = input('Enter beam height h (in): ');
cover = input('Enter cover distance to extreme tension layer (in): ');
n_bars = input('Enter total number of bars: ');
a_bar = input('Enter area per bar (in^2): ');
% Ask if there's a second layer
double_layer_ans = input('Is this a double layer reinforcement? (yes/no): ', 's');
if strcmpi(double_layer_ans, 'yes')
layer_type = 'Double Layer Singly Reinforced';
n_bars1 = input('Enter number of bars in layer 1 (bottom): ');
n_bars2 = input('Enter number of bars in layer 2 (top): ');
spacing = input('Enter spacing between layers (in): ');
else
layer_type = 'Single Layer Singly Reinforced';
end
% Ask user if they want to calculate and show output
show_output = input('Ready to calculate and show the output? (yes/no): ', 's');
if strcmpi(show_output, 'yes')
disp(' ');
disp('--- CALCULATION OUTPUT ---');
% Identify the type of calculated section
disp(['Type of section: ', layer_type]);
disp(' ');
% Basic constants
fc_ksi = fc / 1000;
fy_ksi = fy / 1000;
Es_ksi = 29000;
E_cu = 0.003;
% Calculate beta1 factor
beta1 = 0.85;
if fc > 4000
beta1 = 0.85 - 0.05 * ((fc - 4000) / 1000);
end
beta1 = max(beta1, 0.65);
% Minimum steel factor
limit_val = 3 * sqrt(fc);
As_min_factor = max(limit_val, 200);
if strcmpi(double_layer_ans, 'no')
% --- SINGLE LAYER CALCULATION ---
d = h - cover;
As = n_bars * a_bar;
disp(['1. Effective depth (d): ', num2str(d), ' in']);
disp(['2. Area of steel (A_s): ', num2str(As), ' in^2']);
% Force and depth of compression block
T = As * fy_ksi;
disp(['3. Tension force (T, assuming yield): ', num2str(T), ' kips']);
a = T / (0.85 * fc_ksi * b);
c = a / beta1;
disp(['4. Compression block depth (a): ', num2str(a), ' in']);
disp([' Neutral axis depth (c): ', num2str(c), ' in']);
% Check if steel actually yields
eps_y = fy_ksi / Es_ksi;
eps_s = ((d - c) / c) * E_cu;
disp(['5. Yield strain (eps_y): ', num2str(eps_y)]);
disp([' Steel strain (eps_s): ', num2str(eps_s)]);
if eps_s >= eps_y
disp(' Status: Steel yielded. Assumption OK.');
else
disp(' Status: Steel did NOT yield. Assumption failed.');
end
% Calculate Nominal Moment
Mn = T * (d - a/2) / 12;
disp(['6. Nominal Moment (M_n): ', num2str(Mn), ' kip-ft']);
% Check minimum code requirement for steel
As_min = (As_min_factor / fy) * b * d;
disp(['7. Minimum steel (A_s,min): ', num2str(As_min), ' in^2']);
if As >= As_min
disp(' Status: A_s >= A_s,min. OK.');
end
% Compute reduction factor
eps_t = eps_s;
if eps_t >= 0.005
phi = 0.90;
elseif eps_t <= 0.002
phi = 0.65;
else
phi = 0.65 + (eps_t - 0.002) * (250/3);
end
phi_Mn = phi * Mn;
disp(['8. Reduction factor (phi): ', num2str(phi)]);
disp(['9. Design Moment (phi*M_n): ', num2str(phi_Mn), ' kip-ft']);
else
% --- DOUBLE LAYER CALCULATION ---
As1 = n_bars1 * a_bar;
As2 = n_bars2 * a_bar;
As = As1 + As2;
dist1 = cover;
dist2 = cover + spacing;
% Calculate centroid of steel
g = (As1 * dist1 + As2 * dist2) / As;
d = h - g;
d_t = h - cover;
disp(['1. Centroid distance (g): ', num2str(g), ' in']);
disp(['2. Effective depth (d): ', num2str(d), ' in']);
disp([' Area of steel (A_s): ', num2str(As), ' in^2']);
% Force and depth of compression block
T = As * fy_ksi;
a = T / (0.85 * fc_ksi * b);
c = a / beta1;
disp(['3. Tension force (T, assuming yield): ', num2str(T), ' kips']);
disp(['4. Compression block depth (a): ', num2str(a), ' in']);
disp([' Neutral axis depth (c): ', num2str(c), ' in']);
% Check if steel yields
eps_y = fy_ksi / Es_ksi;
eps_s = ((d - c) / c) * E_cu;
disp(['5. Yield strain (eps_y): ', num2str(eps_y)]);
disp([' Steel strain (eps_s): ', num2str(eps_s)]);
if eps_s < eps_y
disp(' Status: Over-reinforced section. Assumption Failed.');
disp(' Solving exact c using quadratic method...');
% Use quadratic for exact answer if not yielded
A_quad = 0.85 * fc_ksi * b * beta1;
B_quad = As * Es_ksi * E_cu;
C_quad = -1 * As * Es_ksi * E_cu * d;
roots_c = roots([A_quad, B_quad, C_quad]);
c = max(roots_c(roots_c > 0));
a = beta1 * c;
disp([' Exact Neutral axis (c): ', num2str(c), ' in']);
disp([' Exact Compression block (a): ', num2str(a), ' in']);
T = As * Es_ksi * ((d - c)/c) * E_cu;
disp([' Exact Tension force (T): ', num2str(T), ' kips']);
else
disp(' Status: Steel yielded. Assumption OK.');
end
% Calculate Nominal Moment
Mn = T * (d - a/2) / 12;
disp(['6. Nominal Moment (M_n): ', num2str(Mn), ' kip-ft']);
% Check minimum code requirement for steel
As_min = (As_min_factor / fy) * b * d;
disp(['7. Minimum steel (A_s,min): ', num2str(As_min), ' in^2']);
if As >= As_min
disp(' Status: A_s >= A_s,min. OK.');
end
% Compute reduction factor using extreme tension layer
eps_t = ((d_t - c) / c) * E_cu;
if eps_t >= 0.005
phi = 0.90;
elseif eps_t <= 0.002
phi = 0.65;
else
phi = 0.65 + (eps_t - 0.002) * (250/3);
end
phi_Mn = phi * Mn;
disp(['8. Extreme tension strain (eps_t): ', num2str(eps_t)]);
disp([' Reduction factor (phi): ', num2str(phi)]);
disp(['9. Design Moment (phi*M_n): ', num2str(phi_Mn), ' kip-ft']);
end
else
disp('Calculation stopped. Have a great day!');
end