Skip to content

Commit 6528859

Browse files
committed
first plot OK
1 parent 8e54dfd commit 6528859

File tree

2 files changed

+60
-46
lines changed

2 files changed

+60
-46
lines changed

examples/rectangular_wing.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,25 @@ println("CL = $(round(results_vsm["cl"], digits=4))")
5252
println("CD = $(round(results_vsm["cd"], digits=4))")
5353
println("Projected area = $(round(results_vsm["projected_area"], digits=4))")
5454

55-
# Step 6: Plot geometry
56-
plot_geometry(
57-
wa,
58-
"Rectangular_wing_geometry";
59-
data_type=".pdf",
60-
save_path=".",
61-
is_save=false,
62-
is_show=true,
63-
)
55+
# # Step 6: Plot geometry
56+
# plot_geometry(
57+
# wa,
58+
# "Rectangular_wing_geometry";
59+
# data_type=".pdf",
60+
# save_path=".",
61+
# is_save=false,
62+
# is_show=true,
63+
# )
6464

65-
# # Step 7: Plot spanwise distributions
66-
# y_coordinates = [panel.aerodynamic_center[2] for panel in wa.panels]
65+
# Step 7: Plot spanwise distributions
66+
y_coordinates = [panel.aerodynamic_center[2] for panel in wa.panels]
6767

68-
# plot_distribution(
69-
# [y_coordinates, y_coordinates],
70-
# [results_vsm, results_llt],
71-
# ["VSM", "LLT"],
72-
# title="Spanwise Distributions"
73-
# )
68+
plot_distribution(
69+
[y_coordinates, y_coordinates],
70+
[results_vsm, results_llt],
71+
["VSM", "LLT"],
72+
title="Spanwise Distributions"
73+
)
7474

7575
# # Step 8: Plot polar curves
7676
# angle_range = range(0, 20, 20)

src/plotting.jl

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -226,38 +226,52 @@ function plot_geometry(wing_aero, title;
226226
end
227227
end
228228

229-
# """
230-
# plot_distribution(y_coordinates_list, results_list, label_list; kwargs...)
229+
"""
230+
plot_distribution(y_coordinates_list, results_list, label_list; kwargs...)
231231
232-
# Plot spanwise distributions of aerodynamic properties.
232+
Plot spanwise distributions of aerodynamic properties.
233233
234-
# # Arguments
235-
# - `y_coordinates_list`: List of spanwise coordinates
236-
# - `results_list`: List of result dictionaries
237-
# - `label_list`: List of labels for different results
238-
# - `title`: Plot title (default: "spanwise_distribution")
239-
# - `data_type`: File extension for saving (default: ".pdf")
240-
# - `save_path`: Path to save plots
241-
# - `is_save`: Whether to save plots (default: true)
242-
# - `is_show`: Whether to display plots (default: true)
243-
# """
244-
# function plot_distribution(y_coordinates_list, results_list, label_list;
245-
# title="spanwise_distribution",
246-
# data_type=".pdf",
247-
# save_path=nothing,
248-
# is_save=true,
249-
# is_show=true)
234+
# Arguments
235+
- `y_coordinates_list`: List of spanwise coordinates
236+
- `results_list`: List of result dictionaries
237+
- `label_list`: List of labels for different results
238+
- `title`: Plot title (default: "spanwise_distribution")
239+
- `data_type`: File extension for saving (default: ".pdf")
240+
- `save_path`: Path to save plots
241+
- `is_save`: Whether to save plots (default: true)
242+
- `is_show`: Whether to display plots (default: true)
243+
"""
244+
function plot_distribution(y_coordinates_list, results_list, label_list;
245+
title="spanwise_distribution",
246+
data_type=".pdf",
247+
save_path=nothing,
248+
is_save=true,
249+
is_show=true)
250250

251-
# length(results_list) == length(label_list) || throw(ArgumentError(
252-
# "Number of results ($(length(results_list))) must match number of labels ($(length(label_list)))"
253-
# ))
251+
length(results_list) == length(label_list) || throw(ArgumentError(
252+
"Number of results ($(length(results_list))) must match number of labels ($(length(label_list)))"
253+
))
254254

255-
# # Create plot with layout
256-
# res = plot(
257-
# layout=(3,3),
258-
# size=(1200, 800),
259-
# plot_title=title
260-
# )
255+
# Set the plot style
256+
set_plot_style()
257+
258+
# Initializing plot
259+
fig, axs = plt.subplots(3, 3, figsize=(16, 10))
260+
fig.suptitle(title, fontsize=16)
261+
262+
# CL plot
263+
for (y_coordinates_i, result_i, label_i) in zip(y_coordinates_list, results_list, label_list)
264+
value = "$(round(result_i["cl"], digits=2))"
265+
axs[1, 1].plot(
266+
y_coordinates_i,
267+
result_i["cl_distribution"],
268+
label=label_i * L" $C_L$: " * value
269+
)
270+
end
271+
axs[1, 1].set_title(L"$C_L$ Distribution")
272+
axs[1, 1].set_xlabel(L"Spanwise Position $y/b$")
273+
axs[1, 1].set_ylabel(L"Lift Coefficient $C_L$")
274+
axs[1, 1].legend()
261275

262276
# # CL Distribution
263277
# plot!(res[1],
@@ -343,7 +357,7 @@ end
343357
# end
344358

345359
# return res
346-
# end
360+
end
347361

348362
# """
349363
# generate_polar_data(solver, wing_aero, angle_range; kwargs...)

0 commit comments

Comments
 (0)