Skip to content

Commit 077eb78

Browse files
committed
Plot panels
1 parent 355a4f8 commit 077eb78

File tree

2 files changed

+123
-94
lines changed

2 files changed

+123
-94
lines changed

examples/ram_air_kite.jl

Lines changed: 96 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using ControlPlots
1+
using Makie
2+
using GLMakie
23
using VortexStepMethod
34
using LinearAlgebra
45

@@ -17,105 +18,107 @@ wing = RamAirWing(
1718
body_aero = BodyAerodynamics([wing];)
1819
println("First init")
1920
@time VortexStepMethod.reinit!(body_aero)
21+
plot(body_aero.panels[1])
2022

21-
if DEFORM
22-
# Linear interpolation of alpha from 10° at one tip to 0° at the other
23-
println("Deform")
24-
@time VortexStepMethod.smooth_deform!(wing, deg2rad.([10,20,10,0]), deg2rad.([-10,0,-10,0]))
25-
println("Deform init")
26-
@time VortexStepMethod.reinit!(body_aero; init_aero=false)
27-
end
2823

29-
# Create solvers
30-
solver = Solver(body_aero;
31-
aerodynamic_model_type=VSM,
32-
is_with_artificial_damping=false,
33-
rtol=1e-5,
34-
solver_type=NONLIN
35-
)
24+
# if DEFORM
25+
# # Linear interpolation of alpha from 10° at one tip to 0° at the other
26+
# println("Deform")
27+
# @time VortexStepMethod.smooth_deform!(wing, deg2rad.([10,20,10,0]), deg2rad.([-10,0,-10,0]))
28+
# println("Deform init")
29+
# @time VortexStepMethod.reinit!(body_aero; init_aero=false)
30+
# end
3631

37-
# Setting velocity conditions
38-
v_a = 15.0
39-
aoa = 10.0
40-
side_slip = 0.0
41-
yaw_rate = 0.0
42-
aoa_rad = deg2rad(aoa)
43-
vel_app = [
44-
cos(aoa_rad) * cos(side_slip),
45-
sin(side_slip),
46-
sin(aoa_rad)
47-
] * v_a
48-
set_va!(body_aero, vel_app)
32+
# # Create solvers
33+
# solver = Solver(body_aero;
34+
# aerodynamic_model_type=VSM,
35+
# is_with_artificial_damping=false,
36+
# rtol=1e-5,
37+
# solver_type=NONLIN
38+
# )
4939

50-
if LINEARIZE
51-
println("Linearize")
52-
jac, res = VortexStepMethod.linearize(
53-
solver,
54-
body_aero,
55-
[zeros(4); vel_app; zeros(3)];
56-
theta_idxs=1:4,
57-
va_idxs=5:7,
58-
omega_idxs=8:10,
59-
moment_frac=0.1)
60-
@time jac, res = VortexStepMethod.linearize(
61-
solver,
62-
body_aero,
63-
[zeros(4); vel_app; zeros(3)];
64-
theta_idxs=1:4,
65-
va_idxs=5:7,
66-
omega_idxs=8:10,
67-
moment_frac=0.1)
68-
end
40+
# # Setting velocity conditions
41+
# v_a = 15.0
42+
# aoa = 10.0
43+
# side_slip = 0.0
44+
# yaw_rate = 0.0
45+
# aoa_rad = deg2rad(aoa)
46+
# vel_app = [
47+
# cos(aoa_rad) * cos(side_slip),
48+
# sin(side_slip),
49+
# sin(aoa_rad)
50+
# ] * v_a
51+
# set_va!(body_aero, vel_app)
6952

70-
# Plotting polar data
71-
PLOT && plot_polar_data(body_aero)
53+
# if LINEARIZE
54+
# println("Linearize")
55+
# jac, res = VortexStepMethod.linearize(
56+
# solver,
57+
# body_aero,
58+
# [zeros(4); vel_app; zeros(3)];
59+
# theta_idxs=1:4,
60+
# va_idxs=5:7,
61+
# omega_idxs=8:10,
62+
# moment_frac=0.1)
63+
# @time jac, res = VortexStepMethod.linearize(
64+
# solver,
65+
# body_aero,
66+
# [zeros(4); vel_app; zeros(3)];
67+
# theta_idxs=1:4,
68+
# va_idxs=5:7,
69+
# omega_idxs=8:10,
70+
# moment_frac=0.1)
71+
# end
7272

73-
# Plotting geometry
74-
PLOT && plot_geometry(
75-
body_aero,
76-
"";
77-
data_type=".svg",
78-
save_path="",
79-
is_save=false,
80-
is_show=true,
81-
view_elevation=15,
82-
view_azimuth=-120,
83-
use_tex=USE_TEX
84-
)
73+
# # Plotting polar data
74+
# PLOT && plot_polar_data(body_aero)
8575

86-
# Solving and plotting distributions
87-
println("Solve")
88-
results = VortexStepMethod.solve(solver, body_aero; log=true)
89-
@time results = solve(solver, body_aero; log=true)
76+
# # Plotting geometry
77+
# PLOT && plot_geometry(
78+
# body_aero,
79+
# "";
80+
# data_type=".svg",
81+
# save_path="",
82+
# is_save=false,
83+
# is_show=true,
84+
# view_elevation=15,
85+
# view_azimuth=-120,
86+
# use_tex=USE_TEX
87+
# )
9088

91-
body_y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
89+
# # Solving and plotting distributions
90+
# println("Solve")
91+
# results = VortexStepMethod.solve(solver, body_aero; log=true)
92+
# @time results = solve(solver, body_aero; log=true)
9293

93-
PLOT && plot_distribution(
94-
[body_y_coordinates],
95-
[results],
96-
["VSM"];
97-
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))",
98-
data_type=".pdf",
99-
is_save=false,
100-
is_show=true,
101-
use_tex=USE_TEX
102-
)
94+
# body_y_coordinates = [panel.aero_center[2] for panel in body_aero.panels]
10395

104-
PLOT && plot_polars(
105-
[solver],
106-
[body_aero],
107-
[
108-
"VSM from Ram Air Kite OBJ and DAT file",
109-
];
110-
angle_range=range(0, 20, length=20),
111-
angle_type="angle_of_attack",
112-
angle_of_attack=0,
113-
side_slip=0,
114-
v_a=10,
115-
title="ram_kite_panels_$(wing.n_panels)_distribution_$(wing.spanwise_distribution)",
116-
data_type=".pdf",
117-
is_save=false,
118-
is_show=true,
119-
use_tex=USE_TEX
120-
)
121-
nothing
96+
# PLOT && plot_distribution(
97+
# [body_y_coordinates],
98+
# [results],
99+
# ["VSM"];
100+
# 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))",
101+
# data_type=".pdf",
102+
# is_save=false,
103+
# is_show=true,
104+
# use_tex=USE_TEX
105+
# )
106+
107+
# PLOT && plot_polars(
108+
# [solver],
109+
# [body_aero],
110+
# [
111+
# "VSM from Ram Air Kite OBJ and DAT file",
112+
# ];
113+
# angle_range=range(0, 20, length=20),
114+
# angle_type="angle_of_attack",
115+
# angle_of_attack=0,
116+
# side_slip=0,
117+
# v_a=10,
118+
# title="ram_kite_panels_$(wing.n_panels)_distribution_$(wing.spanwise_distribution)",
119+
# data_type=".pdf",
120+
# is_save=false,
121+
# is_show=true,
122+
# use_tex=USE_TEX
123+
# )
124+
# nothing

ext/VortexStepMethodMakieExt.jl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This creates two triangles: (LE1, TE1, TE2) and (LE1, TE2, LE2).
1010
"""
1111
function Makie.plot!(ax::Makie.Axis3, panel::VortexStepMethod.Panel; kwargs...)
1212
points = [Point3f(panel.corner_points[:, i]) for i in 1:4]
13-
faces = [GLTriangleFace(1, 2, 3), GLTriangleFace(1, 3, 4)]
13+
faces = [Makie.GLTriangleFace(1, 2, 3), Makie.GLTriangleFace(1, 3, 4)]
1414
mesh!(ax, points, faces; kwargs...)
1515
end
1616

@@ -25,4 +25,30 @@ function Makie.plot!(ax::Makie.Axis3, body::VortexStepMethod.BodyAerodynamics; k
2525
end
2626
end
2727

28+
function Makie.plot(panel::VortexStepMethod.Panel; size = (1200, 800), kwargs...)
29+
fig = Figure(; size)
30+
ax = Axis3(fig[1, 1]; aspect = :data,
31+
xlabel = "X", ylabel = "Y", zlabel = "Z",
32+
azimuth = 9/8*π, zoommode = :cursor, viewmode = :fit,
33+
xautolimitmargin=(1.0, 1.0),
34+
yautolimitmargin=(10.0, 10.0),
35+
)
36+
37+
plot!(ax, panel; kwargs...)
38+
return fig
39+
end
40+
41+
function Makie.plot(body_aero::VortexStepMethod.BodyAerodynamics; size = (1200, 800), kwargs...)
42+
fig = Figure(; size)
43+
ax = Axis3(fig[1, 1]; aspect = :data,
44+
xlabel = "X", ylabel = "Y", zlabel = "Z",
45+
azimuth = 9/8*π, zoommode = :cursor, viewmode = :fit,
46+
# xautolimitmargin=(1.0, 1.0),
47+
# yautolimitmargin=(10.0, 10.0),
48+
)
49+
50+
plot!(ax, body_aero; kwargs...)
51+
return fig
52+
end
53+
2854
end

0 commit comments

Comments
 (0)