Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions sectionproperties/tests/test_stress.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import math
import sectionproperties.pre.library.primitive_sections as primitive_sections
from sectionproperties.analysis.section import Section

Expand Down Expand Up @@ -48,3 +49,37 @@ def test_stress_runtime_errors():
sec.calculate_stress(Vy=1)
sec.calculate_stress(Mzz=1)
sec.get_stress_at_points(pts=[[10, 10]], Mzz=1)


def test_rectangle():
Mxx = 7
Sy = 50.0 * 100.0**2 / 6.0
sig_max = Mxx / Sy
(sig_0, sig_1, sig_2) = sec.get_stress_at_points(
pts=[[25, 50], [25, 75], [25, 100]], Mxx=Mxx
)
assert sig_0 == pytest.approx((0, 0, 0))
assert sig_1 == pytest.approx((sig_max / 2.0, 0, 0))
assert sig_2 == pytest.approx((sig_max, 0, 0))


def test_rotated_rectangle():
b = 50
d = 100
angle = math.atan(100 / 50)
cx = b / 2 * math.cos(angle) - d / 2 * math.sin(angle)
cy = b / 2 * math.sin(angle) + d / 2 * math.cos(angle)
Sy = b * d / 6.0 * cy
Mxx = 7
sig_max = Mxx / Sy
rot_rect = (
primitive_sections.rectangular_section(b=b, d=d)
.shift_section(-b / 2, -d / 2)
.rotate_section(angle, use_radians=True)
)
rot_rect.create_mesh(mesh_sizes=0) # coarse mesh
rot_sec = Section(rot_rect)
rot_sec.calculate_geometric_properties()
rot_sec.calculate_warping_properties()
(sig_0, sig_1) = rot_sec.get_stress_at_points(pts=[[cx, 0], [cx, cy]], Mxx=Mxx)
assert sig_1 == pytest.approx((sig_max, 0, 0))