Skip to content

Commit 41b0556

Browse files
author
Arjit Seth
authored
Merge pull request #110 from GodotMisogi/develop
Added docs and more bugfixes in profile drag
2 parents 0019ee3 + 750c05b commit 41b0556

File tree

9 files changed

+86
-42
lines changed

9 files changed

+86
-42
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AeroMDAO"
22
uuid = "ae1513eb-aba2-415b-9b88-80f66c7c7c76"
33
authors = ["GodotMisogi <[email protected]>"]
4-
version = "0.3.8"
4+
version = "0.3.9"
55

66
[deps]
77
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ If you use AeroMDAO in your research, please cite the following until any releva
6060
author = {Arjit Seth, Stephane Redonnet, Rhea P. Liem},
6161
title = {AeroMDAO},
6262
url = {https://github.com/GodotMisogi/AeroMDAO},
63-
version = {0.3.8},
63+
version = {0.3.9},
6464
date = {2022-4-06},
6565
}
6666
```

docs/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ If you use AeroMDAO in your research, please cite the following until any releva
5252
author = {Arjit Seth, Rhea P. Liem, Stephane Redonnet},
5353
title = {AeroMDAO},
5454
url = {https://github.com/GodotMisogi/AeroMDAO},
55-
version = {0.3.8},
55+
version = {0.3.9},
5656
date = {2021-04-06},
5757
}
5858
```

examples/vortex_lattice_method/vlm_aircraft.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -93,36 +93,36 @@ end;
9393
## Viscous drag prediction
9494

9595
# Equivalent flat-plate skin friction estimation
96-
CDv_wing = profile_drag_coefficient(wing_mesh, [0.8, 0.8], system.reference)
97-
CDv_htail = profile_drag_coefficient(htail_mesh, [0.6, 0.6], system.reference)
98-
CDv_vtail = profile_drag_coefficient(vtail_mesh, [0.6, 0.6], system.reference)
96+
CDv_wing = profile_drag_coefficient(wing, [0.8, 0.8], system.reference)
97+
CDv_htail = profile_drag_coefficient(htail, [0.6, 0.6], system.reference)
98+
CDv_vtail = profile_drag_coefficient(vtail, [0.6, 0.6], system.reference)
9999

100100
CDv_plate = CDv_wing + CDv_htail + CDv_vtail
101101

102-
## Local dissipation form factor friction estimation
102+
## Local dissipation form factor friction estimation (WRONG???)
103103
import LinearAlgebra: norm
104104

105105
edge_speeds = norm.(surface_velocities(system)); # Inviscid speeds on the surfaces
106106

107107
# Drag coefficients
108-
CDvd_wing = profile_drag_coefficient(wing_mesh, [0.8, 0.8], edge_speeds.wing, refs)
109-
CDvd_htail = profile_drag_coefficient(htail_mesh, [0.6, 0.6], edge_speeds.htail, refs)
110-
CDvd_vtail = profile_drag_coefficient(vtail_mesh, [0.6, 0.6], edge_speeds.vtail, refs)
108+
CDvd_wing = profile_drag_coefficient(wing_mesh, [0.8, 0.8], edge_speeds.wing, ref)
109+
CDvd_htail = profile_drag_coefficient(htail_mesh, [0.6, 0.6], edge_speeds.htail, ref)
110+
CDvd_vtail = profile_drag_coefficient(vtail_mesh, [0.6, 0.6], edge_speeds.vtail, ref)
111111

112-
CDv_diss = CDvd_wing + CDvd_htail + CDvd_vtail
112+
CDv_diss = CDvd_wing + CDvd_htail + CDvd_vtail
113113

114114
## Viscous drag coefficient
115115
CDv = CDv_plate
116116

117-
## Total force coefficients with viscous drag prediction
117+
## Total force coefficients with empirical viscous drag prediction
118118
CDi_nf, CY_nf, CL_nf, Cl, Cm, Cn = nf = nearfield(system)
119119
CDi_ff, CY_ff, CL_ff = ff = farfield(system)
120120

121121
nf_v = (CD = CDi_nf + CDv, CDv = CDv, nf...)
122122
ff_v = (CD = CDi_ff + CDv, CDv = CDv, ff...)
123123

124124
## Spanwise forces/lifting line loads
125-
wing_ll = spanwise_loading(chord_panels(wing_mesh), CFs.wing, S)
125+
wing_ll = spanwise_loading(chord_panels(wing_mesh), CFs.wing, S)
126126
htail_ll = spanwise_loading(chord_panels(htail_mesh), CFs.htail, S)
127127
vtail_ll = spanwise_loading(chord_panels(vtail_mesh), CFs.vtail, S);
128128

examples/vortex_lattice_method/vlm_wing.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ FFs = farfield_coefficients(system)
6060
comp_coeffs = mapreduce(name -> [ sum(CFs[name]); sum(CMs[name]); FFs[name] ], hcat, keys(system.vortices))
6161

6262
## Equivalent flat-plate skin-friction estimation
63-
x_tr = [0.98, 0.98] # Transition locations over sections
64-
CDv_plate = profile_drag_coefficient(wing, x_tr, refs)
63+
x_tr = fill(0.98, 4) # Transition locations over sections
64+
CDv_plate = profile_drag_coefficient(wing_mesh, x_tr, refs)
6565

6666
## Local-dissipation drag estimation (WRONG???)
67-
x_tr = fill(0.98, 4)
6867
cam_panels = camber_panels(wing_mesh)
6968
edge_speeds = surface_velocities(system).wing
7069
CDv_diss = profile_drag_coefficient(wing, x_tr, edge_speeds, cam_panels, refs)

src/AeroMDAO.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ import .AircraftGeometry: Fuselage, projected_area, length, cosine_interpolation
9595
export Fuselage, projected_area, length, cosine_interpolation
9696

9797
# Wing
98-
import .AircraftGeometry: HalfWing, HalfWingSection, Wing, WingSection, affine_transformation, mean_aerodynamic_chord, span, aspect_ratio, projected_area, taper_ratio, leading_edge, trailing_edge, chop_leading_edge, chop_trailing_edge, chop_wing, chop_sections, chop_coordinates, chop_spanwise_sections, chop_chords, chop_spans, wing_bounds, make_panels, mesh_chords, mesh_wing, mesh_cambers, max_thickness_to_chord_ratio_sweeps, mean_aerodynamic_center, panel_wing, number_of_spanwise_panels, symmetric_spacing, coordinates, chord_coordinates, camber_coordinates, surface_coordinates, foils, chords, twists, spans, dihedrals, sweeps, position, orientation, WingMesh, chord_panels, camber_panels, surface_panels, AbstractSpacing, Sine, Cosine, Uniform, properties
98+
import .AircraftGeometry: HalfWing, HalfWingSection, Wing, WingSection, affine_transformation, mean_aerodynamic_chord, span, aspect_ratio, projected_area, taper_ratio, leading_edge, trailing_edge, chop_leading_edge, chop_trailing_edge, chop_wing, chop_sections, chop_coordinates, chop_spanwise_sections, chop_chords, chop_spans, wing_bounds, make_panels, mesh_chords, mesh_wing, mesh_cambers, max_thickness_to_chord_ratio_sweeps, mean_aerodynamic_center, panel_wing, number_of_spanwise_panels, symmetric_spacing, coordinates, chord_coordinates, camber_coordinates, surface_coordinates, foils, chords, twists, spans, dihedrals, sweeps, position, orientation, WingMesh, chord_panels, camber_panels, surface_panels, AbstractSpacing, Sine, Cosine, Uniform, properties, wetted_area_ratio
9999

100-
export HalfWing, HalfWingSection, Wing, WingSection, affine_transformation, mean_aerodynamic_chord, span, aspect_ratio, projected_area, taper_ratio, leading_edge, trailing_edge, chop_leading_edge, chop_trailing_edge, chop_wing, chop_sections, chop_coordinates, chop_spanwise_sections, chop_chords, chop_spans, wing_bounds, make_panels, mesh_chords, mesh_wing, mesh_cambers, max_thickness_to_chord_ratio_sweeps, mean_aerodynamic_center, panel_wing, number_of_spanwise_panels, symmetric_spacing, coordinates, chord_coordinates, camber_coordinates, surface_coordinates, foils, chords, twists, spans, dihedrals, sweeps, position, orientation, WingMesh, chord_panels, camber_panels, surface_panels, AbstractSpacing, Sine, Cosine, Uniform, properties
100+
export HalfWing, HalfWingSection, Wing, WingSection, affine_transformation, mean_aerodynamic_chord, span, aspect_ratio, projected_area, taper_ratio, leading_edge, trailing_edge, chop_leading_edge, chop_trailing_edge, chop_wing, chop_sections, chop_coordinates, chop_spanwise_sections, chop_chords, chop_spans, wing_bounds, make_panels, mesh_chords, mesh_wing, mesh_cambers, max_thickness_to_chord_ratio_sweeps, mean_aerodynamic_center, panel_wing, number_of_spanwise_panels, symmetric_spacing, coordinates, chord_coordinates, camber_coordinates, surface_coordinates, foils, chords, twists, spans, dihedrals, sweeps, position, orientation, WingMesh, chord_panels, camber_panels, surface_panels, AbstractSpacing, Sine, Cosine, Uniform, properties, wetted_area_ratio
101101

102102
# Surfaces
103103
import .AircraftGeometry: HorizontalTail, VerticalTail

src/Aerodynamics/profile_drag.jl

+21-22
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function form_factor(wing :: HalfWing, M)
1010
Kf = form_factor_wing.(xcs, tcs, sweeps, M)
1111
end
1212

13-
form_factor(wing :: Wing, M) = (form_factor(wing.left, M) + form_factor(wing.right, M)) / 2
13+
form_factor(wing :: Wing, M) = [ form_factor(wing.left, M); form_factor(wing.right, M) ]
1414

1515
# Schlichting averaged skin-friction coefficients
1616
cf_lam(Re_c, k_lam = 1.) = 1.328 / (Re_c * k_lam)
@@ -33,14 +33,16 @@ function wetted_area_drag(mean_chords, S_wets, K_fs, x_tr, V, ρ, M, μ)
3333

3434
# Profile drag
3535
Dp_by_q = sum(@. cfs * S_wets * K_fs)
36+
37+
return Dp_by_q
3638
end
3739

38-
function wetted_area_drag(wing :: HalfWing, x_tr, V, ρ, a_ref = 330., μ = 1.5e-5)
40+
function wetted_area_drag(wing :: AbstractWing, x_tr, V, ρ, a_ref, μ)
3941
# Chord processing
4042
mean_chords = (forward_sum chords)(wing) / 2
4143

4244
# Wetted areas
43-
S_wets = @. mean_chords * wing.spans / cos(wing.dihedrals)
45+
S_wets = mean_chords .* spans(wing) ./ cos.(dihedrals(wing))
4446

4547
# Form factors
4648
M = V / a_ref
@@ -49,20 +51,7 @@ function wetted_area_drag(wing :: HalfWing, x_tr, V, ρ, a_ref = 330., μ = 1.5e
4951
wetted_area_drag(mean_chords, S_wets, K_fs, x_tr, V, ρ, M, μ)
5052
end
5153

52-
function wetted_area_drag(wing :: WingMesh, x_tr, V, ρ, a_ref = 330., μ = 1.5e-5)
53-
# Chord processing
54-
mean_chords = (forward_sum chords)(wing.surface) / 2
55-
56-
# Wetted areas
57-
surf_pans = camber_panels(wing)
58-
S_wets = sum(panel_area, surf_pans, dims = 1)
59-
60-
# Form factors
61-
M = V / a_ref
62-
K_fs = form_factor(wing.surface, M)
63-
64-
wetted_area_drag(mean_chords, S_wets, K_fs, x_tr, V, ρ, M, μ)
65-
end
54+
wetted_area_drag(wing :: WingMesh, x_tr, V, ρ, a_ref, μ) = wetted_area_drag(wing.surface, x_tr, V, ρ, a_ref, μ)
6655

6756
# Sato's local-friction and local-dissipation based on power balance method from Mark Drela, Flight Vehicle Aerodynamics, eq. 4.115.
6857
function local_dissipation_drag(wing :: Wing, wetted_areas, ρ_es, u_es, x_tr, V, ρ, M, μ)
@@ -79,8 +68,10 @@ function local_dissipation_drag(wing :: WingMesh, ρ_es, u_es, x_tr, V, ρ, M,
7968
# Chord processing
8069
mean_chords = (forward_sum chords)(wing.surface) / 2
8170

82-
# Compute weighted wetted areas based on inviscid edge velocity distribution.
71+
# Compute wetted area of camber (for now).
8372
S_wets = panel_area.(camber_panels(wing))
73+
74+
# Calculate weighted wetted areas based on inviscid edge velocity distribution.
8475
weighted_S_wets = sum(@. ρ_es * u_es^3 * S_wets; dims = 1) ./* V^3)
8576

8677
wetted_area_drag(mean_chords, weighted_S_wets, 1., x_tr, V, ρ, M, μ)
@@ -91,18 +82,26 @@ abstract type AbstractProfileDrag end
9182
struct FormFactor <: AbstractProfileDrag end
9283
struct Dissipation <: AbstractProfileDrag end
9384

94-
profile_drag_coefficient(wing :: HalfWing, x_tr, V, rho_ref, a_ref, area_ref, μ) = wetted_area_drag(wing, x_tr, V, rho_ref, a_ref, μ) / area_ref
95-
profile_drag_coefficient(wing :: WingMesh, x_tr, V, rho_ref, a_ref, area_ref, μ) = wetted_area_drag(wing, x_tr, V, rho_ref, a_ref, μ) / area_ref
96-
profile_drag_coefficient(wing :: Wing, x_tr, V, rho_ref, a_ref, area_ref, μ) = profile_drag_coefficient(wing.left, x_tr, V, rho_ref, a_ref, area_ref, μ) + profile_drag_coefficient(wing.right, x_tr, V, rho_ref, a_ref, area_ref, μ)
85+
profile_drag_coefficient(wing :: AbstractWing, x_tr, V, rho_ref, a_ref, area_ref, μ) = wetted_area_drag(wing, x_tr, V, rho_ref, a_ref, μ) / area_ref
86+
87+
"""
88+
profile_drag_coefficient(wing :: AbstractWing, x_tr, refs :: References)
9789
90+
Estimate the profile drag coefficient of a `Wing`` using the **wetted-area method** based on Schlichting's skin-friction coefficient formula.
91+
"""
9892
profile_drag_coefficient(wing :: AbstractWing, x_tr, refs :: References) = profile_drag_coefficient(wing, x_tr, refs.speed, refs.density, refs.sound_speed, refs.area, refs.viscosity)
9993

10094
profile_drag_coefficient(wing :: AbstractWing, x_tr, edge_speeds, panels, refs :: References) = local_dissipation_drag(wing, panel_area.(panels), refs.density, edge_speeds, x_tr, refs.speed, refs.density, mach_number(refs), refs.viscosity) / refs.area
10195

96+
"""
97+
profile_drag_coefficient(wing :: WingMesh, x_tr, edge_speeds, panels, refs :: References)
98+
99+
Estimate the profile drag coefficient of a `Wing` using the **local-friction and local-dissipation method** based on Schlichting's skin-friction coefficient formula.
100+
"""
102101
profile_drag_coefficient(wing :: WingMesh, x_tr, edge_speeds, refs :: References) = local_dissipation_drag(wing, refs.density, edge_speeds, x_tr, refs.speed, refs.density, mach_number(refs), refs.viscosity) / refs.area
103102

104103
function wave_drag(M, Λ, t_by_c, Cl, κ_A)
105104
M_drag_divergence = κ_A / cos(Λ) - t_by_c / cos(Λ)^2 - Cl / (10 * cos(Λ)^3) # Drag divergence Mach number
106-
M_crit = M_drag_divergnece - (0.1 / 80)^(1/3) # Critical Mach number
105+
M_crit = M_drag_divergence - (0.1 / 80)^(1/3) # Critical Mach number
107106
CD_wave = ifelse(M > M_crit, 20 * (Mach - M_crit)^4, 0.)
108107
end

src/Geometry/AircraftGeometry/AircraftGeometry.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using Interpolations
1717
import ..MathTools: uniform_spacing, linear_spacing, sine_spacing, cosine_spacing, cosine_interp, splitat, adj3, slope, columns, forward_sum, forward_division, forward_difference, weighted_vector, vectarray, extend_yz
1818

1919
# Panel geometry
20-
import ..PanelGeometry: Panel2D, Panel3D, panel_area, normal_vector, transform, make_panels
20+
import ..PanelGeometry: Panel2D, Panel3D, panel_area, normal_vector, transform, make_panels, wetted_area
2121

2222
import ..AeroMDAO: properties
2323

src/Geometry/AircraftGeometry/Wings/mesh_wing.jl

+47-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ chord_coordinates(wing :: Wing, span_num :: Integer, chord_num :: Integer; spaci
8686

8787
camber_coordinates(wing :: Wing, span_num :: Integer, chord_num :: Integer; spacings = symmetric_spacing(wing)) = camber_coordinates(wing, number_of_spanwise_panels(wing, span_num), chord_num; spacings = spacings)
8888

89+
surface_coordinates(wing :: Wing, span_num :: Integer, chord_num :: Integer; spacings = symmetric_spacing(wing)) = surface_coordinates(wing, number_of_spanwise_panels(wing, span_num), chord_num; spacings = spacings)
90+
8991
## Panelling
9092
#==========================================================================================#
9193

@@ -164,11 +166,37 @@ check_definition(surf :: HalfWing, n_span) = @assert length(n_span) == length(su
164166
check_definition(surf :: Wing, n_span) = @assert length(n_span) == length(surf.right.spans) == length(surf.left.spans) "The spanwise number vector's length must be the same as the number of sections of the surface."
165167

166168
##
169+
"""
170+
chord_coordinates(wing :: WingMesh, n_span = wing.num_span, n_chord = wing.num_chord)
171+
172+
Generate the chord coordinates of a `WingMesh` with default spanwise ``n_s`` and chordwise ``n_c`` panel distributions from the mesh.
173+
"""
167174
chord_coordinates(wing :: WingMesh, n_span = wing.num_span, n_chord = wing.num_chord) = chord_coordinates(wing.surface, n_span, n_chord)
175+
176+
"""
177+
camber_coordinates(wing :: WingMesh, n_span = wing.num_span, n_chord = wing.num_chord)
178+
179+
Generate the camber coordinates of a `WingMesh` with default spanwise ``n_s`` and chordwise ``n_c`` panel distributions from the mesh.
180+
"""
168181
camber_coordinates(wing :: WingMesh, n_span = wing.num_span, n_chord = wing.num_chord) = camber_coordinates(wing.surface, n_span, n_chord)
182+
183+
"""
184+
surface_coordinates(wing :: WingMesh, n_span = wing.num_span, n_chord = wing.num_chord)
185+
186+
Generate the surface coordinates of a `WingMesh` with default spanwise ``n_s`` and chordwise ``n_c`` panel distributions from the mesh.
187+
"""
169188
surface_coordinates(wing :: WingMesh, n_span = wing.num_span, n_chord = wing.num_chord) = surface_coordinates(wing.surface, n_span, n_chord)
170189

171-
surface_panels(wing :: WingMesh, n_span = wing.num_span, n_chord = wing.num_chord) = (make_panels surface_coordinates)(wing, n_span, n_chord)
190+
"""
191+
surface_panels(wing_mesh :: WingMesh,
192+
n_s = wing_mesh.num_span,
193+
n_c = length(first(foils(wing_mesh.surface))).x)
194+
195+
Generate the surface panel distribution from a `WingMesh` with the default spanwise ``n_s`` panel distribution from the mesh and the chordwise panel ``n_c`` distribution from the airfoil.
196+
197+
In case of strange results, provide a higher number of chordwise panels to represent the airfoils more accurately
198+
"""
199+
surface_panels(wing :: WingMesh, n_span = wing.num_span, n_chord = length(first(foils(wing.surface)).x)) = (make_panels surface_coordinates)(wing, n_span, n_chord)
172200

173201
"""
174202
chord_panels(wing_mesh :: WingMesh)
@@ -184,6 +212,24 @@ Generate the camber panel distribution from a `WingMesh`.
184212
"""
185213
camber_panels(wing :: WingMesh) = make_panels(wing.camber_mesh)
186214

215+
"""
216+
wetted_area(wing_mesh :: WingMesh,
217+
n_s = wing_mesh.num_span,
218+
n_c = length(first(foils(wing_mesh.surface))).x)
219+
220+
Determine the wetted area ``S_{wet}`` of a `WingMesh` by calculating the total area of the surface panels.
221+
"""
222+
wetted_area(wing :: WingMesh, n_span = wing.num_span, n_chord = length(first(foils(wing.surface)).x)) = wetted_area(surface_panels(wing, n_span, n_chord))
223+
224+
"""
225+
wetted_area_ratio(wing_mesh :: WingMesh,
226+
n_s = wing_mesh.num_span,
227+
n_c = length(first(foils(wing_mesh.surface))).x)
228+
229+
Determine the wetted area ratio ``S_{wet}/S`` of a `WingMesh` by calculating the ratio of the total area of the surface panels to the projected area of the `Wing`.
230+
"""
231+
wetted_area_ratio(wing :: WingMesh, n_span = wing.num_span, n_chord = length(first(foils(wing.surface)).x)) = wetted_area(wing, n_span, n_chord) / projected_area(wing.surface)
232+
187233
function Base.show(io :: IO, mesh :: WingMesh)
188234
n_c, n_s = size(mesh.chord_mesh) .- 1
189235
println(io, "WingMesh —")

0 commit comments

Comments
 (0)