Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9e2834a
reduce allocations more
1-Bart-1 Feb 21, 2025
7b1c098
add dat file
1-Bart-1 Feb 21, 2025
3ff8bc3
Merge branch 'main' into perf/cut-alloc
1-Bart-1 Feb 22, 2025
605f8f3
add bench file
1-Bart-1 Feb 22, 2025
aaca68f
improve test
1-Bart-1 Feb 22, 2025
20baa8f
Merge branch 'main' into perf/cut-alloc
1-Bart-1 Feb 22, 2025
650bf72
rename Umag to v_a
1-Bart-1 Feb 22, 2025
0ab5152
cant remove calculate_velocity_induced_single_ring_semiinfinite! allocs
1-Bart-1 Feb 22, 2025
7e2bdbc
two non-allocating functions in code_bench
1-Bart-1 Feb 22, 2025
74f68d4
add simple script for alloc testing
1-Bart-1 Feb 22, 2025
9bdea5e
fix calculations
1-Bart-1 Feb 22, 2025
7a0a093
three non-allocating functions
1-Bart-1 Feb 23, 2025
786b2dc
make tests pass again
1-Bart-1 Feb 23, 2025
7317bc4
non-allocating gamma loop
1-Bart-1 Feb 23, 2025
b9868eb
Merge branch 'main' into perf/cut-alloc
1-Bart-1 Feb 23, 2025
08c47f3
more efficient polars
1-Bart-1 Feb 23, 2025
96b1b0c
use symbols instead of strings
1-Bart-1 Feb 23, 2025
d518482
switch to Symbol
1-Bart-1 Feb 24, 2025
7f1d958
tests pass again
1-Bart-1 Feb 24, 2025
d90015c
working test bench
1-Bart-1 Feb 24, 2025
3ac3739
make tests and examples work
1-Bart-1 Feb 24, 2025
33d6d87
Merge branch 'main' into perf/cut-alloc
1-Bart-1 Feb 24, 2025
49abcf2
remove unused dependency
1-Bart-1 Feb 24, 2025
1421cfe
add bench.jl
ufechner7 Feb 24, 2025
2ebe896
add bench to the menu
ufechner7 Feb 24, 2025
9c9d9d9
less output
ufechner7 Feb 24, 2025
60b2a97
fix comment
ufechner7 Feb 24, 2025
9be0dd9
add plot option to example
1-Bart-1 Feb 24, 2025
0528f54
Merge branch 'perf/cut-alloc' of https://github.com/Albatross-Kite-Tr…
1-Bart-1 Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ results/TUDELFT_V3_LEI_KITE/polars/$C_L$ vs $C_D$.pdf
*.bin
results/TUDELFT_V3_LEI_KITE/polars/tutorial_testing_stall_model_n_panels_54_distribution_split_provided.pdf
docs/build/

46 changes: 46 additions & 0 deletions examples/bench.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using LinearAlgebra
using ControlPlots
using VortexStepMethod

plot = true

# Step 1: Define wing parameters
n_panels = 20 # Number of panels
span = 20.0 # Wing span [m]
chord = 1.0 # Chord length [m]
v_a = 20.0 # Magnitude of inflow velocity [m/s]
density = 1.225 # Air density [kg/m³]
alpha_deg = 30.0 # Angle of attack [degrees]
alpha = deg2rad(alpha_deg)

# Step 2: Create wing geometry with linear panel distribution
wing = Wing(n_panels, spanwise_panel_distribution=:linear)

# Add wing sections - defining only tip sections with inviscid airfoil model
add_section!(wing,
[0.0, span/2, 0.0], # Left tip LE
[chord, span/2, 0.0], # Left tip TE
:inviscid)
add_section!(wing,
[0.0, -span/2, 0.0], # Right tip LE
[chord, -span/2, 0.0], # Right tip TE
:inviscid)

# Step 3: Initialize aerodynamics
wa = BodyAerodynamics([wing])

# Set inflow conditions
vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
set_va!(wa, (vel_app, 0.0)) # Second parameter is yaw rate

# Step 4: Initialize solvers for both LLT and VSM methods
llt_solver = Solver(aerodynamic_model_type=:LLT)
vsm_solver = Solver(aerodynamic_model_type=:VSM)

# Step 5: Solve using both methods
results_vsm = solve(vsm_solver, wa)
@time results_vsm = solve(vsm_solver, wa)
# time Python: 32.0 ms
# time Julia: 0.7 ms

nothing
1 change: 1 addition & 0 deletions examples/menu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using REPL.TerminalMenus
options = ["rectangular_wing = include(\"rectangular_wing.jl\")",
"ram_air_kite = include(\"ram_air_kite.jl\")",
"stall_model = include(\"stall_model.jl\")",
"bench = include(\"bench.jl\")",
"quit"]

function example_menu()
Expand Down
12 changes: 7 additions & 5 deletions examples/ram_air_kite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ end
using CSV
using DataFrames

plot = true

# Create wing geometry
wing = KiteWing("data/ram_air_kite_body.obj", "data/ram_air_kite_foil.dat")
body_aero = BodyAerodynamics([wing])

# Create solvers
VSM = Solver(
aerodynamic_model_type="VSM",
aerodynamic_model_type=:VSM,
is_with_artificial_damping=false
)
VSM_with_stall_correction = Solver(
aerodynamic_model_type="VSM",
aerodynamic_model_type=:VSM,
is_with_artificial_damping=true
)

Expand All @@ -36,7 +38,7 @@ vel_app = [
body_aero.va = vel_app

# Plotting geometry
plot_geometry(
plot && plot_geometry(
body_aero,
"";
data_type=".svg",
Expand All @@ -53,7 +55,7 @@ plot_geometry(

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

plot_distribution(
plot && plot_distribution(
[CAD_y_coordinates],
[results],
["VSM"];
Expand All @@ -63,7 +65,7 @@ plot_distribution(
is_show=true
)

plot_polars(
plot && plot_polars(
[VSM],
[body_aero],
[
Expand Down
25 changes: 13 additions & 12 deletions examples/rectangular_wing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ using LinearAlgebra
using ControlPlots
using VortexStepMethod

plot = true

# Step 1: Define wing parameters
n_panels = 20 # Number of panels
span = 20.0 # Wing span [m]
Expand All @@ -12,17 +14,17 @@ alpha_deg = 30.0 # Angle of attack [degrees]
alpha = deg2rad(alpha_deg)

# Step 2: Create wing geometry with linear panel distribution
wing = Wing(n_panels, spanwise_panel_distribution="linear")
wing = Wing(n_panels, spanwise_panel_distribution=:linear)

# Add wing sections - defining only tip sections with inviscid airfoil model
add_section!(wing,
[0.0, span/2, 0.0], # Left tip LE
[chord, span/2, 0.0], # Left tip TE
"inviscid")
:inviscid)
add_section!(wing,
[0.0, -span/2, 0.0], # Right tip LE
[chord, -span/2, 0.0], # Right tip TE
"inviscid")
:inviscid)

# Step 3: Initialize aerodynamics
wa = BodyAerodynamics([wing])
Expand All @@ -32,16 +34,16 @@ vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
set_va!(wa, (vel_app, 0.0)) # Second parameter is yaw rate

# Step 4: Initialize solvers for both LLT and VSM methods
llt_solver = Solver(aerodynamic_model_type="LLT")
vsm_solver = Solver(aerodynamic_model_type="VSM")
llt_solver = Solver(aerodynamic_model_type=:LLT)
vsm_solver = Solver(aerodynamic_model_type=:VSM)

# Step 5: Solve using both methods
results_llt = solve(llt_solver, wa)
@time results_llt = solve(llt_solver, wa)
@time results_llt = solve(llt_solver, wa)
@time results_vsm = solve(vsm_solver, wa)
results_vsm = solve(vsm_solver, wa)
@time results_vsm = solve(vsm_solver, wa)
# time Python: 32.0ms
# time Julia: 1.5ms
# time Julia: 0.7ms

# Print results comparison
println("\nLifting Line Theory Results:")
Expand All @@ -53,20 +55,19 @@ println("CD = $(round(results_vsm["cd"], digits=4))")
println("Projected area = $(round(results_vsm["projected_area"], digits=4)) m²")

# Step 6: Plot geometry
plot_geometry(
plot && plot_geometry(
wa,
"Rectangular_wing_geometry";
data_type=".pdf",
save_path=".",
is_save=false,
is_show=true,
)
nothing

# Step 7: Plot spanwise distributions
y_coordinates = [panel.aerodynamic_center[2] for panel in wa.panels]

plot_distribution(
plot && plot_distribution(
[y_coordinates, y_coordinates],
[results_vsm, results_llt],
["VSM", "LLT"],
Expand All @@ -75,7 +76,7 @@ plot_distribution(

# Step 8: Plot polar curves
angle_range = range(0, 20, 20)
plot_polars(
plot && plot_polars(
[llt_solver, vsm_solver],
[wa, wa],
["LLT", "VSM"];
Expand Down
36 changes: 19 additions & 17 deletions examples/stall_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ end
using CSV
using DataFrames

plot = true

# Find root directory
root_dir = dirname(@__DIR__)
save_folder = joinpath(root_dir, "results", "TUDELFT_V3_LEI_KITE")
mkpath(save_folder)

# Defining discretisation
n_panels = 54
spanwise_panel_distribution = "split_provided"
spanwise_panel_distribution = :split_provided

# Load rib data from CSV
csv_file_path = joinpath(
Expand All @@ -30,7 +32,7 @@ rib_list = []
for row in eachrow(df)
LE = [row.LE_x, row.LE_y, row.LE_z]
TE = [row.TE_x, row.TE_y, row.TE_z]
push!(rib_list, (LE, TE, ("lei_airfoil_breukels", [row.d_tube, row.camber])))
push!(rib_list, (LE, TE, (:lei_airfoil_breukels, [row.d_tube, row.camber])))
end

# Create wing geometry
Expand All @@ -42,11 +44,11 @@ body_aero_CAD_19ribs = BodyAerodynamics([CAD_wing])

# Create solvers
VSM = Solver(
aerodynamic_model_type="VSM",
aerodynamic_model_type=:VSM,
is_with_artificial_damping=false
)
VSM_with_stall_correction = Solver(
aerodynamic_model_type="VSM",
aerodynamic_model_type=:VSM,
is_with_artificial_damping=true
)

Expand All @@ -63,17 +65,17 @@ vel_app = [
] * v_a
body_aero_CAD_19ribs.va = vel_app

# # Plotting geometry
# plot_geometry(
# body_aero_CAD_19ribs,
# "";
# data_type=".svg",
# save_path="",
# is_save=false,
# is_show=true,
# view_elevation=15,
# view_azimuth=-120
# )
# Plotting geometry
plot && plot_geometry(
body_aero_CAD_19ribs,
"";
data_type=".svg",
save_path="",
is_save=false,
is_show=true,
view_elevation=15,
view_azimuth=-120
)

# Solving and plotting distributions
results = solve(VSM, body_aero_CAD_19ribs)
Expand All @@ -82,7 +84,7 @@ results = solve(VSM, body_aero_CAD_19ribs)

CAD_y_coordinates = [panel.aerodynamic_center[2] for panel in body_aero_CAD_19ribs.panels]

plot_distribution(
plot && plot_distribution(
[CAD_y_coordinates, CAD_y_coordinates],
[results, results_with_stall],
["VSM", "VSM with stall correction"];
Expand All @@ -103,7 +105,7 @@ path_cfd_lebesque = joinpath(
"V3_CL_CD_RANS_Lebesque_2024_Rey_300e4.csv"
)

plot_polars(
plot && plot_polars(
[VSM, VSM_with_stall_correction],
[body_aero_CAD_19ribs, body_aero_CAD_19ribs],
[
Expand Down
Loading
Loading