Airfoil Class

class prefoil.airfoil.Airfoil(coords, spline_order=4, normalize=False, nCtl=None)[source]

A class for manipulating airfoil geometry.

Create an instance of an airfoil. There are two ways of instantiating this object: by passing in a set of points, or by reading in a coordinate file. The points must satisfy the following requirements:

  • Ordered such that they form a continuous airfoil surface

  • First and last points correspond to trailing edge

    • If the two points coincide, the airfoil will be considered sharp/round

    • Otherwise, a blunt (open) TE will be assumed

It is not necessary for the points to be in a counter-clockwise ordering. If they are not ordered counter-clockwise, the order will be reversed so that all functions can be written to expect the spline to begin at the upper surface of the trailing edge and end at the lower surface of the trailing edge.

See documentation in pySpline for information on the spline representation

Parameters
coordsndarray[N,3]

Full array of airfoil coordinates

spline_order{4, 2, 3}

Order of the spline. \(n\) order implies \(C^{n-2}\) continuity

normalizebool

True to normalize the chord of the airfoil, set to zero angle of attack, and move the leading edge to the origin

nCtlint

If this is set to an integer the underlying airfoil spline will be created using least mean squares (LMS) instead of interpolation. The number of control points used in the LMS will be equal to nCtl.

center()[source]

Move the airfoil so that the leading edge is at the origin

derotate(origin=numpy.zeros)[source]

derotates the airfoil about the origin by the twist

Parameters
originNdarray [2]

the location about which to preform the rotation

findPt(position, axis=0, s_0=0)[source]

finds that point at the intersection of the plane defined by the axis and the postion and the airfoil curve

Parameters
positionfloat

the position of the plane on the given axis

axisint

the axis the plane will intersect 0 for x and 1 for y

s_0float

an initial guess for the parameteric position of the solution

Returns
XNdarray [2]

The coordinate at the intersection

s_xfloat

the parametric location of the intersection

generateFFD(nffd, filename, fitted=True, xmargin=0.001, ymarginu=0.02, ymarginl=0.02, xslice=None, coords=None)[source]

Generates an FFD from the airfoil and writes it out to file

Parameters
nffdint

the number of chordwise points in the FFD

filenamestr

filename to write out, not including the ‘.xyz’ ending

fittedbool

flag to pick between a fitted FFD (True) and box FFD (False)

xmarginfloat

The closest distance of the FFD box to the tip and aft of the airfoil

ymarginufloat

When a box ffd is generated this specifies the top of the box’s y values as the maximum y value in the airfoil coordinates plus this margin. When a fitted ffd is generated this is the margin between the FFD point at an xslice location and the upper surface of the airfoil at this location

ymarginlfloat

When a box ffd is generated this specifies the bottom of the box’s y values as the minimum y value in the airfoil coordinates minus this margin. When a fitted ffd is generated this is the margin between the FFD point at an xslice location and the lower surface of the airfoil at this location

xsliceNdarray [N,2]

User specified xslice locations. If this is chosen nffd is ignored

coordsNdarray [N,2]

the coordinates to use for defining the airfoil, if the user does not want the original coordinates for the airfoil used. This shouldn’t be used unless the user wants fine tuned control over the FFD creation, It should be sufficient to ignore.

getCDistribution(nPts)[source]

Return the coordinates of the camber points

Parameters
nPtsint

The number of points to sample

Returns
camber_ptsNdarray [nPts, 2]

the locations of the camber points of the airfoil starting with the leading edge and ending with the trailing edge

getCamber()[source]

Calculates the camber spline defined by the airfoil

Returns
camberpySpline curve object

The spline that defines the camberline from s = 0 at the leading edge to s = 1 at the trailing edge.

getChord()[source]

Calculates the chord of the airfoil as the distance between the leading and trailing edges

Returns
chordfloat

The chord length

getLE()[source]

Calculates the leading edge point on the spline, which is defined as the point furthest away from the TE. The spline is assumed to start at the TE. The routine uses a root-finding algorithm to compute the LE.

Returns
LENdarray [2]

the coordinate of the leading edge

s_LEfloat

the parametric position of the leading edge

Notes

Let the TE be at point \(x_0, y_0\), then the Euclidean distance between the TE and any point on the airfoil spline is \(\ell(s) = \sqrt{\Delta x^2 + \Delta y^2}\), where \(\Delta x = x(s)-x_0\) and \(\Delta y = y(s)-y_0\). We know near the LE, this quantity is concave. Therefore, to find its maximum, we differentiate and use a root-finding algorithm on its derivative. \(\\frac{\mathrm{d}\ell}{\mathrm{d}s} = \\frac{\Delta x\\frac{\mathrm{d}x}{\mathrm{d}s} + \Delta y\\frac{\mathrm{d}y}{\mathrm{d}s}}{\ell}\)

The function dellds computes the quantity \(\Delta x\\frac{\mathrm{d}x}{\mathrm{d}s} + \Delta y\\frac{\mathrm{d}y}{\mathrm{d}s}\) which is then used by brentq to find its root, with an initial bracket at \([0.3, 0.7]\).

getLERadius()[source]

Computes the leading edge radius of the airfoil. Note that this is heavily dependent on the initialization points, as well as the spline order/smoothing.

Returns
LE_radfloat

The leading edge radius

getMaxCamber()[source]
Returns
x_locfloat

the x location of the maximum camber

max_camberfloat

the maximum camber of the airfoil

getMaxThickness(tType)[source]
Parameters
tTypestr

Can be one of ‘british’ or ‘american’

Returns
x_locfloat

The x station containing the maximum thickness

max_thicknessfloat

the maximum thickness of the airfoil

getMinCamber()[source]
Returns
x_locflaot

the x location of the maximum ngative camber

min_camberfloat

the maximum negative camber of the airfoil

getSampledPts(nPts, spacingFunc=<function polynomial>, func_args=None, nTEPts=0, TE_knot=False)[source]

This function defines the point sampling along the airfoil surface.

Parameters
nPts: int

Number of points to be sampled

spacingFunc: function

sampling function object. The methods available in prefoil.sampling are a good default example.

func_args: dictionary

Dictionary of input arguments for the sampling function.

nTEPts: float

Number of points along the blunt trailing edge

TE_knot: bool

If True, add a duplicate point between the lower airfoil surface and the TE to indicate that a knot is present. If there is a sharp or round trailing edge then this does nothing.

Returns
coordsNdarray [N, 2]

Coordinates array, anticlockwise, from trailing edge

getSplinePts()[source]

alias for returning the points that make the airfoil spline

Returns
XNdarry [N, 2]

the coordinates that define the airfoil spline

getTE()[source]

Calculates the trailing edge point on the spline

Returns
TE2darry [2]

The coordinate of the trailing edge of the airfoil

getTEAngle()[source]

Computes the trailing edge angle of the airfoil. We assume here that the spline goes from top to bottom, and that s=0 and s=1 corresponds to the top and bottom trailing edge points. Whether or not the airfoil is closed is irrelevant.

Returns
TE_anglefloat

The angle of the trailing edge in degrees

getTEThickness()[source]

gets the trailing edge thickness for the airfoil

Returns
TE_thicknessfloat

the trailing edge thickness

getThickness(nPts, tType)[source]

Computes the thicknesses at each x stations spaced linearly along the airfoil

Parameters
nPtsint

number of points to sample including the edge

tTypestr

either “american” or “british”

Returns
thickness_ptsNdarray [nPts, 2]

The thickness at each x station

getTwist()[source]

Calculates the twist of the airfoil using the leading and trailing edge points

Returns
twistfloat

The twist in degrees of the airfoil

isReflex()[source]

Determines if an airfoil is reflex by checking if the derivative of the camber line at the trailing edge is positive.

Returns
reflexivebool

True if reflexive

isSymmetric(tol=1e-06)[source]

Checks if an airfoil is symmetric

Parameters
tolfloat

tolerance for camber line to still be consdiered symmetrical

Returns
symmetricbool

True if the airfoil is symmetric within the given tolerance

makeBluntTE(xCut=0.98)[source]

This cuts the upper and lower surfaces to creates a blunt trailing edge perpendicular to the chord line.

Parameters
xCutfloat

the location to cut the blunt TE as a percentage of the chord

normalizeAirfoil(derotate=True, normalize=True, center=True)[source]

Sets the twist to zero, the chord to one, and the leading edge location to the origin

Parameters
derotatebool

True to set twist to zero

normalizebool

True to set the chord length to one

centerbool

True to put the leading edge at the origin

normalizeChord(origin=numpy.zeros)[source]

Set the chord to 1 by scaling the airfoil about the given origin

Parameters
originNdarray [2]

the point about which to scale the airfoil

plot(camber=False)[source]

Plots the airfoil. It tries to plot the most recently sampled set of points, but if none exists, it will plot the original set of coordinates.

Parameters
camberbool

True to plot the camber line

Returns
figmatplotlib.pyplot.Figure

The figure with the plotted airfoil

recompute(coords)[source]

Recomputes the underlying spline and relevant parameters from the given set of coordinates.

Parameters
coordsNdarray [N,2]

The coordinate pairs to compute the airfoil spline from

removeTE(tol=0.3, xtol=0.9)[source]

Removes points from the trailing edge of an airfoil, and recomputes the underlying spline.

Parameters
tolfloat

A point is part of the trailing edge if the magnitude of the dot product of the normalized vector of coord[i+1]-coord[i] and the normalized vector from the trailing edge to the leading edge is less than this tolerance. This means that decreasing the tolerance will require the orientation of an element to approach being perpendicular to the chord to be consider part of the trailing edge.

xtolfloat

Only checks for trailing edge points if the coodinate is past this fraction of the chord.

Returns
TE_pointsNdarray [N,2]

The points that were flagged as trailing edge points and removed from the airfoil coordinates.

reorder()[source]

This function orients the points counterclockwise and sets the start point to the TE

rotate(angle, origin=numpy.zeros)[source]

rotates the airfoil about the specified origin

Parameters
anglefloat

the angle to rotate the airfoil in degrees

originNdarray [2]

the point about which to rotate the airfoil

roundTE(xCut=0.98, k=4, nPts=20, dist=0.4)[source]

this method creates a smooth round trailing edge from a blunt one using a spline. If the trailing edge is not already blunt xCut specifies the location of the cut

Parameters
xCutfloat

x location of the cut as a percentage of the chord. Will not do anything if the TE is already blunt.

k: int (3 or 4)

order of the spline used to make the rounded trailing edge of the airfoil.

nPtsint

Number of trailing edge points to add to the airfoil spline

distfloat

Arbitrary factor that specifies how long to make the added TE. Larger dist corresponds to longer addition to the end

scale(factor, origin=numpy.zeros)[source]

Scale the airfoil by factor about the origin

Parameters
factorfloat

the scaling factor

originNdarray [2]

the coordinate about which to preform the scaling

sharpenTE(xCut=0.98)[source]

this method creates a sharp trailing edge from a blunt one by projecting straight lines from the upper and lower surfacs of a blunt trailing edge.

Parameters
xCutfloat

x location as a percentage of chord to cut off the current trailing edge if it is not already blunt.

splitAirfoil()[source]

Splits the airfoil into upper and lower surfaces

Returns
toppySpline curve object

A spline that defines the upper surface

bottompySpline curve object

A spline that defines the lower surface

translate(delta)[source]

Translate the airfoil by the vector delta

Parameters
deltaNdarray [2]

the vector that defines the translation of the airfoil

writeCoords(filename, coords=None, spline_coords=False, file_format='plot3d')[source]

Writes out a set of airfoil coordinates. By default, the most recently sampled coordinates are written out. If there are no recently sampled coordinates and none are passed in this will fail.

Parameters
filenamestr

the filename without extension to write to

coordsNdarray [N,2]

the coordinates to write out to a file. If None then the most recent sampled set of points is used.

spline_coordsbool

If true it will write out the underlying spline coordinates and the value of coords will be ignored. Useful if only geometric modifications to coordinates are being preformed.

file_formatstr

the file format to write, can be plot3d or dat