1use crate::material::Material;
11use crate::section::Section;
12use crate::section_properties::SectionProperties;
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum SectionClass {
18 Class1 = 1,
20 Class2 = 2,
22 Class3 = 3,
24 Class4 = 4,
26}
27
28impl PartialOrd for SectionClass {
29 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
30 Some(self.cmp(other))
31 }
32}
33
34impl Ord for SectionClass {
35 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
36 (*self as u8).cmp(&(*other as u8)).reverse()
38 }
39}
40
41impl SectionClass {
42 pub fn can_plastic_moment(&self) -> bool {
44 matches!(self, SectionClass::Class1 | SectionClass::Class2)
45 }
46
47 pub fn can_plastic_rotation(&self) -> bool {
49 matches!(self, SectionClass::Class1)
50 }
51
52 pub fn requires_effective_section(&self) -> bool {
54 matches!(self, SectionClass::Class4)
55 }
56
57 pub fn description(&self) -> &'static str {
59 match self {
60 SectionClass::Class1 => "Class 1 - Plastic (rotation capacity)",
61 SectionClass::Class2 => "Class 2 - Compact (plastic moment)",
62 SectionClass::Class3 => "Class 3 - Semi-compact (elastic moment)",
63 SectionClass::Class4 => "Class 4 - Slender (local buckling)",
64 }
65 }
66}
67
68#[derive(Debug, Clone, Copy, PartialEq)]
70pub enum StressDistribution {
71 UniformCompression,
73 Bending,
75 BendingAndCompression { alpha: f64 }, FlangeBendingAndCompression { psi: f64 }, }
80
81impl StressDistribution {
82 pub fn pure_bending() -> Self {
84 StressDistribution::Bending
85 }
86
87 pub fn pure_compression() -> Self {
89 StressDistribution::UniformCompression
90 }
91
92 pub fn web_bending_compression(alpha: f64) -> Self {
99 StressDistribution::BendingAndCompression { alpha }
100 }
101
102 pub fn flange_bending_compression(psi: f64) -> Self {
104 StressDistribution::FlangeBendingAndCompression { psi }
105 }
106}
107
108#[derive(Debug, Clone, Copy)]
110pub struct ClassLimit {
111 pub class1: f64,
112 pub class2: f64,
113 pub class3: f64,
114}
115
116impl ClassLimit {
117 pub fn classify(&self, c_t: f64) -> SectionClass {
119 if c_t <= self.class1 {
120 SectionClass::Class1
121 } else if c_t <= self.class2 {
122 SectionClass::Class2
123 } else if c_t <= self.class3 {
124 SectionClass::Class3
125 } else {
126 SectionClass::Class4
127 }
128 }
129}
130
131fn web_limits(eps: f64, stress: StressDistribution) -> ClassLimit {
133 match stress {
134 StressDistribution::UniformCompression => ClassLimit {
135 class1: 33.0 * eps,
136 class2: 38.0 * eps,
137 class3: 42.0 * eps,
138 },
139 StressDistribution::Bending => ClassLimit {
140 class1: 72.0 * eps,
141 class2: 83.0 * eps,
142 class3: 124.0 * eps,
143 },
144 StressDistribution::BendingAndCompression { alpha } => {
145 let alpha = alpha.clamp(0.0, 1.0);
149 let psi = 4.0 * alpha - 3.0;
150 let (class1, class2) = if alpha > 0.5 {
151 (
152 396.0 * eps / (13.0 * alpha - 1.0),
153 456.0 * eps / (13.0 * alpha - 1.0),
154 )
155 } else if alpha > 0.0 {
156 (36.0 * eps / alpha, 41.5 * eps / alpha)
157 } else {
158 (f64::MAX, f64::MAX)
159 };
160 let class3_denom = 0.67 + 0.33 * psi;
162 let class3 = if class3_denom > 0.0 {
163 42.0 * eps / class3_denom
164 } else {
165 f64::MAX
166 };
167 ClassLimit {
168 class1,
169 class2,
170 class3,
171 }
172 }
173 StressDistribution::FlangeBendingAndCompression { .. } => {
174 ClassLimit {
176 class1: 0.0,
177 class2: 0.0,
178 class3: 0.0,
179 }
180 }
181 }
182}
183
184fn outstand_flange_limits(eps: f64, stress: StressDistribution) -> ClassLimit {
186 match stress {
187 StressDistribution::UniformCompression => ClassLimit {
188 class1: 9.0 * eps,
189 class2: 10.0 * eps,
190 class3: 14.0 * eps,
191 },
192 StressDistribution::Bending => ClassLimit {
193 class1: 9.0 * eps,
194 class2: 10.0 * eps,
195 class3: 14.0 * eps,
196 },
197 StressDistribution::BendingAndCompression { .. } => {
198 ClassLimit {
200 class1: 9.0 * eps,
201 class2: 10.0 * eps,
202 class3: 14.0 * eps,
203 }
204 }
205 StressDistribution::FlangeBendingAndCompression { psi } => {
206 let class1 = 9.0 * eps / (1.0 + psi).sqrt().max(0.1);
209 let class2 = 10.0 * eps / (1.0 + psi).sqrt().max(0.1);
210 let class3 = 14.0 * eps / (1.0 + psi).sqrt().max(0.1);
211 ClassLimit {
212 class1,
213 class2,
214 class3,
215 }
216 }
217 }
218}
219
220fn internal_flange_limits(eps: f64) -> ClassLimit {
222 ClassLimit {
223 class1: 33.0 * eps,
224 class2: 38.0 * eps,
225 class3: 42.0 * eps,
226 }
227}
228
229#[derive(Debug, Clone)]
231pub struct SectionClassification {
232 pub overall_class: SectionClass,
234 pub web_class: SectionClass,
236 pub flange_class: SectionClass,
238 pub tension_flange_class: SectionClass,
240 pub web_c_t: f64,
242 pub flange_c_t: f64,
243 pub epsilon: f64,
245 pub web_stress: StressDistribution,
247 pub flange_stress: StressDistribution,
249 pub is_class4: bool,
251}
252
253impl SectionClassification {
254 pub fn can_plastic_moment(&self) -> bool {
256 self.overall_class.can_plastic_moment()
257 }
258
259 pub fn can_plastic_rotation(&self) -> bool {
261 self.overall_class.can_plastic_rotation()
262 }
263
264 pub fn governing_element(&self) -> &'static str {
266 let classes = [
267 (self.web_class, "web"),
268 (self.flange_class, "compression flange"),
269 (self.tension_flange_class, "tension flange"),
270 ];
271 classes
272 .iter()
273 .max_by_key(|(c, _)| *c as u8)
274 .map(|(_, name)| *name)
275 .unwrap_or("unknown")
276 }
277
278 pub fn summary(&self) -> String {
280 format!(
281 "Overall: {} (governed by {}) | Web: c/t={:.1} ({}) | Flange: c/t={:.1} ({}) | ε={:.3}",
282 self.overall_class.description(),
283 self.governing_element(),
284 self.web_c_t,
285 self.web_class.description(),
286 self.flange_c_t,
287 self.flange_class.description(),
288 self.epsilon
289 )
290 }
291}
292
293pub fn classify_i_section(
295 section: &Section,
296 material: &Material,
297 stress: StressDistribution,
298) -> SectionClassification {
299 let fy = material.yield_strength;
300 let eps = (235e6 / fy).sqrt();
301
302 let props = SectionProperties::from_section(section);
304 let bounds = section.bounds();
305 let _h = bounds.3 - bounds.2; let b = bounds.1 - bounds.0; let (tw, tf, hw) = estimate_i_section_dimensions(section, &props);
311
312 let web_c_t = hw / tw;
314
315 let flange_c_t = (b - tw) / (2.0 * tf);
317
318 let web_limits = web_limits(eps, stress);
320 let web_class = web_limits.classify(web_c_t);
321
322 let flange_limits = outstand_flange_limits(eps, stress);
324 let flange_class = flange_limits.classify(flange_c_t);
325
326 let tension_flange_class = SectionClass::Class1;
328
329 let overall_class = [web_class, flange_class, tension_flange_class]
331 .iter()
332 .min()
333 .copied()
334 .unwrap_or(SectionClass::Class4);
335
336 SectionClassification {
337 overall_class,
338 web_class,
339 flange_class,
340 tension_flange_class,
341 web_c_t,
342 flange_c_t,
343 epsilon: eps,
344 web_stress: stress,
345 flange_stress: stress,
346 is_class4: overall_class == SectionClass::Class4,
347 }
348}
349
350pub fn classify_hollow_section(
352 section: &Section,
353 material: &Material,
354 stress: StressDistribution,
355) -> SectionClassification {
356 let fy = material.yield_strength;
357 let eps = (235e6 / fy).sqrt();
358
359 let props = SectionProperties::from_section(section);
360 let bounds = section.bounds();
361 let h = bounds.3 - bounds.2; let b = bounds.1 - bounds.0; let is_circular = (h - b).abs() / h.max(b) < 0.05;
366
367 if is_circular {
368 let area = props.area;
370 let d = h; let t = area / (std::f64::consts::PI * d);
373 let d_t = d / t;
374
375 let limits = ClassLimit {
378 class1: 50.0 * eps * eps,
379 class2: 70.0 * eps * eps,
380 class3: 90.0 * eps * eps,
381 };
382
383 let overall_class = limits.classify(d_t);
384
385 SectionClassification {
386 overall_class,
387 web_class: overall_class,
388 flange_class: overall_class,
389 tension_flange_class: overall_class,
390 web_c_t: d_t,
391 flange_c_t: d_t,
392 epsilon: eps,
393 web_stress: stress,
394 flange_stress: stress,
395 is_class4: overall_class == SectionClass::Class4,
396 }
397 } else {
398 let area = props.area;
402 let peri = 2.0 * (h + b);
403 let t = area / peri; let web_c_t = (h - 2.0 * t) / t;
406 let flange_c_t = (b - 2.0 * t) / t;
407
408 let web_limits = web_limits(eps, stress);
410 let flange_limits = internal_flange_limits(eps);
411
412 let web_class = web_limits.classify(web_c_t);
413 let flange_class = flange_limits.classify(flange_c_t);
414 let tension_flange_class = SectionClass::Class1;
415
416 let overall_class = [web_class, flange_class, tension_flange_class]
417 .iter()
418 .min()
419 .copied()
420 .unwrap_or(SectionClass::Class4);
421
422 SectionClassification {
423 overall_class,
424 web_class,
425 flange_class,
426 tension_flange_class,
427 web_c_t,
428 flange_c_t,
429 epsilon: eps,
430 web_stress: stress,
431 flange_stress: stress,
432 is_class4: overall_class == SectionClass::Class4,
433 }
434 }
435}
436
437pub fn classify_angle_section(section: &Section, material: &Material) -> SectionClassification {
439 let fy = material.yield_strength;
440 let eps = (235e6 / fy).sqrt();
441
442 let bounds = section.bounds();
443 let h = bounds.3 - bounds.2; let b = bounds.1 - bounds.0; let props = SectionProperties::from_section(section);
448 let area = props.area;
449 let _peri = section.outer.vertices.len() as f64; let t = area / (h + b); let c_t_leg1 = h / t;
453 let c_t_leg2 = b / t;
454
455 let limits = outstand_flange_limits(eps, StressDistribution::UniformCompression);
456 let class1 = limits.classify(c_t_leg1);
457 let class2 = limits.classify(c_t_leg2);
458
459 let overall_class = [class1, class2]
460 .iter()
461 .min()
462 .copied()
463 .unwrap_or(SectionClass::Class4);
464
465 SectionClassification {
466 overall_class,
467 web_class: class1,
468 flange_class: class2,
469 tension_flange_class: SectionClass::Class1,
470 web_c_t: c_t_leg1,
471 flange_c_t: c_t_leg2,
472 epsilon: eps,
473 web_stress: StressDistribution::UniformCompression,
474 flange_stress: StressDistribution::UniformCompression,
475 is_class4: overall_class == SectionClass::Class4,
476 }
477}
478
479pub fn classify_channel_section(
481 section: &Section,
482 material: &Material,
483 stress: StressDistribution,
484) -> SectionClassification {
485 let fy = material.yield_strength;
488 let eps = (235e6 / fy).sqrt();
489
490 let props = SectionProperties::from_section(section);
491 let bounds = section.bounds();
492 let _h = bounds.3 - bounds.2; let b = bounds.1 - bounds.0; let (tw, tf, hw) = estimate_i_section_dimensions(section, &props);
496
497 let web_c_t = hw / tw;
498 let flange_c_t = b / tf; let web_limits = web_limits(eps, stress);
501 let flange_limits = outstand_flange_limits(eps, stress);
502
503 let web_class = web_limits.classify(web_c_t);
504 let flange_class = flange_limits.classify(flange_c_t);
505 let tension_flange_class = SectionClass::Class1;
506
507 let overall_class = [web_class, flange_class, tension_flange_class]
508 .iter()
509 .min()
510 .copied()
511 .unwrap_or(SectionClass::Class4);
512
513 SectionClassification {
514 overall_class,
515 web_class,
516 flange_class,
517 tension_flange_class,
518 web_c_t,
519 flange_c_t,
520 epsilon: eps,
521 web_stress: stress,
522 flange_stress: stress,
523 is_class4: overall_class == SectionClass::Class4,
524 }
525}
526
527pub fn classify_tee_section(
529 section: &Section,
530 material: &Material,
531 stress: StressDistribution,
532) -> SectionClassification {
533 let fy = material.yield_strength;
535 let eps = (235e6 / fy).sqrt();
536
537 let props = SectionProperties::from_section(section);
538 let bounds = section.bounds();
539 let _h = bounds.3 - bounds.2; let b = bounds.1 - bounds.0; let (tw, tf, hw) = estimate_i_section_dimensions(section, &props);
543
544 let web_c_t = hw / tw;
546 let flange_c_t = (b - tw) / (2.0 * tf);
548
549 let web_limits = web_limits(eps, stress);
550 let flange_limits = outstand_flange_limits(eps, stress);
551
552 let web_class = web_limits.classify(web_c_t);
553 let flange_class = flange_limits.classify(flange_c_t);
554 let tension_flange_class = SectionClass::Class1;
555
556 let overall_class = [web_class, flange_class, tension_flange_class]
557 .iter()
558 .min()
559 .copied()
560 .unwrap_or(SectionClass::Class4);
561
562 SectionClassification {
563 overall_class,
564 web_class,
565 flange_class,
566 tension_flange_class,
567 web_c_t,
568 flange_c_t,
569 epsilon: eps,
570 web_stress: stress,
571 flange_stress: stress,
572 is_class4: overall_class == SectionClass::Class4,
573 }
574}
575
576pub fn classify_section(
578 section: &Section,
579 material: &Material,
580 stress: StressDistribution,
581) -> SectionClassification {
582 let props = SectionProperties::from_section(section);
584 let bounds = section.bounds();
585 let h = bounds.3 - bounds.2; let b = bounds.1 - bounds.0; let area = props.area;
588
589 if !section.holes.is_empty() {
591 return classify_hollow_section(section, material, stress);
592 }
593
594 let _peri = section.outer.vertices.len() as f64;
596 let _t_est = area / (2.0 * (h + b)); if area / (h * b) < 0.15 && section.holes.is_empty() {
600 }
603
604 let n_verts = section.outer.vertices.len();
606
607 if n_verts <= 6 {
608 if section.is_symmetric_about_x() && section.is_symmetric_about_y() {
611 if section.holes.is_empty() && area / (h * b) > 0.3 {
613 return classify_i_section(section, material, stress);
615 }
616 } else if section.is_symmetric_about_x() || section.is_symmetric_about_y() {
617 return classify_tee_section(section, material, stress);
619 } else {
620 return classify_angle_section(section, material);
622 }
623 }
624
625 classify_i_section(section, material, stress)
627}
628
629fn estimate_i_section_dimensions(section: &Section, props: &SectionProperties) -> (f64, f64, f64) {
631 let bounds = section.bounds();
632 let h = bounds.3 - bounds.2; let b = bounds.1 - bounds.0; let _area = props.area;
635
636 let mut x_coords: Vec<f64> = section.outer.vertices.iter().map(|v| v.x).collect();
641 let mut y_coords: Vec<f64> = section.outer.vertices.iter().map(|v| v.y).collect();
642 x_coords.sort_by(|a, b| a.partial_cmp(b).unwrap());
643 y_coords.sort_by(|a, b| a.partial_cmp(b).unwrap());
644
645 let center_x = (bounds.0 + bounds.1) / 2.0;
649 let mut x_abs: Vec<f64> = section
650 .outer
651 .vertices
652 .iter()
653 .filter(|v| (v.x - center_x).abs() < b * 0.25)
654 .map(|v| (v.x - center_x).abs())
655 .filter(|x| *x > 1e-9)
656 .collect();
657 x_abs.sort_by(|a, b| a.partial_cmp(b).unwrap());
658
659 let tw = if !x_abs.is_empty() {
660 x_abs[0] * 2.0
661 } else {
662 b * 0.1
663 };
664
665 let top_vertices: Vec<f64> = section
667 .outer
668 .vertices
669 .iter()
670 .filter(|v| v.y > bounds.3 - h * 0.1)
671 .map(|v| v.y)
672 .collect();
673 let tf = if top_vertices.len() >= 2 {
674 top_vertices
675 .iter()
676 .max_by(|a, b| a.partial_cmp(b).unwrap())
677 .unwrap()
678 - top_vertices
679 .iter()
680 .min_by(|a, b| a.partial_cmp(b).unwrap())
681 .unwrap()
682 } else {
683 h * 0.05
684 };
685
686 let hw = h - 2.0 * tf;
687
688 (tw.max(1e-6), tf.max(1e-6), hw.max(1e-6))
689}
690
691pub mod effective {
693 use super::*;
694 use crate::geometry::Point;
695 use crate::section::Section;
696 use crate::section_properties::SectionProperties;
697
698 #[derive(Debug, Clone)]
700 pub struct EffectiveProperties {
701 pub area_eff: f64,
702 pub centroid_eff: Point,
703 pub ix_eff: f64,
704 pub iy_eff: f64,
705 pub ixy_eff: f64,
706 pub classification: SectionClassification,
707 pub reduction_factors: ElementReductions,
709 }
710
711 #[derive(Debug, Clone, Default)]
712 pub struct ElementReductions {
713 pub web_rho: f64,
714 pub flange_rho: f64,
715 }
716
717 pub fn effective_section(
719 section: &Section,
720 material: &Material,
721 stress: StressDistribution,
722 ) -> EffectiveProperties {
723 let classification = classify_section(section, material, stress);
724
725 if !classification.is_class4 {
726 let props = SectionProperties::from_section(section);
728 return EffectiveProperties {
729 area_eff: props.area,
730 centroid_eff: props.centroid,
731 ix_eff: props.ix,
732 iy_eff: props.iy,
733 ixy_eff: props.ixy,
734 classification,
735 reduction_factors: ElementReductions::default(),
736 };
737 }
738
739 let fy = material.yield_strength;
741 let eps = (235e6 / fy).sqrt();
742
743 let mut rho_web = 1.0;
745 let mut rho_flange = 1.0;
746
747 if classification.web_class == SectionClass::Class4 {
749 let lambda_p = classification.web_c_t / (33.0 * eps); if lambda_p > 0.673 {
751 rho_web = (lambda_p - 0.22) / lambda_p;
752 rho_web = rho_web.clamp(0.0, 1.0);
753 }
754 }
755
756 if classification.flange_class == SectionClass::Class4 {
758 let lambda_p = classification.flange_c_t / (9.0 * eps);
759 if lambda_p > 0.673 {
760 rho_flange = (lambda_p - 0.22) / lambda_p;
761 rho_flange = rho_flange.clamp(0.0, 1.0);
762 }
763 }
764
765 let props = SectionProperties::from_section(section);
768
769 let area_red = 1.0 - (1.0 - rho_web) * 0.3 - (1.0 - rho_flange) * 0.2; let ix_red = 1.0 - (1.0 - rho_web) * 0.5 - (1.0 - rho_flange) * 0.3;
772
773 EffectiveProperties {
774 area_eff: props.area * area_red,
775 centroid_eff: props.centroid,
776 ix_eff: props.ix * ix_red,
777 iy_eff: props.iy * ix_red, ixy_eff: props.ixy * ix_red,
779 classification,
780 reduction_factors: ElementReductions {
781 web_rho: rho_web,
782 flange_rho: rho_flange,
783 },
784 }
785 }
786}
787
788trait SectionSymmetryCheck {
790 fn is_symmetric_about_x(&self) -> bool;
791 fn is_symmetric_about_y(&self) -> bool;
792}
793
794impl SectionSymmetryCheck for Section {
795 fn is_symmetric_about_x(&self) -> bool {
796 for v in &self.outer.vertices {
797 let found = self
798 .outer
799 .vertices
800 .iter()
801 .any(|v2| (v2.x - v.x).abs() < 1e-6 && (v2.y + v.y).abs() < 1e-6);
802 if !found {
803 return false;
804 }
805 }
806 true
807 }
808
809 fn is_symmetric_about_y(&self) -> bool {
810 for v in &self.outer.vertices {
811 let found = self
812 .outer
813 .vertices
814 .iter()
815 .any(|v2| (v2.y - v.y).abs() < 1e-6 && (v2.x + v.x).abs() < 1e-6);
816 if !found {
817 return false;
818 }
819 }
820 true
821 }
822}
823
824#[cfg(test)]
825mod tests {
826 use super::*;
827
828 use crate::material::presets::STEEL_S355;
829
830 use crate::section_library::ParametricSection;
831 use crate::section_library::steel::ISection;
832
833 #[test]
834 fn classify_i_section_class1() {
835 let i = ISection::from_designation("IPE300").unwrap();
837 let section = i.build();
838 let classification =
839 classify_i_section(§ion, &STEEL_S355, StressDistribution::pure_bending());
840
841 assert!(classification.overall_class >= SectionClass::Class2);
843 assert!(classification.can_plastic_moment());
844 }
845
846 #[test]
847 fn classify_i_section_class4() {
848 let i = ISection::new(1.0, 0.2, 0.003, 0.005, 0.01); let section = i.build();
851 let classification =
852 classify_i_section(§ion, &STEEL_S355, StressDistribution::pure_bending());
853
854 assert_eq!(classification.overall_class, SectionClass::Class4);
855 assert!(classification.is_class4);
856 }
857
858 #[test]
859 fn classify_chs() {
860 let chs = crate::section_library::steel::CircularHollowSectionLib::new(0.219, 0.008);
862 let section = chs.build();
863 let classification =
864 classify_hollow_section(§ion, &STEEL_S355, StressDistribution::pure_bending());
865
866 assert!(classification.overall_class >= SectionClass::Class2);
868 }
869
870 #[test]
871 fn classify_rhs() {
872 let rhs = crate::section_library::steel::RectangularHollowSection::new(
874 0.2, 0.1, 0.008, 0.012, 0.004,
875 );
876 let section = rhs.build();
877 let classification =
878 classify_hollow_section(§ion, &STEEL_S355, StressDistribution::pure_bending());
879
880 assert!(classification.overall_class >= SectionClass::Class2);
882 }
883
884 #[test]
885 fn classify_angle() {
886 let angle = crate::section_library::steel::AngleSection::equal_leg(0.1, 0.01);
887 let section = angle.build();
888 let classification = classify_angle_section(§ion, &STEEL_S355);
889
890 assert!(classification.overall_class <= SectionClass::Class1);
892 }
893
894 #[test]
895 fn epsilon_calculation() {
896 let eps_s235: f64 = (235.0e6_f64 / 235.0e6_f64).sqrt();
898 assert!((eps_s235 - 1.0).abs() < 1e-6);
899
900 let eps_s355: f64 = (235.0e6_f64 / 355.0e6_f64).sqrt();
902 assert!((eps_s355 - 0.814).abs() < 0.01);
903
904 let eps_s460: f64 = (235.0e6_f64 / 460.0e6_f64).sqrt();
906 assert!((eps_s460 - 0.715).abs() < 0.01);
907 }
908
909 #[test]
910 fn effective_section_class4() {
911 let i = ISection::new(0.5, 0.15, 0.003, 0.008, 0.01);
913 let section = i.build();
914
915 let effective =
916 effective::effective_section(§ion, &STEEL_S355, StressDistribution::pure_bending());
917
918 assert!(effective.classification.is_class4);
919 assert!(effective.area_eff < effective.classification.web_c_t * 0.001); assert!(effective.reduction_factors.web_rho < 1.0);
921 }
922
923 #[test]
924 fn class_hierarchy() {
925 assert!(SectionClass::Class1 > SectionClass::Class2);
926 assert!(SectionClass::Class2 > SectionClass::Class3);
927 assert!(SectionClass::Class3 > SectionClass::Class4);
928
929 assert!(SectionClass::Class1.can_plastic_moment());
930 assert!(SectionClass::Class2.can_plastic_moment());
931 assert!(!SectionClass::Class3.can_plastic_moment());
932 assert!(!SectionClass::Class4.can_plastic_moment());
933
934 assert!(SectionClass::Class1.can_plastic_rotation());
935 assert!(!SectionClass::Class2.can_plastic_rotation());
936 }
937
938 #[test]
939 fn stress_distribution_variants() {
940 let bending = StressDistribution::pure_bending();
941 let compression = StressDistribution::pure_compression();
942 let _web_bc = StressDistribution::web_bending_compression(0.5);
943 let _flange_bc = StressDistribution::flange_bending_compression(-0.5);
944
945 assert_eq!(bending, StressDistribution::Bending);
946 assert_eq!(compression, StressDistribution::UniformCompression);
947 }
948
949 #[test]
950 fn web_bending_compression_limits_pure_compression() {
951 let eps = 1.0;
953 let bc = web_limits(eps, StressDistribution::web_bending_compression(1.0));
954 let uc = web_limits(eps, StressDistribution::pure_compression());
955 assert!((bc.class1 - uc.class1).abs() < 1e-10);
956 assert!((bc.class2 - uc.class2).abs() < 1e-10);
957 assert!((bc.class3 - uc.class3).abs() < 1e-10);
958 }
959
960 #[test]
961 fn web_bending_compression_limits_pure_bending() {
962 let eps = 1.0;
964 let bc = web_limits(eps, StressDistribution::web_bending_compression(0.5));
965 let bending = web_limits(eps, StressDistribution::pure_bending());
966 assert!((bc.class1 - bending.class1).abs() < 1e-10);
967 assert!((bc.class2 - bending.class2).abs() < 1e-10);
968 assert!((bc.class3 - bending.class3).abs() < 1.0); }
970
971 #[test]
972 fn web_bending_compression_limits_intermediate() {
973 let eps = 1.0;
977 let bc = web_limits(eps, StressDistribution::web_bending_compression(0.75));
978 assert!((bc.class1 - 396.0 / 8.75).abs() < 1e-10);
979 assert!((bc.class2 - 456.0 / 8.75).abs() < 1e-10);
980 assert!((bc.class3 - 42.0 / 0.67).abs() < 1e-10);
981 }
982
983 #[test]
984 fn web_bending_compression_limits_zero_alpha() {
985 let eps = 1.0;
987 let bc = web_limits(eps, StressDistribution::web_bending_compression(0.0));
988 assert_eq!(bc.class1, f64::MAX);
989 assert_eq!(bc.class2, f64::MAX);
990 }
991}