use crate::cold_formed_analysis::{BucklingCurve, EffectiveWidthParams, ElementReduction};
pub fn effective_width_flat(
width: f64,
thickness: f64,
fy: f64,
e: f64,
stress: f64,
edge_support: crate::cold_formed_analysis::EdgeSupport,
params: &EffectiveWidthParams,
) -> (f64, f64) {
if width <= 0.0 || thickness <= 0.0 || fy <= 0.0 {
return (0.0, 0.0);
}
let nu_clamped = params.nu.clamp(0.0, 0.5); let k = buckling_coefficient(edge_support);
let lambda_bar = (width / thickness)
* (12.0 * (1.0 - nu_clamped * nu_clamped) * fy / (k * e * std::f64::consts::PI.powi(2)))
.sqrt();
let rho = effective_width_reduction(lambda_bar, stress, fy);
let b_eff = rho * width;
(b_eff, rho)
}
fn buckling_coefficient(edge_support: crate::cold_formed_analysis::EdgeSupport) -> f64 {
match edge_support {
crate::cold_formed_analysis::EdgeSupport::DoubleSupported => 4.0, crate::cold_formed_analysis::EdgeSupport::Outstand => 0.43, crate::cold_formed_analysis::EdgeSupport::Stiffened => 4.0, }
}
fn effective_width_reduction(lambda_bar: f64, stress: f64, fy: f64) -> f64 {
const LAMBDA_BAR_LIMIT: f64 = 0.673;
if lambda_bar <= LAMBDA_BAR_LIMIT {
1.0
} else {
let psi = stress / fy; let rho = (1.0 - 0.22 / lambda_bar) / lambda_bar;
if psi < 1.0 {
let rho_psi = 1.0 - (1.0 - rho) * psi;
rho_psi.max(rho).min(1.0)
} else {
rho.min(1.0)
}
}
}
pub fn effective_width_corner(
width: f64,
thickness: f64,
fy: f64,
e: f64,
stress: f64,
corner_radius: f64,
params: &EffectiveWidthParams,
) -> (f64, f64) {
if corner_radius > 0.0 && corner_radius <= 5.0 * thickness {
let r_t = corner_radius / thickness;
let k_c = 1.0 + 0.1 * (r_t - 1.0).min(4.0); let fy_corner = fy * k_c.min(1.5);
let (b_eff, rho) = effective_width_flat(
width,
thickness,
fy_corner,
e,
stress,
crate::cold_formed_analysis::EdgeSupport::DoubleSupported,
params,
);
(b_eff, rho)
} else {
effective_width_flat(
width,
thickness,
fy,
e,
stress,
crate::cold_formed_analysis::EdgeSupport::DoubleSupported,
params,
)
}
}
pub fn effective_width_stiffened(
width: f64,
thickness: f64,
fy: f64,
e: f64,
stress: f64,
stiffener: &crate::cold_formed_analysis::Stiffener,
params: &EffectiveWidthParams,
) -> (f64, f64) {
let i_s = stiffener_moment_of_inertia(stiffener);
let i_s_min = minimum_stiffener_inertia(width, thickness, fy, e, params);
if i_s >= i_s_min {
let (b_eff1, rho1) = effective_width_flat(
width / 2.0,
thickness,
fy,
e,
stress,
crate::cold_formed_analysis::EdgeSupport::DoubleSupported,
params,
);
let (b_eff2, rho2) = effective_width_flat(
width / 2.0,
thickness,
fy,
e,
stress,
crate::cold_formed_analysis::EdgeSupport::DoubleSupported,
params,
);
(b_eff1 + b_eff2, (rho1 + rho2) / 2.0)
} else {
let reduction = (i_s / i_s_min).sqrt().min(1.0);
let (b_eff, rho) = effective_width_flat(
width,
thickness,
fy,
e,
stress,
crate::cold_formed_analysis::EdgeSupport::DoubleSupported,
params,
);
(b_eff, rho * reduction)
}
}
fn stiffener_moment_of_inertia(stiffener: &crate::cold_formed_analysis::Stiffener) -> f64 {
match stiffener.type_ {
crate::cold_formed_analysis::StiffenerType::Intermediate => {
stiffener.width * stiffener.thickness.powi(3) / 12.0
}
crate::cold_formed_analysis::StiffenerType::EdgeWithLip => {
let lip_len = stiffener.lip_length.unwrap_or(0.0);
let a_lip = lip_len * stiffener.thickness;
let a_stiff = stiffener.width * stiffener.thickness;
let total_a = a_lip + a_stiff;
let y_bar = (a_lip * (stiffener.width + lip_len / 2.0)
+ a_stiff * stiffener.width / 2.0)
/ total_a;
let i_lip = a_lip * (stiffener.width + lip_len / 2.0 - y_bar).powi(2)
+ lip_len * stiffener.thickness.powi(3) / 12.0;
let i_stiff = a_stiff * (stiffener.width / 2.0 - y_bar).powi(2)
+ stiffener.width * stiffener.thickness.powi(3) / 12.0;
i_lip + i_stiff
}
crate::cold_formed_analysis::StiffenerType::EdgeWithoutLip => {
stiffener.width * stiffener.thickness.powi(3) / 12.0
}
}
}
fn minimum_stiffener_inertia(
width: f64,
thickness: f64,
fy: f64,
e: f64,
params: &EffectiveWidthParams,
) -> f64 {
let k_sigma = buckling_coefficient(crate::cold_formed_analysis::EdgeSupport::DoubleSupported);
let sigma_cr = k_sigma * e * std::f64::consts::PI.powi(2)
/ (12.0 * (1.0 - params.nu * params.nu))
* (thickness / width).powi(2);
0.5 * thickness.powi(4) * (width / thickness).sqrt() * (fy / sigma_cr).sqrt()
}
pub fn reduced_section_properties(
cfs: &crate::cold_formed_analysis::ColdFormedSection,
f_c: f64,
) -> crate::cold_formed_analysis::EffectiveSectionProperties {
let params = EffectiveWidthParams::default();
let mut element_reductions = Vec::new();
let mut total_area = 0.0;
let _first_moment_x = 0.0;
let _first_moment_y = 0.0;
let _ix = 0.0;
let _iy = 0.0;
let _ixy = 0.0;
let props = crate::section_properties::SectionProperties::from_section(&cfs.section);
for (i, element) in cfs.elements.iter().enumerate() {
let stress = f_c.min(element.yield_strength);
let (b_eff, rho) = match element.element_type {
crate::cold_formed_analysis::ElementType::Flat => effective_width_flat(
element.width,
element.thickness,
element.yield_strength,
params.e,
stress,
element.edge_support,
¶ms,
),
crate::cold_formed_analysis::ElementType::Corner => effective_width_corner(
element.width,
element.thickness,
element.yield_strength,
params.e,
stress,
element.corner_radius,
¶ms,
),
crate::cold_formed_analysis::ElementType::Stiffened => {
if let Some(stiffener) = &element.stiffener {
effective_width_stiffened(
element.width,
element.thickness,
element.yield_strength,
params.e,
stress,
stiffener,
¶ms,
)
} else {
(element.width, 1.0)
}
}
_ => (element.width, 1.0),
};
element_reductions.push(ElementReduction {
element_index: i,
original_width: element.width,
effective_width: b_eff,
reduction_factor: rho,
buckling_curve: match element.edge_support {
crate::cold_formed_analysis::EdgeSupport::DoubleSupported => {
BucklingCurve::Internal
}
crate::cold_formed_analysis::EdgeSupport::Outstand => BucklingCurve::Outstand,
crate::cold_formed_analysis::EdgeSupport::Stiffened => BucklingCurve::Stiffened,
},
});
total_area += b_eff * element.thickness;
}
let area_ratio = if props.area > 0.0 {
total_area / props.area
} else {
1.0
};
crate::cold_formed_analysis::EffectiveSectionProperties {
area_eff: total_area,
centroid_eff: props.centroid,
ix_eff: props.ix * area_ratio,
iy_eff: props.iy * area_ratio,
ixy_eff: props.ixy * area_ratio,
element_reductions,
}
}
pub fn effective_width_flat_simple(
width: f64,
thickness: f64,
fy: f64,
stress: f64,
edge_support: crate::cold_formed_analysis::EdgeSupport,
) -> (f64, f64) {
let params = EffectiveWidthParams {
fy,
e: 200e9,
nu: 0.3,
gamma_m0: 1.0,
use_eurocode: true,
};
effective_width_flat(
width,
thickness,
fy,
params.e,
stress,
edge_support,
¶ms,
)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::cold_formed_analysis::EdgeSupport;
#[test]
fn effective_width_stocky() {
let (b_eff, rho) =
effective_width_flat_simple(50.0, 2.0, 350e6, 200e6, EdgeSupport::DoubleSupported);
assert!((rho - 1.0).abs() < 1e-6);
assert!((b_eff - 50.0).abs() < 1e-6);
}
#[test]
fn effective_width_slender() {
let (b_eff, rho) =
effective_width_flat_simple(500.0, 1.0, 350e6, 300e6, EdgeSupport::DoubleSupported);
assert!(rho < 1.0);
assert!(b_eff < 500.0);
}
#[test]
fn effective_width_outstand() {
let (_b_eff, rho) =
effective_width_flat_simple(100.0, 2.0, 350e6, 300e6, EdgeSupport::Outstand);
assert!(rho <= 1.0);
}
#[test]
fn effective_width_corner_enhancement() {
let params = EffectiveWidthParams::default();
let (_b_eff1, rho1) = effective_width_flat(
100.0,
2.0,
350e6,
200e9,
300e6,
EdgeSupport::DoubleSupported,
¶ms,
);
let (_b_eff2, rho2) =
effective_width_corner(100.0, 2.0, 350e6, 200e9, 300e6, 3.0 * 2.0, ¶ms); assert!(rho2 >= rho1); }
#[test]
fn buckling_coefficients() {
assert_eq!(buckling_coefficient(EdgeSupport::DoubleSupported), 4.0);
assert_eq!(buckling_coefficient(EdgeSupport::Outstand), 0.43);
}
}