Skip to content

Commit 7075202

Browse files
Add plotting tests
1 parent 0ecac69 commit 7075202

File tree

2 files changed

+79
-40
lines changed

2 files changed

+79
-40
lines changed

src/concreteproperties/concrete_section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ def moment_interaction_diagram(
11791179
11801180
Args:
11811181
theta: Angle (in radians) the neutral axis makes with the horizontal axis
1182-
(:math:`-\pi \leq \theta \leq \pi`)
1182+
(:math:`-\pi \leq \theta \leq \pi`). Defaults to ``0``.
11831183
limits: List of control points that define the start and end of the
11841184
interaction diagram. List length must equal two. The default limits
11851185
range from concrete decompression strain to zero curvature tension, i.e.

tests/test_post.py

Lines changed: 78 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests the post methods."""
22

33
import math
4+
import platform
45

56
import pytest
67
from sectionproperties.pre.library import concrete_rectangular_section
@@ -15,6 +16,58 @@
1516
)
1617
from concreteproperties.post import DEFAULT_UNITS, si_kn_m, si_n_mm, string_formatter
1718

19+
linux_only = pytest.mark.skipif(
20+
platform.system() != "Linux",
21+
reason="Only test plotting on Linux",
22+
)
23+
24+
25+
@pytest.fixture
26+
def concrete_section() -> ConcreteSection:
27+
"""Generates a simple ConcreteSection object.
28+
29+
Returns:
30+
Geometry
31+
"""
32+
concrete = Concrete(
33+
name="32 MPa Concrete",
34+
density=2.4e-6,
35+
stress_strain_profile=ConcreteLinear(elastic_modulus=30.1e3),
36+
ultimate_stress_strain_profile=RectangularStressBlock(
37+
compressive_strength=32,
38+
alpha=0.802,
39+
gamma=0.89,
40+
ultimate_strain=0.003,
41+
),
42+
flexural_tensile_strength=3.4,
43+
colour="lightgrey",
44+
)
45+
steel = SteelBar(
46+
name="500 MPa Steel",
47+
density=7.85e-6,
48+
stress_strain_profile=SteelElasticPlastic(
49+
yield_strength=500,
50+
elastic_modulus=200e3,
51+
fracture_strain=0.05,
52+
),
53+
colour="grey",
54+
)
55+
geom = concrete_rectangular_section(
56+
d=300,
57+
b=300,
58+
dia_top=20,
59+
area_top=310,
60+
n_top=2,
61+
c_top=30,
62+
dia_bot=24,
63+
area_bot=450,
64+
n_bot=2,
65+
c_bot=30,
66+
conc_mat=concrete,
67+
steel_mat=steel,
68+
)
69+
return ConcreteSection(geom)
70+
1871

1972
def test_string_formatter():
2073
"""Tests the string formatter."""
@@ -91,46 +144,9 @@ def test_unit_display():
91144
assert si_kn_m.length_4_scale == pytest.approx(1e-12)
92145

93146

94-
def test_print():
147+
def test_print(concrete_section: ConcreteSection):
95148
"""Tests printing results to terminal."""
96-
concrete = Concrete(
97-
name="32 MPa Concrete",
98-
density=2.4e-6,
99-
stress_strain_profile=ConcreteLinear(elastic_modulus=30.1e3),
100-
ultimate_stress_strain_profile=RectangularStressBlock(
101-
compressive_strength=32,
102-
alpha=0.802,
103-
gamma=0.89,
104-
ultimate_strain=0.003,
105-
),
106-
flexural_tensile_strength=3.4,
107-
colour="lightgrey",
108-
)
109-
steel = SteelBar(
110-
name="500 MPa Steel",
111-
density=7.85e-6,
112-
stress_strain_profile=SteelElasticPlastic(
113-
yield_strength=500,
114-
elastic_modulus=200e3,
115-
fracture_strain=0.05,
116-
),
117-
colour="grey",
118-
)
119-
geom = concrete_rectangular_section(
120-
d=600,
121-
b=400,
122-
dia_top=20,
123-
area_top=310,
124-
n_top=3,
125-
c_top=30,
126-
dia_bot=24,
127-
area_bot=450,
128-
n_bot=3,
129-
c_bot=30,
130-
conc_mat=concrete,
131-
steel_mat=steel,
132-
)
133-
conc_sec = ConcreteSection(geom)
149+
conc_sec = concrete_section
134150
gross_props = conc_sec.get_gross_properties()
135151
gross_props.print_results()
136152
gross_props.print_results(units=DEFAULT_UNITS)
@@ -148,3 +164,26 @@ def test_print():
148164
ult_res.print_results()
149165
si_n_mm.radians = False # display angles in degrees
150166
ult_res.print_results(units=si_n_mm)
167+
168+
169+
@linux_only
170+
def test_plot(concrete_section: ConcreteSection):
171+
"""Tests plotting results."""
172+
conc_sec = concrete_section
173+
174+
# mk
175+
mk = conc_sec.moment_curvature_analysis(kappa_inc=1e-6, progress_bar=False)
176+
mk.plot_results()
177+
mk.plot_failure_geometry()
178+
mk.plot_multiple_results([mk, mk], ["1", "2"])
179+
180+
# mi
181+
mi = conc_sec.moment_interaction_diagram()
182+
mi.plot_diagram()
183+
mi.plot_multiple_diagrams([mi, mi], ["1", "2"])
184+
185+
# bbd
186+
bbd = conc_sec.biaxial_bending_diagram(n=16)
187+
bbd.plot_diagram()
188+
bbd.plot_multiple_diagrams_2d([bbd, bbd])
189+
bbd.plot_multiple_diagrams_3d([bbd, bbd])

0 commit comments

Comments
 (0)