pub mod direct_strength;
pub mod distortional;
pub mod effective_width;
pub use direct_strength::{
DsmParams, DsmStrengths, dsm_analysis, dsm_nominal_capacity_distortional,
dsm_nominal_capacity_global, dsm_nominal_capacity_local,
};
pub use distortional::{DistortionalBuckling, DistortionalParams};
pub use effective_width::{
effective_width_corner, effective_width_flat, effective_width_flat_simple,
effective_width_stiffened, reduced_section_properties,
};
use crate::geometry::Point;
use crate::material::Material;
use crate::section::Section;
use crate::section_properties::SectionProperties;
#[derive(Debug, Clone)]
pub struct ColdFormedSection {
pub section: Section,
pub material: Material,
pub elements: Vec<ColdFormedElement>,
}
#[derive(Debug, Clone)]
pub struct ColdFormedElement {
pub element_type: ElementType,
pub width: f64, pub thickness: f64,
pub yield_strength: f64,
pub edge_support: EdgeSupport,
pub stiffener: Option<Stiffener>,
pub corner_radius: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EdgeSupport {
DoubleSupported,
Outstand,
Stiffened,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ElementType {
Flat,
Corner,
Stiffened,
Lip,
Web,
Flange,
}
#[derive(Debug, Clone)]
pub struct Stiffener {
pub type_: StiffenerType,
pub width: f64,
pub thickness: f64,
pub corner_radius: f64,
pub lip_length: Option<f64>, }
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StiffenerType {
Intermediate,
EdgeWithLip,
EdgeWithoutLip,
}
impl ColdFormedSection {
pub fn new(section: Section, material: Material) -> Self {
Self {
section,
material,
elements: Vec::new(),
}
}
pub fn add_element(mut self, element: ColdFormedElement) -> Self {
self.elements.push(element);
self
}
pub fn effective_properties(&self, f_c: f64) -> EffectiveSectionProperties {
reduced_section_properties(self, f_c)
}
pub fn effective_properties_compression(&self) -> EffectiveSectionProperties {
self.effective_properties(self.material.yield_strength)
}
pub fn effective_properties_bending(&self, m_ed: f64) -> EffectiveSectionProperties {
let props = SectionProperties::from_section(&self.section);
let max_fiber = props.max_fiber_distance_y();
let f_c = m_ed / props.ix * max_fiber;
self.effective_properties(f_c.min(self.material.yield_strength))
}
}
#[derive(Debug, Clone)]
pub struct EffectiveSectionProperties {
pub area_eff: f64,
pub centroid_eff: Point,
pub ix_eff: f64,
pub iy_eff: f64,
pub ixy_eff: f64,
pub element_reductions: Vec<ElementReduction>,
}
#[derive(Debug, Clone)]
pub struct ElementReduction {
pub element_index: usize,
pub original_width: f64,
pub effective_width: f64,
pub reduction_factor: f64,
pub buckling_curve: BucklingCurve,
}
impl EffectiveSectionProperties {
pub fn z_eff_compression(&self, section: &Section, axis: crate::plastic::PlasticAxis) -> f64 {
let bounds = section.bounds();
let max_dist = match axis {
crate::plastic::PlasticAxis::X => (bounds.3 - self.centroid_eff.y).abs(),
crate::plastic::PlasticAxis::Y => (bounds.1 - self.centroid_eff.x).abs(),
};
if max_dist > 1e-12 {
match axis {
crate::plastic::PlasticAxis::X => self.ix_eff / max_dist,
crate::plastic::PlasticAxis::Y => self.iy_eff / max_dist,
}
} else {
0.0
}
}
pub fn moment_capacity(
&self,
section: &Section,
material: &Material,
axis: crate::plastic::PlasticAxis,
) -> f64 {
self.z_eff_compression(section, axis) * material.yield_strength
}
}
#[derive(Debug, Clone)]
pub struct EffectiveWidthParams {
pub fy: f64,
pub e: f64,
pub nu: f64,
pub gamma_m0: f64,
pub use_eurocode: bool,
}
impl Default for EffectiveWidthParams {
fn default() -> Self {
Self {
fy: 350e6,
e: 200e9,
nu: 0.3,
gamma_m0: 1.0,
use_eurocode: true,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BucklingCurve {
Internal,
Outstand,
Stiffened,
Corner,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::material::presets::STEEL_S355;
#[test]
fn cold_formed_section_creation() {
let poly = crate::section_library::rectangle_polygon(0.2, 0.1);
let section = Section::new(poly, vec![]);
let cfs = ColdFormedSection::new(section, STEEL_S355);
assert!(cfs.elements.is_empty());
}
#[test]
fn element_types() {
assert_eq!(ElementType::Flat as u8, 0);
}
#[test]
fn z_eff_compression_uses_correct_coordinates() {
let rect = crate::section_library::rectangle_polygon(0.1, 0.2);
let section = Section::new(rect, vec![]);
let props = SectionProperties::from_section(§ion);
let eff = EffectiveSectionProperties {
area_eff: props.area,
ix_eff: props.ix,
iy_eff: props.iy,
ixy_eff: props.ixy,
centroid_eff: props.centroid,
element_reductions: vec![],
};
let zx = eff.z_eff_compression(§ion, crate::plastic::PlasticAxis::X);
let zy = eff.z_eff_compression(§ion, crate::plastic::PlasticAxis::Y);
let bounds = section.bounds();
let expected_zx = props.ix / (bounds.3 - props.centroid.y).abs();
let expected_zy = props.iy / (bounds.1 - props.centroid.x).abs();
assert!(
(zx - expected_zx).abs() / expected_zx < 0.01,
"Zx should use max_y - centroid_y"
);
assert!(
(zy - expected_zy).abs() / expected_zy < 0.01,
"Zy should use max_x - centroid_x"
);
}
}