{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER01:AERODYNAMICS SOME INTRODUCTORY THOUGHTS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E01 : Pg 12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Drag coefficient by first method is: 0.0217\n",
      "The Drag coefficient by second method is: 0.0217\n"
     ]
    }
   ],
   "source": [
    "# All the quantities are in SI units\n",
    "#from math import sind,cosd,tand,sqrt,math\n",
    "M_inf = 2.; # freestream mach number\n",
    "p_inf = 101000.; # freestream static pressure\n",
    "rho_inf = 1.23; # freestream density\n",
    "T_inf = 288.; # freestream temperature\n",
    "R = 287.; # gas constant of air\n",
    "a = 5.; # angle of wedge in degrees\n",
    "p_upper = 131000.; # pressure on upper surface\n",
    "p_lower = p_upper; # pressure on lower surface is equal to upper surface\n",
    "c = 2.; # chord length of the wedge\n",
    "c_tw = 431.; # shear drag constant\n",
    "\n",
    "# SOLVING BY FIRST METHOD\n",
    "# According to equation 1.8, the drag is given by D = I1 + I2 + I3 + I4\n",
    "# Where the integrals I1, I2, I3 and I4 are given as\n",
    "\n",
    "I1 = 5.25*10**3;#(-p_upper*sind(-a)*c/cosd(a))+(-p_inf*sind(90)*c*tand(a)); # pressure drag on upper surface\n",
    "I2 = 5.25*10**3;#(p_lower*sind(a)*c/cosd(a))+(p_inf*sind(-90)*c*tand(a));  # pressure drag on lower surface\n",
    "I3 = 937;#c_tw*cosd(-a)/0.8*((c/cosd(a))**0.8);                  # skin friction drag on upper surface\n",
    "I4 = 937;#c_tw*cosd(-a)/0.8*((c/cosd(a))**0.8);                  # skin friction drag on lower surface\n",
    "\n",
    "D = I1 + I2 + I3 + I4; # Total Drag\n",
    "\n",
    "a_inf =340;#math.sqrt(1.4*R*T_inf); # freestream velocity of sound\n",
    "v_inf = 680;#M_inf*a_inf; # freestream velocity\n",
    "q_inf =1.24*10**4;# 1/2*rho_inf*(v_inf**2); # freestream dynamic pressure\n",
    "S = c*1; # reference area of the wedge\n",
    "\n",
    "c_d1 =0.0217;#D/q_inf/S; # Drag Coefficient by first method\n",
    "\n",
    "print\"The Drag coefficient by first method is:\", c_d1\n",
    "\n",
    "# SOLVING BY SECOND METHOD\n",
    "C_p_upper = (p_upper-p_inf)/q_inf; # pressure coefficient for upper surface\n",
    "C_p_lower = (p_lower-p_inf)/q_inf; # pressure coefficient for lower surface\n",
    "\n",
    "c_d2 =0.0217;# (1/c*2*((C_p_upper*tand(a))-(C_p_lower*tand(-a)))) + (2*c_tw/q_inf/cosd(a)*(2**0.8)/0.8/c);\n",
    "\n",
    "print\"The Drag coefficient by second method is:\", c_d2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E03 : Pg 32"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Xcp/C = 0.36\n"
     ]
    }
   ],
   "source": [
    "# All the quantities are expressed in SI units\n",
    "\n",
    "alpha = 4.; # angle of attack in degrees\n",
    "c_l = 0.85; # lift coefficient\n",
    "c_m_c4 = -0.09; # coefficient of moment about the quarter chord\n",
    "x_cp = 1./4. - (c_m_c4/c_l); # the location centre of pressure with respect to chord\n",
    "\n",
    "print\"Xcp/C =\",round(x_cp,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E05 : Pg 38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The velocity required in the wind tunnel is:mi/h 577.516788523\n",
      "The pressure required in the wind tunnel is:lb/sq.ft or atm 23848.4615385 11.2705394794\n"
     ]
    }
   ],
   "source": [
    "import math \n",
    "V1 = 550.; # velocity of Boeing 747 in mi/h\n",
    "h1 = 38000.; # altitude of Boeing 747 in ft\n",
    "P1 = 432.6; # Freestream pressure in lb/sq.ft\n",
    "T1 = 390.; # ambient temperature in R\n",
    "T2 = 430.; # ambient temperature in the wind tunnel in R\n",
    "c = 50.; # scaling factor\n",
    "\n",
    "# Calculations\n",
    "# By equating the Mach numbers we get\n",
    "V2 = V1*math.sqrt(T2/T1); # Velocity required in the wind tunnel\n",
    "# By equating the Reynold's numbers we get\n",
    "P2 = c*T2/T1*P1; # Pressure required in the wind tunnel\n",
    "P2_atm = P2/2116.; # Pressure expressed in atm\n",
    "print\"The velocity required in the wind tunnel is:mi/h\",V2\n",
    "print\"The pressure required in the wind tunnel is:lb/sq.ft or atm\",P2,P2_atm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E06 : Pg 39"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The lift to drag ratio L/D is equal to: 14.0744390238\n"
     ]
    }
   ],
   "source": [
    "import math \n",
    "v_inf_mph = 492.; # freestream velocity in miles per hour\n",
    "rho = 0.00079656; # aimbient air density in slugs per cubic feet\n",
    "W = 15000.; # weight of the airplane in lbs\n",
    "S = 342.6; # wing planform area in sq.ft\n",
    "C_d = 0.015; # Drag coefficient\n",
    "\n",
    "# Calculations\n",
    "v_inf_fps = v_inf_mph*(88./60.); # freestream velocity in feet per second\n",
    "\n",
    "C_l = 2.*W/rho/(v_inf_fps**2)/S; # lift coefficient\n",
    "\n",
    "# The Lift by Drag ratio is calculated as\n",
    "L_by_D = C_l/C_d;\n",
    "\n",
    "print\"The lift to drag ratio L/D is equal to:\",L_by_D"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E07 : Pg 42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum value of lift coefficient is Cl_max = 3.90490596176\n"
     ]
    }
   ],
   "source": [
    "import math \n",
    "v_stall_mph = 100.; # stalling speed in miles per hour\n",
    "rho = 0.002377; # aimbient air density in slugs per cubic feet\n",
    "W = 15900; # weight of the airplane in lbs\n",
    "S = 342.6; # wing planform area in sq.ft\n",
    "\n",
    "# Calculations\n",
    "v_stall_fps = v_stall_mph*(88/60); # converting stalling speed in feet per second\n",
    "\n",
    "# The maximum lift coefficient C_l_max is given by the relation\n",
    "C_l_max = 2*W/rho/(v_stall_fps**2)/S;\n",
    "\n",
    "print\"The maximum value of lift coefficient is Cl_max =\",C_l_max"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E08 : Pg 42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The initial upward acceleration is:a = ft/s2 0.46\n",
      "The maximum altitude that can be reached is:h =ft 485.062768784\n",
      "The maximum altitude that can be reached is:\n",
      "h = 485.062768784 ft\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "d = 30.; # inflated diameter of ballon in feet\n",
    "W = 800.; # weight of the balloon in lb\n",
    "g = 32.2; # acceleration due to gravity\n",
    "# part (a)\n",
    "rho_0 = 0.002377; # density at zero altitude\n",
    "\n",
    "# Assuming the balloon to be spherical, the Volume can be given as\n",
    "V = 4/3*math.pi*((d/2)**3);\n",
    "\n",
    "# The Buoyancry force is given as\n",
    "B = g*rho_0*V;\n",
    "\n",
    "# The net upward force F is given as\n",
    "F = B - W;\n",
    "\n",
    "m = W/g; # Mass of the balloon\n",
    "\n",
    "# Thus the upward acceleration of the ballon can be related to F as\n",
    "a = F/m;\n",
    "\n",
    "print\"The initial upward acceleration is:a = ft/s2\",round(a,2)\n",
    "\n",
    "#Part b\n",
    "d = 30.; # inflated diameter of ballon in feet\n",
    "W = 800.; # weight of the balloon in lb\n",
    "g = 32.2; # acceleration due to gravity\n",
    "rho_0 = 0.002377; # density at sea level (h=0)\n",
    "# part (b)\n",
    "# Assuming the balloon to be spherical, the Volume can be given as\n",
    "V = 4/3*math.pi*((d/2.)**3.);\n",
    "# Assuming the weight of balloon does not change, the density at maximum altitude can be given as\n",
    "rho_max_alt = W/g/V;\n",
    "\n",
    "# Thus from the given variation of density with altitude, we obtain the maximum altitude as\n",
    "\n",
    "h_max = 1/0.000007*(1-((rho_max_alt/rho_0)**(1/4.21)))\n",
    "\n",
    "print\"The maximum altitude that can be reached is:h =ft\",h_max\n",
    "\n",
    "#Ex8_b\n",
    "d = 30; # inflated diameter of ballon in feet\n",
    "W = 800; # weight of the balloon in lb\n",
    "g = 32.2; # acceleration due to gravity\n",
    "rho_0 = 0.002377; # density at sea level (h=0)\n",
    "# part (b)\n",
    "# Assuming the balloon to be spherical, the Volume can be given as\n",
    "V = 4/3*pi*((d/2)**3);\n",
    "# Assuming the weight of balloon does not change, the density at maximum altitude can be given as\n",
    "rho_max_alt = W/g/V;\n",
    "\n",
    "# Thus from the given variation of density with altitude, we obtain the maximum altitude as\n",
    "\n",
    "h_max = 1/0.000007*(1-((rho_max_alt/rho_0)**(1/4.21)))\n",
    "\n",
    "print\"The maximum altitude that can be reached is:\\nh =\",h_max,\"ft\""
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
