Skip to main content

squid_n_core/section_shape/
builder.rs

1//! [`SectionShape`] から [`Section`] を生成するビルダ([`SectionShape::to_section`])。
2
3use 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    /// Build a fully-populated `squid_n_core::Section` from the shape parameters.
11    ///
12    /// `id` and `name` must be supplied by the caller; all section properties
13    /// are computed automatically. 階(`Section::floor`)は形状から決まらないため
14    /// `None` とし、必要な呼び出し側(ST-Bridge 取り込み・断面形状の変更)が
15    /// 生成後に設定する。
16    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        // せん断変形用断面積 As(材料力学のせん断形状係数)。
22        // ペアリング規約(P1 §4.1): as_z ↔ iy(強軸曲げ→z方向せん断)、
23        // as_y ↔ iz(弱軸曲げ→y方向せん断)。
24        // - RC/SRC: As = A/κ(κ=1.2)。SRC は鉄骨分 sAs·(ngs−1) を累加
25        //   (ngs はせん断弾性係数比。暫定的にヤング係数比 N_S_EQ で代用)。
26        // - S: As = Aw/κ(κ=1.0)。強軸側はウェブ、弱軸側はフランジを有効とする。
27        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            // 平鋼: 中実矩形(せい d=thick、幅 b=width)。せん断有効断面は矩形の A/κ。
91            SectionShape::SteelFlatBar { width, thick } => (
92                thick,
93                width,
94                width * thick / KAPPA_RC,
95                width * thick / KAPPA_RC,
96            ),
97            // 中実丸鋼: せん断形状係数 κ=10/9(As=0.9A)。
98            SectionShape::SteelRoundBar { dia } => (dia, dia, area * 0.9, area * 0.9),
99            // リップ溝形(溝形鋼と同規約): 強軸せん断はウェブ、弱軸はフランジが負担。
100            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            // 非対称組立 H(H 形と同規約): 強軸せん断はウェブ、弱軸は上下フランジが負担。
112            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        // 板厚系の形状は Section.thickness にも板厚を反映する(検定・表示用)。
154        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            // UI設計 §4.2: Section は SectionShape の派生。生成元の形状を保持する。
176            shape: Some(self.clone()),
177            material: None,
178            rebar_material: None,
179            shear_rebar_material: None,
180            steel_material: None,
181        }
182    }
183}