import math
%matplotlib inline
#Variable Decleration
#Defining u and v in comments
#u=0.5+0.8x
#v=1.5-0.8y
a=0.5 #Velocity component
b=0.8 #Velocity component
c=1.5 #Velocity component
#Calculations
#Part(a)
x=-a/b #x-component of stagnation point
y=c/b #y-component of stagnation point
#Result
print "There is a stagnation point at x=",round(x,3),"m","and y=",round(y,3),"m"
#Part (b)
import numpy as np
import matplotlib.pyplot as plt
Y, X = np.mgrid[-1:5:100j, -3:3:100j]
U = 0.5+0.8*X
V = 1.5-0.8*Y
speed = np.sqrt(U*U + V*V)
plt.streamplot(X, Y, U, V, color=U, linewidth=1, cmap=plt.cm.autumn)
plt.colorbar()
plt.ylabel('y')
plt.xlabel('x')
plt.show()
import math
#Variable Decleration
V_dot=0.053*10**-3 #Vloumetric Flow rate in m^3/s
D_inlet=0.0107 #Diameter of the nozzle in m
D_outlet=0.0046 #Diameter of the nozzle at the outlet in m
delta_x=0.0991 #Length of the pipe in m
#Calcualtions
u_inlet=(4*V_dot)/(pi*D_inlet**2) #Velocity at the inlet in m/s
u_outlet=(4*V_dot)/(pi*D_outlet**2) #Velocity at the outlet in m/s
a_x=(u_outlet**2-u_inlet**2)/(2*delta_x) #Axial Acceleration in m/s^2
#Result
print "The magnitude of acceleration is",round(a_x,1),"m/s^2"
import math
%matplotlib inline
#Variable Decleration
x=[-2,-1,0,1,2]
y=[-3,-2,-1,0,1,2,3]
#Calcualtions
a_x=0.4+0.64*x[4]
a_y=-1.2+0.64*y[6]
#Plotting
import numpy as np
import matplotlib.pyplot as plt
Y, X = np.mgrid[-1:5:100j, -3:3:100j]
U = 0.4+0.64*X
V = -1.2+0.64*Y
speed = np.sqrt(U*U + V*V)
plt.streamplot(X, Y, U, V, color=U, linewidth=1, cmap=plt.cm.autumn)
plt.colorbar()
plt.ylabel('y')
plt.xlabel('x')
plt.show()
#Result
print "The acceleration at x=2 and y=3 are a_x=",round(a_x,2),"m/s^2 and a_y=",round(a_y,3),"m/s^2"