|
1 | 1 | import pytest |
| 2 | +import math |
2 | 3 | import sectionproperties.pre.library.primitive_sections as primitive_sections |
3 | 4 | from sectionproperties.analysis.section import Section |
4 | 5 |
|
@@ -48,3 +49,37 @@ def test_stress_runtime_errors(): |
48 | 49 | sec.calculate_stress(Vy=1) |
49 | 50 | sec.calculate_stress(Mzz=1) |
50 | 51 | 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