Aerofoil advice please - Points and Splines

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Grem1983
Posts: 2
Joined: Sat Nov 23, 2019 10:16 pm

Aerofoil advice please - Points and Splines

Postby Grem1983 » Sun Nov 24, 2019 8:03 pm

Hello all!
Great CAD system, seems to be competing well with the expensive ones!

I've been looking through the forum, and am now saturated with information!
I was wondering if someone could let me know the "best" way of doing what I'm after. I appreciate that there are several ways of doing something in CAD, but often some are a lot more efficient than others.

I have an aerofoil with several x-y co-ordinate points that are to be plotted, and a smooth curve (so a spline then) going through them all.
The leading edge is a specific radius.
My aim is to create the upper and lower curve, and make them both tangential to the leading edge radius. Then extrude to make a 3-D model.

I was wondering about using the point function in sketcher, but that means separately constraining the x-y co-ordinates. Works, but takes time.
The other option was the draft function, where I can type x-y co-ordinates for each point in one go.
That's great, but when I convert them to a sketch, the sketches are created, but the points don't follow (Using V0.18).

I was struggling to get the spline tangent to the leading edge radius, but as long as I click the end point of the spline, it seems to work. Tangential to splines seems to be a problem with many CAD systems. This one is one of the better ones!

Any information would be great. I'm writing this in a rush, so if I've missed something or not explained something very well, by all means let me know!

Many thanks!

Grem.
User avatar
wandererfan
Posts: 4078
Joined: Tue Nov 06, 2012 5:42 pm

Re: Aerofoil advice please - Points and Splines

Postby wandererfan » Mon Nov 25, 2019 2:37 pm

Grem1983 wrote:
Sun Nov 24, 2019 8:03 pm
I have an aerofoil with several x-y co-ordinate points that are to be plotted, and a smooth curve (so a spline then) going through them all.
Don't have any real advice for you, but is this macro for importing NACA profiles of any help?
practical
Posts: 31
Joined: Thu Oct 17, 2019 4:26 pm

Re: Aerofoil advice please - Points and Splines

Postby practical » Mon Nov 25, 2019 4:08 pm

I've not done this in FreeCAD, so I'm not sure how much help I can provide, but I have generated entire wings based on a few parameters and a discrete airfoil. These were just meshes though, not parametric solids.

Are you not able to loft with a spline in FreeCAD? I've never tried to, so I don't know. Thinking about it though, unless you need a full-scale wing, I wonder if a discrete airfoil would suffice. While the CFD programs I know of (xfoil, xflr5) let you design with splines, I'm pretty sure their analysis is based on an approximation of the original spline. If you do get this working with splines in FreeCAD, I'd love to see your results.
freedman
Posts: 1689
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Aerofoil advice please - Points and Splines

Postby freedman » Mon Nov 25, 2019 5:16 pm

Can't ou just make a series of sketches, maybe in code. Then do a loft.
Attachments
solid_wing.JPG
solid_wing.JPG (42.12 KiB) Viewed 713 times
Grem1983
Posts: 2
Joined: Sat Nov 23, 2019 10:16 pm

Re: Aerofoil advice please - Points and Splines

Postby Grem1983 » Tue Nov 26, 2019 8:35 pm

Many thanks for all the replies.
I perhaps should have said that I'm only constructing one wing rib for now, rather than creating one solid wing.
The idea would be to create many ribs, and assemble them all as a skeleton model. The wing I'm modelling is canvas covered, so I can't just loft the solid wing, I want to model the wing with the canvas removed.
Also, I'm modelling it full-size, creating a 3D model from 2D drawings.

I guess this next question is an age-old question for FreeCAD, but would it be better to use Draft of Sketcher for what I'm doing? It appears that there's a large overlap between the two. Maybe as a result of development over the years?

How would I input the points, complete with x-y co-ordinates, using code? I've got quite a few for both top and bottom curves, so if this is the most efficient method of inserting and constraining the points, it would be good.
It's a shame I can't insert, and constrain a point in one go in Sketcher, by typing in the x-y co-ordinates.

I have a workaround if necessary, but information is always good. :)

Thanks again.
triops
Posts: 3
Joined: Tue Nov 26, 2019 8:47 pm

Re: Aerofoil advice please - Points and Splines

Postby triops » Wed Nov 27, 2019 5:25 am

Hi,

I wrote a smal macro for me which pretty does most of this what you want I think. In general it works as follows.

You create a spreadsheet with information on where the profile file (.dat / .txt) is located on your mashine (you can get airfoil sections for example from airfoiltools.com), the desired length of the wing, the desired chord length of the root profile, a pre-ballance facror to move the pressure point closer to the x-axis (important for rudder blades) as well as a number of discretizations (this will refine the distance between the created sections towards the tip for a better resolution).

By executing the macro it just creates a bunch of sections, lofts all of these and adds some root and tip faces to close the structure. Maybe you can give it a try or take some code snippets or modify it to your best.

The spreadsheet must have the following structure (alias names are given in quotes):
spreadsheet.png
spreadsheet.png (6.53 KiB) Viewed 653 times
The given values are just an example and can be modified for your needs.


The code for the macro is as follows:

Code: Select all


doc = App.ActiveDocument
gui = FreeCADGui.ActiveDocument

import Draft
import Part
import math
from FreeCAD import Base

# Getting the handle to the EllipticalWing_Config sheet
config = config = App.activeDocument().getObject('Spreadsheet')

# Reading in the file for the profile line by line
f = open(config.file, "r")
content = [x.strip() for x in f.readlines()] 

''' Creating a list of coordinate points for the B-Spline. 
If the first enty of content can't be converted into a float, 
than it's the profile name which has to be removed. '''
try:
	float(content[0].split()[0])
except:
	del content[0]

points = []
for x in content:
	points.append(FreeCAD.Vector(float(x.split()[0]),float(x.split()[1]),0.0))

''' Placing the first point just a cut over the last one. 
The profile starts at the upper side of the trailing edge and ends at the lower side. 
If the first point falls together with the last point, 
the spline will be closed with a continuouse curve, resulting in a non sharp edge. 
After the spline was creaded, the points will be changed again, that they match. '''
points[0] = FreeCAD.Vector(points[-1][0],points[-1][1],points[-1][2]+0.00001)

# Drawing the spline
spline = Draft.makeBSpline(points,closed=False,face=False,support=None)

# Changing the points of the trailing edge back that they match.
points[0] = points[-1]
spline.Points = points

# Scaling the spline that it fits the given chord length
section = Draft.scale([spline],delta=FreeCAD.Vector(config.chord,config.chord,1.0),\
          center=FreeCAD.Vector(0.0,0.0,0.0),copy=False,legacy=True)

# Moving the section a bit forward for ballancing 
max_ballance = config.chord * config.ballance
Draft.move([section],FreeCAD.Vector(-max_ballance,0.0,0.0),copy=False)

# Turning of the visibility of the section
gui.getObject(section.Label).Visibility = False

# Assigning the created section to a list of sections
sections = [section]

# Creating n-1 other sections which can be lofted afterwards
n = int(config.discretization)
for i in range(1, n):
	distance = config.length * math.sin( 90*math.pi/180 / n * i)**0.65
	scale_factor = math.sqrt(1 - (distance**2 / config.length**2))
	section = Draft.scale([spline],delta=FreeCAD.Vector(scale_factor,scale_factor,1.0),\
              center=FreeCAD.Vector(0.0,0.0,-distance),copy=True,legacy=True)
	Draft.move([section],FreeCAD.Vector((1 - scale_factor)*max_ballance,0.0,0.0),copy=False)
	gui.getObject(section.Label).Visibility = False
	sections.append(section)

# Creating a lofted surface from the list of sections
loft = doc.addObject('Part::Loft','Loft')
loft.Sections = sections
loft.Closed=False
loft.Solid=False
loft.Ruled=False

# Creating a face from the first and from the last section
root = App.ActiveDocument.addObject('Part::Feature','Root').Shape = \
       Part.makeFilledFace(Part.__sortEdges__([sections[0].Shape.Edge1, ]))
tip = App.ActiveDocument.addObject('Part::Feature','Tip').Shape = \
      Part.makeFilledFace(Part.__sortEdges__([sections[-1].Shape.Edge1, ]))

# Changing the tesselation of the surfaces
gui.getObject(loft.Label).Deviation = 0.01
gui.getObject(root.Label).Deviation = 0.01
gui.getObject(tip.Label).Deviation = 0.01

# Recompute the whole object to show it
doc.recompute()


Here is an example FreeCAD file:
EllipticalWing.FCStd
(1.65 KiB) Downloaded 25 times
This is my example result after some seconds:
result.png
result.png (101.04 KiB) Viewed 653 times


Hope this helps you.

Best, Nico
Last edited by triops on Wed Nov 27, 2019 5:30 am, edited 1 time in total.
freedman
Posts: 1689
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Aerofoil advice please - Points and Splines

Postby freedman » Wed Nov 27, 2019 5:26 am

I say learn to use Sketcher. Once you learn to sketch then you can turn the sketch into a 3D rib.
chrisb
Posts: 29010
Joined: Tue Mar 17, 2015 9:14 am

Re: Aerofoil advice please - Points and Splines

Postby chrisb » Wed Nov 27, 2019 7:07 am

This macro sounds as if it can very well go into the AirplaneDesign workbench (of which I know nothing more than that it exists).
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
User avatar
Kunda1
Posts: 8739
Joined: Thu Jan 05, 2017 9:03 pm

Re: Aerofoil advice please - Points and Splines

Postby Kunda1 » Thu Nov 28, 2019 11:55 am

a179308 wrote::bell:
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
hbquax
Posts: 4
Joined: Sun Nov 11, 2018 10:10 am
Location: Köln

Re: Aerofoil advice please - Points and Splines

Postby hbquax » Sat Dec 07, 2019 10:37 am

I have spent some time creating aircraft geometries in CAD, here is some general advice based on my personal experience:

1. Airfoil geometry is usually given in nondimensional coordinates (x/l & z/l). This means that X ranges from 0 to 1, and Z has an even smaller range, depending on thickness ratio. Not sure about FreeCad, but the default dimension for length in CATIA is mm, with a resolution of 1/1000 mm. So with nondimensional coordinates, you have at most three digits of resolution lengthwise, and much less in thickness direction, which is clearly not enough. Solution: Scale your coordinates up before import by at least a factor of 1000.
2. Even with higher resolution, there is limited accuracy. A spline is a mathematical function forced to go through all your points. This introduces some mathematical oscillations. Solution: You need to smooth the initial spline. The result will deviate from some of your imported points very slightly, but produce a smooth curve. (This is the digital equivalent to hand sanding a physical model until the surface feels smooth!). You can do a curvature analysis to both curves to see the improvement. You also have to keep in mind that your initial geometry is never perfectly accurate either, due to a limited number of digits and other factors. A very large number of points doesn't necessarly mean the data is very precise...
3. When creating splines, it is best to make a single spline which begins and ends at the trailing edge. Don't do separate splines for upper and lower side, this will result in bad geometry at the nose.

Viel Erfolg!
Nils