Skip to content

Commit 6c30c8d

Browse files
Implement UnitDisplay, add to tests and plots
1 parent 8606dc5 commit 6c30c8d

File tree

12 files changed

+979
-406
lines changed

12 files changed

+979
-406
lines changed

docs/examples/area_properties.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
"name": "python",
174174
"nbconvert_exporter": "python",
175175
"pygments_lexer": "ipython3",
176-
"version": "3.11.4"
176+
"version": "3.12.7"
177177
}
178178
},
179179
"nbformat": 4,

docs/examples/biaxial_bending.ipynb

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
" SteelElasticPlastic,\n",
3636
" add_bar_rectangular_array,\n",
3737
")\n",
38+
"from concreteproperties.post import si_kn_m\n",
3839
"from concreteproperties.results import BiaxialBendingResults"
3940
]
4041
},
@@ -149,13 +150,7 @@
149150
"metadata": {},
150151
"outputs": [],
151152
"source": [
152-
"bb_res.plot_diagram(\n",
153-
" eng=True,\n",
154-
" n_scale=1e-3,\n",
155-
" m_scale=1e-6,\n",
156-
" n_unit=\"kN\",\n",
157-
" m_unit=\"kN.m\",\n",
158-
")"
153+
"bb_res.plot_diagram(eng=True, units=si_kn_m)"
159154
]
160155
},
161156
{
@@ -174,13 +169,7 @@
174169
"outputs": [],
175170
"source": [
176171
"bb_res = conc_sec.biaxial_bending_diagram(n=1000e3, n_points=24, progress_bar=False)\n",
177-
"bb_res.plot_diagram(\n",
178-
" eng=True,\n",
179-
" n_scale=1e-3,\n",
180-
" m_scale=1e-6,\n",
181-
" n_unit=\"kN\",\n",
182-
" m_unit=\"kN.m\",\n",
183-
")"
172+
"bb_res.plot_diagram(eng=True, units=si_kn_m)"
184173
]
185174
},
186175
{
@@ -247,10 +236,7 @@
247236
"BiaxialBendingResults.plot_multiple_diagrams_3d(\n",
248237
" biaxial_results,\n",
249238
" eng=True,\n",
250-
" n_scale=1e-3,\n",
251-
" m_scale=1e-6,\n",
252-
" n_unit=\"kN\",\n",
253-
" m_unit=\"kN.m\",\n",
239+
" units=si_kn_m,\n",
254240
")"
255241
]
256242
},
@@ -273,10 +259,7 @@
273259
" biaxial_results,\n",
274260
" fmt=\"o-\",\n",
275261
" eng=True,\n",
276-
" n_scale=1e-3,\n",
277-
" m_scale=1e-6,\n",
278-
" n_unit=\"kN\",\n",
279-
" m_unit=\"kN.m\",\n",
262+
" units=si_kn_m,\n",
280263
")"
281264
]
282265
},
@@ -301,18 +284,9 @@
301284
" biaxial_results[::2],\n",
302285
" fmt=\"-\",\n",
303286
" labels=labels,\n",
304-
" m_scale=1e-6,\n",
305-
" m_unit=\"kN.m\",\n",
287+
" units=si_kn_m,\n",
306288
")"
307289
]
308-
},
309-
{
310-
"cell_type": "code",
311-
"execution_count": null,
312-
"id": "23",
313-
"metadata": {},
314-
"outputs": [],
315-
"source": []
316290
}
317291
],
318292
"metadata": {

docs/examples/composite_section.ipynb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
" SteelElasticPlastic,\n",
4343
" add_bar_circular_array,\n",
4444
" add_bar_rectangular_array,\n",
45-
")"
45+
")\n",
46+
"from concreteproperties.post import si_kn_m, si_n_mm"
4647
]
4748
},
4849
{
@@ -170,7 +171,7 @@
170171
"outputs": [],
171172
"source": [
172173
"el_stress = conc_sec.calculate_uncracked_stress(m_x=100e6)\n",
173-
"el_stress.plot_stress()"
174+
"el_stress.plot_stress(units=si_n_mm)"
174175
]
175176
},
176177
{
@@ -191,7 +192,7 @@
191192
"source": [
192193
"cr_res = conc_sec.calculate_cracked_properties()\n",
193194
"cr_stress = conc_sec.calculate_cracked_stress(cracked_results=cr_res, m=500e6)\n",
194-
"cr_stress.plot_stress()"
195+
"cr_stress.plot_stress(units=si_n_mm)"
195196
]
196197
},
197198
{
@@ -220,7 +221,7 @@
220221
"metadata": {},
221222
"outputs": [],
222223
"source": [
223-
"mk_res.plot_results(fmt=\"kx-\")"
224+
"mk_res.plot_results(fmt=\"kx-\", eng=True, units=si_kn_m)"
224225
]
225226
},
226227
{
@@ -237,7 +238,7 @@
237238
"serv_stress = conc_sec.calculate_service_stress(\n",
238239
" moment_curvature_results=mk_res, m=None, kappa=2e-5\n",
239240
")\n",
240-
"serv_stress.plot_stress()"
241+
"serv_stress.plot_stress(units=si_n_mm)"
241242
]
242243
},
243244
{
@@ -258,8 +259,8 @@
258259
"source": [
259260
"ult_res_x = conc_sec.ultimate_bending_capacity()\n",
260261
"ult_res_y = conc_sec.ultimate_bending_capacity(theta=np.pi / 2)\n",
261-
"ult_res_x.print_results()\n",
262-
"ult_res_y.print_results()"
262+
"ult_res_x.print_results(units=si_kn_m)\n",
263+
"ult_res_y.print_results(units=si_kn_m)"
263264
]
264265
},
265266
{
@@ -270,7 +271,7 @@
270271
"outputs": [],
271272
"source": [
272273
"mi_res = conc_sec.moment_interaction_diagram(progress_bar=False)\n",
273-
"mi_res.plot_diagram()"
274+
"mi_res.plot_diagram(units=si_kn_m)"
274275
]
275276
},
276277
{
@@ -281,7 +282,7 @@
281282
"outputs": [],
282283
"source": [
283284
"bb_res = conc_sec.biaxial_bending_diagram(n_points=24, progress_bar=False)\n",
284-
"bb_res.plot_diagram()"
285+
"bb_res.plot_diagram(units=si_kn_m)"
285286
]
286287
},
287288
{
@@ -293,8 +294,8 @@
293294
"source": [
294295
"ult_stress_x = conc_sec.calculate_ultimate_stress(ult_res_x)\n",
295296
"ult_stress_y = conc_sec.calculate_ultimate_stress(ult_res_y)\n",
296-
"ult_stress_x.plot_stress()\n",
297-
"ult_stress_y.plot_stress()"
297+
"ult_stress_x.plot_stress(units=si_n_mm)\n",
298+
"ult_stress_y.plot_stress(units=si_n_mm)"
298299
]
299300
},
300301
{
@@ -400,8 +401,8 @@
400401
"source": [
401402
"el_stress_comp = conc_sec_comp.calculate_uncracked_stress(m_x=10e6)\n",
402403
"el_stress_conc = conc_sec_conc.calculate_uncracked_stress(m_x=10e6)\n",
403-
"el_stress_comp.plot_stress()\n",
404-
"el_stress_conc.plot_stress()"
404+
"el_stress_comp.plot_stress(units=si_n_mm)\n",
405+
"el_stress_conc.plot_stress(units=si_n_mm)"
405406
]
406407
},
407408
{
@@ -428,8 +429,8 @@
428429
"cr_stress_conc = conc_sec_conc.calculate_cracked_stress(\n",
429430
" cracked_results=cr_res_conc, m=50e6\n",
430431
")\n",
431-
"cr_stress_comp.plot_stress()\n",
432-
"cr_stress_conc.plot_stress()"
432+
"cr_stress_comp.plot_stress(units=si_n_mm)\n",
433+
"cr_stress_conc.plot_stress(units=si_n_mm)"
433434
]
434435
},
435436
{
@@ -467,6 +468,8 @@
467468
" moment_curvature_results=[mk_res_comp, mk_res_conc],\n",
468469
" labels=[\"Composite\", \"Concrete\"],\n",
469470
" fmt=\"x-\",\n",
471+
" eng=True,\n",
472+
" units=si_kn_m,\n",
470473
")"
471474
]
472475
},
@@ -500,6 +503,7 @@
500503
" moment_interaction_results=[mi_res_comp, mi_res_conc],\n",
501504
" labels=[\"Composite\", \"Concrete\"],\n",
502505
" fmt=\"x-\",\n",
506+
" units=si_kn_m,\n",
503507
")"
504508
]
505509
},
@@ -632,7 +636,7 @@
632636
"metadata": {},
633637
"outputs": [],
634638
"source": [
635-
"mk_res.plot_results()"
639+
"mk_res.plot_results(eng=True, units=si_kn_m)"
636640
]
637641
},
638642
{
@@ -666,9 +670,9 @@
666670
"metadata": {},
667671
"outputs": [],
668672
"source": [
669-
"el_stress.plot_stress()\n",
670-
"yield_stress.plot_stress()\n",
671-
"ult_stress.plot_stress()"
673+
"el_stress.plot_stress(units=si_n_mm)\n",
674+
"yield_stress.plot_stress(units=si_n_mm)\n",
675+
"ult_stress.plot_stress(units=si_n_mm)"
672676
]
673677
},
674678
{
@@ -687,8 +691,8 @@
687691
"metadata": {},
688692
"outputs": [],
689693
"source": [
690-
"ult_res = conc_sec.ultimate_bending_capacity(theta=np.pi / 2)\n",
691-
"ult_res.print_results()"
694+
"ult_res = conc_sec.ultimate_bending_capacity()\n",
695+
"ult_res.print_results(units=si_kn_m)"
692696
]
693697
},
694698
{

docs/examples/cracked_properties.ipynb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@
153153
"metadata": {},
154154
"outputs": [],
155155
"source": [
156-
"cracked_res_sag.print_results(radians=False)\n",
157-
"cracked_res_hog.print_results(radians=False)"
156+
"cracked_res_sag.print_results()\n",
157+
"cracked_res_hog.print_results()"
158158
]
159159
},
160160
{
@@ -174,11 +174,15 @@
174174
"metadata": {},
175175
"outputs": [],
176176
"source": [
177+
"from concreteproperties.post import si_kn_m, si_n_mm\n",
178+
"\n",
179+
"si_n_mm.radians = False # show degrees\n",
180+
"\n",
177181
"cracked_res_sag.calculate_transformed_properties(elastic_modulus=32.8e3)\n",
178182
"cracked_res_hog.calculate_transformed_properties(elastic_modulus=32.8e3)\n",
179183
"\n",
180-
"cracked_res_sag.print_results(radians=False)\n",
181-
"cracked_res_hog.print_results(radians=False)"
184+
"cracked_res_sag.print_results(units=si_kn_m)\n",
185+
"cracked_res_hog.print_results(units=si_n_mm)"
182186
]
183187
},
184188
{

docs/examples/moment_curvature.ipynb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
" SteelBar,\n",
3434
" add_bar_rectangular_array,\n",
3535
")\n",
36+
"from concreteproperties.post import si_kn_m\n",
3637
"from concreteproperties.results import MomentCurvatureResults"
3738
]
3839
},
@@ -260,8 +261,7 @@
260261
" labels=labels,\n",
261262
" fmt=\"-\",\n",
262263
" eng=True,\n",
263-
" m_scale=1e-6,\n",
264-
" m_unit=\"kN.m\",\n",
264+
" units=si_kn_m,\n",
265265
")"
266266
]
267267
},
@@ -303,8 +303,7 @@
303303
" labels=labels[1:],\n",
304304
" fmt=\"-\",\n",
305305
" eng=True,\n",
306-
" m_scale=1e-6,\n",
307-
" m_unit=\"kN.m\",\n",
306+
" units=si_kn_m,\n",
308307
")"
309308
]
310309
},
@@ -681,8 +680,7 @@
681680
" labels=[\"$N=0$ kN\", \"$N=0.2f'cA_g$\", \"$N=-1000$ kN\"],\n",
682681
" fmt=\"-\",\n",
683682
" eng=True,\n",
684-
" m_scale=1e-6,\n",
685-
" m_unit=\"kN.m\",\n",
683+
" units=si_kn_m,\n",
686684
")"
687685
]
688686
},

docs/examples/moment_interaction.ipynb

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
" SteelBar,\n",
3535
" SteelElasticPlastic,\n",
3636
")\n",
37+
"from concreteproperties.post import si_kn_m, si_n_mm\n",
3738
"from concreteproperties.results import MomentInteractionResults"
3839
]
3940
},
@@ -148,7 +149,7 @@
148149
"metadata": {},
149150
"outputs": [],
150151
"source": [
151-
"mi_res.plot_diagram(eng=True, n_unit=\"N\", m_unit=\"N.mm\")"
152+
"mi_res.plot_diagram(eng=True, units=si_n_mm)"
152153
]
153154
},
154155
{
@@ -167,13 +168,7 @@
167168
"outputs": [],
168169
"source": [
169170
"mi_res = conc_sec.moment_interaction_diagram(theta=np.pi / 2, progress_bar=False)\n",
170-
"mi_res.plot_diagram(\n",
171-
" moment=\"m_y\",\n",
172-
" n_scale=1e-3,\n",
173-
" m_scale=1e-6,\n",
174-
" n_unit=\"kN\",\n",
175-
" m_unit=\"kN.m\",\n",
176-
")"
171+
"mi_res.plot_diagram(moment=\"m_y\", units=si_kn_m)"
177172
]
178173
},
179174
{
@@ -231,10 +226,7 @@
231226
" moment_interaction_results=mi_results,\n",
232227
" labels=labels,\n",
233228
" fmt=\"-\",\n",
234-
" n_scale=1e-3,\n",
235-
" m_scale=1e-6,\n",
236-
" n_unit=\"kN\",\n",
237-
" m_unit=\"kN.m\",\n",
229+
" units=si_kn_m,\n",
238230
")"
239231
]
240232
},
@@ -278,8 +270,7 @@
278270
" labels=[\"Positive\", \"Negative\"],\n",
279271
" fmt=\"-\",\n",
280272
" eng=True,\n",
281-
" n_unit=\"N\",\n",
282-
" m_unit=\"N.mm\",\n",
273+
" units=si_n_mm,\n",
283274
")"
284275
]
285276
},
@@ -399,10 +390,7 @@
399390
" fmt=\"-kx\",\n",
400391
" labels=True,\n",
401392
" label_offset=True,\n",
402-
" n_scale=1e-3,\n",
403-
" m_scale=1e-6,\n",
404-
" n_unit=\"kN\",\n",
405-
" m_unit=\"kN.m\",\n",
393+
" units=si_kn_m,\n",
406394
" render=False,\n",
407395
")\n",
408396
"\n",

0 commit comments

Comments
 (0)