I wish to detect the existence of a periodic orbit (limit cycle). For example, the test should return FALSE (i.e. it should fail) for the left (m = 0.35) and return TRUE for the right (m = 0.3) in the following toy model.
sys[m_] := {
x'[t] == x[t] - 0.5 x[t]^2 - x[t] y[t] (x[t] - 1) / (x[t]^2 - 1),
y'[t] == -m y[t] + x[t] y[t] (x[t] - 1) / (x[t]^2 - 1),
x[0] == 0.1,
y[0] == 0.1}
T = 500;
m = 0.35;
sol = First[NDSolve[{sys[m]}, {x, y}, {t, 0, T}]];
p = Plot[Evaluate[{x[t], y[t]} /. sol], {t, 0, T}];
m = 0.3;
sol2 = First[NDSolve[{sys[m]}, {x, y}, {t, 0, T}]];
p2 = Plot[Evaluate[{x[t], y[t]} /. sol2], {t, 0, T}];
GraphicsRow[{p, p2}]
Note that I am not interested in performing local stability analysis on the system (with which the Hopf bifurcation of the above toy model could be discerned), but rather wish to assess the existence of an orbit from the numerical solution itself.
It seems that using a Poincaré section and WhenEvent is the way to go, but I have not figured out a way to implement it that is robust to short transients (when x'[t]==0 is true for all t in the evaluated time period, an empty solution is returned) or very long transients, as demonstrated in the following by changing the period of time (Tstart to Tend) that is assessed:
test[m_] :=
Module[{res},
res = Reap[nd[{m}] =
NDSolve[{sys[m],
WhenEvent[x'[t] == 0 && t > Tstart,
Sow[{m, Round[y[t], 10^-5]}]]},
{x[t], y[t]},
{t, 0, Tend},
MaxSteps -> \[Infinity]]][[-1, 1]];
CountDistinct[res] == 2
]
(* "Correct" inference *)
Tstart = 4500;
Tend = 5000;
test[0.35]
test[0.3]
Out[2916]= False
Out[2917]= True
(* False negative for m=0.3; still in transient phase *)
Tstart = 450;
Tend = 500;
test[0.35]
test[0.3]
Out[2920]= False
Out[2921]= False
(* non-existent part for m=0.35 when past transient phase *)
Tstart = 45000;
Tend = 50000;
test[0.35]
test[0.3]
During evaluation of In[2922]:= Part::partw: Part 1 of {} does not exist.
During evaluation of In[2922]:= Part::partw: Part 1 of {} does not exist.
Out[2924]= False
Out[2925]= True
I have not managed to make sense of How to locate the position of a periodic orbit and Locating periodic orbits with Mathematica.








gz[[1]] < Tol && 1 < (tp /. gz[[2]]) < MaxWin, whereTolis my desired tolerated distance between the start and end of an orbit andMaxWinis the longest suspected period. – user12734 Jun 16 '23 at 15:39