Skip to content

Commit

Permalink
Implement UnitDisplay, add to tests and plots
Browse files Browse the repository at this point in the history
  • Loading branch information
robbievanleeuwen committed Nov 7, 2024
1 parent 8606dc5 commit 6c30c8d
Show file tree
Hide file tree
Showing 12 changed files with 979 additions and 406 deletions.
2 changes: 1 addition & 1 deletion docs/examples/area_properties.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
38 changes: 6 additions & 32 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,13 +150,7 @@
"metadata": {},
"outputs": [],
"source": [
"bb_res.plot_diagram(\n",
" eng=True,\n",
" n_scale=1e-3,\n",
" m_scale=1e-6,\n",
" n_unit=\"kN\",\n",
" m_unit=\"kN.m\",\n",
")"
"bb_res.plot_diagram(eng=True, units=si_kn_m)"
]
},
{
Expand All @@ -174,13 +169,7 @@
"outputs": [],
"source": [
"bb_res = conc_sec.biaxial_bending_diagram(n=1000e3, n_points=24, progress_bar=False)\n",
"bb_res.plot_diagram(\n",
" eng=True,\n",
" n_scale=1e-3,\n",
" m_scale=1e-6,\n",
" n_unit=\"kN\",\n",
" m_unit=\"kN.m\",\n",
")"
"bb_res.plot_diagram(eng=True, units=si_kn_m)"
]
},
{
Expand Down Expand Up @@ -247,10 +236,7 @@
"BiaxialBendingResults.plot_multiple_diagrams_3d(\n",
" biaxial_results,\n",
" eng=True,\n",
" n_scale=1e-3,\n",
" m_scale=1e-6,\n",
" n_unit=\"kN\",\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand All @@ -273,10 +259,7 @@
" biaxial_results,\n",
" fmt=\"o-\",\n",
" eng=True,\n",
" n_scale=1e-3,\n",
" m_scale=1e-6,\n",
" n_unit=\"kN\",\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand All @@ -301,18 +284,9 @@
" biaxial_results[::2],\n",
" fmt=\"-\",\n",
" labels=labels,\n",
" m_scale=1e-6,\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "23",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
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
12 changes: 8 additions & 4 deletions docs/examples/cracked_properties.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@
"metadata": {},
"outputs": [],
"source": [
"cracked_res_sag.print_results(radians=False)\n",
"cracked_res_hog.print_results(radians=False)"
"cracked_res_sag.print_results()\n",
"cracked_res_hog.print_results()"
]
},
{
Expand All @@ -174,11 +174,15 @@
"metadata": {},
"outputs": [],
"source": [
"from concreteproperties.post import si_kn_m, si_n_mm\n",
"\n",
"si_n_mm.radians = False # show degrees\n",
"\n",
"cracked_res_sag.calculate_transformed_properties(elastic_modulus=32.8e3)\n",
"cracked_res_hog.calculate_transformed_properties(elastic_modulus=32.8e3)\n",
"\n",
"cracked_res_sag.print_results(radians=False)\n",
"cracked_res_hog.print_results(radians=False)"
"cracked_res_sag.print_results(units=si_kn_m)\n",
"cracked_res_hog.print_results(units=si_n_mm)"
]
},
{
Expand Down
10 changes: 4 additions & 6 deletions docs/examples/moment_curvature.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
" SteelBar,\n",
" add_bar_rectangular_array,\n",
")\n",
"from concreteproperties.post import si_kn_m\n",
"from concreteproperties.results import MomentCurvatureResults"
]
},
Expand Down Expand Up @@ -260,8 +261,7 @@
" labels=labels,\n",
" fmt=\"-\",\n",
" eng=True,\n",
" m_scale=1e-6,\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down Expand Up @@ -303,8 +303,7 @@
" labels=labels[1:],\n",
" fmt=\"-\",\n",
" eng=True,\n",
" m_scale=1e-6,\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down Expand Up @@ -681,8 +680,7 @@
" labels=[\"$N=0$ kN\", \"$N=0.2f'cA_g$\", \"$N=-1000$ kN\"],\n",
" fmt=\"-\",\n",
" eng=True,\n",
" m_scale=1e-6,\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down
24 changes: 6 additions & 18 deletions docs/examples/moment_interaction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
" SteelBar,\n",
" SteelElasticPlastic,\n",
")\n",
"from concreteproperties.post import si_kn_m, si_n_mm\n",
"from concreteproperties.results import MomentInteractionResults"
]
},
Expand Down Expand Up @@ -148,7 +149,7 @@
"metadata": {},
"outputs": [],
"source": [
"mi_res.plot_diagram(eng=True, n_unit=\"N\", m_unit=\"N.mm\")"
"mi_res.plot_diagram(eng=True, units=si_n_mm)"
]
},
{
Expand All @@ -167,13 +168,7 @@
"outputs": [],
"source": [
"mi_res = conc_sec.moment_interaction_diagram(theta=np.pi / 2, progress_bar=False)\n",
"mi_res.plot_diagram(\n",
" moment=\"m_y\",\n",
" n_scale=1e-3,\n",
" m_scale=1e-6,\n",
" n_unit=\"kN\",\n",
" m_unit=\"kN.m\",\n",
")"
"mi_res.plot_diagram(moment=\"m_y\", units=si_kn_m)"
]
},
{
Expand Down Expand Up @@ -231,10 +226,7 @@
" moment_interaction_results=mi_results,\n",
" labels=labels,\n",
" fmt=\"-\",\n",
" n_scale=1e-3,\n",
" m_scale=1e-6,\n",
" n_unit=\"kN\",\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
")"
]
},
Expand Down Expand Up @@ -278,8 +270,7 @@
" labels=[\"Positive\", \"Negative\"],\n",
" fmt=\"-\",\n",
" eng=True,\n",
" n_unit=\"N\",\n",
" m_unit=\"N.mm\",\n",
" units=si_n_mm,\n",
")"
]
},
Expand Down Expand Up @@ -399,10 +390,7 @@
" fmt=\"-kx\",\n",
" labels=True,\n",
" label_offset=True,\n",
" n_scale=1e-3,\n",
" m_scale=1e-6,\n",
" n_unit=\"kN\",\n",
" m_unit=\"kN.m\",\n",
" units=si_kn_m,\n",
" render=False,\n",
")\n",
"\n",
Expand Down
Loading

0 comments on commit 6c30c8d

Please sign in to comment.