Skip to content

Commit 84fc46f

Browse files
committed
full example works
1 parent 3b3c29c commit 84fc46f

File tree

2 files changed

+114
-56
lines changed

2 files changed

+114
-56
lines changed

examples/testing_stall_model.jl

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Revise
1+
# using Revise
22
using VortexStepMethod
33
using CSV
44
using DataFrames
@@ -60,17 +60,17 @@ vel_app = [
6060
] * Umag
6161
set_va!(wing_aero_CAD_19ribs, (vel_app, yaw_rate))
6262

63-
# # Plotting geometry
64-
# plot_geometry(
65-
# wing_aero_CAD_19ribs,
66-
# "";
67-
# data_type=".svg",
68-
# save_path="",
69-
# is_save=false,
70-
# is_show=true,
71-
# view_elevation=15,
72-
# view_azimuth=-120
73-
# )
63+
# Plotting geometry
64+
plot_geometry(
65+
wing_aero_CAD_19ribs,
66+
"";
67+
data_type=".svg",
68+
save_path="",
69+
is_save=false,
70+
is_show=true,
71+
view_elevation=15,
72+
view_azimuth=-120
73+
)
7474

7575
# Solving and plotting distributions
7676
results = solve(VSM, wing_aero_CAD_19ribs)
@@ -90,34 +90,34 @@ plot_distribution(
9090
is_show=true
9191
)
9292

93-
# # Plotting polar
94-
# save_path = joinpath(root_dir, "results", "TUD_V3_LEI_KITE")
95-
# path_cfd_lebesque = joinpath(
96-
# root_dir,
97-
# "data",
98-
# "TUDELFT_V3_LEI_KITE",
99-
# "literature_results",
100-
# "V3_CL_CD_RANS_Lebesque_2024_Rey_300e4.csv"
101-
# )
93+
# Plotting polar
94+
save_path = joinpath(root_dir, "results", "TUD_V3_LEI_KITE")
95+
path_cfd_lebesque = joinpath(
96+
root_dir,
97+
"data",
98+
"TUDELFT_V3_LEI_KITE",
99+
"literature_results",
100+
"V3_CL_CD_RANS_Lebesque_2024_Rey_300e4.csv"
101+
)
102102

103-
# plot_polars(
104-
# [VSM, VSM_with_stall_correction],
105-
# [wing_aero_CAD_19ribs, wing_aero_CAD_19ribs],
106-
# [
107-
# "VSM CAD 19ribs",
108-
# "VSM CAD 19ribs , with stall correction",
109-
# "CFD_Lebesque Rey 30e5"
110-
# ];
111-
# literature_path_list=[path_cfd_lebesque],
112-
# angle_range=range(0, 25, length=25),
113-
# angle_type="angle_of_attack",
114-
# angle_of_attack=0,
115-
# side_slip=0,
116-
# yaw_rate=0,
117-
# Umag=10,
118-
# title="tutorial_testing_stall_model_n_panels_$(n_panels)_distribution_$(spanwise_panel_distribution)",
119-
# data_type=".pdf",
120-
# save_path=joinpath(save_folder, "polars"),
121-
# is_save=true,
122-
# is_show=true
123-
# )
103+
plot_polars(
104+
[VSM, VSM_with_stall_correction],
105+
[wing_aero_CAD_19ribs, wing_aero_CAD_19ribs],
106+
[
107+
"VSM CAD 19ribs",
108+
"VSM CAD 19ribs , with stall correction",
109+
"CFD_Lebesque Rey 30e5"
110+
];
111+
literature_path_list=[path_cfd_lebesque],
112+
angle_range=range(0, 25, length=25),
113+
angle_type="angle_of_attack",
114+
angle_of_attack=0,
115+
side_slip=0,
116+
yaw_rate=0,
117+
Umag=10,
118+
title="tutorial_testing_stall_model_n_panels_$(n_panels)_distribution_$(spanwise_panel_distribution)",
119+
data_type=".pdf",
120+
save_path=joinpath(save_folder, "polars"),
121+
is_save=true,
122+
is_show=true
123+
)

src/plotting.jl

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,14 @@ function generate_polar_data(
387387
end
388388

389389
# Update inflow conditions
390-
wing_aero.va = [
391-
cos(α) * cos(β),
392-
sin(β),
393-
sin(α)
394-
] * Umag
390+
set_va!(
391+
wing_aero,
392+
[
393+
cos(α) * cos(β),
394+
sin(β),
395+
sin(α)
396+
] * Umag
397+
)
395398

396399
# Solve and store results
397400
results = solve(solver, wing_aero, gamma_distribution[i, :])
@@ -488,32 +491,87 @@ function plot_polars(
488491
end
489492
end
490493

491-
# Create plots
492-
layout = @layout [grid(2,2)]
493-
plt = plot(layout=layout, size=(1000, 1000), title=title)
494+
# Create plots with 2x2 layout
495+
plt = plot(
496+
layout=(2,2),
497+
size=(1000, 1000),
498+
plot_title=title
499+
)
494500

495501
# Number of computational results (excluding literature)
496502
n_solvers = length(solver_list)
497503

498504
# Plot CL vs angle
499-
plot!(plt[1]) # Use plt[1] instead of subplot!(plt, 1)
505+
plot!(plt[1])
500506
for (i, (polar_data, label)) in enumerate(zip(polar_data_list, label_list))
501507
style = i n_solvers ? (:solid, :star, 7) : (:solid, :circle, 5)
502508
plot!(plt[1], polar_data[1], polar_data[2],
503509
label=label, linestyle=style[1], marker=style[2], markersize=style[3])
510+
511+
# Limit y-range if CL > 10
512+
if maximum(polar_data[2]) > 10
513+
ylims!(plt[1], (-0.5, 2.0))
514+
end
504515
end
505-
title!(plt[1], L"C_L vs %$angle_type")
516+
title!(plt[1], L"C_L \textrm{ vs } %$angle_type")
506517
xlabel!(plt[1], "$angle_type [deg]")
507518
ylabel!(plt[1], L"C_L")
508-
509-
# Continue with CD, CS, and CL-CD plots similarly...
510-
# [Additional subplots omitted for brevity]
511-
519+
520+
# Plot CD vs angle
521+
plot!(plt[2])
522+
for (i, (polar_data, label)) in enumerate(zip(polar_data_list, label_list))
523+
style = i n_solvers ? (:solid, :star, 7) : (:solid, :circle, 5)
524+
plot!(plt[2], polar_data[1], polar_data[3],
525+
label=label, linestyle=style[1], marker=style[2], markersize=style[3])
526+
527+
# Limit y-range if CD > 10
528+
if maximum(polar_data[3]) > 10
529+
ylims!(plt[2], (-0.2, 0.5))
530+
end
531+
end
532+
title!(plt[2], L"C_D \textrm{ vs } %$angle_type")
533+
xlabel!(plt[2], "$angle_type [deg]")
534+
ylabel!(plt[2], L"C_D")
535+
536+
# Plot CS vs angle (if available)
537+
plot!(plt[3])
538+
for (i, (polar_data, label)) in enumerate(zip(polar_data_list, label_list))
539+
# Check if CS data is available (length > 3)
540+
if length(polar_data) > 3
541+
style = i n_solvers ? (:solid, :star, 7) : (:solid, :circle, 5)
542+
plot!(plt[3], polar_data[1], polar_data[4],
543+
label=label, linestyle=style[1], marker=style[2], markersize=style[3])
544+
end
545+
end
546+
title!(plt[3], L"C_S \textrm{ vs } %$angle_type")
547+
xlabel!(plt[3], "$angle_type [deg]")
548+
ylabel!(plt[3], L"C_S")
549+
550+
# Plot CL vs CD
551+
plot!(plt[4])
552+
for (i, (polar_data, label)) in enumerate(zip(polar_data_list, label_list))
553+
style = i n_solvers ? (:solid, :star, 7) : (:solid, :circle, 5)
554+
plot!(plt[4], polar_data[2], polar_data[3], # Note: CD on x-axis, CL on y-axis
555+
label=label, linestyle=style[1], marker=style[2], markersize=style[3])
556+
557+
# Limit ranges if values > 10
558+
if maximum(polar_data[2]) > 10 || maximum(polar_data[3]) > 10
559+
ylims!(plt[4], (-0.5, 2.0))
560+
xlims!(plt[4], (-0.2, 0.5))
561+
end
562+
end
563+
title!(plt[4], L"C_L \textrm{ vs } C_D \textrm{ (over } %$angle_type \textrm{ range)}")
564+
xlabel!(plt[4], L"C_D")
565+
ylabel!(plt[4], L"C_L")
566+
567+
# Save and show plot
512568
if is_save
513569
save_plot(plt, save_path, title, data_type=data_type)
514570
end
515571

516572
if is_show
517573
show_plot(plt)
518574
end
575+
576+
return plt
519577
end

0 commit comments

Comments
 (0)