Skip to content

Commit

Permalink
plot CL and CD_tot vs AoA
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed Aug 13, 2024
1 parent 0efc96e commit aae068e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 10 additions & 2 deletions examples/autopilot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ end
using Timers; tic()

LOG_LIFT_DRAG::Bool = true
DRAG_CORR::Float64 = 0.93

using KiteControllers, KiteViewers, KiteModels, StatsBase, ControlPlots, NativeFileDialog, LaTeXStrings
using Printf, LinearAlgebra
import KiteViewers.GLMakie
import KiteViewers.GLMakie.GLFW
import KiteControllers.YAML
import KiteModels.calc_cl
import KiteModels.calc_cd
if false; include("../src/flightpathcontroller.jl"); end
if false; include("../src/flightpathcalculator2.jl"); end
if false; include("../src/systemstatecontrol.jl"); end
Expand Down Expand Up @@ -138,6 +141,8 @@ function simulate(integrator, stopped=true)
if ! stopped
set_status(app.viewer, "ssParking")
end
rel_side_area = app.set.rel_side_area/100.0 # defined in percent
K = 1 - rel_side_area # correction factor for the drag
i=1
j=0; k=0
GC.enable(true)
Expand Down Expand Up @@ -210,8 +215,11 @@ function simulate(integrator, stopped=true)
sys_state.var_13 = app.kps4.alpha_2
sys_state.var_14 = app.kps4.alpha_2b
if LOG_LIFT_DRAG
sys_state.var_15 = norm(app.kps4.lift_force)
sys_state.var_16 = norm(app.kps4.drag_force)
CL2, CD2 = calc_cl(app.kps4.alpha_2), DRAG_CORR * calc_cd(app.kps4.alpha_2)
CL3, CD3 = calc_cl(app.kps4.alpha_3), DRAG_CORR * calc_cd(app.kps4.alpha_3)
CL4, CD4 = calc_cl(app.kps4.alpha_4), DRAG_CORR * calc_cd(app.kps4.alpha_4)
sys_state.var_15 = CL2
sys_state.var_16 = K*(CD2+rel_side_area*(CD3+CD4))
else
sys_state.var_15 = app.kps4.alpha_3b
sys_state.var_16 = app.kps4.alpha_4b
Expand Down
9 changes: 5 additions & 4 deletions examples/plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,13 @@ function plot_aerodynamics(plot_lift_drag = false)
fig="aerodynamics"))
display(plotxy(sl.var_13[2:end], sl.var_15[2:end];
xlabel="AoA [°]",
ylabel="Lift [N]",
fig="Lift as function of AoA"))
ylabel="CL [-]",
fig="CL as function of AoA"))
display(plotxy(sl.var_13[2:end], sl.var_16[2:end];
xlabel="AoA [°]",
ylabel="Drag [N]",
fig="Drag as function of AoA"))
ylabel="CD [-]",
fig="CD as function of AoA"))

else
display(plotx(sl.time, sl.var_08, sl.var_13, sl.var_14, sl.var_15, sl.var_16;
ylabels=["LoD [-]", L"\alpha_2~[°]", L"\alpha_{3b}~[°]", L"\alpha_{4b}~[°]"],
Expand Down

0 comments on commit aae068e

Please sign in to comment.