Public
Types
NeuralFoil.NetParameters — Type
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 valuescov_inputs_scaled::Matrix{Float}: from saved model valuesinv_cov_inputs_scaled::Matrix{Float}: from saved model valuesweights::Vector{Vector{Float}}}: from saved model valuesbiases::Vector{Vector{Float}}}: from saved model values
NeuralFoil.KulfanParameters — Type
KulfanParametersFields
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.
Methods
NeuralFoil.get_aero_from_kulfan_parameters — Function
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 degreesRe::Vector: Reynolds numbers
Keyword Arguments
n_crit::Float=9.0: n for e^n modelxtr_upper::Float=1.0: upper side laminar to turbulent forced transition locationxtr_lower::Float=1.0: lower side laminar to turbulent forced transition locationmodel_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 themodel_size.
Returns
outputs::NeuralOutputs: NeuralOutputs object containing the outputs of the neural net.
NeuralFoil.get_aero_from_coordinates — Function
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 degreesRe::Vector: Reynolds numbers
Keyword Arguments
n_crit::Float=9.0: n for e^n modelxtr_upper::Float=1.0: upper side laminar to turbulent forced transition locationxtr_lower::Float=1.0: lower side laminar to turbulent forced transition locationmodel_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 themodel_size.
Returns
outputs::NeuralOutputs: NeuralOutputs object containing the outputs of the neural net.
NeuralFoil.get_aero_from_dat_file — Function
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 filealpha::Vector: angles of attack in degreesRe::Vector: Reynolds numbers
Keyword Arguments
n_crit::Float=9.0: n for e^n modelxtr_upper::Float=1.0: upper side laminar to turbulent forced transition locationxtr_lower::Float=1.0: lower side laminar to turbulent forced transition locationmodel_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 themodel_size.
Returns
outputs::NeuralOutputs: NeuralOutputs object containing the outputs of the neural net.
Outputs
NeuralFoil.NeuralOutputs — Type
NeuralOutputsFields
analysis_confidence::Vector: confidence factor reported by NeuralFoilcl::Vector: lift coefficientscd::Vector: drag coefficientscm::Vector: moment coefficientstop_xtr::Vector: laminar to turbulent transition location of top surfacebot_xtr::Vector: laminar to turbulent transition location of bottom surfaceupper_bl_ue_over_vinf::Matrix: upper boundary layer normalized surface velocityupper_theta::Matrix: upper boundary layer momentum thicknessupper_H::Matrix: upper boundary layer shape factorlower_bl_ue_over_vinf::Matrix: lower boundary layer normalized surface velocitylower_theta::Matrix: lower boundary layer momentum thicknesslower_H::Matrix: lower boundary layer shape factor
Private
Neural Net Functions
NeuralFoil.net — Function
net(x, net_cache)Neural net
Arguments
x::Matrix{Float}: network inputsnet_cache::NetParameters: network parameters
Returns
y::Matrix{Float}: network outputs
NeuralFoil.swish — Function
swish(x)Swish activation function: x ./ (1.0 .+ exp.(-x))
CST Functions
NeuralFoil.get_kulfan_parameters — Function
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 sideN1::Float=0.5: Class function parameter for leading edgeN2::Float=1.0: Class function parameter for trailing edge
Returns
kulfan_parameters::KulfanParameters: a KulfanParameters object containing the Kulfan parameters.
NeuralFoil.cst — Function
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 edgeN2::Float=1.0: Class function parameter for trailing edge
Returns
y::Vector{Float}: y-coordinates associated with the x-coordinates
NeuralFoil.cst_te0 — Function
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 edgeN2::Float=1.0: Class function parameter for trailing edge
Returns
y::Vector{Float}: y-coordinates associated with the x-coordinates
NeuralFoil.half_cst — Function
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 parametersx::Vector{Float}: x-coordinates (front to back)dz::Float: Trailing edge gapleading_edge_weight::Float: Kulfan leading edge modification weight
Keyword Arguments
N1::Float=0.5: Class function parameter for leading edgeN2::Float=1.0: Class function parameter for trailing edge
Returns
y::Vector{Float}: y-coordinates
NeuralFoil.bernstein — Function
bernstein(r, n, x)Bernstein Basis Function: binomial(n, r) .* x .^ r .* (1 .- x) .^ (n .- r)
NACA 4-Series Functions
NeuralFoil.naca4 — Function
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 liest::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 notsplit::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.
NeuralFoil.naca4_camber — Function
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 chordlinemax_camber::Float64: Maximum camber valuemax_camber_pos::Float64: Position of maximum camber
NeuralFoil.naca4_thickness — Function
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=:squareemaxthick::Float: Maximum thickness value
Keyword Arguments
blunt_te::Bool: Flag whether trailing edge is blunt or not
Utility Functions
Neural Net Post-process Utilities
NeuralFoil.sigmoid — Function
sigmoid(x; ln_eps=log(10.0 / floatmax(Float64)))Sigmoid function: 1.0 / (1.0 + exp(-x))
NeuralFoil.squared_mahalanobis_distance — Function
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 scaledinputdistributioninv_cov_inputs_scaled::Matrix: from scaledinputdistribution
Returns:
sqmd::Vector: The squared Mahalanobis distance. Shape: (N_cases,)
Airfoil Utilities
NeuralFoil.get_coordinates_from_file — Function
get_coordinates_from_file(filename)Parse Selig style dat file into [x y] matrix of coordinates.
NeuralFoil.split_cosine_spacing — Function
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.
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
NeuralFoil.split_upper_lower — Function
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 coordinatesy::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 coordinatesxu::AbstractArray{Float}: Vector of upper half of x coordinatesyl::AbstractArray{Float}: Vector of lower half of y coordinatesyu::AbstractArray{Float}: Vector of upper half of y coordinates
Index
NeuralFoil.KulfanParametersNeuralFoil.NetParametersNeuralFoil.NeuralOutputsNeuralFoil.bernsteinNeuralFoil.cstNeuralFoil.cst_te0NeuralFoil.get_aero_from_coordinatesNeuralFoil.get_aero_from_dat_fileNeuralFoil.get_aero_from_kulfan_parametersNeuralFoil.get_coordinates_from_fileNeuralFoil.get_kulfan_parametersNeuralFoil.half_cstNeuralFoil.naca4NeuralFoil.naca4_camberNeuralFoil.naca4_thicknessNeuralFoil.netNeuralFoil.normalize_coordinates!NeuralFoil.sigmoidNeuralFoil.split_cosine_spacingNeuralFoil.split_upper_lowerNeuralFoil.squared_mahalanobis_distanceNeuralFoil.swish