Skip to content

Commit a62f903

Browse files
authored
use enum for parameter "model" (#70)
* use enum for param model * Add private functions * improve docu * improve docu --------- Co-authored-by: Uwe Fechner <[email protected]>
1 parent cb43571 commit a62f903

17 files changed

+75
-48
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ makedocs(;
2020
"How it works" => "explanation.md",
2121
"Exported Functions" => "functions.md",
2222
"Exported Types" => "types.md",
23+
"Private Functions" => "private_functions.md",
2324
"Reference Frames" => "reference_frames.md"
2425
],
2526
)

docs/src/functions.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ plot_polars
2020

2121
## Helper Functions
2222
```@docs
23-
set_plot_style
2423
save_plot
2524
show_plot
26-
plot_line_segment!
27-
set_axes_equal!
28-
create_geometry_plot
29-
generate_polar_data
30-
```
25+
```

docs/src/private_functions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
```@meta
2+
CurrentModule = VortexStepMethod
3+
```
4+
5+
## Private Functions
6+
```@docs
7+
calculate_AIC_matrices!
8+
plot_line_segment!
9+
create_geometry_plot
10+
generate_polar_data
11+
set_axes_equal!
12+
set_plot_style
13+
```

docs/src/types.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
```@meta
22
CurrentModule = VortexStepMethod
33
```
4+
## Enumerations
5+
```@docs
6+
Model
7+
```
8+
49
## Basic Vectors
510
```@docs
611
MVec3

examples/bench.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
3434
set_va!(wa, vel_app)
3535

3636
# Step 4: Initialize solvers for both LLT and VSM methods
37-
llt_solver = Solver(aerodynamic_model_type=:LLT)
38-
vsm_solver = Solver(aerodynamic_model_type=:VSM)
37+
llt_solver = Solver(aerodynamic_model_type=LLT)
38+
vsm_solver = Solver(aerodynamic_model_type=VSM)
3939

4040
# Step 5: Solve using both methods
4141
results_vsm = solve(vsm_solver, wa)

examples/ram_air_kite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ body_aero = BodyAerodynamics([wing])
1717

1818
# Create solvers
1919
VSM = Solver(
20-
aerodynamic_model_type=:VSM,
20+
aerodynamic_model_type=VSM,
2121
is_with_artificial_damping=false
2222
)
2323

examples/rectangular_wing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
3434
set_va!(wa, vel_app, [0, 0, 0.1])
3535

3636
# Step 4: Initialize solvers for both LLT and VSM methods
37-
llt_solver = Solver(aerodynamic_model_type=:LLT)
38-
vsm_solver = Solver(aerodynamic_model_type=:VSM)
37+
llt_solver = Solver(aerodynamic_model_type=LLT)
38+
vsm_solver = Solver(aerodynamic_model_type=VSM)
3939

4040
# Step 5: Solve using both methods
4141
results_llt = solve(llt_solver, wa)

examples/stall_model.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ body_aero_CAD_19ribs = BodyAerodynamics([CAD_wing])
4444

4545
# Create solvers
4646
VSM = Solver(
47-
aerodynamic_model_type=:VSM,
47+
aerodynamic_model_type=VSM,
4848
is_with_artificial_damping=false
4949
)
5050
VSM_with_stall_correction = Solver(
51-
aerodynamic_model_type=:VSM,
51+
aerodynamic_model_type=VSM,
5252
is_with_artificial_damping=true
5353
)
5454

src/VortexStepMethod.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export add_section!, set_va!
2424
export calculate_span, calculate_projected_area
2525
export plot_wing, plot_circulation_distribution, plot_geometry, plot_distribution, plot_polars
2626
export show_plot, save_plot, menu
27+
export Model, VSM, LLT
2728

2829
"""
2930
const MVec3 = MVector{3, Float64}
@@ -46,6 +47,15 @@ Velocity vector, either a `MVec3` or a `Vector` for use in function signatures.
4647
"""
4748
const VelVector=Union{MVec3, Vector, SizedVector{3, Float64, Vector{Float64}}}
4849

50+
"""
51+
Model `VSM` `LLT`
52+
53+
Enumeration of the implemented model types.
54+
55+
# Elements
56+
- VSM: Vortex Step Method
57+
- LLT: Lifting Line Theory
58+
"""
4959
@enum Model VSM LLT
5060

5161
abstract type AbstractWing end

src/body_aerodynamics.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,25 @@ function calculate_panel_properties(section_list::Vector{Section}, n_panels::Int
227227
end
228228

229229
"""
230-
calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Symbol,
230+
calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Model,
231231
core_radius_fraction::Float64,
232232
va_norm_array::Vector{Float64},
233233
va_unit_array::Matrix{Float64})
234234
235235
Calculate Aerodynamic Influence Coefficient matrices.
236236
237+
See also: [BodyAerodynamics](@ref), [Model](@ref)
238+
237239
Returns:
238-
Tuple of (AIC_x, AIC_y, AIC_z) matrices
240+
Tuple of (`AIC_x`, `AIC_y`, `AIC_z`) matrices
239241
"""
240-
function calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Symbol,
242+
function calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Model,
241243
core_radius_fraction::Float64,
242244
va_norm_array::Vector{Float64},
243245
va_unit_array::Matrix{Float64})
244-
model in [:VSM, :LLT] || throw(ArgumentError("Model must be VSM or LLT"))
245246
# Determine evaluation point based on model
246-
evaluation_point = model === :VSM ? :control_point : :aero_center
247-
evaluation_point_on_bound = model === :LLT
247+
evaluation_point = model === VSM ? :control_point : :aero_center
248+
evaluation_point_on_bound = model === LLT
248249

249250
# Initialize AIC matrices
250251
velocity_induced, tempvel, va_unit, U_2D = zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(MVec3)
@@ -271,7 +272,7 @@ function calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Symbol,
271272
body_aero.AIC[:, icp, jring] .= velocity_induced
272273

273274
# Subtract 2D induced velocity for VSM
274-
if icp == jring && model === :VSM
275+
if icp == jring && model === VSM
275276
calculate_velocity_induced_bound_2D!(U_2D, body_aero.panels[jring], ep, body_aero.work_vectors)
276277
body_aero.AIC[:, icp, jring] .-= U_2D
277278
end
@@ -376,7 +377,7 @@ function update_effective_angle_of_attack_if_VSM(body_aero::BodyAerodynamics,
376377

377378
# Calculate AIC matrices at aerodynamic center using LLT method
378379
calculate_AIC_matrices!(
379-
body_aero, :LLT, core_radius_fraction, va_norm_array, va_unit_array
380+
body_aero, LLT, core_radius_fraction, va_norm_array, va_unit_array
380381
)
381382
AIC_x, AIC_y, AIC_z = @views body_aero.AIC[1, :, :], body_aero.AIC[2, :, :], body_aero.AIC[3, :, :]
382383

@@ -399,7 +400,7 @@ end
399400

400401
"""
401402
calculate_results(body_aero::BodyAerodynamics, gamma_new::Vector{Float64},
402-
density::Float64, aerodynamic_model_type::Symbol,
403+
density::Float64, aerodynamic_model_type::Model,
403404
core_radius_fraction::Float64, mu::Float64,
404405
alpha_array::Vector{Float64}, v_a_array::Vector{Float64},
405406
chord_array::Vector{Float64}, x_airf_array::Matrix{Float64},
@@ -418,7 +419,7 @@ function calculate_results(
418419
gamma_new::Vector{Float64},
419420
reference_point::AbstractVector,
420421
density::Float64,
421-
aerodynamic_model_type::Symbol,
422+
aerodynamic_model_type::Model,
422423
core_radius_fraction::Float64,
423424
mu::Float64,
424425
alpha_array::Vector{Float64},
@@ -454,7 +455,7 @@ function calculate_results(
454455
moment = reshape((cm_array .* 0.5 .* density .* v_a_array.^2 .* chord_array), :, 1)
455456

456457
# Calculate alpha corrections based on model type
457-
alpha_corrected = if aerodynamic_model_type === :VSM
458+
alpha_corrected = if aerodynamic_model_type === VSM
458459
update_effective_angle_of_attack_if_VSM(
459460
body_aero,
460461
gamma_new,
@@ -465,7 +466,7 @@ function calculate_results(
465466
va_norm_array,
466467
va_unit_array
467468
)
468-
elseif aerodynamic_model_type === :LLT
469+
elseif aerodynamic_model_type === LLT
469470
alpha_array
470471
else
471472
throw(ArgumentError("Unknown aerodynamic model type, should be LLT or VSM"))

0 commit comments

Comments
 (0)