@@ -28,7 +28,6 @@ Main structure for calculating aerodynamic properties of bodies. Use the constru
2828 influence coefficients, used only for the corrected angle of attack
2929- `projected_area::Float64` = 1.0: The area projected onto the xy-plane of the kite body reference frame [m²]
3030- `c_ref::Float64` = 1.0: Reference chord length (max panel chord) [m]
31- - `y::MVector{P, Float64}` = MVector{P,Float64}(zeros(P))
3231- `cache::Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}}` = [LazyBufferCache() for _ in 1:15]
3332"""
3433@with_kw mutable struct BodyAerodynamics{P, W<: AbstractWing , T, PN<: Panel{T} }
@@ -50,7 +49,6 @@ Main structure for calculating aerodynamic properties of bodies. Use the constru
5049 AIC_aero_center:: Array{T, 3} = zeros (T, P, P, 3 )
5150 projected_area:: T = one (T)
5251 c_ref:: T = one (T)
53- y:: MVector{P, T} = zeros (MVector{P, T})
5452 cache:: Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}} = [LazyBufferCache () for _ in 1 : 15 ]
5553end
5654
@@ -494,30 +492,26 @@ Returns: nothing
494492end
495493
496494"""
497- calculate_circulation_distribution_elliptical_wing(body_aero::BodyAerodynamics, gamma_0=1.0)
495+ calculate_circulation_distribution_elliptical_wing(gamma_i, body_aero::BodyAerodynamics,
496+ gamma_0=1.0)
498497
499- Calculate circulation distribution for an elliptical wing.
500-
501- Returns: nothing
498+ Write into `gamma_i` an elliptic circulation of peak `gamma_0` over each wing, its control
499+ points measured along that wing's `spanwise_direction` from the wing's mid-span.
502500"""
503- function calculate_circulation_distribution_elliptical_wing (gamma_i, body_aero:: BodyAerodynamics , gamma_0= 1.0 )
504- length (body_aero. wings) == 1 || throw (ArgumentError (" Multiple wings not yet implemented" ))
505-
506- wing_span = body_aero. wings[1 ]. span
507- @debug " Wing span: $wing_span "
508-
509- # Calculate y-coordinates of control points
510- y = body_aero. y
511- for (i, panel) in pairs (body_aero. panels)
512- y[i] = panel. control_point[2 ]
501+ function calculate_circulation_distribution_elliptical_wing (gamma_i,
502+ body_aero:: BodyAerodynamics , gamma_0= 1.0 )
503+ panel_offset = 0
504+ for wing in body_aero. wings
505+ lo, hi = spanwise_extent (wing)
506+ axis = normalize (wing. spanwise_direction)
507+ for i in panel_offset .+ (1 : wing. n_panels)
508+ span_position = dot (body_aero. panels[i]. control_point, axis) - (lo + hi) / 2
509+ # Clamped: a control point can lie outside the span of the unrefined sections
510+ gamma_i[i] = gamma_0 * sqrt (max (0.0 , 1 - (2 span_position / (hi - lo))^ 2 ))
511+ end
512+ panel_offset += wing. n_panels
513513 end
514-
515- # Calculate elliptical distribution (clamp to avoid sqrt of negative
516- # when control points lie outside the nominal span envelope)
517- gamma_i .= gamma_0 * sqrt .(max .(0.0 , 1 .- (2 .* y ./ wing_span). ^ 2 ))
518-
519- @debug " Calculated circulation distribution: $gamma_i "
520- nothing
514+ return nothing
521515end
522516
523517"""
0 commit comments