Public

Types

NeuralFoil.NetParametersType
NetParameters(; model_size="xlarge")

Constructor for NetParameters type.

Keyword Arguments

  • model_size::String="xlarge" : NeuralFoil model size, choose from:
    • "xxsmall"
    • "xsmall"
    • "small"
    • "medium"
    • "large"
    • "xlarge"
    • "xxlarge"
    • "xxxlarge"

Returns

  • net_cache::NetParameters : NetParameters method object with fields:

NetParameters Object Fields:

  • mean_inputs_scaled::Vector{Float} : from saved model values
  • cov_inputs_scaled::Matrix{Float}: from saved model values
  • inv_cov_inputs_scaled::Matrix{Float}: from saved model values
  • weights::Vector{Vector{Float}}}: from saved model values
  • biases::Vector{Vector{Float}}}: from saved model values
source
NeuralFoil.KulfanParametersType
KulfanParameters

Fields

  • upper_weights::Vector{Float} : upper side weights (length 8)
  • lower_weights::Vector{Float} : lower side weights (length 8)
  • leading_edge_weight::Vector{Float} : weight for leading edge thickness (length 1)
  • TE_thickness::Vector{Float} : trailing edge thickness (length 1)

Note: for optimization purposes in Julia, it is convenient to have all fields as arrays.

source

Methods

NeuralFoil.get_aero_from_kulfan_parametersFunction
get_aero_from_coordinates(
    kulfan_parameters,
    alpha,
    Re;
    n_crit=9.0,
    xtr_upper=1.0,
    xtr_lower=1.0,
    model_size="xlarge",
    net_cache=nothing,
)

Determine aerodynamic properties of an airfoil given Kulfan parameters.

Arguments

  • kulfan_parameters::KulfanParameters : KulfanParameters object containig upper and lower weights, leading edge weight, and trailing edge thickness inputs to the neural net.
  • alpha::Vector : angles of attack in degrees
  • Re::Vector : Reynolds numbers

Keyword Arguments

  • n_crit::Float=9.0 : n for e^n model
  • xtr_upper::Float=1.0 : upper side laminar to turbulent forced transition location
  • xtr_lower::Float=1.0 : lower side laminar to turbulent forced transition location
  • model_size::String="xlarge" : NeuralFoil model size. Choose from
    • "xxsmall"
    • "xsmall"
    • "small"
    • "medium"
    • "large"
    • "xlarge"
    • "xxlarge"
    • "xxxlarge"
  • net_cache::NetParameters=nothing : Neural net parameters, if not provided, is generated based on the model_size.

Returns

  • outputs::NeuralOutputs : NeuralOutputs object containing the outputs of the neural net.
source
NeuralFoil.get_aero_from_coordinatesFunction
get_aero_from_coordinates(
    coordinates,
    alpha,
    Re;
    n_crit=9.0,
    xtr_upper=1.0,
    xtr_lower=1.0,
    model_size="xlarge",
    net_cache=nothing,
)

Determine aerodynamic properties of an airfoil given airfoil coordinates.

Determines Kulfan parameters from coordinates and calls get_aero_from_kulfan_parameters.

Arguments

  • coordinates::Matrix{Float} : [x y] coordintes (counter-clockwise starting at upper side trailing edge)
  • alpha::Vector : angles of attack in degrees
  • Re::Vector : Reynolds numbers

Keyword Arguments

  • n_crit::Float=9.0 : n for e^n model
  • xtr_upper::Float=1.0 : upper side laminar to turbulent forced transition location
  • xtr_lower::Float=1.0 : lower side laminar to turbulent forced transition location
  • model_size::String="xlarge" : NeuralFoil model size. Choose from
    • "xxsmall"
    • "xsmall"
    • "small"
    • "medium"
    • "large"
    • "xlarge"
    • "xxlarge"
    • "xxxlarge"
  • net_cache::NetParameters=nothing : Neural net parameters, if not provided, is generated based on the model_size.

Returns

  • outputs::NeuralOutputs : NeuralOutputs object containing the outputs of the neural net.
source
NeuralFoil.get_aero_from_dat_fileFunction
get_aero_from_dat_file(
    filename,
    alpha,
    Re;
    n_crit=9.0,
    xtr_upper=1.0,
    xtr_lower=1.0,
    model_size="xlarge",
    net_cache=nothing,
)

Determine aerodynamic properties of an airfoil given in a .dat file.

Reads in coordinates and calls get_aero_from_coordinates.

Arguments

  • filename::String : name (including path) of Selig style coordinate file
  • alpha::Vector : angles of attack in degrees
  • Re::Vector : Reynolds numbers

Keyword Arguments

  • n_crit::Float=9.0 : n for e^n model
  • xtr_upper::Float=1.0 : upper side laminar to turbulent forced transition location
  • xtr_lower::Float=1.0 : lower side laminar to turbulent forced transition location
  • model_size::String="xlarge" : NeuralFoil model size. Choose from
    • "xxsmall"
    • "xsmall"
    • "small"
    • "medium"
    • "large"
    • "xlarge"
    • "xxlarge"
    • "xxxlarge"
  • net_cache::NetParameters=nothing : Neural net parameters, if not provided, is generated based on the model_size.

Returns

  • outputs::NeuralOutputs : NeuralOutputs object containing the outputs of the neural net.
source

Outputs

NeuralFoil.NeuralOutputsType
NeuralOutputs

Fields

  • analysis_confidence::Vector : confidence factor reported by NeuralFoil
  • cl::Vector : lift coefficients
  • cd::Vector : drag coefficients
  • cm::Vector : moment coefficients
  • top_xtr::Vector : laminar to turbulent transition location of top surface
  • bot_xtr::Vector : laminar to turbulent transition location of bottom surface
  • upper_bl_ue_over_vinf::Matrix : upper boundary layer normalized surface velocity
  • upper_theta::Matrix : upper boundary layer momentum thickness
  • upper_H::Matrix : upper boundary layer shape factor
  • lower_bl_ue_over_vinf::Matrix : lower boundary layer normalized surface velocity
  • lower_theta::Matrix : lower boundary layer momentum thickness
  • lower_H::Matrix : lower boundary layer shape factor
source

Private

Neural Net Functions

NeuralFoil.netFunction
net(x, net_cache)

Neural net

Arguments

  • x::Matrix{Float} : network inputs
  • net_cache::NetParameters : network parameters

Returns

  • y::Matrix{Float} : network outputs
source

CST Functions

NeuralFoil.get_kulfan_parametersFunction
get_kulfan_parameters(coordinates; n_coefficients=8, N1=0.5, N2=1.0)

Use least squares to approximate kulfan parameters generating the input coordinates.

Arguments

  • coordinates::Matrix{Float} : [x y] coordinates for which to find the Kulfan paramters

Keyword Arguments

  • n_coefficients::Int=8 : Number of coefficients to use per side
  • N1::Float=0.5 : Class function parameter for leading edge
  • N2::Float=1.0 : Class function parameter for trailing edge

Returns

  • kulfan_parameters::KulfanParameters : a KulfanParameters object containing the Kulfan parameters.
source
NeuralFoil.cstFunction
cst(x, p; N1=0.5, N2=1.0)

Determine y-coordinates of one side of an airfoil give coeffiecients and x coordinates.

Arguments

  • x::Vector{Float} : x-coordinates (concatenated top and bottom)
  • p::Vector{Float} : parameters including Kulfan parameters, leading edge weight, and trailing edge gap.

Keyword Arguments

  • N1::Float=0.5 : Class function parameter for leading edge
  • N2::Float=1.0 : Class function parameter for trailing edge

Returns

  • y::Vector{Float} : y-coordinates associated with the x-coordinates
source
NeuralFoil.cst_te0Function
cst_te0(x, p; N1=0.5, N2=1.0)

Determine y-coordinates of one side of an airfoil give coeffiecients and x coordinates. Require a zero gap trailing edge

Arguments

  • x::Vector{Float} : x-coordinates (concatenated top and bottom)
  • p::Vector{Float} : parameters including Kulfan parameters, leading edge weight, and trailing edge gap.

Keyword Arguments

  • N1::Float=0.5 : Class function parameter for leading edge
  • N2::Float=1.0 : Class function parameter for trailing edge

Returns

  • y::Vector{Float} : y-coordinates associated with the x-coordinates
source
NeuralFoil.half_cstFunction
half_cst(coefficients, x, dz, leading_edge_weight; N1=0.5, N2=1.0)

Determine y-coordinates of one side of an airfoil give coeffiecients and x coordinates.

Arguments

  • coefficients::Vector{Float} : Kulfan parameters
  • x::Vector{Float} : x-coordinates (front to back)
  • dz::Float : Trailing edge gap
  • leading_edge_weight::Float : Kulfan leading edge modification weight

Keyword Arguments

  • N1::Float=0.5 : Class function parameter for leading edge
  • N2::Float=1.0 : Class function parameter for trailing edge

Returns

  • y::Vector{Float} : y-coordinates
source
NeuralFoil.bernsteinFunction
bernstein(r, n, x)

Bernstein Basis Function: binomial(n, r) .* x .^ r .* (1 .- x) .^ (n .- r)

source

NACA 4-Series Functions

NeuralFoil.naca4Function
naca4(c=2.0, p=4.0, t=12.0; N=161, x=nothing, blunt_te=false, split=false)

Compute x, z airfoil coordinates for N nodes, based on NACA 4-Series Parameterization.

Arguments

  • c::Float : Maximum camber value (percent of chord)
  • p::Float : Position along chord (in 10ths of chord) where maximum naca4_camber lies
  • t::Float : Maximum thickness of airfoil in percent chord

Keyword Arguments

  • N::Int : Total number of coordinates to use. This values should be odd, but if not, the number of points returned will be N-1.
  • x::AbstractArray{Float} : x-coordinates (cosine spaced coordinates used by default)
  • blunt_te::Bool : Flag whether trailing edge is blunt or not
  • split::Bool : Flag wheter to split into upper and lower halves.

Returns

If split == false:

  • x::AbstractArray{Float} : Vector of x coordinates, clockwise from trailing edge.
  • z::AbstractArray{Float} : Vector of z coordinates, clockwise from trailing edge.

If split == true:

  • xl::AbstractArray{Float} : Vector of lower half of x coordinates from trailing edge to leading edge.
  • xu::AbstractArray{Float} : Vector of upper half of x coordinates from leading edge to trailing edge.
  • zl::AbstractArray{Float} : Vector of lower half of z coordinates from trailing edge to leading edge.
  • zu::AbstractArray{Float} : Vector of upper half of z coordinates from leading edge to trailing edge.
source
NeuralFoil.naca4_camberFunction
naca4_camber(x, max_camber, max_camber_pos)

Compute camber at a given chord-normalized x-position by NACA 4-series camber equations.

Arguments

  • x::Float : x position along chordline
  • max_camber::Float64 : Maximum camber value
  • max_camber_pos::Float64 : Position of maximum camber
source
NeuralFoil.naca4_thicknessFunction
naca4_thickness(x, maxthick; blunt_te=false)

Compute thickness at a given chord-normalized x-position by NACA 4-series thickness equations.

Arguments

  • x::Float : x position along chordlin, markersize=3, markershape=:squaree
  • maxthick::Float : Maximum thickness value

Keyword Arguments

  • blunt_te::Bool : Flag whether trailing edge is blunt or not
source

Utility Functions

Neural Net Post-process Utilities

NeuralFoil.sigmoidFunction
sigmoid(x; ln_eps=log(10.0 / floatmax(Float64)))

Sigmoid function: 1.0 / (1.0 + exp(-x))

source
NeuralFoil.squared_mahalanobis_distanceFunction
squared_mahalanobis_distance(x::AbstractMatrix)

Computes the squared Mahalanobis distance of a set of points from the training data.

Arguments:

  • x::Matrix: Query point in the input latent space. Shape: (Ncases, Ninputs) For non-vectorized queries, N_cases=1.
  • mean_inputs_scaled::Vector : from scaledinputdistribution
  • inv_cov_inputs_scaled::Matrix : from scaledinputdistribution

Returns:

  • sqmd::Vector : The squared Mahalanobis distance. Shape: (N_cases,)
source

Airfoil Utilities

NeuralFoil.split_cosine_spacingFunction
split_cosine_spacing(N::Integer=160)

Returns cosine spaced x coordinates from 0 to 1.

Arguments

  • N::Integer : Number of points.

Returns

  • x::AbstractArray{Float} : cosine spaced x-coordinates, starting at 0.0 ending at 1.0.
source
NeuralFoil.normalize_coordinates!Function
normalize_coordinates!(coordinates)

Normalize airfoil to unit chord and shift leading edge to zero. Adjusts coordinates in place.

Arguments:

  • coordinates::Array{Float} : Array of [x y] coordinates
source
NeuralFoil.split_upper_lowerFunction
split_upper_lower(x, y; idx::Integer=nothing)

Split the upper and lower halves of the airfoil coordinates.

Assumes leading edge point is at first minimum x value if idx is not provided. Returns the upper and lower coordinates each with the leading edge point. Assumes airfoil is defined clockwise starting at the trailing edge.

Arguments:

  • x::AbstractArray{Float} : Vector of x coordinates
  • y::AbstractArray{Float} : Vector of y coordinates

Keyword Arguments:

  • idx::Integer : optional index at which to split the coordinates

Returns:

  • xl::AbstractArray{Float} : Vector of lower half of x coordinates
  • xu::AbstractArray{Float} : Vector of upper half of x coordinates
  • yl::AbstractArray{Float} : Vector of lower half of y coordinates
  • yu::AbstractArray{Float} : Vector of upper half of y coordinates
source

Index