Skip to main content

section_properties/
plastic.rs

1//! Plastic and advanced analysis module.
2//!
3//! Provides plastic section analysis, interaction diagrams,
4//! warping torsion, section classification (EN 1993), and advanced post-processing.
5
6pub mod classification;
7pub mod interaction;
8pub mod plastic_section;
9pub mod warping;
10pub mod warping_fem;
11
12pub use classification::{
13    ClassLimit, SectionClass, SectionClassification, StressDistribution, classify_section,
14    effective,
15};
16pub use interaction::{
17    CapacityCheck, InteractionDiagram, InteractionPoint, LoadCase3D, aisc360, en1993,
18};
19pub use plastic_section::{
20    FullPlasticProperties, PlasticAxis, PlasticNeutralAxis, PlasticProperties, PlasticSection,
21};
22pub use warping::{TorsionAnalysis, WarpingProperties, trefftz};
23
24use crate::material::Material;
25use crate::section::Section;
26
27/// High-level plastic analysis for a section.
28#[derive(Debug, Clone)]
29pub struct PlasticAnalysis {
30    pub section: Section,
31    pub material: Material,
32    pub plastic_section: PlasticSection,
33    pub interaction: InteractionDiagram,
34    pub warping: WarpingProperties,
35}
36
37impl PlasticAnalysis {
38    /// Create a complete plastic analysis for a section.
39    pub fn new(section: Section, material: Material) -> Self {
40        let plastic_section = PlasticSection::new(section.clone(), material);
41        let interaction = InteractionDiagram::new(section.clone(), material);
42        let warping = WarpingProperties::from_section(&section, material.poissons_ratio);
43
44        Self {
45            section,
46            material,
47            plastic_section,
48            interaction,
49            warping,
50        }
51    }
52
53    /// Full plastic properties (both axes).
54    pub fn full_properties(&self) -> crate::plastic::plastic_section::FullPlasticProperties {
55        self.plastic_section.full_plastic_properties()
56    }
57
58    /// Section classification per EN 1993-1-1.
59    pub fn classification(&self, stress: StressDistribution) -> SectionClassification {
60        classify_section(&self.section, &self.material, stress)
61    }
62
63    /// Check capacity for a load case.
64    pub fn check_capacity(&self, load: LoadCase3D, gamma_m0: f64) -> CapacityCheck {
65        self.interaction.check_capacity(load, gamma_m0)
66    }
67
68    /// Check capacity using exact plastic surface.
69    pub fn check_capacity_exact(&self, load: LoadCase3D, gamma_m0: f64) -> CapacityCheck {
70        self.interaction.check_capacity_exact(load, gamma_m0)
71    }
72
73    /// EN 1993 combined bending and axial check.
74    pub fn check_en1993(
75        &self,
76        n_ed: f64,
77        m_y_ed: f64,
78        m_z_ed: f64,
79        gamma_m0: f64,
80        gamma_m1: f64,
81    ) -> CapacityCheck {
82        en1993::check_combined_bending_axial(
83            &self.section,
84            &self.material,
85            n_ed,
86            m_y_ed,
87            m_z_ed,
88            gamma_m0,
89            gamma_m1,
90        )
91    }
92
93    /// AISC 360 combined forces check.
94    pub fn check_aisc360(
95        &self,
96        p_u: f64,
97        m_ux: f64,
98        m_uy: f64,
99        phi_c: f64,
100        phi_b: f64,
101    ) -> CapacityCheck {
102        aisc360::check_h1(&self.section, &self.material, p_u, m_ux, m_uy, phi_c, phi_b)
103    }
104
105    /// Pure torsion analysis.
106    pub fn torsion_analysis(&self, torque: f64) -> TorsionAnalysis {
107        TorsionAnalysis::pure_torsion(&self.section, torque, &self.material)
108    }
109
110    /// Constrained torsion analysis (torsion + warping).
111    pub fn constrained_torsion_analysis(&self, torque: f64, bimoment: f64) -> TorsionAnalysis {
112        TorsionAnalysis::constrained_torsion(&self.section, torque, bimoment, &self.material)
113    }
114
115    /// Warping properties.
116    pub fn warping_properties(&self) -> &WarpingProperties {
117        &self.warping
118    }
119
120    /// Shape factors.
121    pub fn shape_factors(&self) -> (f64, f64) {
122        let full = self.full_properties();
123        (full.shape_factor_x, full.shape_factor_y)
124    }
125
126    /// Plastic moment capacities.
127    pub fn plastic_moments(&self) -> (f64, f64) {
128        let full = self.full_properties();
129        (
130            full.x_axis.plastic_moment_capacity,
131            full.y_axis.plastic_moment_capacity,
132        )
133    }
134
135    /// Yield moments.
136    pub fn yield_moments(&self) -> (f64, f64) {
137        let full = self.full_properties();
138        (full.x_axis.yield_moment, full.y_axis.yield_moment)
139    }
140}
141
142#[cfg(test)]
143mod tests {
144    use super::*;
145    use crate::geometry::{Point, Polygon};
146    use crate::material::presets::STEEL_S355;
147    use crate::section::Section;
148    use crate::section_library::ParametricSection;
149
150    #[test]
151    fn plastic_analysis_i_section() {
152        let i = crate::section_library::steel::ISection::new(0.3, 0.15, 0.007, 0.01, 0.012);
153        let section = i.build();
154        let analysis = PlasticAnalysis::new(section, STEEL_S355);
155
156        let full = analysis.full_properties();
157        assert!(full.shape_factor_x > 1.0);
158        assert!(full.shape_factor_y > 1.0);
159
160        let (mpl_x, mpl_y) = analysis.plastic_moments();
161        let (my_x, my_y) = analysis.yield_moments();
162
163        assert!(mpl_x > my_x);
164        assert!(mpl_y > my_y);
165    }
166
167    #[test]
168    fn plastic_analysis_capacity() {
169        let i = crate::section_library::steel::ISection::new(0.3, 0.15, 0.007, 0.01, 0.012);
170        let section = i.build();
171        let analysis = PlasticAnalysis::new(section, STEEL_S355);
172
173        let full = analysis.full_properties();
174        let load = LoadCase3D::new(
175            full.x_axis.plastic_moment_capacity * 0.1,
176            full.x_axis.plastic_moment_capacity * 0.8,
177            0.0,
178        );
179
180        let check = analysis.check_capacity(load, 1.0);
181        assert!(check.utilization > 0.0);
182    }
183
184    #[test]
185    fn plastic_analysis_torsion() {
186        let i = crate::section_library::steel::ISection::new(0.3, 0.15, 0.007, 0.01, 0.012);
187        let section = i.build();
188        let analysis = PlasticAnalysis::new(section, STEEL_S355);
189
190        let torsion = analysis.torsion_analysis(10e3);
191        assert!(torsion.tau_sv_max > 0.0);
192        assert!(torsion.theta_prime > 0.0);
193
194        let constrained = analysis.constrained_torsion_analysis(10e3, 5e3);
195        assert!(constrained.sigma_w_max >= 0.0);
196    }
197
198    #[test]
199    fn plastic_analysis_rectangular() {
200        let poly = Polygon::new(vec![
201            Point::new(-0.1, -0.05),
202            Point::new(0.1, -0.05),
203            Point::new(0.1, 0.05),
204            Point::new(-0.1, 0.05),
205        ]);
206        let section = Section::new(poly, vec![]);
207        let analysis = PlasticAnalysis::new(section, STEEL_S355);
208
209        let (sf_x, sf_y) = analysis.shape_factors();
210        assert!((sf_x - 1.5).abs() < 0.1);
211        assert!((sf_y - 1.5).abs() < 0.1);
212    }
213
214    #[test]
215    fn section_classification() {
216        let i = crate::section_library::steel::ISection::from_designation("IPE300").unwrap();
217        let section = i.build();
218        let analysis = PlasticAnalysis::new(section, STEEL_S355);
219
220        let class = analysis.classification(StressDistribution::pure_bending());
221        assert!(class.overall_class >= crate::plastic::SectionClass::Class2);
222        assert!(class.can_plastic_moment());
223    }
224}