Skip to content

Commit 3800536

Browse files
Add simple concrete sections tests
1 parent 1c3a2af commit 3800536

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import pytest_check as check
2+
import numpy as np
3+
import sectionproperties.pre.pre as pre
4+
import sectionproperties.pre.library.concrete_sections as cs
5+
6+
r_tol = 1e-6
7+
conc_mat = pre.Material(
8+
name="Concrete",
9+
elastic_modulus=32.8e3,
10+
poissons_ratio=0.2,
11+
density=2.4e-6,
12+
yield_strength=40,
13+
color="lightgrey",
14+
)
15+
16+
steel_mat = pre.Material(
17+
name="Steel",
18+
elastic_modulus=200e3,
19+
poissons_ratio=0.3,
20+
density=7.85e-6,
21+
yield_strength=500,
22+
color="grey",
23+
)
24+
25+
26+
def test_concrete_rectangular_section():
27+
rect = cs.concrete_rectangular_section(
28+
b=300,
29+
d=600,
30+
dia_top=16,
31+
n_top=3,
32+
dia_bot=20,
33+
n_bot=3,
34+
n_circle=16,
35+
cover=30,
36+
area_top=200,
37+
area_bot=310,
38+
conc_mat=conc_mat,
39+
steel_mat=steel_mat,
40+
)
41+
42+
# check geometry is created correctly
43+
conc_area = 0
44+
steel_area = 0
45+
46+
for geom in rect.geoms:
47+
if geom.material == conc_mat:
48+
conc_area += geom.calculate_area()
49+
elif geom.material == steel_mat:
50+
steel_area += geom.calculate_area()
51+
else:
52+
raise ValueError(
53+
"Material {0} is not correctly assigned".format(geom.material)
54+
)
55+
56+
net_area = 600 * 300
57+
actual_steel_area = 3 * (200 + 310)
58+
59+
# check areas
60+
check.almost_equal(conc_area, net_area - actual_steel_area, rel=r_tol)
61+
check.almost_equal(steel_area, actual_steel_area, rel=r_tol)
62+
63+
64+
def test_concrete_tee_section():
65+
rect = cs.concrete_tee_section(
66+
b=300,
67+
d=900,
68+
b_f=1200,
69+
d_f=200,
70+
dia_top=20,
71+
n_top=6,
72+
dia_bot=24,
73+
n_bot=3,
74+
n_circle=16,
75+
cover=30,
76+
area_top=310,
77+
area_bot=450,
78+
conc_mat=conc_mat,
79+
steel_mat=steel_mat,
80+
)
81+
82+
# check geometry is created correctly
83+
conc_area = 0
84+
steel_area = 0
85+
86+
for geom in rect.geoms:
87+
if geom.material == conc_mat:
88+
conc_area += geom.calculate_area()
89+
elif geom.material == steel_mat:
90+
steel_area += geom.calculate_area()
91+
else:
92+
raise ValueError(
93+
"Material {0} is not correctly assigned".format(geom.material)
94+
)
95+
96+
net_area = 700 * 300 + 1200 * 200
97+
actual_steel_area = 6 * 310 + 3 * 450
98+
99+
# check areas
100+
check.almost_equal(conc_area, net_area - actual_steel_area, rel=r_tol)
101+
check.almost_equal(steel_area, actual_steel_area, rel=r_tol)
102+
103+
104+
def test_concrete_circular_section():
105+
rect = cs.concrete_circular_section(
106+
d=600,
107+
n=64,
108+
dia=20,
109+
n_bar=8,
110+
n_circle=16,
111+
cover=45,
112+
area_conc=np.pi * 600 * 600 / 4,
113+
area_bar=310,
114+
conc_mat=conc_mat,
115+
steel_mat=steel_mat,
116+
)
117+
118+
# check geometry is created correctly
119+
conc_area = 0
120+
steel_area = 0
121+
122+
for geom in rect.geoms:
123+
if geom.material == conc_mat:
124+
conc_area += geom.calculate_area()
125+
elif geom.material == steel_mat:
126+
steel_area += geom.calculate_area()
127+
else:
128+
raise ValueError(
129+
"Material {0} is not correctly assigned".format(geom.material)
130+
)
131+
132+
net_area = np.pi * 600 * 600 / 4
133+
actual_steel_area = 8 * 310
134+
135+
# check areas
136+
check.almost_equal(conc_area, net_area - actual_steel_area, rel=r_tol)
137+
check.almost_equal(steel_area, actual_steel_area, rel=r_tol)

0 commit comments

Comments
 (0)