pyramid shape new parameters

master
sp9unb 2022-10-14 23:26:31 +02:00
rodzic d07902ba1f
commit 63c146fed6
2 zmienionych plików z 132 dodań i 72 usunięć

Wyświetl plik

@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "6ea87a15-f571-4611-8487-5b7556e2ef45",
"metadata": {
"extensions": {
@ -68,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "d075a994-76bb-46f7-bdfb-cc6ef449dc43",
"metadata": {
"extensions": {
@ -107,7 +107,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "2f3b63fd-d5ea-40b6-a2f9-b31c84cfef36",
"metadata": {
"extensions": {
@ -129,7 +129,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8b66cd42e9b34ccfb444e407d016d44a",
"model_id": "9d3ec588fb884df5b8c6e42dad1615a0",
"version_major": 2,
"version_minor": 0
},
@ -137,7 +137,7 @@
"VBox(children=(FloatSlider(value=2.0, description='Width [m]:', layout=Layout(width='500px'), max=5.0, min=0.1…"
]
},
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@ -180,7 +180,7 @@
" color = None\n",
" print( \"Free lift force:\", colored(\"{:.2f} [g]\".format(freeLiftForce),color)) \n",
"\n",
" \n",
"\n",
" geometry=BoxBufferGeometry(\n",
" width=width, \n",
" height=height, \n",
@ -248,7 +248,7 @@
"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",
"tapeDens=widgets.FloatSlider(min=1, max=20, step=1.0, value=2.0, description='Adh. tape density [g/m]:',readout_format='.0f',layout=layout,style=style) \n",
"tapeDens=widgets.FloatSlider(min=0.5, max=10, step=0.5, value=2.0, description='Adh. tape density [g/m]:',readout_format='.1f',layout=layout,style=style) \n",
"payloadWeight=widgets.FloatSlider(min=0.0, max=1000.0, step=1, value=0.0, description='Payload weight [g]:',readout_format='.0f',layout=layout,style=style)\n",
"\n",
"\n",

Wyświetl plik

@ -123,24 +123,27 @@
"\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",
" return a / ( 2 * tan( pi / n )) \n",
"\n",
"# edge length\n",
"def edge_len(r=1.0,h=1.0):\n",
" return sqrt(pow(r,2) + pow(h,2))\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",
"def volume(a=1.0,h1=1.0,h2=1.0,n=3):\n",
" return base_area(a,n) * ( h1 + h2 ) / 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"
"def surface_area(a=1.0,h1=1.0,h2=1.0,n=3):\n",
" return 0.5 * a * n * ( sqrt( pow(h1,2) + pow(inradius(a,n),2)) + sqrt( pow(h2,2) + pow(inradius(a,n),2)) )\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "2f3b63fd-d5ea-40b6-a2f9-b31c84cfef36",
"metadata": {
"extensions": {
@ -161,69 +164,109 @@
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5478a07a77934741aca7e530640992ac",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<style>\n",
" .widget-hbox { margin-top: 20px; }\n",
" </style>"
],
"text/plain": [
"interactive(children=(IntSlider(value=3, description='Segment num:', layout=Layout(width='500px'), max=12, min…"
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e68f02b1e1c548d482d0e63bb21611dc",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(IntSlider(value=3, description='Segment num:', layout=Layout(width='500px'), max=12, min=3, sty…"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def f(num,width,height,airTemp,hotAirTemp,coatDens):\n",
" print(\"\\n\")\n",
"def f(num,width,heightT,heightB,airTemp,hotAirTemp,coatDens,tapeDens,payloadWeight):\n",
"\n",
" out=widgets.Output(layout={'margin': '10px 10px 10px 20px'}) \n",
" with out: \n",
" # Volume\n",
" vol = volume(width,heightB,heightT,num)\n",
" print( \"Volume: {:.2f} [m3]\".format(vol)) \n",
" # Area\n",
" area = surface_area(width,heightB,heightT,num)\n",
" print( \"Area: {:.2f} [m2]\".format(area)) \n",
" # Coating density (from: protective film for painting): 300g / 4x5m = 15g/m2 \n",
" coatingWeight = coatDens * area\n",
" print( \"Coating weight: {:.2f} [g]\".format(coatingWeight)) \n",
" # adhesive tape density : average 2g/m \n",
" tapeLength = num * ( edge_len(outradius(width,num),heightT) + edge_len(outradius(width,num),heightB) )\n",
" tapeWeight = tapeDens * tapeLength\n",
" print( \"Adh.tape length: {:.2f} [m]\".format(tapeLength)) \n",
" print( \"Adh.tape weight: {:.2f} [g]\".format(tapeWeight)) \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 - tapeWeight - payloadWeight\n",
" if freeLiftForce < 0:\n",
" color = 'red'\n",
" else:\n",
" color = None\n",
" print( \"Free lift force:\", colored(\"{:.2f} [g]\".format(freeLiftForce),color)) \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 (protective film for painting): 300g / 4x5m = 15g/m2 \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",
"# coating geometry \n",
" bottomGeometry = CylinderBufferGeometry(\n",
" radiusTop=outradius(width,num), \n",
" radiusBottom=0.0, \n",
" height=height, \n",
" height=heightB, \n",
" radialSegments=num, \n",
" heightSegments=1, \n",
" openEnded=False, \n",
" openEnded=True, \n",
" thetaStart=0, \n",
" thetaLength=2.0*pi),\n",
" material=MeshLambertMaterial(color='gray') \n",
" thetaLength=2.0*pi)\n",
" \n",
" bottomCylinder = Mesh(bottomGeometry,\n",
" material=MeshLambertMaterial(color='#c0c0c0'),\n",
" position=[0,0,0] \n",
" )\n",
" \n",
" zTop = ( heightB + heightT ) / 2.0\n",
" topGeometry = CylinderBufferGeometry(\n",
" radiusTop=0.0, \n",
" radiusBottom=outradius(width,num), \n",
" height=heightT, \n",
" radialSegments=num, \n",
" heightSegments=1, \n",
" openEnded=True, \n",
" thetaStart=0, \n",
" thetaLength=2.0*pi)\n",
" \n",
" topCylinder = Mesh(topGeometry,\n",
" material=MeshLambertMaterial(color='#c0c0c0'),\n",
" position=[0,zTop,0] \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",
" c = PerspectiveCamera(position=[2, 2, 6], up=[0, 1, 0], children=[keyLight])\n",
"\n",
" scene = Scene(children=[cylinder, c, AmbientLight(color='#777777')], background=None)\n",
" scene = Scene(children=[bottomCylinder,topCylinder, c, AmbientLight(color='#777777')], background=None)\n",
"\n",
" renderer = Renderer(camera=c,\n",
" scene=scene,\n",
@ -231,29 +274,46 @@
" clearOpacity=1.0,\n",
" clearColor='#62a0ea',\n",
" controls=[OrbitControls(controlling=c)])\n",
" return renderer\n",
" display(widgets.HBox([renderer, out])) \n",
"\n",
"#display(HTML('''<style>\n",
"# .widget-label { min-width: 25ex !important; }\n",
"#</style>'''))\n",
"\n",
"\n",
"display(HTML('''<style>\n",
" .widget-hbox { margin-top: 20px; }\n",
" </style>'''))\n",
"\n",
"layout=Layout(width='500px')\n",
"style = {'description_width': 'initial'}\n",
" \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=3.0, description='Segment width [m]:',readout_format='.1f',layout=layout,style=style) \n",
"heightT=widgets.FloatSlider(min=0.1, max=5.0, step=0.1, value=1.0, description='Height top [m]:',readout_format='.1f',layout=layout,style=style) \n",
"heightB=widgets.FloatSlider(min=0.1, max=5.0, step=0.1, value=2.0, description='Height bottom [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",
"tapeDens=widgets.FloatSlider(min=0.5, max=10, step=0.5, value=2.0, description='Adh. tape density [g/m]:',readout_format='.1f',layout=layout,style=style)\n",
"payloadWeight=widgets.FloatSlider(min=0.0, max=1000.0, step=1, value=0.0, description='Payload weight [g]:',readout_format='.0f',layout=layout,style=style)\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=3.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=3.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"
"w = widgets.interactive_output(f, { 'num' : num,\n",
" 'width' : width,\n",
" 'heightT' : heightT,\n",
" 'heightB' : heightB,\n",
" 'airTemp' : airTemp,\n",
" 'hotAirTemp' : hotAirTemp,\n",
" 'coatDens' : coatDens,\n",
" 'tapeDens' : tapeDens,\n",
" 'payloadWeight' : payloadWeight\n",
" }\n",
" )\n",
"\n",
"widgets.VBox([num, width, heightT, heightB, airTemp, hotAirTemp, coatDens,tapeDens,payloadWeight, w])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "27db67a1-c298-4f36-a90f-ad8cd6f79826",
"id": "0c7663e8-418e-47a9-9c2b-33d787f109ff",
"metadata": {},
"outputs": [],
"source": []