Skip to content

Commit d208a5d

Browse files
Add unit tests for stress at points
1 parent 5dcead8 commit d208a5d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

sectionproperties/tests/test_stress.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import math
23
import sectionproperties.pre.library.primitive_sections as primitive_sections
34
from sectionproperties.analysis.section import Section
45

@@ -48,3 +49,37 @@ def test_stress_runtime_errors():
4849
sec.calculate_stress(Vy=1)
4950
sec.calculate_stress(Mzz=1)
5051
sec.get_stress_at_points(pts=[[10, 10]], Mzz=1)
52+
53+
54+
def test_rectangle():
55+
Mxx = 7
56+
Sy = 50.0 * 100.0**2 / 6.0
57+
sig_max = Mxx / Sy
58+
(sig_0, sig_1, sig_2) = sec.get_stress_at_points(
59+
pts=[[25, 50], [25, 75], [25, 100]], Mxx=Mxx
60+
)
61+
assert sig_0 == pytest.approx((0, 0, 0))
62+
assert sig_1 == pytest.approx((sig_max / 2.0, 0, 0))
63+
assert sig_2 == pytest.approx((sig_max, 0, 0))
64+
65+
66+
def test_rotated_rectangle():
67+
b = 50
68+
d = 100
69+
angle = math.atan(100 / 50)
70+
rot_rect = (
71+
primitive_sections.rectangular_section(b=b, d=d)
72+
.shift_section(-b / 2, -d / 2)
73+
.rotate_section(angle, use_radians=True)
74+
)
75+
rot_rect.create_mesh(mesh_sizes=0) # coarse mesh
76+
rot_sec = Section(rot_rect)
77+
rot_sec.calculate_geometric_properties()
78+
rot_sec.calculate_warping_properties()
79+
Mxx = 7
80+
cx = b / 2 * math.cos(angle) - d / 2 * math.sin(angle)
81+
cy = b / 2 * math.sin(angle) + d / 2 * math.cos(angle)
82+
Sy = b * d / 6.0 * cy
83+
sig_max = Mxx / Sy
84+
(sig_0, sig_1) = rot_sec.get_stress_at_points(pts=[[cx, 0], [cx, cy]], Mxx=Mxx)
85+
assert sig_1 == pytest.approx((sig_max, 0, 0))

0 commit comments

Comments
 (0)