{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 10 - Refrigeration and Air Conditioning"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - pg 10.42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power rating of the compressor-motor unit if the cop of the plant is 2.1 is (kW) =  40.4\n"
     ]
    }
   ],
   "source": [
    "#pg 10.42\n",
    "#calculate the Power rating of compressor-motor\n",
    "#Input data\n",
    "T1=273.;#The temperature of ice in K\n",
    "T2=298.;#Temperature of water at room in K\n",
    "COP=2.1;#Cop of the plant\n",
    "ne=90.;#Overall electrochemical efficiency in percentage\n",
    "w=15.;#Weight of ice produced per day in tonnes\n",
    "cw=4.187;#Specific heat of water in kJ/kg degrees celcius\n",
    "Li=335.;#Latent heat of ice in kJ/kg\n",
    "mi=1.;#Mass of ice produced at 0 degrees celcius\n",
    "\n",
    "#Calculations\n",
    "m=(w*1000.)/(24*60);#Mass of ice produced in kg/min\n",
    "h=(mi*cw*(T2-T1))+Li;#Heat extracted from 1kg of water at 25 degrees celcius to produce 1kg of ice at 0 degrees celcius in kJ/kg\n",
    "Q=m*h;#Total heat extracted in kJ\n",
    "W=Q/COP;#Work done by the compressor in kJ/kg\n",
    "P=W/(60.*(ne/100));#Power of compressor in kW\n",
    "\n",
    "#Output\n",
    "print 'Power rating of the compressor-motor unit if the cop of the plant is 2.1 is (kW) = ',round(P,1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 - pg 10.43"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The refrigeration capacity of the plant is (TR) =  0.541\n"
     ]
    }
   ],
   "source": [
    "#pg 10.43\n",
    "#calculate the refrigeration capacity\n",
    "#Input data\n",
    "m=400.;#Mass of fruits supplied to a cold storage in kg\n",
    "T1=293.;#Temperature at which fruits are stored in K\n",
    "T2=268.;#Temperature of cold storage in K\n",
    "t=8.;#The time untill which fruits are cooled in hours\n",
    "hfg=105.;#Latent heat of freezing in kJ/kg\n",
    "Cf=1.25;#Specific heat of fruit\n",
    "TR=210.;#One tonne refrigeration in kJ/min\n",
    "\n",
    "#Calculations\n",
    "Q1=m*Cf*(T1-T2);#Sensible heat in kJ\n",
    "Q2=m*hfg;#Latent heat of freezing in kJ\n",
    "Q=Q1+Q2;#Heat removed from fruits in 8 hrs\n",
    "Th=(Q1+Q2)/(t*60);#Total heat removed in one minute in kJ/kg\n",
    "Rc=Th/TR;#Refrigerating capacity of the plant in TR\n",
    "\n",
    "#Output\n",
    "print 'The refrigeration capacity of the plant is (TR) = ',round(Rc,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 - pg 10.44"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)COP of the machine when it is operated as a refrigerating machine is  5.0\n",
      "(b)COP when it is operated as heat pump is  6.0\n",
      "(c)COP or efficiency of the Heat engine is (percent) =  16.67\n"
     ]
    }
   ],
   "source": [
    "#pg 10.44\n",
    "#calculate the COP of machine in all cases\n",
    "#Input data\n",
    "T1=300.;#The maximum temperature at which carnot cycle operates in K\n",
    "T2=250.;#The minimum temperature at which carnot cycle operates in K\n",
    "\n",
    "#Calculations\n",
    "COPr=T2/(T1-T2);#COP of the refrigerating machine\n",
    "COPh=T1/(T1-T2)#COP of heat pump\n",
    "n=((T1-T2)/T1)*100;#COP or efficiency of the heat engine in percentage\n",
    "\n",
    "#Output data\n",
    "print '(a)COP of the machine when it is operated as a refrigerating machine is ',COPr\n",
    "print '(b)COP when it is operated as heat pump is ',COPh\n",
    "print '(c)COP or efficiency of the Heat engine is (percent) = ',round(n,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 - pg 10.45"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Capacity of the plant is (TR) =  48.31\n",
      "(b)Time taken to achieve cooling is (hours) =  10.67\n"
     ]
    }
   ],
   "source": [
    "#pg 10.45\n",
    "#calculate the capacity of the plant and time taken\n",
    "#Input data\n",
    "m=20000.;#The storage capacity of fish in a storage plant in kg\n",
    "T1=298.;#Supplied temperature of fish in K\n",
    "T2=263.;#Temperature of cold storage in which fish are stored in K\n",
    "T3=268.;#Freezing point of fish in K\n",
    "Caf=2.95;#Specific heat of fish above freezing point in kJ/kg K\n",
    "Cbf=1.25;#Specific heat of below freezing point in kJ/kg K\n",
    "W=75.;#Work required by the plant in kW\n",
    "TR=210.;#One tonne refrigeration in kJ/min\n",
    "hfg=230.;#Latent heat of fish in kJ/kg\n",
    "\n",
    "#Calculations\n",
    "COPr=T2/(T1-T2);#COP of reversed carnot cycle\n",
    "COPa=0.3*COPr;#Given that actual COP is 0.3 times of reversed COP\n",
    "Hr=(COPa*W)*60;#Heat removed by the plant in kJ/min\n",
    "C=Hr/TR;#Capacity of the plant in TR\n",
    "Q1=m*Caf*(T1-T3);#Heat removed from the fish above freezing point in kJ\n",
    "Q2=m*Cbf*(T3-T2);#Heat removed from fish below freezing point in kJ\n",
    "Q3=m*hfg;#Total latent heat of the fish in kJ\n",
    "Q=Q1+Q2+Q3;#Total heat removed by the plant in kJ\n",
    "T=(Q/Hr)/60;#Time taken to achieve cooling in hrs \n",
    "\n",
    "#Output data\n",
    "print '(a)Capacity of the plant is (TR) = ',round(C,2)\n",
    "print '(b)Time taken to achieve cooling is (hours) = ',round(T,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5 - pg 10.46"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Theoretical COP for a CO2 machine working at given temperatures =  4.39\n",
      "The answer in textbook is wrong. Please check using a calculator\n"
     ]
    }
   ],
   "source": [
    "#pg 10.46\n",
    "#calculate the Theoretical COP\n",
    "#Input data\n",
    "T2=298.;#Maximum temperature at which CO2 machine works in K\n",
    "T1=268.;#Minimum temperature at which CO2 machine works in K\n",
    "sf1=-0.042;#Liquid entropy at 268 K in kJ/kg K\n",
    "hfg1=245.3;#Latent heat of gas at 268 K in kJ/kg\n",
    "sf2=0.251;#Liquid entropy in kJ/kg K\n",
    "hfg2=121.4;#Latent heat of gas at 298 K in kJ/kg\n",
    "hf1=-7.54;#Liquid enthalpy at 268 K in kJ/kg\n",
    "hf2=81.3;#Liquid enthalpy at 298 K in kJ/kg\n",
    "hf3=81.3;#Enthalpy at point 3 in graph in kJ/kg\n",
    "\n",
    "#Calculations\n",
    "s2=sf2+(hfg2/T2);#Entropy at point 2 from the graph in kJ/kg K\n",
    "x1=(s2-sf1)/(hfg1/T1);#Dryness fraction at point 1\n",
    "h1=hf1+(x1*hfg1);#Enthalpy at point 1 in kJ/kg\n",
    "h2=hf2+hfg2;#Enthalpy at point 2 in kJ/kg\n",
    "COP=(h1-hf3)/(h2-h1);#Coefficient of performance for a CO2 machine working at given temperatures\n",
    "\n",
    "#Output data\n",
    "print 'Theoretical COP for a CO2 machine working at given temperatures = ',round(COP,2)\n",
    "print 'The answer in textbook is wrong. Please check using a calculator'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6 - pg 10.48"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The capacity of refrigerator is (TR) =  24.0\n"
     ]
    }
   ],
   "source": [
    "#pg 10.48\n",
    "#calculate the capacity of refrigerator\n",
    "#Input data\n",
    "T2=298.;#Maximum temperature at which ammonia refrigerating system works in K\n",
    "T1=263.;#Minimum temperature at which ammonia refrigerating system works in K\n",
    "mf=5.;#Fluid flow rate in kg/min\n",
    "sf1=0.5443;#Liquid entropy at 298 K in kJ/kg K\n",
    "sf2=1.1242;#Liquid entropy at 263 K in kJ/kg K\n",
    "hfg1=1297.68;#Latent heat at 298 K in kJ/kg\n",
    "hfg2=1166.94;#Latent heat at 263 K in kJ/kg\n",
    "hf1=135.37;#Liquid enthalpy at point 1 in graph in kJ/kg\n",
    "hf2=298.9;#Liquid enthalpy at point 2 in graph in kJ/kg\n",
    "TR=210.;#One tonne refrigeration in TR\n",
    "\n",
    "#Calculations\n",
    "s2=sf2+(hfg2/T2);#Entropy at point 2 in kJ/kg\n",
    "x1=(s2-sf1)/(hfg1/T1);#Dryness fraction at point 1\n",
    "h1=hf1+(x1*hfg1);#Enthalpy at point 1 in kJ/kg\n",
    "h=h1-hf2;#Heat extracted of refrigerating effect produced per kg of refrigerant in kJ/kg\n",
    "ht=mf*h;#Total heat extracted at a fluid flow rate of 5 kg/min in kJ/min\n",
    "C=ht/TR;#Capacity of refrigerating in TR\n",
    "\n",
    "#Output\n",
    "print 'The capacity of refrigerator is (TR) = ',round(C,0)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7 - pg 10.49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The theoretical COP of a ammonia refrigerating machine working between given temperatures =  5.56\n"
     ]
    }
   ],
   "source": [
    "#pg 10.49\n",
    "#calculate the theoretical COP\n",
    "#Input data\n",
    "T1=263.;#Minimum temperature at which ammonia refrigerating machine works in K\n",
    "T2=303.;#Maximum temperature at which ammonia refrigerating machine works in K\n",
    "x1=0.6;#Dryness fraction of ammonia during suction stroke\n",
    "sf1=0.5443;#Liquid entropy at 263 K in kJ/kg K\n",
    "hfg1=1297.68;#Latent heat at 263 K in kJ/kg\n",
    "sf2=1.2037;#Liquid entropy at 303 K in kJ/kg K\n",
    "hfg2=1145.8;#Latent heat at 303 K in kJ/kg\n",
    "hf1=135.37;#Liquid enthalpy at 263 K in kJ/kg\n",
    "hf2=323.08;#Liquid enthalpy at 303 K in kJ/kg\n",
    "\n",
    "#Calculations\n",
    "s1=sf1+((x1*hfg1)/T1);#Entropy at point 1 in kJ/kg K\n",
    "x2=(s1-sf2)/(hfg2/T2);#Entropy at point 2 in kJ/kg K\n",
    "h1=hf1+(x1*hfg1);#Enthalpy at point 1 in kJ/kg\n",
    "h2=hf2+(x2*hfg2);#Enthalpy at point 2 in kJ/kg\n",
    "COP=(h1-hf2)/(h2-h1);#Theoretical COP of ammonia refrigerating machine\n",
    "\n",
    "#Output\n",
    "print 'The theoretical COP of a ammonia refrigerating machine working between given temperatures = ',round(COP,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8 - pg 10.51"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The amount of ice produced is (kg/kW hr) =  11.44\n"
     ]
    }
   ],
   "source": [
    "#pg 10.51\n",
    "#calculate the amount of ice\n",
    "#Input data\n",
    "T1=263.;#Minimum temperature at which Vapour compression refrigerator using methyl chloride operates in K\n",
    "T2=318.;#Maximum temperature at which Vapour compression refrigerator using methyl chloride operates in K\n",
    "sf1=0.183;#Entropy of the liquid in kJ/kg K\n",
    "hfg1=460.7;#Enthalpy of the liquid in kJ/kg\n",
    "sf2=0.485;#Entropy of the liquid in kJ/kg K\n",
    "hfg2=483.6;#Enthalpy of the liquid in kJ/kg\n",
    "x2=0.95;#Dryness fraction at point 2\n",
    "hf3=133.0;#Enthalpy of the liquid in kJ/kg\n",
    "W=3600.;#Work to be spent corresponding to 1kW/hour\n",
    "Cw=4.187;#Specific heat of water in kJ/kg degrees celcius\n",
    "mi=1;#Mass of ice produced at 0 degrees celcius\n",
    "Li=335.;#Latent heat of ice in kJ/kg\n",
    "hf1=45.4;#Enthalpy of liquid at 263 K in kJ/kg\n",
    "hf2=133.;#Enthalpy of liquid at 318 K in kJ/kg\n",
    "\n",
    "#Calculations\n",
    "s2=sf2+((x2*(hfg2-hf2))/T2);#Enthalpy at point 2 in kJ/kg\n",
    "x1=(s2-sf1)/((hfg1-hf1)/T1);#Dryness fraction at point 1\n",
    "h1=hf1+(x1*hfg1);#Enthalpy at point 1 in kJ/kg\n",
    "h2=hf2+(x2*hfg2);#Enthalpy at point 2 in kJ/kg\n",
    "COP=(h1-hf3)/(h2-h1);#Theoretical COP\n",
    "COPa=0.6*COP;#Actual COP which is 60 percent of theoretical COP\n",
    "H=W*COPa;#Heat extracted or refrigeration effect produced per kW hour in kJ\n",
    "Hw=(mi*Cw*10)+Li;#Heat extracted from water at 10 degrees celcius for the formation of 1 kg of ice at 0 degrees celcius\n",
    "I=H/Hw;#Amount of ice produced in kg/kW hr\n",
    "\n",
    "#Output\n",
    "print 'The amount of ice produced is (kg/kW hr) = ',round(I,2)\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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}