Skip to content

Commit e56c5c8

Browse files
authored
deform with dist instead of left-right (#123)
1 parent 338c2c5 commit e56c5c8

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

examples/ram_air_kite.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ wing = RamAirWing("data/ram_air_kite_body.obj", "data/ram_air_kite_foil.dat")
1111
body_aero = BodyAerodynamics([wing];)
1212

1313
if DEFORM
14-
alpha = [deg2rad(10), 0]
15-
delta = [deg2rad(10), 0]
16-
@time VortexStepMethod.deform!(wing, alpha, delta; width=1.0)
14+
# Linear interpolation of alpha from 10° at one tip to 0° at the other
15+
n_panels = wing.n_panels
16+
theta_start = deg2rad(10)
17+
theta_end = deg2rad(0)
18+
delta_start = deg2rad(10)
19+
delta_end = deg2rad(0)
20+
theta_dist = [theta_start - i * (theta_start - theta_end)/(n_panels-1) for i in 0:(n_panels-1)]
21+
delta_dist = [delta_start - i * (delta_start - delta_end)/(n_panels-1) for i in 0:(n_panels-1)]
22+
@time VortexStepMethod.deform!(wing, theta_dist, delta_dist)
1723
@time VortexStepMethod.init!(body_aero)
1824
end
1925

src/kite_geometry.jl

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ mutable struct RamAirWing <: AbstractWing
337337
le_interp::NTuple{3, Extrapolation}
338338
te_interp::NTuple{3, Extrapolation}
339339
area_interp::Extrapolation
340-
alpha_dist::Vector{Float64}
340+
theta_dist::Vector{Float64}
341341
delta_dist::Vector{Float64}
342342
end
343343

@@ -426,45 +426,33 @@ function RamAirWing(obj_path, dat_path; alpha=0.0, crease_frac=0.75, wind_vel=10
426426
end
427427

428428
"""
429-
deform!(wing::RamAirWing, alphas::AbstractVector, deltas::AbstractVector; width)
429+
deform!(wing::RamAirWing, theta_dist::AbstractVector, delta_dist::AbstractVector; width)
430430
431-
Deform wing by applying left and right alpha and delta.
431+
Deform wing by applying theta and delta distributions.
432432
433433
# Arguments
434434
- `wing`: RamAirWing to deform
435-
- `alphas`: [left, right] the angle between of the kite and the body x-axis in radians
436-
- `deltas`: [left, right] the deformation of the trailing edges
437-
- `width`: Transition width in meters to smoothe out the transition from left to right deformation
435+
- `theta_dist`: the angle distribution between of the kite and the body x-axis in radians of each panel
436+
- `delta_dist`: the deformation of the trailing edges of each panel
438437
439438
# Effects
440439
Updates wing.sections with deformed geometry
441440
"""
442-
function deform!(wing::RamAirWing, alphas::AbstractVector, deltas::AbstractVector; width)
441+
function deform!(wing::RamAirWing, theta_dist::AbstractVector, delta_dist::AbstractVector)
442+
!(length(theta_dist) == wing.n_panels) && throw(ArgumentError("theta_dist and panels are of different lengths"))
443+
!(length(delta_dist) == wing.n_panels) && throw(ArgumentError("delta_dist and panels are of different lengths"))
444+
wing.theta_dist .= theta_dist
445+
wing.delta_dist .= delta_dist
446+
443447
local_y = zeros(MVec3)
444448
chord = zeros(MVec3)
445449

446-
for (i, gamma) in enumerate(range(-wing.gamma_tip, wing.gamma_tip, wing.n_panels))
447-
normalized_gamma = (gamma * wing.radius / width + 0.5) # Maps [-0.5, 0.5] to [0, 1]
448-
wing.alpha_dist[i] = if normalized_gamma <= 0.0
449-
alphas[1]
450-
elseif normalized_gamma >= 1.0
451-
alphas[2]
452-
else
453-
alphas[1] * (1.0 - normalized_gamma) + alphas[2] * normalized_gamma
454-
end
455-
wing.delta_dist[i] = if normalized_gamma <= 0.0
456-
deltas[1]
457-
elseif normalized_gamma >= 1.0
458-
deltas[2]
459-
else
460-
deltas[1] * (1.0 - normalized_gamma) + deltas[2] * normalized_gamma
461-
end
462-
450+
for i in 1:wing.n_panels
463451
section1 = wing.non_deformed_sections[i]
464452
section2 = wing.non_deformed_sections[i+1]
465453
local_y .= normalize(section1.LE_point - section2.LE_point)
466454
chord .= section1.TE_point .- section1.LE_point
467-
wing.sections[i].TE_point .= section1.LE_point .+ rotate_v_around_k(chord, local_y, wing.alpha_dist[i])
455+
wing.sections[i].TE_point .= section1.LE_point .+ rotate_v_around_k(chord, local_y, wing.theta_dist[i])
468456
end
469457
return nothing
470458
end

0 commit comments

Comments
 (0)