{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib widget" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6c60f5bb1705487882af9db4454aa700", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from pysketcher import *\n", "from numpy import exp, linspace\n", "\n", "W = 5 # upstream area\n", "L = 10 # downstread area\n", "H = 4 # height\n", "sigma = 2\n", "alpha = 2\n", "\n", "drawing_tool.set_coordinate_system(xmin=0, xmax=W+L+1,\n", " ymin=-2, ymax=H+1,\n", " axis=True)\n", "drawing_tool.set_linecolor('blue')\n", "\n", "# Create bottom\n", "\n", "def gaussian(x):\n", " return alpha*exp(-(x-W)**2/(0.5*sigma**2))\n", "\n", "x = linspace(0, W+L, 51)\n", "y = gaussian(x)\n", "wall = Wall(x, y, thickness=-0.3, pattern='|', transparent=True).\\\n", " set_linecolor('brown')\n", "wall['eraser'].set_linecolor('white')\n", "def velprofile(y):\n", " return [2*y*(2*H-y)/H**2, 0]\n", "\n", "inlet_profile = VelocityProfile((0,0), H, velprofile, 5)\n", "symmetry_line = Line((0,H), (W+L,H))\n", "symmetry_line.set_linestyle('dashed')\n", "outlet = Line((W+L,0), (W+L,H))\n", "outlet.set_linestyle('dashed')\n", "\n", "fig = Composition({\n", " 'bottom': wall,\n", " 'inlet': inlet_profile,\n", " 'symmetry line': symmetry_line,\n", " 'outlet': outlet,\n", " })\n", "\n", "fig.draw() # send all figures to plotting backend\n", "\n", "vx, vy = velprofile(H/2.)\n", "symbols = {\n", " 'alpha': Distance_wText((W,0), (W,alpha), r'$\\alpha$'),\n", " 'W': Distance_wText((0,-0.5), (W,-0.5), r'$W$',\n", " text_spacing=-1./30),\n", " 'L': Distance_wText((W,-0.5), (W+L,-0.5), r'$L$',\n", " text_spacing=-1./30),\n", " 'v(y)': Text('$v(y)$', (H/2., vx)),\n", " 'dashed line': Line((W-2.5*sigma,0), (W+2.5*sigma,0)).\\\n", " set_linestyle('dotted').set_linecolor('black'),\n", " }\n", "symbols = Composition(symbols)\n", "symbols.draw()\n", "\n", "drawing_tool.display()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.5" } }, "nbformat": 4, "nbformat_minor": 4 }