Skip to content

Commit e9921ab

Browse files
Merge pull request #576 from robbievanleeuwen/feature/display-transformed-results
Add `display_transformed_results()` method
2 parents f4ae7f6 + 584c12c commit e9921ab

File tree

6 files changed

+384
-13
lines changed

6 files changed

+384
-13
lines changed

docs/examples/materials/composite_analysis.ipynb

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
"id": "29",
346346
"metadata": {},
347347
"source": [
348-
"A plastic analysis for composite sections will calculate plastic moments rather than plastic section moduli. The plastic moment assumes all geometry fibres reach the yield strength."
348+
"Further, we can display the transformed results with respect to an elastic modulus by calling the `display_transformed_results()` method. Here we print the transformed section properties with respect to the timber."
349349
]
350350
},
351351
{
@@ -354,14 +354,32 @@
354354
"id": "30",
355355
"metadata": {},
356356
"outputs": [],
357+
"source": [
358+
"sec.display_transformed_results(e_ref=timber)"
359+
]
360+
},
361+
{
362+
"cell_type": "markdown",
363+
"id": "31",
364+
"metadata": {},
365+
"source": [
366+
"A plastic analysis for composite sections will calculate plastic moments rather than plastic section moduli. The plastic moment assumes all geometry fibres reach the yield strength."
367+
]
368+
},
369+
{
370+
"cell_type": "code",
371+
"execution_count": null,
372+
"id": "32",
373+
"metadata": {},
374+
"outputs": [],
357375
"source": [
358376
"mp_xx, _ = sec.get_mp()\n",
359377
"print(f\"Mp = {mp_xx / 1e6:.1f} kN.m\")"
360378
]
361379
},
362380
{
363381
"cell_type": "markdown",
364-
"id": "31",
382+
"id": "33",
365383
"metadata": {},
366384
"source": [
367385
"### Stress Analysis"
@@ -370,7 +388,7 @@
370388
{
371389
"cell_type": "code",
372390
"execution_count": null,
373-
"id": "32",
391+
"id": "34",
374392
"metadata": {},
375393
"outputs": [],
376394
"source": [
@@ -380,7 +398,7 @@
380398
{
381399
"cell_type": "code",
382400
"execution_count": null,
383-
"id": "33",
401+
"id": "35",
384402
"metadata": {},
385403
"outputs": [],
386404
"source": [
@@ -390,7 +408,7 @@
390408
{
391409
"cell_type": "code",
392410
"execution_count": null,
393-
"id": "34",
411+
"id": "36",
394412
"metadata": {},
395413
"outputs": [],
396414
"source": [
@@ -399,7 +417,7 @@
399417
},
400418
{
401419
"cell_type": "markdown",
402-
"id": "35",
420+
"id": "37",
403421
"metadata": {},
404422
"source": [
405423
"We can plot only a specific list of materials by including the `material_list` argument. In the above plot it is difficult to see the stress in the timber so we set `material_list=[timber]`."
@@ -408,7 +426,7 @@
408426
{
409427
"cell_type": "code",
410428
"execution_count": null,
411-
"id": "36",
429+
"id": "38",
412430
"metadata": {},
413431
"outputs": [],
414432
"source": [
@@ -432,7 +450,7 @@
432450
"name": "python",
433451
"nbconvert_exporter": "python",
434452
"pygments_lexer": "ipython3",
435-
"version": "3.9.17"
453+
"version": "3.14.0"
436454
}
437455
},
438456
"nbformat": 4,

docs/examples/results/display_results.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"id": "11",
115115
"metadata": {},
116116
"source": [
117-
"Because we have not specified any material properties, the displayed properties are purely geometric. If we assign a steel material to the CHS, we will see some results change to material property weighted values (see [here](../../user_guide/results.rst#how-material-properties-affect-results) for more information on how material properties affect results)."
117+
"Because we have not specified any material properties, the displayed properties are purely geometric. If we assign a steel material to the CHS, we will see some results change to material property weighted values (see [here](../../user_guide/results.rst#how-material-properties-affect-results) for more information on how material properties affect results). We can also print the transformed results using the `display_transformed_results()` method."
118118
]
119119
},
120120
{
@@ -145,7 +145,8 @@
145145
"sec.calculate_geometric_properties()\n",
146146
"sec.calculate_warping_properties()\n",
147147
"sec.calculate_plastic_properties()\n",
148-
"sec.display_results(fmt=\".3e\")"
148+
"sec.display_results(fmt=\".3e\")\n",
149+
"sec.display_transformed_results(e_ref=steel, fmt=\".3e\")"
149150
]
150151
}
151152
],
@@ -165,7 +166,7 @@
165166
"name": "python",
166167
"nbconvert_exporter": "python",
167168
"pygments_lexer": "ipython3",
168-
"version": "3.9.17"
169+
"version": "3.14.0"
169170
}
170171
},
171172
"nbformat": 4,

docs/examples/results/get_results.ipynb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,24 @@
270270
"source": [
271271
"print(f\"I_rect = {300 * 600**3 / 12:.3e} mm4\")"
272272
]
273+
},
274+
{
275+
"cell_type": "markdown",
276+
"id": "21",
277+
"metadata": {},
278+
"source": [
279+
"Finally, we can print the transformed section properties using the `display_transformed_results()` method."
280+
]
281+
},
282+
{
283+
"cell_type": "code",
284+
"execution_count": null,
285+
"id": "22",
286+
"metadata": {},
287+
"outputs": [],
288+
"source": [
289+
"sec.display_transformed_results(e_ref=concrete, fmt=\".3e\")"
290+
]
273291
}
274292
],
275293
"metadata": {
@@ -288,7 +306,7 @@
288306
"name": "python",
289307
"nbconvert_exporter": "python",
290308
"pygments_lexer": "ipython3",
291-
"version": "3.9.17"
309+
"version": "3.14.0"
292310
}
293311
},
294312
"nbformat": 4,

docs/user_guide/results.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ Displaying the Results
77
A list of cross-section properties that have been calculated by the performed analyses
88
can be printed to the terminal using the
99
:meth:`~sectionproperties.analysis.section.Section.display_results` method that belongs
10-
to every :class:`~sectionproperties.analysis.section.Section` object.
10+
to every :class:`~sectionproperties.analysis.section.Section` object.
1111

1212
.. automethod:: sectionproperties.analysis.section.Section.display_results
1313
:noindex:
1414

15+
If a composite analysis has been performed, the transformed properties can be printed to
16+
the terminal using the
17+
:meth:`~sectionproperties.analysis.section.Section.display_transformed_results` method
18+
that belongs to every :class:`~sectionproperties.analysis.section.Section` object.
19+
20+
.. automethod:: sectionproperties.analysis.section.Section.display_transformed_results
21+
:noindex:
22+
1523
Retrieving Section Properties
1624
-----------------------------
1725

src/sectionproperties/analysis/section.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,36 @@ def display_results(
18731873
"""
18741874
post.print_results(section=self, fmt=fmt)
18751875

1876+
def display_transformed_results(
1877+
self,
1878+
e_ref: float | pre.Material,
1879+
fmt: str = "8.6e",
1880+
) -> None:
1881+
"""Prints the transformed results that have been calculated to the terminal.
1882+
1883+
All results that are scaled by the elastic modulus in ``display_results()``
1884+
(e.g. ``e.ixx_c``) are divided by ``e_ref``.
1885+
1886+
This is a composite only method, as such this can only be called if material
1887+
properties have been applied to the cross-section.
1888+
1889+
Args:
1890+
e_ref: Reference elastic modulus or material property by which to transform
1891+
the results.
1892+
fmt: Number formatting string, see
1893+
https://docs.python.org/3/library/string.html. Defaults to ``"8.6e"``.
1894+
1895+
Raises:
1896+
RuntimeError: If material properties have *not* been applied
1897+
"""
1898+
if not self.is_composite():
1899+
msg = "Attempting to call a composite only method for a geometric analysis"
1900+
msg += " (material properties have not been applied). Consider using"
1901+
msg += " display_results()."
1902+
raise RuntimeError(msg)
1903+
1904+
post.print_transformed_results(section=self, e_ref=e_ref, fmt=fmt)
1905+
18761906
def is_composite(self) -> bool:
18771907
"""Returns whether or not a composite section is being analysed.
18781908

0 commit comments

Comments
 (0)