@zy-0815
2016-10-23T22:05:56.000000Z
字数 9011
阅读 1053
2.10
In this passage,we are going to discuss the track of a cannon shell with adbiatic effect and wind resistance(headwind,or tailwind).Additionally,a calculation of minimun velocity with regard to a specific target is presented too.
With the previous knowledge of Euler Method,we don't have to illustrate again the basic knowledge.What is of great importance to us is the additional wind resistance.Here we set the velocity of wind to be ,and the veloocity of cannon to be .
The components of the drag force can be represented as:
The analyatic form of can be expressed as:
import math
import pylab as pl
a=1
class cannon:
def __init__(self,intial_velocity,intial_angle,velocity_of_wind,angle_of_wind):#Variable that can be set#
self.x=[0]
self.y=[0]
time_step=0.01
mass=10
intial_vx=intial_velocity*math.cos(int(intial_angle)*math.pi/180)
intial_vy=intial_velocity*math.sin(int(intial_angle)*math.pi/180)
self.vx=[intial_vx]
self.vy=[intial_vy]
self.v=[math.sqrt(intial_vx**2+intial_vy**2)]
self.dt=time_step
self.intial_angle=intial_angle
self.m=mass
self.angle_of_wind=angle_of_wind
self.velocity_of_wind=velocity_of_wind
self.B2=[self.m*(0.0039+0.0058/(1+math.exp((self.v[0]-35)/5)))]
self.delta_v_mold=[math.sqrt((intial_vx-self.velocity_of_wind*math.cos(self.angle_of_wind*math.pi/180))**2+(intial_vy-self.velocity_of_wind*math.sin(self.angle_of_wind*math.pi/180))**2)]
def run(self):
i=0
while self.y[i]>=0:
self.B2.append(self.m*(0.0039+0.0058/(1+math.exp((self.v[i]-35)/5))))
self.v.append(math.sqrt(abs(self.vx[i])**2+abs(self.vy[i])**2))
self.delta_v_mold.append(math.sqrt((self.vx[i]-abs(self.velocity_of_wind*math.cos(self.angle_of_wind*math.pi/180)))**2+(self.vy[i]-self.velocity_of_wind*math.sin(self.angle_of_wind*math.pi/180))**2))
self.x.append(self.x[i]+self.vx[i]*self.dt)
self.y.append(self.y[i]+self.vy[i]*self.dt)
self.vx.append(self.vx[i]-pow(1-0.0065*self.y[i]/273,2.5)*self.B2[i]*self.delta_v_mold[i]*(self.vx[i]-self.velocity_of_wind*math.cos(self.angle_of_wind*math.pi/180))/self.m*self.dt)
self.vy.append(self.vy[i]-10*self.dt-pow(1-0.0065*self.y[i]/273,2.5)*self.B2[i]*self.delta_v_mold[i]*(self.vy[i]-self.velocity_of_wind*math.sin(self.angle_of_wind*math.pi/180))/self.m*self.dt)
i+=1
self.x[-1]=(self.x[-1] * self.y[-2] - self.x[-2] * self.y[-1])/ (self.y[-2] - self.y[-1])figure_2.png-74.6kB
def show(self):
pl.plot(self.x,self.y,label='$\\theta=$'+str(self.intial_angle)+'$^{\circ}$'+'.x='+str(int(self.x[-1]))+',Wind velocity '+str(self.velocity_of_wind)+'\n'+'Angle of wind is '+str(self.angle_of_wind)+'$^{\circ}$')
pl.ylim(0,300)
pl.xlim(0,400)
pl.xlabel('x(m)')
pl.ylabel('y(m)')
pl.show()
pl.legend(fontsize='xx-small')
class show_trajectory_of_various_angle(cannon):
def run2(self):
theta=0
while theta<90:
a=cannon(intial_angle=theta,intial_velocity=110,velocity_of_wind=10,angle_of_wind=135)
theta+=1
a.run()
a.show()
class show_trajectory_of_various_wind_velocity(cannon):
def run3(self):
v=0
while v<30:
b=cannon(intial_velocity=110,intial_angle=45,velocity_of_wind=v,angle_of_wind=135)
v+=1
b.run()
b.show()
class show_trajectory_of_various_angle_of_wind(cannon):
def run4(self):
theta2=45
while theta2 in [45,135]:
c=cannon(intial_velocity=244,angle_of_wind=theta2,intial_angle=35,velocity_of_wind=22.27)
theta2+=135
c.run()
c.show()
a=show_trajectory_of_various_angle(110,45,10,135)
a.run2()
import math
import pylab as pl
import time
a=1
class cannon:
def __init__(self,intial_velocity,intial_angle,velocity_of_wind,angle_of_wind):#Variable that can be set#
self.x=[0]
self.y=[0]
time_step=0.01
mass=10
intial_vx=intial_velocity*math.cos(int(intial_angle)*math.pi/180)
intial_vy=intial_velocity*math.sin(int(intial_angle)*math.pi/180)
self.vx=[intial_vx]
self.vy=[intial_vy]
self.v=[math.sqrt(intial_vx**2+intial_vy**2)]
self.dt=time_step
self.intial_angle=intial_angle
self.m=mass
self.angle_of_wind=angle_of_wind
self.velocity_of_wind=velocity_of_wind
self.B2=[self.m*(0.0039+0.0058/(1+math.exp((self.v[0]-35)/5)))]
self.delta_v_mold=[math.sqrt((intial_vx-self.velocity_of_wind*math.cos(self.angle_of_wind*math.pi/180))**2+(intial_vy-self.velocity_of_wind*math.sin(self.angle_of_wind*math.pi/180))**2)]
def run(self):
i=0
while self.y[i]>=-100:
self.B2.append(self.m*(0.0039+0.0058/(1+math.exp((self.v[i]-35)/5))))
self.v.append(math.sqrt(abs(self.vx[i])**2+abs(self.vy[i])**2))
self.delta_v_mold.append(math.sqrt((self.vx[i]-abs(self.velocity_of_wind*math.cos(self.angle_of_wind*math.pi/180)))**2+(self.vy[i]-self.velocity_of_wind*math.sin(self.angle_of_wind*math.pi/180))**2))
self.x.append(self.x[i]+self.vx[i]*self.dt)
self.y.append(self.y[i]+self.vy[i]*self.dt)
self.vx.append(self.vx[i]-pow(1-0.0065*self.y[i]/273,2.5)*self.B2[i]*self.delta_v_mold[i]*(self.vx[i]-self.velocity_of_wind*math.cos(self.angle_of_wind*math.pi/180))/self.m*self.dt)
self.vy.append(self.vy[i]-10*self.dt-pow(1-0.0065*self.y[i]/273,2.5)*self.B2[i]*self.delta_v_mold[i]*(self.vy[i])/self.m*self.dt)
i+=1
self.x[-1]=((-100-self.y[-1])*(self.x[-1]-self.x[-2])/(self.y[-1]-self.y[-2]))+self.x[-1]
self.y[-1]=-100
global a
a=self.x[-1]
def show(self):
pl.plot(self.x,self.y,'r',label='$\\theta=$'+str(self.intial_angle)+'$^{\circ}$'+'.x='+str(int(self.x[-1]))+',Wind velocity '+str(self.velocity_of_wind)+'\n'+'Angle of wind is '+str(self.angle_of_wind)+'$^{\circ}$')
pl.ylim(-100,300)
pl.xlabel('x(m)')
pl.ylabel('y(m)')
pl.show()
pl.legend(fontsize='xx-small')
class find_spot(cannon):
object_x=220
object_y=-100
def run4(self):
v=67.7230
while 67.7230<=v<68:
theta2=14.99
while 14.99<=theta2<20:
c=cannon(intial_velocity=v,angle_of_wind=135,intial_angle=theta2,velocity_of_wind=10)
c.run()
if 220>a:
theta2+=0.0001
else:
print theta2,'degree',a,'m',v,'m/s'
break
v+=0.00001
if 220<a:
break
a=find_spot(110,45,10,135)
a.run4()
Here we set the intial velocity all to be .The angle of wind is (headwind),and the velocity of wind is
Now we change the intial firing angles from with
As this figure is not too compact and difficult to distinguish,we now set
Here we can see,around ,the land point reachs max.
Now we take a closer look at around .
Here we can see, at around ,the land point reaches the maxium.And .
Here we set the intial velocity all to be .The angle of wind is (from tailwind to headwind),,and the velocity of wind is .Intial angles is .
Here we can see,as the angles of wind is changed from tailwind to headwind, the land point is shifting left,which means reach a lesser distance.
To illustrate the difference with or withoud wind,I am going to attach another figure.The angle of wind is and
This figure corresponds well to our feeling in our life!
Here we set the intial velocity all to be .The angle of wind is (headwind),and the velocity of wind is ,. Intial angles is .
As the wind velocity is becoming larger and larger,there may be situation where the cannon shell is blown back.
In this section,we are going to discuss about how to fire a cannon shell with the minimun velocity to reach the target.At first,we set the objec to be set in ,which means the target is lower than the firing places.
However,when we are about to set the scanning interval of and velocity with and .The time taken by the calculation is too long.For compromising,we set the and to identify the mighty intervals,and we find around and velocity about is the ideal result.
Step by step,we narrow the section and finally finds out that at and ,the velocity reaches the minmum.
1.Yu kang has helped with the find-spot programming.
2.Matplotlib.