Important
The documentation is not yet finished, but should be good enough to make meshes.
PyAero documentation¶
PyAero is an airfoil contour analysis and CFD meshing tool written in Python.
PyAero is open-source and distributed under the MIT license, see LICENSE.
Above analysis result was obtained using the CFD code AVL-FIRE. It is an unsteady laminar 3D calculation of the RG14 airfoil. The mesh was thickened with several layers in spanwise direction in order to allow for turbulent fluctuations in all three dimensions. The calculation result shown is based on pure laminar settings (i.e. no turbulence model switched on). Later (result not shown) a LES calculation using the Kobayashi SGS model was done. With the applied mesh resolution both approaches lead to quite similar results.
Model | Drag | Lift |
---|---|---|
Laminar | 0.0079 | 0.371 |
LES | 0.0078 | 0.362 |
Features
- Load and display airfoil contour files
- Airfoil splining and refining
- Prepare contour for meshing
- Splining is done to get a smooth contour and sufficient contour points
- Refining allows to improve leading and trailing edge resolution
- Airfoil contour analysis
- Analyze gradient, curvature, and curvature circle at the leading edge, i.e. leadinge edge radius
- Trailing edge generation
- Specification of the trailing edge thickness (blunt trailing edge)
- Smart blending functions (arbitrary polynomial)
- Independent blending for upper and lower contour (e.g. for strong cambered airfoils)
- Automatic generation of block-strcuctured meshes for airfoils
- Currently only single element C-type meshes are supported
- Mesh control
- Boundary layer region
- Wake region
- Windtunnel
- Mesh export (most formats based on the meshio library)
- Simple aerodynamic analysis, i.e. panel methods
Quick start guide
Follow the Quick start guide tutorial to get a first impression of the key functionality.
Code repository
The code ist hosted on GitHub: PyAero source code
Introduction¶
PyAero is an open-source airfoil contour analysis and CFD meshing tool. The main intention of writing the software was to make an easy to use tool for 2D airfoil meshing. Meshes generated by PyAero are intended to be used in subsequent CFD analysis.
PyAero, at least at the moment, does not do the CFD calculation itself. At a later stage it might be possible that PyAero will be interfaced (i.e. export meshes in the respective format(s)) with existing open source CFD methods like SU2 or similar.
As an initial step towards aerodynamic calculations, a panel method from AeroPython (©2014 Lorena A. Barba, Olivier Mesnard) has been implemented.
Airfoil contours (at least legacy airfoils) often are described through a limited number of points (approx. 60 points). When meshing such contours, if not interpolated by splines, the resulting mesh and numerical solutions based on it would end up with artefacts. These would deteriorate the quality of the analysis results.
Therefore, in addition to the mesh generation module, some additional features have been implemented. These features are intended to be able to analyze and improve the airfoil contour. The improvement process is supported by point insertion and spline interpolation techniques. First and second derivatives of the contour allow for control of the contour as well as curvature smoothness.
To reflect real shapes, an option for creating a trailing edge and blending it to the contour is implemented.
The following figures show an example mesh for the airfoil RAE2822 and a magnification of leading edge and trailing edge sections.
Quick start guide¶
The general steps for mesh generation in PyAero can be explained as follows:
- Load an airfoil contour file
This is to get the raw data decribing the airfoil contour. - Spline and refine the airfoil contour
This is to update/improve the contour and prepare the mesh resolution along the airfoil. - Make a trailing edge with finite thickness
This adds a so called blunt trailing edge to the contour.
Skip this step if the trailing edge should be sharp. - Mesh the refined airfoil contour
Start the meshing process. - Export the mesh in the required format
Save the mesh in the specified format to the harddrive.
This is it.
Check the animation below, on how this looks in the graphical user interface (version 2.1.5).
User Interface¶
PyAero comes with a graphical user interface (GUI) written in Qt for Python aka Pyside6.
Overview¶
The layout of the user interface can be seen in the figure below. Different functional areas are bordered with blue lines. These areas are:
- Menubar
- Toolbar
- Toolbox
- Graphics view
- Viewing options
- Message window
Loading and saving geometry and meshes is done via the menus and the toolbar. Most operations during geometry preparation and meshing are done inside the toolbox.
Toolbar¶
The toolbar in PyAero allows fast access to actions which are otherwise triggered by menus. Each of the toolbar buttons launch a specific action. The toolbar can be customized by editing the file $PYAEROPATH/data/PToolBar.xml
.
Toolbox Functions¶
The toolbox functions are arranged at the left border of the GUI. A toolbox is a GUI element that displays a column of tabs one above the other, with the current item displayed below the current tab. The toolbox is the main working area when generating meshes with PyAero. The complete functionality like splining, refining, contour analysis and meshing are operated there. See the animation below to get an overview on the options available in the toolbox.
Tabbed Views¶
The graphics view in PyAero and a set of other views (see figure below) are arranged via a tab bar. E.g., the views can be switched between the graphics view and the contour analysis view. The latter contains graphs for curvature analysis.
Note
The look and feel of the tabs might change over time.
Zooming, Panning¶
When an airfoil is loaded it is displayed with a size that fits into the graphics view (leaving a small margin left and right). The contour can then be panned and zoomed in the following way:
Panning¶
In order to pan (drag) the contour or any other item press and hold CTRL (CMD on MacOS) and then press and hold the left mouse button and move the mouse in order to drag the contour.
Zooming¶
Zooming is activated by pressing and holding the left mouse button. While dragging the mouse, a rubberband rectangle is drawn. This rectangle indicates the area which will be zoomed when releasing the left mouse button. In order to avoid accidential zooming too deep, a minimum size rectangle has to show up. A valid zoom rectangle is indicated by changing its background to a transparent blueish color (the minimum allowed size can be set in Settings.py
by changing the value of RUBBERBANDSIZE). In order to zoom in deeper, the rubberband rectangle can be subsequently used.
Zoom limits (MINZOOM, MAXZOOM) are set in the file Settings.py
.
Another natural possibility to zoom the view, is to use the scroll wheel. Thereby the geometry is zoomed with respect to the current mouse position.
Zooming can further be done using the Page-Up and Page-Up down keys.
A reset to the initial (home) position can either be achieved by pressing the HOME key or by right clicking in the graphics view and selecting Fit airfoil in view from the pulldown menu.
Keyboard shortcuts¶
To speed up some operations, a set of keyboard shortcuts are defined. In some of the menus the shortcuts for the respective actions are defined at the right side of the menu. Furthermore, the shortcut CTRL+k on Windows and CMD+k on MacOS are used to access an overview of the keyboard shortcuts.
Note
The keyboard shortcuts are rendered as uppercase letters in the GUI. Nevertheless, always lowercase letters need to be used, unless the SHIFT key is a part of the shortcut.
Loading Airfoils¶
Loading airfoils can be done in different ways.
Load via the inline file browser¶
As outlined above there are more ways to load airfoils. A very handy way to browse airfoils is to use the
implemented file browser. This browser is restricted in terms of navigation. Only files and folders below a
predefined root path are visible. The default root is the data/Airfoils
subfolder from the
standard installation. The root path for airfoils can be changed by the user in the file src/Settings.py
by changing the value of the variable AIRFOILDATA
.
The file browser is located in the toolbox on the left side of the application. It is the uppermost tab in the toolbox area.
See also
For more information on configuring the root path to airfoil data see Settings.
Load via the Toolbar¶
Another way to open the file dialog is to click on the data/PToolBar.xml
.
See also
For more information on configuring the menubar and the toolbar see Settings.
Load a predefined airfoil¶
For testing purposes a predefined airfoil can be loaded without the need of a file dialog. The airfoil which is predefined can be configured.
See also
See tutorial Settings on how to change the default airfoil.
Load via drag and drop¶
Last but not least, one or more airfoil(s) can be loaded via drag and drop. Just drag a couple of files, e.g. from the Explorer (Windows) or Finder (MacOS), to the graphics window. All files will be loaded, but only one file will be displayed. All the other files are shown (and can be activated by double-clicking on the name) in the toolbox area.
Splining and Refining Airfoil Contours¶
The meshing process in PyAero relies on the point distribution on the airfoil contour. During meshing, there is a mesh constructed around the airfoil, which consists of mesh lines perpendicular to the airfoil contour. The mesh lines are starting at the individual airfoil contour points. So in order to be able to generate a proper mesh, the contour point distribution has to be adapted first. This is important, because particularly legacy wing sections have quite a coarse resolution (around 60 points). In the figure below, there is an animation of:
- the original airfoil contour
- the splined airfoil contour
- and the mesh lines parting from the splined contour
Two functions improve the contour before meshing. After clicking Spline and Refine in the respective toolbox function, the contour will at first be splined and in a second step refined.
The splining is done using B-splines via the Scipy function scipy.interpolate.splprep
. This produces a spline representation through the initial (raw) airfoil contour. The number of points on the spline obviously can be set by Number of points on spline. Using an equal arc length the respective number of points is distributed homogeneously along the spline. This is the intended behaviour, as it guarantees constant size mesh cells around the airfoil (since the mesh is based on these points).
Obviously, at the leading and trailing edges some more care is necessary to produce the required mesh resolution. At the leading edge it is required to resolve the big pressure gradients which are produced by the shape of the airfoil nose.
A recursive refinement algorithm is used to resolve the contour until a certain criterion is met (see following figure). A B-spline is interpolated throug the given raw contour points. At first, equidistant arc length segments are created on the spline (according to the prescribed number of points). During recursive refinement, the algorithm checks each pair of adjacent line segments if they match the criterion. The criterion is based on the angle included between adjacent segments. If the angle is less than a threshold specified by the user via the Refinement tolerance input, the algorithm adds two points. Each point is placed on the interpolated spline, half distance within each of the current segments. Then, new segments are created and angles are checked over and over again, until no pair of segments exists which include angles less than the threshold. This guarantees that the angle between adjacent mesh cells in the boundary layer is as uniform as possible. Thus, pressure gradients around the airfoil are resolved with the same quality.
Angles between 170° and 173° already produce very well resolved leading edge contours (see following figures).
At the trailing edge again pronounced pressure gradients due to flow separation shall be resolved by a finer mesh.
The trailing edge refinement algorithm is somewhat simpler. The user specifies the number of segments to be refinded at the trailing edge. If the number of Refine trailinge edge (old segments) is 3, both, at the upper and lower sides of the contour, the last 3 segments are selected for refinement. The number of segments is then changed to Refine trailinge edge (new segments). If this number is 6 and the chosen compression rate Refine trailinge edge ratio is 4, a distribution as depicted in figure Airfoil RG15: Close-up, 60 points, LE refinement 3, 6, 4 is created.
Trailing Edge¶
Note
If a sharp trailing edge is needed, this step can to be skipped.
As outlined in the section before, the meshing process relies on the point distribution on the airfoil contour. Real airfoils, i.e. airfoils which are built as a hardware, have a trailing edge (TE) with a definite thickness, a blunt trailing edge. This is due to manufacturing and/or structural reasons. To be able to model this, PyAero has a dedicated function. The following figure shows an animation of a sharp trailing edge and a blunt trailing edge.
The blunt trailing edge needs to be added to the original contour in a controlled manner. The parameters shown in the following figure can be used to control this process.
The trailing edge thickness itself can be specified relative to the unit chord. The thickenning is done perpendicular to the camber line at the trailing edge. In order to prevent aerodynamic artefacts due to the blunt TE, a smooth controlled blend from the blunt TE vertices into the original (raw) contour needs to be done.
This is achieved by allowing to blend along a certain user specified length into the original contour. Furthermore, the degree of the blending curve can be specified. The blending length describes the fraction (in %) of the chord in which the blending is done. The polynomial exponent can be used to describe the blending curve degree. The blending can be controlled individually for the upper and lower sides of the contour. This is specifically useful for strongly camber airfoils.
To better understand the TE blending options the following figure depicts a visually exaggerated TE blending (by clicking several times on the Add Trailing Edge button). The upper side of the aifoil is blended over 50% of the chord with a linear blend, whereas the lower side is blended over 20% of the chord with a polynom of degree three.
Playing with the settings and finding the best setup for blending is always best viewed by clicking two or three times on the Add Trailing Edge button. A reset to the original curve can be achieved by simply clicking on the Spline and Refine button in the menu above (see Toolbox function for specifying spline and refining parameters).
When a satisfying result is achieved for the contour in terms of splining, refining and trailing edge, the meshing process can be started.
Making Meshes¶
After Splining and Refining Airfoil Contours and optionally making a blunt Trailing Edge, the airfoil contour can be meshed which is the primary purpose of PyAero. As for splining and refining the meshing options are located in the toolbox area which is the left pane of the user interface (see Overview on toolbox options).
The default settings for the mesh generation process should be good enough to generate a mesh that can be used to do CFD RANS simulations.
The mesh is constructed from four individual blocks, each of which has its own configuration options. The mesh blocks are (listed below with the same name as in the GUI):
- Airfoil contour mesh (block 1)
- Airfoil trailing edge mesh (block 2)
- Windtunnel mesh around airfoil (block 3)
- Windtunnel mesh in the wake (block 4)
The main mesh block is the one directly attached to the airfoil contour. It is constructed by grid lines emerging perpendicular from the airfoil, starting at the points from the splined contour (see Splining and Refining Airfoil Contours). Another set of lines parallel to the airfoil contour complete the main mesh block. The default settings there implement a streching away from the airfoil, so that the thinnest mesh layer is attached at the airfoil and further mesh layers are gradually thickened outwards.
The process of constructing the grid lines perpendicular and parallel to the contour guarantees a fully orthogonal mesh in the vicinity of the airfoil which is important for keeping numerical errors as low as possible in the region of interest. The mesh distribution settings for this block are depicted in the following figure (Settings for the mesh around the airfoil (block 1)).
The value for the number of Gridpoints along airfoil
contour is grayed out. This value is taken from the number of points on the spline and is displayed here just for reference(see also Toolbox function for specifying spline and refining parameters). If a different number of grid points along the contour is required the spline has to be updated at first. Next the Divisions normal to airfoil
allows to vary the number mesh layers normal to the contour within mesh block 1. The setting 1st cell layer thickness
specifies the dimension/length of block 1 normal to the contour in percentage of the airfoil chord. It is limited to 100% chord length, but typical values would be in the range 5% to 20%. The final parameter for block 1 is the Cell thickness ratio (-)
. It specifies the ratio of the cell thickness of the outermost cell in the block (wrt to airfoil normal direction) over the cell thickness of the layer which is attached to the contour. So if for example the ratio is 3, the outer cell layer of block one is 3 times a thick as the cell layer at the airfoil (see Mesh stretching ratio).
The trailing edge mesh is the region directly behind the airfoil (block 2, see Mesh blocking structure). This block has its own parameters in order to be able to fine control the grid resolution where upper and lower contour shear layers meet and interact(see figure_mesh_block_TE).
The parameter Divisions at trailing edge controls the number of subdivisions at the trailing edge (see blue circle in Mesh at the trailing edge (block 2)). If the airfoil trailing edge has a finite thickness (blunt trailing edge), these cells resolve the small vertical part of the trailing edge. Divisions downstream trailing edge is the number of subdivisions in the direction of the airfoil wake inside block 2. The Length behind trailing edge (%) is the length of block 2 in the same direction measured as fraction of the unit chord. The Cell thickness ratio (-) has the same effect on the grid line distribution as already depicted for the mesh around the airfoil (block 1).
In case of a sharp trailing edge, above parameters are not used. The cells of the airfoil upper and lower grid lines meet at the trailing edge and continue as one gridline downstream.
The next set of parameters specifies the grid distribution within block 3. The parameters are handled in the same way as for block 1 and block 2. The distribution biasing is just and intermediate helper function and should be kept with its default value (see note below) for symmetric or slightly cambered airfoils. For airfoils with pronounced camber setting biasing to lower improves the mesh quality.
Important
The meshing algorithm in block 3 is not finished, rather it is a tweaked version of a transfinite interpolation. This will be updated with elliptic grid generation or similar.
The final mesh block (see block 4 in Mesh blocking structure) is the remainder of the windtunnel downstream. It copies the mesh distribution of blocks 1,2 and 3 onits upstream side. Again the settings left over here should be self explanatory, except Equalize vertical wake line at (%). At the outlet of the windtunnel downstrream all cells have equal width in the vertical direction. The setting just mentioned allows to specify at which percentage of the block 4 in downstream direction the cells will be of homogeneous size in the vertical direction (see Mesh block 4 - equalizing trailing edge grid line distribution). The dashed vertical line indicates the location from where the vertical grid line distribution is homogeneous.
The following figure shows the final mesh of an example airfoil (hn1033a).
Batch mode (run from command line)¶
In order to be able to automate the mesh generation process, a batch utility is available. This allows to run the mesh generation on a large number of airfoils. A batch control file is used to specify the airfoils to be processed. The batch control file is a text file which contains the following information:
- Airfoils which should be meshed
- Settings to be used for the mesher
- Output formats in which the mesh(es) should be written
The command used to launch the batch processing is:
python src/PyAero.py -no-gui data/Batch/batch_control.json
The batch control file can be located in an arbitrary folder and have any name. It just has to have the same format as the example file of the installation, see data/Batch/batch_control.json
.
CFD_boundary_conditions¶
Aerodynamics (panel code)¶
For fast lift coefficient calculations a panel method has been implemented. The code is based on an open source software developed by the Barba group. The codes in Aeropython are part of a series of lessons of a university course. The specific module used here is based on a vortex-source panel method (code in module 4).
Clicking on Calulate lift coefficient will calculate the lift coefficient for the current configuration. The code runs very fast and is not influenced much by the number of panels. The code is using its own paneling method. Paneling is either based on the airfoil raw data or on the splined contour data (if available). A too high number of panels may lead to convergence issues.
A typical result/output of the method is shown below (the information is displayed in the message window):
INFO - Aerodynamic properties of Makarov KPS Long Root:
INFO - Cl = 1.268 [-] at Uinf = 5.000 [m/s], and AOA = 3.000 [degree]
Barba, Lorena A., and Mesnard, Olivier (2019). Aero Python: classical aerodynamics of potential flow using Python. Journal of Open Source Education, 2(15), 45, https://doi.org/10.21105/jose.00045
Contour Analysis¶
Settings¶
PyAero supports customizing its behaviour. The parameters which can be modified are
stored in a file called Settings.py
.
Modify and extend GUI Functionality¶
License¶
The MIT License (MIT)
Copyright (c) 2022 Andreas Ennemoser
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.