@@ -16,7 +16,8 @@ mutable struct WingAerodynamics
1616
1717 alpha_array:: Vector{Float64}
1818 v_a_array:: Vector{Float64}
19- work_vectors:: NTuple{10,Vector{Float64}}
19+ work_vectors:: NTuple{10,MVec3}
20+ AIC:: Array{Float64, 3}
2021
2122 function WingAerodynamics (
2223 wings:: Vector{T} ;
@@ -60,7 +61,8 @@ mutable struct WingAerodynamics
6061 alpha_array = zeros (n_panels)
6162 v_a_array = zeros (n_panels)
6263 work_vectors = ntuple (_ -> Vector {Float64} (undef, 3 ), 10 )
63-
64+ AIC = zeros (3 , n_panels, n_panels)
65+
6466 new (
6567 panels,
6668 n_panels,
@@ -72,7 +74,8 @@ mutable struct WingAerodynamics
7274 stall_angle_list,
7375 alpha_array,
7476 v_a_array,
75- work_vectors
77+ work_vectors,
78+ AIC
7679 )
7780 end
7881end
@@ -206,7 +209,7 @@ function calculate_panel_properties(section_list::Vector{Section}, n_panels::Int
206209end
207210
208211"""
209- calculate_AIC_matrices(wa::WingAerodynamics, model::String,
212+ calculate_AIC_matrices! (wa::WingAerodynamics, model::String,
210213 core_radius_fraction::Float64,
211214 va_norm_array::Vector{Float64},
212215 va_unit_array::Matrix{Float64})
@@ -216,35 +219,41 @@ Calculate Aerodynamic Influence Coefficient matrices.
216219Returns:
217220 Tuple of (AIC_x, AIC_y, AIC_z) matrices
218221"""
219- function calculate_AIC_matrices (wa:: WingAerodynamics , model:: String ,
220- core_radius_fraction:: Float64 ,
221- va_norm_array:: Vector{Float64} ,
222- va_unit_array:: Matrix{Float64} )
222+ function calculate_AIC_matrices! (wa:: WingAerodynamics , model,
223+ core_radius_fraction,
224+ va_norm_array,
225+ va_unit_array)
223226 model in [" VSM" , " LLT" ] || throw (ArgumentError (" Model must be VSM or LLT" ))
224-
225227 # Determine evaluation point based on model
226228 evaluation_point = model == " VSM" ? :control_point : :aerodynamic_center
227229 evaluation_point_on_bound = model == " LLT"
228230
229231 # Initialize AIC matrices
230- AIC = zeros (3 , wa. n_panels, wa. n_panels)
232+ AIC = @views wa. AIC
233+ velocity_induced, tempvel, va_unit = zeros (MVec3), zeros (MVec3), zeros (MVec3)
231234
232235 # Calculate influence coefficients
233236 for icp in 1 : wa. n_panels
234237 ep = getproperty (wa. panels[icp], evaluation_point)
235238 for jring in 1 : wa. n_panels
236- velocity_induced = calculate_velocity_induced_single_ring_semiinfinite (
239+ velocity_induced .= 0.0
240+ tempvel .= 0.0
241+ va_unit .= @views va_unit_array[jring, :]
242+ wa. panels[jring]
243+ calculate_velocity_induced_single_ring_semiinfinite! (
244+ velocity_induced,
245+ tempvel,
237246 wa. panels[jring],
238247 ep,
239248 evaluation_point_on_bound,
240249 va_norm_array[jring],
241- va_unit_array[jring, :] ,
250+ va_unit ,
242251 1.0 ,
243252 core_radius_fraction,
244253 wa. work_vectors
245254 )
246255
247- AIC[:, icp, jring] = velocity_induced
256+ AIC[:, icp, jring] . = velocity_induced
248257
249258 # Subtract 2D induced velocity for VSM
250259 if icp == jring && model == " VSM"
@@ -253,8 +262,7 @@ function calculate_AIC_matrices(wa::WingAerodynamics, model::String,
253262 end
254263 end
255264 end
256-
257- return AIC[1 , :, :], AIC[2 , :, :], AIC[3 , :, :]
265+ return nothing
258266end
259267
260268"""
@@ -352,9 +360,10 @@ function update_effective_angle_of_attack_if_VSM(wa::WingAerodynamics,
352360 va_unit_array:: Matrix{Float64} )
353361
354362 # Calculate AIC matrices at aerodynamic center using LLT method
355- AIC_x, AIC_y, AIC_z = calculate_AIC_matrices (
363+ calculate_AIC_matrices! (
356364 wa, " LLT" , core_radius_fraction, va_norm_array, va_unit_array
357365 )
366+ AIC_x, AIC_y, AIC_z = @views wa. AIC[1 , :, :], wa. AIC[2 , :, :], wa. AIC[3 , :, :]
358367
359368 # Calculate induced velocities
360369 induced_velocity = [
0 commit comments