Skip to content

Commit fca49af

Browse files
committed
succesful but unverified ram kite example
1 parent 30261c9 commit fca49af

File tree

3 files changed

+82
-62
lines changed

3 files changed

+82
-62
lines changed

examples/ram_kite.jl

Lines changed: 75 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,49 @@ using Plots
88
# Create wing geometry
99
wing = KiteWing("data/HL5_ram_air_kite_body.obj")
1010

11-
alphas = -10:1:25 # Range of angles from -10 to 25 degrees
11+
alphas = deg2rad.(-10:1:25) # Range of angles from -10 to 25 degrees
1212
polars = zeros(length(alphas), 4) # Matrix for [alpha, CD, CL, CM]
1313
for (i, alpha) in enumerate(alphas)
1414
# Simplified aerodynamic coefficients
1515
cd = 0.015 + 0.015 * abs(alpha/10)^1.5 # Drag increases with angle
16-
cl = 0.1 * alpha + 0.01 * alpha^2 * exp(-alpha/20) # Lift with stall behavior
16+
cl = 5.0 * alpha + 0.01 * alpha^2 * exp(-alpha/20) # Lift with stall behavior
1717
cm = -0.02 * alpha # Linear pitching moment
1818

1919
polars[i, :] .= [alpha, cd, cl, cm]
2020
end
2121

22+
# Plot polars directly
23+
p = plot(layout=(2,2), size=(1000,1000))
24+
25+
# CL vs alpha
26+
plot!(p[1], rad2deg.(polars[:,1]), polars[:,3],
27+
label="CL",
28+
xlabel="Angle of Attack [deg]",
29+
ylabel="CL",
30+
title="Lift Coefficient")
31+
32+
# CD vs alpha
33+
plot!(p[2], rad2deg.(polars[:,1]), polars[:,2],
34+
label="CD",
35+
xlabel="Angle of Attack [deg]",
36+
ylabel="CD",
37+
title="Drag Coefficient")
38+
39+
# CM vs alpha
40+
plot!(p[3], rad2deg.(polars[:,1]), polars[:,4],
41+
label="CM",
42+
xlabel="Angle of Attack [deg]",
43+
ylabel="CM",
44+
title="Moment Coefficient")
45+
46+
# CL vs CD
47+
plot!(p[4], polars[:,2], polars[:,3],
48+
label="Polar",
49+
xlabel="CD",
50+
ylabel="CL",
51+
title="Lift-Drag Polar")
52+
display(p)
53+
2254
for gamma in range(wing.gamma_tip - wing.gamma_tip/10, -wing.gamma_tip + wing.gamma_tip/10, 20)
2355
add_section!(wing, gamma, ("polar_data", polars))
2456
end
@@ -36,7 +68,7 @@ VSM_with_stall_correction = Solver(
3668

3769
# Setting velocity conditions
3870
Umag = 15.0
39-
aoa = 17.0
71+
aoa = 15.0
4072
side_slip = 0.0
4173
yaw_rate = 0.0
4274
aoa_rad = deg2rad(aoa)
@@ -47,64 +79,49 @@ vel_app = [
4779
] * Umag
4880
wing_aero.va = vel_app
4981

50-
# # Plotting geometry
51-
# plot_geometry(
52-
# wing_aero,
53-
# "";
54-
# data_type=".svg",
55-
# save_path="",
56-
# is_save=false,
57-
# is_show=true,
58-
# view_elevation=15,
59-
# view_azimuth=-120
60-
# )
82+
# Plotting geometry
83+
plot_geometry(
84+
wing_aero,
85+
"";
86+
data_type=".svg",
87+
save_path="",
88+
is_save=false,
89+
is_show=true,
90+
view_elevation=15,
91+
view_azimuth=-120
92+
)
6193

6294
# Solving and plotting distributions
63-
results = solve(VSM, wing_aero)
64-
@time results_with_stall = solve(VSM_with_stall_correction, wing_aero)
95+
@time results = solve(VSM, wing_aero)
6596
@time results_with_stall = solve(VSM_with_stall_correction, wing_aero)
6697

67-
# CAD_y_coordinates = [panel.aerodynamic_center[2] for panel in wing_aero.panels]
98+
CAD_y_coordinates = [panel.aerodynamic_center[2] for panel in wing_aero.panels]
6899

69-
# plot_distribution(
70-
# [CAD_y_coordinates, CAD_y_coordinates],
71-
# [results, results_with_stall],
72-
# ["VSM", "VSM with stall correction"];
73-
# title="CAD_spanwise_distributions_alpha_$(round(aoa, digits=1))_beta_$(round(side_slip, digits=1))_yaw_$(round(yaw_rate, digits=1))_Umag_$(round(Umag, digits=1))",
74-
# data_type=".pdf",
75-
# save_path=joinpath(save_folder, "spanwise_distributions"),
76-
# is_save=false,
77-
# is_show=true
78-
# )
79-
80-
# # Plotting polar
81-
# save_path = joinpath(root_dir, "results", "TUD_V3_LEI_KITE")
82-
# path_cfd_lebesque = joinpath(
83-
# root_dir,
84-
# "data",
85-
# "TUDELFT_V3_LEI_KITE",
86-
# "literature_results",
87-
# "V3_CL_CD_RANS_Lebesque_2024_Rey_300e4.csv"
88-
# )
100+
plot_distribution(
101+
[CAD_y_coordinates, CAD_y_coordinates],
102+
[results, results_with_stall],
103+
["VSM", "VSM with stall correction"];
104+
title="CAD_spanwise_distributions_alpha_$(round(aoa, digits=1))_beta_$(round(side_slip, digits=1))_yaw_$(round(yaw_rate, digits=1))_Umag_$(round(Umag, digits=1))",
105+
data_type=".pdf",
106+
is_save=false,
107+
is_show=true
108+
)
89109

90-
# plot_polars(
91-
# [VSM, VSM_with_stall_correction],
92-
# [wing_aero, wing_aero],
93-
# [
94-
# "VSM CAD 19ribs",
95-
# "VSM CAD 19ribs , with stall correction",
96-
# "CFD_Lebesque Rey 30e5"
97-
# ];
98-
# literature_path_list=[path_cfd_lebesque],
99-
# angle_range=range(0, 25, length=25),
100-
# angle_type="angle_of_attack",
101-
# angle_of_attack=0,
102-
# side_slip=0,
103-
# yaw_rate=0,
104-
# Umag=10,
105-
# title="tutorial_testing_stall_model_n_panels_$(n_panels)_distribution_$(spanwise_panel_distribution)",
106-
# data_type=".pdf",
107-
# save_path=joinpath(save_folder, "polars"),
108-
# is_save=true,
109-
# is_show=true
110-
# )
110+
plot_polars(
111+
[VSM, VSM_with_stall_correction],
112+
[wing_aero, wing_aero],
113+
[
114+
"VSM CAD 19ribs",
115+
"VSM CAD 19ribs , with stall correction",
116+
];
117+
angle_range=range(0, 25, length=25),
118+
angle_type="angle_of_attack",
119+
angle_of_attack=0,
120+
side_slip=0,
121+
yaw_rate=0,
122+
Umag=10,
123+
title="tutorial_testing_stall_model_n_panels_$(wing.n_panels)_distribution_$(wing.spanwise_panel_distribution)",
124+
data_type=".pdf",
125+
is_save=false,
126+
is_show=true
127+
)

src/VortexStepMethod.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using Plots
1010
using Measures
1111
using LaTeXStrings
1212
using NonlinearSolve
13-
using Interpolations: linear_interpolation
13+
using Interpolations: linear_interpolation, Line
1414

1515
# Export public interface
1616
export Wing, Section, KiteWing

src/panel.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ function calculate_cl(panel::Panel, alpha::Float64)
248248
elseif panel.panel_aero_model == "polar_data"
249249
return linear_interpolation(
250250
panel.panel_polar_data[:,1],
251-
panel.panel_polar_data[:,2]
251+
panel.panel_polar_data[:,2];
252+
extrapolation_bc=Line()
252253
)(alpha)
253254
else
254255
throw(ArgumentError("Unsupported aero model: $(panel.panel_aero_model)"))
@@ -273,11 +274,13 @@ function calculate_cd_cm(panel::Panel, alpha::Float64)
273274
elseif panel.panel_aero_model == "polar_data"
274275
cd = linear_interpolation(
275276
panel.panel_polar_data[:,1],
276-
panel.panel_polar_data[:,3]
277+
panel.panel_polar_data[:,3];
278+
extrapolation_bc=Line()
277279
)(alpha)
278280
cm = linear_interpolation(
279281
panel.panel_polar_data[:,1],
280-
panel.panel_polar_data[:,4]
282+
panel.panel_polar_data[:,4];
283+
extrapolation_bc=Line()
281284
)(alpha)
282285
return cd, cm
283286
else

0 commit comments

Comments
 (0)