Utility Functions

I/O

exception prefoil.utils.io.Error(message)[source]

Formats error messages to make it clear that it was explicitly raised by prefoil.

prefoil.utils.io.readCoordFile(filename, headerlines=0)[source]

This function reads in a ‘.dat’ style airfoil coordinate file, with each coordinate on a new line and each line containing an xy pair separate by whitespace

Parameters
filenamestr

the file to read from

headerlinesint

the number of lines to skip at the beginning of the file to reach the coordinates

Returns
XNdarray [N,2]

The coordinates read from the file

Geometry Helpers

prefoil.utils.geom_ops.checkCellRatio(X, ratio_tol=1.2)[source]

Checks a set of coordinates for consecutive cell ratios that exceed a given tolerance

Parameters
XNdarray [N,2]

The set of coordinates being checked

ratio_tolfloat

The maximum cell ratio that is allowed

Returns
cell_ratioNdarray [N]

the cell ratios for each cell

max_cell_ratiofloat

the maximum cell ratio

avg_cell_ratiofloat

the average cell ratio

excNdarray

the cell indicies that exceed the ratio tolerance

prefoil.utils.geom_ops.generateNACA(code, nPts, spacingFunc=<function cosine>, func_args=None)[source]

This function generates airfoil coordinates from the analytical definition of the NACA airfoils. It currently only supports 4 digit series airfoils.

Parameters
codestr

The 4 digit code, this is expected to be a length four string

nPtsint

The number of points to sample from the defintion of the NACA airfoil, half will be sampled on the top and half on the bottom

spacingFunccallable

The spacing function to use for determining the sampling point locations of the x coordinates of the camber line

func_argsdict

Arguments to pass to the sampling function when it is called

Returns
afNdarray [N,2]

Coordinates that were sampled from the NACA 4-digit code

Sampling Functions