110110 @test isapprox (alpha, expected_alpha)
111111 @test isapprox (rel_vel, relative_velocity)
112112 end
113+
114+ # Generate mock polar data
115+ alphas = - 10 : 1 : 25
116+ n_points = length (alphas)
117+ polar_data = zeros (n_points, 4 )
118+
119+ # Fill polar data with realistic values
120+ for (i, alpha) in enumerate (alphas)
121+ cd = 0.015 + 0.015 * abs (alpha/ 10 )^ 1.5 # Drag increases with angle
122+ cl = 0.1 * alpha + 0.01 * alpha^ 2 * exp (- alpha/ 20 ) # Lift with stall behavior
123+ cm = - 0.02 * alpha # Linear pitching moment
124+ polar_data[i,:] = [alpha, cd, cl, cm]
125+ end
126+
127+ # Create two sections with slightly different polar data
128+ section1 = Section ([0.0 , 0.0 , 0.0 ], [1.0 , 0.0 , 0.0 ], (" polar_data" , polar_data))
129+ section2 = Section ([0.0 , 10.0 , 0.0 ], [1.0 , 10.0 , 0.0 ], (" polar_data" , polar_data * 1.1 ))
130+
131+ # Create panel
132+ panel = create_panel (section1, section2)
133+
134+ @testset " Panel Polar Data Initialization" begin
135+ # Test if panel has polar data
136+ @test hasattr (panel, :panel_polar_data )
137+ @test ! isnothing (panel. panel_polar_data)
138+ @test size (panel. panel_polar_data) == size (polar_data)
139+
140+ # Test if panel polar data is correctly averaged
141+ expected_data = (polar_data + polar_data * 1.1 ) / 2
142+ @test isapprox (panel. panel_polar_data, expected_data, rtol= 1e-5 )
143+ end
144+
145+ @testset " Coefficient Interpolation" begin
146+ test_alphas = [- 5.0 , 0.0 , 5.0 , 10.0 ]
147+ for alpha in test_alphas
148+ # Calculate coefficients using panel methods
149+ alpha_rad = deg2rad (alpha)
150+ cl = panel. calculate_cl (alpha_rad)
151+ cd, cm = panel. calculate_cd_cm (alpha_rad)
152+
153+ # Calculate expected values through interpolation
154+ expected_cl = linear_interpolate (polar_data[:,1 ], polar_data[:,3 ], [alpha])[1 ]
155+ expected_cd = linear_interpolate (polar_data[:,1 ], polar_data[:,2 ], [alpha])[1 ]
156+ expected_cm = linear_interpolate (polar_data[:,1 ], polar_data[:,4 ], [alpha])[1 ]
157+
158+ # Average with slightly different data (1.1 factor)
159+ expected_cl = (expected_cl + 1.1 * expected_cl) / 2
160+ expected_cd = (expected_cd + 1.1 * expected_cd) / 2
161+ expected_cm = (expected_cm + 1.1 * expected_cm) / 2
162+
163+ @test isapprox (cl, expected_cl, rtol= 1e-5 )
164+ @test isapprox (cd, expected_cd, rtol= 1e-5 )
165+ @test isapprox (cm, expected_cm, rtol= 1e-5 )
166+ end
167+ end
113168end
0 commit comments