Skip to content

Commit 6d69a25

Browse files
committed
cleanup
1 parent 61c3434 commit 6d69a25

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/body_aerodynamics.jl

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
21
"""
32
BodyAerodynamics
43
54
Main structure for calculating aerodynamic properties of bodies.
65
76
# Fields
87
- panels::Vector{Panel}: Vector of Panel structs
9-
- n_panels::Int64: number of panels
108
- wings::Vector{AbstractWing}: a vector of wings; a body can have multiple wings
119
- `_va`::Union{Nothing, Vector{Float64}, Tuple{Vector{Float64}, Float64}}: A vector of the apparent wind speed,
1210
or a tuple of the v_a vector and yaw rate (rad/s).
13-
- ` gamma_distribution`::Union{Nothing, Vector{Float64}}: unclear, please defined
11+
- `gamma_distribution`::Union{Nothing, Vector{Float64}}: unclear, please defined
1412
- `alpha_uncorrected`::Union{Nothing, Vector{Float64}}: unclear, please define
1513
- `alpha_corrected`::Union{Nothing, Vector{Float64}}: unclear, please define
1614
- `stall_angle_list`::Vector{Float64}: unclear, please define
1715
"""
1816
mutable struct BodyAerodynamics
1917
panels::Vector{Panel}
20-
n_panels::Int64 # TODO: Why is this needed? Just use length(panels)
2118
wings::Vector{AbstractWing} # TODO: Why not a concrete type? And why a vector?
2219
_va::Union{Nothing, Vector{Float64}, Tuple{Vector{Float64}, Float64}}
2320
gamma_distribution::Union{Nothing, Vector{Float64}}
@@ -74,7 +71,6 @@ mutable struct BodyAerodynamics
7471

7572
new(
7673
panels,
77-
n_panels,
7874
wings,
7975
nothing, # va
8076
nothing, # gamma_distribution
@@ -248,12 +244,12 @@ function calculate_AIC_matrices(wa::BodyAerodynamics, model::String,
248244
evaluation_point_on_bound = model == "LLT"
249245

250246
# Initialize AIC matrices
251-
AIC = zeros(3, wa.n_panels, wa.n_panels)
247+
AIC = zeros(3, length(wa.panels), length(wa.panels))
252248

253249
# Calculate influence coefficients
254-
for icp in 1:wa.n_panels
250+
for icp in 1:length(wa.panels)
255251
ep = getproperty(wa.panels[icp], evaluation_point)
256-
for jring in 1:wa.n_panels
252+
for jring in 1:length(wa.panels)
257253
velocity_induced = calculate_velocity_induced_single_ring_semiinfinite(
258254
wa.panels[jring],
259255
ep,
@@ -628,7 +624,7 @@ Set velocity array and update wake filaments.
628624
"""
629625
function set_va!(wa::BodyAerodynamics, va)
630626
# Add length check for va_vec
631-
if va isa Vector{Float64} && length(va) != 3 && length(va) != wa.n_panels
627+
if va isa Vector{Float64} && length(va) != 3 && length(va) != length(wa.panels)
632628
throw(ArgumentError("va must be length 3 or match number of panels"))
633629
end
634630
# Handle input types
@@ -643,8 +639,8 @@ function set_va!(wa::BodyAerodynamics, va)
643639

644640
# Calculate va_distribution based on input type
645641
va_distribution = if length(va_vec) == 3 && yaw_rate == 0.0
646-
repeat(reshape(va_vec, 1, 3), wa.n_panels)
647-
elseif length(va_vec) == wa.n_panels
642+
repeat(reshape(va_vec, 1, 3), length(wa.panels))
643+
elseif length(va_vec) == length(wa.panels)
648644
va_vec
649645
elseif yaw_rate != 0.0 && length(va_vec) == 3
650646
va_dist = Vector{Float64}[]
@@ -661,7 +657,7 @@ function set_va!(wa::BodyAerodynamics, va)
661657
end
662658
reduce(vcat, va_dist)
663659
else
664-
throw(ArgumentError("Invalid va distribution: length(va)=$(length(va_vec)) ≠ n_panels=$(wa.n_panels)"))
660+
throw(ArgumentError("Invalid va distribution: length(va)=$(length(va_vec)) ≠ n_panels=$(length(wa.panels))"))
665661
end
666662

667663
# Update panel velocities

0 commit comments

Comments
 (0)