Skip to content

Commit 920f705

Browse files
committed
improve lint problems
1 parent cd082de commit 920f705

27 files changed

+1080
-831
lines changed

examples/alt_stiffness_3d.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
Matrix Structural Analysis: Second Edition 2nd Edition
77
by William McGuire, Richard H. Gallagher, Ronald D. Ziemian
88
"""
9-
from context import pystran
10-
from pystran import model
11-
from pystran import property
12-
from pystran import geometry
13-
from pystran import plots
9+
from math import sqrt
1410
from numpy import zeros, dot
1511
from numpy.linalg import norm
16-
from math import sqrt
12+
from context import pystran
13+
from pystran import model
14+
from pystran import section
1715

1816
m = model.create(3)
1917

@@ -24,29 +22,29 @@
2422
# Default orientation
2523
# model.add_joint(m, 1, [0.0, 0.0, 0.0])
2624
# model.add_joint(m, 2, [10.0, 0.0, 0.0])
27-
h = norm(m['joints'][1]['coordinates'] - m['joints'][2]['coordinates'])
25+
h = norm(m["joints"][1]["coordinates"] - m["joints"][2]["coordinates"])
2826

2927
E = 2.0e6
3028
G = E / (2 * (1 + 0.3))
3129
H = 0.13
3230
B = 0.5
3331
A = H * B
34-
Iy = H*B**3/12
35-
Iz = H**3*B/12
32+
Iy = H * B**3 / 12
33+
Iz = H**3 * B / 12
3634
Ix = Iy + Iz
3735
J = Ix
3836
xz_vector = [0, 0, 1]
39-
p1 = property.beam_property('property_1', E, G, A, Ix, Iy, Iz, J, xz_vector)
37+
p1 = section.beam_3d_section("property_1", E, G, A, Ix, Iy, Iz, J, xz_vector)
4038
model.add_beam_member(m, 1, [1, 2], p1)
4139

4240
model.number_dofs(m)
4341

44-
nt, nf = m['ntotaldof'], m['nfreedof']
45-
# Assemble global stiffness matrix
42+
nt, nf = m["ntotaldof"], m["nfreedof"]
43+
# Assemble global stiffness matrix
4644
K = zeros((nt, nt))
47-
for member in m['beam_members'].values():
48-
connectivity = member['connectivity']
49-
i, j = m['joints'][connectivity[0]], m['joints'][connectivity[1]]
45+
for member in m["beam_members"].values():
46+
connectivity = member["connectivity"]
47+
i, j = m["joints"][connectivity[0]], m["joints"][connectivity[1]]
5048
pystran.beam.assemble_stiffness(K, member, i, j)
5149

5250
K1 = K.copy()
@@ -98,7 +96,7 @@
9896
K[8, 10] = 6 * E * Iy / h**2
9997

10098

101-
i, j = m['joints'][connectivity[0]], m['joints'][connectivity[1]]
99+
i, j = m["joints"][connectivity[0]], m["joints"][connectivity[1]]
102100
e_x, e_y, e_z, h = pystran.beam.beam_3d_member_geometry(i, j, xz_vector)
103101

104102
# Transformation matrix
@@ -124,4 +122,3 @@
124122
# # ax = plots.plot_shear_forces(m, scale=0.50e-3)
125123
# # ax.set_title('Shear forces')
126124
# plots.show(m)
127-

examples/cantil_3d_a.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,43 @@
66
Matrix Structural Analysis: Second Edition 2nd Edition
77
by William McGuire, Richard H. Gallagher, Ronald D. Ziemian
88
"""
9-
from context import pystran
10-
from pystran import model
11-
from pystran import property
12-
from pystran import geometry
13-
from pystran import plots
9+
from math import sqrt
1410
from numpy import array, dot
1511
from numpy import linalg
1612
from numpy.linalg import cross
17-
from math import sqrt
13+
from context import pystran
14+
from pystran import model
15+
from pystran import section
1816

1917
h = 8.0
2018
E = 2.0e6
2119
G = E / (2 * (1 + 0.3))
2220
H = 0.13
2321
B = 0.5
2422
A = H * B
25-
Iy = H*B**3/12
26-
Iz = H**3*B/12
23+
Iy = H * B**3 / 12
24+
Iz = H**3 * B / 12
2725
Ix = Iy + Iz
2826
J = Ix
29-
27+
28+
3029
def test(e_x, e_y, e_z, F, refdefl, refslope):
3130
m = model.create(3)
3231
model.add_joint(m, 1, [0.0, 0.0, 0.0])
33-
model.add_joint(m, 2, h*e_x)
34-
clamped = m['joints'][1]
35-
freeend = m['joints'][2]
36-
32+
model.add_joint(m, 2, h * e_x)
33+
clamped = m["joints"][1]
34+
freeend = m["joints"][2]
35+
3736
model.add_support(clamped, model.U1)
3837
model.add_support(clamped, model.U2)
3938
model.add_support(clamped, model.U3)
4039
model.add_support(clamped, model.UR1)
4140
model.add_support(clamped, model.UR2)
4241
model.add_support(clamped, model.UR3)
43-
44-
45-
p1 = property.beam_property('property_1', E, G, A, Ix, Iy, Iz, J, e_z)
42+
43+
p1 = section.beam_3d_section("property_1", E, G, A, Ix, Iy, Iz, J, e_z)
4644
model.add_beam_member(m, 1, [1, 2], p1)
47-
45+
4846
model.add_load(freeend, model.U1, F[0])
4947
model.add_load(freeend, model.U2, F[1])
5048
model.add_load(freeend, model.U3, F[2])
@@ -63,47 +61,48 @@ def test(e_x, e_y, e_z, F, refdefl, refslope):
6361
# print(m['K'][0:m['nfreedof'], 0:m['nfreedof']])
6462

6563
# print(m['U'][0:m['nfreedof']])
66-
64+
6765
rot = cross(e_x, F)
68-
defl = dot(F, freeend['displacements'][0:3])
69-
slope = dot(rot, freeend['displacements'][3:6])
66+
defl = dot(F, freeend["displacements"][0:3])
67+
slope = dot(rot, freeend["displacements"][3:6])
7068

71-
print('Reference deflection: ', refdefl, ' Computed deflection: ', defl)
72-
print('Reference slope: ', refslope, ' Computed slope: ', slope)
73-
74-
if abs(defl - refdefl) > 1.e-3 * abs(refdefl):
75-
raise ValueError('Displacement calculation error')
69+
print("Reference deflection: ", refdefl, " Computed deflection: ", defl)
70+
print("Reference slope: ", refslope, " Computed slope: ", slope)
7671

77-
if abs(slope - refslope) > 1.e-3 * abs(refslope):
78-
raise ValueError('Slope calculation error')
72+
if abs(defl - refdefl) > 1.0e-3 * abs(refdefl):
73+
raise ValueError("Displacement calculation error")
74+
75+
if abs(slope - refslope) > 1.0e-3 * abs(refslope):
76+
raise ValueError("Slope calculation error")
7977

8078
# plots.plot_setup(m)
8179
# plots.plot_members(m)
8280
# plots.plot_deformations(m, 10.0)
8381
# # ax = plots.plot_shear_forces(m, scale=0.50e-3)
8482
# # ax.set_title('Shear forces')
8583
# plots.show(m)
86-
84+
85+
8786
e_x, e_y, e_z = array([1, 0, 0]), array([0, 1, 0]), array([0, 0, 1])
8887
F = array([0, 1, 0])
89-
refdefl = 1*h**3/(3*E*Iz)
90-
refslope = 1*h**2/(2*E*Iz)
88+
refdefl = 1 * h**3 / (3 * E * Iz)
89+
refslope = 1 * h**2 / (2 * E * Iz)
9190
test(e_x, e_y, e_z, F, refdefl, refslope)
9291

9392
e_x, e_y, e_z = array([1, 0, 0]), array([0, 1, 0]), array([0, 0, 1])
9493
F = array([0, 0, 1])
95-
refdefl = 1*h**3/(3*E*Iy)
96-
refslope = 1*h**2/(2*E*Iy)
94+
refdefl = 1 * h**3 / (3 * E * Iy)
95+
refslope = 1 * h**2 / (2 * E * Iy)
9796
test(e_x, e_y, e_z, F, refdefl, refslope)
9897

9998
e_x, e_y, e_z = array([0, 1, 0]), array([0, 0, 1]), array([1, 0, 0])
10099
F = array([0, 0, 1])
101-
refdefl = 1*h**3/(3*E*Iz)
102-
refslope = 1*h**2/(2*E*Iz)
100+
refdefl = 1 * h**3 / (3 * E * Iz)
101+
refslope = 1 * h**2 / (2 * E * Iz)
103102
test(e_x, e_y, e_z, F, refdefl, refslope)
104103

105104
e_x, e_y, e_z = array([0, 1, 0]), array([0, 0, 1]), array([1, 0, 0])
106105
F = array([0, 0, -1])
107-
refdefl = 1*h**3/(3*E*Iz)
108-
refslope = 1*h**2/(2*E*Iz)
106+
refdefl = 1 * h**3 / (3 * E * Iz)
107+
refslope = 1 * h**2 / (2 * E * Iz)
109108
test(e_x, e_y, e_z, F, refdefl, refslope)

examples/cantilever_3d.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99
from context import pystran
1010
from pystran import model
11-
from pystran import property
11+
from pystran import section
1212
from pystran import geometry
1313
from pystran import plots
1414
from math import sqrt
@@ -18,14 +18,14 @@
1818
h = 8.0
1919
model.add_joint(m, 1, [0.0, 0.0, 0.0])
2020
model.add_joint(m, 2, [h, 0.0, 0.0])
21-
a = m['joints'][1]
21+
a = m["joints"][1]
2222
model.add_support(a, model.U1)
2323
model.add_support(a, model.U2)
2424
model.add_support(a, model.U3)
2525
model.add_support(a, model.UR1)
2626
model.add_support(a, model.UR2)
2727
model.add_support(a, model.UR3)
28-
a = m['joints'][2]
28+
a = m["joints"][2]
2929
model.add_support(a, model.U1)
3030
model.add_support(a, model.U2)
3131
model.add_support(a, model.UR1)
@@ -39,37 +39,33 @@
3939
Ix = Iy / 5
4040
J = 300e3 / 10**12
4141
xz_vector = [0, 0, 1]
42-
p1 = property.beam_property('property_1', E, G, A, Ix, Iy, Iz, J, xz_vector)
42+
p1 = section.beam_3d_section("property_1", E, G, A, Ix, Iy, Iz, J, xz_vector)
4343
model.add_beam_member(m, 1, [1, 2], p1)
4444

45-
d = m['joints'][2]
45+
d = m["joints"][2]
4646
F = 10e3
4747
model.add_load(d, model.U3, F)
4848

4949
model.number_dofs(m)
5050

51-
print('Number of free degrees of freedom = ', m['nfreedof'])
52-
print('Number of all degrees of freedom = ', m['ntotaldof'])
51+
print("Number of free degrees of freedom = ", m["nfreedof"])
52+
print("Number of all degrees of freedom = ", m["ntotaldof"])
5353

54-
print([j['dof'] for j in m['joints'].values()])
54+
print([j["dof"] for j in m["joints"].values()])
5555

5656
model.solve(m)
5757

58-
print([j['displacements'] for j in m['joints'].values()])
58+
print([j["displacements"] for j in m["joints"].values()])
5959

60-
print(m['K'][0:m['nfreedof'], 0:m['nfreedof']])
60+
print(m["K"][0 : m["nfreedof"], 0 : m["nfreedof"]])
6161

62-
print(m['U'][0:m['nfreedof']])
62+
print(m["U"][0 : m["nfreedof"]])
6363

64-
print('Reference: ', F*h**3/(3*E*Iy))
64+
print("Reference: ", F * h**3 / (3 * E * Iy))
6565

6666
plots.plot_setup(m)
6767
plots.plot_members(m)
6868
plots.plot_deformations(m, 10.0)
6969
# ax = plots.plot_shear_forces(m, scale=0.50e-3)
7070
# ax.set_title('Shear forces')
7171
plots.show(m)
72-
73-
74-
75-

examples/context.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
"""
2+
Mechanism for making python aware of the pystran package.
3+
"""
4+
15
import os
26
import sys
37

48
# This is an ugly hack. Jupyter notebook runs in a different path than plain python.
5-
sys.path.insert(0, os.path.abspath('../pystran'))
6-
sys.path.insert(0, os.path.abspath('../../pystran'))
9+
sys.path.insert(0, os.path.abspath("../pystran"))
10+
sys.path.insert(0, os.path.abspath("../../pystran"))
711

8-
import pystran
12+
import pystran

0 commit comments

Comments
 (0)