[关闭]
@XF 2016-10-23T16:14:19.000000Z 字数 2058 阅读 83

第六次作业


摘要

本作业将对2.10题进行进一步升级,发展“超级辅助精确打击系统”(考虑炮弹初始发射的时候发射角度误差,速度有5%的误差,迎面风阻误差10%,以炮弹落点与打击目标距离差平方均值最小为优胜)

一、背景介绍

由牛顿第二定律:



而且:


用小量形式表示:

二、正文

  1. import pylab as pl
  2. import math
  3. class cannon :
  4. def __init__(self,i=0,air_resistance=0.00004,power=10,mass = 1,time_step=0.1,\
  5. initial_velocity=700,initial_x=0,initial_y=0,\
  6. initial_velocity_x=700*math.cos(math.pi/4),\
  7. initial_velocity_y=700*math.sin(math.pi/4)):
  8. self.x = [initial_x]
  9. self.y = [initial_y]
  10. self.vx = [initial_velocity_x]
  11. self.vy = [initial_velocity_y]
  12. self.v = [initial_velocity]
  13. self.t = [0]
  14. self.m = mass
  15. self.p = power
  16. self.B_2 = air_resistance
  17. self.dt = time_step
  18. def run(self):
  19. while(1):
  20. s1=self.x[-1] + self.vx[-1]*self.dt
  21. s2=self.y[-1] + self.vy[-1]*self.dt
  22. v1=self.vx[-1] - self.dt *pow((1-(0.0065*self.y[-1])/300),2.5)*\
  23. (0.0039+0.0058/(1+math.exp((self.v[-1]-35)/5)))*\
  24. self.v[-1] * self.vx[-1]
  25. v2=self.vy[-1] - 9.8*self.dt - self.dt *\
  26. pow((1-(0.0065*self.y[-1])/300),2.5)*(0.0039+\
  27. 0.0058/(1+math.exp((self.v[-1]-35)/5))) *\
  28. self.v[-1] * self.vx[-1]
  29. self.x.append(s1)
  30. self.y.append(s2)
  31. self.v.append(math.sqrt(self.vx[-1]*self.vx[-1] + self.vy[-1]*self.vy[-1]))
  32. self.vx.append(v1)
  33. self.vy.append(v2)
  34. if(s2<0):
  35. break
  36. def show_results(self):
  37. pl.plot(self.x,self.y,'b',label='angle is 43 degree')
  38. pl.title('Precise guidance system')
  39. pl.xlabel('X')
  40. pl.ylabel('Y')
  41. pl.legend()
  42. pl.ylim(0,)
  43. pl.show()
  44. a = cannon()
  45. a.run()
  46. a.show_results()

三、结论

(1)Position of goal is(1000,100),the velocity of wind is -10m/s:
The minimum velocity:105.99231719970703m/s,angle:47°
(2)Position of goal is(1000,-100),the velocity of wind is -10m/s::
The minimum velocity:95.76740264892578m/s,angle:41°
(1)目标位置(1000,100),风速为-10m/s
最小速度105.99m/s
(2)目标位置(1000,-100),风速为-10m/m/s
最小速度为95.76m/s

致谢

感谢曹昕宇、杜威同学程序方便的帮助。

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