summaryrefslogtreecommitdiff
path: root/Fluid_Mechanics_by_John_F_Douglas/Chapter_17.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Fluid_Mechanics_by_John_F_Douglas/Chapter_17.ipynb')
-rwxr-xr-xFluid_Mechanics_by_John_F_Douglas/Chapter_17.ipynb274
1 files changed, 274 insertions, 0 deletions
diff --git a/Fluid_Mechanics_by_John_F_Douglas/Chapter_17.ipynb b/Fluid_Mechanics_by_John_F_Douglas/Chapter_17.ipynb
new file mode 100755
index 00000000..2791e2c2
--- /dev/null
+++ b/Fluid_Mechanics_by_John_F_Douglas/Chapter_17.ipynb
@@ -0,0 +1,274 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:c21785277c0a99c3eb4c310a9e20c477f6ab2a0a22da1b2d3844df1699a78d21"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 17: Compressible Flow in Pipes"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 17.1, Page 566"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "import math\n",
+ "import sympy\n",
+ "from sympy import solve,symbols\n",
+ "\n",
+ " #Initializing the variables\n",
+ "g = 9.81;\n",
+ "rho = 1000;\n",
+ "rhoHg = 13.6*rho;\n",
+ "d1 = 0.075;\n",
+ "d2 = 0.025;\n",
+ "Pi = 0.250;\n",
+ "Pt = 0.150;\n",
+ "P_Hg = 0.760;\n",
+ "rho1 = 1.6;\n",
+ "gma = 1.4;\n",
+ "\n",
+ " #Calculations\n",
+ "P1 = (Pi+P_Hg)*rhoHg*g;\n",
+ "P2 = (Pt+P_Hg)*rhoHg*g;\n",
+ "rho2 = rho1*(P2/P1)**(1/gma);\n",
+ "V0=symbols('V0')\n",
+ "V1=symbols('V1')\n",
+ "Velo = solve([d2**2*V1*rho2-d1**2*V0*rho1,0.5*(V1**2 - V0**2)*((gma-1)/gma)*(rho2*rho1/(rho2*P1-rho1*P2))-1],[V0,V1])\n",
+ "s=(Velo[1])[0]\n",
+ "Flow = math.pi*d1**2/4*s;\n",
+ "\n",
+ "print \"Volume of flow (m3/s):\",round(Flow,3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Volume of flow (m3/s): 0.06\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 17.2, Page 571"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "import math\n",
+ "\n",
+ "\n",
+ " #Initializing the variables\n",
+ "Ma = 4;\n",
+ "gma = 1.4;\n",
+ "At = 500; # in mm\n",
+ "\n",
+ " #Calculations\n",
+ "N = 1 + (gma-1)*Ma**2/2;\n",
+ "D = (gma+1)/2 ;\n",
+ "#ratio of A/At ==R\n",
+ "R = round( (N/D)**((gma+1)/(2*(gma-1)))/Ma,2);\n",
+ "A=At*R\n",
+ "print \"Area of test section (mm^2):\",A"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Area of test section (mm^2): 5360.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 17.3, Page 575"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "import math\n",
+ "\n",
+ "\n",
+ " #Initializing the variables\n",
+ "Ma1 = 2;\n",
+ "gma = 1.4;\n",
+ "T1 = 15+273; # In kelvin\n",
+ "P1 = 105; \n",
+ "\n",
+ " #Calculations\n",
+ "Ma2 = (((gma-1)*Ma1**2 +2)/(2*gma*Ma1**2-gma+1))**0.5;\n",
+ "P2 = P1*(1+gma*Ma1**2)/(1+gma*Ma2**2);\n",
+ "T2 = T1*(1 +(gma-1)/2*Ma1**2)/(1 +(gma-1)/2*Ma2**2);\n",
+ "\n",
+ "\n",
+ "print \"Mach No downstream shock wave :\",round(Ma2,3)\n",
+ "print \"Pressure (bar) of downstream shock wave :\",round(P2)\n",
+ "print \"Temperature (Degree C) of downstream shock wave :\",T2 - 273"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mach No downstream shock wave : 0.577\n",
+ "Pressure (bar) of downstream shock wave : 473.0\n",
+ "Temperature (Degree C) of downstream shock wave : 213.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 17.4, Page 581"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "import math\n",
+ "\n",
+ "\n",
+ " #Initializing the variables\n",
+ "gma = 1.4;\n",
+ "f = 0.00375;\n",
+ "d = 0.05;\n",
+ "\n",
+ " #Calculations\n",
+ "m = d/4;\n",
+ "def x(Ma):\n",
+ " A =(1 -Ma**2 )/(gma*Ma**2);\n",
+ " B = (gma+1)*Ma**2/(2+(gma-1)*Ma**2); \n",
+ " y = m/f*(A+ (gma+1)*math.log(B)/(2*gma));\n",
+ " return y\n",
+ "\n",
+ "X1 = x(0.2); # At entrance Ma = 0.2;\n",
+ "X06_X1 =x(0.6); # Section(b) Ma = 0.6;\n",
+ "\n",
+ "X06 = X1-X06_X1;\n",
+ "\n",
+ "print \"The Distance X1 at which the Mach number is unity (m) :\",round(X1,2)\n",
+ "print \"Distance from the entrance (m) :\",round(X06,2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Distance X1 at which the Mach number is unity (m) : 48.44\n",
+ "Distance from the entrance (m) : 46.81\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 17.5, Page 585"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from __future__ import division\n",
+ "import math\n",
+ "from scipy.optimize import fsolve\n",
+ "\n",
+ " #Initializing the variables\n",
+ "gma = 1.4;\n",
+ "Q = 28/60; # m3/s\n",
+ "d = 0.1;\n",
+ "p1 = 200*10**3;\n",
+ "f = 0.004;\n",
+ "x_x1 = 60;\n",
+ "R = 287;\n",
+ "T = 15+273;\n",
+ "\n",
+ " #Calculations\n",
+ "A = math.pi*d**2/4;\n",
+ "m = d/4;\n",
+ "v1 = Q/A;\n",
+ "pa = p1*(1-f*(x_x1)*v1**2/(m*R*T))**0.5;\n",
+ "\n",
+ "def g(p):\n",
+ " A = (v1*p1)**2/(R*T)\n",
+ " B = f*A*x_x1/(2*m);\n",
+ " y = (p**2 - p1**2)/2 -A*math.log(p/p1) +B;\n",
+ " return y\n",
+ " \n",
+ "pb=fsolve(g,pa) # Guessing solution around pa\n",
+ "pb=pb[0]\n",
+ "print \"Pressure at the outlet, neglecting velocity changes (kN/m2) :\",round(pa/1000,1)\n",
+ "print \"Pressure at the outlet, allowing for velocity changes (kN/m2) :\",round(pb/1000,1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Pressure at the outlet, neglecting velocity changes (kN/m2) : 153.6\n",
+ "Pressure at the outlet, allowing for velocity changes (kN/m2) : 150.4\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file