add pyramid shape

master
SP9UNB 2022-10-10 10:58:22 +02:00
rodzic 271eaaa3a0
commit 9d4984968d
2 zmienionych plików z 304 dodań i 71 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "25ff728c-ed95-4d35-ade5-7254bae85240",
"id": "33295fc3-e98b-4c17-bca0-366c3a80c9c8",
"metadata": {
"extensions": {
"jupyter_dashboards": {
@ -17,7 +17,8 @@
}
}
}
}
},
"tags": []
},
"source": [
"## Hot air balloon - lift calculator\n",
@ -103,8 +104,8 @@
},
{
"cell_type": "code",
"execution_count": 98,
"id": "9a4bbc2b-810d-40ef-8189-9efb64b6df6b",
"execution_count": null,
"id": "2f3b63fd-d5ea-40b6-a2f9-b31c84cfef36",
"metadata": {
"extensions": {
"jupyter_dashboards": {
@ -119,25 +120,9 @@
}
}
}
},
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1501ab1298aa43a4b5d45c8f4fd3a186",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=2.0, description='Width [m]:', layout=Layout(width='500px'), max=5.0, …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
},
"outputs": [],
"source": [
"def f(width,height,depth,airTemp,hotAirTemp,coatDens):\n",
" print(\"\\n\")\n",
@ -210,55 +195,6 @@
" coatDens=widgets.FloatSlider(min=1, max=50, step=1.0, value=15.0, description='Coating density [g/m2]:',readout_format='.0f',layout=layout,style=style) \n",
" );\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "74ed5886-bf61-4e41-8482-bf8ba34faba6",
"metadata": {
"extensions": {
"jupyter_dashboards": {
"activeView": "grid_default",
"views": {
"grid_default": {
"col": null,
"height": 2,
"hidden": true,
"row": null,
"width": 2
}
}
}
},
"tags": []
},
"outputs": [],
"source": [
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2f3b63fd-d5ea-40b6-a2f9-b31c84cfef36",
"metadata": {
"extensions": {
"jupyter_dashboards": {
"activeView": "grid_default",
"views": {
"grid_default": {
"col": null,
"height": 2,
"hidden": true,
"row": null,
"width": 2
}
}
}
}
},
"outputs": [],
"source": []
}
],
"metadata": {

Wyświetl plik

@ -0,0 +1,297 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "c6b2e4d0-bf43-4a8a-a8e7-4fa081d61317",
"metadata": {
"extensions": {
"jupyter_dashboards": {
"activeView": "grid_default",
"views": {
"grid_default": {
"col": 0,
"height": 1,
"hidden": false,
"row": 0,
"width": 1
}
}
}
},
"tags": []
},
"source": [
"## Hot air balloon - lift calculator\n",
"### Inverted pyramid shape\n"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "6ea87a15-f571-4611-8487-5b7556e2ef45",
"metadata": {
"extensions": {
"jupyter_dashboards": {
"activeView": "grid_default",
"views": {
"grid_default": {
"col": null,
"height": 2,
"hidden": true,
"row": null,
"width": 2
}
}
}
}
},
"outputs": [],
"source": [
"# https://pythreejs.readthedocs.io\n",
"from pythreejs import *\n",
"from IPython.display import HTML,display\n",
"from math import pi\n",
"\n",
"# https://ipywidgets.readthedocs.io\n",
"import ipywidgets as widgets\n",
"from ipywidgets import Layout\n",
"\n",
"# https://pypi.org/project/termcolor/\n",
"from termcolor import colored\n",
"\n",
"#from scipy.interpolate import interp1d\n",
"#import numpy as np\n",
"\n",
"#math\n",
"from math import sin, tan, sqrt"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "d075a994-76bb-46f7-bdfb-cc6ef449dc43",
"metadata": {
"extensions": {
"jupyter_dashboards": {
"activeView": "grid_default",
"views": {
"grid_default": {
"col": null,
"height": 2,
"hidden": true,
"row": null,
"width": 2
}
}
}
}
},
"outputs": [],
"source": [
"# air density–temperature relationship at 1 atm or 101.325 kPa\n",
"# https://en.wikipedia.org/wiki/Density_of_air\n",
"# https://www.engineersedge.com/calculators/air-density.htm\n",
"# temp in st.C density in g/m3\n",
"\n",
"#temp = [-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35]\n",
"#dens = [1422.4,1394.3,1367.3,1341.3,1316.3,1292.2,1269.0,1246.6,1225.0,1204.1,1183.9,1164.4,1145.5]\n",
"#dens_temp_func = interp1d(temp, dens)\n",
"\n",
"\n",
"def airDensity(temp=0.0):\n",
" tempK = temp + 273.0 # absolute temperature [K]\n",
" p = 101325.0 # pressure [Pa]\n",
" rSpec = 287.0500676 # specific gas constant for dry air [J⋅kg1⋅K1]\n",
" return 1000.0 * p / ( rSpec * tempK )"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "229c0a36-bf1f-4c07-884c-f3522d5eaae5",
"metadata": {},
"outputs": [],
"source": [
"# math: https://pl.wikipedia.org/wiki/Wielok%C4%85t_foremny\n",
"\n",
"# radius of the circle described on the polygon\n",
"def outradius(a=1.0,n=3):\n",
" return a / ( 2 * sin( pi / n ))\n",
"\n",
"# radius of the circle inscribed in the polygon\n",
"def inradius(a=1.0,n=3):\n",
" return a / ( 2 * tan( pi / n )) \n",
"\n",
"#pyramid area/volume\n",
"def base_area(a=1.0,n=3):\n",
" return 0.5 * n * pow(outradius(a,n),2) * sin( 2 * pi / n)\n",
"\n",
"def volume(a=1.0,h=1.0,n=3):\n",
" return base_area(a,n) * h / 3\n",
" \n",
"def surface_area(a=1.0,h=1.0,n=3):\n",
" return base_area(a,n) + 0.5 * a * n * sqrt( pow(h,2) + pow(inradius(a,n),2))\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "2f3b63fd-d5ea-40b6-a2f9-b31c84cfef36",
"metadata": {
"extensions": {
"jupyter_dashboards": {
"activeView": "grid_default",
"views": {
"grid_default": {
"col": null,
"height": 2,
"hidden": true,
"row": null,
"width": 2
}
}
}
}
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "60a4721d0e034caabff5f13695af2a7b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=3, description='Segment num:', layout=Layout(width='500px'), max=12, min…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"def f(num,width,height,airTemp,hotAirTemp,coatDens):\n",
" print(\"\\n\")\n",
" \n",
"# Volume\n",
" vol = volume(width,height,num)\n",
" print( \"Volume: {:.2f} [m3]\".format(vol)) \n",
"# Area\n",
" area = surface_area(width,height,num)\n",
" print( \"Area: {:.2f} [m2]\".format(area)) \n",
"# Coating density 300g / 4x5m = 15g/m2\n",
"# coatingDensity = 15.0\n",
"# print( \"Coating density: {:.2f} [g/m2]\".format(coatingDensity)) \n",
" coatingWeight = coatDens * area\n",
" print( \"Coating weight: {:.2f} [g]\".format(coatingWeight)) \n",
"# Lift per volume g/m3 \n",
"# airDens = dens_temp_func( airTemp )\n",
"# hotAirDens = dens_temp_func( hotAirTemp ) \n",
" airDens = airDensity( airTemp )\n",
" hotAirDens = airDensity( hotAirTemp ) \n",
" lift = airDens - hotAirDens\n",
" print( \"Lift: {:.2f} [g/m3]\".format(lift)) \n",
"# Total lift force lift * volume \n",
" totalLiftForce = lift * vol\n",
" print( \"Total lift force: {:.2f} [g]\".format(totalLiftForce)) \n",
"# Free lift force totalLiftForce - coatingWeight \n",
" freeLiftForce = totalLiftForce - coatingWeight\n",
" if freeLiftForce < 0:\n",
" color = 'red'\n",
" else:\n",
" color = None\n",
" print( \"Free lift force:\", colored(\"{:.2f} [g]\".format(freeLiftForce),color)) \n",
" print(\"\\n\")\n",
" \n",
" \n",
" cylinder = Mesh(geometry=CylinderBufferGeometry(\n",
" radiusTop=outradius(width,num), \n",
" radiusBottom=0.0, \n",
" height=height, \n",
" radialSegments=num, \n",
" heightSegments=1, \n",
" openEnded=False, \n",
" thetaStart=0, \n",
" thetaLength=2.0*pi),\n",
" material=MeshLambertMaterial(color='gray') \n",
" )\n",
" \n",
" keyLight = DirectionalLight(color='white', position=[3, 5, 1], intensity=0.5)\n",
"\n",
" c = PerspectiveCamera(position=[2, 2, 5], up=[0, 1, 0], children=[keyLight])\n",
"\n",
" scene = Scene(children=[cylinder, c, AmbientLight(color='#777777')], background=None)\n",
"\n",
" renderer = Renderer(camera=c,\n",
" scene=scene,\n",
" alpha=True,\n",
" clearOpacity=1.0,\n",
" clearColor='#62a0ea',\n",
" controls=[OrbitControls(controlling=c)])\n",
" return renderer\n",
"\n",
"#display(HTML('''<style>\n",
"# .widget-label { min-width: 25ex !important; }\n",
"#</style>'''))\n",
"\n",
"layout=Layout(width='500px')\n",
"style = {'description_width': 'initial'}\n",
" \n",
"widgets.interact(f, \n",
" num=widgets.IntSlider(min=3, max=12, step=1, value=3, description='Segment num:',layout=layout,style=style), \n",
" width=widgets.FloatSlider(min=0.1, max=5.0, step=0.1, value=2.0, description='Segment width [m]:',readout_format='.1f',layout=layout,style=style), \n",
" height=widgets.FloatSlider(min=0.1, max=5.0, step=0.1, value=2.0, description='Height [m]:',readout_format='.1f',layout=layout,style=style), \n",
" airTemp=widgets.FloatSlider(min=-40, max=35, step=1.0, value=10.0, description='Air temp.[°C]:',readout_format='.0f',layout=layout,style=style), \n",
" hotAirTemp=widgets.FloatSlider(min=-40, max=55, step=1.0, value=35.0, description='Hot air temp.[°C]:',readout_format='.0f',layout=layout,style=style),\n",
" coatDens=widgets.FloatSlider(min=1, max=50, step=1.0, value=15.0, description='Coating density [g/m2]:',readout_format='.0f',layout=layout,style=style) \n",
" );\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "27db67a1-c298-4f36-a90f-ad8cd6f79826",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"extensions": {
"jupyter_dashboards": {
"activeView": "grid_default",
"version": 1,
"views": {
"grid_default": {
"cellMargin": 2,
"defaultCellHeight": 60,
"maxColumns": 12,
"name": "grid",
"type": "grid"
}
}
}
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"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.9.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}