{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 18 - Refrigeration"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1: pg 612"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 18.1\n",
      " (a) The coefficient of performance of the refrigerator is  =   4.49\n",
      " (b) The mass flow of refrigerant/h is (kg) =  166.94\n",
      " (c) The mass flow of water required is (kg/h) =  579.74\n",
      "The answer is a bit different due to rounding off error in textbook\n"
     ]
    }
   ],
   "source": [
    "#pg 612\n",
    "print('Example 18.1');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the coefficient of performance\n",
    "# (b) the mass flow of the refrigerant\n",
    "# (c) the cooling water required by the condenser\n",
    "import math\n",
    "from math import log\n",
    "# given values\n",
    "P1 = 462.47;# pressure limit, [kN/m**2]\n",
    "P3 = 1785.90;# pressure limit, [kN/m**2]\n",
    "T2 = 273.+59;# entering saturation temperature, [K]\n",
    "T5 = 273.+32;# exit temperature of condenser, [K]\n",
    "d = 75*10**-3;# bore, [m]\n",
    "L = d;# stroke, [m]\n",
    "N = 8;# engine speed, [rev/s]\n",
    "VE = .8;# olumetric efficiency\n",
    "cpL = 1.32;# heat capacity of liquid, [kJ/kg K]\n",
    "c = 4.187;# heat capacity of water, [kj/kg K]\n",
    "\n",
    "# solution\n",
    "# from given table\n",
    "# at P1\n",
    "h1 = 231.4;# specific enthalpy, [kJ/kg]\n",
    "s1 = .8614;# specific entropy,[ kJ/kg K\n",
    "v1 = .04573;# specific volume, [m**3/kg]\n",
    "\n",
    "# at P3\n",
    "h3 = 246.4;# specific enthalpy, [kJ/kg]\n",
    "s3 = .8093;# specific entropy,[ kJ/kg K\n",
    "v3 = .04573;# specific volume, [m**3/kg]\n",
    "T3= 273+40;# saturation temperature, [K]\n",
    "h4 = 99.27;# specific enthalpy, [kJ/kg]\n",
    "# (a)\n",
    "s2 = s1;# specific entropy, [kJ/kg k]\n",
    "# using s2=s3+cpv*log(T2/T3)\n",
    "cpv = (s2-s3)/log(T2/T3);# heat capacity, [kj/kg k]\n",
    "\n",
    "# from Fig.18.8\n",
    "T4 = T3;\n",
    "h2 = h3+cpv*(T2-T3);# specific enthalpy, [kJ/kg]\n",
    "h5 = h4-cpL*(T4-T5);# specific enthalpy, [kJ/kg]\n",
    "h6 = h5;\n",
    "COP = (h1-h6)/(h2-h1);# coefficient of performance\n",
    "print ' (a) The coefficient of performance of the refrigerator is  =  ',round(COP,2)\n",
    "\n",
    "# (b)\n",
    "SV = math.pi/4*d**2*L;# swept volume of compressor/rev, [m**3]\n",
    "ESV = SV*VE*N*3600;# effective swept volume/h, [m**3]\n",
    "m = ESV/v1;# mass flow of refrigerant/h,[kg]\n",
    "print ' (b) The mass flow of refrigerant/h is (kg) = ',round(m,2)\n",
    "\n",
    "# (c)\n",
    "dT = 12;# temperature limit, [C]\n",
    "Q = m*(h2-h5);# heat transfer in condenser/h, [kJ]\n",
    "# using Q=m_dot*c*dT, so\n",
    "m_dot = Q/(c*dT);# mass flow of water required, [kg/h]\n",
    "print ' (c) The mass flow of water required is (kg/h) = ',round(m_dot,2)\n",
    "\n",
    "print 'The answer is a bit different due to rounding off error in textbook'\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2: pg 614"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 18.2\n",
      " (a) The mass flow of R401 is (kg/h) =  592.6\n",
      " (b) The dryness fraction of R401 at the entry to the evaporator is  =  0.244\n",
      " (c) The power to driving motor is (kW) =  5.86\n",
      " (d) The ratio of heat transferred from condenser to the power required to the motor is  =   4.74 :1\n"
     ]
    }
   ],
   "source": [
    "#pg 614\n",
    "print('Example 18.2');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the mass flow of R401\n",
    "# (b) the dryness fraction of  R401 at the entry to the evaporator\n",
    "# (c) the power of driving motor\n",
    "# (d) the ratio of heat transferred from condenser to the power required to the motor\n",
    "from math import log\n",
    "# given values\n",
    "P1 = 411.2;# pressure limit, [kN/m^2]\n",
    "P3 = 1118.9;# pressure limit, [kN/m^2]\n",
    "Q = 100*10**3;# heat transfer from the condenser,[kJ/h]\n",
    "T2 = 273+60;# entering saturation temperature, [K]\n",
    "\n",
    "# given\n",
    "# from given table\n",
    "# at P1\n",
    "h1 = 409.3;# specific enthalpy, [kJ/kg]\n",
    "s1 = 1.7431;# specific entropy,[ kJ/kg K\n",
    "\n",
    "# at P3\n",
    "h3 = 426.4;# specific enthalpy, [kJ/kg]\n",
    "s3 = 1.7192;# specific entropy,[ kJ/kg K\n",
    "T3 = 273.+50;# saturation temperature, [K]\n",
    "h4 = 265.5;# specific enthalpy, [kJ/kg]\n",
    "# (a)\n",
    "s2 = s1;# specific entropy, [kJ/kg k]\n",
    "# using s2=s3+cpv*log(T2/T3)\n",
    "cpv = (s2-s3)/log(T2/T3);# heat capacity, [kj/kg k]\n",
    "\n",
    "# from Fig.18.8\n",
    "h2 = h3+cpv*(T2-T3);# specific enthalpy, [kJ/kg]\n",
    "Qc = h2-h4;# heat transfer from condenser, [kJ/kg]\n",
    "mR401 = Q/Qc;# mass flow of R401, [kg]\n",
    "print ' (a) The mass flow of R401 is (kg/h) = ',round(mR401,1)\n",
    "\n",
    "# (b)\n",
    "hf1 = 219;# specific enthalpy, [kJ/kg]\n",
    "h5 = h4;\n",
    "# using h5=hf1+s5*(h1-hf1),so\n",
    "x5 = (h5-hf1)/(h1-hf1);# dryness fraction\n",
    "print ' (b) The dryness fraction of R401 at the entry to the evaporator is  = ',round(x5,3)\n",
    "\n",
    "# (c)\n",
    "P = mR401*(h2-h1)/3600/.7;# power to driving motor, [kW]\n",
    "print ' (c) The power to driving motor is (kW) = ',round(P,2)\n",
    "\n",
    "# (d)\n",
    "r = Q/3600./P;# ratio\n",
    "print ' (d) The ratio of heat transferred from condenser to the power required to the motor is  =  ',round(r,2),\":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
}