From 906cd2aa5e456074dfcd393f1677700fb9652bb5 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Mon, 17 Feb 2025 05:35:02 +0100 Subject: [PATCH 1/7] Add type MVec3 --- Project.toml | 1 + src/VortexStepMethod.jl | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Project.toml b/Project.toml index 592eeb16..5c9ed345 100644 --- a/Project.toml +++ b/Project.toml @@ -12,5 +12,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/VortexStepMethod.jl b/src/VortexStepMethod.jl index e0623806..6bb88609 100644 --- a/src/VortexStepMethod.jl +++ b/src/VortexStepMethod.jl @@ -1,6 +1,7 @@ module VortexStepMethod using LinearAlgebra +using StaticArrays using Logging using Statistics using Colors @@ -18,6 +19,13 @@ export add_section!, set_va! export calculate_span, calculate_projected_area export plot_wing, plot_circulation_distribution, plot_geometry, plot_distribution, plot_polars +""" + const MVec3 = MVector{3, Float64} + +Basic 3-dimensional vector, stack allocated, mutable. +""" +const MVec3 = MVector{3, Float64} + # Include core functionality include("wing_geometry.jl") include("filament.jl") From 1fca784b00a7d1773781bdac1c783fe495335c61 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Mon, 17 Feb 2025 05:58:05 +0100 Subject: [PATCH 2/7] add PosVector --- src/VortexStepMethod.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/VortexStepMethod.jl b/src/VortexStepMethod.jl index 6bb88609..9a51072a 100644 --- a/src/VortexStepMethod.jl +++ b/src/VortexStepMethod.jl @@ -26,6 +26,13 @@ Basic 3-dimensional vector, stack allocated, mutable. """ const MVec3 = MVector{3, Float64} +""" + const PosVector=Union{MVec3, Vector} + +Position vector, either a `MVec3` or a `Vector` for use in function signatures. +""" +const PosVector=Union{MVec3, Vector} + # Include core functionality include("wing_geometry.jl") include("filament.jl") From c30b375eea8208edb8a5c79ebb9a73cd65feb01c Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Mon, 17 Feb 2025 06:12:32 +0100 Subject: [PATCH 3/7] fix warning --- test/test_semi_infinite_filament.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_semi_infinite_filament.jl b/test/test_semi_infinite_filament.jl index b566d896..f220ff9b 100644 --- a/test/test_semi_infinite_filament.jl +++ b/test/test_semi_infinite_filament.jl @@ -3,7 +3,7 @@ using LinearAlgebra using Test using BenchmarkTools -function create_test_filament() +function create_test_filament2() x1 = [0.0, 0.0, 0.0] direction = [1.0, 0.0, 0.0] filament_direction = 1 @@ -41,7 +41,7 @@ end work_vectors = ntuple(_ -> Vector{Float64}(undef, 3), 10) @testset "Allocation Tests" begin - filament = create_test_filament() + filament = create_test_filament2() control_point = [0.5, 0.5, 2.0] induced_velocity = zeros(3) @@ -60,7 +60,7 @@ end end @testset "Calculate Induced Velocity" begin - filament = create_test_filament() + filament = create_test_filament2() control_point = [0.5, 0.5, 2.0] induced_velocity = zeros(3) @@ -83,7 +83,7 @@ end end @testset "Point on Filament" begin - filament = create_test_filament() + filament = create_test_filament2() test_points = [ [0.0, 0.0, 0.0], # Start point [0.5, 0.0, 0.0], # Along filament @@ -106,7 +106,7 @@ end end @testset "Different Gamma Values" begin - filament = create_test_filament() + filament = create_test_filament2() control_point = [0.5, 1.0, 0.0] v1 = zeros(3) v2 = zeros(3) @@ -121,7 +121,7 @@ end end @testset "Symmetry" begin - filament = create_test_filament() + filament = create_test_filament2() vel_pos = zeros(3) vel_neg = zeros(3) From bc68ad9a3c20d6210346eb4069b369a0533865a0 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Mon, 17 Feb 2025 06:13:05 +0100 Subject: [PATCH 4/7] add type VelVector --- src/VortexStepMethod.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/VortexStepMethod.jl b/src/VortexStepMethod.jl index 9a51072a..42b4b51c 100644 --- a/src/VortexStepMethod.jl +++ b/src/VortexStepMethod.jl @@ -32,6 +32,7 @@ const MVec3 = MVector{3, Float64} Position vector, either a `MVec3` or a `Vector` for use in function signatures. """ const PosVector=Union{MVec3, Vector} +const VelVector=Union{MVec3, Vector} # Include core functionality include("wing_geometry.jl") From ce8d684112759efa86a3055d39dc7bbd394e4c7b Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Mon, 17 Feb 2025 06:13:38 +0100 Subject: [PATCH 5/7] use PosVector and VelVector --- src/panel.jl | 14 +++++++------- src/wing_geometry.jl | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/panel.jl b/src/panel.jl index c974b9d6..f572cac0 100644 --- a/src/panel.jl +++ b/src/panel.jl @@ -50,10 +50,10 @@ mutable struct Panel function Panel( section_1::Section, section_2::Section, - aerodynamic_center::Vector{Float64}, - control_point::Vector{Float64}, - bound_point_1::Vector{Float64}, - bound_point_2::Vector{Float64}, + aerodynamic_center::PosVector, + control_point::PosVector, + bound_point_1::PosVector, + bound_point_2::PosVector, x_airf::Vector{Float64}, y_airf::Vector{Float64}, z_airf::Vector{Float64} @@ -352,10 +352,10 @@ Calculate the velocity induced by a vortex ring at a control point. """ function calculate_velocity_induced_single_ring_semiinfinite( panel::Panel, - evaluation_point::Vector{Float64}, + evaluation_point::PosVector, evaluation_point_on_bound::Bool, va_norm::Float64, - va_unit::Vector{Float64}, + va_unit::VelVector, gamma::Float64, core_radius_fraction::Float64, work_vectors::NTuple{10,Vector{Float64}} @@ -421,7 +421,7 @@ Only needed for VSM, as LLT bound and filament align, thus no induced velocity. """ function calculate_velocity_induced_bound_2D( panel::Panel, - evaluation_point::Vector{Float64} + evaluation_point::PosVector ) # r3 perpendicular to the bound vortex r3 = evaluation_point - (panel.bound_point_1 + panel.bound_point_2) / 2 diff --git a/src/wing_geometry.jl b/src/wing_geometry.jl index d89e5c2f..be662d19 100644 --- a/src/wing_geometry.jl +++ b/src/wing_geometry.jl @@ -62,8 +62,8 @@ mutable struct Wing end """ - add_section!(wing::Wing, LE_point::Vector{Float64}, - TE_point::Vector{Float64}, aero_input::Vector{Any}) + add_section!(wing::Wing, LE_point::PosVector, + TE_point::PosVector, aero_input::Vector{Any}) Add a new section to the wing. """ From be458ecd60b68789d1428456d937c81606465900 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Mon, 17 Feb 2025 06:36:05 +0100 Subject: [PATCH 6/7] use PosVector and VelVector --- src/filament.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/filament.jl b/src/filament.jl index 25b56b5c..1d6229b5 100644 --- a/src/filament.jl +++ b/src/filament.jl @@ -19,7 +19,7 @@ struct BoundFilament <: Filament length::Float64 # Filament length r0::Vector{Float64} # Vector from x1 to x2 - function BoundFilament(x1::Vector{Float64}, x2::Vector{Float64}) + function BoundFilament(x1::PosVector, x2::PosVector) new(x1, x2, norm(x2 - x1), x2 - x1) end end @@ -31,9 +31,9 @@ end Calculate induced velocity by a bound vortex filament at a point in space. """ function velocity_3D_bound_vortex!( - vel::Vector{Float64}, + vel::VelVector, filament::BoundFilament, - XVP::Vector{Float64}, + XVP::PosVector, gamma::Float64, core_radius_fraction::Float64, work_vectors::NTuple{10, Vector{Float64}} @@ -95,9 +95,9 @@ Reference: Rick Damiani et al. "A vortex step method for nonlinear airfoil polar as implemented in KiteAeroDyn". """ function velocity_3D_trailing_vortex!( - vel::Vector{Float64}, + vel::VelVector, filament::BoundFilament, - XVP::Vector{Float64}, + XVP::PosVector, gamma::Float64, Uinf::Float64, work_vectors::NTuple{10,Vector{Float64}} @@ -162,10 +162,10 @@ end Calculate induced velocity by a semi-infinite trailing vortex filament. """ function velocity_3D_trailing_vortex_semiinfinite!( - vel::Vector{Float64}, + vel::VelVector, filament::SemiInfiniteFilament, - Vf::Vector{Float64}, - XVP::Vector{Float64}, + Vf::VelVector, + XVP::PosVector, GAMMA::Float64, Uinf::Float64, work_vectors::NTuple{10,Vector{Float64}} From 555bffe1e7b32129539d837ca6f04162a0e35bb7 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Mon, 17 Feb 2025 06:45:00 +0100 Subject: [PATCH 7/7] use PosVector --- src/wing_aerodynamics.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wing_aerodynamics.jl b/src/wing_aerodynamics.jl index b318ca3f..db56ca07 100644 --- a/src/wing_aerodynamics.jl +++ b/src/wing_aerodynamics.jl @@ -83,10 +83,10 @@ end Structure to hold calculated panel properties. """ struct PanelProperties - aero_centers::Vector{Vector{Float64}} - control_points::Vector{Vector{Float64}} - bound_points_1::Vector{Vector{Float64}} - bound_points_2::Vector{Vector{Float64}} + aero_centers::Vector{PosVector} + control_points::Vector{PosVector} + bound_points_1::Vector{PosVector} + bound_points_2::Vector{PosVector} x_airf::Vector{Vector{Float64}} y_airf::Vector{Vector{Float64}} z_airf::Vector{Vector{Float64}}