{
 "metadata": {
  "name": "",
  "signature": "sha256:673810cabac48e32fa28182f2f2ca38e3fabfd4e716ae55b274dc47aad093ef0"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER03 : FUNDAMENTALS OF INVISCID INCOMPRESSIBLE FLOW"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E01 : Pg 63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "import math \n",
      "from math import sqrt\n",
      "rho_inf = 1.23;    # freestream density of air at sea level\n",
      "p_inf = 101000.;    # freestream static pressure\n",
      "v_inf = 50.;        # freestream velocity\n",
      "p = 90000.;         # pressure at given point\n",
      "\n",
      "# The velocity at the given point can be expressed as\n",
      "v = sqrt((2.*(p_inf-p)/rho_inf) + (v_inf**2.));\n",
      "\n",
      "print\"The velocity at the given point is V =\",v,\"m/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at the given point is V = 142.780176712 m/s\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E02 : Pg 64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "rho = 1.225;       # freestream density of air along the streamline\n",
      "p_1 = 101314.1;    # pressure at point 1\n",
      "v_1 = 3.05;        # velocity at point 1\n",
      "v_2 = 57.91;       # velocity at point 2\n",
      "# The pressure at point 2 on the given streamline can be given as\n",
      "p_2 = p_1 + 1/2*rho*((v_1**2) - (v_2**2));\n",
      "print\"The pressure at point 2 is p2 =\",p_2,\"Pa\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure at point 2 is p2 = 101314.1 Pa\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E03 : Pg 69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "import math \n",
      "rho = 1.225;       # freestream density of air along the streamline\n",
      "delta_p = 335.16;   # pressure difference between inlet and throat\n",
      "ratio = 0.8;       # throat-to-inlet area ratio\n",
      "# The velocity at the inlet can be given as\n",
      "v_1 = math.sqrt(2*delta_p/rho/(((1/ratio)**2)-1));\n",
      "print\"The value of velocity at the inlet is V1 =\",v_1,\"m/s\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of velocity at the inlet is V1 = 31.1897419034 m/s\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E04 : Pg 72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "import math \n",
      "rho=1.23;           # freestream density of air along the streamline\n",
      "v=50.;               # operating velocity inside wind tunnel\n",
      "rho_hg = 13600.;       # density of mercury\n",
      "ratio = 12.;           # contraction ratio of the nozzle\n",
      "g = 9.8;              # acceleration due to gravity\n",
      "w = rho_hg*g;         # weight per unit volume of mercury\n",
      "# The pressure difference delta_p between the inlet and the test section is given as\n",
      "delta_p = 1./2.*rho*v*v*(1.-(1./ratio**2.));\n",
      "# Thus the height difference in a U-tube mercury manometer would be\n",
      "delta_h = delta_p/w;\n",
      "print\"The height difference in a U-tube mercury manometer is delta_h =\",delta_h,\"m\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The height difference in a U-tube mercury manometer is delta_h = 0.0114557541767 m\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E05 : Pg 73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "import math \n",
      "from math import sqrt \n",
      "ratio = 12.;        # contraction ratio of wind tunnel nozzle\n",
      "Cl_max = 1.3;      # maximum lift coefficient of the model\n",
      "S = 0.56;          # wing planform area of the model\n",
      "L_max = 4448.22;   # maximum lift force that can be measured by the mechanical balance\n",
      "rho_inf = 1.225;   # free-stream density of air\n",
      "# the maximum allowable freestream velocity can be given as\n",
      "V_inf = sqrt(2.*L_max/rho_inf/S/Cl_max);\n",
      "# thus the maximum allowable pressure difference is given by\n",
      "delta_p = 1./2.*rho_inf*(V_inf**2.)*(1.-(ratio**-2.));\n",
      "print\"The maximum allowable pressure difference between the wind tunnel setling chamber and the test section is delta_p =\",delta_p,\"Pa\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum allowable pressure difference between the wind tunnel setling chamber and the test section is delta_p = 6067.76041667 Pa\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E06 : Pg 75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "\n",
      "V2 = 100.*1609./3600.;        # test section flow velocity converted from miles per hour to meters per second\n",
      "p_atm = 101000.;            # atmospheric pressure\n",
      "p2 = p_atm;                # pressure of the test section which is vented to atmosphere\n",
      "rho = 1.23;                # air density at sea level\n",
      "ratio = 10.;                # contraction ratio of the nozzle\n",
      "\n",
      "# the pressure difference in the wind tunnel can be calculated as\n",
      "delta_p = rho/2.*(V2**2.)*(1.-(1./ratio**2.));\n",
      "\n",
      "# thus the reservoir pressure can be given as\n",
      "p1 = p2 + delta_p;\n",
      "\n",
      "p1_atm = p1/p_atm;         # reservoir pressure expressed in units of atm\n",
      "\n",
      "print\"The reservoir pressure is p1 =\",p1_atm,\"atm\"\n",
      "\n",
      "#Ex3_6b\n",
      "# all the quantities are expressed in SI units\n",
      "\n",
      "V2 = 89.4;        # test section flow velocity converted from miles per hour to meters per second\n",
      "p_atm = 101000;            # atmospheric pressure\n",
      "p2 = p_atm;                # pressure of the test section which is vented to atmosphere\n",
      "rho = 1.23;                # air density at sea level\n",
      "ratio = 10;                # contraction ratio of the nozzle\n",
      "\n",
      "# the pressure difference in the wind tunnel can be calculated as\n",
      "delta_p = rho/2*(V2**2)*(1-(1/ratio**2));\n",
      "\n",
      "# thus the reservoir pressure can be given as\n",
      "p1 = p2 + delta_p;\n",
      "\n",
      "p1_atm = p1/p_atm;         # reservoir pressure expressed in units of atm\n",
      "\n",
      "print\"The new reservoir pressure is p1 =\",p1_atm,\"atm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reservoir pressure is p1 = 1.01204192792 atm\n",
        "The new reservoir pressure is p1 = 1.0486663505 atm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E07 : Pg 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "import math \n",
      "p0 = 104857.2;             # total pressure as measured by the pitot tube\n",
      "p1 = 101314.1;             # standard sea level pressure\n",
      "rho = 1.225;               # density of air at sea level\n",
      "\n",
      "# thus the velocity of the airplane can be given as\n",
      "V1 = math.sqrt(2*(p0-p1)/rho);\n",
      "\n",
      "print\"The velocity of the airplane is V1 =\",V1,\"atm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of the airplane is V1 = 76.0569067293 atm\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E08 : Pg 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "\n",
      "V_inf = 100.1;                # freestream velocity\n",
      "p_inf = 101314.1;             # standard sea level pressure\n",
      "rho_inf = 1.225;              # density of air at sea level\n",
      "\n",
      "# the dynamic pressure can be calculated as\n",
      "q_inf = 1/2*rho_inf*(V_inf**2);\n",
      "\n",
      "# thus the total pressure is given as\n",
      "p0 = p_inf + q_inf;\n",
      "\n",
      "print\"The total pressure measured by pitot tube is p0 =\",p0,\"Pa\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The total pressure measured by pitot tube is p0 = 101314.1 Pa\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E09 : Pg 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "import math \n",
      "p0 = 6.7e4;                # total pressure as measured by the pitot tube\n",
      "p1 = 6.166e4;              # ambient pressure at 4km altitude\n",
      "rho = 0.81935;             # density of air at 4km altitude\n",
      "\n",
      "# thus the velocity of the airplane can be given as\n",
      "V1 = math.sqrt(2*(p0-p1)/rho);\n",
      "\n",
      "print\"The velocity of the airplane is V1 =\",V1,\"m/s =\",V1/0.447,\"mph\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of the airplane is V1 = 114.169709845 m/s = 255.413221129 mph\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 : Pg 88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "import math \n",
      "from math import sqrt\n",
      "V1 =114.2;                 # velocity of airplane at 4km altitude\n",
      "rho = 0.81935;             # density of air at 4km altitude\n",
      "q1 = 1./2.*rho*(V1**2.)        # dynamic pressure experienced by the aircraft at 4km altitude\n",
      "rho_sl = 1.23;             # density of air at sea level\n",
      "# according to the question\n",
      "q_sl = q1;                 # sealevel dynamic pressure\n",
      "# thus the equivallent air speed at sea level is given by\n",
      "Ve = sqrt(2*q_sl/rho_sl);\n",
      "print\"The equivallent airspeed of the airplane is Ve =\",Ve,\"m/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equivallent airspeed of the airplane is Ve = 93.2069457878 m/s\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 : Pg 89"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "V_inf = 45.72;        # freestream velocity\n",
      "V = 68.58;            # velocity at the given point\n",
      "# the coeeficient of pressure at the given point is given as\n",
      "Cp = 1. - (V/V_inf)**2.;\n",
      "print\"The coefficient of pressure at the given point is Cp =\",Cp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The coefficient of pressure at the given point is Cp = -1.25\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E12 : Pg 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "import math \n",
      "from math import sqrt,pi\n",
      "Cp = -5.3;            # peak negative pressure coefficient\n",
      "V_inf = 24.38;        # freestream velocity\n",
      "\n",
      "# the velocity at the given point can be calculated as\n",
      "V = sqrt(V_inf**2*(1-Cp));\n",
      "\n",
      "print\"The velocity at the given point is V =\",V,\"m/s\"\n",
      "\n",
      "#Ex3_12b\n",
      "# all the quantities are expressed in SI units\n",
      "import math \n",
      "Cp = -5.3;            # peak negative pressure coefficient\n",
      "V_inf = 91.44;        # freestream velocity\n",
      "# the velocity at the given point can be calculated as\n",
      "V = math.sqrt(V_inf**2*(1-Cp));\n",
      "\n",
      "print\"The velocity at the given point is V =\",V,\"m/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at the given point is V = 61.1933143407 m/s\n",
        "The velocity at the given point is V = 229.512578479 m/s\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E13 : Pg 100"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# all the quantities are expressed in SI units\n",
      "# When p = p_inf, Cp = 0, thus\n",
      "# 1-4*(sin(theta)**2) = 0\n",
      "# thus theta can be given as\n",
      "#theta = (asind(1/2), 180-asind(1/2), 180-asind(-1/2), 360+asind(-1/2));            # sine inverse of 1/2 and -1/2 where theta varies from 0 to 360 degrees\n",
      "theta1=30.;#\n",
      "theta2=150.;#\n",
      "theta3=210.;#\n",
      "theta4=330.;#\n",
      "print\"The angular locations where surface pressure equals freestream pressure are theta=\",theta1,theta2,theta3,theta4,\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The angular locations where surface pressure equals freestream pressure are theta= 30.0 150.0 210.0 330.0 degrees\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E14 : Pg 103"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "import math \n",
      "Cl = 5;                              # lift coefficient of the cylinder\n",
      "V_by_Vinf = -2 - Cl/2/math.pi;            # ratio of maximum to freestream velocity\n",
      "\n",
      "# thus the pressure coefficient can be calculated as\n",
      "Cp = 1 - (V_by_Vinf**2);\n",
      "\n",
      "print\"The peak negative pressure coefficient is Cp =\",Cp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The peak negative pressure coefficient is Cp = -5.95176382404\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E15 : Pg 106"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "#theta = (180-asind(-5/4/math.pi) 360+asind(-5/4/math.pi));        # location of the stagnation points\n",
      "theta1=203.4;#\n",
      "theta2=336.6;#\n",
      "print\"The angular location of the stagnation points are theta =\",theta1, theta2,\"degrees\"\n",
      "#function temp = Cp(thet)\n",
      "#   temp = 0.367 -3.183*sind(thet) - 4*(sind(thet)**2);    # Cp written as a function of theta\n",
      "#endfunction\n",
      "Cp90=-6.82;#\n",
      "print \"\\nCp =\",Cp90\n",
      "#[k] = roots([-4 -3.183 0.367]);\n",
      "#theta_2 = 180/math.pi*(math.pi-asin(k(1)), 2*math.pi+asin(k(1)), asin(k(2)), math.pi-asin(k(2)));\n",
      "theta_2_1=243.9;#\n",
      "theta_2_2=296.11;#\n",
      "theta_2_3=5.86;#\n",
      "theta_2_4=174.1;#\n",
      "Cp270=-0.45;#\n",
      "print\"\\nThe angular location of points on the cylinder where p = p_inf is theta =\",theta_2_1,theta_2_2,theta_2_3,theta_2_4\n",
      "print\"\\nThe value of Cp at the bottom of the cylinder is Cp = \",Cp270"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The angular location of the stagnation points are theta = 203.4 336.6 degrees\n",
        "\n",
        "Cp = -6.82\n",
        "\n",
        "The angular location of points on the cylinder where p = p_inf is theta = 243.9 296.11 5.86 174.1\n",
        "\n",
        "The value of Cp at the bottom of the cylinder is Cp =  -0.45\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E16 : Pg 110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "import math \n",
      "rho_inf = 0.90926;        # density of air at 3km altitude\n",
      "V_theta = -75;            # maximum velocity on the surface of the cylinder\n",
      "V_inf = 25;               # freestream velocity\n",
      "R = 0.25;                 # radius of the cylinder\n",
      "\n",
      "# thus the circulation can be calculated as\n",
      "tow = -2*math.pi*R*(V_theta+2*V_inf);\n",
      "\n",
      "# and the lift per unit span is given as\n",
      "L = rho_inf*V_inf*tow;\n",
      "\n",
      "print\"The Lift per unit span for the given cylinder is L=\",L,\"N\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Lift per unit span for the given cylinder is L= 892.663917563 N\n"
       ]
      }
     ],
     "prompt_number": 17
    }
   ],
   "metadata": {}
  }
 ]
}