Let's model the motion of a small BB shot horizontally with an air cannon into water. Use the following values: $b=\beta D$ where $\beta \approx 9\times 10^{-3}$ N$\cdot$s/m$^2$ at room temperature. The diameter of the BB is $D=0.5$ mm and its mass is $6\times10^{-7}$ kg. Assume it has an initial velocity of 5 m/s. What is its total displacement before stopping and approximately how long does it take to stop?
In [2]:
%matplotlib inline
In [3]:
from __future__ import division, print_function
from ivisual import *
from numpy import *
import matplotlib.pyplot as plt
In [56]:
beta=9e-3
D=0.5e-3
m=6e-7
vi=5
r=vector(0,0,0)
v=vector(vi,0,0)
t=0
dt=0.01
tlist=[]
xlist=[]
vxlist=[]
while v.x>0.01:
Fnet=-beta*D*v
v=v+Fnet/m*dt
r=r+v*dt
t=t+dt
tlist.append(t)
xlist.append(r.x)
vxlist.append(v.x)
#theoretical curve fit
#the array function turns tlist into an array; numpy allows us to use an array in an expression
vxtheor=vi*exp(-beta*D/m*array(tlist)) #array of theoretical values for vx
xtheor=vi*m/beta/D*(1-exp(-beta*D/m*array(tlist))) #array of theoretical values of x
In [57]:
plt.title('vx vs t')
plt.xlabel('time (s)')
plt.ylabel('vx (m/s)')
#plot both the numerical model and the theoretical curve
plt.plot(tlist, vxlist, 'b.', tlist, vxtheor, 'r-')
plt.show()
In [58]:
plt.title('x vs t')
plt.xlabel('time (s)')
plt.ylabel('x (m)')
plt.plot(tlist, xlist, 'b.', tlist, xtheor, 'r-')
plt.show()
In [59]:
print("The displacement is", "{0:0.3f}".format(xlist[len(xlist)-1])," m")
Finding the total time to stop is ambiguous. Literally, it takes an infinite time to stop since the velocity exponentially decays to zero. Thus we need an operational definition of "stop." Let's define "stopping" as being less than 1% of the initial speed.
In [60]:
i=0
for vx in vxlist:
if vx<0.01*vi:
print("The time for v < 1% of vx0 is", "{0:0.3f}".format(tlist[i])," s")
break
i=i+1
Note that the theoretical curve for x(t) does not match numerical model. We're using the Euler-Cromer method for numerically integrating Newton's second law and the velocity, which can lead to high numerical error.
How can we increase the accuracy of the numerical model? Go ahead and do that right now.
Suppose that a small water drop, such as in a mist or aerosol, falls vertically in air from rest. For air at STP, $\beta=1.6\times10^{-4}$ N$\cdot$s/m$^2$. The drop has a diameter of 0.2 mm and mass $4\times10^{-9}$ kg. Model the motion of the falling drop.
In [6]:
beta=1.6e-4
D=0.2e-3
m=4e-9
vi=2
g=9.8
vtermy=-m*g/beta/D
viy=vi
r=vector(0,0,0)
v=vector(0,viy,0)
Fgrav=vector(0,-m*g,0)
t=0
dt=0.01
tlist=[]
ylist=[]
vylist=[]
while t<1:
Fnet=-beta*D*v+Fgrav
v=v+Fnet/m*dt
r=r+v*dt
t=t+dt
tlist.append(t)
ylist.append(r.y)
vylist.append(v.y)
#print lists
#print(tlist)
#print(vylist)
#theoretical values
vytheor=vtermy*(1-exp(-beta*D/m*array(tlist)))+viy*exp(-beta*D/m*array(tlist))
ytheor=vtermy*array(tlist)+(viy-vtermy)*(m/beta/D)*(1-exp(-beta*D/m*array(tlist)))
In [7]:
plt.title('vy vs t')
plt.xlabel('time (s)')
plt.ylabel('vy (m/s)')
#plot both the numerical model and the theoretical curve
plt.plot(tlist, vylist, 'b.', tlist, vytheor, 'r-')
plt.show()
In [8]:
plt.title('y vs t')
plt.xlabel('time (s)')
plt.ylabel('y (m)')
#plot both the numerical model and the theoretical curve
plt.plot(tlist, ylist, 'b.', tlist, ytheor, 'r-')
plt.show()
In [25]:
b=beta*D
vterm=m*g/b
vi=2
tanal=m/b*log((vterm+vi)/vterm)
print(tanal)
In [27]:
yanal=vterm*m/b*log((vterm+vi)/vterm)-vi*m/b
print(yanal)
In [ ]: