I'm trying to reproduce the Example 3.1 from the book Applied Nonlinear Dynamics: Finding periodic solutions and bifurcation analysis. However, I stocked. Here is the code:
importPyDSToolasdstimportmatplotlib.pyplotaspltfromPyDSTool.Toolboximportphaseplaneaspppars={'mu':1,'alpha':-1,'omega':1,'beta':1}icdict={'x':0.5,'y':0.1}xstr='mu*x - omega*y + (alpha*x - beta*y)*(x*x + y*y)'ystr='omega*x + mu*y + (beta*x + alpha*y)*(x*x + y*y)'DSargs=dst.args(name='2D-System')DSargs.pars=parsDSargs.varspecs={'x':xstr,'y':ystr}DSargs.ics=icdictDSargs.tdomain=[0,15]# set the range of integration.DSargs.xdomain={'x':[-3,3],'y':[-3,3]}DSargs.pdomain={'mu':[-1,1]}DSargs.algparams={'max_pts':3000,'init_step':0.02,'stiff':True}ode=dst.Generator.Vode_ODEsystem(DSargs)traj=ode.compute('polarization')pts=traj.sample(dt=0.01)plt.plot(pts['t'],pts['x'])plt.xlabel('time')# Axes labelsplt.ylabel('x')plt.show()plt.plot(pts['x'],pts['y'])plt.xlabel('x')# Axes labelsplt.ylabel('y')plt.show()# plot vector field, using a scale exponent to ensure arrows are well spaced# and sizedpp.plot_PP_vf(ode,'x','y',scale_exp=-1,N=50)plt.show()PyCont=dst.ContClass(ode)PCargs=dst.args(name='EQ1',type='EP-C')PCargs.freepars=['mu']PCargs.StepSize=0.1PCargs.MaxNumPoints=50PCargs.MaxStepSize=2PCargs.MinStepSize=1e-5PCargs.LocBifPoints=['all']PCargs.verbosity=2PCargs.SaveEigen=TruePyCont.newCurve(PCargs)print('Computing curve...')start=dst.clock()PyCont['EQ1'].forward()PyCont['EQ1'].backward()print('done in %.3f seconds!'%(dst.clock()-start))PyCont['EQ1'].display(['mu','y'],stability=True)plt.show()
For mu>=0, I should've observe a Hopf Point, but it doesn't happen. What did I miss?
Also, the other options as 'H-C1' or H-C2' create this error:
Hi Bruno,
have you tried playing with StepSize, MaxStepSize and MinStepSize? Often it is related to the initialization of the tangent vector for continuation. Indeed this is why often, you can run the same continuation with the same parameters and get different results.
Also see if you can play with the different tolerances values. See this post.
Hope this helps.
If not, Rob and the other folks will come out shortly :)
M
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I did what you said and it did not work.
I downloaded the package again. First, it presents a SciPy version error and here I found a solution.
Even overcome these, another error arises:
PyDSTool/PyCont/TestFunc.py", line 381, in __init__
self.data.P = zeros((n*(n-1)/2, n*(n-1)/2), float)
TypeError: 'float' object cannot be interpreted as an integer
I already suppressed the current errors and I did found the Hopf bifurcation point at mu=0 as we can see in Figure_1 (Cheers =D)!!!
I know that, from mu>= 0, the stability jumps to a stable limit cycle (or periodic attractor).
So, I'm did this,
Hi, Bruno. Question: why is your free parameter for the limit cycles alpha? I changed it to mu, the same as the equilibrium point curve, and got the attached diagram. Does this look close to what you are expecting? Also, if you add PCargs.StopAtPoints = 'B' to your equilibrium point curve arguments, the curve will stop at the predetermined boundary points (plus and minus 1).
Hello, guys.
I'm trying to reproduce the Example 3.1 from the book Applied Nonlinear Dynamics: Finding periodic solutions and bifurcation analysis. However, I stocked. Here is the code:
For mu>=0, I should've observe a Hopf Point, but it doesn't happen. What did I miss?
Also, the other options as 'H-C1' or H-C2' create this error:
Any help would be pretty much appreciated.
Thanks.
Hi Bruno,
have you tried playing with
StepSize,MaxStepSizeandMinStepSize? Often it is related to the initialization of the tangent vector for continuation. Indeed this is why often, you can run the same continuation with the same parameters and get different results.Also see if you can play with the different tolerances values. See this post.
Hope this helps.
If not, Rob and the other folks will come out shortly :)
M
Hi, Maurizio.
Yes, I have tried. Also, I checked the suggested post, but still the same result =[
Thanks for your answer.
Bruno.
Hi, Bruno. I think it's the
PCargs.LocBifPoints = ['all']line. I changed it toPCargs.LocBifPoints = 'all'and it worked.Hi, Drew.
I did what you said and it did not work.
I downloaded the package again. First, it presents a SciPy version error and here I found a solution.
Even overcome these, another error arises:
So, I did this:
And then, the previous error arises:
But this error only occurs when I demand Hopf Point (Or Limit Cycle Curve).
Thanks for your help.
Bruno.
Hello, guys.
I already suppressed the current errors and I did found the Hopf bifurcation point at mu=0 as we can see in Figure_1 (Cheers =D)!!!
I know that, from mu>= 0, the stability jumps to a stable limit cycle (or periodic attractor).
So, I'm did this,
and the Figure_2 showed up.
Did I do something wrong? What does "MX1" mean?
I'm already very happy!!!
Thank you, guys =D
Hi, Bruno. Question: why is your free parameter for the limit cycles
alpha? I changed it tomu, the same as the equilibrium point curve, and got the attached diagram. Does this look close to what you are expecting? Also, if you addPCargs.StopAtPoints = 'B'to your equilibrium point curve arguments, the curve will stop at the predetermined boundary points (plus and minus 1).Hi, Drew.
That is it. I used alpha parameter by mistake =/,
Now, I did reproduce the results from literature =D
But, What python version do you, guys, use?
I'm already with SciPy v1.0.0 and Python 3.6.4.
This is probably why some errors popped up to me.
Thank you very much =D