Objectives
Here we will show you how to perform an aerodynamic analysis of an airfoil.
Recipe
- Compute the coordinates of a NACA 4-digit series airfoil.
- Plot its camber, thickness, upper and lower surface representations.
- Perform an aerodynamic analysis at a given angle of attack.
- Plot its aerodynamic properties.
For this, we will need to import some packages which will be convenient for plotting.
using AeroFuse # Main package
using Plots # Plotting library
gr(dpi = 300) # Plotting backend
using LaTeXStrings # For LaTeX printing in plots
Your First Airfoil
You can define a NACA 4-digit series airfoil using the following function.
airfoil = naca4((2,4,1,2), 60)
NACA 2412 Foil{Float64} with 119 points.
You can access the $x$- and $y$-coordinates as the following fields.
airfoil.x, airfoil.y
([1.0, 0.9992981882625027, 0.9971946084073808, 0.9936948246213843, 0.9888081041263779, 0.9825474070711719, 0.9749293714656669, 0.9659742923191958, 0.9557060940082984, 0.9441522948292751 … 0.9431997802272964, 0.9549286788466147, 0.9653618851331425, 0.9744682370027143, 0.9822204617433441, 0.9885952856914888, 0.9935735300999603, 0.9971401918027563, 0.9992845074142591, 1.0], [-1.6616460838224803e-17, 0.00014994327027663046, 0.0005984546661103868, 0.0013416010129608839, 0.002372899768779709, 0.0036834253181048772, 0.005261952261861909, 0.007095130492785934, 0.009167685786814105, 0.011462638875020038 … -0.004305264850848705, -0.0034318413055497835, -0.002648506782021171, -0.001959587327218415, -0.0013690972131801405, -0.00088064261196314, -0.0004973272941477818, -0.00022166619369339412, -5.551211404810675e-5, 1.6616460838224803e-17])
You can obtain the coordinates as an array by calling the following function.
coordinates(airfoil)
119×2 Matrix{Float64}:
1.0 -1.66165e-17
0.999298 0.000149943
0.997195 0.000598455
0.993695 0.0013416
0.988808 0.0023729
0.982547 0.00368343
0.974929 0.00526195
0.965974 0.00709513
0.955706 0.00916769
0.944152 0.0114626
⋮
0.954929 -0.00343184
0.965362 -0.00264851
0.974468 -0.00195959
0.98222 -0.0013691
0.988595 -0.000880643
0.993574 -0.000497327
0.99714 -0.000221666
0.999285 -5.55121e-5
1.0 1.66165e-17
Geometric Representations
You can convert these coordinates into the camber-thickness representation.
xcamthick = camber_thickness(airfoil, 60)
61×3 Matrix{Float64}:
0.0 0.0 0.0
0.000685233 0.00165715 0.00867606
0.00273905 0.0017672 0.0180042
0.00615583 0.00203342 0.0269113
0.0109262 0.00242718 0.0355243
0.0170371 0.00293959 0.0438502
0.0244717 0.00356255 0.0518745
0.0332098 0.00428708 0.0595753
0.0432273 0.00510318 0.066927
0.0544967 0.0059998 0.0739022
⋮
0.956773 0.0028295 0.0122458
0.96679 0.00219383 0.00946855
0.975528 0.00162951 0.0070167
0.982963 0.00114212 0.00490866
0.989074 0.000736515 0.00316062
0.993844 0.000416739 0.0017863
0.997261 0.000186 0.00079662
0.999315 4.66184e-5 0.000199565
1.0 0.0 -3.32329e-17
You can split the coordinates into their upper and lower surfaces.
upper, lower = split_surface(airfoil);
x_upper, y_upper = @views upper[:,1], upper[:,2]
x_lower, y_lower = @views lower[:,1], lower[:,2];
Plotting
You can plot the airfoil by calling plot
from Plots.jl
and passing the Foil
object as the first argument. Optionally, you can enable flags to plot the camber and thickness distributions.
plot(
airfoil,
camber = true,
thickness = true,
aspect_ratio = 1,
xlabel=L"(x/c)",
ylabel = L"y"
)
Your First Doublet-Source Analysis
Now we have an airfoil, and we would like to analyze its aerodynamic characteristics. The potential flow panel method for inviscid analyses of airfoils, which you may have studied in your course on aerodynamics, provides decent estimations of the lift generated by the airfoil.
Our analysis also requires boundary conditions, which is the freestream flow defined by a magnitude $V_\infty$ and angle of attack $\alpha$. We provide these to the analysis by defining variables and feeding them to a Uniform2D
type, corresponding to uniform flow in 2 dimensions.
V = 1.0
alpha = 4.0 # degrees
uniform = Uniform2D(V, alpha)
Uniform2D{Float64}(1.0, 0.06981317007977318)
You can analyze this airfoil for the given freestream flow as shown.
system = solve_case(
airfoil, uniform;
num_panels = 80
);
This will run the analysis and return a system which can be used to obtain the aerodynamic quantities of interest and post-processing. The panels used for the analysis can be accessed as follows.
panels = system.surface_panels
78-element view(::Vector{Panel2D{Float64}}, 78:-1:1) with eltype Panel2D{Float64}:
Panel2D{Float64}([1.0, 1.6616460838224803e-17], [0.9983786540671049, -0.00012570291449866332])
Panel2D{Float64}([0.9983786540671049, -0.00012570291449866332], [0.9935251313189564, -0.0005010539079096189])
Panel2D{Float64}([0.9935251313189564, -0.0005010539079096189], [0.985470908713026, -0.0011200400170492484])
Panel2D{Float64}([0.985470908713026, -0.0011200400170492484], [0.9742682209735727, -0.001974719065561243])
Panel2D{Float64}([0.9742682209735727, -0.001974719065561243], [0.9599897218294121, -0.0030518536407216934])
Panel2D{Float64}([0.9599897218294121, -0.0030518536407216934], [0.9427280128266049, -0.004340093269408703])
Panel2D{Float64}([0.9427280128266049, -0.004340093269408703], [0.9225950427718974, -0.005821397857625334])
Panel2D{Float64}([0.9225950427718974, -0.005821397857625334], [0.8997213817017505, -0.0074835618802499525])
Panel2D{Float64}([0.8997213817017505, -0.0074835618802499525], [0.8742553740855505, -0.00930660513155278])
Panel2D{Float64}([0.8742553740855505, -0.00930660513155278], [0.8463621767547997, -0.011278505974986367])
⋮
Panel2D{Float64}([0.8742553740855505, 0.024528991290121795], [0.8997213817017505, 0.01992712863731834])
Panel2D{Float64}([0.8997213817017505, 0.01992712863731834], [0.9225950427718974, 0.015634911050710687])
Panel2D{Float64}([0.9225950427718974, 0.015634911050710687], [0.9427280128266049, 0.01174051529843651])
Panel2D{Float64}([0.9427280128266049, 0.01174051529843651], [0.9599897218294121, 0.008303069108260726])
Panel2D{Float64}([0.9599897218294121, 0.008303069108260726], [0.9742682209735727, 0.005397295196262384])
Panel2D{Float64}([0.9742682209735727, 0.005397295196262384], [0.985470908713026, 0.0030714609375638983])
Panel2D{Float64}([0.985470908713026, 0.0030714609375638983], [0.9935251313189564, 0.0013774132702494887])
Panel2D{Float64}([0.9935251313189564, 0.0013774132702494887], [0.9983786540671049, 0.00034600027495394753])
Panel2D{Float64}([0.9983786540671049, 0.00034600027495394753], [1.0, -1.6616460838224803e-17])
You can compute the lift coefficient from the system.
cl = lift_coefficient(system)
0.7127871936238398
You can also compute the sectional lift, moment and pressure coefficients.
cls, cms, cps = surface_coefficients(system)
([0.0012701252075150225, 0.0019206412409880993, 0.002320332158513812, 0.0026345844299854684, 0.002901018757609892, 0.003110961939507397, 0.003279271589172203, 0.003398731138494789, 0.003490577088470696, 0.003544674498839626 … 0.004071006912727737, 0.002553118391231324, 0.001226397404961188, 5.943071294530485e-5, -0.0008734792485322162, -0.001592753969975974, -0.0020340330255412937, -0.002188568822560695, -0.001977049557973509, -0.0012850621154426784], [-0.001264976950387672, -0.0019035570488642813, -0.002281049749759667, -0.0025605393095797877, -0.0027781641963196524, -0.0029256468358164413, -0.0030180698929924547, -0.0030504621582683315, -0.003044222098155253, -0.002992770384465919 … -0.003437153094693458, -0.0022266402456672845, -0.0011007281018672794, -5.46969168554226e-5, 0.0008214474652249358, 0.001525302806583325, 0.00197686643085138, 0.002151517120820944, 0.0019594636112772105, 0.0012798533138569986], [0.3923231560578939, 0.2975910175373142, 0.2409826735818793, 0.20678079024298412, 0.18395185193918018, 0.1663793304141825, 0.15249603856873495, 0.14061358337950358, 0.13082924224840686, 0.12215717981662699 … -0.14039643463905027, -0.09575579955387314, -0.050774173779668086, -0.0027653672644960547, 0.04674405527490677, 0.10104527417098685, 0.15972255924403955, 0.2273742896728842, 0.30641978613246157, 0.396992712960727])
Note the difference between the lift coefficient computed and the sum of the sectional lift coefficients; this is due to numerical errors in the solution procedure and modeling.
cl, sum(cls)
(0.7127871936238398, 0.7121901349529233)
Support for drag prediction with boundary layer calculations will be added soon. For now, try out the amazing Webfoil developed by the MDOLab at University of Michigan – Ann Arbor!
Visualization
Let's see what the pressure and lift distribution curves look like over the airfoil. AeroFuse provides more helper functions for post-processing data. For example, you can make your fancy plots by segregating the values depending on the locations of the panels by defining the following function.
cp_upper, cp_lower = get_surface_values(panels, cps)
([(0.0008106729664475176, 0.15332616324590354), (0.004048107306969306, -0.8925692272371835), (0.010501979984008786, -1.316861265142233), (0.020130435156700627, -1.42733106221664), (0.03287102859850757, -1.3621585058921197), (0.048641132671991494, -1.3173211755762493), (0.0673384722007489, -1.2429762772029966), (0.08884178776317603, -1.1958803576456498), (0.11301162210634938, -1.1381386975013545), (0.13969122457982486, -1.0956542374098075) … (0.8603087754201751, -0.14039643463905027), (0.8869883778936505, -0.09575579955387314), (0.911158212236824, -0.050774173779668086), (0.9326615277992512, -0.0027653672644960547), (0.9513588673280085, 0.04674405527490677), (0.9671289714014923, 0.10104527417098685), (0.9798695648432993, 0.15972255924403955), (0.9894980200159912, 0.2273742896728842), (0.9959518926930306, 0.30641978613246157), (0.9991893270335525, 0.396992712960727)], [(0.9959518926930306, 0.3923231560578939), (0.9894980200159912, 0.2975910175373142), (0.9798695648432993, 0.2409826735818793), (0.9671289714014923, 0.20678079024298412), (0.9513588673280085, 0.18395185193918018), (0.9326615277992512, 0.1663793304141825), (0.911158212236824, 0.15249603856873495), (0.8869883778936505, 0.14061358337950358), (0.8603087754201751, 0.13082924224840686), (0.8312924322762442, 0.12215717981662699) … (0.13969122457982486, 0.09672889133297302), (0.11301162210634938, 0.12379860025306055), (0.08884178776317603, 0.15571962935100558), (0.0673384722007489, 0.21058345890162544), (0.048641132671991494, 0.2829531459153697), (0.03287102859850757, 0.3926093876042568), (0.020130435156700627, 0.5461527496970991), (0.010501979984008786, 0.753638677029769), (0.004048107306969306, 0.9665439182814376), (0.0008106729664475176, 0.9140724040543231)])
Now let's plot the results!
# Pressure coefficients
plot(yflip = true, xlabel = L"(x/c)", ylabel = L"C_p", lw = 2)
plot!(cp_upper, label = L"$C_p$ Upper",
ls = :dash, lw = 2, c = :cornflowerblue)
plot!(cp_lower, label = L"$C_p$ Lower",
ls = :dash, lw = 2, c = :orange)
plot!(x_upper, -y_upper, label = "$(airfoil.name) Upper",
ls = :solid, lw = 2, c = :cornflowerblue)
plot!(x_lower, -y_lower, label = "$(airfoil.name) Lower",
ls = :solid, lw = 2, c = :orange)
# Lift coefficients
cl_upper, cl_lower = get_surface_values(panels, cls)
cl_plot = plot(xlabel = L"(x/c)", ylabel = L"C_l", lw = 2)
plot!(cl_upper, label = L"$C_l$ Upper",
ls = :dash, lw = 2, c = :cornflowerblue)
plot!(cl_lower, label = L"$C_l$ Lower",
ls = :dash, lw = 2, c = :orange)
plot!(x_lower, y_lower, label = "$(airfoil.name) Lower",
ls = :solid, lw = 2, c = :orange)
plot!(x_upper, y_upper, label = "$(airfoil.name) Upper",
ls = :solid, lw = 2, c = :cornflowerblue)
# Moment coefficients
cm_upper, cm_lower = get_surface_values(panels, cms)
cm_plot = plot(xlabel = L"(x/c)", ylabel = L"C_m")
plot!(cm_upper, label = L"$C_m$ Upper",
ls = :dash, lw = 2, c = :cornflowerblue)
plot!(cm_lower, label = L"$C_m$ Lower",
ls = :dash, lw = 2, c = :orange)
plot!(x_upper, y_upper, label = L"$C_m$ Upper",
ls = :solid, lw = 2, c = :cornflowerblue)
plot!(x_lower, y_lower, label = L"$C_m$ Lower",
ls = :solid, lw = 2, c = :orange)
Great! We've created our first airfoil and run an aerodynamic analysis in 2 dimensions. Now we can move on to analyzing an aircraft configuration in the Aircraft Aerodynamic Analysis tutorial.
This page was generated using Literate.jl.