Skip to content

Commit b9520f7

Browse files
committed
update tests
1 parent 89a209a commit b9520f7

3 files changed

Lines changed: 47 additions & 12 deletions

File tree

tests/test_girder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
\hline
3838
\end{tabular}
3939
"""
40+
41+
4042
def test_asbi():
4143

4244
# Flat soffit
@@ -84,6 +86,7 @@ def test_asbi():
8486
assert shape.area == pytest.approx(6_135_000*u.mm**2, rel=1e-2)
8587

8688

89+
8790
def test_torsion():
8891

8992
shape = load_shape("G02", mesh_type="T6", mesh_scale=1)

tests/test_groups.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
from xsection.library import WideFlange
3-
from xsection._benchmarks import load_shape
3+
from xsection._benchmarks import load_shape, ShapeM03
44

55

66

@@ -10,7 +10,9 @@
1010
tw = 0.1
1111
A_ref = (d-2*tf)*tw + 2*tf*b
1212

13+
1314
def test_1():
15+
1416
for elem in ["T3", "T6"]:
1517
for mesher in ["triangle", "gmsh"]:
1618
shape = WideFlange(d=d, b=b, tf=tf, tw=tw,
@@ -21,7 +23,7 @@ def test_1():
2123
A = 0
2224
for fiber in shape.create_fibers(group="1"):
2325
A += fiber["area"]
24-
assert A == pytest.approx(A_ref, rel=1e-6)
26+
assert A == pytest.approx(A_ref, rel=1e-8)
2527

2628

2729
def test_2():
@@ -38,22 +40,47 @@ def test_2():
3840
A = 0
3941
for fiber in shape._create_fibers(shape.model, [], group="1"):
4042
A += fiber["area"]
41-
assert A == pytest.approx(A_ref, rel=1e-6)
43+
assert A == pytest.approx(A_ref, rel=1e-8)
4244

4345

44-
def test_composite():
46+
def test_m01():
4547
shape = load_shape("M01")
4648

4749
A1 = 0
4850
for fiber in shape.create_fibers(group="1"):
4951
A1 += fiber["area"]
52+
5053
A2 = 0
5154
for fiber in shape.create_fibers(group="2"):
5255
A2 += fiber["area"]
56+
57+
58+
assert A2 == pytest.approx(shape._shapes[0].area, rel=1e-8)
59+
assert A1 == pytest.approx(shape._shapes[1].area, rel=1e-8)
60+
61+
62+
63+
def test_m03():
64+
shape, properties = ShapeM03()
65+
66+
A_gross = 0.0
67+
A_rebar = 0.0
68+
A_core = 0.0
69+
70+
for fiber in shape.create_fibers(group="rebar"):
71+
A_rebar += fiber["area"]
72+
A_gross += fiber["area"]
73+
74+
for fiber in shape.create_fibers(group="core"):
75+
A_core += fiber["area"]
76+
A_gross += fiber["area"]
5377

78+
for fiber in shape.create_fibers(group="cover"):
79+
A_gross += fiber["area"]
80+
5481

55-
assert A2 == pytest.approx(
56-
shape._shapes[0].area, rel=1e-6)
57-
assert A1 == pytest.approx(
58-
shape._shapes[1].area, rel=1e-6)
82+
83+
assert A_rebar == pytest.approx(properties["rebar"]["A"], rel=1e-8)
84+
assert A_gross == pytest.approx(properties["gross"]["A"], rel=1e-8)
85+
5986

tests/test_r_twist.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ def test_T3():
1818
assert sv.twist_rigidity() == pytest.approx(J, rel=1e-2)
1919

2020

21+
2122
def test_T3_material():
2223

23-
shape = Rectangle(b=3, d=5,
24+
shape = Rectangle(b=3,
25+
d=5,
2426
mesh_scale=1/40,
2527
material={"E": 4, "G": 2},
2628
mesher="triangle",
@@ -36,7 +38,8 @@ def test_T3_material():
3638

3739

3840
def test_T6():
39-
shape = Rectangle(b=3, d=5,
41+
shape = Rectangle(b=3,
42+
d=5,
4043
mesh_scale=1/5,
4144
mesher="triangle",
4245
mesh_type="T6")
@@ -60,7 +63,8 @@ def test_T6_gmsh():
6063
from xsection.library import Rectangle
6164
from xsection.properties import torsion_constant
6265
material = {"E": 4, "G": 2}
63-
shape = Rectangle(b=3, d=5,
66+
shape = Rectangle(b=3,
67+
d=5,
6468
mesh_scale=1/10,
6569
material=material,
6670
mesher="gmsh",
@@ -82,7 +86,8 @@ def test_T6_material_gmsh():
8286
from xsection.library import Rectangle
8387
from xsection.properties import torsion_constant
8488

85-
shape = Rectangle(b=3, d=5,
89+
shape = Rectangle(b=3,
90+
d=5,
8691
mesh_scale=1/10,
8792
material={"E": 4, "G": 2},
8893
mesher="gmsh",

0 commit comments

Comments
 (0)