@@ -29,4 +29,152 @@ using Test
2929 rm (settings_file; force= true )
3030 end
3131 end
32+
33+ @testset " Solver with n_groups=0" begin
34+ # Test that solver works correctly when n_groups=0 (no group functionality)
35+ settings_file = create_temp_wing_settings (" solver" , " solver_test_wing.yaml" ;
36+ alpha= 5.0 , beta= 0.0 , wind_speed= 10.0 , n_groups= 0 )
37+
38+ try
39+ settings = VSMSettings (settings_file)
40+ wing = Wing (settings)
41+ @test wing. n_groups == 0
42+
43+ body_aero = BodyAerodynamics ([wing])
44+ solver = Solver (body_aero, settings)
45+
46+ # Verify solver has zero groups
47+ @test length (solver. sol. group_moment_dist) == 0
48+ @test length (solver. sol. group_moment_coeff_dist) == 0
49+
50+ # Test that solve! works without errors
51+ va = [10.0 , 0.0 , 0.0 ]
52+ set_va! (body_aero, va)
53+ sol = solve! (solver, body_aero)
54+
55+ @test sol isa VSMSolution
56+ @test sol. solver_status == SUCCESS
57+
58+ # Verify that group moments are empty
59+ @test length (sol. group_moment_dist) == 0
60+ @test length (sol. group_moment_coeff_dist) == 0
61+
62+ # But force and moment should still be computed
63+ @test ! all (sol. force .== 0.0 )
64+ @test norm (sol. force) > 0
65+
66+ finally
67+ rm (settings_file; force= true )
68+ end
69+ end
70+
71+ @testset " Linearize with n_groups=0" begin
72+ # Test that linearize works correctly when n_groups=0
73+ settings_file = create_temp_wing_settings (" solver" , " solver_test_wing.yaml" ;
74+ alpha= 5.0 , beta= 0.0 , wind_speed= 10.0 , n_groups= 0 , n_panels= 4 )
75+
76+ try
77+ settings = VSMSettings (settings_file)
78+ wing = Wing (settings)
79+ @test wing. n_groups == 0
80+
81+ body_aero = BodyAerodynamics ([wing])
82+ solver = Solver (body_aero, settings)
83+
84+ # Set velocity
85+ va = [10.0 , 0.0 , 0.0 ]
86+ set_va! (body_aero, va)
87+
88+ # Test linearize with only velocity (no theta or delta since n_groups=0)
89+ y = va # Only velocity in input vector
90+ jac, results = VortexStepMethod. linearize (
91+ solver,
92+ body_aero,
93+ y;
94+ theta_idxs= nothing ,
95+ delta_idxs= nothing ,
96+ va_idxs= 1 : 3 ,
97+ omega_idxs= nothing
98+ )
99+
100+ # Results should only have 6 elements (force + moment, no group moments)
101+ @test length (results) == 6
102+ @test size (jac) == (6 , 3 ) # 6 outputs, 3 inputs (vx, vy, vz)
103+
104+ # Verify forces are non-zero
105+ @test norm (results[1 : 3 ]) > 0
106+
107+ # Test that using theta_idxs with n_groups=0 throws an error
108+ @test_throws ArgumentError VortexStepMethod. linearize (
109+ solver,
110+ body_aero,
111+ [0.0 , 10.0 , 0.0 , 0.0 ]; # Invalid: trying to use theta
112+ theta_idxs= 1 : 1 ,
113+ va_idxs= 2 : 4
114+ )
115+
116+ # Test that using delta_idxs with n_groups=0 throws an error
117+ @test_throws ArgumentError VortexStepMethod. linearize (
118+ solver,
119+ body_aero,
120+ [0.0 , 10.0 , 0.0 , 0.0 ]; # Invalid: trying to use delta
121+ delta_idxs= 1 : 1 ,
122+ va_idxs= 2 : 4
123+ )
124+
125+ finally
126+ rm (settings_file; force= true )
127+ end
128+ end
129+
130+ @testset " Linearize theta_idxs validation" begin
131+ # Test that theta_idxs length must match n_groups
132+ settings_file = create_temp_wing_settings (" solver" , " solver_test_wing.yaml" ;
133+ alpha= 5.0 , beta= 0.0 , wind_speed= 10.0 , n_groups= 2 , n_panels= 4 )
134+
135+ try
136+ settings = VSMSettings (settings_file)
137+ wing = Wing (settings)
138+ @test wing. n_groups == 2
139+
140+ body_aero = BodyAerodynamics ([wing])
141+ solver = Solver (body_aero, settings)
142+
143+ va = [10.0 , 0.0 , 0.0 ]
144+ set_va! (body_aero, va)
145+
146+ # Test with correct number of theta angles (2)
147+ y_correct = [0.0 , 0.0 , 10.0 , 0.0 , 0.0 ] # 2 theta + 3 va
148+ jac, results = VortexStepMethod. linearize (
149+ solver,
150+ body_aero,
151+ y_correct;
152+ theta_idxs= 1 : 2 ,
153+ va_idxs= 3 : 5
154+ )
155+ @test size (jac, 1 ) == 8 # 6 + 2 group moments
156+
157+ # Test with wrong number of theta angles (should throw error)
158+ y_wrong = [0.0 , 0.0 , 0.0 , 0.0 , 10.0 , 0.0 , 0.0 ] # 4 theta + 3 va
159+ @test_throws ArgumentError VortexStepMethod. linearize (
160+ solver,
161+ body_aero,
162+ y_wrong;
163+ theta_idxs= 1 : 4 , # Wrong: 4 angles but only 2 groups
164+ va_idxs= 5 : 7
165+ )
166+
167+ # Test with wrong number of delta angles
168+ @test_throws ArgumentError VortexStepMethod. linearize (
169+ solver,
170+ body_aero,
171+ y_wrong;
172+ delta_idxs= 1 : 4 , # Wrong: 4 angles but only 2 groups
173+ va_idxs= 5 : 7
174+ )
175+
176+ finally
177+ rm (settings_file; force= true )
178+ end
179+ end
32180end
0 commit comments