1pub 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#[derive(Debug, Clone)]
27pub struct ColdFormedSection {
28 pub section: Section,
29 pub material: Material,
30 pub elements: Vec<ColdFormedElement>,
32}
33
34#[derive(Debug, Clone)]
35pub struct ColdFormedElement {
36 pub element_type: ElementType,
37 pub width: f64, 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 DoubleSupported,
49 Outstand,
51 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>, }
73
74#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75pub enum StiffenerType {
76 Intermediate,
78 EdgeWithLip,
80 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 pub fn effective_properties(&self, f_c: f64) -> EffectiveSectionProperties {
100 reduced_section_properties(self, f_c)
101 }
102
103 pub fn effective_properties_compression(&self) -> EffectiveSectionProperties {
105 self.effective_properties(self.material.yield_strength)
106 }
107
108 pub fn effective_properties_bending(&self, m_ed: f64) -> EffectiveSectionProperties {
110 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 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 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#[derive(Debug, Clone)]
168pub struct EffectiveWidthParams {
169 pub fy: f64,
171 pub e: f64,
173 pub nu: f64,
175 pub gamma_m0: f64,
177 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,
197 Outstand,
199 Stiffened,
201 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 let rect = crate::section_library::rectangle_polygon(0.1, 0.2);
231 let section = Section::new(rect, vec![]);
232 let props = SectionProperties::from_section(§ion);
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(§ion, crate::plastic::PlasticAxis::X);
244 let zy = eff.z_eff_compression(§ion, crate::plastic::PlasticAxis::Y);
245
246 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}