11using ModelingToolkitBase, ModelingToolkitStandardLibrary. Blocks, ControlSystemsBase
22using ModelingToolkitStandardLibrary. Mechanical. Rotational
33using ModelingToolkitStandardLibrary. Blocks
4+ using SymbolicIndexingInterface
45using OrdinaryDiffEq, LinearAlgebra
56using Test
67using ModelingToolkitBase: t_nounits as t, D_nounits as D, AnalysisPoint, AbstractSystem
@@ -618,6 +619,16 @@ if @isdefined(ModelingToolkit)
618619 @test SciMLBase. successful_retcode (solve (prob, Rodas5P ()))
619620 matrices_normal, _ = get_sensitivity (sys_normal, sys_normal. normal_inner. ap)
620621
622+ function compare_matrices (reference, value)
623+ @assert size (reference. A) == (2 , 2 ) " This testing function is only valid for `2x2` systems"
624+ @test isequal (reference. C, value. C) || isequal (reverse (reference. C), value. C)
625+ colorder = isequal (reference. C, value. C) ? [1 , 2 ] : [2 , 1 ]
626+ @test isequal (reference. B, value. B) || isequal (reverse (reference. B), value. B)
627+ roworder = isequal (reference. B, value. B) ? [1 , 2 ] : [2 , 1 ]
628+ @test isequal (reference. D, value. D)
629+ @test isequal (reference. A[roworder, colorder], value. A)
630+ end
631+
621632 @testset " Analysis point overriding part of connection - normal connect" begin
622633 @named F1 = FirstOrder (k = 1 , T = 1 )
623634 @named F2 = FirstOrder (k = 1 , T = 1 )
@@ -643,7 +654,7 @@ if @isdefined(ModelingToolkit)
643654 @test SciMLBase. successful_retcode (solve (prob, Rodas5P ()))
644655
645656 matrices, _ = get_sensitivity (sys, sys. ap)
646- @test matrices == matrices_normal
657+ compare_matrices (matrices_normal, matrices)
647658 end
648659
649660 @testset " Analysis point overriding part of connection - variable connect" begin
@@ -671,7 +682,7 @@ if @isdefined(ModelingToolkit)
671682 @test SciMLBase. successful_retcode (solve (prob, Rodas5P ()))
672683
673684 matrices, _ = get_sensitivity (sys, sys. ap)
674- @test matrices == matrices_normal
685+ compare_matrices (matrices_normal, matrices)
675686 end
676687
677688 @testset " Analysis point overriding part of connection - mixed connect" begin
@@ -699,7 +710,7 @@ if @isdefined(ModelingToolkit)
699710 @test SciMLBase. successful_retcode (solve (prob, Rodas5P ()))
700711
701712 matrices, _ = get_sensitivity (sys, sys. ap)
702- @test matrices == matrices_normal
713+ compare_matrices (matrices_normal, matrices)
703714 end
704715
705716 @testset " Ignored analysis points only affect relevant connection sets" begin
0 commit comments