Skip to content

Commit 3ac3739

Browse files
committed
make tests and examples work
1 parent d90015c commit 3ac3739

File tree

7 files changed

+69
-203
lines changed

7 files changed

+69
-203
lines changed

examples/code_bench.jl

Lines changed: 0 additions & 132 deletions
This file was deleted.

examples/ram_air_kite.jl

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ end
88
using CSV
99
using DataFrames
1010

11+
plot = true
12+
1113
# Create wing geometry
1214
wing = KiteWing("data/ram_air_kite_body.obj", "data/ram_air_kite_foil.dat")
1315
body_aero = BodyAerodynamics([wing])
1416

1517
# Create solvers
1618
VSM = Solver(
17-
aerodynamic_model_type="VSM",
19+
aerodynamic_model_type=:VSM,
1820
is_with_artificial_damping=false
1921
)
2022
VSM_with_stall_correction = Solver(
21-
aerodynamic_model_type="VSM",
23+
aerodynamic_model_type=:VSM,
2224
is_with_artificial_damping=true
2325
)
2426

@@ -35,48 +37,48 @@ vel_app = [
3537
] * v_a
3638
body_aero.va = vel_app
3739

38-
# # Plotting geometry
39-
# plot_geometry(
40-
# body_aero,
41-
# "";
42-
# data_type=".svg",
43-
# save_path="",
44-
# is_save=false,
45-
# is_show=true,
46-
# view_elevation=15,
47-
# view_azimuth=-120
48-
# )
40+
# Plotting geometry
41+
plot && plot_geometry(
42+
body_aero,
43+
"";
44+
data_type=".svg",
45+
save_path="",
46+
is_save=false,
47+
is_show=true,
48+
view_elevation=15,
49+
view_azimuth=-120
50+
)
4951

5052
# Solving and plotting distributions
5153
@time results = solve(VSM, body_aero)
5254
@time results = solve(VSM, body_aero)
5355

5456
CAD_y_coordinates = [panel.aerodynamic_center[2] for panel in body_aero.panels]
5557

56-
# plot_distribution(
57-
# [CAD_y_coordinates],
58-
# [results],
59-
# ["VSM"];
60-
# title="CAD_spanwise_distributions_alpha_$(round(aoa, digits=1))_beta_$(round(side_slip, digits=1))_yaw_$(round(yaw_rate, digits=1))_v_a_$(round(v_a, digits=1))",
61-
# data_type=".pdf",
62-
# is_save=false,
63-
# is_show=true
64-
# )
58+
plot && plot_distribution(
59+
[CAD_y_coordinates],
60+
[results],
61+
["VSM"];
62+
title="CAD_spanwise_distributions_alpha_$(round(aoa, digits=1))_beta_$(round(side_slip, digits=1))_yaw_$(round(yaw_rate, digits=1))_v_a_$(round(v_a, digits=1))",
63+
data_type=".pdf",
64+
is_save=false,
65+
is_show=true
66+
)
6567

66-
# plot_polars(
67-
# [VSM],
68-
# [body_aero],
69-
# [
70-
# "VSM from Ram Air Kite OBJ and DAT file",
71-
# ];
72-
# angle_range=range(0, 20, length=20),
73-
# angle_type="angle_of_attack",
74-
# angle_of_attack=0,
75-
# side_slip=0,
76-
# v_a=10,
77-
# title="ram_kite_panels_$(wing.n_panels)_distribution_$(wing.spanwise_panel_distribution)",
78-
# data_type=".pdf",
79-
# is_save=false,
80-
# is_show=true
81-
# )
68+
plot && plot_polars(
69+
[VSM],
70+
[body_aero],
71+
[
72+
"VSM from Ram Air Kite OBJ and DAT file",
73+
];
74+
angle_range=range(0, 20, length=20),
75+
angle_type="angle_of_attack",
76+
angle_of_attack=0,
77+
side_slip=0,
78+
v_a=10,
79+
title="ram_kite_panels_$(wing.n_panels)_distribution_$(wing.spanwise_panel_distribution)",
80+
data_type=".pdf",
81+
is_save=false,
82+
is_show=true
83+
)
8284
nothing

examples/rectangular_wing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using LinearAlgebra
22
using ControlPlots
33
using VortexStepMethod
44

5-
plot = false
5+
plot = true
66

77
# Step 1: Define wing parameters
88
n_panels = 20 # Number of panels

examples/stall_model.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mkpath(save_folder)
1515

1616
# Defining discretisation
1717
n_panels = 54
18-
spanwise_panel_distribution = "split_provided"
18+
spanwise_panel_distribution = :split_provided
1919

2020
# Load rib data from CSV
2121
csv_file_path = joinpath(
@@ -30,7 +30,7 @@ rib_list = []
3030
for row in eachrow(df)
3131
LE = [row.LE_x, row.LE_y, row.LE_z]
3232
TE = [row.TE_x, row.TE_y, row.TE_z]
33-
push!(rib_list, (LE, TE, ("lei_airfoil_breukels", [row.d_tube, row.camber])))
33+
push!(rib_list, (LE, TE, (:lei_airfoil_breukels, [row.d_tube, row.camber])))
3434
end
3535

3636
# Create wing geometry
@@ -42,11 +42,11 @@ body_aero_CAD_19ribs = BodyAerodynamics([CAD_wing])
4242

4343
# Create solvers
4444
VSM = Solver(
45-
aerodynamic_model_type="VSM",
45+
aerodynamic_model_type=:VSM,
4646
is_with_artificial_damping=false
4747
)
4848
VSM_with_stall_correction = Solver(
49-
aerodynamic_model_type="VSM",
49+
aerodynamic_model_type=:VSM,
5050
is_with_artificial_damping=true
5151
)
5252

@@ -63,17 +63,17 @@ vel_app = [
6363
] * v_a
6464
body_aero_CAD_19ribs.va = vel_app
6565

66-
# # Plotting geometry
67-
# plot_geometry(
68-
# body_aero_CAD_19ribs,
69-
# "";
70-
# data_type=".svg",
71-
# save_path="",
72-
# is_save=false,
73-
# is_show=true,
74-
# view_elevation=15,
75-
# view_azimuth=-120
76-
# )
66+
# Plotting geometry
67+
plot_geometry(
68+
body_aero_CAD_19ribs,
69+
"";
70+
data_type=".svg",
71+
save_path="",
72+
is_save=false,
73+
is_show=true,
74+
view_elevation=15,
75+
view_azimuth=-120
76+
)
7777

7878
# Solving and plotting distributions
7979
results = solve(VSM, body_aero_CAD_19ribs)

src/panel.jl

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,7 @@ function calculate_cl(panel::Panel, alpha::Float64)::Float64
262262
end
263263
elseif panel.aero_model === :inviscid
264264
cl = 2π * alpha
265-
elseif panel.aero_model === :polar_data
266-
cl = panel.cl_interp(alpha)::Float64
267-
elseif panel.aero_model === :interpolations
265+
elseif panel.aero_model === :polar_data || panel.aero_model === :interpolations
268266
cl = panel.cl_interp(alpha)::Float64
269267
else
270268
throw(ArgumentError("Unsupported aero model: $(panel.aero_model)"))
@@ -279,26 +277,20 @@ end
279277
Calculate drag and moment coefficients for given angle of attack.
280278
"""
281279
function calculate_cd_cm(panel::Panel, alpha::Float64)
280+
cd, cm = 0.0, 0.0
282281
if panel.aero_model === :lei_airfoil_breukels
283282
cd = evalpoly(rad2deg(alpha), reverse(panel.cd_coefficients))
284283
cm = evalpoly(rad2deg(alpha), reverse(panel.cm_coefficients))
285284
if abs(alpha) >/9) # Outside ±20 degrees
286285
cd = 2 * sin(alpha)^3
287286
end
288-
return cd, cm
289-
elseif panel.aero_model === :inviscid
290-
return 0.0, 0.0
291-
elseif panel.aero_model === :polar_data
292-
cd = panel.cd_interp(alpha)
293-
cm = panel.cm_interp(alpha)
294-
return cd, cm
295-
elseif panel.aero_model === :interpolations
296-
cd = panel.cd_interp(alpha, 0.0)
297-
cm = panel.cm_interp(alpha, 0.0)
298-
return cd, cm
299-
else
287+
elseif panel.aero_model === :polar_data || panel.aero_model === :interpolations
288+
cd = panel.cd_interp(alpha)::Float64
289+
cm = panel.cm_interp(alpha)::Float64
290+
elseif !(panel.aero_model === :inviscid)
300291
throw(ArgumentError("Unsupported aero model: $(panel.aero_model)"))
301292
end
293+
return cd, cm
302294
end
303295

304296
"""

test/bench.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using BenchmarkTools
2+
using StaticArrays
23
using VortexStepMethod
34
using VortexStepMethod: calculate_AIC_matrices!, gamma_loop, calculate_results,
45
update_effective_angle_of_attack_if_VSM, calculate_projected_area,
@@ -55,6 +56,7 @@ using LinearAlgebra
5556
core_radius_fractions = [0.001, 10.0]
5657

5758
@testset "AIC Matrix Calculation" begin
59+
@info "AIC Matrix Calculation"
5860
for model in models
5961
for frac in core_radius_fractions
6062
@testset "Model $model Core Radius Fraction $frac" begin
@@ -67,7 +69,7 @@ using LinearAlgebra
6769
end
6870

6971
@testset "Gamma Loop" begin
70-
72+
@info "Gamma Loop"
7173
# Pre-allocate arrays
7274
gamma_new = zeros(n_panels)
7375
va_array = zeros(n_panels, 3)
@@ -244,4 +246,5 @@ using LinearAlgebra
244246
# )
245247
# @test result.allocs == 0
246248
# end
247-
end
249+
end
250+

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Test
33
cd("..")
44
println("Running tests...")
55
@testset verbose = true "Testing VortexStepMethod..." begin
6+
include("bench.jl")
67
include("test_bound_filament.jl")
78
include("test_panel.jl")
89
include("test_semi_infinite_filament.jl")

0 commit comments

Comments
 (0)