{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This is a widget-heavy notebook that uses the methods from the airfoil designer to repanel an existing airfoil that has been loaded from a text file.\n", "There is no aerodynamic analysis done here." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Plot nice and large\n", "%matplotlib inline\n", "%config InlineBackend.figure_format = 'svg'\n", "import numpy as np\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", "import viiflowtools.vf_tools as vft\n", "\n", "# Import airfoil designer modules\n", "from af_bezier import * \n", "from af_ui import * \n", "from af_pac import * \n", "from af_analysis import * " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b00dbdd0c4f346c6987ac51f63a7d8dd", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HTML(value='Discretization Parameter'), HBox(children=(VBox(children=(HTML(value='Wei…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e5c5adf701b847beb65b73e1d1bd2e3d", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Import some widgets\n", "import ipywidgets as widgets\n", "from ipywidgets import interactive, interact\n", "from ipywidgets import FloatSlider\n", "\n", "matplotlib.rcParams['figure.figsize'] = [12, 6] # Make plots bigger than default\n", "\n", "# Default to read. After running this cell this is loaded.\n", "N0 = 50\n", "ArcPoints = vft.read_selig('FX77W153.dat')\n", "\n", "# \"Global\" points, for later use\n", "X=ArcPoints\n", "\n", "# Widget function\n", "def manipulateAirfoil(N,LEFAC,TEFAC,KAPFAC,REFTOPX0,REFTOPX1,REFBOTX0,REFBOTX1,REFVAL):\n", " global X\n", " X = vft.repanel(ArcPoints,int(N),LEFAC,TEFAC,KAPFAC,\n", " [REFTOPX0,REFTOPX1,REFBOTX0,REFBOTX1],REFVAL)\n", " plt.plot(X[0,:],X[1,:],\"+\",color=\"#AAAAAA\")\n", " plt.plot(X[0,:],X[1,:],\"-k\")\n", " plt.axis('equal')\n", "\n", " \n", "# Set up the sliders\n", "paramdisc = widgets.HBox([widgets.VBox([widgets.HTML(value=\"Weights\"),\n", " N,KAPFAC,LEFAC,TEFAC,REFVAL]),\n", " widgets.VBox([widgets.HTML(value=\"Refinement\"),\n", " REFTOPX0,REFTOPX1,REFBOTX0,REFBOTX1])])\n", "\n", "ui = widgets.VBox([widgets.HTML(value=\"Discretization Parameter\"),paramdisc])\n", "\n", "\n", "# Again, very elegant.\n", "out=widgets.interactive_output(manipulateAirfoil, {'N':N,'LEFAC':LEFAC,'TEFAC':TEFAC,'KAPFAC':KAPFAC,\n", " 'REFTOPX0':REFTOPX0,'REFTOPX1':REFTOPX1,\n", " 'REFBOTX0':REFBOTX0,'REFBOTX1':REFBOTX1,\n", " 'REFVAL':REFVAL})\n", "display(ui, out)\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Save discretized airfoil points, if you want\n", "savePoints('HTR1555.dat',X,'HTR1555')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.6" } }, "nbformat": 4, "nbformat_minor": 2 }