Skip to content

Commit 34b1dfa

Browse files
committed
add computation of section properties
1 parent 4fbc81d commit 34b1dfa

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

examples/i_beam.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
3+
"""
4+
5+
from numpy import array, dot
6+
from numpy.linalg import cross
7+
from context import pystran
8+
from pystran import model
9+
from pystran import section
10+
11+
H = 0.3
12+
B = 0.15
13+
tf = 0.01
14+
tw = 0.005
15+
# p = section.i_beam_points(H, B, tf, tw)
16+
# print(section.area(p))
17+
# print(section.centroid(p))
18+
# p = p - section.centroid(p)
19+
# print(section.centroid(p))
20+
# print(section.inertias(p))
21+
22+
Iy = (B / 12) * H**3 - ((B - tw) / 12) * (H - 2 * tf) ** 3
23+
print(Iy)
24+
Iz = (
25+
H * B**3 / 12
26+
- 2 * ((B - tw) / 2) ** 3 * (H - 2 * tf) / 12
27+
- 2 * ((B - tw) / 2) * (H - 2 * tf) * ((B - tw) / 4 + tw / 2) ** 2
28+
)
29+
print(Iz)
30+
# # Iy = (a3 h / 12) + (b3 / 12) (H - h)
31+
32+
A, Ix, Iy, Iz, J = section.i_beam(H, B, tf, tw)
33+
print(A, Ix, Iy, Iz, J)
34+
35+
print((2 * B * tf**3 + (H - 2 * tf) * tw**3) / 3)

pystran/section.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
second moment of area, and also orientation of the cross section profile.
66
"""
77

8+
from math import pi
9+
import numpy
10+
811

912
def truss_section(name, E=0.0, A=0.0, rho=0.0):
1013
"""
@@ -46,7 +49,7 @@ def beam_3d_section(
4649
Iz=0.0,
4750
J=0.0,
4851
rho=0.0,
49-
xz_vector=[0, 0, 1],
52+
xz_vector=(0, 0, 1),
5053
):
5154
"""
5255
Define 3d beam section.
@@ -71,3 +74,49 @@ def beam_3d_section(
7174
s["J"] = J
7275
s["xz_vector"] = xz_vector
7376
return s
77+
78+
79+
def close_points(points):
80+
"""
81+
If the input points do not form a closed polygon, closes the polygon
82+
and returns the result.
83+
84+
Parameters
85+
----------
86+
points : array
87+
An array of (x, y) coordinates of shape (N, 2).
88+
"""
89+
p = numpy.asarray(points)
90+
if (p[0] == p[-1]).all():
91+
return p
92+
return numpy.append(p, [p[0]], axis=0)
93+
94+
95+
def hollow_circle(innerradius, outerradius):
96+
"""
97+
Returns the area, moments of inertia and torsion constant for a hollow circle (tube).
98+
"""
99+
Rext = outerradius
100+
Rint = innerradius
101+
A = pi * (Rext ^ 2 - Rint ^ 2)
102+
Iy = pi / 4 * (Rext ^ 4 - Rint ^ 4)
103+
Iz = pi / 4 * (Rext ^ 4 - Rint ^ 4)
104+
Ix = Iy + Iz
105+
J = pi / 2 * (Rext ^ 4 - Rint ^ 4)
106+
return A, Ix, Iy, Iz, J
107+
108+
109+
def i_beam(H, B, tf, tw):
110+
"""
111+
Returns the area, moments of inertia and torsion constant for an I-beam.
112+
"""
113+
A = B * H - (B - tw) * (H - 2 * tf)
114+
Iy = (B / 12) * H**3 - ((B - tw) / 12) * (H - 2 * tf) ** 3
115+
Iz = (
116+
H * B**3 / 12
117+
- 2 * ((B - tw) / 2) ** 3 * (H - 2 * tf) / 12
118+
- 2 * ((B - tw) / 2) * (H - 2 * tf) * ((B - tw) / 4 + tw / 2) ** 2
119+
)
120+
Ix = Iy + Iz
121+
J = (2 * B * tf**3 + (H - 2 * tf) * tw**3) / 3
122+
return A, Ix, Iy, Iz, J

0 commit comments

Comments
 (0)