Skip to content

Commit 0f7db59

Browse files
committed
Rename wa to body_aero
1 parent fea5434 commit 0f7db59

16 files changed

+254
-290
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ add_section!(wing,
117117
INVISCID)
118118

119119
# Step 3: Initialize aerodynamics
120-
wa = BodyAerodynamics([wing])
120+
body_aero = BodyAerodynamics([wing])
121121

122122
# Set inflow conditions
123123
vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a

docs/src/examples.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ add_section!(wing,
5454

5555
#### Step 4: Initialize aerodynamics
5656
```
57-
wa = BodyAerodynamics([wing])
57+
body_aero = BodyAerodynamics([wing])
5858
```
5959
We need to pass here an array of wing objects, because a body can have multiple wings.
6060

6161
###### Set inflow conditions
6262
```julia
6363
vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
64-
set_va!(wa, vel_app, [0, 0, 0.1])
64+
set_va!(body_aero, vel_app, [0, 0, 0.1])
6565
```
6666
#### Step 5: Plot the geometry
6767
```julia
6868
plot_geometry(
69-
wa,
69+
body_aero,
7070
"Rectangular_wing_geometry";
7171
data_type=".pdf",
7272
save_path=".",
@@ -86,8 +86,8 @@ vsm_solver = Solver(aerodynamic_model_type=VSM)
8686

8787
#### Step 7: Solve using both methods
8888
```
89-
results_llt = solve(llt_solver, wa)
90-
results_vsm = solve(vsm_solver, wa)
89+
results_llt = solve(llt_solver, body_aero)
90+
results_vsm = solve(vsm_solver, body_aero)
9191
```
9292

9393
##### Print results comparison
@@ -103,7 +103,7 @@ println("Projected area = $(round(results_vsm["projected_area"], digits=4)) m²"
103103

104104
#### Step 8: Plot spanwise distributions
105105
```julia
106-
y_coordinates = [panel.aero_center[2] for panel in wa.panels]
106+
y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
107107

108108
plot_distribution(
109109
[y_coordinates, y_coordinates],
@@ -121,7 +121,7 @@ You should see a plot like this:
121121
angle_range = range(0, 20, 20)
122122
plot_polars(
123123
[llt_solver, vsm_solver],
124-
[wa, wa],
124+
[body_aero, body_aero],
125125
["LLT", "VSM"];
126126
angle_range,
127127
angle_type="angle_of_attack",

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ add_section!(wing,
115115
INVISCID)
116116

117117
# Step 3: Initialize aerodynamics
118-
wa = BodyAerodynamics([wing])
118+
body_aero = BodyAerodynamics([wing])
119119

120120
# Set inflow conditions
121121
vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a

examples/bench.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,29 @@ add_section!(wing,
3232
INVISCID)
3333

3434
# Step 3: Initialize aerodynamics
35-
wa = BodyAerodynamics([wing])
35+
body_aero = BodyAerodynamics([wing])
3636

3737
# Set inflow conditions
3838
vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
39-
set_va!(wa, vel_app)
39+
set_va!(body_aero, vel_app)
4040

4141
# Step 4: Initialize solvers for both LLT and VSM methods
42-
P = length(wa.panels)
43-
llt_solver = Solver{P}(aerodynamic_model_type=LLT)
44-
vsm_solver = Solver{P}(aerodynamic_model_type=VSM)
42+
P = length(body_aero.panels)
43+
llt_solver = Solver(body_aero; aerodynamic_model_type=LLT)
44+
vsm_solver = Solver(body_aero; aerodynamic_model_type=VSM)
4545

4646
# Step 5: Solve using both methods
47-
results_vsm = solve(vsm_solver, wa)
48-
sol = solve!(vsm_solver, wa)
49-
results_vsm_base = solve_base!(vsm_solver, wa)
47+
results_vsm = solve(vsm_solver, body_aero)
48+
sol = solve!(vsm_solver, body_aero)
49+
results_vsm_base = solve_base!(vsm_solver, body_aero)
5050
println("Rectangular wing, solve_base!:")
51-
@time results_vsm_base = solve_base!(vsm_solver, wa)
51+
@time results_vsm_base = solve_base!(vsm_solver, body_aero)
5252
# time Python: 32.0 ms Ryzen 7950x
5353
# time Julia: 0.42 ms Ryzen 7950x
5454
println("Rectangular wing, solve!:")
55-
@time sol = solve!(vsm_solver, wa)
55+
@time sol = solve!(vsm_solver, body_aero)
5656
println("Rectangular wing, solve:")
57-
@time solve(vsm_solver, wa)
57+
@time solve(vsm_solver, body_aero)
5858

5959
# Create wing geometry
6060
wing = RamAirWing("data/ram_air_kite_body.obj", "data/ram_air_kite_foil.dat")

examples/ram_air_kite.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if DEFORM
2222
end
2323

2424
# Create solvers
25-
vsm_solver = Solver(body_aero;
25+
solver = Solver(body_aero;
2626
aerodynamic_model_type=VSM,
2727
is_with_artificial_damping=false,
2828
rtol=1e-5,
@@ -45,7 +45,7 @@ set_va!(body_aero, vel_app)
4545
if LINEARIZE
4646
println("Linearize")
4747
jac, res = VortexStepMethod.linearize(
48-
vsm_solver,
48+
solver,
4949
body_aero,
5050
wing,
5151
[zeros(4); vel_app; zeros(3)];
@@ -54,7 +54,7 @@ if LINEARIZE
5454
omega_idxs=8:10,
5555
moment_frac=0.1)
5656
@time jac, res = VortexStepMethod.linearize(
57-
vsm_solver,
57+
solver,
5858
body_aero,
5959
wing,
6060
[zeros(4); vel_app; zeros(3)];
@@ -82,8 +82,8 @@ PLOT && plot_geometry(
8282

8383
# Solving and plotting distributions
8484
println("Solve")
85-
results = VortexStepMethod.solve(vsm_solver, body_aero; log=true)
86-
@time results = solve(vsm_solver, body_aero; log=true)
85+
results = VortexStepMethod.solve(solver, body_aero; log=true)
86+
@time results = solve(solver, body_aero; log=true)
8787

8888
body_y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
8989

@@ -99,7 +99,7 @@ PLOT && plot_distribution(
9999
)
100100

101101
PLOT && plot_polars(
102-
[vsm_solver],
102+
[solver],
103103
[body_aero],
104104
[
105105
"VSM from Ram Air Kite OBJ and DAT file",

examples/rectangular_wing.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ add_section!(wing,
2828
INVISCID)
2929

3030
# Step 3: Initialize aerodynamics
31-
wa = BodyAerodynamics([wing])
31+
body_aero = BodyAerodynamics([wing])
3232

3333
# Set inflow conditions
3434
vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
35-
set_va!(wa, vel_app, [0, 0, 0.1])
35+
set_va!(body_aero, vel_app, [0, 0, 0.1])
3636

3737
# Step 4: Initialize solvers for both LLT and VSM methods
38-
P = length(wa.panels)
39-
llt_solver = Solver{P}(aerodynamic_model_type=LLT)
40-
vsm_solver = Solver{P}(aerodynamic_model_type=VSM)
38+
P = length(body_aero.panels)
39+
llt_solver = Solver(body_aero; aerodynamic_model_type=LLT)
40+
vsm_solver = Solver(body_aero; aerodynamic_model_type=VSM)
4141

4242
# Step 5: Solve using both methods
43-
results_llt = solve(llt_solver, wa)
44-
@time results_llt = solve(llt_solver, wa)
45-
results_vsm = solve(vsm_solver, wa)
46-
@time results_vsm = solve(vsm_solver, wa)
43+
results_llt = solve(llt_solver, body_aero)
44+
@time results_llt = solve(llt_solver, body_aero)
45+
results_vsm = solve(vsm_solver, body_aero)
46+
@time results_vsm = solve(vsm_solver, body_aero)
4747

4848
# Print results comparison
4949
println("\nLifting Line Theory Results:")
@@ -56,7 +56,7 @@ println("Projected area = $(round(results_vsm["projected_area"], digits=4)) m²"
5656

5757
# Step 6: Plot geometry
5858
PLOT && plot_geometry(
59-
wa,
59+
body_aero,
6060
"Rectangular_wing_geometry";
6161
data_type=".pdf",
6262
save_path=".",
@@ -66,7 +66,7 @@ PLOT && plot_geometry(
6666
)
6767

6868
# Step 7: Plot spanwise distributions
69-
y_coordinates = [panel.aero_center[2] for panel in wa.panels]
69+
y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
7070

7171
PLOT && plot_distribution(
7272
[y_coordinates, y_coordinates],
@@ -80,7 +80,7 @@ PLOT && plot_distribution(
8080
angle_range = range(0, 20, 20)
8181
PLOT && plot_polars(
8282
[llt_solver, vsm_solver],
83-
[wa, wa],
83+
[body_aero, body_aero],
8484
["LLT", "VSM"];
8585
angle_range,
8686
angle_type="angle_of_attack",

examples/stall_model.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ CAD_wing = Wing(n_panels; spanwise_distribution)
4242
for rib in rib_list
4343
add_section!(CAD_wing, rib[1], rib[2], rib[3], rib[4])
4444
end
45-
body_aero_CAD_19ribs = BodyAerodynamics([CAD_wing])
45+
body_aero = BodyAerodynamics([CAD_wing])
4646

4747
# Create solvers
48-
P = length(body_aero_CAD_19ribs.panels)
49-
vsm_solver = Solver{P}(
48+
P = length(body_aero.panels)
49+
vsm_solver = Solver(body_aero;
5050
aerodynamic_model_type=VSM,
5151
is_with_artificial_damping=false
5252
)
53-
VSM_with_stall_correction = Solver{P}(
53+
VSM_with_stall_correction = Solver(body_aero;
5454
aerodynamic_model_type=VSM,
5555
is_with_artificial_damping=true
5656
)
@@ -66,11 +66,11 @@ vel_app = [
6666
sin(side_slip),
6767
sin(aoa_rad)
6868
] * v_a
69-
set_va!(body_aero_CAD_19ribs, vel_app)
69+
set_va!(body_aero, vel_app)
7070

7171
# Plotting geometry
7272
PLOT && plot_geometry(
73-
body_aero_CAD_19ribs,
73+
body_aero,
7474
"";
7575
data_type=".svg",
7676
save_path="",
@@ -82,11 +82,11 @@ PLOT && plot_geometry(
8282
)
8383

8484
# Solving and plotting distributions
85-
results = solve(vsm_solver, body_aero_CAD_19ribs)
86-
@time results_with_stall = solve(VSM_with_stall_correction, body_aero_CAD_19ribs)
87-
@time results_with_stall = solve(VSM_with_stall_correction, body_aero_CAD_19ribs)
85+
results = solve(vsm_solver, body_aero)
86+
@time results_with_stall = solve(VSM_with_stall_correction, body_aero)
87+
@time results_with_stall = solve(VSM_with_stall_correction, body_aero)
8888

89-
CAD_y_coordinates = [panel.aero_center[2] for panel in body_aero_CAD_19ribs.panels]
89+
CAD_y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
9090

9191
PLOT && plot_distribution(
9292
[CAD_y_coordinates, CAD_y_coordinates],
@@ -112,7 +112,7 @@ path_cfd_lebesque = joinpath(
112112

113113
PLOT && plot_polars(
114114
[vsm_solver, VSM_with_stall_correction],
115-
[body_aero_CAD_19ribs, body_aero_CAD_19ribs],
115+
[body_aero, body_aero],
116116
[
117117
"VSM CAD 19ribs",
118118
"VSM CAD 19ribs , with stall correction",

src/body_aerodynamics.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ function BodyAerodynamics(
6767
section.LE_point .-= kite_body_origin
6868
section.TE_point .-= kite_body_origin
6969
end
70-
if wing.spanwise_distribution == UNCHANGED
70+
if wing.spanwise_distribution == UNCHANGED && !(wing.n_panels == length(wing.sections) - 1)
71+
@warn "Changing wing.n_panels from $(wing.n_panels) to $(length(wing.sections) - 1)"
7172
wing.n_panels = length(wing.sections) - 1
7273
wing.refined_sections = wing.sections
7374
else

src/kite_geometry.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,15 @@ Constructor for a [RamAirWing](@ref) that allows to use an `.obj` and a `.dat` f
435435
- `spanwise_direction`=[0.0, 1.0, 0.0]
436436
- `remove_nan::Bool`: Wether to remove the NaNs from interpolations or not
437437
"""
438-
function RamAirWing(obj_path, dat_path; crease_frac=0.9, wind_vel=10., mass=1.0,
439-
n_panels=56, n_sections=n_panels+1, n_groups=n_panels÷4, spanwise_distribution=UNCHANGED,
440-
spanwise_direction=[0.0, 1.0, 0.0], remove_nan=true, align_to_principal=false,
441-
alpha_range=deg2rad.(-5:1:20), delta_range=deg2rad.(-5:1:20), interp_steps=n_sections
442-
)
443-
438+
function RamAirWing(
439+
obj_path, dat_path;
440+
crease_frac=0.9, wind_vel=10., mass=1.0,
441+
n_panels=56, n_sections=n_panels+1, n_groups=4, spanwise_distribution=UNCHANGED,
442+
spanwise_direction=[0.0, 1.0, 0.0], remove_nan=true, align_to_principal=false,
443+
alpha_range=deg2rad.(-5:1:20), delta_range=deg2rad.(-5:1:20), interp_steps=n_sections # TODO: check if interpolations are still needed
444+
)
445+
446+
!(n_panels % n_groups == 0) && throw(ArgumentError("Number of panels should be divisible by number of groups"))
444447
!isapprox(spanwise_direction, [0.0, 1.0, 0.0]) && throw(ArgumentError("Spanwise direction has to be [0.0, 1.0, 0.0], not $spanwise_direction"))
445448

446449
# Load or create polars

0 commit comments

Comments
 (0)