[关闭]
@zy-0815 2016-10-16T16:14:34.000000Z 字数 1921 阅读 1469

计算物理第五次作业2.9


摘要

这道题主要是要计算以一定速度和角度发射的大炮的运动轨迹,而相对于书上,此题要考虑空气阻力和空气密度随海拔高度变化,并求出相应的哪个角度大炮所运动的轨迹最远。

背景介绍

抛体运动是物理问题中一个很重要的模型,而用Python语言写出相应的程序解决具体问题也是学习后的具体应用体现。

正文

首先将空气阻力简单表示成 Fdrag=-Bv^2

而且空气密度随海拔变化为p= p0exp(-y/y0)

因此阻力可表示为Fdrag=p/p0*Fdrag(y=0)

同时根据Euler法模拟自行车运动问题和理想状态不受阻力情况下大炮运动轨迹,因此程序可写为:

  1. import pylab as pl
  2. import math
  3. class Trajectory_of_cannon:
  4. """
  5. Calculate the trajectory of the cannon shell including
  6. both air drag and the reduced air density at high altitudes.
  7. """
  8. def __init__(self,time_step=0.05,X=0,Y=0,initial_speed=700,initial_angel=30):
  9. self.theta=initial_angel
  10. self.Vx=[math.cos(self.theta*math.pi/180)*700]
  11. self.Vy=[math.sin(self.theta*math.pi/180)*700]
  12. self.X=[0]
  13. self.Y=[0]
  14. self.dt=time_step
  15. self.t=[0]
  16. def calculate(self):
  17. i=0
  18. while self.Y[i]>=0:
  19. V=math.sqrt(math.pow(self.Vx[i],2)+math.pow(self.Vy[i],2))
  20. temp_X=self.X[i]+self.Vx[i]*self.dt
  21. temp_Y=self.Y[i]+self.Vy[i]*self.dt
  22. self.X.append(temp_X)
  23. self.Y.append(temp_Y)
  24. temp_Vx=self.Vx[i]-math.exp(-self.Y[i]/10000)*0.00004*V*self.Vx[i]*self.dt
  25. temp_Vy=self.Vy[i]-9.79*self.dt-math.exp(-self.Y[i]/10000)*0.00004*V*self.Vy[i]*self.dt
  26. self.Vx.append(temp_Vx)
  27. self.Vy.append(temp_Vy)
  28. self.t.append(self.t[i]+self.dt)
  29. i+=1
  30. def show_result(self):
  31. pl.plot(self.X,self.Y)
  32. pl.xlabel("X(m)")
  33. pl.ylabel("Y(m)")
  34. pl.xlim(0,30000)
  35. pl.ylim(0,20000)
  36. pl.show()
  37. def landing_point(self):
  38. self.angel_point=dict()
  39. self.angel_point[self.theta]=self.X[-1]-self.Y[-1]*(self.X[-1]-self.X[-2])/(self.Y[-1]-self.Y[-2])
  40. print(self.angel_point)
  41. a=Trajectory_of_cannon()
  42. a.calculate()
  43. a.show_result()
  44. a.landing_point()
  45. class Maximum_of_range(Trajectory_of_cannon):
  46. def line_of_different_angel(self):
  47. self.theta=0
  48. for i in range(91):
  49. b=Trajectory_of_cannon(initial_angel=self.theta)
  50. b.calculate()
  51. b.show_result()
  52. b.landing_point()
  53. self.theta=self.theta+1
  54. b=Maximum_of_range()
  55. b.line_of_different_angel()

此为角度为25度时的轨迹图像:
image_1av738erh1erj8a4h46g7f8uf9.png-11.6kB
此为角度为50度是的轨迹图像:
image_1av73be7b9o510rcgtu1n4e4k0m.png-13.3kB
由于个人知识储备的不足,无法将所有的运动的轨迹整合在一个图片上,但通过查看结果,可看出当角度为46度时大炮运动的轨迹最远。其轨迹图为:
image_1av73njom185o1ki3ck86259d413.png-12.8kB

结论

当考虑空气阻力和空气密度时,大炮的发射角度为46度时运动的轨迹最远。同时不会将所有轨迹整合在一起仍然需要自己慢慢去学习。

致谢

谢谢陆文龙同学作业给予的帮助。

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