Skip to content

Commit

Permalink
Merge pull request #144 from robbievanleeuwen/feature/print-results-s…
Browse files Browse the repository at this point in the history
…caling

Improved number formatting
  • Loading branch information
robbievanleeuwen authored Nov 7, 2024
2 parents b0b1185 + 7075202 commit 3cbe091
Show file tree
Hide file tree
Showing 24 changed files with 2,117 additions and 350 deletions.
6 changes: 3 additions & 3 deletions docs/examples/area_properties.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"outputs": [],
"source": [
"gross_props = conc_sec.get_gross_properties()\n",
"gross_props.print_results(fmt=\".3e\")"
"gross_props.print_results()"
]
},
{
Expand All @@ -153,7 +153,7 @@
"outputs": [],
"source": [
"transformed_props = conc_sec.get_transformed_gross_properties(elastic_modulus=30.1e3)\n",
"transformed_props.print_results(fmt=\".3e\")"
"transformed_props.print_results()"
]
}
],
Expand All @@ -173,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
43 changes: 30 additions & 13 deletions docs/examples/as3600.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
" RectangularStressBlock,\n",
")\n",
"from concreteproperties.design_codes import AS3600\n",
"from concreteproperties.results import MomentInteractionResults"
"from concreteproperties.post import si_kn_m, si_n_mm\n",
"from concreteproperties.results import BiaxialBendingResults, MomentInteractionResults"
]
},
{
Expand Down Expand Up @@ -68,8 +69,12 @@
"source": [
"print(concrete.name)\n",
"print(f\"Density = {concrete.density} kg/mm^3\")\n",
"concrete.stress_strain_profile.plot_stress_strain(title=\"Service Profile\")\n",
"concrete.ultimate_stress_strain_profile.plot_stress_strain(title=\"Ultimate Profile\")\n",
"concrete.stress_strain_profile.plot_stress_strain(\n",
" title=\"Service Profile\", eng=True, units=si_n_mm\n",
")\n",
"concrete.ultimate_stress_strain_profile.plot_stress_strain(\n",
" title=\"Ultimate Profile\", eng=True, units=si_n_mm\n",
")\n",
"print(\n",
" f\"Concrete Flexural Tensile Strength: {concrete.flexural_tensile_strength:.2f} MPa\"\n",
")"
Expand All @@ -92,7 +97,7 @@
"source": [
"print(steel.name)\n",
"print(f\"Density = {steel.density} kg/mm^3\")\n",
"steel.stress_strain_profile.plot_stress_strain()"
"steel.stress_strain_profile.plot_stress_strain(eng=True, units=si_n_mm)"
]
},
{
Expand Down Expand Up @@ -240,7 +245,10 @@
"outputs": [],
"source": [
"MomentInteractionResults.plot_multiple_diagrams(\n",
" [f_mi_res, mi_res], [\"Factored\", \"Unfactored\"], fmt=\"-\"\n",
" [mi_res, f_mi_res],\n",
" [\"Unfactored\", \"Factored\"],\n",
" fmt=\"-\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down Expand Up @@ -294,7 +302,11 @@
"n_cases = len(n_stars)\n",
"\n",
"# plot moment interaction diagram\n",
"ax = f_mi_res.plot_diagram(fmt=\"k-\", render=False)\n",
"ax = f_mi_res.plot_diagram(\n",
" fmt=\"k-\",\n",
" units=si_kn_m,\n",
" render=False,\n",
")\n",
"\n",
"# check to see if combination is within diagram and plot result\n",
"for idx in range(n_cases):\n",
Expand Down Expand Up @@ -356,6 +368,7 @@
" [f_mi_res, f_mi_res_bil, f_mi_res_par],\n",
" [\"Rectangular\", \"Bilinear\", \"Parabolic\"],\n",
" fmt=\"-\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down Expand Up @@ -400,15 +413,19 @@
"outputs": [],
"source": [
"# plot case 1\n",
"ax = f_bb_res1.plot_diagram(fmt=\"x-\", render=False)\n",
"bb_res1.plot_diagram(fmt=\"o-\", ax=ax)\n",
"plt.show()\n",
"BiaxialBendingResults.plot_multiple_diagrams_2d(\n",
" [bb_res1, f_bb_res1],\n",
" labels=[\"Unfactored\", \"Factored\"],\n",
" units=si_kn_m,\n",
")\n",
"print(f\"Average phi = {np.mean(phis1):.3f}\")\n",
"\n",
"# plot case 2\n",
"ax = f_bb_res2.plot_diagram(fmt=\"x-\", render=False)\n",
"bb_res2.plot_diagram(fmt=\"o-\", ax=ax)\n",
"plt.show()\n",
"BiaxialBendingResults.plot_multiple_diagrams_2d(\n",
" [bb_res2, f_bb_res2],\n",
" labels=[\"Unfactored\", \"Factored\"],\n",
" units=si_kn_m,\n",
")\n",
"print(f\"Average phi = {np.mean(phis2):.3f}\")"
]
},
Expand Down Expand Up @@ -437,7 +454,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.12.7"
},
"vscode": {
"interpreter": {
Expand Down
36 changes: 22 additions & 14 deletions docs/examples/biaxial_bending.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
" SteelElasticPlastic,\n",
" add_bar_rectangular_array,\n",
")\n",
"from concreteproperties.post import si_kn_m\n",
"from concreteproperties.results import BiaxialBendingResults"
]
},
Expand Down Expand Up @@ -149,7 +150,7 @@
"metadata": {},
"outputs": [],
"source": [
"bb_res.plot_diagram()"
"bb_res.plot_diagram(eng=True, units=si_kn_m)"
]
},
{
Expand All @@ -168,7 +169,7 @@
"outputs": [],
"source": [
"bb_res = conc_sec.biaxial_bending_diagram(n=1000e3, n_points=24, progress_bar=False)\n",
"bb_res.plot_diagram()"
"bb_res.plot_diagram(eng=True, units=si_kn_m)"
]
},
{
Expand All @@ -189,8 +190,8 @@
"source": [
"mi_x = conc_sec.moment_interaction_diagram(progress_bar=False)\n",
"mi_y = conc_sec.moment_interaction_diagram(theta=np.pi / 2, progress_bar=False)\n",
"mi_x.plot_diagram()\n",
"mi_y.plot_diagram(moment=\"m_y\")\n",
"mi_x.plot_diagram(eng=True)\n",
"mi_y.plot_diagram(moment=\"m_y\", eng=True)\n",
"print(f\"Decompression point for M_x is N = {mi_x.results[1].n / 1e3:.2f} kN\")\n",
"print(f\"Decompression point for M_y is N = {mi_y.results[1].n / 1e3:.2f} kN\")"
]
Expand Down Expand Up @@ -232,7 +233,11 @@
"metadata": {},
"outputs": [],
"source": [
"BiaxialBendingResults.plot_multiple_diagrams_3d(biaxial_results)"
"BiaxialBendingResults.plot_multiple_diagrams_3d(\n",
" biaxial_results,\n",
" eng=True,\n",
" units=si_kn_m,\n",
")"
]
},
{
Expand All @@ -250,7 +255,12 @@
"metadata": {},
"outputs": [],
"source": [
"BiaxialBendingResults.plot_multiple_diagrams_2d(biaxial_results, fmt=\"o-\")"
"BiaxialBendingResults.plot_multiple_diagrams_2d(\n",
" biaxial_results,\n",
" fmt=\"o-\",\n",
" eng=True,\n",
" units=si_kn_m,\n",
")"
]
},
{
Expand All @@ -268,16 +278,14 @@
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"labels = [f\"N = {bb_res.n / 1e3:.0f} kN\" for bb_rs in biaxial_results[::2]]\n",
"labels = [f\"N = {bb_res.n / 1e3:.0f} kN\" for bb_res in biaxial_results[::2]]\n",
"\n",
"ax = BiaxialBendingResults.plot_multiple_diagrams_2d(\n",
" biaxial_results[::2], fmt=\"-\", labels=labels, render=False\n",
")\n",
"ax.set_xlabel(\"Bending Moment $M_x$ [kN.m]\")\n",
"ax.set_ylabel(\"Bending Moment $M_y$ [kN.m]\")\n",
"plt.show()"
" biaxial_results[::2],\n",
" fmt=\"-\",\n",
" labels=labels,\n",
" units=si_kn_m,\n",
")"
]
}
],
Expand Down
46 changes: 25 additions & 21 deletions docs/examples/composite_section.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
" SteelElasticPlastic,\n",
" add_bar_circular_array,\n",
" add_bar_rectangular_array,\n",
")"
")\n",
"from concreteproperties.post import si_kn_m, si_n_mm"
]
},
{
Expand Down Expand Up @@ -170,7 +171,7 @@
"outputs": [],
"source": [
"el_stress = conc_sec.calculate_uncracked_stress(m_x=100e6)\n",
"el_stress.plot_stress()"
"el_stress.plot_stress(units=si_n_mm)"
]
},
{
Expand All @@ -191,7 +192,7 @@
"source": [
"cr_res = conc_sec.calculate_cracked_properties()\n",
"cr_stress = conc_sec.calculate_cracked_stress(cracked_results=cr_res, m=500e6)\n",
"cr_stress.plot_stress()"
"cr_stress.plot_stress(units=si_n_mm)"
]
},
{
Expand Down Expand Up @@ -220,7 +221,7 @@
"metadata": {},
"outputs": [],
"source": [
"mk_res.plot_results(fmt=\"kx-\")"
"mk_res.plot_results(fmt=\"kx-\", eng=True, units=si_kn_m)"
]
},
{
Expand All @@ -237,7 +238,7 @@
"serv_stress = conc_sec.calculate_service_stress(\n",
" moment_curvature_results=mk_res, m=None, kappa=2e-5\n",
")\n",
"serv_stress.plot_stress()"
"serv_stress.plot_stress(units=si_n_mm)"
]
},
{
Expand All @@ -258,8 +259,8 @@
"source": [
"ult_res_x = conc_sec.ultimate_bending_capacity()\n",
"ult_res_y = conc_sec.ultimate_bending_capacity(theta=np.pi / 2)\n",
"ult_res_x.print_results()\n",
"ult_res_y.print_results()"
"ult_res_x.print_results(units=si_kn_m)\n",
"ult_res_y.print_results(units=si_kn_m)"
]
},
{
Expand All @@ -270,7 +271,7 @@
"outputs": [],
"source": [
"mi_res = conc_sec.moment_interaction_diagram(progress_bar=False)\n",
"mi_res.plot_diagram()"
"mi_res.plot_diagram(units=si_kn_m)"
]
},
{
Expand All @@ -281,7 +282,7 @@
"outputs": [],
"source": [
"bb_res = conc_sec.biaxial_bending_diagram(n_points=24, progress_bar=False)\n",
"bb_res.plot_diagram()"
"bb_res.plot_diagram(units=si_kn_m)"
]
},
{
Expand All @@ -293,8 +294,8 @@
"source": [
"ult_stress_x = conc_sec.calculate_ultimate_stress(ult_res_x)\n",
"ult_stress_y = conc_sec.calculate_ultimate_stress(ult_res_y)\n",
"ult_stress_x.plot_stress()\n",
"ult_stress_y.plot_stress()"
"ult_stress_x.plot_stress(units=si_n_mm)\n",
"ult_stress_y.plot_stress(units=si_n_mm)"
]
},
{
Expand Down Expand Up @@ -400,8 +401,8 @@
"source": [
"el_stress_comp = conc_sec_comp.calculate_uncracked_stress(m_x=10e6)\n",
"el_stress_conc = conc_sec_conc.calculate_uncracked_stress(m_x=10e6)\n",
"el_stress_comp.plot_stress()\n",
"el_stress_conc.plot_stress()"
"el_stress_comp.plot_stress(units=si_n_mm)\n",
"el_stress_conc.plot_stress(units=si_n_mm)"
]
},
{
Expand All @@ -428,8 +429,8 @@
"cr_stress_conc = conc_sec_conc.calculate_cracked_stress(\n",
" cracked_results=cr_res_conc, m=50e6\n",
")\n",
"cr_stress_comp.plot_stress()\n",
"cr_stress_conc.plot_stress()"
"cr_stress_comp.plot_stress(units=si_n_mm)\n",
"cr_stress_conc.plot_stress(units=si_n_mm)"
]
},
{
Expand Down Expand Up @@ -467,6 +468,8 @@
" moment_curvature_results=[mk_res_comp, mk_res_conc],\n",
" labels=[\"Composite\", \"Concrete\"],\n",
" fmt=\"x-\",\n",
" eng=True,\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down Expand Up @@ -500,6 +503,7 @@
" moment_interaction_results=[mi_res_comp, mi_res_conc],\n",
" labels=[\"Composite\", \"Concrete\"],\n",
" fmt=\"x-\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down Expand Up @@ -632,7 +636,7 @@
"metadata": {},
"outputs": [],
"source": [
"mk_res.plot_results()"
"mk_res.plot_results(eng=True, units=si_kn_m)"
]
},
{
Expand Down Expand Up @@ -666,9 +670,9 @@
"metadata": {},
"outputs": [],
"source": [
"el_stress.plot_stress()\n",
"yield_stress.plot_stress()\n",
"ult_stress.plot_stress()"
"el_stress.plot_stress(units=si_n_mm)\n",
"yield_stress.plot_stress(units=si_n_mm)\n",
"ult_stress.plot_stress(units=si_n_mm)"
]
},
{
Expand All @@ -687,8 +691,8 @@
"metadata": {},
"outputs": [],
"source": [
"ult_res = conc_sec.ultimate_bending_capacity(theta=np.pi / 2)\n",
"ult_res.print_results()"
"ult_res = conc_sec.ultimate_bending_capacity()\n",
"ult_res.print_results(units=si_kn_m)"
]
},
{
Expand Down
Loading

0 comments on commit 3cbe091

Please sign in to comment.