Skip to content

Commit 0e8753a

Browse files
committed
Blackify
1 parent 19f570d commit 0e8753a

File tree

2 files changed

+67
-41
lines changed

2 files changed

+67
-41
lines changed

sectionproperties/pre/library/concrete_sections.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def concrete_rectangular_section(
131131

132132

133133
def concrete_column_section(
134-
b: float,
135-
d: float,
134+
b: float,
135+
d: float,
136136
dia_bar: float,
137137
bar_area: float,
138138
cover: float,
@@ -144,7 +144,7 @@ def concrete_column_section(
144144
n_circle: int = 4,
145145
) -> geometry.CompoundGeometry:
146146
"""Constructs a concrete rectangular section of width *b* and depth *d*, with
147-
steel bar reinforcing organized as an *n_bars_b* by *n_bars_d* array, discretised
147+
steel bar reinforcing organized as an *n_bars_b* by *n_bars_d* array, discretised
148148
with *n_circle* points with equal sides and top/bottom *cover* to the steel which
149149
is taken as the clear cover (edge of bar to edge of concrete).
150150
@@ -160,14 +160,14 @@ def concrete_column_section(
160160
:param Optional[sectionproperties.pre.pre.Material] steel_mat: Material to
161161
associate with the reinforcing steel
162162
:param bool filled: When True, will populate the concrete section with an equally
163-
spaced 2D array of reinforcing bars numbering 'n_bars_b' by 'n_bars_d'.
163+
spaced 2D array of reinforcing bars numbering 'n_bars_b' by 'n_bars_d'.
164164
When False, only the bars around the perimeter of the array will be present.
165165
:param int n_circle: The number of points used to discretize the circle of the reinforcing
166166
bars. The bars themselves will have an exact area of 'bar_area' regardless of the
167167
number of points used in the circle. Useful for making the reinforcing bars look
168168
more circular when plotting the concrete section.
169169
170-
:raises ValueErorr: If the number of bars in either 'n_bars_b' or 'n_bars_d' is not greater
170+
:raises ValueErorr: If the number of bars in either 'n_bars_b' or 'n_bars_d' is not greater
171171
than or equal to 2.
172172
173173
The following example creates a 600D x 300W concrete column with 25 mm diameter
@@ -187,7 +187,7 @@ def concrete_column_section(
187187
)
188188
189189
geometry = concrete_column_section(
190-
b=300, d=600, dia_bar=25, bar_area=500, cover=35, n_bars_b=3, n_bars_d=6,
190+
b=300, d=600, dia_bar=25, bar_area=500, cover=35, n_bars_b=3, n_bars_d=6,
191191
conc_mat=concrete, steel_mat=steel, filled=False, n_circle=4
192192
)
193193
geometry.create_mesh(mesh_sizes=[500])
@@ -205,17 +205,18 @@ def concrete_column_section(
205205
Mesh generated from the above geometry.
206206
"""
207207
concrete_geometry = primitive_sections.rectangular_section(b, d, material=conc_mat)
208-
bar_extents = concrete_geometry.offset_perimeter(-cover - dia_bar/2).calculate_extents()
208+
bar_extents = concrete_geometry.offset_perimeter(
209+
-cover - dia_bar / 2
210+
).calculate_extents()
209211
bar_x_min, bar_x_max, bar_y_min, bar_y_max = bar_extents
210-
212+
211213
b_edge_bars_x = np.linspace(bar_x_min, bar_x_max, n_bars_b)
212214
d_edge_bars_y = np.linspace(bar_y_min, bar_y_max, n_bars_d)
213-
215+
214216
if not filled:
215217
b_edge_bars_y1 = [bar_y_min] * n_bars_b
216218
b_edge_bars_y2 = [bar_y_max] * n_bars_b
217219

218-
219220
d_edge_bars_x1 = [bar_x_min] * n_bars_d
220221
d_edge_bars_x2 = [bar_x_max] * n_bars_d
221222

@@ -224,23 +225,26 @@ def concrete_column_section(
224225
d_edge_bars_right = list(zip(d_edge_bars_x2, d_edge_bars_y))
225226
d_edge_bars_left = list(zip(d_edge_bars_x1, d_edge_bars_y))
226227

227-
all_bar_coords = list(set(b_edge_bars_top + b_edge_bars_bottom + d_edge_bars_right + d_edge_bars_left))
228+
all_bar_coords = list(
229+
set(
230+
b_edge_bars_top
231+
+ b_edge_bars_bottom
232+
+ d_edge_bars_right
233+
+ d_edge_bars_left
234+
)
235+
)
228236
if filled:
229237
xy = np.meshgrid(b_edge_bars_x, d_edge_bars_y)
230-
all_bar_coords = np.append(
231-
xy[0].reshape(-1,1),
232-
xy[1].reshape(-1,1),
233-
axis=1
234-
)
235-
238+
all_bar_coords = np.append(xy[0].reshape(-1, 1), xy[1].reshape(-1, 1), axis=1)
239+
236240
for bar_coord in all_bar_coords:
237241
concrete_geometry = add_bar(
238-
concrete_geometry,
239-
area=bar_area,
240-
material=steel_mat,
241-
x=bar_coord[0],
242-
y=bar_coord[1],
243-
n=n_circle
242+
concrete_geometry,
243+
area=bar_area,
244+
material=steel_mat,
245+
x=bar_coord[0],
246+
y=bar_coord[1],
247+
n=n_circle,
244248
)
245249
return concrete_geometry
246250

sectionproperties/tests/test_concrete_sections.py

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,38 @@ def test_concrete_circular_section():
141141
def test_concrete_column_section():
142142

143143
concrete = pre.Material(
144-
name='Concrete', elastic_modulus=30.1e3, poissons_ratio=0.2, yield_strength=32,
145-
density=2.4e-6, color='lightgrey'
144+
name="Concrete",
145+
elastic_modulus=30.1e3,
146+
poissons_ratio=0.2,
147+
yield_strength=32,
148+
density=2.4e-6,
149+
color="lightgrey",
146150
)
147151
steel = pre.Material(
148-
name='Steel', elastic_modulus=200e3, poissons_ratio=0.3, yield_strength=500,
149-
density=7.85e-6, color='grey'
152+
name="Steel",
153+
elastic_modulus=200e3,
154+
poissons_ratio=0.3,
155+
yield_strength=500,
156+
density=7.85e-6,
157+
color="grey",
150158
)
151159

152160
geometry = cs.concrete_column_section(
153-
b=300, d=600, dia_bar=40, bar_area=500, cover=40, n_bars_b=3, n_bars_d=6,
154-
conc_mat=concrete, steel_mat=steel, filled=False, n_circle=4
155-
) # NOTE: Bar diam and Bar area do not match. This is intentional.
161+
b=300,
162+
d=600,
163+
dia_bar=40,
164+
bar_area=500,
165+
cover=40,
166+
n_bars_b=3,
167+
n_bars_d=6,
168+
conc_mat=concrete,
169+
steel_mat=steel,
170+
filled=False,
171+
n_circle=4,
172+
) # NOTE: Bar diam and Bar area do not match. This is intentional.
156173
geometry.create_mesh(mesh_sizes=[500])
157174

158-
# check geometry is created correctly
175+
# check geometry is created correctly
159176
conc_area = 0
160177
steel_area = 0
161178

@@ -170,24 +187,25 @@ def test_concrete_column_section():
170187
)
171188

172189
net_area = 300 * 600
173-
actual_steel_area = 14 * 500.
174-
190+
actual_steel_area = 14 * 500.0
191+
175192
check.almost_equal(conc_area, net_area - actual_steel_area, rel=r_tol)
176193
check.almost_equal(steel_area, actual_steel_area, rel=r_tol)
177194

178195
bar_centroids = [tuple(geom.geom.centroid.coords[0]) for geom in geometry.geoms[1:]]
179196

180197
from collections import Counter
198+
181199
x_coords = Counter(round(coord[0], 0) for coord in bar_centroids)
182200
y_coords = Counter(round(coord[1], 0) for coord in bar_centroids)
183201

184202
# Validate that we have 14 bars with the correct x-coordinates
185-
check.equal(x_coords.get(60) , 6)
203+
check.equal(x_coords.get(60), 6)
186204
check.equal(x_coords.get(150), 2)
187205
check.equal(x_coords.get(240), 6)
188206

189207
# Validate that we have 14 bars with the correct y-coordinates
190-
check.equal(y_coords.get(60) , 3)
208+
check.equal(y_coords.get(60), 3)
191209
check.equal(y_coords.get(156), 2)
192210
check.equal(y_coords.get(252), 2)
193211
check.equal(y_coords.get(348), 2)
@@ -198,16 +216,20 @@ def test_concrete_column_section():
198216
def test_add_bar():
199217
rect = ps.rectangular_section(b=400, d=600)
200218
steel = pre.Material(
201-
name='Steel', elastic_modulus=200e3, poissons_ratio=0.3, yield_strength=500,
202-
density=7.85e-6, color='grey'
219+
name="Steel",
220+
elastic_modulus=200e3,
221+
poissons_ratio=0.3,
222+
yield_strength=500,
223+
density=7.85e-6,
224+
color="grey",
203225
)
204226
rect = cs.add_bar(rect, area=500, x=100, y=100, material=steel)
205227
rect = cs.add_bar(rect, area=500, x=200, y=200, material=steel)
206228
rect_area = rect.geoms[0].geom.area
207-
steel_area = 2 * 500.
208-
check.almost_equal(rect_area, 400*600 - steel_area)
209-
229+
steel_area = 2 * 500.0
230+
check.almost_equal(rect_area, 400 * 600 - steel_area)
231+
210232
bar_1 = rect.geoms[1]
211233
bar_2 = rect.geoms[2]
212234
check.almost_equal(bar_1.calculate_centroid(), (100, 100))
213-
check.almost_equal(bar_2.calculate_centroid(), (200, 200))
235+
check.almost_equal(bar_2.calculate_centroid(), (200, 200))

0 commit comments

Comments
 (0)