[WIP] airfoil workbench

Show off your FreeCAD projects here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [WIP] airfoil workbench

Post by looo »

microelly2 wrote: Thu Dec 12, 2019 10:46 pm What is the definition of the leading edge? I think, I have a feeling,but it is better to have a well defined concept.
Wikipedia:
The leading edge is the point at the front of the airfoil that has maximum curvature (minimum radius).[8]
I will try this one. I bet there are some special cases where this is also not the expected result.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: [WIP] airfoil workbench

Post by Joel_graff »

I think I just solved this problem... like yesterday. :)

The illustration you provided suggests that the point of maximum curvature is on a horizontal line from the trailing edge of the airfoil. Is that a correct assumption?

If so, and you have an ordered list of the points of the airfoil, then you really need to just calculate the intersection point of two line segments. It's a discrete solution, obviously, but it's certainly easy to keep the error below whatever threshold seems appropriate.


If you need to search for the point of maximum curvature, I think you can accomplish it using OCC, though not directly...

Otherwise, the easiest way I can imagine to tackle that problem is to simply iterate the line segments of the curve, looking for the two segments with the smallest angle between them, then select the adjoining vertex as the point for the leading edge.

You can achieve greater accuracy and efficiency by:

1. Limiting the set of points you test. It seems to me that the leading edge should most certainly fall in the middle fifth of a set of points for any given airfoil.

2. Once you've identified the point as I described above, select the portion of the curve immediately around it, discretize it into smaller segments, and repeat until you've reduced the error to acceptable levels.

I can think of other ways to get this done, but these two approaches seem most straightforward to me.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [WIP] airfoil workbench

Post by looo »

Joel_graff wrote: Fri Dec 13, 2019 3:37 am The illustration you provided suggests that the point of maximum curvature is on a horizontal line from the trailing edge of the airfoil. Is that a correct assumption?
Yes this is how the foil should look after 'normalization'. The given coordinates can be rotated... That is why finding the leading edge is important. 1. to sepperate upper and lower side, 2. to guarantee that the airfoil is passing coordinate (0,0).
Joel_graff wrote: Fri Dec 13, 2019 3:37 am If you need to search for the point of maximum curvature, I think you can accomplish it using OCC, though not directly...
The airfoil is a python class and no freecad stuff is involved. I would like to keep it this way to sepperate freecad dependent and non freecad dependent stuff.
Joel_graff wrote: Fri Dec 13, 2019 3:37 am Otherwise, the easiest way I can imagine to tackle that problem is to simply iterate the line segments of the curve, looking for the two segments with the smallest angle between them, then select the adjoining vertex as the point for the leading edge.
Yes, finding the max curvature shouldn't be too hard. But the max curvature can be anywhere between 3 given points... Refining is not really possible for foils given by coordinates as an interpolation/approximation is necessary.
alberich
Posts: 77
Joined: Thu Aug 17, 2017 2:09 pm
Location: Texas

Re: [WIP] airfoil workbench

Post by alberich »

The smallest-x of the camber curve would be the leading edge, would it not?
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: [WIP] airfoil workbench

Post by Joel_graff »

looo wrote: Fri Dec 13, 2019 8:22 am The airfoil is a python class and no freecad stuff is involved. I would like to keep it this way to sepperate freecad dependent and non freecad dependent stuff.
...
Yes, finding the max curvature shouldn't be too hard. But the max curvature can be anywhere between 3 given points... Refining is not really possible for foils given by coordinates as an interpolation/approximation is necessary.
I had presumed you were using OCC to provide a discretization of the spline representing the airfoil, which should permit you to re-discretize at smaller intervals. Aren't you starting with a spline approximation?

My thinking on interpolation is simply that each segment represents the chord of the curve between those points. As the segments get smaller, the arc curvature approaches a constant, and the arc becomes circular.

So, unless you have a way to determine the end of the camber curve as @alberich suggests, won't you be forced to make approximations...?
Last edited by Joel_graff on Fri Dec 13, 2019 1:48 pm, edited 1 time in total.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: [WIP] airfoil workbench

Post by Joel_graff »

Just thinking about this some more...

https://www.physicsforums.com/threads/a ... us.507700/

Standard airfoil designs already have a parameterized curve worked out from which you can calculate the leading edge. That, there, is spline territory.

So, either you write your own curve parameterization routine / spline solver (which would probably mean implementing an approach found in a thesis or white paper) or you abstract that part away and allow for a dependency on a third party solver, whether it's OCC or scipy or something else.

Otherwise, without some way to iterate on the airfoil coordinates by regenerating discrete points along a spline / parameterized curve, I'm not really sure how else to approach this problem.

But then, I'm not an aeronautical engineer. If I knew one, I'd happily pick their brains on your behalf. ;)
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [WIP] airfoil workbench

Post by looo »

Joel_graff wrote: Fri Dec 13, 2019 1:04 pm
looo wrote: Fri Dec 13, 2019 8:22 am The airfoil is a python class and no freecad stuff is involved. I would like to keep it this way to sepperate freecad dependent and non freecad dependent stuff.
...
Yes, finding the max curvature shouldn't be too hard. But the max curvature can be anywhere between 3 given points... Refining is not really possible for foils given by coordinates as an interpolation/approximation is necessary.
I had presumed you were using OCC to provide a discretization of the spline representing the airfoil, which should permit you to re-discretize at smaller intervals. Aren't you starting with a spline approximation?

My thinking on interpolation is simply that each segment represents the chord of the curve between those points. As the segments get smaller, the curve will approach a circular arc. So, unless you have a way to determine the end of the camber curve as @alberich suggests, won't you be forced to make approximations...?
alberich wrote: Fri Dec 13, 2019 12:03 pm The smallest-x of the camber curve would be the leading edge, would it not?
Absolutely correct, but computing the tip of the camber-line and computing the leading edge is in principle the same task. Neither of them is given.

The real problem I would like to solve is the following:
Given an airfoil by coordinates (which are discrete points of a curve), find two bsplines which fit the coordinates as good as possible. But to start with the fitting the coordinates have to be normalized. This means that the trailing-edge should be aligned with (1, 0) and the leading edge with (0, 0). Now we need to define the leading edge. The max-curvature seems to work quite well, but as we are working with discrete points the result might be not the same as we expect by looking at the foil.
Bildschirmfoto von 2019-12-13 14-46-13.png
Bildschirmfoto von 2019-12-13 14-46-13.png (11.76 KiB) Viewed 1985 times


The yellow point in the image represent my intuitive interpolation (where I think the nose-index should be). The point chosen as the leading edge is the point with max curvature (computed by a circle which aligns with the point itself and the 2 neighbor points)
The difference between the chosen leading edge and the leading interpolated le is not much.

This problem has effect when eg. a jukowsky airfoil is computed with different number of coodinates. See this image:
Bildschirmfoto von 2019-12-13 14-58-00.png
Bildschirmfoto von 2019-12-13 14-58-00.png (17.69 KiB) Viewed 1985 times
So the number of coordinates have some influence on the aoa of the airfoil and therefor the lift-cooeficients will be different...

Anyway, I think there is no perfect solution for this, and going with the max-curvature is a already very good.
Joel_graff wrote: Fri Dec 13, 2019 1:44 pm Standard airfoil designs already have a parameterized curve worked out from which you can calculate the leading edge. That, there, is spline territory.
I guess you are talking about NACA airfoils. The problem is that NACA airfoils cannot represent any airfoil. This is why I would like to go with the b-spline airfoil which is somewhere between NACA-foils and foils given by coordinates. The splines have a fixed number of poles and most airfoils can be fitted.
Joel_graff wrote: Fri Dec 13, 2019 1:44 pm So, either you write your own curve parameterization routine / spline solver (which would probably mean implementing an approach found in a thesis or white paper) or you abstract that part away and allow for a dependency on a third party solver, whether it's OCC or scipy or something else.
Yes theoretically it's possible to create an approximation/interpolation first only to compute the leading-edge. Maybe this is something for the future. For now and for most use-cases the current max-curvature implementation is good enough I guess.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: [WIP] airfoil workbench

Post by Zolko »

looo wrote: Fri Dec 13, 2019 2:19 pm The real problem I would like to solve is the following:
Given an airfoil by coordinates...
...
But to start with the fitting the coordinates have to be normalized. This means that the trailing-edge should be aligned with (1, 0) and the leading edge with (0, 0)
what sort of coordinates are you using ? Mots airfoils come normalized like that, even though some don't include the exact (0,0) point.

looo wrote: Wed Dec 11, 2019 3:25 pm 2. optimizing spline foils (reducing drag with libxfoil)
3. interpolation of drag-computation with neural networks (not yet sure if this is a good idea)
What is it exactly that you're after ? You want to interface FreeCAD with X-foil and neural networks ?
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [WIP] airfoil workbench

Post by looo »

Zolko wrote: Fri Dec 13, 2019 5:09 pm what sort of coordinates are you using ? Mots airfoils come normalized like that, even though some don't include the exact (0,0) point.
There are a lot of airfoils available as .dat files. Eg. https://m-selig.ae.illinois.edu/ads/coord_database.html
Zolko wrote: Fri Dec 13, 2019 5:09 pm What is it exactly that you're after ? You want to interface FreeCAD with X-foil and neural networks ?
exactly. Libxfoil is a python wrapper for xfoil which allows to compute cl / cd / cm / alpha tables. For optimization you simple create an spline-foil create a target function (like minimizing drag over a range of different lift) and use an optimizer to find a better solution by dragging the spline points.

phpBB [video]


The neural network should work as a surrogate model which can predict /interpoalte the data. There are two ways how it can be used:
1. predict lift / drag from the poles (Actually I saw a paper where a neural network predicted the drag by an image of the airfoil)
2. predict lift / drag from a analyzed airfoil for Re / Ma / alpha which was not yet computed.

The surrogate-model is nice because it can be trained also with other computations (not only xfoil) and also with measurements from experiments.
montagdude
Posts: 54
Joined: Tue Jan 08, 2019 9:04 pm

Re: [WIP] airfoil workbench

Post by montagdude »

Looks really cool. Could this be used to smooth out "wiggles" in existing airfoils, i.e. ones generated by Xoptfoil?

https://github.com/montagdude/Xoptfoil
Post Reply