Skip to content

Commit

Permalink
add std_elevation
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed Oct 30, 2024
1 parent 8d81eff commit 837fa29
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions examples/plot_cl_cd2.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# plot the lift and drag coefficients as function of angle of attack

# t_start t_stop duration depower height av_elevation av_pitch av_wind_200
# ─────────────────────────────────────────────────────────────────────────────────
# 11624.9 11653.3 28.4 40.0 268.3 70.6789 12.8284 10.23
# 11538.2 11559.5 21.3 44.0 250.1 65.2369 13.7453 11.53
# 12866.4 12886.6 20.2 51.98 249.4 57.9619 14.0217 12.0867
# 11472.8 11490.6 17.8 47.99 237.5 61.4089 14.8983 11.92
# t_start t_stop duration depower height av_elevation std_elevation av_pitch av_wind_200
# ────────────────────────────────────────────────────────────────────────────────────────────────
# 11624.9 11653.3 28.4 40.0 268.3 70.6789 1.26185 12.8284 10.23
# 11538.2 11559.5 21.3 44.0 250.1 65.2369 0.821425 13.7453 11.53
# 12866.4 12886.6 20.2 51.98 249.4 57.9619 0.92951 14.0217 12.0867
# 11472.8 11490.6 17.8 47.99 237.5 61.4089 0.648852 14.8983 11.92


ELEV_MEASURED = [70.6789, 65.2369, 61.4089, 57.9619]
STD_ELEVATION = [1.26185, 0.821425, 0.648852, 0.92951]
PITCH = [12.8284, 13.7453, 14.8983, 14.0217]

V_WIND_200 = [ 10.23, 11.53, 12.0867, 11.92]
HEIGHT = [ 268.3, 250.1, 249.4, 237.5]
DEPOWER = [0.40, 0.44, 0.4799, 0.5198]

using Printf
using KiteModels, KitePodModels, KiteUtils, LinearAlgebra
Expand All @@ -25,16 +29,15 @@ plt.close("all")

set.abs_tol=0.0006
set.rel_tol=0.00001
V_WIND = 8.9

# the following values can be changed to match your interest
dt = 0.05
set.solver="DFBDF" # IDA or DFBDF
STEPS = 500
STEPS = 680
PLOT = true
PRINT = true
STATISTIC = false
DEPOWER = [0.40, 0.44, 0.4799, 0.5198]

# DEPOWER = [0.236, 0.28, 0.32, 0.36] # for hyra20 kite
# end of user parameter section #

Expand Down Expand Up @@ -89,23 +92,24 @@ CD = zeros(length(DEPOWER))
AOA = zeros(length(DEPOWER))
DEP = zeros(length(DEPOWER))
ELEV = zeros(length(DEPOWER))
V_WIND_KITE = zeros(length(DEPOWER))

elev = set.elevation
i = 1
set.v_wind = V_WIND # 25
for depower in DEPOWER
println("Depower: $depower")
global elev, i, kps4
local cl, cd, aoa, kcu

logger = Logger(set.segments + 5, STEPS)
DEP[i] = depower
set.depower = 100*depower

# set.depower_gain = 5

kcu::KCU = KCU(set)
kps4::KPS4 = KPS4(kcu)
integrator = KiteModels.init_sim!(kps4; delta=0.01, stiffness_factor=1, prn=STATISTIC)
set.v_wind = V_WIND_200[i] / 1.348881340489221 * calc_wind_factor(kps4.am, HEIGHT[i])/1.348881340489221
integrator = KiteModels.init_sim!(kps4; delta=0.001*0, stiffness_factor=1, prn=STATISTIC)
if ! isnothing(integrator)
try
cl, cd = simulate(kps4, integrator, logger, STEPS)
Expand All @@ -126,31 +130,35 @@ for depower in DEPOWER
end
elev = rad2deg(logger.elevation_vec[end])
ELEV[i] = elev
V_WIND_KITE[i] = norm(kps4.v_wind)

if elev > 70
set.elevation = elev - 4
else
set.elevation = elev - 4
end
if i ==2
j=i
if j ==2
set.elevation -= 4
elseif i == 3
elseif j == 3
set.elevation -= 4
elseif j == 4
set.elevation += 4
end

aoa = kps4.alpha_2
orient_vec = orient_euler(kps4)
alpha_depower = rad2deg(kps4.alpha_depower)
pitch = rad2deg(orient_vec[2]) + alpha_depower
v_app = norm(kps4.v_apparent)
v_200 = calc_wind_factor(kps4.am, 200) * V_WIND
# v_200 = calc_wind_factor(kps4.am, 200) * V_WIND
height = logger.z_vec[end][end-2]
CL[i] = cl
CD[i] = cd
AOA[i] = aoa
if PRINT
print("Depower: $depower, alpha_dp: $(round(alpha_depower, digits=2)), CL $(round(cl, digits=3)), CD: $(round(cd, digits=3)), aoa: $(round(aoa, digits=2)), pitch: $(round(pitch, digits=2)), CL/CD: $(round(cl/cd, digits=2))")
println(", elevation: $(round((elev), digits=2)), height:$(round(height, digits=2)), v_200: $(round(v_200, digits=2))")
println(", elevation: $(round((elev), digits=2)), height:$(round(height, digits=2))")
end
# if depower in [DEPOWER[begin+1], DEPOWER[end]] && PLOT
if PLOT
Expand All @@ -174,4 +182,4 @@ end
# display(plot(AOA, [CD, cd], xlabel="AOA [deg]", ylabel="CD", labels=["CD","cd"], fig="CD vs AOA"))
# display(plot(DEP, AOA, xlabel="Depower", ylabel="AOA [deg]", fig="AOA vs Depower"))
display(plot(DEP,[ELEV, ELEV_MEASURED]; xlabel="depower", ylabel="elevation [°]", scatter=true, labels=["simulated", "measured"], fig="elevation vs depower"))
display(plot(DEP,[AOA, 1.5*25.5 .- 2PITCH]; xlabel="depower", ylabel="aoa/pitch [°]", scatter=true, labels=["aoa", "38.25°-2pitch"], fig="pitch and aoa vs depower"))
# display(plot(DEP,[AOA, 1.5*25.5 .- 2PITCH]; xlabel="depower", ylabel="aoa/pitch [°]", scatter=true, labels=["aoa", "38.25°-2pitch"], fig="pitch and aoa vs depower"))

0 comments on commit 837fa29

Please sign in to comment.