squid_n_core/section_shape/
builder.rs1use super::constants::{KAPPA_RC, N_S_EQ};
4use super::geometry::h_web_shear_area;
5use super::types::SectionShape;
6use crate::ids::SectionId;
7use crate::model::Section;
8
9impl SectionShape {
10 pub fn to_section(&self, id: SectionId, name: String) -> Section {
17 let area = self.calc_area();
18 let iy = self.calc_iy();
19 let iz = self.calc_iz();
20 let j = self.calc_j();
21 let (depth, width, as_y, as_z) = match *self {
28 SectionShape::SteelH {
29 height,
30 width,
31 web_thick,
32 flange_thick,
33 } => (
34 height,
35 width,
36 2.0 * width * flange_thick,
37 h_web_shear_area(height, web_thick),
38 ),
39 SectionShape::SteelBox {
40 height,
41 width,
42 thick,
43 ..
44 }
45 | SectionShape::CftBox {
46 height,
47 width,
48 thick,
49 } => (
50 height,
51 width,
52 2.0 * thick * (width - 2.0 * thick).max(0.0),
53 2.0 * thick * (height - 2.0 * thick).max(0.0),
54 ),
55 SectionShape::SteelAngle {
56 leg_a,
57 leg_b,
58 thick,
59 } => (
60 leg_a.max(leg_b),
61 leg_a.min(leg_b),
62 leg_b * thick,
63 leg_a * thick,
64 ),
65 SectionShape::SteelChannel {
66 height,
67 width,
68 web_thick,
69 flange_thick,
70 } => (
71 height,
72 width,
73 2.0 * width * flange_thick,
74 h_web_shear_area(height, web_thick),
75 ),
76 SectionShape::SteelTee {
77 height,
78 width,
79 web_thick,
80 flange_thick,
81 } => (
82 height,
83 width,
84 width * flange_thick,
85 h_web_shear_area(height, web_thick),
86 ),
87 SectionShape::SteelPipe { outer_dia, .. } | SectionShape::CftPipe { outer_dia, .. } => {
88 (outer_dia, outer_dia, area / 2.0, area / 2.0)
89 }
90 SectionShape::SteelFlatBar { width, thick } => (
92 thick,
93 width,
94 width * thick / KAPPA_RC,
95 width * thick / KAPPA_RC,
96 ),
97 SectionShape::SteelRoundBar { dia } => (dia, dia, area * 0.9, area * 0.9),
99 SectionShape::SteelLipChannel {
101 height,
102 width,
103 thick,
104 ..
105 } => (
106 height,
107 width,
108 2.0 * (width - thick) * thick,
109 h_web_shear_area(height, thick),
110 ),
111 SectionShape::SteelBuiltH {
113 height,
114 upper_width,
115 upper_thick,
116 lower_width,
117 lower_thick,
118 web_thick,
119 } => (
120 height,
121 upper_width.max(lower_width),
122 upper_width * upper_thick + lower_width * lower_thick,
123 h_web_shear_area(height, web_thick),
124 ),
125 SectionShape::RcRect { b, d, .. } => (d, b, b * d / KAPPA_RC, b * d / KAPPA_RC),
126 SectionShape::RcCircle { d, .. } => (d, d, area / KAPPA_RC, area / KAPPA_RC),
127 SectionShape::SrcRect {
128 b,
129 d,
130 steel_height,
131 steel_width,
132 steel_web_thick,
133 steel_flange_thick,
134 ..
135 } => {
136 let rc_as = b * d / KAPPA_RC;
137 let s_web = h_web_shear_area(steel_height, steel_web_thick);
138 let s_flange = 2.0 * steel_width * steel_flange_thick;
139 (
140 d,
141 b,
142 rc_as + (N_S_EQ - 1.0) * s_flange,
143 rc_as + (N_S_EQ - 1.0) * s_web,
144 )
145 }
146 SectionShape::RcWall { thickness, .. } | SectionShape::RcSlab { thickness } => (
147 1000.0,
148 thickness,
149 1000.0 * thickness / KAPPA_RC,
150 1000.0 * thickness / KAPPA_RC,
151 ),
152 };
153 let thickness = match *self {
155 SectionShape::CftBox { thick, .. } | SectionShape::CftPipe { thick, .. } => Some(thick),
156 SectionShape::RcWall { thickness, .. } | SectionShape::RcSlab { thickness } => {
157 Some(thickness)
158 }
159 _ => None,
160 };
161 Section {
162 id,
163 name,
164 floor: None,
165 area,
166 iy,
167 iz,
168 j,
169 depth,
170 width,
171 as_y,
172 as_z,
173 panel_thickness: None,
174 thickness,
175 shape: Some(self.clone()),
177 material: None,
178 rebar_material: None,
179 shear_rebar_material: None,
180 steel_material: None,
181 }
182 }
183}