-
Notifications
You must be signed in to change notification settings - Fork 0
Fix bug in untested linearize branch #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1044,8 +1044,9 @@ function linearize(solver::Solver, body_aero::BodyAerodynamics, y::Vector{T}; | |||||||||
| throw(ArgumentError("Cannot use theta_idxs or delta_idxs when wing has no unrefined sections")) | ||||||||||
| end | ||||||||||
|
|
||||||||||
| init_va = body_aero.cache[1][body_aero.va] | ||||||||||
| init_va .= body_aero.va | ||||||||||
| init_va = body_aero.cache[1][body_aero._va] | ||||||||||
| init_va .= body_aero._va | ||||||||||
| init_omega = copy(body_aero.omega) | ||||||||||
| last_theta_ref = Ref{Vector{T}}(Vector{T}(undef, 0)) | ||||||||||
| if !isnothing(theta_idxs) | ||||||||||
| @views last_theta_ref[] = body_aero.cache[2][y[theta_idxs]] | ||||||||||
|
|
@@ -1085,15 +1086,10 @@ function linearize(solver::Solver, body_aero::BodyAerodynamics, y::Vector{T}; | |||||||||
| end | ||||||||||
| end | ||||||||||
|
|
||||||||||
| if !isnothing(va_idxs) && isnothing(omega_idxs) | ||||||||||
| set_va!(body_aero, y[va_idxs]) | ||||||||||
| elseif !isnothing(va_idxs) && !isnothing(omega_idxs) | ||||||||||
| set_va!(body_aero, y[va_idxs], y[omega_idxs]) | ||||||||||
| elseif isnothing(va_idxs) && !isnothing(omega_idxs) | ||||||||||
| set_va!(body_aero, init_va, y[omega_idxs]) | ||||||||||
| else | ||||||||||
| set_va!(body_aero, init_va) | ||||||||||
| end | ||||||||||
| va = isnothing(va_idxs) ? init_va : y[va_idxs] | ||||||||||
| om = isnothing(omega_idxs) ? init_omega : | ||||||||||
|
Comment on lines
+1089
to
+1090
|
||||||||||
| va = isnothing(va_idxs) ? init_va : y[va_idxs] | |
| om = isnothing(omega_idxs) ? init_omega : | |
| @views va = isnothing(va_idxs) ? init_va : y[va_idxs] | |
| @views om = isnothing(omega_idxs) ? init_omega : |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,10 +36,10 @@ end | |
|
|
||
| @testset "Nonlinear vs Linear - Comprehensive Input Testing" begin | ||
| # Initialize with base parameters | ||
| va = [15.0, 0.0, 0.0] | ||
| theta = zeros(4) | ||
| delta = zeros(4) | ||
| omega = zeros(3) | ||
| va = [15.0, 1.0, 0.5] | ||
| theta = deg2rad.([2.0, 1.0, -1.0, -2.0]) | ||
| delta = deg2rad.([1.0, 0.5, -0.5, -1.0]) | ||
| omega = [0.0, 0.1, 0.0] | ||
|
|
||
| # Define perturbation magnitudes | ||
| dva_magnitudes = [0.01, 0.01, 0.01] # Velocity perturbations (m/s) | ||
|
|
@@ -123,7 +123,7 @@ end | |
| reset_va = copy(va) | ||
| reset_theta = copy(theta) | ||
| reset_delta = copy(delta) | ||
| reset_omega = zeros(3) | ||
| reset_omega = copy(omega) | ||
|
|
||
| # Apply the perturbation to the nonlinear model | ||
| if input_name == "va" | ||
|
|
@@ -133,7 +133,7 @@ end | |
| elseif input_name == "delta" | ||
| reset_delta = delta + perturbation[11:14] | ||
| elseif input_name == "omega" | ||
| reset_omega = perturbation[8:10] | ||
| reset_omega = omega + perturbation[8:10] | ||
| else | ||
| throw(ArgumentError()) | ||
| end | ||
|
|
@@ -302,8 +302,8 @@ end | |
| @info "$combo_name error metrics" prediction_error baseline_difference error_ratio | ||
|
|
||
| # Validate the prediction | ||
| @test lin_prediction ≈ nonlin_res rtol=0.01 atol=1e-3 | ||
| @test error_ratio < 0.005 | ||
| @test lin_prediction ≈ nonlin_res rtol=0.05 atol=1e-3 | ||
| @test error_ratio < 0.05 | ||
|
Comment on lines
+305
to
+306
|
||
| end | ||
| end | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_distributed_vais now always set tofalsein the(va, omega)overload, even whenomegainduces per-panel velocity variation. Sincegetproperty(::BodyAerodynamics, :va)uses this flag to decide whether.vais well-defined, it would help to clarify (in theset_va!docstring and/or the:vaerror message) thathas_distributed_vaonly refers to externally supplied per-panel inflow (matrix input), not rotation-induced variation.