Search This Blog

Tuesday, June 21, 2011

Simulation falling through viscous medium


#Falling of a body through viscous medium
#Loss of weight   V*d1*g-V*d2*g=V*d1*g(1-d2/d1)=m*a where a=g(1-d2/d1)
#Drag in the case of ball 6*pi*eta*a*v=k*v
#dy/dt=v
#dv/dt=a-kv
from pylab import*
from math import*
d1=2000.0
d2=750.0
g=9.8

height=2000
y0=0
v0=0
a=(1.0- d2/d1)*g #including buoyant force
k=0.2 #drag coefficient
h=0.001
t=0
y=[y0]
v=[v0]
time=[t]
 
while height-y0>0:
    v1=v0+h*(a-k*v0)
    y1=y0+h*v0
 
    t=t+h
    y.append(height-y1)
    v.append(fabs(v1))
    time.append(t)
    y0=y1
    v0=v1

 
figure(1)
title("Fall through viscous medium")
xlabel(" Time")
ylabel("Position")
plot(time,y)


figure(2)
title("Fall through viscous medium")
xlabel(" Time")
ylabel("Velocity")
plot(time,v)
show()


 

1 comment:

  1. 6*pi*eta*a*v=k*v, so k*v is force
    v1=v0+h*(a-k*v0), here you are substracting force from acceleration. Please clarify

    ReplyDelete