Skip to content

Commit 9800ca9

Browse files
Some minor pep8 updates
1 parent 4d2bdd5 commit 9800ca9

File tree

5 files changed

+65
-64
lines changed

5 files changed

+65
-64
lines changed

sectionproperties/analysis/cross_section.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ class CrossSection:
6363
6464
mesh = geometry.create_mesh(mesh_sizes=[5, 10])
6565
66-
steel = Material(name='Steel', elastic_modulus=200e3, poissons_ratio=0.3,
67-
yield_strength=250, color='grey'
66+
steel = Material(
67+
name='Steel', elastic_modulus=200e3, poissons_ratio=0.3, yield_strength=250,
68+
color='grey'
6869
)
69-
timber = Material(name='Timber', elastic_modulus=8e3, poissons_ratio=0.35,
70-
yield_strength=20, color='burlywood'
70+
timber = Material(
71+
name='Timber', elastic_modulus=8e3, poissons_ratio=0.35, yield_strength=20,
72+
color='burlywood'
7173
)
7274
7375
section = CrossSection(geometry, mesh, [steel, timber])
@@ -363,8 +365,8 @@ def solve_warping():
363365
# determine the torsion constant
364366
def j_func():
365367
return (
366-
self.section_props.ixx_c + self.section_props.iyy_c -
367-
omega.dot(k.dot(np.transpose(omega)))
368+
self.section_props.ixx_c + self.section_props.iyy_c
369+
- omega.dot(k.dot(np.transpose(omega)))
368370
)
369371

370372
if time_info:
@@ -452,29 +454,29 @@ def shear_centres():
452454
# calculate shear centres (elasticity approach)
453455
Delta_s = (
454456
2 * (1 + self.section_props.nu_eff) * (
455-
self.section_props.ixx_c * self.section_props.iyy_c -
456-
self.section_props.ixy_c ** 2)
457+
self.section_props.ixx_c * self.section_props.iyy_c
458+
- self.section_props.ixy_c ** 2)
457459
)
458460
x_se = (
459-
(1 / Delta_s) * ((self.section_props.nu_eff / 2 *
460-
sc_xint) - f_torsion.dot(phi_shear))
461+
(1 / Delta_s) * ((self.section_props.nu_eff / 2
462+
* sc_xint) - f_torsion.dot(phi_shear))
461463
)
462464
y_se = (
463-
(1 / Delta_s) * ((self.section_props.nu_eff / 2 *
464-
sc_yint) + f_torsion.dot(psi_shear))
465+
(1 / Delta_s) * ((self.section_props.nu_eff / 2
466+
* sc_yint) + f_torsion.dot(psi_shear))
465467
)
466468
(x11_se, y22_se) = fea.principal_coordinate(self.section_props.phi, x_se, y_se)
467469

468470
# calculate shear centres (Trefftz's approach)
469471
x_st = (
470472
(self.section_props.ixy_c * i_xomega - self.section_props.iyy_c * i_yomega) / (
471-
self.section_props.ixx_c * self.section_props.iyy_c -
472-
self.section_props.ixy_c ** 2)
473+
self.section_props.ixx_c * self.section_props.iyy_c
474+
- self.section_props.ixy_c ** 2)
473475
)
474476
y_st = (
475477
(self.section_props.ixx_c * i_xomega - self.section_props.ixy_c * i_yomega) / (
476-
self.section_props.ixx_c * self.section_props.iyy_c -
477-
self.section_props.ixy_c ** 2)
478+
self.section_props.ixx_c * self.section_props.iyy_c
479+
- self.section_props.ixy_c ** 2)
478480
)
479481

480482
return (Delta_s, x_se, y_se, x11_se, y22_se, x_st, y_st)
@@ -538,7 +540,7 @@ def assemble_shear_deformation():
538540
# rotate the tensor by the principal axis angle
539541
phi_rad = self.section_props.phi * np.pi / 180
540542
R = np.array([
541-
[np.cos(phi_rad), np.sin(phi_rad)],
543+
[np.cos(phi_rad), np.sin(phi_rad)],
542544
[-np.sin(phi_rad), np.cos(phi_rad)]
543545
])
544546

@@ -674,14 +676,14 @@ def calculate_frame():
674676
self.section_props.iyy_g - self.section_props.qy ** 2 / self.section_props.ea
675677
)
676678
self.section_props.ixy_c = (
677-
self.section_props.ixy_g - self.section_props.qx * self.section_props.qy /
678-
self.section_props.ea
679+
self.section_props.ixy_g - self.section_props.qx * self.section_props.qy
680+
/ self.section_props.ea
679681
)
680682

681683
# calculate the principal axis angle
682684
Delta = (
683-
((self.section_props.ixx_c - self.section_props.iyy_c) / 2) ** 2 +
684-
self.section_props.ixy_c ** 2
685+
((self.section_props.ixx_c - self.section_props.iyy_c) / 2) ** 2
686+
+ self.section_props.ixy_c ** 2
685687
) ** 0.5
686688

687689
i11_c = (
@@ -981,7 +983,7 @@ def assemble_torsion(self, lg=True):
981983
col = np.hstack((col, N))
982984
data = np.hstack((data, 0))
983985

984-
k_lg = coo_matrix((data, (row, col)), shape=(N+1, N+1))
986+
k_lg = coo_matrix((data, (row, col)), shape=(N + 1, N + 1))
985987

986988
return (csc_matrix(k), csc_matrix(k_lg), f_torsion)
987989

@@ -1890,8 +1892,7 @@ def calculate_plastic_properties(self, cross_section, verbose):
18901892
fibres = self.calculate_extreme_fibres(0)
18911893

18921894
# 1a) Calculate x-axis plastic centroid
1893-
(y_pc, r, f, c_top, c_bot) = self.pc_algorithm(
1894-
np.array([1, 0]), fibres[2:], 1, verbose)
1895+
(y_pc, r, f, c_top, c_bot) = self.pc_algorithm(np.array([1, 0]), fibres[2:], 1, verbose)
18951896

18961897
self.check_convergence(r, 'x-axis')
18971898
cross_section.section_props.y_pc = y_pc
@@ -2270,7 +2271,7 @@ def add_line(self, geometry, line):
22702271
# add new facets by looping from the second facet index to the end
22712272
for (i, idx) in enumerate(fct_idx[1:]):
22722273
# get mid-point of proposed new facet
2273-
mid_pt = 0.5 * (int_pts[i] + int_pts[i+1])
2274+
mid_pt = 0.5 * (int_pts[i] + int_pts[i + 1])
22742275

22752276
# check to see if the mid-point is not in a hole
22762277
# add the facet
@@ -2332,12 +2333,12 @@ def point_within_element(self, pt):
23322333

23332334
# compute variables alpha, beta and gamma
23342335
alpha = (
2335-
((y2 - y3) * (px - x3) + (x3 - x2) * (py - y3)) /
2336-
((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
2336+
((y2 - y3) * (px - x3) + (x3 - x2) * (py - y3))
2337+
/ ((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
23372338
)
23382339
beta = (
2339-
((y3 - y1) * (px - x3) + (x1 - x3) * (py - y3)) /
2340-
((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
2340+
((y3 - y1) * (px - x3) + (x1 - x3) * (py - y3))
2341+
/ ((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
23412342
)
23422343
gamma = 1.0 - alpha - beta
23432344

sectionproperties/analysis/fea.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def torsion_properties(self):
9999
# calculated modulus weighted stiffness matrix and load vector
100100
k_el += gp[0] * np.dot(np.transpose(B), B) * j * (self.material.elastic_modulus)
101101
f_el += (
102-
gp[0] * np.dot(np.transpose(B), np.transpose(np.array([Ny, -Nx]))) *
103-
j * self.material.elastic_modulus
102+
gp[0] * np.dot(np.transpose(B), np.transpose(np.array([Ny, -Nx])))
103+
* j * self.material.elastic_modulus
104104
)
105105

106106
return (k_el, f_el)
@@ -141,14 +141,14 @@ def shear_load_vectors(self, ixx, iyy, ixy, nu):
141141
h2 = -iyy * r - ixy * q
142142

143143
f_psi += (
144-
gp[0] * (nu / 2 * np.transpose(np.transpose(B).dot(np.array([[d1], [d2]])))[0] +
145-
2 * (1 + nu) * np.transpose(N) * (ixx * Nx - ixy * Ny)) * j *
146-
self.material.elastic_modulus
144+
gp[0] * (nu / 2 * np.transpose(np.transpose(B).dot(np.array([[d1], [d2]])))[0]
145+
+ 2 * (1 + nu) * np.transpose(N) * (ixx * Nx - ixy * Ny)) * j
146+
* self.material.elastic_modulus
147147
)
148148
f_phi += (
149-
gp[0] * (nu / 2 * np.transpose(np.transpose(B).dot(np.array([[h1], [h2]])))[0] +
150-
2 * (1 + nu) * np.transpose(N) * (iyy * Ny - ixy * Nx)) * j *
151-
self.material.elastic_modulus
149+
gp[0] * (nu / 2 * np.transpose(np.transpose(B).dot(np.array([[h1], [h2]])))[0]
150+
+ 2 * (1 + nu) * np.transpose(N) * (iyy * Ny - ixy * Nx)) * j
151+
* self.material.elastic_modulus
152152
)
153153

154154
return (f_psi, f_phi)
@@ -189,12 +189,12 @@ def shear_warping_integrals(self, ixx, iyy, ixy, omega):
189189
Nomega = np.dot(N, np.transpose(omega))
190190

191191
sc_xint += (
192-
gp[0] * (iyy * Nx + ixy * Ny) * (Nx ** 2 + Ny ** 2) *
193-
j * self.material.elastic_modulus
192+
gp[0] * (iyy * Nx + ixy * Ny) * (Nx ** 2 + Ny ** 2)
193+
* j * self.material.elastic_modulus
194194
)
195195
sc_yint += (
196-
gp[0] * (ixx * Ny + ixy * Nx) * (Nx ** 2 + Ny ** 2) *
197-
j * self.material.elastic_modulus
196+
gp[0] * (ixx * Ny + ixy * Nx) * (Nx ** 2 + Ny ** 2)
197+
* j * self.material.elastic_modulus
198198
)
199199
q_omega += gp[0] * Nomega * j * self.material.elastic_modulus
200200
i_omega += gp[0] * Nomega ** 2 * j * self.material.elastic_modulus
@@ -245,18 +245,18 @@ def shear_coefficients(self, ixx, iyy, ixy, psi_shear, phi_shear, nu):
245245

246246
kappa_x += (
247247
gp[0] * (psi_shear.dot(np.transpose(B)) - nu / 2 * np.array([d1, d2])).dot(
248-
B.dot(psi_shear) - nu / 2 * np.array([d1, d2])) * j *
249-
self.material.elastic_modulus
248+
B.dot(psi_shear) - nu / 2 * np.array([d1, d2])) * j
249+
* self.material.elastic_modulus
250250
)
251251
kappa_y += (
252252
gp[0] * (phi_shear.dot(np.transpose(B)) - nu / 2 * np.array([h1, h2])).dot(
253-
B.dot(phi_shear) - nu / 2 * np.array([h1, h2])) * j *
254-
self.material.elastic_modulus
253+
B.dot(phi_shear) - nu / 2 * np.array([h1, h2])) * j
254+
* self.material.elastic_modulus
255255
)
256256
kappa_xy += (
257257
gp[0] * (psi_shear.dot(np.transpose(B)) - nu / 2 * np.array([d1, d2])).dot(
258-
B.dot(phi_shear) - nu / 2 * np.array([h1, h2])) * j *
259-
self.material.elastic_modulus
258+
B.dot(phi_shear) - nu / 2 * np.array([h1, h2])) * j
259+
* self.material.elastic_modulus
260260
)
261261

262262
return (kappa_x, kappa_y, kappa_xy)
@@ -296,12 +296,12 @@ def monosymmetry_integrals(self, phi):
296296
int_x += gp[0] * (Nx * Nx * Ny + Ny * Ny * Ny) * j * self.material.elastic_modulus
297297
int_y += gp[0] * (Ny * Ny * Nx + Nx * Nx * Nx) * j * self.material.elastic_modulus
298298
int_11 += (
299-
gp[0] * (Nx_11 * Nx_11 * Ny_22 + Ny_22 * Ny_22 * Ny_22) * j *
300-
self.material.elastic_modulus
299+
gp[0] * (Nx_11 * Nx_11 * Ny_22 + Ny_22 * Ny_22 * Ny_22) * j
300+
* self.material.elastic_modulus
301301
)
302302
int_22 += (
303-
gp[0] * (Ny_22 * Ny_22 * Nx_11 + Nx_11 * Nx_11 * Nx_11) * j *
304-
self.material.elastic_modulus
303+
gp[0] * (Ny_22 * Ny_22 * Nx_11 + Nx_11 * Nx_11 * Nx_11) * j
304+
* self.material.elastic_modulus
305305
)
306306

307307
return (int_x, int_y, int_11, int_22)
@@ -496,12 +496,12 @@ def point_within_element(self, pt):
496496

497497
# compute variables alpha, beta and gamma
498498
alpha = (
499-
((y2 - y3) * (px - x3) + (x3 - x2) * (py - y3)) /
500-
((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
499+
((y2 - y3) * (px - x3) + (x3 - x2) * (py - y3))
500+
/ ((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
501501
)
502502
beta = (
503-
((y3 - y1) * (px - x3) + (x1 - x3) * (py - y3)) /
504-
((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
503+
((y3 - y1) * (px - x3) + (x1 - x3) * (py - y3))
504+
/ ((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3))
505505
)
506506
gamma = 1.0 - alpha - beta
507507

@@ -617,17 +617,17 @@ def extrapolate_to_nodes(w):
617617
"""
618618

619619
H_inv = np.array([
620-
[1.87365927351160, 0.138559587411935, 0.138559587411935,
620+
[1.87365927351160, 0.138559587411935, 0.138559587411935,
621621
-0.638559587411936, 0.126340726488397, -0.638559587411935],
622622
[0.138559587411935, 1.87365927351160, 0.138559587411935,
623623
-0.638559587411935, -0.638559587411935, 0.126340726488397],
624624
[0.138559587411935, 0.138559587411935, 1.87365927351160,
625625
0.126340726488396, -0.638559587411935, -0.638559587411935],
626626
[0.0749010751157440, 0.0749010751157440, 0.180053080734478,
627-
1.36051633430762, -0.345185782636792, -0.345185782636792],
627+
1.36051633430762, -0.345185782636792, -0.345185782636792],
628628
[0.180053080734478, 0.0749010751157440, 0.0749010751157440,
629629
-0.345185782636792, 1.36051633430762, -0.345185782636792],
630-
[0.0749010751157440, 0.180053080734478, 0.0749010751157440,
630+
[0.0749010751157440, 0.180053080734478, 0.0749010751157440,
631631
-0.345185782636792, -0.345185782636792, 1.36051633430762]
632632
])
633633

sectionproperties/examples/example_advanced1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# get the torsion constant
3131
j = section.get_j()
32-
print("d/b = {0:.3f}; J = {1:.5e}".format(d/b, j))
32+
print("d/b = {0:.3f}; J = {1:.5e}".format(d / b, j))
3333
j_list.append(j)
3434

3535
# plot the torsion constant as a function of the aspect ratio

sectionproperties/examples/example_custom.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
# build the lists of points, facets, holes and control points
1010
points = [
11-
[-t/2, -2*a], [t/2, -2*a], [t/2, -t/2], [a, -t/2], [a, t/2], [-t/2, t/2], [-b/2, -2*a],
12-
[b/2, -2*a], [b/2, -2*a-t], [-b/2, -2*a-t]
11+
[-t / 2, -2 * a], [t / 2, -2 * a], [t / 2, -t / 2], [a, -t / 2], [a, t / 2], [-t / 2, t / 2],
12+
[-b / 2, -2 * a], [b / 2, -2 * a], [b / 2, -2 * a - t], [-b / 2, -2 * a - t]
1313
]
1414
facets = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6]]
1515
holes = []
16-
control_points = [[0, 0], [0, -2*a-t/2]]
16+
control_points = [[0, 0], [0, -2 * a - t / 2]]
1717

1818
# create the custom geometry object
1919
geometry = sections.CustomSection(points, facets, holes, control_points)

sectionproperties/pre/pre.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ def remove_duplicate_facets(self):
489489
idx_2 = i + j + 1
490490

491491
# check for a duplicate facet that has not already been deleted
492-
if (self.is_duplicate_facet(fct1, fct2) and
493-
idx_2 not in idx_to_remove):
492+
if (self.is_duplicate_facet(fct1, fct2)
493+
and idx_2 not in idx_to_remove):
494494
idx_to_remove.append(idx_2)
495495

496496
if self.verbose:

0 commit comments

Comments
 (0)