{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 11 - The steam engine"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1: pg 326"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.1\n",
      " (a) The bore of the cylinder is (mm) =  239.0\n",
      " (b) The piston stroke is (mm) =  299.0\n",
      " (c) The speed of the engine is (rev/min) =  301.1\n"
     ]
    }
   ],
   "source": [
    "#pg 326\n",
    "print('Example 11.1')\n",
    "import math\n",
    "#  aim : To determine the \n",
    "# (a) bore of the cylinder\n",
    "# (b) piston stroke\n",
    "# (c) speed of the engine\n",
    "\n",
    "#  Given values\n",
    "P_req = 60.;# power required to develop, [kW]\n",
    "P = 1.25;# boiler pressure, [MN/m^2]\n",
    "Pb = .13;# back pressure, [MN/m^2]\n",
    "cut_off = .3;# [stroke]\n",
    "k = .82;# diagram factor\n",
    "n = .78;# mechanical efficiency\n",
    "LN = 3.;# mean piston speed, [m/s]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "r = 1/cut_off;# expansion ratio\n",
    "Pm = P/r*(1+math.log(r))-Pb;# mean effective pressure, [MN/m^2]\n",
    "P_ind = P_req/n;# Actual indicated power developed, [kW]\n",
    "P_the = P_ind/k;# Theoretical indicated power developed, [kW]\n",
    "\n",
    "#  using indicated_power=Pm*LN*A\n",
    "#  Hence\n",
    "A = P_the/(Pm*LN)*10**-3;# piston area,[m^2]\n",
    "d = math.sqrt(4*A/math.pi)*10**3;# bore ,[mm]\n",
    "print ' (a) The bore of the cylinder is (mm) = ',round(d)\n",
    "\n",
    "# (b)\n",
    "# given that stroke is 1.25 times bore\n",
    "L = 1.25*d;# [mm]\n",
    "print ' (b) The piston stroke is (mm) = ',round(L)\n",
    "\n",
    "# (c)\n",
    "# LN=mean piston speed, where L is stroke in meter and N is 2*rev/s,(since engine is double_acting)\n",
    "#  hence\n",
    "rev_per_sec = LN/(2*L*10**-3);# [rev/s]\n",
    "\n",
    "rev_per_min = rev_per_sec*60;# [rev/min]\n",
    "print ' (c) The speed of the engine is (rev/min) = ',round(rev_per_min,1)\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2: pg 328"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.2\n",
      " (a) The diameter of the cylinder is (mm) =  189.0\n",
      " (b) The piston stroke is (mm) =  227.2\n",
      " (c) The actual steam consumption/h is (kg) =  514.3\n",
      "     The indicated thermal efficiency is (percent) =  6.8\n",
      "The answers are a bit different due to rounding off error in textbook\n"
     ]
    }
   ],
   "source": [
    "#pg 328\n",
    "print('Example 11.2')\n",
    "import math\n",
    "#  aim : To determine the \n",
    "#  (a) the diameter of the cylinder\n",
    "#  (b) piston stroke\n",
    "#  (c) actual steam consumption and indicated thermal efficiency\n",
    "\n",
    "#  Given values\n",
    "P = 900.;# inlet pressure, [kN/m^2]\n",
    "Pb = 140.;#  exhaust pressure, [kN/m^2]\n",
    "cut_off =.4;# [stroke]\n",
    "k = .8;# diagram factor\n",
    "rs = 1.2;# stroke to bore ratio\n",
    "N = 4.;# engine speed, [rev/s]\n",
    "ip = 22.5;# power output from the engine, [kW]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "r = 1/cut_off;# expansion ratio\n",
    "Pm = P/r*(1+math.log(r))-Pb;# mean effective pressure, [kN/m^2]\n",
    "Pm = Pm*k;# actual mean effective pressure, [kN/m^2]\n",
    "\n",
    "# using ip=Pm*L*A*N\n",
    "# and L=r*d; where L is stroke and d is bore\n",
    "d = (ip/(Pm*rs*math.pi/4.*2*N))**(1./3);# diameter of the cylinder, [m]\n",
    "\n",
    "print ' (a) The diameter of the cylinder is (mm) = ',round(d*1000)\n",
    "\n",
    "# (b)\n",
    "L = rs*d;# stroke, [m]\n",
    "print ' (b) The piston stroke is (mm) = ',round(L*1000,1)\n",
    "\n",
    "# (c)\n",
    "SV = math.pi/4*d**2*L;# stroke volume, [m^3]\n",
    "V = SV*cut_off*2*240*60;# volume of steam consumed per  hour, [m^3]\n",
    "v = .2148;# specific volume at 900 kN/m^2, [m^3/kg]\n",
    "SC = V/v;# steam consumed/h, [kg]\n",
    "ASC = 1.5*SC;# actual steam consumption/h, [kg]\n",
    "print ' (c) The actual steam consumption/h is (kg) = ',round(ASC,1)\n",
    "\n",
    "m_dot = ASC/3600.;# steam consumption,[kg/s] \n",
    "# from steam table\n",
    "hg = 2772.1;# specific enthalpy of inlet steam, [kJ/kg]\n",
    "hfe = 458.4;# specific liquid enthalpy at exhaust pressure, [kJ/kg]\n",
    "\n",
    "ITE = ip/(m_dot*(hg-hfe));# indicated thermal efficiency\n",
    "print '     The indicated thermal efficiency is (percent) = ',round(ITE*100,1)\n",
    "\n",
    "print 'The answers are a bit different due to rounding off error in textbook'\n",
    "#  End\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3: pg 330"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.3\n",
      " (a) The diagram factor is  =  0.85\n",
      " (b) The indicated thermal efficiency is (percent) =  15.0\n"
     ]
    }
   ],
   "source": [
    "#pg 330\n",
    "print('Example 11.3');\n",
    "\n",
    "#  aim : To determine\n",
    "#  (a) the diagram factor\n",
    "#  (b) the indicated thermal efficiency of the engine\n",
    "import math\n",
    "# given values\n",
    "d = 250.*10**-3;# cylinder diameter, [m]\n",
    "L = 375.*10**-3;# length of stroke, [m]\n",
    "P = 1000.;# steam pressure , [kPa]\n",
    "x = .96;# dryness fraction of steam\n",
    "Pb = 55;# exhaust pressure, [kPa]\n",
    "r = 6.;# expansion ratio\n",
    "ip = 45.;# indicated power developed, [kW]\n",
    "N = 3.5;# speed of engine, [rev/s]\n",
    "m = 460.;# steam consumption, [kg/h]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "Pm = P/r*(1+math.log(r))-Pb;# [kN/m**3]\n",
    "A = math.pi*(d)**2/4;# area, [m**2]\n",
    "tip = Pm*L*A*N*2;# theoretical indicated power, [kW]\n",
    "k = ip/tip;# diagram factor\n",
    "print ' (a) The diagram factor is  = ',round(k,2)\n",
    "\n",
    "# (b)\n",
    "# from steam table at 1 MN/m**2\n",
    "hf = 762.6;# [kJ/kg]\n",
    "hfg = 2013.6;# [kJ/kg]\n",
    "# so \n",
    "h1 = hf+x*hfg;# specific enthalpy of steam at 1MN/m**2, [kJ/kg]\n",
    "# minimum specific enthalpy in engine at 55 kPa \n",
    "hf = 350.6;# [kJ/kg]\n",
    "# maximum energy available in engine is\n",
    "h = h1-hf;# [kJ/kg]\n",
    "ITE = ip/(m*h/3600)*100;# indicated thermal efficiency\n",
    "print ' (b) The indicated thermal efficiency is (percent) = ',round(ITE)\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4: pg 333"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.4\n",
      "The steam consumption is (kg/h) =  213.0\n"
     ]
    }
   ],
   "source": [
    "#pg 333\n",
    "print('Example 11.4');\n",
    "\n",
    "# aim : To determine\n",
    "# steam consumption\n",
    "\n",
    "# given values\n",
    "P1 = 11.;# power, [kW]\n",
    "m1 = 276.;# steam use/h when developing power P1,[kW]\n",
    "ip = 8.;# indicated power output, [kW]\n",
    "B = 45.;# steam used/h at no load, [kg]\n",
    "\n",
    "# solution\n",
    "# using graph of Fig.11.9 \n",
    "A = (m1-B)/P1;# slop of line, [kg/kWh]\n",
    "W = A*ip+B;# output, [kg/h]\n",
    "#results\n",
    "print 'The steam consumption is (kg/h) = ',W\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5: pg 338"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.5\n",
      " (a) The intermediate pressure is (kN/m^2) =  455.0\n",
      " (b) The indicated power is (kW) =  110.5\n",
      " (c) The steam consumption of the engine is (kg/h) =  1016.0\n"
     ]
    }
   ],
   "source": [
    "#pg 338\n",
    "print('Example 11.5');\n",
    "from scipy.optimize import brentq\n",
    "#  aim : To determine\n",
    "# (a) the intermediate pressure\n",
    "# (b) the indicated power output\n",
    "# (c) the steam consumption of the engine\n",
    "import math\n",
    "# given values\n",
    "P1 = 1400.;# initial pressure, [kN/m**2]\n",
    "x = .9;# dryness fraction\n",
    "P5 = 35.;# exhaust pressure\n",
    "k = .8;# diagram factor of low-pressure cylindaer\n",
    "L = 350.*10**-3;# stroke of both the cylinder, [m]\n",
    "dhp = 200.*10**-3;# diameter of high pressure cylinder, [m]\n",
    "dlp = 300.*10**-3;# diameter of low-pressure cylinder, [m]\n",
    "N = 300.;# engine speed, [rev/min]\n",
    "\n",
    "# solution\n",
    "# taking reference Fig.11.13\n",
    "Ahp = math.pi/4*dhp**2;# area of high-pressure cylinder, [m**2]\n",
    "Alp = math.pi/4*dlp**2;# area of low-pressure cylinder, [m**2]\n",
    "# for equal initial piston loads\n",
    "# (P1-P7)Ahp=(P7-P5)Alp\n",
    "def f(P7):\n",
    "\treturn (P1-P7)*Ahp - (P7-P5)*Alp\n",
    "#deff('[x]=f(P7)','x=(P1-P7)*Ahp-(P7-P5)*Alp');\n",
    "P7 = brentq(f,0,1000);# intermediate pressure, [kN/m**2]\n",
    "print ' (a) The intermediate pressure is (kN/m^2) = ',P7\n",
    "\n",
    "# (b)\n",
    "V6 = Ahp*L;# volume of high-pressure cylinder, [m**3]\n",
    "P2 = P1;\n",
    "P6 = P7;\n",
    "# using P2*V2=P6*V6\n",
    "V2 = P6*V6/P2; # [m**3]\n",
    "V1 = Alp*L;# volume of low-pressure cylinder, [m**3]\n",
    "R = V1/V2;# expansion ratio\n",
    "Pm = P1/R*(1+math.log(R))-P5;# effective pressure of low-pressure cylinder, [kn/m**2]\n",
    "Pm = k*Pm;# actual effective pressure, [kN/m**2]\n",
    "ip = Pm*L*Alp*N*2/60.;# indicated power, [kW]\n",
    "print ' (b) The indicated power is (kW) = ',round(ip,1)\n",
    "\n",
    "# (c) \n",
    "COV = V1/ R;# cut-off  volume in high-pressure cylinder, [m**3]\n",
    "V = COV*N*2*60;# volume of steam admitted/h\n",
    "# from steam table\n",
    "vg = .1407;# [m**3/kg]\n",
    "AV = x*vg;# specific volume of admission steam, [m**3/kg]\n",
    "m = V/AV;# steam consumption, [kg/h]\n",
    "print ' (c) The steam consumption of the engine is (kg/h) = ',round(m)\n",
    "\n",
    "#  End \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6: pg 340"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.6\n",
      " (a) The indicated power is (kW) =  440.0\n",
      " (b) The diameter of high-pressure cylinder is (mm) =  383.0\n",
      " (c) The intermediate opressure is (kN/m^2) =  338.0\n"
     ]
    }
   ],
   "source": [
    "#pg 340\n",
    "print('Example 11.6');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the indicated power output\n",
    "# (b) the diameter of high-pressure cylinder of the engine\n",
    "# (c) the intermediate pressure\n",
    "import math\n",
    "from math import sqrt, exp, log, pi\n",
    "# given values\n",
    "P = 1100.;# initial pressure, [kN/m**2]\n",
    "Pb = 28.;# exhaust pressure\n",
    "k = .82;# diagram factor of low-pressure cylindaer\n",
    "L = 600.*10**-3;# stroke of both the cylinder, [m]\n",
    "dlp = 600.*10**-3;# diameter of low-pressure cylinder, [m]\n",
    "N = 4.;# engine speed, [rev/s]\n",
    "R = 8.;# expansion ratio\n",
    "\n",
    "# solution\n",
    "# taking reference Fig.11.13\n",
    "# (a)\n",
    "Pm = P/R*(1+log(R))-Pb;# effective pressure of low-pressure cylinder, [kn/m**2]\n",
    "Pm = k*Pm;# actual effective pressure, [kN/m**2]\n",
    "Alp = pi/4*dlp**2;# area of low-pressure cylinder, [m**2]\n",
    "ip = Pm*L*Alp*N*2;# indicated power, [kW]\n",
    "print ' (a) The indicated power is (kW) = ',round(ip)\n",
    "\n",
    "# (b)\n",
    "# work done by both cylinder is same as area of diagram\n",
    "w = Pm*Alp*L;# [kJ]\n",
    "W = w/2;# work done/cylinder, [kJ]\n",
    "V2 = Alp*L/8;# volume, [m63]\n",
    "P2 = P;# [kN/m**2]\n",
    "#  using area A1267=P2*V2*log(V6/V2)=W\n",
    "V6 = V2*exp(W/(P2*V2));# intermediate volume, [m**3]\n",
    "# using Ahp*L=%pi/4*dhp**2*L=V6\n",
    "dhp = sqrt(V6*4/L/pi);# diameter of high-pressure cylinder, [m]\n",
    "print ' (b) The diameter of high-pressure cylinder is (mm) = ',round(dhp*1000)\n",
    "\n",
    "# (c)\n",
    "# using P2*V2=P6*V6\n",
    "P6 = P2*V2/V6; # intermediate pressure, [kN/m**2]\n",
    "print ' (c) The intermediate opressure is (kN/m^2) = ',round(P6)\n",
    "\n",
    "#  End \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7: pg 342"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.7\n",
      " (a) The engine speed is (rev/s) =  6.52\n",
      " (b) The diameter of the high pressure cylinder is (mm) =  179.0\n"
     ]
    }
   ],
   "source": [
    "#pg 342\n",
    "print('Example 11.7');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) The speed of the engine\n",
    "# (b) the diameter of the high pressure cylinder\n",
    "import math\n",
    "from math import sqrt,log, exp,pi\n",
    "# given values\n",
    "ip = 230.;# indicated power, [kW]\n",
    "P = 1400.;# admission pressure, [kN/m**2]\n",
    "Pb = 35.;# exhaust pressure, [kN/m**2]\n",
    "R = 12.5;# expansion ratio\n",
    "d1 = 400.*10**-3;# diameter of low pressure cylinder, [m]\n",
    "L = 500.*10**-3;# stroke of both the cylinder, [m]\n",
    "k = .78;# diagram factor\n",
    "rv = 2.5;# expansion ratio of high pressure cylinder\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "Pm = P/R*(1+log(R))-Pb;# mean effective pressure in low pressure cylinder, [kN/m**2]\n",
    "ipt = ip/k;# theoretical indicated power, [kw]\n",
    "# using ip=Pm*L*A*N\n",
    "A = pi/4*d1**2;# area , [m**2]\n",
    "N = ipt/(Pm*L*A*2);# speed, [rev/s]\n",
    "print ' (a) The engine speed is (rev/s) = ',round(N,2)\n",
    "\n",
    "# (b)\n",
    "Vl = A*L;# volume of low pressure cylinder, [m**3]\n",
    "COV = Vl/R;# cutt off volume of hp cylinder, [m**3]\n",
    "V = COV*rv;# total volume, [m**3]\n",
    "\n",
    "#  V = %pi/4*d**2*L, so\n",
    "d = sqrt(4*V/pi/L);# diameter of high pressure cylinder, [m]\n",
    "print ' (b) The diameter of the high pressure cylinder is (mm) = ',round(d*1000)\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8: pg 344"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.8\n",
      " (a) The actual mean effective pressure referred to LP cylinder is (kN/m^2) =  234.1\n",
      "     The hypothetical mean effective pressure referred to LP cylinder is (kN/m^2) =  287.0\n",
      " (b) The overall diagram factor is  =  0.814\n",
      " (c) The indicated power is  (kW) =  143.0\n"
     ]
    }
   ],
   "source": [
    "#pg 344\n",
    "print('Example 11.8');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the actual and hypothetical mean effective pressures referred to the low-pressure cylinder\n",
    "# (b) the overall diagram factor\n",
    "# (c) the indicated power \n",
    "import  math\n",
    "from math import pi,sqrt,log\n",
    "# given values\n",
    "P = 1100.;# steam supply pressure, [kN/m**2]\n",
    "Pb = 32.;# back pressure, [kN/m**2]\n",
    "d1 = 300.*10**-3;# cylinder1 diameter, [m]\n",
    "d2 = 600.*10**-3;# cylinder2 diameter, [m]\n",
    "L = 400.*10**-3;# common stroke of both cylinder, [m]\n",
    "\n",
    "A1 = 12.5;#  average area of indicated diagram for HP, [cm**2]\n",
    "A2 = 11.4;#  average area of indicated diagram for LP, [cm**2]\n",
    "\n",
    "P1 = 270.;# indicator calibration, [kN/m**2/ cm]\n",
    "P2 = 80.;# spring calibration, [kN/m**2/ cm]\n",
    "N = 2.7;# engine speed, [rev/s]\n",
    "l = .75;# length of both diagram, [m]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "# for HP cylinder\n",
    "Pmh = P1*A1/7.5;# [kN/m**2]\n",
    "F = Pmh*pi/4*d1**2;# force on HP, [kN]\n",
    "PmH = Pmh*(d1/d2)**2;# pressure referred to LP cylinder, [kN/m**2]\n",
    "PmL = P2*A2/7.5;# pressure for LP cylinder, [kN/m**2]\n",
    "PmA = PmH+PmL;# actual effective pressure referred to LP cylinder, [kN/m**2]\n",
    "\n",
    "Ah = pi/4*d1**2;# area of HP cylinder, [m**2]\n",
    "Vh = Ah*L;# volume of HP cylinder, [m**3]\n",
    "CVh = Vh/3;# cut-off volume of HP cylinder, [m**3]\n",
    "Al = pi/4*d2**2;# area of LP cylinder, [m**2]\n",
    "Vl = Al*L;# volume of LP cylinder, [m**3]\n",
    "\n",
    "R = Vl/CVh;# expansion ratio\n",
    "Pm = P/R*(1+log(R))-Pb;# hypothetical mean effective pressure referred to LP cylinder, [kN/m**2]\n",
    "\n",
    "print ' (a) The actual mean effective pressure referred to LP cylinder is (kN/m^2) = ',PmA\n",
    "print '     The hypothetical mean effective pressure referred to LP cylinder is (kN/m^2) = ',round(Pm)\n",
    "\n",
    "# (a)\n",
    "ko = PmA/Pm;# overall diagram factor\n",
    "print ' (b) The overall diagram factor is  = ',round(ko,3)\n",
    "\n",
    "# (c) \n",
    "ip = PmA*L*Al*N*2;# indicated power, [kW]\n",
    "print ' (c) The indicated power is  (kW) = ',round(ip)\n",
    "\n",
    "#   End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9: pg 345"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 11.9\n",
      " (a) The actual mean effective pressure referred to LP cylinder is (kN/m^2) =  219.6\n",
      "      The hypothetical mean effective pressure referred to LP cylinder is (kN/m^2) =  326.0\n",
      " (b) The overall diagram factor is  =   0.673\n",
      " (c) The pecentage of the total indicated power developed in HP cylinder is (percent) =  29.9\n",
      "     The pecentage of the total indicated power developed in IP cylinder is (percent) =  30.1\n",
      "     The pecentage of the total indicated power developed in LP cylinder is (percent) =  40.1\n"
     ]
    }
   ],
   "source": [
    "#pg 345\n",
    "print('Example 11.9');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the actual and hypothetical mean effective pressures referred to the low-pressure cylinder\n",
    "# (b) the overall diagram factor\n",
    "# (c) the pecentage of the total indicated power developed in each cylinder\n",
    "from math import pi,log,sqrt\n",
    "# given values\n",
    "P = 1400.;# steam supply pressure, [kN/m**2]\n",
    "Pb = 20.;# back pressure, [kN/m**2]\n",
    "Chp = .6;# cut-off in HP cylinder, [stroke]\n",
    "dh = 300.*10**-3;# HP diameter, [m]\n",
    "di = 500.*10**-3;# IP diameter, [m]\n",
    "dl = 900.*10**-3;# LP diameter, [m]\n",
    "\n",
    "Pm1 = 590.;# actual pressure of HP cylinder, [kN/m**2]\n",
    "Pm2 = 214.;# actual pressure of IP cylinder, [kN/m**2]\n",
    "Pm3 = 88.;# actual pressure of LP cylinder, [kN/m**2]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "# for HP cylinder\n",
    "PmH = Pm1*(dh/dl)**2;# PmH referred to LP cylinder, [kN/m**2]\n",
    "# for IP cylinder\n",
    "PmI = Pm2*(di/dl)**2;# PmI referred to LP cylinder, [kN/m**2]\n",
    "PmA = PmH+PmI+Pm3;# actual mean effective pressure referred to LP cylinder, [kN/m**2]\n",
    "\n",
    "R = dl**2/(dh**2*Chp);# expansion ratio\n",
    "Pm = P/R*(1+log(R))-Pb;# hypothetical mean effective pressure referred to LP cylinder, [kN/m**2]\n",
    "\n",
    "print ' (a) The actual mean effective pressure referred to LP cylinder is (kN/m^2) = ',round(PmA,2)\n",
    "print '      The hypothetical mean effective pressure referred to LP cylinder is (kN/m^2) = ',round(Pm)\n",
    "\n",
    "# (b)\n",
    "ko = PmA/Pm;# overall diagram factor\n",
    "print ' (b) The overall diagram factor is  =  ',round(ko,3)\n",
    "\n",
    "# (c)\n",
    "HP = PmH/PmA*100;# %age of indicated power developed in HP\n",
    "IP = PmI/PmA*100; # %age of indicated power developed in IP\n",
    "LP = Pm3/PmA*100; # %age of indicated power developed in LP\n",
    "print ' (c) The pecentage of the total indicated power developed in HP cylinder is (percent) = ',round(HP,1)\n",
    "print '     The pecentage of the total indicated power developed in IP cylinder is (percent) = ',round(IP,1)\n",
    "print '     The pecentage of the total indicated power developed in LP cylinder is (percent) = ',round(LP,1)\n",
    "\n",
    "#   End\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}