Skip to content

Commit

Permalink
V3 dev merge (#5)
Browse files Browse the repository at this point in the history
* dev initial

* dev

* dev

* dev

* dev

* dev

* dev

* dev

* preparing v3.0

* dev

* preparing v3.0

* refactor lazy polars

* show polar op points

* blend SD7003 - thanks Thomas!

* popen Windows conditionals - thanks Thomas

* preparing beta 2

* fix logging

* refactor subprocess call

to align better with LINUX (?)

* scale re

* fix exe directory

* re_scale

* asyncio tests

* refactoring polar generation

* cleaning

* Update airfoil_test.py

* code cleanings

* cleanup file functions

* fix example airfoil

* Update airfoil_examples.py

* blend label

* refactor Artist refresh

* polar error handling

* refresh polar defs

* code cleaning

* code cleaning

* bezier sanity file check - thanks Martin!

* UI tweaks

* Improved Worker check

* preparing 3.0
  • Loading branch information
jxjo authored Jan 29, 2025
1 parent 5e49bdb commit fcf3ca5
Show file tree
Hide file tree
Showing 42 changed files with 5,589 additions and 1,042 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
releases
AirfoilEditor.settings
example.dat
example_mod.dat
README.pdf
*_polars
*_designs
tmpinp*

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
479 changes: 340 additions & 139 deletions AirfoilEditor.py

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions AirfoilEditor.settings

This file was deleted.

91 changes: 50 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,74 @@
![AE](images/AirfoilEditor_logo.png "Screenshot of the AirfoilEditor ")

# v2.0
# v3.0 <sup>beta 2</sup>


The AirfoilEditor is on one hand a fast airfoil viewer and on the other hand a powerful editor to modify the geometry of an airfoil. Focusing on an airfoils geometry the principle of this app is: Don't do too much but do it really well.
The AirfoilEditor is on one hand a fast airfoil viewer and on the other hand a powerful editor to modify the geometry of an airfoil. Focusing on an airfoils geometric and aerodynamic characteristics the principle of this app is: Don't do too much but do it really well.


Main features:

* View an airfoil and browse through the airfoils of its subdirectory
* View the curvature of the airfoil surface
* Analyze the curvature of the airfoil surface
* **! New !** View polars of an airfoil
* Repanel and normalize the airfoil
* Modify the geometry parameters thickness, camber, its high points, trailing edge gap
* Create a Bezier curve based 'copy' of an airfoil
* Blend an airfoil with another airfoil

The driver for this app was to overcome some of the artefacts using xfoils geometry routines (for example used in Xflr5) when creating geometric 'high quality' airfoils. The focus of the app is on pure geometry work with airfoils - aerodynamic aspects are out of scope.
The driver for this app was to overcome some of the artefacts using xfoils geometry routines (for example used in Xflr5) when creating geometric 'high quality' airfoils.

An attempt was made to create a self-explanatory app that invites to play and try out. Hopefully this objective has been achieved ...


![AE](images/AirfoilEditor_App.png "Screenshot of the AirfoilEditor ")


## Basic concepts
## Geometry: Basic Concepts

The `AirfoilEditor` implements different "strategies" to represent an airfoils geometry:

- 'Linear interpolation' - Based on the point coordinates of the airfoils '.dat' file, intermediate points are evaluated with a simple linear interpolation. This is used for fast preview and basic operations.
- 'Cubic spline interpolation' - A cubic spline is built based on the airfoils point coordinates. The spline allows to evaluate intermediate points with high precision.
- 'Bezier curve' - An airfoil is represented by two Bezier curves for upper and lower side of the airfoil. A nelder mead optimization allows to approximate the Bezier curves to an existing airfoil.
- (not in 2.0 beta) 'Hicks Henne' - Hicks Henne bump functions are applied to a "seed airfoil" to achieve a new shape (in development for Xoptfoil2)


The spline interpolation is used to find the position of the 'real' leading edge, which may differ from the leading edge of the coordinates (which is the point with the smallest x-value). When 'normalizing' the airfoil, the 'real' leading edge is taken in an iteration to rotate, stretch and move the airfoil to become 0,0 - 1,0 normalized.

For thickness and camber geometry operations the airfoil (spline) is splitted into two new splines representing thickness and camber distribution. For moving the highpoint of either thickness or camber a mapping spline for the airfoil coordinates is used quite similar to the approach implemented in xfoil. After these operations the airfoil is rebuild out of thickness and camber.

The same approach is applied to move the highpoint of the upper and lower side of the airfoil which makes it possible to optimize the upper and lower side independently of each other.

![Modify](images/Modify.png "Screenshot of Modifying Airfoil")

Repaneling is based on a modified cosine distribution of the airfoil points on the arc of the spline. This differs from the xfoil approach but the repanel shows 'nice' behavior in aero calculation.

As an example for the modification functionality of the app, the dialog for repaneling is shown:
![Modify](images/Modify.png "Screenshot of Modifying Airfoil")
<sub>The 'Edit Mode' of the `AirfoilEditor` to change the geometry either by value or by moving the mouse helper points. Each change creates a new 'Design' variant which allows to browse through the changes made in this session. </sub>
<br></br>

Repaneling is based on a modified cosine distribution of the airfoil points on the arc of the spline. The bunching of the coordinate points at leading and trailing edge can be adjusted.

![Repanel](images/Repanel.png "Screenshot of Repaneling within AirfoilEditor")
<sup>Dialog for repaneling of an airfoil. Recommendations are given for 'healthy' panel angles. </sup>
</p>
An airfoil may be 'blended' with another airfoil to create a new airfoil that has the genes of both airfoils.

### Curvature

On of the major views on an airfoil in the Airfoil Editor is the curvature of the airfoils surface. It allows a quick assessment of the surface quality and to detect artefacts like a 'spoiler' at the trailing edge which is quite common.
On of the major views on an airfoil in the `AirfoilEditor` is the curvature of the airfoils surface. It allows a quick assessment of the surface quality and to detect artefacts like a 'spoiler' at the trailing edge which is quite common.


![Curvature](images/Curvature.png "Screenshot of Curvature")
<sub>The additional 'Curvature View' on the airfoil indicating reversals of the curvature. </sub>

> [!TIP]
Have a look at the [documentation of Xoptfoil2](https://jxjo.github.io/Xoptfoil2/docs/geometry) with more information about an airfoils geometry.


## Bezier based airfoils
### Bezier based airfoils

Beside '.dat'-files the Airfoil Editor seamlessly displays '.bez'-Files defining an Bezier based airfoil.

![Bezier](images/Bezier.png "Screenshot of Bezier curve definition")

A '.bez'-file defines the x,y coordinates of the Bezier control points and looks like:
```
JX-GT-15
Top Start
0.0000000000 0.0000000000
0.0000000000 0.0120189628
0.0681109425 0.1240586151
0.6435307964 0.0748001854
1.0000000000 0.0000000000
Top End
Bottom Start
0.0000000000 0.0000000000
0.0000000000 -0.0222920000
0.3333333333 -0.0240468000
1.0000000000 0.0000000000
Bottom End
````
A special feature is the definition of a (new) airfoil based on two Bezier curves for upper and lower side. The Bezier editor allows to move the control points of the curve by mouse.

A special feature is the definition of a (new) airfoil based on two Bezier curves for upper and lower side. The control points of the Bezier curve can be moved by mouse.

The 'Match' function performs a best match of the Bezier curve to an existing airfoil. For this a simplex optimization (Nelder Mead) is performed to
- minimize the norm2 deviation between the Bezier curve and the target airfoil
Expand All @@ -93,8 +78,6 @@ The 'Match' function performs a best match of the Bezier curve to an existing ai

![AE](images/Match_Bezier.png "Screenshot of Bezier curve definition")

<!---
## Hicks-Henne based airfoils
Expand All @@ -107,10 +90,34 @@ The Airfoil Editor allows to visualize the Hicks-Henne functions which were appl
<sup>Visualization of the Hicks-Henne bump functions, which were applied to the upper and lower side of the airfoil</sup>
-->
<br></br>

## Airfoil Polars

To generate the polars of an airfoil the `AirfoilEditor` uses the `Worker` tool of the [Xoptfoil2 project](https://jxjo.github.io/Xoptfoil2). On of the `Worker` actions is the multi-threaded creation of a polar set using Xfoil.

Within the app a polar is generated 'lazy' - meaning at the moment when the polar should be displayed - and asynchronous in a backround task. Each polar is stored in a single file having the Xfoil polar format. This approach allows to step through airfoils or the designs of an airfoil and present the polars without further user interaction.

For polar generation the `auto_range` feature of the `Worker` is applied which optimizes the alpha range of the polar to show the complete T1 polar from cl_min to cl_max of the airfoil. For T2 polars (constant lift) the range starts right above cl=0.0 to cl_max.


![Polars](images/Polars.png "Screenshot of Polar Generation")
<sub>Polar view with polar definitions and settings for the polar diagrams. The polars were generated in the background. </sub>

### Airfoil Direct Design

The combination of the 'Edit Mode' and automated polar generation allows a playful approach to a 'Direct Design' of an airfoil based on its geometry: Each modification, e.g. moving the camber highpoint or the control point of a Bezier curve, will generate a new design with its individual new polars. Stepping through the design polars creates an intuitive understanding how geometeric modifications influence the aerodynamic characteristics of an airfoil.


![Polars](images/Polars_direct_design.png "Direct Design with polar gneration")
<sub>Direct Design with automated polar generation. The current design is compared with the reference airfoil MH31
. </sub>



## Short Introduction

Have a look at this little video showing the main functionality of the AirfoilEditor:
Have a look at this little video showing the main functionality of the AirfoilEditor v2:

[![Watch the video](https://img.youtube.com/vi/gkgPbVkOAcU/maxresdefault.jpg)](https://youtu.be/gkgPbVkOAcU)

Expand All @@ -123,21 +130,21 @@ The `AirfoilEditor` is developed in [Python](https://www.python.org/) using [Py
The main building blocks of the App are
* Model - containing all geometry and math helper routines of an airfoil. The model is independent of the UI. The different modules are kept in [modules/model](modules/model).

* `Worker` tool including Xfoil from the [ Xoptfoil2](https://jxjo.github.io/Xoptfoil2) project to generate airfoil polars.

* UI-Framework - base classes and a little framework to ease the implementation of forms based on widgets and diagrams based on artists for the plot tasks. The base classes are in [modules/base](modules/base)

* Application - controller and view classes to handle presentation and user interaction - [modules/](modules/)

The airfoil model and the base classes also form the core of the other Apps of the family like `Planform Creator` and `Airfoil Optimizer` (to come).
The airfoil model and the base classes also form the core of other Apps like the [Planform Creator2](https://github.com/jxjo/PlanformCreator2) .

## Install

A pre-build Windows-Exe of the app is available in the releases section https://github.com/jxjo/AirfoilEditor/releases
A pre-build Windows App including `Worker.exe`is available in the releases section https://github.com/jxjo/AirfoilEditor/releases

or

Download python sources from https://github.com/jxjo/AirfoilEditor/releases or Clone the repository
and Install
Download python sources from https://github.com/jxjo/AirfoilEditor/releases or clone the repository and install

```
pip3 install pyqt6
Expand All @@ -147,6 +154,8 @@ pip3 install termcolor
```

Linux users who want to use polar generation have to compile `Worker.exe` in the [ Xoptfoil2 project](https://jxjo.github.io/Xoptfoil2)

> [!TIP]
For Windows: Use the "Open with ..." Explorer command to connect the 'AirfoilEditor.exe' to file extension '.dat'. Later a double click on an airfoil .dat-file will open the AirfoilEditor and you can browse through the files in the directory (if you are using the Python version, create a little batch job to open the .dat file)

Expand Down
Binary file added assets/windows/Worker.exe
Binary file not shown.
Binary file modified dev/UI_Drafts.pptx
Binary file not shown.
47 changes: 47 additions & 0 deletions dev/build_release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@echo off

set APP_VERSION=3.0
set WIN_RELEASE=AirfoilEditor_%APP_VERSION%_win

echo.
echo ------ Packaging AirfoilEditor windows runtime into %WIN_RELEASE%
echo.
echo. ? build_win_exe.bat run ? (in .\dist is actual build version)
echo. ? README.pdf ready ? (in VSCode export readme.md as pdf)
echo.
echo.
pause

cd ..

rem ----- clean dist folder ------------

if exist dist\AirfoilEditor\Example.dat del dist\AirfoilEditor\example.dat /q
if exist dist\AirfoilEditor\Example_polars rd dist\AirfoilEditor\Example_polars /s /q
if exist dist\AirfoilEditor\_internal\AirfoilEditor.settings del dist\AirfoilEditor\_internal\AirfoilEditor.settings /q

pause

rem ----- clean releases folder ------------

if exist releases\%WIN_RELEASE% rd releases\%WIN_RELEASE% /s /q
if exist releases\%WIN_RELEASE%.zip del releases\%WIN_RELEASE%.zip /q

mkdir "releases\%WIN_RELEASE%"

rem ----- copy files ------------

if not exist Readme.pdf goto end
xcopy README.pdf releases\%WIN_RELEASE%\ /i /q

xcopy dist\AirfoilEditor releases\%WIN_RELEASE%\ /s /i /q

pause

rem ----- zip with powershell ------------
cd releases
powershell Compress-Archive %WIN_RELEASE%\* %WIN_RELEASE%.zip
cd ..
dir releases\%WIN_RELEASE%
pause
:end
37 changes: 37 additions & 0 deletions dev/build_win_exe.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@echo off
echo.
echo Make onedir exe with pyinstaller in .\dist
echo.
echo ! Dont't forget to increase version number in source file !
echo.

echo - Running Pytest for *-test.py
echo.
cd ..
Pytest

pause

rem this is needed for pyinstaller to avoid "WARNING: lib not found: api-ms-win-crt ..."
set PATH=%PATH%;C:\Windows\System32\downlevel

rem to show missing imports: --debug imports ^
rem also look in modules for imports!: --paths modules ^
rem more infos during build: --log-level=INFO

echo.
echo - Building AirfoilEditor.exe in dist\AirfoilEditor
echo.
rem suppress console --noconsole ^
pyinstaller --noconfirm --log-level=INFO --onedir --noconsole ^
--icon=./modules/AE_ico.ico ^
--paths modules ^
--add-data="./modules/base/icons;./icons" ^
--add-data="./modules/AE_ico.ico;./icons" ^
--add-data="./assets/windows/worker.exe;./assets/windows" ^
--runtime-tmpdir="mySuperTemp" ^
AirfoilEditor.py

echo.
pause

Binary file modified images/AirfoilEditor_App.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Match_Bezier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Modify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Polars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Polars_concept.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Polars_direct_design.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/Repanel.png
Binary file not shown.
Loading

0 comments on commit fcf3ca5

Please sign in to comment.