Skip to content

Commit 9e535da

Browse files
committed
Deformable yaml kite
1 parent ec46e3b commit 9e535da

File tree

4 files changed

+61
-150
lines changed

4 files changed

+61
-150
lines changed

examples/V3_kite.jl

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ using LinearAlgebra
22
using VortexStepMethod
33
using GLMakie
44

5+
PLOT = true
6+
USE_TEX = false
7+
DEFORM = false
8+
59
project_dir = dirname(dirname(pathof(VortexStepMethod))) # Go up one level from src to project root#
610
literature_paths = [
711
joinpath(project_dir, "data", "TUDELFT_V3_KITE", "literature_results","CFD_RANS_Rey_5e5_Poland2025_alpha_sweep_beta_0_NoStruts.csv"),
@@ -11,8 +15,8 @@ literature_paths = [
1115
]
1216
labels= [
1317
"Julia VSM 2D CFD PCHIP",
14-
"CFD RANS Re=5e5",
15-
"CFD RANS Re=10e5 (With Struts)",
18+
"CFD RANS Re=5e5",
19+
"CFD RANS Re=10e5 (With Struts)",
1620
"Python VSM 2D CFD PCHIP Re=5e5",
1721
"Wind Tunnel Re=5e5 (With Struts)"
1822
]
@@ -22,7 +26,20 @@ settings = VSMSettings("TUDELFT_V3_KITE/vsm_settings.yaml")
2226

2327
# Create wing, body_aero, and solver objects using settings
2428
wing = Wing(settings)
29+
refine!(wing)
2530
body_aero = BodyAerodynamics([wing])
31+
VortexStepMethod.reinit!(body_aero)
32+
33+
if DEFORM
34+
VortexStepMethod.unrefined_deform!(
35+
wing,
36+
deg2rad.(range(-10, 10, length=wing.n_unrefined_sections)),
37+
deg2rad.(range(0, 0, length=wing.n_unrefined_sections));
38+
smooth=true
39+
)
40+
VortexStepMethod.reinit!(body_aero; init_aero=false)
41+
end
42+
2643
solver = Solver(body_aero, settings)
2744

2845
# Set flight conditions from settings
@@ -38,53 +55,23 @@ yaw_rate = settings.condition.yaw_rate
3855
PLOT = true
3956
USE_TEX = false
4057

41-
# Plotting polars
42-
PLOT && plot_polars(
43-
[solver],
44-
[body_aero],
45-
labels,
58+
# Solve and plot combined analysis
59+
results = VortexStepMethod.solve(solver, body_aero; log=true)
60+
PLOT && plot_combined_analysis(
61+
solver,
62+
body_aero,
63+
results;
64+
solver_label="VSM",
4665
literature_path_list=literature_paths,
4766
angle_range=range(-5, 25, length=30),
4867
angle_type="angle_of_attack",
4968
angle_of_attack=angle_of_attack_deg,
5069
side_slip=sideslip_deg,
5170
v_a=wind_speed,
52-
title="$(wing.n_panels)_panels_$(wing.spanwise_distribution)_from_yaml_settings",
53-
data_type=".png",
54-
is_save=false,
55-
is_show=true,
56-
use_tex=USE_TEX
57-
)
58-
59-
60-
# Plotting geometry
61-
results = VortexStepMethod.solve(solver, body_aero; log=true)
62-
PLOT && plot_geometry(
63-
body_aero,
64-
"";
65-
data_type=".svg",
66-
save_path="",
67-
is_save=false,
68-
is_show=true,
69-
view_elevation=15,
70-
view_azimuth=-120,
71-
use_tex=USE_TEX
72-
)
73-
74-
75-
# Plotting spanwise distributions
76-
body_y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
77-
78-
PLOT && plot_distribution(
79-
[body_y_coordinates],
80-
[results],
81-
["VSM"];
82-
title="CAD_spanwise_distributions_alpha_$(round(angle_of_attack_deg, digits=1))_delta_$(round(sideslip_deg, digits=1))_yaw_$(round(yaw_rate, digits=1))_v_a_$(round(wind_speed, digits=1))",
83-
data_type=".png",
84-
is_save=false,
71+
title="TU Delft V3 Kite",
8572
is_show=true,
8673
use_tex=USE_TEX
8774
)
8875

8976

90-
nothing
77+
nothing

examples/pyramid_model.jl

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ vsm_settings = VSMSettings("pyramid_model/vsm_settings.yaml")
99

1010
# Create wing, body_aero, and solver objects using vsm_settings
1111
wing = Wing(vsm_settings)
12+
refine!(wing)
1213
body_aero = BodyAerodynamics([wing])
1314
solver = Solver(body_aero, vsm_settings)
1415

@@ -28,47 +29,18 @@ results = VortexStepMethod.solve(solver, body_aero; log=true)
2829
PLOT = true
2930
USE_TEX = false
3031

31-
# Plotting polars
32-
PLOT && plot_polars(
33-
[solver],
34-
[body_aero],
35-
["VSM Pyramid Model"],
32+
# Plotting combined analysis
33+
PLOT && plot_combined_analysis(
34+
solver,
35+
body_aero,
36+
results;
37+
solver_label="VSM",
3638
angle_range=range(-5, 25, length=30),
3739
angle_type="angle_of_attack",
3840
angle_of_attack=angle_of_attack_deg,
3941
side_slip=sideslip_deg,
4042
v_a=wind_speed,
41-
title="$(wing.n_panels)_panels_$(wing.spanwise_distribution)_pyramid_model",
42-
data_type=".png",
43-
is_save=false,
44-
is_show=true,
45-
use_tex=USE_TEX
46-
)
47-
48-
# Plotting geometry
49-
results = VortexStepMethod.solve(solver, body_aero; log=true)
50-
PLOT && plot_geometry(
51-
body_aero,
52-
"";
53-
data_type=".svg",
54-
save_path="",
55-
is_save=false,
56-
is_show=true,
57-
view_elevation=15,
58-
view_azimuth=-120,
59-
use_tex=USE_TEX
60-
)
61-
62-
# Plotting spanwise distributions
63-
body_y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
64-
65-
PLOT && plot_distribution(
66-
[body_y_coordinates],
67-
[results],
68-
["VSM"];
69-
title="pyramid_spanwise_distributions_alpha_$(round(angle_of_attack_deg, digits=1))_delta_$(round(sideslip_deg, digits=1))_yaw_$(round(yaw_rate, digits=1))_v_a_$(round(wind_speed, digits=1))",
70-
data_type=".png",
71-
is_save=false,
43+
title="Pyramid Model",
7244
is_show=true,
7345
use_tex=USE_TEX
7446
)

examples/rectangular_wing.jl

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ alpha = deg2rad(alpha_deg)
1818
wing = Wing(n_panels, spanwise_distribution=LINEAR)
1919

2020
# Add wing sections - defining only tip sections with inviscid airfoil model
21-
add_section!(wing,
22-
[0.0, span/2, 0.0], # Left tip LE
21+
add_section!(wing,
22+
[0.0, span/2, 0.0], # Left tip LE
2323
[chord, span/2, 0.0], # Left tip TE
2424
INVISCID)
25-
add_section!(wing,
25+
add_section!(wing,
2626
[0.0, -span/2, 0.0], # Right tip LE
2727
[chord, -span/2, 0.0], # Right tip TE
2828
INVISCID)
2929

30+
# Refine mesh
31+
refine!(wing)
32+
3033
# Step 3: Initialize aerodynamics
3134
body_aero = BodyAerodynamics([wing])
3235

@@ -53,38 +56,18 @@ println("CL = $(round(results_vsm["cl"], digits=4))")
5356
println("CD = $(round(results_vsm["cd"], digits=4))")
5457
println("Projected area = $(round(results_vsm["projected_area"], digits=4))")
5558

56-
# Step 6: Plot geometry
57-
PLOT && plot_geometry(
58-
body_aero,
59-
"Rectangular_wing_geometry";
60-
data_type=".png",
61-
save_path=".",
62-
is_save=false,
63-
is_show=true,
64-
use_tex=USE_TEX
65-
)
66-
67-
# Step 7: Plot spanwise distributions
68-
y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
69-
70-
PLOT && plot_distribution(
71-
[y_coordinates, y_coordinates],
72-
[results_vsm, results_llt],
73-
["VSM", "LLT"],
74-
title="Spanwise Distributions",
75-
use_tex=USE_TEX
76-
)
77-
78-
# Step 8: Plot polar curves
59+
# Step 6: Plot combined analysis
7960
angle_range = range(0, 20, 20)
80-
PLOT && plot_polars(
61+
PLOT && plot_combined_analysis(
8162
[llt_solver, vsm_solver],
8263
[body_aero, body_aero],
83-
["LLT", "VSM"];
84-
angle_range,
64+
[results_llt, results_vsm];
65+
solver_label=["LLT", "VSM"],
66+
angle_range=angle_range,
8567
angle_type="angle_of_attack",
86-
v_a,
87-
title="Rectangular Wing Polars",
68+
v_a=v_a,
69+
title="Rectangular Wing",
70+
is_show=true,
8871
use_tex=USE_TEX
8972
)
9073
nothing

examples/stall_model.jl

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ CAD_wing = Wing(n_panels; spanwise_distribution)
3939
for rib in rib_list
4040
add_section!(CAD_wing, rib[1], rib[2], rib[3], rib[4])
4141
end
42+
refine!(CAD_wing)
4243
body_aero = BodyAerodynamics([CAD_wing])
4344

4445
# Create solvers
@@ -64,40 +65,12 @@ vel_app = [
6465
] * v_a
6566
set_va!(body_aero, vel_app)
6667

67-
# Plotting geometry
68-
PLOT && plot_geometry(
69-
body_aero,
70-
"";
71-
data_type=".svg",
72-
save_path="",
73-
is_save=false,
74-
is_show=true,
75-
view_elevation=15,
76-
view_azimuth=-120,
77-
use_tex=USE_TEX
78-
)
79-
80-
# Solving and plotting distributions
68+
# Solve both configurations
8169
results = solve(vsm_solver, body_aero)
8270
@time results_with_stall = solve(VSM_with_stall_correction, body_aero)
8371
@time results_with_stall = solve(VSM_with_stall_correction, body_aero)
8472

85-
CAD_y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
86-
87-
PLOT && plot_distribution(
88-
[CAD_y_coordinates, CAD_y_coordinates],
89-
[results, results_with_stall],
90-
["VSM", "VSM with stall correction"];
91-
title="CAD_spanwise_distributions_alpha_$(round(aoa, digits=1))_delta_$(round(side_slip, digits=1))_yaw_$(round(yaw_rate, digits=1))_v_a_$(round(v_a, digits=1))",
92-
data_type=".png",
93-
save_path=joinpath(save_folder, "spanwise_distributions"),
94-
is_save=false,
95-
is_show=true,
96-
use_tex=USE_TEX
97-
)
98-
99-
# Plotting polar
100-
save_path = joinpath(root_dir, "results", "TUD_V3_LEI_KITE")
73+
# Setup literature data paths
10174
path_cfd_lebesque = joinpath(
10275
root_dir,
10376
"data",
@@ -108,24 +81,20 @@ path_cfd_lebesque = joinpath(
10881

10982
# Only include literature data if file exists
11083
literature_paths = isfile(path_cfd_lebesque) ? [path_cfd_lebesque] : String[]
111-
labels = isfile(path_cfd_lebesque) ?
112-
["VSM CAD 19ribs", "VSM CAD 19ribs , with stall correction", "CFD_Lebesque Rey 30e5"] :
113-
["VSM CAD 19ribs", "VSM CAD 19ribs , with stall correction"]
11484

115-
PLOT && plot_polars(
85+
# Plot combined analysis
86+
PLOT && plot_combined_analysis(
11687
[vsm_solver, VSM_with_stall_correction],
11788
[body_aero, body_aero],
118-
labels;
89+
[results, results_with_stall];
90+
solver_label=["VSM", "VSM (with stall)"],
11991
literature_path_list=literature_paths,
12092
angle_range=range(0, 25, length=25),
12193
angle_type="angle_of_attack",
122-
angle_of_attack=0,
123-
side_slip=0,
124-
v_a=10,
125-
title="tutorial_testing_stall_model_n_panels_$(n_panels)_distribution_$(spanwise_distribution)_unrefined_$(CAD_wing.n_unrefined_sections)",
126-
data_type=".png",
127-
save_path=joinpath(save_folder, "polars"),
128-
is_save=true,
94+
angle_of_attack=aoa,
95+
side_slip=side_slip,
96+
v_a=v_a,
97+
title="Stall Model Comparison",
12998
is_show=true,
13099
use_tex=USE_TEX
131100
)

0 commit comments

Comments
 (0)