Skip to content

Commit bb7583f

Browse files
committed
More tests
1 parent f6fb77b commit bb7583f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/plotting.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ function plot_geometry(wing_aero, title;
232232
plt.ion()
233233
fig = create_geometry_plot(wing_aero, title, view_elevation, view_azimuth)
234234
plt.display(fig)
235+
else
236+
fig = create_geometry_plot(wing_aero, title, view_elevation, view_azimuth)
235237
end
238+
fig
236239
end
237240

238241
"""

test/test_plotting.jl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,37 @@ using VortexStepMethod
22
using ControlPlots
33
using Test
44

5+
function result_vsm()
6+
# Step 1: Define wing parameters
7+
n_panels = 20 # Number of panels
8+
span = 20.0 # Wing span [m]
9+
chord = 1.0 # Chord length [m]
10+
Umag = 20.0 # Magnitude of inflow velocity [m/s]
11+
density = 1.225 # Air density [kg/m³]
12+
alpha_deg = 30.0 # Angle of attack [degrees]
13+
alpha = deg2rad(alpha_deg)
14+
15+
# Step 2: Create wing geometry with linear panel distribution
16+
wing = Wing(n_panels, spanwise_panel_distribution="linear")
17+
18+
# Add wing sections - defining only tip sections with inviscid airfoil model
19+
add_section!(wing,
20+
[0.0, span/2, 0.0], # Left tip LE
21+
[chord, span/2, 0.0], # Left tip TE
22+
"inviscid")
23+
add_section!(wing,
24+
[0.0, -span/2, 0.0], # Right tip LE
25+
[chord, -span/2, 0.0], # Right tip TE
26+
"inviscid")
27+
28+
# Step 3: Initialize aerodynamics
29+
wa = WingAerodynamics([wing])
30+
# Set inflow conditions
31+
vel_app = [cos(alpha), 0.0, sin(alpha)] .* Umag
32+
set_va!(wa, (vel_app, 0.0)) # Second parameter is yaw rate
33+
wa
34+
end
35+
536
plt.ioff()
637
@testset "Plotting" begin
738
fig = plt.figure(figsize=(14, 14))
@@ -12,5 +43,22 @@ plt.ioff()
1243
@test isfile("/tmp/plot.pdf")
1344
rm("/tmp/plot.pdf")
1445
show_plot(fig)
46+
wa = result_vsm()
47+
fig = plot_geometry(
48+
wa,
49+
"Rectangular_wing_geometry";
50+
data_type=".pdf",
51+
save_path="/tmp",
52+
is_save=true,
53+
is_show=false)
54+
@test fig isa plt.PyPlot.Figure
55+
@test isfile("/tmp/Rectangular_wing_geometry_angled_view.pdf")
56+
rm("/tmp/Rectangular_wing_geometry_angled_view.pdf")
57+
@test isfile("/tmp/Rectangular_wing_geometry_front_view.pdf")
58+
rm("/tmp/Rectangular_wing_geometry_front_view.pdf")
59+
@test isfile("/tmp/Rectangular_wing_geometry_side_view.pdf")
60+
rm("/tmp/Rectangular_wing_geometry_side_view.pdf")
61+
@test isfile("/tmp/Rectangular_wing_geometry_top_view.pdf")
62+
rm("/tmp/Rectangular_wing_geometry_top_view.pdf")
1563
end
1664
plt.ion()

0 commit comments

Comments
 (0)