Skip to content

Commit 7e00593

Browse files
Merge pull request #262 from normanrichardson/unit-test-stress-at-point
Unit test stress at point
2 parents 706ba2f + 777ba32 commit 7e00593

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+
cx = b / 2 * math.cos(angle) - d / 2 * math.sin(angle)
71+
cy = b / 2 * math.sin(angle) + d / 2 * math.cos(angle)
72+
Sy = b * d / 6.0 * cy
73+
Mxx = 7
74+
sig_max = Mxx / Sy
75+
rot_rect = (
76+
primitive_sections.rectangular_section(b=b, d=d)
77+
.shift_section(-b / 2, -d / 2)
78+
.rotate_section(angle, use_radians=True)
79+
)
80+
rot_rect.create_mesh(mesh_sizes=0) # coarse mesh
81+
rot_sec = Section(rot_rect)
82+
rot_sec.calculate_geometric_properties()
83+
rot_sec.calculate_warping_properties()
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)