{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 10 : Steam Power Plant and Rankine Cycle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.1 Page No : 244"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Carnot efficiency of an engine when the steam is 0.87 dry in % is : 21.75\n",
      "Carnot efficiency of an engine when the steam is dry saturated in % is : 21.75\n",
      "Carnot efficiency of an engine when the steam is superheated in % is : 29.53\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# Variables\n",
    "p1 = 10;\t\t\t# in bar\n",
    "p2 = 0.5;\t\t\t# in bar\n",
    "T1 = 179.9;\t\t\t# in °C\n",
    "T1 = T1 +273;\t\t\t# in K\n",
    "T2 = 81.4;\t\t\t# in °C\n",
    "\n",
    "# Calculations and Results\n",
    "T2 = T2 + 273;\t\t\t# in K\n",
    "Eta_carnot = (T1 - T2)/T1*100;\t\t\t# in %\n",
    "print \"Carnot efficiency of an engine when the steam is 0.87 dry in %% is : %.2f\"%Eta_carnot\n",
    "print \"Carnot efficiency of an engine when the steam is dry saturated in %% is : %.2f\"%Eta_carnot\n",
    "\n",
    "T1 = T1 + 50;\t\t\t# in K\n",
    "Eta_carnot1 = (T1 - T2) / T1*100;\t\t\t# in %\n",
    "print \"Carnot efficiency of an engine when the steam is superheated in %% is : %.2f\"%Eta_carnot1\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.2 Page No : 247"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Heat supplied to the boiler in kJ/kg is 2900.05\n",
      "Work developed by turbine in kJ/kg is : 689.0\n",
      "Work absorbed by pump in kJ/kg is :  1.95\n",
      "Efficiency of flow system in % is : 23.69\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# Variables\n",
    "h1 = 3015.;\t    \t\t# in kJ/kg\n",
    "h2 = 2326.;\t    \t\t# in kJ/kg\n",
    "h3 = 113;\t\t    \t# in kJ/kg\n",
    "h4 = 114.95;\t\t\t# in kJ/kg\n",
    "\n",
    "# Calculations and Results\n",
    "Q = h1 - h4;\t\t\t# in kJ/kg\n",
    "print \"Heat supplied to the boiler in kJ/kg is\",Q\n",
    "\n",
    "W_T = h1 - h2;\t\t\t#/ in kJ/kg\n",
    "print \"Work developed by turbine in kJ/kg is : %.1f\"%W_T\n",
    "\n",
    "W_P = ( h1 - h3) - Q;\t\t\t# in kJ/kg\n",
    "print \"Work absorbed by pump in kJ/kg is : \",W_P\n",
    "\n",
    "Eta = (W_T - W_P)/Q*100;\t\t\t# in %\n",
    "print \"Efficiency of flow system in %% is : %.2f\"%Eta\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.3 Page No : 248"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rankine efficiency in % is : 20.09\n",
      "Percentage drop in Rankine efficiency in % is : 1.01\n",
      "Percentage increase in rankine efficiency in % is : 1.51\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# Variables\n",
    "phi_s = 6.583;\n",
    "phi_w = 1.091;\n",
    "phi_s1 = 6.504;\n",
    "C_p = 2.25;\n",
    "T_sat =179.9;       \t\t\t# in °C\n",
    "T_sat = T_sat + 273;\t\t\t# in K\n",
    "T_sup = T_sat + 50;\t\t\t# in K\n",
    "x2 = (phi_s - phi_w)/phi_s1;\n",
    "H1 = 2776.2; \t\t\t# in kJ/kg\n",
    "H_w2 = 340.6;\t\t\t# in kJ/kg\n",
    "L2 = 2305.;\n",
    "\n",
    "# Calculations and Results\n",
    "H2 = H_w2 + (x2 * L2);\t\t\t# in kJ/kg\n",
    "Eta_rankine = (H1 - H2)/(H1 - H_w2)*100;\t\t\t# in %\n",
    "print \"Rankine efficiency in %% is : %.2f\"%Eta_rankine\n",
    "\n",
    "phi_w1 = 2.138;\n",
    "x1 = 0.87;\n",
    "phi_s1 = 4.445;\n",
    "phi_w2 = 1.091;\n",
    "phi_s2 = 6.504;\n",
    "x2 = (phi_w1 + (x1 * phi_s1) - phi_w2) / phi_s2;\n",
    "H1 = 762.6 + (x1 * 2013.6);\t\t\t# in kJ/kg\n",
    "H2 = 340.6 + (x2 * 2305);\t\t\t# in kJ/kg\n",
    "Eta_rankine1 = (H1 - H2) / (H1 - H_w2)*100;\t\t\t# in %\n",
    "PerDropInRankine= (Eta_rankine - Eta_rankine1)/Eta_rankine * 100;\t\t\t# in %\n",
    "print \"Percentage drop in Rankine efficiency in %% is : %.2f\"%PerDropInRankine\n",
    "\n",
    "phi_s1 = 6.583;\n",
    "phi_w1 = 1.091;\n",
    "phi_s2 = 6.504;\n",
    "x2 = (phi_s1 + C_p * math.log(T_sup/T_sat) - phi_w1)/phi_s2;\n",
    "H_s1 = 2776.2;\n",
    "H1 = H_s1 + C_p * (T_sup - T_sat);\t\t\t# in kJ/kg\n",
    "H2 = 340.6 + (0.88 * 2305);\t\t\t# in kJ/kg\n",
    "H_w2 = 340.6;\n",
    "Eta_rankine2 = (H1 - H2) / (H1 - H_w2);\n",
    "Eta_rankine2 = Eta_rankine2 * 10**2;\t\t\t# in percentage\n",
    "PerIncInRank = ((Eta_rankine2 - Eta_rankine)/Eta_rankine2) * 100;\t\t\t# in percentage\n",
    "print \"Percentage increase in rankine efficiency in %% is : %.2f\"%PerIncInRank\n",
    "\n",
    "# rounding off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.4 Page No : 253"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Thermal effienciency of the cycle in % is : 15.70\n",
      "Heat removed in condenser in kJ/kg is : 2101.9\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# Variables\n",
    "H2 = 2776.2;\t\t\t# in kJ/kg\n",
    "p1 = 10.;\t\t\t# in bar\n",
    "p_2 = 1.;\t\t\t# in bar\n",
    "p_3 = 0.25;\t\t\t# in bar\n",
    "p_4 = p_3;\t\t\t# in bar\n",
    "# w = (H2 - H_2) + ((p_2 - p_3) * v_2);\t\t\t# work done in kJ/kg\n",
    "phi_2 = 6.583;\n",
    "phi_d2 = 1.303;\n",
    "L = 6.057;\n",
    "x_2 = (phi_2 - phi_d2) / L;\n",
    "H2_desh = 417.5 + (x_2* 2257.9);\t\t\t# in kJ/kg\n",
    "v_s = 1.694;\n",
    "\n",
    "# Calculations and Results\n",
    "v_2 = x_2 * v_s;\t\t\t# in m**3 per kg\n",
    "w = (H2 - H2_desh) + ((p_2 - p_3) * v_2);\t\t\t# in kJ/kg\n",
    "H4 = 282.7;\t\t\t# in kJ/kg\n",
    "H_w4 =H4;\t\t\t# in kJ/kg\n",
    "HeatSupplied = H2 - H4;\t\t\t# kJ/kg\n",
    "Eta_modifiedRankine = w / HeatSupplied*100;\t\t\t# in %\n",
    "print \"Thermal effienciency of the cycle in %% is : %.2f\"%Eta_modifiedRankine\n",
    "\n",
    "HeatRemoved = HeatSupplied - w;\t\t\t# in kJ/kg\n",
    "print \"Heat removed in condenser in kJ/kg is : %.1f\"%HeatRemoved\n",
    "\n",
    "# rounding off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.13 Page No : 256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Work output per kg in kW is :  1110.0\n",
      "flow rate in kg/hr is : 3567.57\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# Variables\n",
    "Q = 1100;\t\t\t# in kW\n",
    "m = 1;    \t\t\t# in kg\n",
    "p1 = 15;\t\t\t# in bar\n",
    "p1 = p1 * 10**5;\t\t\t# in Pa\n",
    "p1 = p1 * 10**-3;\t\t\t# in kPa\n",
    "p2 = 0.05 * 10**2;\t\t\t# in kPa\n",
    "v1 = 0.16;\t\t\t# m**3 per kg\n",
    "v2 = 26;\t\t\t# in m**3 per kg\n",
    "V1 = 110;\t\t\t# in m per s\n",
    "V2 = 120;\t\t\t# in m per s\n",
    "u1 = 2935;\t\t\t# in kJ per kg\n",
    "u2 = 1885;\t\t\t# in kJ per kg\n",
    "g = 9.8;\n",
    "z1 = 0;\n",
    "z2 = 0; \n",
    "\n",
    "# Calculations and Results\n",
    "# Formula Q-W= m*{(u2 - u1) + (p2*v2-p1*v1)+1/2*(V2**2-V1**2)+g*(z2 - z1)}\n",
    "W =Q-m*((u2 - u1) + (p2*v2-p1*v1)+1./2*(V2**2-V1**2)+g*(z2 - z1));\t\t\t# in kW\n",
    "print \"Work output per kg in kW is : \",W\n",
    "\n",
    "SteamFlowRate = Q / W;\t\t\t# in kg/sec\n",
    "SteamFlowRate = SteamFlowRate * 3600;\t\t\t# in kg per hr\n",
    "print  \"flow rate in kg/hr is : %.2f\"%SteamFlowRate\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.14 Page No : 257"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Ratio of mass flow rate of cooling water to condensing steam is : 36.24\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# Variables\n",
    "h_sen = 191.9;\t\t\t# in kJ/kg\n",
    "L = 2392;\t\t\t# in kJ/kg\n",
    "x = 0.95;\n",
    "t_o = 35;\t\t\t# in °C\n",
    "t_i = 20;\t\t\t# in °C\n",
    "C = 4.18;\n",
    "\n",
    "# Calculations\n",
    "H_totalwet =  h_sen + (x * L);\t\t\t#in kJ/kg\n",
    "# m_steam * (H_totalwet - h_sen) = m_water * C * (t_o - t_i)\n",
    "msBYmw = (H_totalwet - h_sen) / ( C * (t_o - t_i));\t\t\t#\n",
    "\n",
    "# Results\n",
    "print \"The Ratio of mass flow rate of cooling water to condensing steam is : %.2f\"%msBYmw\n",
    "\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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}