@@ -131,12 +131,16 @@ end
131131# Now we will test the local stability measures in `StabilityMeasuresAccumulator` in a
132132# linear system.
133133function linear_evolution (z, p, n)
134- A = [- 0.5 0.0 ; 0.0 - 0.5 ] # Linear transformation matrix
134+ if p[1 ] < 0.0
135+ A = [1.0 0.0 ; 0.0 1.0 ] # Linear transformation matrix
136+ else
137+ A = [- 0.5 0.0 ; 0.0 - 0.5 ] # Linear transformation matrix
138+ end
135139 return SVector (A * [z[1 ], z[2 ]]. .. ) # Convert matrix multiplication result to SVector
136140end
137141
138142# Create the dynamical system
139- dynamics = CoupledODEs (linear_evolution, [1.0 , 1.0 ], [0 .0 ])
143+ dynamics = CoupledODEs (linear_evolution, [1.0 , 1.0 ], [1 .0 ])
140144
141145# Define a grid for initial conditions
142146grid = ([- 1.0 , - 0.1 , 0.3 , 1.0 ], [- 1.0 , - 0.3 , 0.1 , 1.0 ])
@@ -171,6 +175,41 @@ results_expected = Dict(
171175 end
172176end
173177
178+ # Now we test the continuation of local stability measures using the linear map.
179+ pcurve_local = [[1 => p] for p in [- 1.0 , 1.0 ]]
180+ attractors_cont_local = [
181+ Dict (1 => StateSpaceSet ([SVector (0.0 , 0.0 )])),
182+ Dict (1 => StateSpaceSet ([SVector (0.0 , 0.0 )]))
183+ ]
184+
185+ proximity_mapper_options_local = (
186+ Ttr= 0 , stop_at_Δt = false , horizon_limit = 1e2 , consecutive_lost_steps = 10000
187+ )
188+ measures_cont_local = stability_measures_along_continuation (
189+ dynamics, attractors_cont_local, pcurve_local, ics_from_grid (grid), ε= 0.1 , finite_time= 0.5 ,
190+ proximity_mapper_options = proximity_mapper_options_local
191+ )
192+
193+ measures_cont_local_expected = Dict (
194+ " characteristic_return_time" => [Dict (1 => Inf , - 1 => NaN ), Dict (1 => 2.0 , - 1 => NaN )],
195+ " reactivity" => [Dict (1 => 1.0 , - 1 => NaN ), Dict (1 => - 0.5 , - 1 => NaN )],
196+ " maximal_amplification" => [Dict (1 => Inf , - 1 => NaN ), Dict (1 => 1.0 , - 1 => NaN )],
197+ " maximal_amplification_time" => [Dict (1 => Inf , - 1 => NaN ), Dict (1 => 0.0 , - 1 => NaN )]
198+ )
199+ @testset " Local Stability Measures Continuation" begin
200+ # Validate the results
201+ for (key, value) in measures_cont_local_expected
202+ @test key in keys (measures_cont_local)
203+ for k in [1 , 2 ]
204+ @test isapprox (
205+ sort (collect (values (value[k]))),
206+ sort (collect (values (measures_cont_local[key][k]))),
207+ atol = 1e-5 ,
208+ nans = true ,
209+ )
210+ end
211+ end
212+ end
174213
175214@testset " Discrete time" begin
176215 # For these parameters the map has 1 fixed point and one period 3 orbit.
0 commit comments