Skip to content

Commit 6c40a87

Browse files
Add default units, update docs
1 parent fc5f535 commit 6c40a87

File tree

15 files changed

+469
-90
lines changed

15 files changed

+469
-90
lines changed

docs/examples/as3600.ipynb

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
" RectangularStressBlock,\n",
2828
")\n",
2929
"from concreteproperties.design_codes import AS3600\n",
30-
"from concreteproperties.results import MomentInteractionResults"
30+
"from concreteproperties.post import si_kn_m, si_n_mm\n",
31+
"from concreteproperties.results import BiaxialBendingResults, MomentInteractionResults"
3132
]
3233
},
3334
{
@@ -68,8 +69,12 @@
6869
"source": [
6970
"print(concrete.name)\n",
7071
"print(f\"Density = {concrete.density} kg/mm^3\")\n",
71-
"concrete.stress_strain_profile.plot_stress_strain(title=\"Service Profile\")\n",
72-
"concrete.ultimate_stress_strain_profile.plot_stress_strain(title=\"Ultimate Profile\")\n",
72+
"concrete.stress_strain_profile.plot_stress_strain(\n",
73+
" title=\"Service Profile\", eng=True, units=si_n_mm\n",
74+
")\n",
75+
"concrete.ultimate_stress_strain_profile.plot_stress_strain(\n",
76+
" title=\"Ultimate Profile\", eng=True, units=si_n_mm\n",
77+
")\n",
7378
"print(\n",
7479
" f\"Concrete Flexural Tensile Strength: {concrete.flexural_tensile_strength:.2f} MPa\"\n",
7580
")"
@@ -92,7 +97,7 @@
9297
"source": [
9398
"print(steel.name)\n",
9499
"print(f\"Density = {steel.density} kg/mm^3\")\n",
95-
"steel.stress_strain_profile.plot_stress_strain()"
100+
"steel.stress_strain_profile.plot_stress_strain(eng=True, units=si_n_mm)"
96101
]
97102
},
98103
{
@@ -240,7 +245,10 @@
240245
"outputs": [],
241246
"source": [
242247
"MomentInteractionResults.plot_multiple_diagrams(\n",
243-
" [f_mi_res, mi_res], [\"Factored\", \"Unfactored\"], fmt=\"-\"\n",
248+
" [mi_res, f_mi_res],\n",
249+
" [\"Unfactored\", \"Factored\"],\n",
250+
" fmt=\"-\",\n",
251+
" units=si_kn_m,\n",
244252
")"
245253
]
246254
},
@@ -294,7 +302,11 @@
294302
"n_cases = len(n_stars)\n",
295303
"\n",
296304
"# plot moment interaction diagram\n",
297-
"ax = f_mi_res.plot_diagram(fmt=\"k-\", render=False)\n",
305+
"ax = f_mi_res.plot_diagram(\n",
306+
" fmt=\"k-\",\n",
307+
" units=si_kn_m,\n",
308+
" render=False,\n",
309+
")\n",
298310
"\n",
299311
"# check to see if combination is within diagram and plot result\n",
300312
"for idx in range(n_cases):\n",
@@ -356,6 +368,7 @@
356368
" [f_mi_res, f_mi_res_bil, f_mi_res_par],\n",
357369
" [\"Rectangular\", \"Bilinear\", \"Parabolic\"],\n",
358370
" fmt=\"-\",\n",
371+
" units=si_kn_m,\n",
359372
")"
360373
]
361374
},
@@ -400,15 +413,19 @@
400413
"outputs": [],
401414
"source": [
402415
"# plot case 1\n",
403-
"ax = f_bb_res1.plot_diagram(fmt=\"x-\", render=False)\n",
404-
"bb_res1.plot_diagram(fmt=\"o-\", ax=ax)\n",
405-
"plt.show()\n",
416+
"BiaxialBendingResults.plot_multiple_diagrams_2d(\n",
417+
" [bb_res1, f_bb_res1],\n",
418+
" labels=[\"Unfactored\", \"Factored\"],\n",
419+
" units=si_kn_m,\n",
420+
")\n",
406421
"print(f\"Average phi = {np.mean(phis1):.3f}\")\n",
407422
"\n",
408423
"# plot case 2\n",
409-
"ax = f_bb_res2.plot_diagram(fmt=\"x-\", render=False)\n",
410-
"bb_res2.plot_diagram(fmt=\"o-\", ax=ax)\n",
411-
"plt.show()\n",
424+
"BiaxialBendingResults.plot_multiple_diagrams_2d(\n",
425+
" [bb_res2, f_bb_res2],\n",
426+
" labels=[\"Unfactored\", \"Factored\"],\n",
427+
" units=si_kn_m,\n",
428+
")\n",
412429
"print(f\"Average phi = {np.mean(phis2):.3f}\")"
413430
]
414431
},

docs/examples/nzs3101.ipynb

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
" RectangularStressBlock,\n",
2828
")\n",
2929
"from concreteproperties.design_codes import NZS3101\n",
30+
"from concreteproperties.post import si_kn_m, si_n_mm\n",
3031
"from concreteproperties.results import (\n",
3132
" MomentCurvatureResults,\n",
3233
" MomentInteractionResults,\n",
@@ -75,10 +76,16 @@
7576
"ult_comp = concrete_40.ultimate_stress_strain_profile.get_ultimate_compressive_strain()\n",
7677
"print(f\"Ultimate Compressive Strain: {ult_comp:.4f}\")\n",
7778
"concrete_40.stress_strain_profile.plot_stress_strain(\n",
78-
" title=\"Concrete Serviceability Stress-Strain Profile\", fmt=\"-r\"\n",
79+
" title=\"Concrete Serviceability Stress-Strain Profile\",\n",
80+
" fmt=\"-r\",\n",
81+
" eng=True,\n",
82+
" units=si_n_mm,\n",
7983
")\n",
8084
"concrete_40.ultimate_stress_strain_profile.plot_stress_strain(\n",
81-
" title=\"Concrete Ultimate Stress-Strain Profile\", fmt=\"-r\"\n",
85+
" title=\"Concrete Ultimate Stress-Strain Profile\",\n",
86+
" fmt=\"-r\",\n",
87+
" eng=True,\n",
88+
" units=si_n_mm,\n",
8289
")"
8390
]
8491
},
@@ -103,7 +110,10 @@
103110
"print(f\"Ultimate Tensile Strain = {ult_strain}\")\n",
104111
"print(f\"Overstrength Factor = {steel_300e.phi_os}\")\n",
105112
"steel_300e.stress_strain_profile.plot_stress_strain(\n",
106-
" title=\"Steel Stress-Strain Profile\", fmt=\"-r\"\n",
113+
" title=\"Steel Stress-Strain Profile\",\n",
114+
" fmt=\"-r\",\n",
115+
" eng=True,\n",
116+
" units=si_n_mm,\n",
107117
")"
108118
]
109119
},
@@ -458,6 +468,7 @@
458468
" fmt=\"or\",\n",
459469
" render=False,\n",
460470
" moment=\"m_xy\",\n",
471+
" units=si_kn_m,\n",
461472
")\n",
462473
"plt.gca().lines[0].set_linestyle(\"solid\")\n",
463474
"plt.gca().lines[0].set_marker(\"\")\n",
@@ -490,7 +501,7 @@
490501
"n_cases = len(n_stars)\n",
491502
"\n",
492503
"# plot moment interaction diagram\n",
493-
"ax = f_mi_res.plot_diagram(fmt=\"-r\", render=False)\n",
504+
"ax = f_mi_res.plot_diagram(fmt=\"-r\", render=False, units=si_kn_m)\n",
494505
"\n",
495506
"# check to see if combination is within diagram and plot result\n",
496507
"for idx in range(n_cases):\n",
@@ -541,12 +552,12 @@
541552
"outputs": [],
542553
"source": [
543554
"# plot case 1\n",
544-
"ax = f_bb_res1.plot_diagram(fmt=\"-r\", render=False)\n",
555+
"ax = f_bb_res1.plot_diagram(fmt=\"-r\", render=False, units=si_kn_m)\n",
545556
"ax.plot(M_o_T, 0, \"sk\")\n",
546557
"plt.show()\n",
547558
"\n",
548559
"# plot case 2\n",
549-
"ax = f_bb_res2.plot_diagram(fmt=\"-r\", render=False)\n",
560+
"ax = f_bb_res2.plot_diagram(fmt=\"-r\", render=False, units=si_kn_m)\n",
550561
"ax.plot(M_o_C, 0, \"ok\")\n",
551562
"plt.show()"
552563
]
@@ -703,7 +714,10 @@
703714
")\n",
704715
"\n",
705716
"concrete_25_prob.stress_strain_profile.plot_stress_strain(\n",
706-
" title=\"Mander Unconfined Stress-Strain Profile\", fmt=\"-r\"\n",
717+
" title=\"Mander Unconfined Stress-Strain Profile\",\n",
718+
" fmt=\"-r\",\n",
719+
" eng=True,\n",
720+
" units=si_n_mm,\n",
707721
")"
708722
]
709723
},
@@ -801,7 +815,12 @@
801815
"fail_mat = moment_curvature_results.failure_geometry.material.name\n",
802816
"print(f\"The failure material is:-\\n{fail_mat}\")\n",
803817
"\n",
804-
"MomentCurvatureResults.plot_results(moment_curvature_results, fmt=\"-r\")\n",
818+
"MomentCurvatureResults.plot_results(\n",
819+
" moment_curvature_results,\n",
820+
" fmt=\"-r\",\n",
821+
" eng=True,\n",
822+
" units=si_kn_m,\n",
823+
")\n",
805824
"mcr = conc_sec.calculate_cracked_properties(theta=0).m_cr / 1e6\n",
806825
"print(f\"Cracking moment is M_cr = {mcr:.2f} kNm\")"
807826
]

docs/examples/prestressed_section.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@
624624
"id": "42",
625625
"metadata": {},
626626
"source": [
627-
"Another point of interest on the moment curvature diagram is around 8000 kN.m. At this magnitude of external moment, the section in the service analysis remains uncracked (just below the flexural tensile strenght). However, the section in the ultimate analysis has started to crack and the bending stiffness has begun to soften. Note also the resulting increase in concrete compressive stress to compensate."
627+
"Another point of interest on the moment curvature diagram is around 8000 kN.m. At this magnitude of external moment, the section in the service analysis remains uncracked (just below the flexural tensile strength). However, the section in the ultimate analysis has started to crack and the bending stiffness has begun to soften. Note also the resulting increase in concrete compressive stress to compensate."
628628
]
629629
},
630630
{

docs/user_guide/design_codes/as3600.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ created it must be assigned to the design code::
2121
.. automethod:: concreteproperties.design_codes.as3600.AS3600.assign_concrete_section
2222
:noindex:
2323

24-
.. note::
24+
.. warning::
2525

26-
To maintain unit consistency, the cross-section dimensions should be entered in
27-
*[mm]*.
26+
To maintain unit consistency, length dimensions must be entered in *[mm]*, force
27+
dimensions entered in *[N]* and density dimensions entered |dunits|.
2828

29+
.. |dunits| raw:: html
30+
31+
<em>[kg/mm<sup>3</sup>]</em>
2932

3033
Creating Material Properties
3134
----------------------------

docs/user_guide/results.rst

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ attributes. The transformed gross area properties can be printed to the terminal
4040
calling the
4141
:meth:`~concreteproperties.results.TransformedGrossProperties.print_results` method.
4242

43-
.. autoclass:: concreteproperties.results.TransformedGrossProperties()
43+
.. automethod:: concreteproperties.results.TransformedGrossProperties.print_results()
4444
:noindex:
45-
:members:
4645

4746
.. seealso::
4847
For an application of the above, see the example
@@ -68,7 +67,7 @@ returns a :class:`~concreteproperties.results.CrackedResults` object.
6867
bending.
6968

7069
Calling
71-
:meth:`~concreteproperties.results.TransformedGrossProperties.calculate_transformed_properties`
70+
:meth:`~concreteproperties.results.CrackedResults.calculate_transformed_properties`
7271
on a :class:`~concreteproperties.results.CrackedResults` object stores the transformed
7372
cracked properties as attributes within the current object.
7473

@@ -167,3 +166,49 @@ stress results.
167166
.. seealso::
168167
For an application of the above, see the example
169168
:ref:`/examples/stress_analysis.ipynb`.
169+
170+
171+
Units
172+
-----
173+
174+
Most of the above methods take an optional ``units`` argument as a
175+
:class:`~concreteproperties.post.UnitDisplay()` object. This argument allows results to
176+
be scaled and unit labels applied to numbers/plot axes.
177+
178+
.. autoclass:: concreteproperties.post.UnitDisplay()
179+
:noindex:
180+
181+
For example, if the model data is specified in ``[N]`` and ``[mm]``, results can be
182+
expressed using ``[kN]`` and ``[m]`` by creating an appropriate ``UnitDisplay`` object:
183+
184+
.. code-block:: python
185+
186+
from concreteproperties.post import UnitDisplay
187+
188+
kn_m = UnitDisplay(si_kn_m = UnitDisplay(
189+
length="m", force="kN", mass="kg", length_factor=1e3, force_factor=1e3
190+
)
191+
192+
Note that stresses will automatically be displayed as kilopascals using the above
193+
unit system as ``[kPa]`` is equivalent to |kpa|. Similarly, results in ``[N.mm]``,
194+
``[MPa]`` etc. can be automatically displayed by creating a ``UnitDisplay`` object that
195+
represents the base unit system:
196+
197+
.. |kpa| raw:: html
198+
199+
<code class="docutils literal notranslate"><span class="pre">[kN/m<sup>2</sup>]</span></code>
200+
201+
.. code-block:: python
202+
203+
from concreteproperties.post import UnitDisplay
204+
205+
n_mm = UnitDisplay(length="mm", force="N", mass="kg")
206+
207+
Note that the above two unit systems are baked into ``concreteproperties`` in the
208+
``post`` module with the ``si_n_mm`` and ``si_kn_m`` objects:
209+
210+
.. code-block:: python
211+
212+
from concreteproperties.post import si_kn_m, si_n_mm
213+
214+
``concreteproperties`` welcomes the contribution of further unit systems!

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ docs = [
5959
"ipython==8.29.0",
6060
"nbsphinx==0.9.5",
6161
"nbconvert==7.16.4",
62+
"sphinx-autobuild==2024.10.03",
6263
"sphinx-copybutton==0.5.2",
6364
"sphinxext-opengraph==0.9.1",
6465
]

0 commit comments

Comments
 (0)