Skip to content

Commit db262e0

Browse files
authored
add type AeroData (#86)
* add type AeroData * Add POLAR_MATRIX * use both POLAR_DATA and POLAR_MATRIX * bugfix * improve docstring * improve docstring * rename to POLAR_VECTORS and POLAR_MATRICES * improve docstring * improve docstring
1 parent db03d14 commit db262e0

File tree

7 files changed

+64
-50
lines changed

7 files changed

+64
-50
lines changed

docs/src/types.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ PosVector
1616
VelVector
1717
```
1818

19+
## Aerodynamic data
20+
```@docs
21+
AeroData
22+
```
23+
1924
## Wing Geometry, Panel and Aerodynamics
2025
A body is constructed of one or more abstract wings. An abstract wing can be a Wing or a KiteWing.
2126
A Wing/ KiteWing has one or more sections.

src/VortexStepMethod.jl

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export add_section!, set_va!
2424
export calculate_span, calculate_projected_area
2525
export menu, MVec3
2626
export Model, VSM, LLT
27-
export AeroModel, LEI_AIRFOIL_BREUKELS, POLAR_DATA, INVISCID
27+
export AeroModel, LEI_AIRFOIL_BREUKELS, POLAR_VECTORS, POLAR_MATRICES, INVISCID
2828
export PanelDistribution, LINEAR, COSINE, COSINE_VAN_GARREL, SPLIT_PROVIDED, UNCHANGED
2929
export InitialGammaDistribution, ELLIPTIC, ZEROS
3030

@@ -72,18 +72,22 @@ Enumeration of the implemented model types.
7272
@enum Model VSM LLT
7373

7474
"""
75-
AeroModel `LEI_AIRFOIL_BREUKELS` `POLAR_DATA` `INVISCID`
75+
AeroModel `LEI_AIRFOIL_BREUKELS` `POLAR_VECTORS` `POLAR_MATRICES` `INVISCID`
7676
77-
Enumeration of the implemented aerodynamic models.
77+
Enumeration of the implemented aerodynamic models. See also: [AeroData](@ref)
7878
7979
# Elements
8080
- `LEI_AIRFOIL_BREUKELS`: Polynom approximation for leading edge inflatable kites
81-
- `POLAR_DATA`: Polar data (lookup tables with interpolation)
81+
- `POLAR_VECTORS`: Polar vectors as function of alpha (lookup tables with interpolation)
82+
- `POLAR_MATRICES`: Polar matrices as function of alpha and beta (lookup tables with interpolation)
8283
- INVISCID
84+
85+
where `alpha` is the angle of attack, `beta` is trailing edge angle.
8386
"""
8487
@enum AeroModel begin
8588
LEI_AIRFOIL_BREUKELS
86-
POLAR_DATA
89+
POLAR_VECTORS
90+
POLAR_MATRICES
8791
INVISCID
8892
end
8993

@@ -120,6 +124,30 @@ Enumeration of the implemented initial gamma distributions.
120124

121125
abstract type AbstractWing end
122126

127+
"""
128+
AeroData= Union{
129+
Nothing,
130+
NTuple{2, Float64},
131+
Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}},
132+
Tuple{Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, Matrix{Float64}}
133+
}
134+
135+
Union of different definitions of the aerodynamic properties of a wing section. See also: [AeroModel](@ref)
136+
- nothing for INVISCID
137+
- (`tube_diameter`, camber) for `LEI_AIRFOIL_BREUKELS`
138+
- (`alpha_range`, `cl_vector`, `cd_vector`, `cm_vector`) for `POLAR_VECTORS`
139+
- (`alpha_range`, `beta_range`, `cl_matrix`, `cd_matrix`, `cm_matrix`) for `POLAR_MATRICES`
140+
141+
where `alpha` is the angle of attack, `beta` is trailing edge angle, `cl` the lift coefficient,
142+
`cd` the drag coefficient and `cm` the pitching moment coefficient.
143+
"""
144+
const AeroData = Union{
145+
Nothing,
146+
NTuple{2, Float64},
147+
Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}},
148+
Tuple{Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, Matrix{Float64}}
149+
}
150+
123151
function menu()
124152
Main.include("examples/menu.jl")
125153
end

src/kite_geometry.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function KiteWing(obj_path, dat_path; alpha=0.0, crease_frac=0.75, wind_vel=10.,
287287
else
288288
TE_point = LE_point .+ [te_interp(gamma) - le_interp(gamma), 0.0, 0.0]
289289
end
290-
push!(sections, Section(LE_point, TE_point, POLAR_DATA, aero_data))
290+
push!(sections, Section(LE_point, TE_point, POLAR_MATRICES, aero_data))
291291
end
292292

293293
KiteWing(n_panels, spanwise_panel_distribution, spanwise_direction, sections, sections,

src/panel.jl

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ function init_aero!(
119119
throw(ArgumentError("Both sections must have the same aero model, not $(panel.aero_model) and $aero_model_2"))
120120
end
121121

122-
if panel.aero_model === LEI_AIRFOIL_BREUKELS
122+
if panel.aero_model == LEI_AIRFOIL_BREUKELS
123123
panel.cl_coeffs, panel.cd_coeffs, panel.cm_coeffs = compute_lei_coeffs(section_1, section_2)
124124

125-
elseif panel.aero_model === POLAR_DATA
125+
elseif panel.aero_model in (POLAR_VECTORS, POLAR_MATRICES)
126126
aero_1 = section_1.aero_data
127127
aero_2 = section_2.aero_data
128128
if !all(size.(aero_1) .== size.(aero_2))
129129
throw(ArgumentError("Polar data must have same shape"))
130130
end
131131

132-
if length(aero_1) == 4
132+
if panel.aero_model == POLAR_VECTORS
133133
!all(isapprox.(aero_1[1], aero_2[1])) && @error "Make sure you use the same alpha range for all your interpolations."
134134

135135
polar_data = (
@@ -143,7 +143,7 @@ function init_aero!(
143143
panel.cd_interp = linear_interpolation(alphas, polar_data[2]; extrapolation_bc=NaN)
144144
panel.cm_interp = linear_interpolation(alphas, polar_data[3]; extrapolation_bc=NaN)
145145

146-
elseif length(aero_1) == 5
146+
elseif panel.aero_model == POLAR_MATRICES
147147
!all(isapprox.(aero_1[1], aero_2[1])) && @error "Make sure you use the same alpha range for all your interpolations."
148148
!all(isapprox.(aero_1[2], aero_2[2])) && @error "Make sure you use the same beta range for all your interpolations."
149149

@@ -314,14 +314,10 @@ function calculate_cl(panel::Panel, alpha::Float64)::Float64
314314
end
315315
elseif panel.aero_model == INVISCID
316316
cl = 2π * alpha
317-
elseif panel.aero_model == POLAR_DATA
318-
if isa(panel.cl_interp, I1)
319-
cl = panel.cl_interp(alpha)::Float64
320-
elseif isa(panel.cl_interp, I2)
321-
cl = panel.cl_interp(alpha, 0.0)::Float64
322-
else
323-
throw(ArgumentError("cl_interp is $(panel.cl_interp)"))
324-
end
317+
elseif panel.aero_model == POLAR_VECTORS
318+
cl = panel.cl_interp(alpha)::Float64
319+
elseif panel.aero_model == POLAR_MATRICES
320+
cl = panel.cl_interp(alpha, 0.0)::Float64
325321
else
326322
throw(ArgumentError("Unsupported aero model: $(panel.aero_model)"))
327323
end
@@ -342,14 +338,12 @@ function calculate_cd_cm(panel::Panel, alpha::Float64)
342338
if abs(alpha) >/9) # Outside ±20 degrees
343339
cd = 2 * sin(alpha)^3
344340
end
345-
elseif panel.aero_model == POLAR_DATA
346-
if isa(panel.cd_interp, I1)
347-
cd = panel.cd_interp(alpha)::Float64
348-
cm = panel.cm_interp(alpha)::Float64
349-
elseif isa(panel.cd_interp, I2)
350-
cd = panel.cd_interp(alpha, 0.0)::Float64
351-
cm = panel.cm_interp(alpha, 0.0)::Float64
352-
end
341+
elseif panel.aero_model == POLAR_VECTORS
342+
cd = panel.cd_interp(alpha)::Float64
343+
cm = panel.cm_interp(alpha)::Float64
344+
elseif panel.aero_model == POLAR_MATRICES
345+
cd = panel.cd_interp(alpha, 0.0)::Float64
346+
cm = panel.cm_interp(alpha, 0.0)::Float64
353347
elseif !(panel.aero_model == INVISCID)
354348
throw(ArgumentError("Unsupported aero model: $(panel.aero_model)"))
355349
end

src/wing_geometry.jl

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,13 @@ Represents a wing section with leading edge, trailing edge, and aerodynamic prop
88
- `LE_point::MVec3` = zeros(MVec3): Leading edge point coordinates
99
- `TE_point::MVec3` = zeros(MVec3): Trailing edge point coordinates
1010
- `aero_model`::AeroModel = INVISCID: [AeroModel](@ref)
11-
- `aero_data` = nothing: Can be:
12-
- nothing for INVISCID
13-
- (`tube_diameter`, camber) for `LEI_AIRFOIL_BREUKELS`
14-
- (`alpha_range`, `cl_vector`, `cd_vector`, `cm_vector`) for `POLAR_DATA`
15-
- (`alpha_range`, `beta_range`, `cl_matrix`, `cd_matrix`, `cm_matrix`) for `POLAR_DATA`
11+
- `aero_data`::AeroData = nothing: See: [AeroData]
1612
"""
1713
@with_kw mutable struct Section
1814
LE_point::MVec3 = zeros(MVec3)
1915
TE_point::MVec3 = zeros(MVec3)
2016
aero_model::AeroModel = INVISCID
21-
aero_data::Union{
22-
Nothing,
23-
NTuple{2, Float64},
24-
Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}},
25-
Tuple{Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, Matrix{Float64}}
26-
} = nothing
17+
aero_data::AeroData = nothing
2718
end
2819
"""
2920
Section(LE_point::Vector{Float64}, TE_point::Vector{Float64},
@@ -130,14 +121,10 @@ Add a new section to the wing.
130121
- LE_point::PosVector: [PosVector](@ref) of the point on the side of the leading edge
131122
- TE_point::PosVector: [PosVector](@ref) of the point on the side of the trailing edge
132123
- `aero_model`::AeroModel: [AeroModel](@ref)
133-
- `aero_data`: Can be:
134-
- nothing for INVISCID
135-
- (`tube_diameter`, camber) for `LEI_AIRFOIL_BREUKELS`
136-
- (`alpha_range`, `cl_vector`, `cd_vector`, `cm_vector`) for `POLAR_DATA`
137-
- (`alpha_range`, `beta_range`, `cl_matrix`, `cd_matrix`, `cm_matrix`) for `POLAR_DATA`
124+
- `aero_data`::AeroData: See [AeroData](@ref)
138125
"""
139126
function add_section!(wing::Wing, LE_point::Vector{Float64},
140-
TE_point::Vector{Float64}, aero_model::AeroModel, aero_data=nothing)
127+
TE_point::Vector{Float64}, aero_model::AeroModel, aero_data::AeroData=nothing)
141128
push!(wing.sections, Section(LE_point, TE_point, aero_model, aero_data))
142129
return nothing
143130
end
@@ -258,15 +245,15 @@ function calculate_new_aero_data(aero_model,
258245
throw(ArgumentError("Different aero models over the span are not supported"))
259246
end
260247

261-
if model_type === INVISCID
248+
if model_type == INVISCID
262249
return nothing
263250

264-
elseif model_type === POLAR_DATA
251+
elseif model_type in (POLAR_VECTORS, POLAR_MATRICES)
265252
polar_left = aero_data[section_index]
266253
polar_right = aero_data[section_index + 1]
267254

268255
# Unpack polar data
269-
if length(polar_left) == 4
256+
if model_type == POLAR_VECTORS
270257
alpha_left, CL_left, CD_left, CM_left = polar_left
271258
alpha_right, CL_right, CD_right, CM_right = polar_right
272259

@@ -281,7 +268,7 @@ function calculate_new_aero_data(aero_model,
281268

282269
return (alpha_left, CL_data, CD_data, CM_data)
283270

284-
elseif length(polar_left) == 5
271+
elseif model_type == POLAR_MATRICES
285272
alpha_left, beta_left, CL_left, CD_left, CM_left = polar_left
286273
alpha_right, beta_right, CL_right, CD_right, CM_right = polar_right
287274

test/bench.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ using LinearAlgebra
9999
cms = [-0.1 * α for α in alphas]
100100

101101
for model in models
102-
for (aero_model, aero_data) in [(INVISCID, nothing), (POLAR_DATA, (alphas, cls, cds, cms))]
102+
for (aero_model, aero_data) in [(INVISCID, nothing), (POLAR_VECTORS, (alphas, cls, cds, cms))]
103103
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
104104
add_section!(wing,
105105
[0.0, span/2, 0.0], # Left tip LE

test/test_panel.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ end
137137
end
138138

139139
# Create two sections with slightly different polar data
140-
section1 = Section([0.0, 0.0, 0.0], [1.0, 0.0, 0.0], POLAR_DATA, polar_data)
141-
section2 = Section([0.0, 10.0, 0.0], [1.0, 10.0, 0.0], POLAR_DATA, big_polar_data)
140+
section1 = Section([0.0, 0.0, 0.0], [1.0, 0.0, 0.0], POLAR_VECTORS, polar_data)
141+
section2 = Section([0.0, 10.0, 0.0], [1.0, 10.0, 0.0], POLAR_VECTORS, big_polar_data)
142142

143143
# Create panel
144144
panel = create_panel(section1, section2)

0 commit comments

Comments
 (0)