{
 "metadata": {
  "name": "",
  "signature": "sha256:0fec1a915dc11972a0b348fe3db6dc5cdc775b2840fa9a3ae3580b08a05d480b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter8-Boundary Layers, Wakes and Other Shear Layers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg302"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Displacement thickness and Momentum thickness \n",
      "delta=0.6; ## mm\n",
      "\n",
      "delta1=delta/3.;\n",
      "\n",
      "theta=2./15*delta;\n",
      "\n",
      "print'%s %.1f %s'%(\"Displacement thickness =\",delta1,\"mm\")\n",
      "\n",
      "print'%s %.2f %s'%(\"Momentum thickness =\",theta,\"mm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Displacement thickness = 0.2 mm\n",
        "Momentum thickness = 0.08 mm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Evaluate the constants A and B\n",
      "import numpy\n",
      "from numpy import linalg\n",
      "import scipy\n",
      "from scipy import integrate\n",
      "## To determine the values of a1 & a2 following conditions must be satisfied\n",
      "\n",
      "## Condition I - When n=0, u/um=0\n",
      "## Condition II - When n=1, u/um=a1+a2=1\n",
      "## Condition III - When n=1, d(u/um)/dn = a1+2a2=0\n",
      "\n",
      "## By  satisfying these conditions, we have\n",
      "## a1+a2=1;\n",
      "## a1+2a2=0;\n",
      "\n",
      "A=([[1,1],[1,2]]);\n",
      "B=([[1],[0]]);\n",
      "X=numpy.linalg.inv(A)*B;\n",
      "\n",
      "a1=X[0];\n",
      "a2=X[1];\n",
      "\n",
      "print(\"a1=\",a1[0])\n",
      "\n",
      "print(\"a2=\",a1[1])\n",
      "\n",
      "\n",
      "print(\"Evaluate the constants A and B\")\n",
      "\n",
      "## A = integrate('(1-f(n))*f(n)','n',0,1)\n",
      "\n",
      "def function(n):\n",
      "\tfun=(1-(2*n-n**2))*(2*n-n**2)\n",
      "\treturn fun\n",
      "\n",
      "A=scipy.integrate.quad(function,0,1)\n",
      "print(\"A = \",A[0],\"\")\n",
      "\n",
      "\n",
      "## B = differentiation of (2*n-n^2) at n=0, we get \n",
      "B=2;\n",
      "\n",
      "print(\"B =\",B,\"\")\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('a1=', 2.0)\n",
        "('a2=', -1.0)\n",
        "Evaluate the constants A and B\n",
        "('A = ', 0.13333333333333333, '')\n",
        "('B =', 2, '')\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg310"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Evaluate the constants A and B\n",
      "import numpy\n",
      "from numpy import linalg\n",
      "import scipy\n",
      "from scipy import integrate\n",
      "## To determine the values of a1 & a2 following conditions must be satisfied\n",
      "\n",
      "## Condition I - When n=0, u/um=0\n",
      "## Condition II - When n=1, u/um=a1+a2=1\n",
      "## Condition III - When n=1, d(u/um)/dn = a1+2a2=0\n",
      "\n",
      "## By  satisfying these conditions, we have\n",
      "## a1+a2=1;\n",
      "## a1+2a2=0;\n",
      "\n",
      "A=([[1,1],[1,2]]);\n",
      "B=([[1],[0]]);\n",
      "X=numpy.linalg.inv(A)*B;\n",
      "\n",
      "a1=X[0];\n",
      "a2=X[1];\n",
      "\n",
      "print(\"a1=\",a1[0])\n",
      "\n",
      "print(\"a2=\",a1[1])\n",
      "\n",
      "\n",
      "print(\"Evaluate the constants A and B\")\n",
      "\n",
      "## A = integrate('(1-f(n))*f(n)','n',0,1)\n",
      "\n",
      "def function(n):\n",
      "\tfun=(1-(2*n-n**2))*(2*n-n**2)\n",
      "\treturn fun\n",
      "\n",
      "A=scipy.integrate.quad(function,0,1)\n",
      "print(\"A = \",A[0],\"\")\n",
      "\n",
      "\n",
      "## B = differentiation of (2*n-n^2) at n=0, we get \n",
      "B=2;\n",
      "\n",
      "print(\"B =\",B,\"\")\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('a1=', 2.0)\n",
        "('a2=', -1.0)\n",
        "Evaluate the constants A and B\n",
        "('A = ', 0.13333333333333333, '')\n",
        "('B =', 2, '')\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg312"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the velocity of the airstream and frictional drag of the plat\n",
      "v=1.5*10**(-5); ## m^2/s\n",
      "Re_t=5.*10**5;\n",
      "x_t=1.2; ## m\n",
      "rho=1.21; ## kg/m^3\n",
      "\n",
      "u_m=v*Re_t/x_t;\n",
      "\n",
      "print'%s %.2f %s'%(\"the velocity of the airstream =\",u_m,\"m/s\")\n",
      "\n",
      "\n",
      "theta=0.646*x_t/math.sqrt(Re_t);\n",
      "\n",
      "F=rho*u_m**2*theta;\n",
      "\n",
      "D_F=2.*F*x_t;\n",
      "print'%s %.3f %s'%(\"the frictional drag of the plate, D_F =\",D_F,\"N\")\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the velocity of the airstream = 6.25 m/s\n",
        "the frictional drag of the plate, D_F = 0.124 N\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg316"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the boundary layer thickness at the rear of the train and the frictional drag acting on the train and the power required to overcome the frictional drag\n",
      "u_m = 50.; ## m/s or 180 km/h\n",
      "v=1.5*10**(-5); ## m^2/s\n",
      "l=100.; ## m\n",
      "rho=1.2; ## kg/m^3\n",
      "b=8.3; ## m\n",
      "\n",
      "delta = 0.37*(v/u_m)**(1/5.)*l**(4/5.);\n",
      "\n",
      "print'%s %.3f %s'%(\"the boundary layer thickness at the rear of the train =\",delta,\"m\")\n",
      "Re_l = u_m*l/v;\n",
      "C_F=0.074*(Re_l)**(-1/5.);\n",
      "F=0.037*rho*u_m**2*l*Re_l**(-1/5.);\n",
      "\n",
      "D_F = F*b;\n",
      "\n",
      "print'%s %.4f %s'%(\"the frictional drag acting on the train, D_F =\",D_F,\"N\")\n",
      "\n",
      "\n",
      "P=D_F*u_m;\n",
      "print'%s %.1f %s'%(\"the power required to overcome the frictional drag =\",P/1000,\"kW\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the boundary layer thickness at the rear of the train = 0.731 m\n",
        "the frictional drag acting on the train, D_F = 1818.9691 N\n",
        "the power required to overcome the frictional drag = 90.9 kW\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg318"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the proportion of the plate occupied by the laminar boundary layer and   the skin friction coefficient CF evaluated at the trailing edge\n",
      "Re_t=5.*10**5;\n",
      "Re_l=5.*10**6;\n",
      "\n",
      "r1=Re_t/Re_l; ## r1=x_t/l\n",
      "r2=1-36.9*(1./Re_t)**(3/8.); ## r2=x_0/x_t\n",
      "\n",
      "r=r1*r2; ## r=x_0/l;\n",
      "\n",
      "print'%s %.2f %s'%(\"the proportion of the plate occupied by the laminar boundary layer =\",r*100,\"%\")\n",
      "\n",
      "C_F = 0.074/Re_l**(1/5.)*(1-r)**(4/5.);\n",
      "print'%s %.4f %s'%(\"the skin friction coefficient CF evaluated at the trailing edge =\",C_F,\"\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the proportion of the plate occupied by the laminar boundary layer = 7.31 %\n",
        "the skin friction coefficient CF evaluated at the trailing edge = 0.0032 \n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}