7070 delta_idxs= 11 : 14 ,
7171 moment_frac= 0.1
7272 )
73+
74+ coeff_jac, coeff_lin_res = VortexStepMethod. linearize (
75+ solver,
76+ body_aero,
77+ base_inputs;
78+ theta_idxs= 1 : 4 ,
79+ va_idxs= 5 : 7 ,
80+ omega_idxs= 8 : 10 ,
81+ delta_idxs= 11 : 14 ,
82+ moment_frac= 0.1 ,
83+ aero_coeffs= true
84+ )
7385
7486 # Verify that linearization results match nonlinear results at operating point
7587 baseline_res = VortexStepMethod. solve! (solver, body_aero; log= false )
7688 baseline_res = [solver. sol. force; solver. sol. moment; solver. sol. group_moment_dist]
89+ coeff_baseline_res = [solver. sol. force_coeffs; solver. sol. moment_coeffs; solver. sol. group_moment_coeff_dist]
7790 @test baseline_res ≈ lin_res
91+ @test coeff_baseline_res ≈ coeff_lin_res
7892
7993 # Define test cases
8094 test_cases = [
88102 for (input_name, indices, magnitudes) in test_cases
89103 @testset " Input: $input_name " begin
90104 max_error_ratio = 0.0
105+ coeff_max_error_ratio = 0.0
91106
92107 # Select one index at a time for focused testing
93108 for idx in indices
@@ -128,18 +143,25 @@ end
128143 # Get nonlinear solution
129144 nonlin_res = VortexStepMethod. solve! (solver, body_aero, nothing ; log= false )
130145 nonlin_res = [solver. sol. force; solver. sol. moment; solver. sol. group_moment_dist]
146+ coeff_nonlin_res = [solver. sol. force_coeffs; solver. sol. moment_coeffs; solver. sol. group_moment_coeff_dist]
131147 @test nonlin_res ≉ baseline_res
148+ @test coeff_nonlin_res ≉ baseline_res
132149
133150 # Compute linearized prediction
134151 lin_prediction = lin_res + jac * perturbation
152+ coeff_lin_prediction = coeff_lin_res + coeff_jac * perturbation
135153
136154 # Calculate error ratio for this case
137155 prediction_error = norm (lin_prediction - nonlin_res)
138156 baseline_difference = norm (baseline_res - nonlin_res)
139157 error_ratio = prediction_error / baseline_difference
158+ coeff_prediction_error = norm (coeff_lin_prediction - coeff_nonlin_res)
159+ coeff_baseline_difference = norm (coeff_baseline_res - coeff_nonlin_res)
160+ coeff_error_ratio = coeff_prediction_error / coeff_baseline_difference
140161
141162 # Update max error ratio
142163 max_error_ratio = max (max_error_ratio, error_ratio)
164+ coeff_max_error_ratio = max (coeff_max_error_ratio, coeff_error_ratio)
143165
144166 # For small perturbations, test that error ratio is small
145167 if idx == first (indices) && mag == first (magnitudes)
149171 end
150172
151173 @info " Max error ratio for $input_name : $max_error_ratio "
174+ @info " Max coeff error ratio for $input_name : $coeff_max_error_ratio "
152175 end
153176 end
154177
275298 end
276299 end
277300 end
278- end
301+ end
0 commit comments