@@ -513,15 +513,23 @@ function solve_wings(wings)
513513end
514514
515515"""
516- linearize_wings(wings; kwargs... )
516+ wing_pair(section_y, n_panels, offset )
517517
518- `linearize` at zero twist and deflection of the body [`solve_wings`](@ref) builds from
519- `wings`, over the twist and the deflection of every unrefined section, then the inflow
520- and the angular rate.
518+ Two `inviscid_wing`s of `n_panels` panels, the second shifted by `-offset` [m] in y.
521519"""
522- function linearize_wings (wings; kwargs... )
523- n_sections = sum (wing -> wing. n_unrefined_sections, wings)
524- body_aero = BodyAerodynamics (wings; va= [10.0 , 0.0 , 1.0 ])
520+ function wing_pair (section_y, n_panels, offset)
521+ return [inviscid_wing (section_y; n_panels),
522+ inviscid_wing (section_y .- offset; n_panels)]
523+ end
524+
525+ """
526+ linearize_body(body_aero; kwargs...)
527+
528+ `linearize` of `body_aero` at zero twist and deflection over the twist and the deflection of
529+ every unrefined section, then the inflow and the angular rate.
530+ """
531+ function linearize_body (body_aero; kwargs... )
532+ n_sections = sum (wing -> wing. n_unrefined_sections, body_aero. wings)
525533 solver = Solver (body_aero; use_gamma_prev= false , rtol= 1e-10 )
526534 y0 = [zeros (2 n_sections); body_aero. va; zeros (3 )]
527535 return VortexStepMethod. linearize (solver, body_aero, y0;
538546 @test single. solver_status == FEASIBLE
539547
540548 @testset " wings far apart each act as the isolated wing" begin
541- wings = [inviscid_wing (section_y; n_panels),
542- inviscid_wing (section_y .- 1e4 ; n_panels)]
543- body_aero, sol = solve_wings (wings)
549+ body_aero, sol = solve_wings (wing_pair (section_y, n_panels, 1e4 ))
544550
545551 @test length (body_aero. panels) == 2 n_panels
546552 @test sol. solver_status == FEASIBLE
552558 end
553559
554560 @testset " wings one chord apart induce on each other" begin
555- wings = [inviscid_wing (section_y; n_panels),
556- inviscid_wing (section_y .- (span + 1.0 ); n_panels)]
557- _, sol = solve_wings (wings)
561+ _, sol = solve_wings (wing_pair (section_y, n_panels, span + 1.0 ))
558562 gamma = sol. gamma_distribution
559563
560564 @test sol. solver_status == FEASIBLE
@@ -563,31 +567,30 @@ end
563567 @test sol. force[3 ] > 2 single. force[3 ]
564568 end
565569
566- n_sections = 2 length (section_y)
570+ n_wing_sections = length (section_y)
567571 @testset " linearize: theta of each wing moves that wing's sections" begin
568- wings = [ inviscid_wing ( section_y; n_panels),
569- inviscid_wing (section_y .- 1e4 ; n_panels)]
570- jac, _, converged = linearize_wings (wings)
571- wing_rows = ( 7 : 6 + length (section_y), 7 + length (section_y) : 6 + n_sections)
572- wing_columns = ( 1 : length (section_y), length (section_y) + 1 : n_sections)
572+ body_aero, _ = solve_wings ( wing_pair ( section_y, n_panels, 1e4 ))
573+ jac, _, converged = linearize_body (body_aero)
574+ first_sections = 1 : n_wing_sections
575+ second_sections = n_wing_sections + 1 : 2 n_wing_sections
576+ own_first = jac[ 6 .+ first_sections, first_sections]
573577
574578 @test converged
575- @test norm (jac[wing_rows[ 1 ], wing_columns[ 1 ]] ) > 0
576- @test jac[wing_rows[ 2 ], wing_columns[ 2 ]] ≈ jac[wing_rows[ 1 ], wing_columns[ 1 ]] rtol= 1e-4
577- @test norm (jac[wing_rows[ 1 ], wing_columns[ 2 ]] ) < 1e-4 norm (jac[wing_rows[ 1 ], wing_columns[ 1 ]] )
578- @test norm (jac[wing_rows[ 2 ], wing_columns[ 1 ]] ) < 1e-4 norm (jac[wing_rows[ 1 ], wing_columns[ 1 ]] )
579+ @test norm (own_first ) > 0
580+ @test jac[6 .+ second_sections, second_sections] ≈ own_first rtol= 1e-4
581+ @test norm (jac[6 .+ first_sections, second_sections] ) < 1e-4 norm (own_first )
582+ @test norm (jac[6 .+ second_sections, first_sections] ) < 1e-4 norm (own_first )
579583 end
580584
581585 @testset " linearize: AutoForwardDiff matches AutoFiniteDiff" begin
582- wings = [inviscid_wing (section_y; n_panels),
583- inviscid_wing (section_y .- (span + 1.0 ); n_panels)]
584- jac_fwd, _, fwd_converged = linearize_wings (wings)
585- jac_fd, _, fd_converged = linearize_wings (wings; backend= nothing ,
586+ body_aero, _ = solve_wings (wing_pair (section_y, n_panels, span + 1.0 ))
587+ jac_fwd, _, fwd_converged = linearize_body (body_aero)
588+ jac_fd, _, fd_converged = linearize_body (body_aero; backend= nothing ,
586589 fd_absstep= 1e-6 , fd_relstep= 1e-6 )
587590
588591 @test fwd_converged
589592 @test fd_converged
590- @test norm (jac_fwd[:, 1 : n_sections ]) > 0
593+ @test norm (jac_fwd[:, 1 : 2 n_wing_sections ]) > 0
591594 @test jac_fwd ≈ jac_fd rtol= 1e-4
592595 end
593596end
0 commit comments