Repository navigation
Measure alpha in the plane square to the bound vortex (Gaunaa CP1) #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ Main structure for calculating aerodynamic properties of bodies. Use the constru | |
| influence coefficients, used only for the corrected angle of attack | ||
| - `projected_area::Float64` = 1.0: The area projected onto the xy-plane of the KA body frame [m²] | ||
| - `c_ref::Float64` = 1.0: Reference chord length (max panel chord) [m] | ||
| - `cache::Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}}` = [LazyBufferCache() for _ in 1:15] | ||
| - `cache::Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}}` = [LazyBufferCache() for _ in 1:12] | ||
| """ | ||
| @with_kw mutable struct BodyAerodynamics{P, W<:AbstractWing, T, PN<:Panel{T}} | ||
| panels::Vector{PN} | ||
|
|
@@ -49,7 +49,7 @@ Main structure for calculating aerodynamic properties of bodies. Use the constru | |
| AIC_aero_center::Array{T, 3} = zeros(T, P, P, 3) | ||
| projected_area::T = one(T) | ||
| c_ref::T = one(T) | ||
| cache::Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}} = [LazyBufferCache() for _ in 1:15] | ||
| cache::Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}} = [LazyBufferCache() for _ in 1:12] | ||
| end | ||
|
|
||
| """ | ||
|
|
@@ -523,20 +523,16 @@ end | |
|
|
||
| """ | ||
| update_effective_angle_of_attack!(alpha_corrected, body_aero::BodyAerodynamics, gamma, | ||
| core_radius_fraction, z_airf_dist, x_airf_dist, | ||
| va_vec_dist, va_dist, va_unit_dist) | ||
| core_radius_fraction, va_vec_dist, va_dist, | ||
| va_unit_dist) | ||
|
|
||
| Update angle of attack at aerodynamic center for VSM method. | ||
|
|
||
| Returns: | ||
| nothing | ||
| Write each panel's [`inflow_angle`](@ref) at its aerodynamic centre into | ||
| `alpha_corrected`, the induced velocity taken from `gamma` on the LLT influence matrix. | ||
| """ | ||
| function update_effective_angle_of_attack!(alpha_corrected, | ||
| body_aero::BodyAerodynamics, | ||
| body_aero::BodyAerodynamics, | ||
| gamma, | ||
| core_radius_fraction, | ||
| z_airf_dist, | ||
| x_airf_dist, | ||
| va_vec_dist, | ||
| va_dist, | ||
| va_unit_dist) | ||
|
|
@@ -551,31 +547,11 @@ function update_effective_angle_of_attack!(alpha_corrected, | |
| mul!(view(induced_velocity, :, k), view(body_aero.AIC_aero_center, :, :, k), gamma) | ||
| end | ||
|
|
||
| # In-place relative velocity calculation | ||
| relative_velocity = body_aero.cache[2][va_vec_dist] | ||
| relative_velocity .= va_vec_dist .+ induced_velocity | ||
|
|
||
| # Preallocate and compute dot products manually | ||
| n = size(relative_velocity, 1) | ||
| v_normal = body_aero.cache[3][relative_velocity] | ||
| v_tangential = body_aero.cache[4][relative_velocity] | ||
|
|
||
| @inbounds for i in 1:n | ||
| vn = 0.0 | ||
| vt = 0.0 | ||
| for j in 1:3 | ||
| vn += z_airf_dist[i, j] * relative_velocity[i, j] | ||
| vt += x_airf_dist[i, j] * relative_velocity[i, j] | ||
| end | ||
| v_normal[i] = vn | ||
| v_tangential[i] = vt | ||
| end | ||
|
|
||
| # Direct angle calculation without temporary arrays | ||
| @inbounds for i in 1:n | ||
| alpha_corrected[i] = atan(v_normal[i], v_tangential[i]) | ||
| @inbounds for (i, panel) in enumerate(body_aero.panels) | ||
| v_rel = matrix_row(va_vec_dist, i) .+ matrix_row(induced_velocity, i) | ||
| alpha_corrected[i] = inflow_angle(v_rel, SVector{3}(panel.y_airf), | ||
| SVector{3}(panel.z_airf)) | ||
| end | ||
|
|
||
| nothing | ||
| end | ||
|
|
||
|
|
@@ -832,21 +808,21 @@ function calculate_results( | |
| ) | ||
|
|
||
| n_panels = length(panels) | ||
| if length(body_aero.cache) < 15 | ||
| append!(body_aero.cache, [LazyBufferCache() for _ in 1:(15 - length(body_aero.cache))]) | ||
| if length(body_aero.cache) < 12 | ||
| append!(body_aero.cache, [LazyBufferCache() for _ in 1:(12 - length(body_aero.cache))]) | ||
| end | ||
|
|
||
| cl_dist = body_aero.cache[5][alpha_dist] | ||
| cd_dist = body_aero.cache[6][alpha_dist] | ||
| cm_dist = body_aero.cache[7][alpha_dist] | ||
| panel_width_dist = body_aero.cache[8][alpha_dist] | ||
| alpha_corrected = body_aero.cache[9][alpha_dist] | ||
| cl_prescribed_va = body_aero.cache[10][alpha_dist] | ||
| cd_prescribed_va = body_aero.cache[11][alpha_dist] | ||
| cs_prescribed_va = body_aero.cache[12][alpha_dist] | ||
| f_body_3D = body_aero.cache[13][alpha_dist, (3, length(alpha_dist))] | ||
| m_body_3D = body_aero.cache[14][alpha_dist, (3, length(alpha_dist))] | ||
| alpha_geometric = body_aero.cache[15][alpha_dist] | ||
| cl_dist = body_aero.cache[2][alpha_dist] | ||
| cd_dist = body_aero.cache[3][alpha_dist] | ||
| cm_dist = body_aero.cache[4][alpha_dist] | ||
| panel_width_dist = body_aero.cache[5][alpha_dist] | ||
| alpha_corrected = body_aero.cache[6][alpha_dist] | ||
| cl_prescribed_va = body_aero.cache[7][alpha_dist] | ||
| cd_prescribed_va = body_aero.cache[8][alpha_dist] | ||
| cs_prescribed_va = body_aero.cache[9][alpha_dist] | ||
| f_body_3D = body_aero.cache[10][alpha_dist, (3, length(alpha_dist))] | ||
| m_body_3D = body_aero.cache[11][alpha_dist, (3, length(alpha_dist))] | ||
| alpha_geometric = body_aero.cache[12][alpha_dist] | ||
|
|
||
| fill!(f_body_3D, 0.0) | ||
| fill!(m_body_3D, 0.0) | ||
|
|
@@ -861,19 +837,8 @@ function calculate_results( | |
| body_aero.pitch_rate_dist[i], chord_dist[i], v_rel_dist[i]) | ||
| end | ||
| panel_width_dist[i] = panel.width | ||
| va = va_dist[i] | ||
| x_norm = norm3(panel.x_airf) | ||
| z_norm = norm3(panel.z_airf) | ||
| if va == 0.0 || x_norm == 0.0 || z_norm == 0.0 | ||
| alpha_geometric[i] = NaN | ||
| else | ||
| inv_va = 1.0 / va | ||
| v_tangential = -dot3(panel.x_airf, panel.va_vec) * | ||
| inv_va / x_norm | ||
| v_normal = -dot3(panel.z_airf, panel.va_vec) * | ||
| inv_va / z_norm | ||
| alpha_geometric[i] = atan(-v_normal, -v_tangential) | ||
| end | ||
| alpha_geometric[i] = iszero(va_dist[i]) ? NaN : inflow_angle(panel.va_vec, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MINOR: This line drops the last use of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| SVector{3}(panel.y_airf), SVector{3}(panel.z_airf)) | ||
| end | ||
|
|
||
| # Calculate alpha corrections based on model type | ||
|
|
@@ -883,8 +848,6 @@ function calculate_results( | |
| body_aero, | ||
| gamma_new, | ||
| core_radius_fraction, | ||
| z_airf_dist, | ||
| x_airf_dist, | ||
| va_vec_dist, | ||
| va_dist, | ||
| va_unit_dist | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MINOR: After this rewrite nothing reads
body_aero.cacheslots 2–4, yet BodyAerodynamics still allocates 15. The solver cache was trimmed from 10 to 8; this one was left behind, contrary to §2 on removing what a change stops using.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 746e79b: the cache is 12 slots, renumbered, nothing unused.