Skip to content

Commit 9b77791

Browse files
committed
Geometry tests pass
1 parent 84a57e7 commit 9b77791

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/polars.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ function create_polars(; dat_path, cl_polar_path, cd_polar_path, cm_polar_path,
232232
interpolate_matrix_nans!(cm_matrix)
233233
end
234234

235-
# serialize(polar_path, (alpha_range, delta_range, cl_matrix, cd_matrix, cm_matrix))
236235
write_aero_matrix(cl_polar_path, cl_matrix, alpha_range, delta_range, "C_l")
237236
write_aero_matrix(cd_polar_path, cd_matrix, alpha_range, delta_range, "C_d")
238237
write_aero_matrix(cm_polar_path, cm_matrix, alpha_range, delta_range, "C_m")

src/ram_geometry.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,15 @@ function RamAirWing(
450450
area, width, crease_frac, alpha_range, delta_range, remove_nan)
451451
end
452452

453-
# (alpha_range, delta_range, cl_matrix::Matrix, cd_matrix::Matrix, cm_matrix::Matrix) = deserialize(polar_path)
454453
cl_matrix, _, _ = read_aero_matrix(cl_polar_path)
455454
cd_matrix, _, _ = read_aero_matrix(cd_polar_path)
456455
cm_matrix, alpha_range, delta_range = read_aero_matrix(cm_polar_path)
456+
457+
if remove_nan
458+
any(isnan.(cl_matrix)) && interpolate_matrix_nans!(cl_matrix; prn)
459+
any(isnan.(cd_matrix)) && interpolate_matrix_nans!(cd_matrix; prn)
460+
any(isnan.(cm_matrix)) && interpolate_matrix_nans!(cm_matrix; prn)
461+
end
457462

458463
# Create sections
459464
sections = Section[]

test/test_kite_geometry.jl

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
using Test
33
using VortexStepMethod
4-
using VortexStepMethod: create_interpolations, find_circle_center_and_radius, calculate_inertia_tensor, center_to_com!, read_faces, calc_inertia_y_rotation
4+
using VortexStepMethod: create_interpolations, find_circle_center_and_radius, calculate_inertia_tensor,
5+
center_to_com!, read_faces, calc_inertia_y_rotation, write_aero_matrix, read_aero_matrix
56
using LinearAlgebra
67
using Interpolations
78
using Serialization
@@ -78,7 +79,7 @@ using Serialization
7879
Δθ = π/2 / 1000
7980
for θ in range(-π/4, π/4-Δθ, 1000)
8081
frac = 1.0 - abs(4θ/π) # Goes from 0 to 1 to 0
81-
x_le = 0.1 - 0.1 * frac # Goes from 0.1 to 0.0 to 0.1
82+
x_le = 0.1 - 0.1 * frac # Goes from 0.1 to 0.0 to 0.1
8283
x_te = 0.9 + 0.1 * frac # Goes from 0.9 to 1.0 to 0.9
8384

8485
push!(vertices, [x_le, r*sin(θ), z_center + r*cos(θ)])
@@ -109,9 +110,14 @@ using Serialization
109110
cd_matrix[end] = NaN
110111
cm_matrix[end] = NaN
111112

112-
# Serialize polar data
113-
polar_path = test_dat_path[1:end-4] * "_polar.bin"
114-
serialize(polar_path, (alphas, d_trailing_edge_angles, cl_matrix, cd_matrix, cm_matrix))
113+
cl_polar_path = joinpath(tempdir(), test_dat_path[1:end-4] * "_cl_polar.csv")
114+
cd_polar_path = joinpath(tempdir(), test_dat_path[1:end-4] * "_cd_polar.csv")
115+
cm_polar_path = joinpath(tempdir(), test_dat_path[1:end-4] * "_cm_polar.csv")
116+
117+
# Write matrices to CSV
118+
write_aero_matrix(cl_polar_path, cl_matrix, deg2rad.(alphas), deg2rad.(d_trailing_edge_angles), "C_l")
119+
write_aero_matrix(cd_polar_path, cd_matrix, deg2rad.(alphas), deg2rad.(d_trailing_edge_angles), "C_d")
120+
write_aero_matrix(cm_polar_path, cm_matrix, deg2rad.(alphas), deg2rad.(d_trailing_edge_angles), "C_m")
115121

116122
# Create and serialize obj file
117123
faces = [[i, i+1, i+2] for i in 1:3:length(vertices)-2]
@@ -124,6 +130,13 @@ using Serialization
124130
end
125131
end
126132

133+
# Test reading back the matrices
134+
cl_read, alphas_read, deltas_read = read_aero_matrix(cl_polar_path)
135+
@test cl_read[1:end-1,:] cl_matrix[1:end-1,:]
136+
@test isnan(cl_read[end,end])
137+
@test alphas_read deg2rad.(alphas)
138+
@test deltas_read deg2rad.(d_trailing_edge_angles)
139+
127140
# Create info file
128141
info_path = test_obj_path[1:end-4] * "_info.bin"
129142
le_interp, te_interp, area_interp = create_interpolations(vertices, z_center, r, π/4, I(3))

0 commit comments

Comments
 (0)