use crate::material::Material;
use crate::section::Section;
use crate::section_properties::SectionProperties;
#[derive(Debug, Clone)]
pub struct DistortionalParams {
pub fy: f64,
pub e: f64,
pub g: f64,
pub nu: f64,
pub length: f64,
pub iw: f64,
pub j: f64,
}
impl Default for DistortionalParams {
fn default() -> Self {
Self {
fy: 350e6,
e: 200e9,
g: 76.9e9,
nu: 0.3,
length: 1.0,
iw: 0.0,
j: 0.0,
}
}
}
#[derive(Debug, Clone)]
pub struct DistortionalBuckling {
pub sigma_crd: f64,
pub lambda_d: f64,
pub chi_d: f64,
pub n_crd: f64,
}
impl DistortionalBuckling {
pub fn analyze(section: &Section, material: &Material, params: &DistortionalParams) -> Self {
let props = SectionProperties::from_section(section);
let area = props.area;
let (sigma_crd, lambda_d, chi_d) = if section.holes.is_empty() {
compute_open_section_distortional(section, material, params)
} else {
compute_closed_section_distortional(section, material, params)
};
let n_crd = chi_d * area * material.yield_strength;
Self {
sigma_crd,
lambda_d,
chi_d,
n_crd,
}
}
pub fn capacity(&self) -> f64 {
self.n_crd
}
}
fn compute_open_section_distortional(
section: &Section,
material: &Material,
params: &DistortionalParams,
) -> (f64, f64, f64) {
let props = SectionProperties::from_section(section);
let _area = props.area;
let bounds = section.bounds();
let h = bounds.3 - bounds.2; let _b = bounds.1 - bounds.0;
let _iw = if params.iw > 0.0 {
params.iw
} else {
estimate_warping_constant(section, &props)
};
let _j = if params.j > 0.0 {
params.j
} else {
estimate_torsion_constant(section)
};
let k_d = distortional_buckling_coefficient(section);
let t = estimate_thickness(section);
let sigma_crd = k_d * material.youngs_modulus * (t / h).powi(2);
let lambda_d = (material.yield_strength / sigma_crd).sqrt();
let chi_d = if lambda_d <= 0.561 {
1.0
} else {
1.0 / (lambda_d * lambda_d) * (1.0 - 0.25 / (lambda_d * lambda_d))
}
.min(1.0);
(sigma_crd, lambda_d, chi_d)
}
fn compute_closed_section_distortional(
section: &Section,
material: &Material,
params: &DistortionalParams,
) -> (f64, f64, f64) {
let props = SectionProperties::from_section(section);
let area = props.area;
let iw = params.iw.max(estimate_warping_constant(section, &props));
let j = params.j.max(estimate_torsion_constant(section));
let length = params.length.max(1.0);
let sigma_crd =
material.youngs_modulus * iw / (area * length * length) + material.shear_modulus * j / area;
let lambda_d = (material.yield_strength / sigma_crd).sqrt();
let chi_d = if lambda_d <= 0.561 {
1.0
} else {
1.0 / (lambda_d * lambda_d)
}
.min(1.0);
(sigma_crd, lambda_d, chi_d)
}
fn distortional_buckling_coefficient(section: &Section) -> f64 {
let bounds = section.bounds();
let h = bounds.3 - bounds.2;
let b = bounds.1 - bounds.0;
let aspect = h / b;
if aspect > 2.0 {
0.5 } else if aspect > 1.0 {
0.8
} else {
1.2 }
}
fn estimate_thickness(section: &Section) -> f64 {
let props = SectionProperties::from_section(section);
let peri = section.perimeter();
if peri > 0.0 { props.area / peri } else { 0.001 }
}
fn estimate_warping_constant(section: &Section, props: &SectionProperties) -> f64 {
let bounds = section.bounds();
let h = bounds.3 - bounds.2;
let _b = bounds.1 - bounds.0;
props.iy * h.powi(2) / 4.0
}
fn estimate_torsion_constant(section: &Section) -> f64 {
let _props = SectionProperties::from_section(section);
let bounds = section.bounds();
let h = bounds.3 - bounds.2;
let b = bounds.1 - bounds.0;
let t = estimate_thickness(section);
(h + 2.0 * b) * t.powi(3) / 3.0
}
pub fn local_distortional_interaction(local_capacity: f64, distortional_capacity: f64) -> f64 {
let n_cr = local_capacity.min(distortional_capacity);
let n_c = local_capacity;
let n_cd = distortional_capacity;
if n_cr == n_c && n_cr == n_cd {
n_cr
} else if n_c < n_cd {
n_c * (1.0 - 0.5 * (1.0 - n_c / n_cd))
} else {
n_cd * (1.0 - 0.5 * (1.0 - n_cd / n_c))
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::material::presets::STEEL_S355;
use crate::section_library::ParametricSection;
#[test]
fn distortional_c_section() {
let c =
crate::section_library::steel::ChannelSection::new(0.2, 0.07, 0.002, 0.002, 0.0, 0.015);
let section = c.build();
let params = DistortionalParams {
fy: STEEL_S355.yield_strength,
e: STEEL_S355.youngs_modulus,
g: STEEL_S355.shear_modulus,
nu: STEEL_S355.poissons_ratio,
length: 3.0,
iw: 0.0,
j: 0.0,
};
let db = DistortionalBuckling::analyze(§ion, &STEEL_S355, ¶ms);
assert!(db.sigma_crd > 0.0);
assert!(db.lambda_d > 0.0);
assert!(db.chi_d <= 1.0);
assert!(db.n_crd > 0.0);
}
#[test]
fn distortional_box_section() {
let rhs = crate::section_library::steel::RectangularHollowSection::new(
0.1, 0.05, 0.002, 0.003, 0.001,
);
let section = rhs.build();
let params = DistortionalParams::default();
let db = DistortionalBuckling::analyze(§ion, &STEEL_S355, ¶ms);
assert!(db.n_crd > 0.0);
}
#[test]
fn local_distortional_interaction_test() {
let local = 100e3;
let distortional = 120e3;
let combined = local_distortional_interaction(local, distortional);
assert!(combined < local);
assert!(combined < distortional);
assert!(combined > 0.0);
}
#[test]
fn distortional_c_section_depth_gt_width() {
let c =
crate::section_library::steel::ChannelSection::new(0.2, 0.07, 0.002, 0.002, 0.0, 0.015);
let section = c.build();
let params = DistortionalParams {
fy: STEEL_S355.yield_strength,
e: STEEL_S355.youngs_modulus,
g: STEEL_S355.shear_modulus,
nu: STEEL_S355.poissons_ratio,
length: 3.0,
iw: 0.0,
j: 0.0,
};
let db = DistortionalBuckling::analyze(§ion, &STEEL_S355, ¶ms);
let c2 =
crate::section_library::steel::ChannelSection::new(0.07, 0.2, 0.002, 0.002, 0.0, 0.015);
let section2 = c2.build();
let db2 = DistortionalBuckling::analyze(§ion2, &STEEL_S355, ¶ms);
assert!(
db.sigma_crd < db2.sigma_crd,
"sigma_crd for depth=0.2 should be < sigma_crd for depth=0.07; got {} vs {}",
db.sigma_crd,
db2.sigma_crd
);
}
}