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
7 changes: 6 additions & 1 deletion src/kite_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,19 @@ function RamAirWing(obj_path, dat_path; alpha=0.0, crease_frac=0.75, wind_vel=10

# Create sections
sections = Section[]
refined_sections = Section[]
non_deformed_sections = Section[]
for gamma in range(-gamma_tip, gamma_tip, n_sections)
aero_data = (collect(alpha_range), collect(delta_range), cl_matrix, cd_matrix, cm_matrix)
LE_point = [le_interp[i](gamma) for i in 1:3]
TE_point = [te_interp[i](gamma) for i in 1:3]
push!(sections, Section(LE_point, TE_point, POLAR_MATRICES, aero_data))
push!(refined_sections, Section(LE_point, TE_point, POLAR_MATRICES, aero_data))
push!(non_deformed_sections, Section(LE_point, TE_point, POLAR_MATRICES, aero_data))
end

RamAirWing(n_panels, spanwise_panel_distribution, spanwise_direction, sections, sections, remove_nan, sections,
RamAirWing(n_panels, spanwise_panel_distribution, spanwise_direction, sections,
refined_sections, remove_nan, non_deformed_sections,
mass, circle_center_z, gamma_tip, inertia_tensor, radius,
le_interp, te_interp, area_interp, zeros(n_panels), zeros(n_panels))
end
Expand Down
11 changes: 5 additions & 6 deletions src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,10 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
log=false, reference_point=zeros(MVec3), moment_frac=0.1)

# calculate intermediate result
(converged,
body_aero, gamma_new, reference_point, density, aerodynamic_model_type, core_radius_fraction,
mu, alpha_array, v_a_array, chord_array, x_airf_array, y_airf_array, z_airf_array,
va_array, va_norm_array, va_unit_array, panels,
is_only_f_and_gamma_output) = solve_base(solver, body_aero, gamma_distribution; log, reference_point)
(converged, body_aero, gamma_new, reference_point, density, aerodynamic_model_type, core_radius_fraction,
mu, alpha_array, v_a_array, chord_array, x_airf_array, y_airf_array, z_airf_array,
va_array, va_norm_array, va_unit_array, panels,
is_only_f_and_gamma_output) = solve_base(solver, body_aero, gamma_distribution; log, reference_point)
if !isnothing(solver.sol.gamma_distribution)
solver.sol.gamma_distribution .= gamma_new
else
Expand Down Expand Up @@ -242,7 +241,7 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
# Calculate the moment distribution (moment on each panel)
arm = (moment_frac - 0.25) * panel.chord
moment_distribution[i] = dot(ftotal_induced_va, panel.z_airf) * arm
moment_coefficient_distribution[i] = moment_distribution[i] ./ (q_inf * projected_area)
moment_coefficient_distribution[i] = moment_distribution[i] / (q_inf * projected_area)
end

# update the result struct
Expand Down
36 changes: 36 additions & 0 deletions test/test_kite_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,42 @@ using Serialization
@test isnan(wing.sections[1].aero_data[4][end])
@test isnan(wing.sections[1].aero_data[5][end])
end

@testset "Wing Deformation" begin
# Create a RamAirWing for testing
wing = RamAirWing(test_obj_path, test_dat_path; remove_nan=true)
body_aero = BodyAerodynamics([wing])

# Store original TE point for comparison
i = length(body_aero.panels) ÷ 2
original_te_point = copy(body_aero.panels[i].TE_point_1)

# Apply deformation with non-zero angles
theta_dist = fill(deg2rad(30.0), wing.n_panels) # 10 degrees twist
delta_dist = fill(deg2rad(5.0), wing.n_panels) # 5 degrees trailing edge deflection

VortexStepMethod.deform!(wing, theta_dist, delta_dist)
VortexStepMethod.init!(body_aero)

# Check if TE point changed after deformation
deformed_te_point = copy(body_aero.panels[i].TE_point_1)
@test !isapprox(original_te_point, deformed_te_point, atol=1e-2)
@test deformed_te_point[3] < original_te_point[3] # right hand rule
@test deformed_te_point[2] ≈ original_te_point[2] atol=1e-2 # right hand rule
@test deformed_te_point[1] < original_te_point[1] # right hand rule
@test body_aero.panels[i].delta ≈ deg2rad(5.0)

# Reset deformation with zero angles
zero_theta_dist = zeros(wing.n_panels)
zero_delta_dist = zeros(wing.n_panels)

VortexStepMethod.deform!(wing, zero_theta_dist, zero_delta_dist)
VortexStepMethod.init!(body_aero)

# Check if TE point returned to original position
reset_te_point = copy(body_aero.panels[i].TE_point_1)
@test original_te_point ≈ reset_te_point atol=1e-4
end

rm(test_obj_path)
rm(test_dat_path)
Expand Down
Loading