Skip to main content

section_properties/
cold_formed_analysis.rs

1//! Cold-formed steel design per EN 1993-1-3, AS 4600, AISI S100.
2//!
3//! Implements effective width method for slender elements,
4//! distortional buckling, and combined local-distortional interaction.
5
6pub mod direct_strength;
7pub mod distortional;
8pub mod effective_width;
9
10pub use direct_strength::{
11    DsmParams, DsmStrengths, dsm_analysis, dsm_nominal_capacity_distortional,
12    dsm_nominal_capacity_global, dsm_nominal_capacity_local,
13};
14pub use distortional::{DistortionalBuckling, DistortionalParams};
15pub use effective_width::{
16    effective_width_corner, effective_width_flat, effective_width_flat_simple,
17    effective_width_stiffened, reduced_section_properties,
18};
19
20use crate::geometry::Point;
21use crate::material::Material;
22use crate::section::Section;
23use crate::section_properties::SectionProperties;
24
25/// Cold-formed steel section analysis.
26#[derive(Debug, Clone)]
27pub struct ColdFormedSection {
28    pub section: Section,
29    pub material: Material,
30    /// Element properties for effective width calculation
31    pub elements: Vec<ColdFormedElement>,
32}
33
34#[derive(Debug, Clone)]
35pub struct ColdFormedElement {
36    pub element_type: ElementType,
37    pub width: f64, // Flat width (excluding corners)
38    pub thickness: f64,
39    pub yield_strength: f64,
40    pub edge_support: EdgeSupport,
41    pub stiffener: Option<Stiffener>,
42    pub corner_radius: f64,
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46pub enum EdgeSupport {
47    /// Supported on both edges (internal element, e.g., web)
48    DoubleSupported,
49    /// Supported on one edge (outstand, e.g., flange)
50    Outstand,
51    /// Stiffened edge
52    Stiffened,
53}
54
55#[derive(Debug, Clone, Copy, PartialEq, Eq)]
56pub enum ElementType {
57    Flat,
58    Corner,
59    Stiffened,
60    Lip,
61    Web,
62    Flange,
63}
64
65#[derive(Debug, Clone)]
66pub struct Stiffener {
67    pub type_: StiffenerType,
68    pub width: f64,
69    pub thickness: f64,
70    pub corner_radius: f64,
71    pub lip_length: Option<f64>, // For edge stiffener with lip
72}
73
74#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75pub enum StiffenerType {
76    /// Intermediate stiffener
77    Intermediate,
78    /// Edge stiffener with lip
79    EdgeWithLip,
80    /// Edge stiffener without lip
81    EdgeWithoutLip,
82}
83
84impl ColdFormedSection {
85    pub fn new(section: Section, material: Material) -> Self {
86        Self {
87            section,
88            material,
89            elements: Vec::new(),
90        }
91    }
92
93    pub fn add_element(mut self, element: ColdFormedElement) -> Self {
94        self.elements.push(element);
95        self
96    }
97
98    /// Compute effective section properties at a given stress level.
99    pub fn effective_properties(&self, f_c: f64) -> EffectiveSectionProperties {
100        reduced_section_properties(self, f_c)
101    }
102
103    /// Compute effective properties for pure compression.
104    pub fn effective_properties_compression(&self) -> EffectiveSectionProperties {
105        self.effective_properties(self.material.yield_strength)
106    }
107
108    /// Compute effective properties for bending (compression flange).
109    pub fn effective_properties_bending(&self, m_ed: f64) -> EffectiveSectionProperties {
110        // Estimate compression stress from moment
111        let props = SectionProperties::from_section(&self.section);
112        let max_fiber = props.max_fiber_distance_y();
113        let f_c = m_ed / props.ix * max_fiber;
114        self.effective_properties(f_c.min(self.material.yield_strength))
115    }
116}
117
118#[derive(Debug, Clone)]
119pub struct EffectiveSectionProperties {
120    pub area_eff: f64,
121    pub centroid_eff: Point,
122    pub ix_eff: f64,
123    pub iy_eff: f64,
124    pub ixy_eff: f64,
125    pub element_reductions: Vec<ElementReduction>,
126}
127
128#[derive(Debug, Clone)]
129pub struct ElementReduction {
130    pub element_index: usize,
131    pub original_width: f64,
132    pub effective_width: f64,
133    pub reduction_factor: f64,
134    pub buckling_curve: BucklingCurve,
135}
136
137impl EffectiveSectionProperties {
138    /// Effective section modulus (compression).
139    pub fn z_eff_compression(&self, section: &Section, axis: crate::plastic::PlasticAxis) -> f64 {
140        let bounds = section.bounds();
141        let max_dist = match axis {
142            crate::plastic::PlasticAxis::X => (bounds.3 - self.centroid_eff.y).abs(),
143            crate::plastic::PlasticAxis::Y => (bounds.1 - self.centroid_eff.x).abs(),
144        };
145        if max_dist > 1e-12 {
146            match axis {
147                crate::plastic::PlasticAxis::X => self.ix_eff / max_dist,
148                crate::plastic::PlasticAxis::Y => self.iy_eff / max_dist,
149            }
150        } else {
151            0.0
152        }
153    }
154
155    /// Effective moment capacity.
156    pub fn moment_capacity(
157        &self,
158        section: &Section,
159        material: &Material,
160        axis: crate::plastic::PlasticAxis,
161    ) -> f64 {
162        self.z_eff_compression(section, axis) * material.yield_strength
163    }
164}
165
166/// Parameters for effective width calculation.
167#[derive(Debug, Clone)]
168pub struct EffectiveWidthParams {
169    /// Material yield strength
170    pub fy: f64,
171    /// Young's modulus
172    pub e: f64,
173    /// Poisson's ratio
174    pub nu: f64,
175    /// Safety factor (gamma_m0)
176    pub gamma_m0: f64,
177    /// Whether to use EN 1993-1-3 (true) or AISI S100 (false)
178    pub use_eurocode: bool,
179}
180
181impl Default for EffectiveWidthParams {
182    fn default() -> Self {
183        Self {
184            fy: 350e6,
185            e: 200e9,
186            nu: 0.3,
187            gamma_m0: 1.0,
188            use_eurocode: true,
189        }
190    }
191}
192
193#[derive(Debug, Clone, Copy, PartialEq, Eq)]
194pub enum BucklingCurve {
195    /// Internal element (flat)
196    Internal,
197    /// Outstand element
198    Outstand,
199    /// Stiffened element
200    Stiffened,
201    /// Corner element
202    Corner,
203}
204
205#[cfg(test)]
206mod tests {
207    use super::*;
208    use crate::material::presets::STEEL_S355;
209
210    #[test]
211    fn cold_formed_section_creation() {
212        let poly = crate::section_library::rectangle_polygon(0.2, 0.1);
213        let section = Section::new(poly, vec![]);
214        let cfs = ColdFormedSection::new(section, STEEL_S355);
215
216        assert!(cfs.elements.is_empty());
217    }
218
219    #[test]
220    fn element_types() {
221        assert_eq!(ElementType::Flat as u8, 0);
222    }
223
224    #[test]
225    fn z_eff_compression_uses_correct_coordinates() {
226        // Regression test: bounds.1 (max_x) was used with centroid.y,
227        // and bounds.3 (max_y) was used with centroid.x.
228        // For PlasticAxis::X: max_dist should be max_y - centroid_y
229        // For PlasticAxis::Y: max_dist should be max_x - centroid_x
230        let rect = crate::section_library::rectangle_polygon(0.1, 0.2);
231        let section = Section::new(rect, vec![]);
232        let props = SectionProperties::from_section(&section);
233
234        let eff = EffectiveSectionProperties {
235            area_eff: props.area,
236            ix_eff: props.ix,
237            iy_eff: props.iy,
238            ixy_eff: props.ixy,
239            centroid_eff: props.centroid,
240            element_reductions: vec![],
241        };
242
243        let zx = eff.z_eff_compression(&section, crate::plastic::PlasticAxis::X);
244        let zy = eff.z_eff_compression(&section, crate::plastic::PlasticAxis::Y);
245
246        // For 0.1 wide x 0.2 deep rectangle centered at origin:
247        // X-axis: max_dist = max_y - 0 = 0.1, Zx = Ix / 0.1
248        // Y-axis: max_dist = max_x - 0 = 0.05, Zy = Iy / 0.05
249        let bounds = section.bounds();
250        let expected_zx = props.ix / (bounds.3 - props.centroid.y).abs();
251        let expected_zy = props.iy / (bounds.1 - props.centroid.x).abs();
252
253        assert!(
254            (zx - expected_zx).abs() / expected_zx < 0.01,
255            "Zx should use max_y - centroid_y"
256        );
257        assert!(
258            (zy - expected_zy).abs() / expected_zy < 0.01,
259            "Zy should use max_x - centroid_x"
260        );
261    }
262}