# Chapter 4: Motion Fluid Particles and Streams¶

## Example 4.1, Page 103¶

In [1]:
import math
from pylab import *
import numpy as np
%matplotlib inline

#Initializing  the  variables
x = [0, 23, 28, 31, 32, 29, 22, 14, 0]
y = np.linspace(0,80,9)
xlabel('Velocity  (m/s)')
ylabel('Distance  from  one  side(mm)')
title('Velocity Distribution Curve')
grid(1)

#Calculations
plot(x,y,'-*')
show()
mu=[17.5 , 26.0,  29.6,  31.9,  30.7,  25.4,  18.1,  7.7]
#  mean  velocity
print "Mean velocity (m/s):",round(mean(mu),2)

Mean velocity (m/s): 23.36


## Example 4.2, Page 106¶

In [3]:
import math
from pylab import *
import numpy as np

#Initializing  the  variables  all  unknowns  are  assigned  0

d  =  [0.0, 0.05, 0.075, 0, 0.030];
Q  =  [0, 0, 0, 0, 0];
V  =  [0, 0, 2, 1.5, 0];
A  =  [0, 0, 0, 0, 0]
#Calculations
A2  =  math.pi*d[2]**2/4;
Q[2]  =A2*V[2];
Q  =  [0,Q[2], Q[2],  Q[2]/1.5 , 0.5*Q[2]/1.5];
d[3]  =  (Q[3]*4/(V[3]*math.pi))**0.5;
for i in range(0,5):
A[i]  =  math.pi*d[i]**2/4;
V[1]  =  V[2]*(A[2]/A[1]);
V[4]=Q[4]/A[4];

header  =  "Diameter(mm)  Area(m2)\t Flow Rate(m3/s)  Velocity(m/s)"
for c in range(1,5):
mm=str(round(d[c]*1000,1))+'\t  '+str(round(A[c],6))+' \t    '+str(round(Q[c],6))+'     \t'+str(round(V[c],2))
print mm

Diameter(mm)  Area(m2)	 Flow Rate(m3/s)  Velocity(m/s)
50.0	  0.001963 	    0.008836     	4.5
75.0	  0.004418 	    0.008836     	2.0
70.7	  0.003927 	    0.00589     	1.5
30.0	  0.000707 	    0.002945     	4.17


## Example 4.3, Page 108¶

In [10]:
from __future__ import division
import math
import sympy
from sympy import diff, Symbol

#Initializing  the  variables
'''
def df(x, h=0.1e-5):
return ( f(x+h/2) - f(x-h/2) )/h
return df

print df(2*x,h)
'''
x = Symbol('x')
vx  =  3-x
vy  =  4+2*x
vz  =  2-x

#Calculations
delVx  =  vx.diff(x);
delVy  =  vx.diff(x);
delVz  =  vx.diff(x);

result  =  delVx+delVy+delVz;#requirement  of  continuity  equation  (result  =  0)
print "Satisfy requirement of continuity "

Satisfy requirement of continuity