[关闭]
@wudawufanfan 2016-11-13T06:24:52.000000Z 字数 6311 阅读 549

chapter3.18、3.19、3.20、3.21

未分类

This homework is about the problem of period doubling.


A show of vPython

shiyan.gif

this is the code for simulation

  1. from __future__ import division
  2. from visual import *
  3. from math import *
  4. # add some constants
  5. q=0.5
  6. l=9.8
  7. g=9.8
  8. f=2/3
  9. dt=0.04
  10. theta0=0.2
  11. omega0=0
  12. # add three ceilings
  13. ceil1=box(pos=(-20,5,0),size=(5,0.5,2),material=materials.bricks)
  14. ceil2=box(pos=(0,5,0),size=(5,0.5,2),material=materials.bricks)
  15. ceil3=box(pos=(20,5,0),size=(5,0.5,2),material=materials.bricks)
  16. ball1=sphere(pos=(-20+l*sin(theta0),5-l*cos(theta0),0),radius=1,material=materials.emissive,color=color.red)
  17. ball2=sphere(pos=(l*sin(theta0),5-l*cos(theta0),0),radius=1,material=materials.emissive,color=color.yellow)
  18. ball3=sphere(pos=(20+l*sin(theta0),5-l*cos(theta0),0),radius=1,material=materials.emissive,color=color.green)
  19. ball1.omega=omega0
  20. ball2.omega=omega0
  21. ball3.omega=omega0
  22. ball1.theta=theta0
  23. ball2.theta=theta0
  24. ball3.theta=theta0
  25. ball1.t=0
  26. ball2.t=0
  27. ball3.t=0
  28. ball1.F=0
  29. ball2.F=0.5
  30. ball3.F=1.2
  31. string1=curve(pos=[ceil1.pos,ball1.pos],color=color.red)
  32. string2=curve(pos=[ceil2.pos,ball2.pos],color=color.yellow)
  33. string3=curve(pos=[ceil3.pos,ball3.pos],color=color.green)
  34. po1=arrow(pos=ball1.pos,axis=(10*ball1.omega*cos(ball1.theta),10*ball1.omega*sin(ball1.theta),0),color=color.red)
  35. po2=arrow(pos=ball2.pos,axis=(10*ball2.omega*cos(ball2.theta),10*ball2.omega*sin(ball2.theta),0),color=color.yellow)
  36. po3=arrow(pos=ball3.pos,axis=(10*ball3.omega*cos(ball3.theta),10*ball3.omega*sin(ball3.theta),0),color=color.green)
  37. while True:
  38. rate(100)
  39. ball1.omega=ball1.omega-((g/l)*sin(ball1.theta)+q*ball1.omega-ball1.F*sin(f*ball1.t))*dt
  40. ball2.omega=ball2.omega-((g/l)*sin(ball2.theta)+q*ball2.omega-ball2.F*sin(f*ball2.t))*dt
  41. ball3.omega=ball3.omega-((g/l)*sin(ball3.theta)+q*ball3.omega-ball3.F*sin(f*ball3.t))*dt
  42. angle1_new=ball1.theta+ball1.omega*dt
  43. while angle1_new>pi:
  44. angle1_new-=2*pi
  45. while angle1_new<-pi:
  46. angle1_new+=2*pi
  47. angle2_new=ball2.theta+ball2.omega*dt
  48. while angle2_new>pi:
  49. angle2_new-=2*pi
  50. while angle2_new<-pi:
  51. angle2_new+=2*pi
  52. angle3_new=ball3.theta+ball3.omega*dt
  53. while angle3_new>pi:
  54. angle3_new-=2*pi
  55. while angle3_new<-pi:
  56. angle3_new+=2*pi
  57. ball1.theta=angle1_new
  58. ball2.theta=angle2_new
  59. ball3.theta=angle3_new
  60. ball1.pos=(-20+l*sin(ball1.theta),5-l*cos(ball1.theta),0)
  61. ball2.pos=(l*sin(ball2.theta),5-l*cos(ball2.theta),0)
  62. ball3.pos=(20+l*sin(ball3.theta),5-l*cos(ball3.theta),0)
  63. string1.pos=[ceil1.pos,ball1.pos]
  64. string2.pos=[ceil2.pos,ball2.pos]
  65. string3.pos=[ceil3.pos,ball3.pos]
  66. po1.pos=ball1.pos
  67. po2.pos=ball2.pos
  68. po3.pos=ball3.pos
  69. po1.axis=(10*ball1.omega*cos(ball1.theta),10*ball1.omega*sin(ball1.theta),0)
  70. po2.axis=(10*ball2.omega*cos(ball2.theta),10*ball2.omega*sin(ball2.theta),0)
  71. po3.axis=(10*ball3.omega*cos(ball3.theta),10*ball3.omega*sin(ball3.theta),0)
  72. ball1.t=ball1.t+dt
  73. ball2.t=ball2.t+dt
  74. ball3.t=ball3.t+dt

TEXT

We use the same condition but different driving force
        

  1. import math
  2. import pylab as pl
  3. class harmonic:
  4. def __init__(self, w_0 = 0, theta_0=0.2, time_of_duration =60, time_step = 0.04,g=9.8,length=9.8,q=1/2,F=1.35,D=2/3):
  5. # unit of time is second
  6. self.n_uranium_A = [w_0]
  7. self.n_uranium_B = [theta_0]
  8. self.t = [0]
  9. self.g=g
  10. self.length=length
  11. self.dt = time_step
  12. self.time = time_of_duration
  13. self.nsteps = int(time_of_duration // time_step + 1)
  14. self.q=q
  15. self.F=F
  16. self.D=D
  17. def calculate(self):
  18. for i in range(self.nsteps):
  19. tmpA = self.n_uranium_A[i] -((self.g/self.length)*math.sin(self.n_uranium_B[i])+self.q*self.n_uranium_A[i]-self.F*math.sin(self.D*self.t[i]))*self.dt
  20. tmpB = self.n_uranium_B[i] + self.n_uranium_A[i]*self.dt
  21. self.n_uranium_A.append(tmpA)
  22. self.n_uranium_B.append(tmpB)
  23. self.t.append(self.t[i] + self.dt)
  24. if self.n_uranium_B[i+1]<-math.pi:
  25. self.n_uranium_B[i+1]=self.n_uranium_B[i+1]+2*math.pi
  26. if self.n_uranium_B[i+1]>math.pi:
  27. self.n_uranium_B[i+1]=self.n_uranium_B[i+1]-2*math.pi
  28. else:
  29. pass
  30. def show_results(self):
  31. pl.plot(self.t, self.n_uranium_B,label=' F=1.35')
  32. pl.xlabel('time ($s$)')
  33. pl.ylabel('angle(radians)')
  34. pl.legend(loc='best',frameon = True)
  35. pl.grid(True)
  36. a = harmonic()
  37. a.calculate()
  38. a.show_results()

we find that the period is T,2T,4T
QQ截图20161112150401.jpg
QQ截图20161112150525.jpg
QQ截图20161112150953.jpg
this picture is not good
when we change the time step form 0.04 to 0.01,it tends to good reult
QQ截图20161112150942.jpg
But if the period keeps on doubling,what about the transition to chaos?Our textbook give a way to appreciate how this transition comes about is with what is known as a bifurcation diagram.

  1. from __future__ import division
  2. from math import *
  3. from pylab import *
  4. from numpy import *
  5. # define a function that given amplitude of force, gives angle,avelo and t
  6. def change_amp(F,f):
  7. # define some constants
  8. q = 0.5
  9. l = 9.8
  10. g = 9.8
  11. dt = pi/100
  12. theta0 = 0.2
  13. omega0 = 0
  14. angle = [theta0]
  15. avelo = [omega0]
  16. t = [0]
  17. an=[]
  18. # move the pendulum
  19. while t[-1] <= 1200*pi:
  20. avelo_new = avelo[-1] - ((g/l)*sin(angle[-1]) + q*avelo[-1] - F*sin(f*t[-1]))*dt
  21. avelo.append(avelo_new)
  22. angle_new = angle[-1] + avelo[-1]*dt
  23. while angle_new > pi:
  24. angle_new -= 2*pi
  25. while angle_new < -pi:
  26. angle_new += 2*pi
  27. angle.append(angle_new)
  28. if t[-1]>=900*pi:
  29. if t[-1]%(3*pi)<=dt:
  30. an.append(angle_new)
  31. t_new = t[-1] + dt
  32. t.append(t_new)
  33. return an
  34. ###
  35. fdd_1=list(linspace(1.35,1.5,100))
  36. fd_1=[]
  37. th_1=[]
  38. for i in fdd_1:
  39. points=change_amp(i,2/3)
  40. for j in points:
  41. fd_1.append(i)
  42. th_1.append(j)
  43. ###
  44. ###
  45. scatter(fd_1,th_1,s=10)
  46. grid(True)
  47. xlim(1.35,1.48)
  48. ylim(0,3)
  49. title('f=2/3')
  50. xlabel('FD')
  51. ylabel('theta(radians)')
  52. show()

we have get the bifurcation diagram when the frenquency is 2/3
figure_1.png

use the magnified plot of the diagram,we could estimate the point
at which the transition to period- behaviors take place.
figure_1-1.png
figure_1-2.png
figure_1-3.png
here,I can only distinguish three points,and their corresponding coordinates are 1.41972、1.45455、1.47123
=2.088

Now ,I tend to Poincare sections for the pendulum as it undergoes the period-doubling route to chaos for    
QQ截图20161112151514.jpg
QQ截图20161112151523.jpg
QQ截图20161112151531.jpg
After removing the points corresponding to the initial transient the attractor in the period-1 regime will contain,likewise,the attractor will contain n discrete points if the behavior is period n.
when change the driving force,I find a interesting phenomenon
QQ截图20161112152449.jpg
QQ截图20161112152413.jpg
QQ截图20161112152514.jpg
a small change to force will change the poincare sections a lot

In order to see this phenomenon clearly,we tend to observe bifurcation diagram by change the condition like the drive frequency and damping parameter.
QQ截图20161112153844.jpg
QQ截图20161112155241.jpg
QQ截图20161112155537.jpg
QQ截图20161113135928.jpg
when the frequency increase a little,the figure move down

it is not a esay job, for the bifurcation diagram can easily be strange with a unsuitable frequency.

or change q,the parameter that measures the strength of the damping
QQ截图20161112155823.jpg
QQ截图20161112160314.jpg
we can see that bifurcation point move right.
since drag force is larger,the drive force is increasing at the same time.

Conclusion

We have now obtained at least a qualitative understanding of how the transiton from rugular to chaotic behavior occurs for one particular systerm in one particular range of parameters.

Thanks

Douwei's support for vPython.
Wu yuqiao's code for vPython's show.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注