{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Application (Wing-Fuselage)\n", "## Post-processing of a CFD simulation with a multi-block structured cell-centered dataset.\n", "\n", "In this tutorial, you will process solution data from a typical external aerodynamic test case. The actual structured mesh used has been coarsened four times to alleviate memory costs. Please download the associated data at https://www.cerfacs.fr/antares/downloads/application3_tutorial_data.tgz\n", "\n", "untar the archive in the working directory\n", "\n", "copy the app3_aircraft.ipynb in the directory application3" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Preliminary Steps\n", "\n", "import os and antares packages\n", "\n", "create a directory named OUTPUT under application3" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "import \n", "import \n", "\n", "if :\n", " os." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Part I: Read Input Data\n", "\n", "The topic of this part is to create the basic structures from the data of a CFD simulation of typical wing-fuselage configuration. It will be used later throughout the tutorial.\n", "\n", "The first step is to create a Base named base by reading grids from files MESH/mesh_XXXX (Tecplot binary format) as shared data.\n", "You must also give topological information contained in script_topology.py and the zones must be named BlockXXXX to insure coherence with the topological data.\n", "Have fun with your data. Compute the total number nodes using the grid_points attribute of the Base object. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "r = antares.\n", "r[] = os.path.join()\n", "r['zone_prefix'] = 'Block'\n", "r['topology_file'] = os.path.join('script_topology.py')\n", "r[] = \n", "base = \n", "\n", "print('Total number of nodes = {}'.format(base.grid_points))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "Now add the solution stored in files FLOW/flow_XXXX (Tecplot binary format) to your existing base.\n", "\n", "The solution given here is located at nodes. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "r = antares.\n", "r[] = \n", "r[] = os.path.join()\n", "r['zone_prefix'] = 'Block'\n", "r." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Part II: Extract Skin Data\n", "\n", "This part details the steps to extract data on the aircraft skin in order to visualize the static pressure distribution. \n", "\n", "In this part, we will focus on skin extraction. It would be at least interesting to locate the aircraft. Therefore, it is necessary to extract the mesh coordinates on the aircraft skin.\n", "As topological information have been read in script_topology.py, the base already contains families. Print the families to see the family names. Then, build a new family aircraft_family including all families except JOIN and NREF" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "print(base.families)\n", "\n", "# build a new family\n", "aircraft_family = antares.\n", "aircraft_family[] = base.\n", "aircraft_family[] = base.\n", "aircraft_family[] = base.\n", "aircraft_family[] = base.\n", "aircraft_family[] = base.\n", "aircraft_family[] = base.\n", "# add the new family to the base\n", "base.families['SKIN'] = \n", "\n", "# extracting the skin base\n", "skin_base = \n", "print(skin_base)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "Secondly, we would like to visualize the static pressure on the aircraft skin. To do so, we will use the Base method compute(). Look in Antares documentation to know how to use it. Beforehand, we have to declare the computer model internal with the Base method set_computer_model(). " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "skin_base.\n", "\n", "skin_base.compute()" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "To finally visualize the skin, write the base skin_base in VTK binary format (compatible with Paraview software) in directory OUTPUT/SKIN/. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "writer = antares.\n", "writer[] = \n", "writer[] = os.path.join()\n", "writer." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Part III: Create Cut\n", "\n", "This part will teach you how to extract the Mach number field on a geometrical plane cut. \n", "\n", "We want to visualize the Mach number on a geometrical cut. Use the function compute() to compute this variable on your base. Do not forget to declare a computer model. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "base.\n", "base.compute()" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "Use cut treatment (see documentation for more information) to perform a geometrical cut in your domain at a constant x value of 2.25. The base obtained after cut will be named cut_base. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "plane_cut = antares.\n", "plane_cut[] = \n", "plane_cut[] = \n", "plane_cut[] = \n", "plane_cut[] = \n", "cut_base = " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "To finally visualize the cut, write the base cut_base in VTK binary format (compatible with Paraview software) in directory OUTPUT/XCUT/. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "writer = antares.\n", "writer[] = \n", "writer[] = os.path.join()\n", "writer." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Part IV: Plot Data Over Line\n", "\n", "The objective of this part is to plot the pressure distribution on the wing at a given 'y' coordinate. \n", "\n", "We want now to vizualize the wing pressure distribution at constant y value of 0.4. As we have already extracted the skin base skin_base (tutorial part II), apply a cut treatment to extract values at constant y (y=0.4). " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "plane_cut = antares.\n", "plane_cut[] = \n", "plane_cut[] = \n", "plane_cut[] = \n", "plane_cut[] = \n", "cut_base = " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "Use the threshold treatment (see documentation to learn how it works) to isolate the right wing (0.15 < y and 0.78 < x < 1.47). Then use the merge treatment (see documentation to learn how it works) to merge and the unwrapline treatment reorganize the line points. The base obtained will be named line_base." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "clip = antares.\n", "clip[] = \n", "clip[] = \n", "clip[] = \n", "line_base = \n", "\n", "merge = antares.\n", "merge[] = \n", "line_base1 = \n", "\n", "unw = antares.\n", "unw[] = \n", "line_base = " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "To visualize data stored in the base line_base use matplotlib. Plot the static pressure distribution as a function of x." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "plt.plot(line_base[0][0]['x'], line_base[0][0]['psta'], lw=2.5)\n", "plt.grid()\n", "plt.xlabel('{}'.format('x'), fontsize=18)\n", "plt.ylabel('{}'.format('psta'), fontsize=18)\n", "plt.autoscale(axis='x')\n", "plt.autoscale(axis='y')\n", "plt.show()\n", "plt.close()" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "Write the base line_base in directory OUTPUT/LINE/ in the column format. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "writer = antares.\n", "writer[] = \n", "writer[] = os.path.join()\n", "writer." ] } ], "metadata": { "celltoolbar": "Diaporama", "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" }, "nbpresent": { "slides": { "046854bb-a4d0-4839-a656-3c29bfa2eafa": { "id": "046854bb-a4d0-4839-a656-3c29bfa2eafa", "prev": "84edf4c4-5c79-4186-a419-f1a524255c47", "regions": { "bcfe2215-71a6-4f03-bc3a-cf45c2756ec8": { "attrs": { "height": 0.8, "width": 0.8, "x": 0.1, "y": 0.1 }, "content": { "cell": "e1b15d2c-795f-406d-8130-b73f190da8ca", "part": "whole" }, "id": "bcfe2215-71a6-4f03-bc3a-cf45c2756ec8" } } }, "21beb54a-dbf4-4372-b741-72f75c45488b": { "id": "21beb54a-dbf4-4372-b741-72f75c45488b", "prev": "c5f9ef9c-fda9-4f64-81b0-8df95ac9a0e7", "regions": { "322dbed9-3442-4b1a-82cd-4322d9af373e": { "attrs": { "height": 0.8, "width": 0.8, "x": 0.1, "y": 0.1 }, "content": { "cell": "60bef50c-9fe4-4d42-a3b3-16dee2c569d4", "part": "whole" }, "id": "322dbed9-3442-4b1a-82cd-4322d9af373e" } } }, "31895f0d-c84f-48fd-9e46-3910f3a32871": { "id": "31895f0d-c84f-48fd-9e46-3910f3a32871", "prev": null, "regions": { "255b4f54-02eb-4c41-bf69-c668d8117399": { "attrs": { "height": 0.8, "width": 0.8, "x": 0.1, "y": 0.1 }, "content": { "cell": "3e2abaca-ff6d-4475-97f6-b43d1634e2c9", "part": "source" }, "id": "255b4f54-02eb-4c41-bf69-c668d8117399" } } }, "4090087b-dded-4a9e-a828-8f208228d474": { "id": "4090087b-dded-4a9e-a828-8f208228d474", "prev": "046854bb-a4d0-4839-a656-3c29bfa2eafa", "regions": { "e367bf97-6261-4623-b7dd-1694ad126099": { "attrs": { "height": 0.8, "width": 0.8, "x": 0.1, "y": 0.1 }, "content": { "cell": "42947e78-728f-4008-bd3d-d1f0110164a1", "part": "whole" }, "id": "e367bf97-6261-4623-b7dd-1694ad126099" } } }, "84edf4c4-5c79-4186-a419-f1a524255c47": { "id": "84edf4c4-5c79-4186-a419-f1a524255c47", "prev": "a209d110-660b-4251-a92e-e4d7a7e2f95d", "regions": { "e10c5d08-4e24-4045-a27d-d6901a4df427": { "attrs": { "height": 0.8, "width": 0.8, "x": 0.1, "y": 0.1 }, "content": { "cell": "e3738ad3-06a7-4974-873b-6385ed7f8b30", "part": "source" }, "id": "e10c5d08-4e24-4045-a27d-d6901a4df427" } } }, "a209d110-660b-4251-a92e-e4d7a7e2f95d": { "id": "a209d110-660b-4251-a92e-e4d7a7e2f95d", "prev": "31895f0d-c84f-48fd-9e46-3910f3a32871", "regions": { "50d5c9c8-cca1-4f70-b2b1-97961e71d2d3": { "attrs": { "height": 0.8, "width": 0.8, "x": 0.1, "y": 0.1 }, "content": { "cell": "1a128849-789e-4bad-8366-d5b57675e4d2", "part": "source" }, "id": "50d5c9c8-cca1-4f70-b2b1-97961e71d2d3" } } }, "c5f9ef9c-fda9-4f64-81b0-8df95ac9a0e7": { "id": "c5f9ef9c-fda9-4f64-81b0-8df95ac9a0e7", "prev": "4090087b-dded-4a9e-a828-8f208228d474", "regions": { "e4cbbebb-636e-4ef0-82ef-950cd5adb8af": { "attrs": { "height": 0.8, "width": 0.8, "x": 0.1, "y": 0.1 }, "content": { "cell": "73689d5a-c0db-4e1d-a0d6-16021b427eea", "part": "whole" }, "id": "e4cbbebb-636e-4ef0-82ef-950cd5adb8af" } } } }, "themes": {} } }, "nbformat": 4, "nbformat_minor": 2 }