1use crate::geometry::{Point, Polygon};
6use crate::material::{Material, MaterialGroup};
7use crate::section::Section;
8use crate::section_library::{ParametricSection, rectangle_polygon};
9use std::f64::consts::PI;
10
11#[derive(Debug, Clone)]
13pub struct CompositeSection {
14 pub outer: Polygon,
15 pub holes: Vec<Polygon>,
16 pub extra_outers: Vec<Polygon>,
19 pub material_groups: Vec<MaterialGroup>,
20 pub reference_material: Material,
22}
23
24impl CompositeSection {
25 pub fn single_material(section: Section, material: Material) -> Self {
27 let reference_material = material;
28 Self {
29 outer: section.outer,
30 holes: section.holes,
31 extra_outers: Vec::new(),
32 material_groups: vec![MaterialGroup::new(material, vec![0])],
33 reference_material,
34 }
35 }
36
37 pub fn new(outer: Polygon, holes: Vec<Polygon>, material_groups: Vec<MaterialGroup>) -> Self {
39 let reference_material = material_groups
40 .first()
41 .map(|g| g.material)
42 .unwrap_or_else(|| Material::default());
43 Self {
44 outer,
45 holes,
46 extra_outers: Vec::new(),
47 material_groups,
48 reference_material,
49 }
50 }
51
52 pub fn from_parametric<S: ParametricSection>(section: &S, material: Material) -> Self {
54 Self::single_material(section.build(), material)
55 }
56
57 pub fn from_components(components: Vec<(Box<dyn ParametricSection>, Point, Material)>) -> Self {
63 if components.is_empty() {
64 return Self::new(Polygon::new(vec![]), Vec::new(), Vec::new());
65 }
66
67 let mut outers: Vec<Polygon> = Vec::new();
68 let mut all_holes: Vec<Polygon> = Vec::new();
69 let mut region_materials: Vec<(usize, Vec<usize>, Material)> = Vec::new();
72
73 for (section, offset, material) in components {
74 let built = section.build();
75 let mut outer = built.outer;
76 for v in &mut outer.vertices {
77 v.x += offset.x;
78 v.y += offset.y;
79 }
80 let outer_index = outers.len();
81 outers.push(outer);
82
83 let mut hole_indices = Vec::new();
84 for mut hole in built.holes {
85 for v in &mut hole.vertices {
86 v.x += offset.x;
87 v.y += offset.y;
88 }
89 hole_indices.push(all_holes.len());
90 all_holes.push(hole);
91 }
92 region_materials.push((outer_index, hole_indices, material));
93 }
94
95 let reference_material = region_materials[0].2.clone();
96 let outer = outers.remove(0);
97
98 Self {
99 outer,
100 holes: all_holes,
101 extra_outers: outers,
102 material_groups: region_materials
103 .into_iter()
104 .map(|(_o, h, m)| MaterialGroup::new(m, h))
105 .collect(),
106 reference_material,
107 }
108 }
109
110 pub fn reference_material(&self) -> &Material {
112 &self.reference_material
113 }
114
115 pub fn modular_ratios(&self) -> Vec<f64> {
117 self.material_groups
118 .iter()
119 .map(|g| g.material.modular_ratio(&self.reference_material))
120 .collect()
121 }
122
123 pub fn transformed_properties(&self) -> crate::section_properties::SectionProperties {
129 let mut total_area = 0.0;
138 let mut first_moment_x = 0.0;
139 let mut first_moment_y = 0.0;
140 let mut ix = 0.0;
141 let mut iy = 0.0;
142 let mut ixy = 0.0;
143
144 if let Some(group) = self
146 .material_groups
147 .iter()
148 .find(|g| g.polygon_indices.contains(&0))
149 {
150 let n = group.material.modular_ratio(&self.reference_material);
151 let poly = &self.outer;
152 let signed_area = poly.signed_area() * n;
153 let centroid = poly.centroid();
154 let i_x = poly.moment_of_inertia_x() * n;
155 let i_y = poly.moment_of_inertia_y() * n;
156 let i_xy = poly.product_of_inertia_xy() * n;
157
158 total_area += signed_area;
159 first_moment_x += signed_area * centroid.x;
160 first_moment_y += signed_area * centroid.y;
161 ix += i_x;
162 iy += i_y;
163 ixy += i_xy;
164 }
165
166 for (i, hole) in self.holes.iter().enumerate() {
168 let poly_index = i + 1;
169 if let Some(group) = self
170 .material_groups
171 .iter()
172 .find(|g| g.polygon_indices.contains(&poly_index))
173 {
174 let n = group.material.modular_ratio(&self.reference_material);
175 let signed_area = hole.signed_area() * n; let centroid = hole.centroid();
178 let i_x = hole.moment_of_inertia_x() * n;
179 let i_y = hole.moment_of_inertia_y() * n;
180 let i_xy = hole.product_of_inertia_xy() * n;
181
182 total_area += signed_area;
183 first_moment_x += signed_area * centroid.x;
184 first_moment_y += signed_area * centroid.y;
185 ix += i_x;
186 iy += i_y;
187 ixy += i_xy;
188 }
189 }
190
191 for (i, extra) in self.extra_outers.iter().enumerate() {
195 if let Some(group) = self.material_groups.get(i + 1) {
196 let n = group.material.modular_ratio(&self.reference_material);
197 let signed_area = extra.signed_area() * n;
198 let centroid = extra.centroid();
199 let i_x = extra.moment_of_inertia_x() * n;
200 let i_y = extra.moment_of_inertia_y() * n;
201 let i_xy = extra.product_of_inertia_xy() * n;
202
203 total_area += signed_area;
204 first_moment_x += signed_area * centroid.x;
205 first_moment_y += signed_area * centroid.y;
206 ix += i_x;
207 iy += i_y;
208 ixy += i_xy;
209 }
210 }
211
212 assert!(
213 total_area.abs() > f64::EPSILON,
214 "Transformed section area too small"
215 );
216
217 let centroid = Point::new(first_moment_x / total_area, first_moment_y / total_area);
219
220 let ix_c = ix - total_area * centroid.y.powi(2);
222 let iy_c = iy - total_area * centroid.x.powi(2);
223 let ixy_c = ixy - total_area * centroid.x * centroid.y;
224
225 let max_fiber_y = self
226 .outer
227 .vertices
228 .iter()
229 .chain(self.holes.iter().flat_map(|p| p.vertices.iter()))
230 .chain(self.extra_outers.iter().flat_map(|p| p.vertices.iter()))
231 .map(|v| (v.y - centroid.y).abs())
232 .fold(0.0, f64::max);
233 let max_fiber_x = self
234 .outer
235 .vertices
236 .iter()
237 .chain(self.holes.iter().flat_map(|p| p.vertices.iter()))
238 .chain(self.extra_outers.iter().flat_map(|p| p.vertices.iter()))
239 .map(|v| (v.x - centroid.x).abs())
240 .fold(0.0, f64::max);
241
242 let avg = (ix_c + iy_c) * 0.5;
243 let diff = (ix_c - iy_c) * 0.5;
244 let radius = (diff * diff + ixy_c * ixy_c).sqrt();
245 let i11 = avg + radius;
246 let i22 = avg - radius;
247 let phi = 0.5 * (2.0 * ixy_c).atan2(ix_c - iy_c);
248
249 crate::section_properties::SectionProperties {
250 geometric: crate::section_properties::GeometricProperties {
251 area: total_area,
252 centroid,
253 ix: ix_c,
254 iy: iy_c,
255 ixy: ixy_c,
256 max_fiber_distance_y: max_fiber_y,
257 max_fiber_distance_x: max_fiber_x,
258 zxx_plus: ix_c / max_fiber_y.max(1e-10),
259 zxx_minus: ix_c / max_fiber_y.max(1e-10),
260 zyy_plus: iy_c / max_fiber_x.max(1e-10),
261 zyy_minus: iy_c / max_fiber_x.max(1e-10),
262 perimeter: self.outer.perimeter(),
263 qx: 0.0,
264 qy: 0.0,
265 ixx_g: ix_c + total_area * centroid.y.powi(2),
266 iyy_g: iy_c + total_area * centroid.x.powi(2),
267 ixy_g: ixy_c + total_area * centroid.x * centroid.y,
268 },
269 principal: crate::section_properties::PrincipalProperties {
270 i11,
271 i22,
272 phi,
273 ..Default::default()
274 },
275 gyration: crate::section_properties::GyrationProperties {
276 rx: (ix_c / total_area).sqrt(),
277 ry: (iy_c / total_area).sqrt(),
278 r11: (i11 / total_area).sqrt(),
279 r22: (i22 / total_area).sqrt(),
280 polar: ((ix_c + iy_c) / total_area).sqrt(),
281 },
282 }
283 }
284
285 pub fn material_group_properties(
287 &self,
288 group_index: usize,
289 ) -> Option<crate::section_properties::SectionProperties> {
290 if group_index >= self.material_groups.len() {
291 return None;
292 }
293 let group = &self.material_groups[group_index];
294
295 let mut area = 0.0;
296 let mut fx = 0.0;
297 let mut fy = 0.0;
298 let mut ix = 0.0;
299 let mut iy = 0.0;
300 let mut ixy = 0.0;
301
302 for &poly_idx in &group.polygon_indices {
303 let poly = if poly_idx == 0 {
304 &self.outer
305 } else if poly_idx > 0 && poly_idx <= self.holes.len() {
306 &self.holes[poly_idx - 1]
307 } else {
308 continue;
309 };
310
311 let signed_area = poly.signed_area();
312 let centroid = poly.centroid();
313
314 area += signed_area;
315 fx += signed_area * centroid.x;
316 fy += signed_area * centroid.y;
317 ix += poly.moment_of_inertia_x();
318 iy += poly.moment_of_inertia_y();
319 ixy += poly.product_of_inertia_xy();
320 }
321
322 if area.abs() < f64::EPSILON {
323 return None;
324 }
325
326 let centroid = Point::new(fx / area, fy / area);
327 let ix_c = ix - area * centroid.y.powi(2);
328 let iy_c = iy - area * centroid.x.powi(2);
329 let ixy_c = ixy - area * centroid.x * centroid.y;
330
331 let max_fiber_y = self
332 .outer
333 .vertices
334 .iter()
335 .chain(self.holes.iter().flat_map(|p| p.vertices.iter()))
336 .chain(self.extra_outers.iter().flat_map(|p| p.vertices.iter()))
337 .map(|v| (v.y - centroid.y).abs())
338 .fold(0.0, f64::max);
339 let max_fiber_x = self
340 .outer
341 .vertices
342 .iter()
343 .chain(self.holes.iter().flat_map(|p| p.vertices.iter()))
344 .chain(self.extra_outers.iter().flat_map(|p| p.vertices.iter()))
345 .map(|v| (v.x - centroid.x).abs())
346 .fold(0.0, f64::max);
347
348 let avg = (ix_c + iy_c) * 0.5;
349 let diff = (ix_c - iy_c) * 0.5;
350 let radius = (diff * diff + ixy_c * ixy_c).sqrt();
351 let i11 = avg + radius;
352 let i22 = avg - radius;
353 let phi = 0.5 * (2.0 * ixy_c).atan2(ix_c - iy_c);
354
355 Some(crate::section_properties::SectionProperties {
356 geometric: crate::section_properties::GeometricProperties {
357 area,
358 centroid,
359 ix: ix_c,
360 iy: iy_c,
361 ixy: ixy_c,
362 max_fiber_distance_y: max_fiber_y,
363 max_fiber_distance_x: max_fiber_x,
364 zxx_plus: ix_c / max_fiber_y.max(1e-10),
365 zxx_minus: ix_c / max_fiber_y.max(1e-10),
366 zyy_plus: iy_c / max_fiber_x.max(1e-10),
367 zyy_minus: iy_c / max_fiber_x.max(1e-10),
368 perimeter: self.outer.perimeter(),
369 qx: 0.0,
370 qy: 0.0,
371 ixx_g: ix_c + area * centroid.y.powi(2),
372 iyy_g: iy_c + area * centroid.x.powi(2),
373 ixy_g: ixy_c + area * centroid.x * centroid.y,
374 },
375 principal: crate::section_properties::PrincipalProperties {
376 i11,
377 i22,
378 phi,
379 ..Default::default()
380 },
381 gyration: crate::section_properties::GyrationProperties {
382 rx: (ix_c / area).sqrt(),
383 ry: (iy_c / area).sqrt(),
384 r11: (i11 / area).sqrt(),
385 r22: (i22 / area).sqrt(),
386 polar: ((ix_c + iy_c) / area).sqrt(),
387 },
388 })
389 }
390
391 pub fn n_groups(&self) -> usize {
393 self.material_groups.len()
394 }
395
396 pub fn group(&self, index: usize) -> Option<&MaterialGroup> {
398 self.material_groups.get(index)
399 }
400
401 pub fn add_group(&mut self, group: MaterialGroup) {
403 self.material_groups.push(group);
404 }
405}
406
407#[derive(Debug)]
409pub struct SteelConcreteComposite {
410 pub steel_section: Box<dyn ParametricSection>,
411 pub concrete_slab: CompositeSlab,
412 pub shear_connectors: ShearConnectorLayout,
413 pub construction_stage: ConstructionStage,
414}
415
416#[derive(Debug, Clone, PartialEq)]
417pub struct CompositeSlab {
418 pub width: f64, pub thickness: f64, pub deck_thickness: f64, pub deck_orientation: DeckOrientation,
422 pub concrete_grade: ConcreteGrade,
423 pub reinforcement: Vec<RebarLayer>,
424}
425
426#[derive(Debug, Clone, Copy, PartialEq, Eq)]
427pub enum DeckOrientation {
428 Parallel, Perpendicular, }
431
432#[derive(Debug, Clone, Copy, PartialEq, Eq)]
433pub enum ConcreteGrade {
434 C20_25,
435 C25_30,
436 C30_37,
437 C35_45,
438 C40_50,
439 C45_55,
440 C50_60,
441}
442
443impl ConcreteGrade {
444 pub fn fck(&self) -> f64 {
445 match self {
446 ConcreteGrade::C20_25 => 20e6,
447 ConcreteGrade::C25_30 => 25e6,
448 ConcreteGrade::C30_37 => 30e6,
449 ConcreteGrade::C35_45 => 35e6,
450 ConcreteGrade::C40_50 => 40e6,
451 ConcreteGrade::C45_55 => 45e6,
452 ConcreteGrade::C50_60 => 50e6,
453 }
454 }
455
456 pub fn fcm(&self) -> f64 {
457 self.fck() + 8e6
458 }
459
460 pub fn ecm(&self) -> f64 {
461 22e3 * (self.fcm() / 10e6).powf(0.3) * 1e6 }
464
465 pub fn material(&self) -> Material {
466 use crate::material::Material;
467 Material::with_all(
468 self.ecm(),
469 self.ecm() / (2.0 * (1.0 + 0.2)),
470 0.2,
471 2400.0,
472 10e-6,
473 self.fck(),
474 self.fcm(),
475 "Concrete",
476 )
477 }
478}
479
480#[derive(Debug, Clone, Copy, PartialEq)]
481pub struct RebarLayer {
482 pub y: f64, pub diameter: f64,
484 pub spacing: f64,
485 pub count_per_m: usize, pub material: Material,
487}
488
489#[derive(Debug, Clone, Copy, PartialEq)]
490pub struct ShearConnectorLayout {
491 pub type_: ShearConnectorType,
492 pub diameter: f64,
493 pub height: f64,
494 pub spacing: f64, pub n_per_row: usize, pub material: Material,
497}
498
499#[derive(Debug, Clone, Copy, PartialEq, Eq)]
500pub enum ShearConnectorType {
501 HeadedStud,
502 Channel,
503 Perfobond,
504}
505
506#[derive(Debug, Clone, Copy, PartialEq, Eq)]
507pub enum ConstructionStage {
508 BareSteel,
510 SteelWetConcrete,
512 Composite,
514 PartialInteraction,
516}
517
518impl SteelConcreteComposite {
519 pub fn new(
520 steel_section: impl ParametricSection + 'static,
521 concrete_slab: CompositeSlab,
522 shear_connectors: ShearConnectorLayout,
523 ) -> Self {
524 Self {
525 steel_section: Box::new(steel_section),
526 concrete_slab,
527 shear_connectors,
528 construction_stage: ConstructionStage::Composite,
529 }
530 }
531
532 pub fn with_stage(mut self, stage: ConstructionStage) -> Self {
533 self.construction_stage = stage;
534 self
535 }
536
537 pub fn effective_width(&self, span: f64, beam_spacing: f64) -> f64 {
539 let beff = match self.concrete_slab.deck_orientation {
540 DeckOrientation::Parallel => {
541 let b0 = span / 8.0;
543 (b0.min(beam_spacing)).min(self.concrete_slab.width)
544 }
545 DeckOrientation::Perpendicular => {
546 let b0 = span / 8.0;
548 (b0.min(beam_spacing / 2.0)).min(self.concrete_slab.width)
549 }
550 };
551 beff
552 }
553
554 pub fn modular_ratio(&self, long_term: bool) -> f64 {
556 let steel_mat = crate::material::presets::STEEL_S355;
557 let conc_mat = self.concrete_slab.concrete_grade.material();
558 let n = steel_mat.modular_ratio(&conc_mat);
559 if long_term {
560 n * 2.0
563 } else {
564 n
565 }
566 }
567
568 pub fn build_section(&self, span: f64, beam_spacing: f64) -> CompositeSection {
570 let beff = self.effective_width(span, beam_spacing);
571 let _n = self.modular_ratio(matches!(
572 self.construction_stage,
573 ConstructionStage::Composite
574 ));
575
576 let steel_sec = self.steel_section.build();
577 let steel_mat = crate::material::presets::STEEL_S355;
578 let conc_mat = self.concrete_slab.concrete_grade.material();
579
580 let steel_props = crate::section_properties::SectionProperties::from_section(&steel_sec);
582 let steel_top_y = steel_props.centroid.y
583 + steel_sec
584 .outer
585 .vertices
586 .iter()
587 .map(|v| v.y)
588 .max_by(|a, b| a.partial_cmp(b).unwrap())
589 .unwrap_or(0.0);
590
591 let slab_y = steel_top_y + self.concrete_slab.thickness / 2.0;
593 let slab_offset = Point::new(0.0, slab_y - steel_props.centroid.y);
594
595 CompositeSection::from_components(vec![
597 (
598 Box::new(self.steel_section.build()),
599 Point::new(0.0, 0.0),
600 steel_mat,
601 ),
602 (
603 Box::new(RectangularSection {
604 width: beff,
605 height: self.concrete_slab.thickness,
606 }),
607 slab_offset,
608 conc_mat,
609 ),
610 ])
611 }
612
613 pub fn composite_properties(
615 &self,
616 span: f64,
617 beam_spacing: f64,
618 ) -> crate::section_properties::SectionProperties {
619 let comp = self.build_section(span, beam_spacing);
620 comp.transformed_properties()
621 }
622
623 pub fn plastic_moment_capacity(&self, span: f64, beam_spacing: f64) -> f64 {
625 let props = self.composite_properties(span, beam_spacing);
627 let steel_mat = crate::material::presets::STEEL_S355;
628 let fy = steel_mat.yield_strength;
629 props.ix.max(props.iy) / (self.height() / 2.0) * fy
632 }
633
634 fn height(&self) -> f64 {
635 let steel_sec = self.steel_section.build();
636 let _steel_props = crate::section_properties::SectionProperties::from_section(&steel_sec);
637 steel_sec
638 .outer
639 .vertices
640 .iter()
641 .map(|v| v.y)
642 .max_by(|a, b| a.partial_cmp(b).unwrap())
643 .unwrap_or(0.0)
644 - steel_sec
645 .outer
646 .vertices
647 .iter()
648 .map(|v| v.y)
649 .min_by(|a, b| a.partial_cmp(b).unwrap())
650 .unwrap_or(0.0)
651 + self.concrete_slab.thickness
652 }
653}
654
655#[derive(Debug, Clone, Copy, PartialEq)]
657struct RectangularSection {
658 width: f64,
659 height: f64,
660}
661
662impl ParametricSection for RectangularSection {
663 fn build(&self) -> Section {
664 Section::new(rectangle_polygon(self.width, self.height), Vec::new())
665 }
666
667 fn designation(&self) -> String {
668 format!(
669 "RECT {:.0}x{:.0}",
670 self.width * 1000.0,
671 self.height * 1000.0
672 )
673 }
674}
675
676#[derive(Debug)]
678pub struct TimberConcreteComposite {
679 pub timber_section: Box<dyn ParametricSection>,
680 pub concrete_slab: CompositeSlab,
681 pub connection: TCCConnection,
682}
683
684#[derive(Debug, Clone, Copy, PartialEq)]
685pub struct TCCConnection {
686 pub type_: TCCConnectorType,
687 pub stiffness: f64, pub spacing: f64, pub n_per_row: usize,
690}
691
692#[derive(Debug, Clone, Copy, PartialEq, Eq)]
693pub enum TCCConnectorType {
694 Screw,
695 Nail,
696 Dowel,
697 Notch,
698 Glue,
699 ShearPlate,
700}
701
702impl TimberConcreteComposite {
703 pub fn new(
704 timber_section: impl ParametricSection + 'static,
705 concrete_slab: CompositeSlab,
706 connection: TCCConnection,
707 ) -> Self {
708 Self {
709 timber_section: Box::new(timber_section),
710 concrete_slab,
711 connection,
712 }
713 }
714
715 pub fn gamma(&self, span: f64) -> f64 {
717 let k = self.connection.stiffness * 1000.0; let s = self.connection.spacing;
720 let n = self.connection.n_per_row as f64;
721 let k_ser = k * n / s; let timber_mat = crate::material::presets::TIMBER_GL24H;
725 let conc_mat = self.concrete_slab.concrete_grade.material();
726
727 let timber_sec = self.timber_section.build();
729 let timber_props = crate::section_properties::SectionProperties::from_section(&timber_sec);
730
731 let beff = self.concrete_slab.width;
733 let tc = self.concrete_slab.thickness;
734
735 let ei_timber = timber_mat.youngs_modulus * timber_props.ix.max(timber_props.iy);
738 let ei_concrete = conc_mat.youngs_modulus * beff * tc.powi(3) / 12.0;
739 let ei_eff = ei_timber + ei_concrete;
740
741 let gamma = 1.0 / (1.0 + (PI * PI * ei_eff) / (k_ser * span * span));
742 gamma.clamp(0.0, 1.0)
743 }
744}
745
746#[derive(Debug)]
748pub struct SandwichPanel {
749 pub face_sheet: Box<dyn ParametricSection>,
750 pub core: Box<dyn ParametricSection>,
751 pub face_material: Material,
752 pub core_material: Material,
753}
754
755impl SandwichPanel {
756 pub fn new(
757 face_sheet: impl ParametricSection + 'static,
758 core: impl ParametricSection + 'static,
759 face_material: Material,
760 core_material: Material,
761 ) -> Self {
762 Self {
763 face_sheet: Box::new(face_sheet),
764 core: Box::new(core),
765 face_material,
766 core_material,
767 }
768 }
769
770 pub fn build(&self) -> CompositeSection {
771 let face_sec = self.face_sheet.build();
772 let core_sec = self.core.build();
773
774 let face_props = crate::section_properties::SectionProperties::from_section(&face_sec);
775 let core_props = crate::section_properties::SectionProperties::from_section(&core_sec);
776
777 let face_offset = Point::new(0.0, core_props.centroid.y + face_props.centroid.y);
779
780 CompositeSection::from_components(vec![
781 (
782 Box::new(self.face_sheet.build()),
783 Point::new(0.0, face_offset.y),
784 self.face_material,
785 ),
786 (
787 Box::new(self.core.build()),
788 Point::new(0.0, 0.0),
789 self.core_material,
790 ),
791 (
792 Box::new(self.face_sheet.build()),
793 Point::new(0.0, -face_offset.y),
794 self.face_material,
795 ),
796 ])
797 }
798
799 pub fn transformed_properties(&self) -> crate::section_properties::SectionProperties {
800 self.build().transformed_properties()
801 }
802
803 pub fn bending_stiffness_d(&self, width: f64) -> f64 {
805 let props = self.transformed_properties();
808 self.face_material.youngs_modulus * props.ix * width
809 }
810}
811
812#[cfg(test)]
813mod tests {
814 use super::*;
815 use crate::material::presets::*;
816 use crate::section_library::ParametricSection;
817 use crate::section_library::concrete::RectangularConcreteSection;
818 use crate::section_library::steel::ISection;
819
820 #[test]
821 fn composite_single_material() {
822 let rect = RectangularConcreteSection::new(0.3, 0.5);
823 let comp = CompositeSection::from_parametric(&rect, CONCRETE_C30_37);
824 let props = comp.transformed_properties();
825 assert!((props.area - 0.15).abs() < 1e-6);
826 }
827
828 #[test]
829 fn composite_steel_concrete() {
830 let steel = ISection::from_designation("IPE300").expect("IPE300");
831 let slab = CompositeSlab {
832 width: 1.0,
833 thickness: 0.15,
834 deck_thickness: 0.0,
835 deck_orientation: DeckOrientation::Perpendicular,
836 concrete_grade: ConcreteGrade::C30_37,
837 reinforcement: vec![],
838 };
839 let connectors = ShearConnectorLayout {
840 type_: ShearConnectorType::HeadedStud,
841 diameter: 0.019,
842 height: 0.1,
843 spacing: 0.3,
844 n_per_row: 2,
845 material: STEEL_S355,
846 };
847 let composite = SteelConcreteComposite::new(steel, slab, connectors)
848 .with_stage(ConstructionStage::Composite);
849
850 let props = composite.composite_properties(6.0, 3.0);
851 assert!(props.area > 0.0);
852 assert!(props.ix > 0.0);
853 }
854
855 #[test]
856 fn concrete_grade_properties() {
857 let c30 = ConcreteGrade::C30_37;
858 assert!((c30.fck() - 30e6).abs() < 1e-3);
859 assert!((c30.ecm() - 33e9).abs() < 1e9); }
861
862 #[test]
863 fn modular_ratio_steel_concrete() {
864 let steel = ISection::from_designation("IPE300").expect("IPE300");
865 let slab = CompositeSlab {
866 width: 1.0,
867 thickness: 0.15,
868 deck_thickness: 0.0,
869 deck_orientation: DeckOrientation::Perpendicular,
870 concrete_grade: ConcreteGrade::C30_37,
871 reinforcement: vec![],
872 };
873 let connectors = ShearConnectorLayout {
874 type_: ShearConnectorType::HeadedStud,
875 diameter: 0.019,
876 height: 0.1,
877 spacing: 0.3,
878 n_per_row: 2,
879 material: STEEL_S355,
880 };
881 let composite = SteelConcreteComposite::new(steel, slab, connectors);
882 let n_short = composite.modular_ratio(false);
883 let n_long = composite.modular_ratio(true);
884 assert!(n_short > 6.0 && n_short < 7.0); assert!((n_long / n_short - 2.0).abs() < 0.1);
886 }
887
888 #[test]
889 fn sandwich_panel() {
890 use crate::section_library::primitive::RectangularSection as PrimRect;
891 let face = PrimRect::new(1.0, 0.002);
892 let core = PrimRect::new(1.0, 0.1);
893 let panel = SandwichPanel::new(
894 face,
895 core,
896 STEEL_S355,
897 crate::material::presets::ALUMINUM_6061_T6,
898 );
899 let props = panel.transformed_properties();
900 assert!(props.area > 0.0);
901 assert!(props.ix > 0.0);
902 }
903
904 #[test]
905 fn transformed_single_material_matches_homogeneous() {
906 let rect = RectangularConcreteSection::new(0.3, 0.5);
908 let comp = CompositeSection::from_parametric(&rect, CONCRETE_C30_37);
909 let tprops = comp.transformed_properties();
910
911 let section = rect.build();
912 let hprops = crate::section_properties::SectionProperties::from_section(§ion);
913
914 assert!((tprops.area - hprops.area).abs() / hprops.area < 1e-6);
915 assert!((tprops.ix - hprops.ix).abs() / hprops.ix < 1e-6);
916 assert!((tprops.iy - hprops.iy).abs() / hprops.iy < 1e-6);
917 }
918
919 #[test]
920 fn transformed_area_modular_ratio() {
921 let concrete_poly = crate::section_library::rectangle_polygon(0.3, 0.5);
924 let steel_poly = crate::section_library::rectangle_polygon(0.3, 0.01);
925
926 let mut steel_shifted = steel_poly.clone();
928 for v in &mut steel_shifted.vertices {
929 v.y += 0.255; }
931
932 let _groups = vec![
933 MaterialGroup::new(CONCRETE_C30_37, vec![0]),
934 MaterialGroup::new(STEEL_S355, vec![1]),
935 ];
936
937 let comp = CompositeSection::new(
940 concrete_poly,
941 vec![],
942 vec![MaterialGroup::new(CONCRETE_C30_37, vec![0])],
943 );
944 let props = comp.transformed_properties();
945
946 assert!((props.area - 0.15).abs() < 1e-6);
948 }
949
950 #[test]
951 fn transformed_steel_concrete_section() {
952 let i_section = ISection::new(0.2, 0.1, 0.005, 0.008, 0.0);
954 let steel_section = i_section.build();
955
956 let comp = CompositeSection::single_material(steel_section.clone(), STEEL_S355);
958 let props = comp.transformed_properties();
959
960 let original_area = steel_section.area();
962 assert!((props.area - original_area).abs() / original_area < 1e-6);
963
964 let orig_props = crate::section_properties::SectionProperties::from_section(&steel_section);
966 assert!((props.ix - orig_props.ix).abs() / orig_props.ix < 1e-6);
967 }
968
969 #[test]
970 fn transformed_centroid_shift() {
971 let rect = RectangularConcreteSection::new(0.3, 0.5);
973 let comp = CompositeSection::from_parametric(&rect, CONCRETE_C30_37);
974 let props = comp.transformed_properties();
975
976 assert!(props.centroid.x.abs() < 1e-6);
978 assert!(props.centroid.y.abs() < 1e-6);
979 }
980}