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 Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 16 additions & 0 deletions src/VortexStepMethod.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module VortexStepMethod

using LinearAlgebra
using StaticArrays
using Logging
using Statistics
using Colors
Expand All @@ -18,6 +19,21 @@ 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}

"""
const PosVector=Union{MVec3, Vector}

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")
include("filament.jl")
Expand Down
16 changes: 8 additions & 8 deletions src/filament.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down
14 changes: 7 additions & 7 deletions src/panel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/wing_aerodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
4 changes: 2 additions & 2 deletions src/wing_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
12 changes: 6 additions & 6 deletions test/test_semi_infinite_filament.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)

Expand Down
Loading