Created
December 30, 2021 23:45
-
-
Save connorferster/74c39da3da2710315921d95bc67eb03d to your computer and use it in GitHub Desktop.
sectionproperties: triangle vs meshpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "8ae09f57-8d0d-4e37-bb63-ede5cd4119fe", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"%load_ext autoreload\n", | |
"%autoreload 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "9d52ff71-c26c-4308-81a2-10d461da40dc", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from sectionproperties.pre import sections\n", | |
"from sectionproperties.pre.pre import Material\n", | |
"from sectionproperties.analysis.cross_section import Section" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "6b9303dd-2dbb-42a5-a4d6-ab0b27b208bf", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"rhs = sections.rectangular_hollow_section(\n", | |
" b=150,\n", | |
" d=300,\n", | |
" t=12,\n", | |
" r_out=20,\n", | |
" n_r=12,\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "83673687-98c9-41d0-9a09-5ea10d89bcec", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"sectionproperties.pre.sections.Geometry\n", | |
"object at: 0x15ec6fc7a30\n", | |
"Material: default\n" | |
] | |
}, | |
{ | |
"data": { | |
"image/svg+xml": [ | |
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"174.0\" height=\"300\" viewBox=\"-12.0 -12.0 174.0 324.0\" preserveAspectRatio=\"xMinYMin meet\"><g transform=\"matrix(1,0,0,-1,0,300.0)\"><path fill-rule=\"evenodd\" fill=\"#66cc99\" stroke=\"#555555\" stroke-width=\"2.16\" opacity=\"0.6\" d=\"M 0.0,280.0 L 0.20357116238134765,282.8462967654657 L 0.810140527710054,285.6346511368286 L 1.807360092909633,288.30830026003775 L 3.174929343376377,290.8128163491119 L 4.885008512914837,293.0972146789057 L 6.902785321094299,295.11499148708515 L 9.187183650888048,296.8250706566236 L 11.691699739962274,298.1926399070904 L 14.365348863171405,299.1898594722899 L 17.153703234534298,299.79642883761863 L 20.0,300.0 L 130.0,300.0 L 132.8462967654657,299.79642883761863 L 135.63465113682858,299.1898594722899 L 138.30830026003773,298.1926399070904 L 140.81281634911196,296.8250706566236 L 143.09721467890571,295.11499148708515 L 145.11499148708518,293.0972146789057 L 146.8250706566236,290.8128163491119 L 148.19263990709038,288.30830026003775 L 149.18985947228995,285.6346511368286 L 149.79642883761866,282.8462967654657 L 150.0,280.0 L 150.0,19.999999999999996 L 149.79642883761866,17.153703234534294 L 149.18985947228995,14.365348863171405 L 148.19263990709038,11.69169973996227 L 146.8250706566236,9.187183650888052 L 145.11499148708515,6.902785321094289 L 143.0972146789057,4.885008512914826 L 140.81281634911196,3.1749293433763697 L 138.30830026003773,1.8073600929096294 L 135.63465113682858,0.8101405277100504 L 132.8462967654657,0.2035711623813441 L 130.0,0.0 L 19.999999999999996,0.0 L 17.153703234534294,0.20357116238134765 L 14.365348863171405,0.810140527710054 L 11.691699739962273,1.807360092909633 L 9.187183650888052,3.1749293433763732 L 6.902785321094296,4.885008512914837 L 4.885008512914833,6.902785321094299 L 3.174929343376377,9.187183650888048 L 1.8073600929096294,11.691699739962278 L 0.8101405277100504,14.365348863171413 L 0.2035711623813441,17.1537032345343 L 0.0,20.000000000000004 L 0.0,280.0 z M 12.081428464952538,18.86148129381372 L 12.32405621108402,17.746139545268566 L 12.722944037163852,16.67667989598491 L 13.26997173735055,15.674873460355219 L 13.954003405165933,14.76111412843772 L 14.761114128437718,13.954003405165935 L 15.67487346035522,13.269971737350549 L 16.676679895984908,12.722944037163852 L 17.746139545268562,12.32405621108402 L 18.861481293813718,12.081428464952538 L 20.0,12.0 L 130.0,12.0 L 131.1385187061863,12.081428464952538 L 132.25386045473144,12.32405621108402 L 133.3233201040151,12.722944037163852 L 134.32512653964477,13.269971737350549 L 135.23888587156227,13.954003405165931 L 136.04599659483407,14.761114128437715 L 136.73002826264945,15.67487346035522 L 137.27705596283616,16.676679895984908 L 137.675943788916,17.746139545268562 L 137.91857153504745,18.861481293813718 L 138.0,19.999999999999996 L 138.0,280.0 L 137.91857153504745,281.1385187061863 L 137.675943788916,282.2538604547314 L 137.27705596283616,283.32332010401507 L 136.73002826264945,284.32512653964477 L 136.04599659483407,285.2388858715623 L 135.23888587156227,286.0459965948341 L 134.32512653964477,286.73002826264945 L 133.3233201040151,287.27705596283613 L 132.25386045473144,287.67594378891596 L 131.1385187061863,287.9185715350475 L 130.0,288.0 L 20.0,288.0 L 18.86148129381372,287.9185715350475 L 17.746139545268562,287.67594378891596 L 16.67667989598491,287.27705596283613 L 15.674873460355219,286.73002826264945 L 14.76111412843772,286.0459965948341 L 13.954003405165935,285.2388858715623 L 13.269971737350552,284.32512653964477 L 12.722944037163852,283.32332010401507 L 12.32405621108402,282.2538604547314 L 12.081428464952538,281.1385187061863 L 12.0,280.0 L 12.0,20.0 L 12.081428464952538,18.86148129381372 z\" /></g></svg>" | |
], | |
"text/plain": [ | |
"<sectionproperties.pre.sections.Geometry at 0x15ec6fc7a30>" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"rhs" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0329fc41-0143-4abd-bafb-bfc5f85ae854", | |
"metadata": {}, | |
"source": [ | |
"# Benchmarks" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "910aa70f-ff5d-4f67-9376-903dfe8b720b", | |
"metadata": {}, | |
"source": [ | |
"## `sectionproperties` on `triangle`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "8b6766a4-7bce-4b78-b580-2cec28c3ef19", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"57.7 ms ± 4.82 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%%timeit\n", | |
"mesh_sizes = [20, 10, 5, 2.5, 1]\n", | |
"for mesh_size in mesh_sizes:\n", | |
" rhs.create_mesh([mesh_size])" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "b15c73db-37b6-4fa5-8833-1b22503c6450", | |
"metadata": {}, | |
"source": [ | |
"## `sectionproperties` on `meshpy`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "d203b4f5-3ec2-4070-8d2a-d7a5df46d1b8", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"67.7 ms ± 4.87 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%%timeit\n", | |
"mesh_sizes = [20, 10, 5, 2.5, 1]\n", | |
"for mesh_size in mesh_sizes:\n", | |
" rhs.create_mesh([mesh_size])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "2c5d0d28-f194-4228-8467-4c75850b46ac", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "sectionproperties", | |
"language": "python", | |
"name": "sectionproperties" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.8.12" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment