|
| 1 | +import pytest |
| 2 | +import sectionproperties.pre.library.primitive_sections as primitive_sections |
| 3 | +from sectionproperties.analysis.section import Section |
| 4 | + |
| 5 | +# define geometry |
| 6 | +rect = primitive_sections.rectangular_section(b=50, d=100) |
| 7 | +rect.create_mesh(mesh_sizes=0) # coarse mesh |
| 8 | +sec = Section(rect) |
| 9 | + |
| 10 | + |
| 11 | +# test stress runtime errors |
| 12 | +def test_stress_runtime_errors(): |
| 13 | + # check runtime error with no analysis performed |
| 14 | + with pytest.raises(RuntimeError): |
| 15 | + sec.calculate_stress() |
| 16 | + |
| 17 | + sec.calculate_geometric_properties() |
| 18 | + |
| 19 | + # check runtime errors with shear/torsion applied, no warping analysis |
| 20 | + with pytest.raises(RuntimeError): |
| 21 | + sec.calculate_stress(Vx=1) |
| 22 | + |
| 23 | + with pytest.raises(RuntimeError): |
| 24 | + sec.calculate_stress(Vy=1) |
| 25 | + |
| 26 | + with pytest.raises(RuntimeError): |
| 27 | + sec.calculate_stress(Mzz=1) |
| 28 | + |
| 29 | + # check no runtime errors with no shear/torsion applied |
| 30 | + sec.calculate_stress(N=1) |
| 31 | + sec.calculate_stress(Mxx=1) |
| 32 | + sec.calculate_stress(Myy=1) |
| 33 | + sec.calculate_stress(M11=1) |
| 34 | + sec.calculate_stress(M22=1) |
| 35 | + |
| 36 | + sec.calculate_warping_properties() |
| 37 | + |
| 38 | + # check no runtime errors after warping analysis |
| 39 | + sec.calculate_stress(N=1) |
| 40 | + sec.calculate_stress(Mxx=1) |
| 41 | + sec.calculate_stress(Myy=1) |
| 42 | + sec.calculate_stress(M11=1) |
| 43 | + sec.calculate_stress(M22=1) |
| 44 | + sec.calculate_stress(Vx=1) |
| 45 | + sec.calculate_stress(Vy=1) |
| 46 | + sec.calculate_stress(Mzz=1) |
0 commit comments