[关闭]
@2014301020081 2016-11-14T09:29:36.000000Z 字数 3402 阅读 742

Computational Physics Chapter 3 problem 3.18,20

by defeng kong(2014301020081)

未分类


Abstract

Using the way and the code of problem 3.12,we can work out the problem and draw a conclusion that if the behavior is period n,Poincare sections will contain n discreter points.
As for 3.20,I just make a simple work.(I have a trouble)

Background

3.18
Plot versus ,with one point plotted for each drive cycle,as in Figure3.9,Do ihin for and,using the other parameters as given in connection with Figure 3.10.
3.20
Calculate the bifurcation diagram for the pendulum in the vicinty of to.Make amagnified plot of the diagram (as compared to Figure 3.11)and obtain an estimate of the Fegenbaum parameter.

The GIF of problem 3.18,3.20:
for period-1
此处输入图片的描述
for period-2
此处输入图片的描述
for period-4
此处输入图片的描述

Main body

For 3.18:

I have written the code from problem 3.12.In problem 3.12,the ,For 3.18,we should do something for and.Just append it.
The code is:

  1. import matplotlib.pyplot as plt
  2. from math import sin,pi
  3. g=9.8
  4. l=9.8
  5. class pendulums:
  6. def _init_(self,F,q,time_step=0.01,init_w=0,init_rad=0.2,dri=2.0/3):
  7. self.w=init_w
  8. self.rad=init_rad
  9. self.t=0
  10. self.dt=time_step
  11. self.dri=dri
  12. self.F=F
  13. self.q=q
  14. self.w1=[]
  15. self.rad1=[]
  16. def calculate(self):
  17. while(self.t<60000):
  18. self.w=self.w-((g/l)*sin(self.rad)\
  19. +self.q*self.w-self.F*sin(self.dri*self.t))*self.dt
  20. self.rad=self.rad+self.w*self.dt
  21. if self.rad>pi:
  22. self.rad=self.rad-2*pi
  23. elif self.rad<-pi:
  24. self.rad=self.rad+2*pi
  25. self.t=self.t+self.dt
  26. n=self.t*self.dri/(2.0*pi)
  27. if abs(n-round(n))<10e-6:
  28. self.w1.append(self.w)
  29. self.rad1.append( self.rad)
  30. def show_results1(self):
  31. plt.scatter(self.rad1,self.w1,s=12)
  32. plt.legend()
  33. plt.xlabel(r'$\omega$')
  34. plt.ylabel(r'$\theta$')
  35. plt.title(r'$\theta$ versus $\omega$ $F_D$=1.35')
  36. plt.show()
  37. a= pendulums()
  38. a._init_(1.40,0.5)
  39. a.calculate()
  40. a.show_results1()
  41. b= pendulums()
  42. b._init_(1.44,0.5)
  43. b.calculate()
  44. b.show_results1()
  45. c= pendulums()
  46. c._init_(1.465,0.5)
  47. c.calculate()
  48. c.show_results1()
  49. d= pendulums()
  50. d._init_(1.2,0.5)
  51. d.calculate()
  52. d.show_results1()

For 3.20

The code is

  1. import matplotlib.pyplot as plt
  2. from math import sin,pi
  3. g=9.8
  4. l=9.8
  5. class pendulums:
  6. def _init_(self,F,q,time_step=0.01,init_w=0,init_rad=0.2,dri=2.0/3):
  7. self.w=init_w
  8. self.rad=init_rad
  9. self.t=0
  10. self.dt=time_step
  11. self.dri=dri
  12. self.F=F
  13. self.q=q
  14. self.rad1=[]
  15. self.FD=[]
  16. def circulation(self,F1=1.35,F2=1.50,dF=0.001,init_w=0,init_rad=0.2):
  17. for i in range(int((F2-F1)/dF)):
  18. self.F=self.F+i*dF
  19. self.calculate()
  20. self.w=init_w
  21. self.rad=init_rad
  22. self.t=0
  23. def calculate(self):
  24. while(self.t<400*3*pi):
  25. self.w=self.w-((g/l)*sin(self.rad)\
  26. +self.q*self.w-self.F*sin(self.dri*self.t))*self.dt
  27. self.rad=self.rad+self.w*self.dt
  28. if self.rad>pi:
  29. self.rad=self.rad-2*pi
  30. elif self.rad<-pi:
  31. self.rad=self.rad+2*pi
  32. self.t=self.t+self.dt
  33. if self.t/3.0*pi>300:
  34. n=self.t*self.dri/(2*pi)
  35. if abs(n-round(n))<0.001:
  36. #if self.t%(3.0*pi)<10e-4:
  37. self.FD.append(self.F)
  38. self.rad1.append( self.rad)
  39. def show_results(self):
  40. plt.scatter(self.FD, self.rad1,s=2)
  41. plt.axis([1.35,1.5,1,3])
  42. plt.xlabel('$F_D$')
  43. plt.ylabel('angle$\theta$')
  44. plt.title('$\theta$ versus $F_D$')
  45. plt.show()
  46. a= pendulums()
  47. a._init_(1.35,0.5)
  48. a.circulation()
  49. a.calculate()
  50. a.show_results()

Conclusion

For 3.18

此处输入图片的描述
此处输入图片的描述
此处输入图片的描述
此处输入图片的描述
Form the Figure of FD=1.40,1.44,1465.I can find that in the period-1,it contain only one point.Likewise,if the behavior is period n,it will contain n discreter points.

For 3.20

此处输入图片的描述
in my code :

  1. def circulation(self,F1=1.35,F2=1.50,dF=0.001,init_w=0,init_rad=0.2):
  2. for i in range(int((F2-F1)/dF)):
  3. self.F=self.F+i*dF

I set dt =0.001,but figure .... about dt=0.02,and the time of running is very very long.I don't think my code is uncorrect,or I can't find the uncorrect position.so I want to wait ,I think next week I can debug.

Thanks

myself

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