Skip to content

Commit d0bff00

Browse files
committed
improves syntax
1 parent ec9b47d commit d0bff00

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

pystran/assemble.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
from numpy import arange
66

7+
78
def assemble(Kg, dof, k):
9+
"""
10+
Assemble local stiffness matrix into global stiffness matrix.
11+
"""
812
for r in arange(len(dof)):
913
for c in arange(len(dof)):
1014
gr, gc = dof[r], dof[c]

pystran/beam.py

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ def beam_2d_shape_fun(xi):
2626

2727
def beam_2d_shape_fun_xi(xi):
2828
"""
29-
Compute the first derivative of the beam shape functions for deflection in the x-z plane (i.e. in 2d).
29+
Compute the first derivative of the beam shape functions for deflection in
30+
the x-z plane (i.e. in 2d).
3031
31-
The quantity computed is
32-
```math
33-
\frac{d^1 N(\\xi)}{d \\xi^1}
34-
```
32+
The quantity computed is ```math \frac{d^1 N(\\xi)}{d \\xi^1} ```
3533
"""
3634
return array(
3735
[
@@ -45,24 +43,20 @@ def beam_2d_shape_fun_xi(xi):
4543

4644
def beam_2d_shape_fun_xi2(xi):
4745
"""
48-
Compute the second derivative of the beam shape functions for deflection in the x-z plane (i.e. in 2d).
46+
Compute the second derivative of the beam shape functions for deflection in
47+
the x-z plane (i.e. in 2d).
4948
50-
The quantity computed is
51-
```math
52-
\frac{d^2 N(\\xi)}{d \\xi^2}
53-
```
49+
The quantity computed is ```math \frac{d^2 N(\\xi)}{d \\xi^2} ```
5450
"""
5551
return array([(6 * xi) / 4, (2 - 6 * xi) / 4, (-6 * xi) / 4, (-2 - 6 * xi) / 4])
5652

5753

5854
def beam_2d_shape_fun_xi3(xi):
5955
"""
60-
Compute the third derivative of the beam shape functions for deflection in the x-z plane (i.e. in 2d).
56+
Compute the third derivative of the beam shape functions for deflection in
57+
the x-z plane (i.e. in 2d).
6158
62-
The quantity computed is
63-
```math
64-
\frac{d^3 N(\\xi)}{d \\xi^3}
65-
```
59+
The quantity computed is ```math \frac{d^3 N(\\xi)}{d \\xi^3} ```
6660
"""
6761
return array([(6) / 4, (-6) / 4, (-6) / 4, (-6) / 4])
6862

@@ -76,7 +70,8 @@ def beam_3d_xz_shape_fun(xi):
7670

7771
def beam_3d_xz_shape_fun_xi2(xi):
7872
"""
79-
Compute the second derivative of the beam shape functions for deflection in the x-z plane.
73+
Compute the second derivative of the beam shape functions for deflection in
74+
the x-z plane.
8075
"""
8176
return beam_2d_shape_fun_xi2(xi)
8277

@@ -85,12 +80,10 @@ def beam_3d_xy_shape_fun(xi):
8580
"""
8681
Compute the beam shape functions for deflection in the x-y plane.
8782
88-
The quantity computed is
89-
```math
90-
\frac{d^2 N(\\xi)}{d \\xi^2}
91-
```
83+
The quantity computed is ```math \frac{d^2 N(\\xi)}{d \\xi^2} ```
9284
93-
The signs of the shape functions that go with the rotations (i.e. the second and fourth) need to be reversed.
85+
The signs of the shape functions that go with the rotations (i.e. the second
86+
and fourth) need to be reversed.
9487
"""
9588
N = beam_2d_shape_fun(xi)
9689
N[1] *= -1.0
@@ -100,14 +93,13 @@ def beam_3d_xy_shape_fun(xi):
10093

10194
def beam_3d_xy_shape_fun_xi2(xi):
10295
"""
103-
Compute the second derivative of the beam shape functions for deflection in the x-y plane.
96+
Compute the second derivative of the beam shape functions for deflection in
97+
the x-y plane.
10498
105-
The quantity computed is
106-
```math
107-
\frac{d^2 N(\\xi)}{d \\xi^2}
108-
```
99+
The quantity computed is ```math \frac{d^2 N(\\xi)}{d \\xi^2} ```
109100
110-
The signs of the shape functions that go with the rotations (i.e. the second and fourth) need to be reversed.
101+
The signs of the shape functions that go with the rotations (i.e. the second
102+
and fourth) need to be reversed.
111103
"""
112104
d2Ndxi2 = beam_2d_shape_fun_xi2(xi)
113105
d2Ndxi2[1] *= -1.0
@@ -130,9 +122,10 @@ def beam_2d_member_geometry(i, j):
130122
if h <= 0.0:
131123
raise ZeroDivisionError("Length of element must be positive")
132124
e_x /= h
133-
# The orientation here reflects the sign convention in the book.
134-
# The deflection is measured positive downwards, while the x coordinate is measured left to right.
135-
# So in two dimensions e_x and e_z form a left-handed coordinate system.
125+
# The orientation here reflects the sign convention in the book. The
126+
# deflection is measured positive downwards, while the x coordinate is
127+
# measured left to right. So in two dimensions e_x and e_z form a
128+
# left-handed coordinate system.
136129
e_z = array([e_x[1], -e_x[0]])
137130
return e_x, e_z, h
138131

@@ -146,9 +139,10 @@ def beam_3d_member_geometry(i, j, xz_vector):
146139
if h <= 0.0:
147140
raise ZeroDivisionError("Length of element must be positive")
148141
e_x /= h
149-
# The orientation here reflects the sign convention in the book.
150-
# The deflection is measured positive downwards, while the x coordinate is measured left to right.
151-
# So in two dimensions e_x and e_z form a left-handed coordinate system.
142+
# The orientation here reflects the sign convention in the book. The
143+
# deflection is measured positive downwards, while the x coordinate is
144+
# measured left to right. So in two dimensions e_x and e_z form a
145+
# left-handed coordinate system.
152146
if abs(dot(e_x, xz_vector)) > 0.99 * norm(xz_vector):
153147
raise ZeroDivisionError("xz_vector must not be parallel to the beam axis")
154148
e_y = cross(xz_vector, e_x)

0 commit comments

Comments
 (0)