# Chapter 20 : Computational fluid dynamics¶

### Example 20.1 page no : 588¶

In [2]:
#Calculate first derivative and second derivative of the fluid flow

# variables
y_fd2=0.4336                    #m
y_fd1=0.4375                    #m
delta_yfd=y_fd2-y_fd1           #m
x_fd2=0.75                      #m
x=0.5                           #m
delta_xfd=x_fd2-x               #m
y_bd2=0.4375                    #m
y_bd1=0.2461                    #m
delta_ybd=y_bd2-y_bd1           #m
x_bd1=0.25                      #m
delta_xbd=x-x_bd1               #m

# calculation
#Let D denote d/dx and D2 denote d^2/dx^2
Dy_fd=delta_yfd/delta_xfd       #dimentionless
Dy_bd=delta_ybd/delta_xbd       #dimentionless
Dy=(Dy_fd+Dy_bd)/2              #dimentionless
D2y=(Dy_fd-Dy_bd)/delta_xfd     #dimentionless

# result
print "The first derivative of fluid flow is %f\n"%Dy
print "The second derivative of fluid flow is %.3f"%D2y

The first derivative of fluid flow is 0.375000

The second derivative of fluid flow is -3.125


### Example 20.3 page no : 592¶

In [1]:
#Calculate the grid velocities

# variables
v=1.077*10**(-5)                  #ft^2/s
t=2.                              #sec
dy=0.01                           #ft
w=v*t/dy**2                       #dimentionless

#Let Vij represent velocity through the i,j grid
V00=5.                            #ft/s
V10=5.                            #ft/s
V01=0.                            #ft/s
V02=0.                            #ft/s
V12=0.                            #ft/s

# calculation
V11=V01+w*(V00-2*V01+V02)         #ft/s
V21=V11+w*(V10-2*V11+V12)         #ft/s
V13=0.                            #ft/s
V22=V12+w*(V11-2*V12+V13)         #ft/s

# result
print "The grid velocity for 2,1 is %.3f ft/s\n"%V21
print "The grid velocity for 2,2 is %.3f ft/s\n"%V22

The grid velocity for 2,1 is 1.690 ft/s

The grid velocity for 2,2 is 0.232 ft/s