Hello. I am relatively new to PyDSTools. I am unable to capture exactly one limit cycle (one period only) in my dynamical system. The error seems to be at the findApproxPeriod step. But I don't understand where I am going wrong here. I would greatly appreciate your help.
In this case, I think you just didn't give findApproxPeriod a good enough starting condition. You might need to change the tolerances to be more forgiving or do some plots to get a reasonable first estimate that's within the TguessTol you select.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried several things. I raised the guess_tol to 0.5. Does that mean that it checks from 50% to 2 times my first estimate for the period? I also confirmed graphically that the period is around 0.79, so I made that my initial guess. Furthermore I lowered rtol a lot. I still get the the following errors
Did not converge. The endpoint difference at t=0.556904 was:
u1: -1.03114363176e-06
u2: 0.058386355186
v1: -0.0413803050605
v2: -0.0182916301155
with infinity-norm 0.239187 > 0.000050 tolerance.
Try a different starting point,a different test variable, or reduce relative tolerance.
ValueError Traceback (most recent call last)
/home/rehman/Desktop/CMU_Research/Mathematical_Neuroscience/Chapter_3/Two_Variable_WC/TwoVarWC4.py in <module>()
160
161 " I would use exactly one cycle, but the following doesnt work "
--> 162 cycTraj = find_cycle(WC2DS,getlastpoint(traj),0.9,guess_tol=0.5)
163 # the findApproxPeriod function is throwing the following error
164 #ValueError Traceback (most recent call last)</module>
/home/rehman/anaconda3/lib/python3.4/site-packages/PyDSTool-0.90.0-py3.4.egg/PyDSTool/Trajectory.py in findApproxPeriod(traj, t0, t1_guess, T_guess, coordname, ttol, rtol, guess_tol)
1534 "Try a different starting point," +
1535 "a different test variable, or reduce relative tolerance.")
-> 1536 raise ValueError("Did not converge")
The docstring for findApproxPeriod says "guess_tol fraction of T_guess will be checked as a bracketing interval for bisection" so that means that the bisection routine had better find that the sign of the endpoint to initial testpoint difference changes between T_guess - (guess_Tol*T_guess) and T_guess + (guess_Tol*T_guess). You are also changing the tolerance in the wrong direction! A tiny tolerance will only it make convergence less likely. I guess "reduce tolerance" is a poor choice of words, since the idea is to increase the value and reduce the algorithm's fussiness. I should change that in the warning string.
You are only going to find an approximate period with this routine (hence the name), and it only uses simple interpolation, so it might not be surprising that the norm of the difference at its best estimate is as big as 0.239. It probably did converge to that value but your tolerance rejected it. Once you have that point, it might be good enough for improvement by PyCont.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you so much for your quick response and all the help you've given me so far. Your input definitely fixed the issue above, but I ran into another issue.
Although the bifurcation diagram correctly continues the limit cycle over my parameter (se), the continuation is stopped at two LPCs.
I checked the se value at the LPCs (seHigh and seLow) as well as the limit cycles at those points and I discovered that these are actually the locations of two Periodic Doubling (PD) bifurcations.
I know that I should be able to continue the limit cycles beyond those point. I want to be able to extend se from 0 to 1 which I know is possible.
This is also a problem because I also want to track the PD bifurcation in codimension-2 as I vary se and si, but it seems that AUTO isn't recognizing the PD bifurcation point.
I figured out the solution. I just need to nudge the parameter past the LPC point and restart continuation from there. Here is my Code if anyone is interested
Your code was very helpful for me, learning how to work with python. Now I want to do some continuation of limit cycles and examine periodic doubling phenomena. Your last script is giving me only a MX in the figure, the last continuation 'PerDoub' is not working. Is there a problem with my system? I've tried to play around with PCargs.period, but changes have no effect at all. Maybe anyone can help me (please see https://sourceforge.net/p/pydstool/discussion/472291/thread/fdbd34fb/)?
Thanks a lot!
Emil
Last edit: Emil Knut 2016-08-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello. I am relatively new to PyDSTools. I am unable to capture exactly one limit cycle (one period only) in my dynamical system. The error seems to be at the findApproxPeriod step. But I don't understand where I am going wrong here. I would greatly appreciate your help.
I attached my python code for this
I get the following error trail:
ValueError Traceback (most recent call last)
/home/rehman/Desktop/CMU_Research/Mathematical_Neuroscience/Chapter_3/Two_Variable_WC/TwoVarWC2.py in <module>()
71 limCycICs = {'u1':pts['u1'][-1],'u2':pts['u2'][-1],
72 'v1':pts['v1'][-1],'v2':pts['v2'][-1]}
---> 73 cycle = find_cycle(WC2DS,limCycICs,T0,TguessTol=0.01)
74
75 </module>
/home/rehman/Desktop/CMU_Research/Mathematical_Neuroscience/Chapter_3/Two_Variable_WC/TwoVarWC2.py in find_cycle(DS, ICs, Tguess, TguessTol, tinit, disp, threeAxes)
19 t0 = tinit; T0 = Tguess;
20 T = findApproxPeriod(traj, t0, t0+T0, coordname=threeAxes[0], \
---> 21 rtol=0.005, guess_tol=TguessTol);
22 cycle = traj.sample(dt=0.01, tlo=t0, thi=t0+T, precise=True)
23 cycle.indepvararray = cycle.indepvararray.flatten()
/home/rehman/anaconda3/lib/python3.4/site-packages/PyDSTool-0.90.0-py3.4.egg/PyDSTool/Trajectory.py in findApproxPeriod(traj, t0, t1_guess, T_guess, coordname, ttol, rtol, guess_tol)
1514 result = bisect(f, t1_guess-guess_tol(t1_guess-t0),
1515 t1_guess+guess_tol(t1_guess-t0),
-> 1516 xtol=ttol)
1517 except RuntimeError:
1518 raise ValueError("Did not converge for this initial guess")
/home/rehman/anaconda3/lib/python3.4/site-packages/scipy/optimize/zeros.py in bisect(f, a, b, args, xtol, rtol, maxiter, full_output, disp)
223 if rtol < _rtol:
224 raise ValueError("rtol too small (%g < %g)" % (rtol, _rtol))
--> 225 r = _zeros._bisect(f,a,b,xtol,rtol,maxiter,args,full_output,disp)
226 return results_c(full_output, r)
227
ValueError: f(a) and f(b) must have different signs
Thank You,
Rehman Ali
Last edit: Rehman Ali 2015-06-07
Hi Rehman,
In this case, I think you just didn't give findApproxPeriod a good enough starting condition. You might need to change the tolerances to be more forgiving or do some plots to get a reasonable first estimate that's within the TguessTol you select.
Hello Dr. Clewley,
I tried several things. I raised the guess_tol to 0.5. Does that mean that it checks from 50% to 2 times my first estimate for the period? I also confirmed graphically that the period is around 0.79, so I made that my initial guess. Furthermore I lowered rtol a lot. I still get the the following errors
Did not converge. The endpoint difference at t=0.556904 was:
u1: -1.03114363176e-06
u2: 0.058386355186
v1: -0.0413803050605
v2: -0.0182916301155
with infinity-norm 0.239187 > 0.000050 tolerance.
Try a different starting point,a different test variable, or reduce relative tolerance.
ValueError Traceback (most recent call last)
/home/rehman/Desktop/CMU_Research/Mathematical_Neuroscience/Chapter_3/Two_Variable_WC/TwoVarWC4.py in <module>()
160
161 " I would use exactly one cycle, but the following doesnt work "
--> 162 cycTraj = find_cycle(WC2DS,getlastpoint(traj),0.9,guess_tol=0.5)
163 # the findApproxPeriod function is throwing the following error
164 #ValueError Traceback (most recent call last)</module>
/home/rehman/Desktop/CMU_Research/Mathematical_Neuroscience/Chapter_3/Two_Variable_WC/TwoVarWC4.py in find_cycle(DS, ics, T_guess, guess_tol, t_init)
92 t0 = t_init; T0 = T_guess;
93 T = findApproxPeriod(traj, t0, t0+T0, coordname='u1', \
---> 94 rtol=0.00005, guess_tol=guess_tol);
95 cycle = traj.sample(dt=0.01, tlo=t0, thi=t0+T, precise=True)
96 cycle.indepvararray = cycle.indepvararray.flatten()
/home/rehman/anaconda3/lib/python3.4/site-packages/PyDSTool-0.90.0-py3.4.egg/PyDSTool/Trajectory.py in findApproxPeriod(traj, t0, t1_guess, T_guess, coordname, ttol, rtol, guess_tol)
1534 "Try a different starting point," +
1535 "a different test variable, or reduce relative tolerance.")
-> 1536 raise ValueError("Did not converge")
ValueError: Did not converge
The docstring for
findApproxPeriod
says "guess_tol fraction of T_guess will be checked as a bracketing interval for bisection" so that means that the bisection routine had better find that the sign of the endpoint to initial testpoint difference changes betweenT_guess - (guess_Tol*T_guess)
andT_guess + (guess_Tol*T_guess)
. You are also changing the tolerance in the wrong direction! A tiny tolerance will only it make convergence less likely. I guess "reduce tolerance" is a poor choice of words, since the idea is to increase the value and reduce the algorithm's fussiness. I should change that in the warning string.You are only going to find an approximate period with this routine (hence the name), and it only uses simple interpolation, so it might not be surprising that the norm of the difference at its best estimate is as big as 0.239. It probably did converge to that value but your tolerance rejected it. Once you have that point, it might be good enough for improvement by PyCont.
Hello Dr. Clewley,
Thank you so much for your quick response and all the help you've given me so far. Your input definitely fixed the issue above, but I ran into another issue.
Although the bifurcation diagram correctly continues the limit cycle over my parameter (se), the continuation is stopped at two LPCs.
I checked the se value at the LPCs (seHigh and seLow) as well as the limit cycles at those points and I discovered that these are actually the locations of two Periodic Doubling (PD) bifurcations.
I know that I should be able to continue the limit cycles beyond those point. I want to be able to extend se from 0 to 1 which I know is possible.
This is also a problem because I also want to track the PD bifurcation in codimension-2 as I vary se and si, but it seems that AUTO isn't recognizing the PD bifurcation point.
Do you know what the issue is here?
Thank You,
Rehman Ali
I figured out the solution. I just need to nudge the parameter past the LPC point and restart continuation from there. Here is my Code if anyone is interested
Hi!
Your code was very helpful for me, learning how to work with python. Now I want to do some continuation of limit cycles and examine periodic doubling phenomena. Your last script is giving me only a MX in the figure, the last continuation 'PerDoub' is not working. Is there a problem with my system? I've tried to play around with PCargs.period, but changes have no effect at all. Maybe anyone can help me (please see https://sourceforge.net/p/pydstool/discussion/472291/thread/fdbd34fb/)?
Thanks a lot!
Emil
Last edit: Emil Knut 2016-08-01