[关闭]
@Guozhongzhi 2016-10-23T15:02:29.000000Z 字数 3873 阅读 891

第六次作业

计算物理 郭忠智


一、摘要

本次作业完成了计算物理课本上第二章problem2.10炮弹发射抛物线运动轨迹的近似计算,加入了风阻,以及海拔对空气浓度的影响,对炮弹运行轨迹做了估计,观察目标海拔对炮弹发射速度的影响等。

二、背景

2.10 Generalize the program developed for the previous priblem so that it can deal with situations in which the target is at different altitude than the cannon.Consider cases in which the target is highter and lower than the cannon.Also investigate how the minimum firing velocity required to hit the target varies as the altitude of the target is varied.

三、正文

(一)没有阻力时,运动的方程为:



引入速度有:


(二)引入迎面风阻:

考虑空气浓度随海拔变化,用代替,得到

为空气浓度比,由气体的绝热模型可以得到:

所以

阻力在水平和竖直方向上的分量为:



所以(3)式变为:

用欧拉方法,得到:

(二)用Python编写代码,计算欧拉方法给出的结果
代码如下:

  1. import numpy
  2. import math
  3. import pylab as pl
  4. class cannon_shell:
  5. def __init__(self, x_0, y_0, initial_velocity, theta_0, \
  6. time_step, total_time, target_altitude):
  7. self.theta = theta_0
  8. self.v = [initial_velocity]
  9. self.v_0 = initial_velocity
  10. self.x = [x_0]
  11. self.y = [y_0]
  12. self.v_x = [math.cos(theta_0 * math.pi / 180) * initial_velocity]
  13. self.v_y = [math.sin(theta_0 * math.pi / 180) * initial_velocity]
  14. self.g = 9.8
  15. self.dt = time_step
  16. self.time = total_time
  17. self.a= 65e-4
  18. self.alpha = 2.5
  19. self.T_0 = 300
  20. self.B_2_m = 4e-5
  21. self.fm = []
  22. self.fy = []
  23. self.target_altitude = target_altitude
  24. def run(self):
  25. for i in range(self.time):
  26. self.v.append(math.sqrt(self.v_x[-1] ** 2 + self.v_y[-1] ** 2))
  27. self.v_x.append(self.v_x[-1] - ((1 - self.a * self.y[-1] / \
  28. self.T_0) ** self.alpha) * self.B_2_m * self.v_x[-1] * \
  29. self.dt * self.v[-1])
  30. self.x.append(self.x[-1] + self.dt * self.v_x[-1])
  31. self.v_y.append(self.v_y[-1] - self.g * self.dt - ((1 - \
  32. self.a * self.y[-1] / self.T_0) ** self.alpha) * \
  33. self.B_2_m *self.v_y[-1] * self.dt * self.v[-1])
  34. self.y.append(self.y[-1] + self.dt * self.v_y[-1])
  35. if self.y[-1] <= self.target_altitude and self.y[-2] >= \
  36. self.target_altitude:
  37. break
  38. self.x[-1] = (self.target_altitude -self.y[-2]) * \
  39. (self.x[-1] - self.x[-2]) / (self.y[-1] - self.y[-2]) +self.x[-2]
  40. for j in range(len(self.x)):
  41. self.x[j] = self.x[j] / 1000
  42. for j in range(len(self.y)):
  43. self.y[j] = self.y[j] / 1000
  44. for j in range(100):
  45. self.fm.append(max(self.y))
  46. self.fy.append(self.y[-1])
  47. def show_results(self):
  48. font1 = {'family': 'serif',
  49. 'color': 'darkred',
  50. 'weight': 'normal',
  51. 'size': 16,
  52. }
  53. font2 = {'family': 'serif',
  54. 'color': 'darkred',
  55. 'weight': 'normal',
  56. 'size': 6,
  57. }
  58. pl.plot(self.x, self.y)
  59. pl.plot(numpy.linspace(0, self.x[len(self.x) / 2], 100), \
  60. self.fm, ':')
  61. pl.plot(numpy.linspace(0, self.x[-1], 100), self.fy, ':')
  62. pl.title('Trajectory of cannon shell', fontdict = font1)
  63. pl.xlim(0, 35)
  64. pl.ylim(0, 16)
  65. pl.legend(loc="best")
  66. pl.xlabel('x ($km$)')
  67. pl.ylabel('y ($km$)')
  68. pl.text(22, max(self.y),\
  69. \
  70. str(self.theta) +'$\degree$, ' + str(self.v_0) + '$m/s$,'\
  71. + str(max(self.y)) + '$km$', fontdict = font2)
  72. pl.figure(1)
  73. for i in numpy.linspace(100, 700, 12):
  74. a = cannon_shell(0 , 0, i, 50, 0.1, 1500, 2000)
  75. a.run()
  76. pl.figure(1)
  77. a.show_results()
  78. pl.show()
  79. pl.figure(2)
  80. for j in numpy.linspace(0, 45, 11):
  81. a = cannon_shell(0 , 0, 700, 30 + j, 0.1, 1500, 5000)
  82. a.run()
  83. pl.figure(2)
  84. a.show_results()
  85. pl.show()

上述算法计算了在同一发射角度、不同发射速度给出的轨迹,以及同一发射速度、不同发射角度的轨迹。给出的结果如下:
2_10相同角度.png-34kB
2_10相同速度.png-41.8kB

四、结论

从运行结果可以看到,当考虑空气浓度随海拔的变化后。炮弹运动轨迹与抛物线相似,观察图线,可以发现固定发射角度时,炮弹达到目标高度随发射速度成正相关。当固定发射速度,改变发射角度,炮弹达到目标高度时的前进距离会发生变化。

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