@@ -63,7 +63,7 @@ include("utils.jl")
6363 cd_cm = calculate_cd_cm (panel, alpha[i])
6464 drag[i] = dyn_visc * cd_cm[1 ] * panel. chord
6565 moment[i] = dyn_visc * cd_cm[2 ] * panel. chord^ 2
66- @info " lift: $lift , drag: $drag , moment: $moment "
66+ # @info "lift: $lift, drag: $drag, moment: $moment"
6767 end
6868 Fmag = hcat (lift, drag, moment)
6969
@@ -104,7 +104,6 @@ include("utils.jl")
104104 @test length (results_NEW[" cd_distribution" ]) == length (wing_aero. panels)
105105end
106106
107-
108107@testset " Induction Matrix Creation" begin
109108 # Setup
110109 n_panels = 3
@@ -206,6 +205,149 @@ end
206205 @test isapprox (MatrixU, AIC_x, atol= 1e-8 )
207206 @test isapprox (MatrixV, - AIC_y, atol= 1e-8 )
208207 @test isapprox (MatrixW, AIC_z, atol= 1e-8 )
209- @show MatrixU MatrixV MatrixW
210208 end
211- end
209+ end
210+
211+
212+ @testset " Wing Geometry Creation" begin
213+ function create_geometry (; model= " VSM" , wing_type= " rectangular" , plotting= false , N= 40 )
214+ max_chord = 1.0
215+ span = 17.0
216+ AR = span^ 2 / (π * span * max_chord / 4 )
217+ @debug " AR: $AR "
218+ Umag = 20.0
219+ aoa = 5.7106 * π / 180
220+ Uinf = [cos (aoa), 0.0 , sin (aoa)] .* Umag
221+
222+ coord = if wing_type == " rectangular"
223+ twist = range (- 0.5 , 0.5 , length= N)
224+ beta = range (- 2 , 2 , length= N)
225+ generate_coordinates_rect_wing (
226+ fill (max_chord, N),
227+ span,
228+ twist,
229+ beta,
230+ N,
231+ " lin"
232+ )
233+ elseif wing_type == " curved"
234+ generate_coordinates_curved_wing (
235+ max_chord, span, π/ 4 , 5 , N, " cos"
236+ )
237+ elseif wing_type == " elliptical"
238+ generate_coordinates_el_wing (max_chord, span, N, " cos" )
239+ else
240+ error (" Invalid wing type" )
241+ end
242+
243+ coord_left_to_right = flip_created_coord_in_pairs (deepcopy (coord))
244+ wing = Wing (N; spanwise_panel_distribution= " unchanged" )
245+ for i in 1 : 2 : size (coord_left_to_right, 1 )
246+ add_section! (
247+ wing,
248+ coord_left_to_right[i,:],
249+ coord_left_to_right[i+ 1 ,:],
250+ " inviscid"
251+ )
252+ end
253+ wing_aero = WingAerodynamics ([wing])
254+ set_va! (wing_aero, (Uinf, 0.0 ))
255+
256+ return wing_aero, coord, Uinf, model
257+ end
258+
259+ for model in [" VSM" , " LLT" ]
260+ @debug " model: $model "
261+ for wing_type in [" rectangular" , " curved" , " elliptical" ]
262+ @debug " wing_type: $wing_type "
263+ wing_aero, coord, Uinf, model = create_geometry (
264+ model= model, wing_type= wing_type
265+ )
266+
267+ # Generate geometry
268+ expected_controlpoints, expected_rings, expected_bladepanels,
269+ expected_ringvec, expected_coord_L = create_geometry_general (
270+ coord, Uinf, div (size (coord,1 ), 2 ), " 5fil" , model
271+ )
272+
273+ for i in 1 : length (wing_aero. panels)
274+ @debug " i: $i "
275+ # Handle control points
276+ index_reversed = length (wing_aero. panels) - i + 1
277+ panel = wing_aero. panels[index_reversed]
278+
279+ evaluation_point = if model == " VSM"
280+ panel. control_point
281+ else # LLT
282+ panel. aerodynamic_center
283+ end
284+
285+ @test isapprox (evaluation_point, expected_controlpoints[i][" coordinates" ], atol= 1e-4 )
286+ @test isapprox (panel. chord, expected_controlpoints[i][" chord" ], atol= 1e-4 )
287+ @test isapprox (panel. x_airf, expected_controlpoints[i][" normal" ], atol= 1e-4 )
288+ @test isapprox (panel. y_airf, expected_controlpoints[i][" tangential" ], atol= 1e-4 )
289+ @test isapprox (
290+ hcat (panel. x_airf, panel. y_airf, panel. z_airf),
291+ expected_controlpoints[i][" airf_coord" ],
292+ atol= 1e-4
293+ )
294+
295+ if model == " VSM"
296+ @test isapprox (
297+ panel. aerodynamic_center,
298+ expected_controlpoints[i][" coordinates_aoa" ],
299+ atol= 1e-4
300+ )
301+ end
302+
303+ # Handle rings
304+ expected_ring_i = expected_rings[i]
305+ expected_ring_i_list = [
306+ expected_ring_i[1 ],
307+ expected_ring_i[2 ],
308+ expected_ring_i[3 ],
309+ expected_ring_i[4 ],
310+ expected_ring_i[5 ]
311+ ]
312+
313+ filaments = panel. filaments
314+ filament_list = [
315+ filaments[1 ],
316+ filaments[3 ],
317+ filaments[5 ],
318+ filaments[2 ],
319+ filaments[4 ]
320+ ]
321+
322+ for (j, fil) in enumerate (filament_list)
323+ if j == 1 # bound filaments
324+ @test isapprox (fil. x1, expected_ring_i_list[j][" x1" ], atol= 1e-4 )
325+ @test isapprox (fil. x2, expected_ring_i_list[j][" x2" ], atol= 1e-4 )
326+ elseif j ∈ (2 , 4 ) # trailing filaments
327+ @test isapprox (fil. x1, expected_ring_i_list[j][" x1" ], atol= 1e-4 )
328+ @test isapprox (fil. x2, expected_ring_i_list[j][" x2" ], atol= 1e-4 )
329+ else # semi-infinite filaments
330+ @test isapprox (fil. x1, expected_ring_i_list[j][" x1" ], atol= 1e-4 )
331+ end
332+ end
333+
334+ # Handle bladepanels
335+ exp_bladepanels = expected_bladepanels[i]
336+ @test isapprox (panel. LE_point_2, exp_bladepanels[" p1" ], atol= 1e-4 )
337+ @test isapprox (panel. LE_point_1, exp_bladepanels[" p2" ], atol= 1e-4 )
338+ @test isapprox (panel. TE_point_1, exp_bladepanels[" p3" ], atol= 1e-4 )
339+ @test isapprox (panel. TE_point_2, exp_bladepanels[" p4" ], atol= 1e-4 )
340+
341+ # Handle ringvec
342+ exp_ringvec = expected_ringvec[i]
343+ r0 = panel. bound_point_1 - panel. bound_point_2
344+ r3 = evaluation_point - (panel. bound_point_1 + panel. bound_point_2) / 2
345+ @test isapprox (r0, exp_ringvec[" r0" ], atol= 1e-4 )
346+ @test isapprox (r3, exp_ringvec[" r3" ], atol= 1e-4 )
347+
348+ # Handle coord_L
349+ @test all (isapprox .(panel. aerodynamic_center, expected_coord_L[:, i]))
350+ end
351+ end
352+ end
353+ end
0 commit comments