11
22using Test
33using 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
56using LinearAlgebra
67using Interpolations
78using 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