Skip to content

Commit a5fbb29

Browse files
committed
Create test_twist.py
1 parent ae317c8 commit a5fbb29

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

tests/test_twist.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import pytest
2+
3+
from xsection.analysis.venant import SaintVenantSectionAnalysis
4+
from xsection.library import Rectangle
5+
from xsection.properties import torsion_constant
6+
7+
8+
def test_T3():
9+
10+
shape = Rectangle(b=3, d=5,
11+
mesh_scale=1/40,
12+
mesher="triangle",
13+
mesh_type="T3")
14+
sv = SaintVenantSectionAnalysis(shape, nu=0.3)
15+
assert sv._A == pytest.approx(shape.d*shape.b, rel=1e-6)
16+
17+
J = torsion_constant(shape)
18+
assert sv.twist_rigidity() == pytest.approx(J, rel=1e-2)
19+
20+
21+
def test_T3_material():
22+
23+
shape = Rectangle(b=3, d=5,
24+
mesh_scale=1/40,
25+
material={"E": 4, "G": 2},
26+
mesher="triangle",
27+
mesh_type="T3")
28+
sv = SaintVenantSectionAnalysis(shape)
29+
assert sv._A == pytest.approx(shape.d*shape.b, rel=1e-6)
30+
assert sv._EA == pytest.approx(shape.d*shape.b*shape.material["E"], rel=1e-6)
31+
32+
J = torsion_constant(shape)
33+
assert sv.twist_rigidity()/shape.material["G"] == pytest.approx(J, rel=1e-2)
34+
35+
36+
37+
38+
def test_T6():
39+
shape = Rectangle(b=3, d=5,
40+
mesh_scale=1/5,
41+
poisson=0.3,
42+
mesher="triangle",
43+
mesh_type="T6")
44+
45+
sv = SaintVenantSectionAnalysis(shape, nu=0.3)
46+
assert sv._A == pytest.approx(shape.d*shape.b, rel=1e-6)
47+
48+
J = torsion_constant(shape)
49+
assert sv.torsion_constant() == pytest.approx(J, rel=1e-2)
50+
51+
52+
ic = sv.iesan_center()
53+
# print("Iesan center:", ic)
54+
assert ic[0] == pytest.approx(0, abs=1e-3)
55+
assert ic[1] == pytest.approx(0, abs=1e-3)
56+
57+
58+
def test_T6_gmsh():
59+
from xsection.analysis.venant import SaintVenantSectionAnalysis
60+
from xsection.library import Rectangle
61+
from xsection.properties import torsion_constant
62+
material = {"E": 4, "G": 2}
63+
shape = Rectangle(b=3, d=5,
64+
mesh_scale=1/10,
65+
material=material,
66+
mesher="gmsh",
67+
mesh_type="T6")
68+
sv = SaintVenantSectionAnalysis(shape)#, nu=0.3)
69+
assert sv._A == pytest.approx(shape.d*shape.b, rel=1e-6)
70+
71+
J = torsion_constant(shape)
72+
assert sv.twist_rigidity()/material["G"] == pytest.approx(J, rel=1e-2)
73+
74+
75+
ic = sv.iesan_center()
76+
assert ic[0] == pytest.approx(0, abs=1e-3)
77+
assert ic[1] == pytest.approx(0, abs=1e-3)
78+
79+
80+
def test_T6_material_gmsh():
81+
from xsection.analysis.venant import SaintVenantSectionAnalysis
82+
from xsection.library import Rectangle
83+
from xsection.properties import torsion_constant
84+
85+
shape = Rectangle(b=3, d=5,
86+
mesh_scale=1/10,
87+
material={"E": 4, "G": 2},
88+
mesher="gmsh",
89+
mesh_type="T6")
90+
sv = SaintVenantSectionAnalysis(shape, nu=0.3)
91+
assert sv._A == pytest.approx(shape.d*shape.b, rel=1e-6)
92+
assert sv._EA == pytest.approx(shape.d*shape.b*shape.material["E"], rel=1e-6)
93+
assert sv._GA == pytest.approx(shape.d*shape.b*shape.material["G"], rel=1e-6)
94+
95+
J = torsion_constant(shape)
96+
assert sv.twist_rigidity()/shape.material["G"] == pytest.approx(J, rel=1e-2)
97+
98+
99+
ic = sv.iesan_center()
100+
assert ic[0] == pytest.approx(0, abs=1e-3)
101+
assert ic[1] == pytest.approx(0, abs=1e-3)

0 commit comments

Comments
 (0)