Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ makedocs(;
"How it works" => "explanation.md",
"Exported Functions" => "functions.md",
"Exported Types" => "types.md",
"Private Functions" => "private_functions.md",
"Reference Frames" => "reference_frames.md"
],
)
Expand Down
7 changes: 1 addition & 6 deletions docs/src/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ plot_polars

## Helper Functions
```@docs
set_plot_style
save_plot
show_plot
plot_line_segment!
set_axes_equal!
create_geometry_plot
generate_polar_data
```
```
13 changes: 13 additions & 0 deletions docs/src/private_functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```@meta
CurrentModule = VortexStepMethod
```

## Private Functions
```@docs
calculate_AIC_matrices!
plot_line_segment!
create_geometry_plot
generate_polar_data
set_axes_equal!
set_plot_style
```
5 changes: 5 additions & 0 deletions docs/src/types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
```@meta
CurrentModule = VortexStepMethod
```
## Enumerations
```@docs
Model
```

## Basic Vectors
```@docs
MVec3
Expand Down
4 changes: 2 additions & 2 deletions examples/bench.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
set_va!(wa, vel_app)

# Step 4: Initialize solvers for both LLT and VSM methods
llt_solver = Solver(aerodynamic_model_type=:LLT)
vsm_solver = Solver(aerodynamic_model_type=:VSM)
llt_solver = Solver(aerodynamic_model_type=LLT)
vsm_solver = Solver(aerodynamic_model_type=VSM)

# Step 5: Solve using both methods
results_vsm = solve(vsm_solver, wa)
Expand Down
2 changes: 1 addition & 1 deletion examples/ram_air_kite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ body_aero = BodyAerodynamics([wing])

# Create solvers
VSM = Solver(
aerodynamic_model_type=:VSM,
aerodynamic_model_type=VSM,
is_with_artificial_damping=false
)

Expand Down
4 changes: 2 additions & 2 deletions examples/rectangular_wing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
set_va!(wa, vel_app, [0, 0, 0.1])

# Step 4: Initialize solvers for both LLT and VSM methods
llt_solver = Solver(aerodynamic_model_type=:LLT)
vsm_solver = Solver(aerodynamic_model_type=:VSM)
llt_solver = Solver(aerodynamic_model_type=LLT)
vsm_solver = Solver(aerodynamic_model_type=VSM)

# Step 5: Solve using both methods
results_llt = solve(llt_solver, wa)
Expand Down
4 changes: 2 additions & 2 deletions examples/stall_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ body_aero_CAD_19ribs = BodyAerodynamics([CAD_wing])

# Create solvers
VSM = Solver(
aerodynamic_model_type=:VSM,
aerodynamic_model_type=VSM,
is_with_artificial_damping=false
)
VSM_with_stall_correction = Solver(
aerodynamic_model_type=:VSM,
aerodynamic_model_type=VSM,
is_with_artificial_damping=true
)

Expand Down
10 changes: 10 additions & 0 deletions src/VortexStepMethod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export add_section!, set_va!
export calculate_span, calculate_projected_area
export plot_wing, plot_circulation_distribution, plot_geometry, plot_distribution, plot_polars
export show_plot, save_plot, menu
export Model, VSM, LLT

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

"""
Model `VSM` `LLT`

Enumeration of the implemented model types.

# Elements
- VSM: Vortex Step Method
- LLT: Lifting Line Theory
"""
@enum Model VSM LLT

abstract type AbstractWing end
Expand Down
25 changes: 13 additions & 12 deletions src/body_aerodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,25 @@ function calculate_panel_properties(section_list::Vector{Section}, n_panels::Int
end

"""
calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Symbol,
calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Model,
core_radius_fraction::Float64,
va_norm_array::Vector{Float64},
va_unit_array::Matrix{Float64})

Calculate Aerodynamic Influence Coefficient matrices.

See also: [BodyAerodynamics](@ref), [Model](@ref)

Returns:
Tuple of (AIC_x, AIC_y, AIC_z) matrices
Tuple of (`AIC_x`, `AIC_y`, `AIC_z`) matrices
"""
function calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Symbol,
function calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Model,
core_radius_fraction::Float64,
va_norm_array::Vector{Float64},
va_unit_array::Matrix{Float64})
model in [:VSM, :LLT] || throw(ArgumentError("Model must be VSM or LLT"))
# Determine evaluation point based on model
evaluation_point = model === :VSM ? :control_point : :aero_center
evaluation_point_on_bound = model === :LLT
evaluation_point = model === VSM ? :control_point : :aero_center
evaluation_point_on_bound = model === LLT

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

# Subtract 2D induced velocity for VSM
if icp == jring && model === :VSM
if icp == jring && model === VSM
calculate_velocity_induced_bound_2D!(U_2D, body_aero.panels[jring], ep, body_aero.work_vectors)
body_aero.AIC[:, icp, jring] .-= U_2D
end
Expand Down Expand Up @@ -376,7 +377,7 @@ function update_effective_angle_of_attack_if_VSM(body_aero::BodyAerodynamics,

# Calculate AIC matrices at aerodynamic center using LLT method
calculate_AIC_matrices!(
body_aero, :LLT, core_radius_fraction, va_norm_array, va_unit_array
body_aero, LLT, core_radius_fraction, va_norm_array, va_unit_array
)
AIC_x, AIC_y, AIC_z = @views body_aero.AIC[1, :, :], body_aero.AIC[2, :, :], body_aero.AIC[3, :, :]

Expand All @@ -399,7 +400,7 @@ end

"""
calculate_results(body_aero::BodyAerodynamics, gamma_new::Vector{Float64},
density::Float64, aerodynamic_model_type::Symbol,
density::Float64, aerodynamic_model_type::Model,
core_radius_fraction::Float64, mu::Float64,
alpha_array::Vector{Float64}, v_a_array::Vector{Float64},
chord_array::Vector{Float64}, x_airf_array::Matrix{Float64},
Expand All @@ -418,7 +419,7 @@ function calculate_results(
gamma_new::Vector{Float64},
reference_point::AbstractVector,
density::Float64,
aerodynamic_model_type::Symbol,
aerodynamic_model_type::Model,
core_radius_fraction::Float64,
mu::Float64,
alpha_array::Vector{Float64},
Expand Down Expand Up @@ -454,7 +455,7 @@ function calculate_results(
moment = reshape((cm_array .* 0.5 .* density .* v_a_array.^2 .* chord_array), :, 1)

# Calculate alpha corrections based on model type
alpha_corrected = if aerodynamic_model_type === :VSM
alpha_corrected = if aerodynamic_model_type === VSM
update_effective_angle_of_attack_if_VSM(
body_aero,
gamma_new,
Expand All @@ -465,7 +466,7 @@ function calculate_results(
va_norm_array,
va_unit_array
)
elseif aerodynamic_model_type === :LLT
elseif aerodynamic_model_type === LLT
alpha_array
else
throw(ArgumentError("Unknown aerodynamic model type, should be LLT or VSM"))
Expand Down
2 changes: 1 addition & 1 deletion src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ Plot polar data comparing different solvers and configurations.
# Keyword arguments
- `literature_path_list`: Optional paths to literature data files
- `angle_range`: Range of angles to analyze [°]
- `angle_type`: "angle_of_attack" or "side_slip"; (default: `angle_of_attack`)
- `angle_type`: "`angle_of_attack`" or "`side_slip`"; (default: `angle_of_attack`)
- `angle_of_attack:` AoA to be used for plotting the polars (default: 0.0) [rad]
- `side_slip`: side slip angle (default: 0.0) [rad]
- v_a: norm of apparent wind speed (default: 10.0) [m/s]
Expand Down
4 changes: 2 additions & 2 deletions src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Main solver structure for the Vortex Step Method.
"""
struct Solver
# General settings
aerodynamic_model_type::Symbol
aerodynamic_model_type::Model
density::Float64
max_iterations::Int64
allowed_error::Float64
Expand All @@ -44,7 +44,7 @@ struct Solver
is_only_f_and_gamma_output::Bool

function Solver(;
aerodynamic_model_type::Symbol = :VSM,
aerodynamic_model_type::Model = VSM,
density::Float64 = 1.225,
max_iterations::Int64 = 1500,
allowed_error::Float64 = 1e-5,
Expand Down
2 changes: 2 additions & 0 deletions src/wing_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ end

Add a new section to the wing.

See also: [Wing](@ref), [PosVector](@ref)

# Arguments:
- LE_point::PosVector: position of the point on the side of the leading edge
- TE_point::PosVector: position of the point on the side of the leading edge
Expand Down
4 changes: 2 additions & 2 deletions test/bench.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using LinearAlgebra
va_norm_array = ones(n_panels)
va_unit_array = ones(n_panels, 3)

models = [:VSM, :LLT]
models = [VSM, LLT]
core_radius_fractions = [0.001, 10.0]

@testset "AIC Matrix Calculation" begin
Expand Down Expand Up @@ -158,7 +158,7 @@ using LinearAlgebra
$gamma,
$reference_point,
$density,
:VSM,
VSM,
1e-20,
0.0,
$alpha_array,
Expand Down
22 changes: 11 additions & 11 deletions test/test_body_aerodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include("utils.jl")
AR = span^2 / (π * span * max_chord / 4)
aoa = deg2rad(5)
v_a = [cos(aoa), 0.0, sin(aoa)] .* v_a
model = :VSM
model = VSM

# Setup wing geometry
dist = "cos"
Expand Down Expand Up @@ -139,7 +139,7 @@ end

# Calculate reference matrices using thesis functions
controlpoints, rings, bladepanels, ringvec, coord_L =
create_geometry_general(coord, v_a, N, "5fil", :LLT)
create_geometry_general(coord, v_a, N, "5fil", LLT)

# Test LLT matrices
@testset "LLT Matrices" begin
Expand All @@ -152,15 +152,15 @@ end
zeros(N-1),
nothing, # data_airf not needed
nothing, # conv_crit not needed
:LLT
LLT
)

# Calculate new matrices
va_norm_array = fill(norm(v_a), length(coord))
va_unit_array = repeat(reshape(v_a ./ norm(v_a), 1, 3), length(coord))
calculate_AIC_matrices!(
body_aero,
:LLT,
LLT,
core_radius_fraction,
va_norm_array,
va_unit_array
Expand All @@ -177,7 +177,7 @@ end
@testset "VSM Matrices" begin
# Calculate reference matrices for VSM
controlpoints, rings, bladepanels, ringvec, coord_L =
create_geometry_general(coord, v_a, N, "5fil", :VSM)
create_geometry_general(coord, v_a, N, "5fil", VSM)

MatrixU, MatrixV, MatrixW = thesis_induction_matrix_creation(
deepcopy(ringvec),
Expand All @@ -187,15 +187,15 @@ end
zeros(N-1),
nothing,
nothing,
:VSM
VSM
)

# Calculate new matrices
va_norm_array = fill(norm(v_a), length(coord))
va_unit_array = repeat(reshape(v_a ./ norm(v_a), 1, 3), length(coord))
calculate_AIC_matrices!(
body_aero,
:VSM,
VSM,
core_radius_fraction,
va_norm_array,
va_unit_array
Expand All @@ -211,7 +211,7 @@ end


@testset "Wing Geometry Creation" begin
function create_geometry(; model=:VSM, wing_type=:rectangular, plotting=false, N=40)
function create_geometry(; model=VSM, wing_type=:rectangular, plotting=false, N=40)
max_chord = 1.0
span = 17.0
AR = span^2 / (π * span * max_chord / 4)
Expand Down Expand Up @@ -257,7 +257,7 @@ end
return body_aero, coord, v_a, model
end

for model in [:VSM, :LLT]
for model in [VSM, LLT]
@debug "model: $model"
for wing_type in [:rectangular, :curved, :elliptical]
@debug "wing_type: $wing_type"
Expand All @@ -277,7 +277,7 @@ end
index_reversed = length(body_aero.panels) - i + 1
panel = body_aero.panels[index_reversed]

evaluation_point = if model === :VSM
evaluation_point = if model === VSM
panel.control_point
else # LLT
panel.aero_center
Expand All @@ -293,7 +293,7 @@ end
atol=1e-4
)

if model === :VSM
if model === VSM
@test isapprox(
panel.aero_center,
expected_controlpoints[i]["coordinates_aoa"],
Expand Down
4 changes: 2 additions & 2 deletions test/test_plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ plt.ioff()
rm("/tmp/Rectangular_wing_geometry_top_view.pdf")

# Step 5: Initialize the solvers
vsm_solver = Solver(aerodynamic_model_type=:VSM)
llt_solver = Solver(aerodynamic_model_type=:LLT)
vsm_solver = Solver(aerodynamic_model_type=VSM)
llt_solver = Solver(aerodynamic_model_type=LLT)

# Step 6: Solve the VSM and LLT
results_vsm = solve(vsm_solver, wa)
Expand Down
Loading
Loading