{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 10:Component Selection and Balancing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.1,PAGE NUMBER:136"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "LMTD=4.5 K\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Variable declaration\n",
    "w_a=8.4;# The mass flow rate of air in kg/s\n",
    "R=3.8;# Rating of an air-cooling evaporator in kW/k\n",
    "T_a=-15;# Entering air temperature in °C\n",
    "T_r=-21;# Refrigerant temperature in °C\n",
    "\n",
    "# Calculation\n",
    "deltaT=(T_a+273)-(T_r+273);# Rating LMTD in K\n",
    "E=R*deltaT;# Rated duty in kW\n",
    "C_pair=1.006;# kJ/kg.K\n",
    "T_ar=E/(C_pair*w_a);# Reduction in air temperature in °C \n",
    "T_al=T_a-T_ar;# Air leaving temperature in °C\n",
    "deltaT_min=(T_al+273)-(T_r+273);# K\n",
    "deltaT_max=deltaT;# K\n",
    "LMTD=(deltaT_max-deltaT_min)/(math.log(deltaT_max/deltaT_min));\n",
    "print\"\\nLMTD=%1.1f K\"%LMTD"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 10.2,PAGE NUMBER:136"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Design mass air flow=7.35 kg/s\n",
      "The cooling capacity at 100,95,90and 85 percentage mass air flow=45,42.3,39.3and 36.7 kW\n"
     ]
    }
   ],
   "source": [
    "# Variable declaration\n",
    "Q=45;# The sensible heat extracted by an air-cooling coil in kW\n",
    "T_in=24;# The entering air temperature in °C\n",
    "T_out=18;# The leaving air temperature in °C\n",
    "T_e=11;#  Refrigerant  evaporating temperature in °C\n",
    "C_pa=1.02;# The specific heat capacity of air in kJ/kg.K\n",
    "Af=[100,95,90,85];# Air flow (%)\n",
    "m=[7.35,6.99,6.62,6.25];# Mass air flow (kg/s)\n",
    "T_a=[24,24,24,24];# Air temperature on coil (°C)\n",
    "deltaT=[6,6.3,6.7,7.1];# ΔT for 45 kW (K)\n",
    "T_aoff=[18,17.7,17.3,16.9];# Air temperature off coil (°C)\n",
    "LMTD=[9.7,9.5,9.2,9.0];# LMTD,refrigerant at 11°C (K)\n",
    "h=[1,0.96,0.92,0.88];# h, in terms of design (from V0.8) \n",
    "\n",
    "# Calculation\n",
    "m_af=Q/(C_pa*(T_in-T_out));\n",
    "Capacity=[(45*h[0]*LMTD[0])/9.7,(45*h[1]*LMTD[1])/9.7,(45*h[2]*LMTD[2])/9.7,(45*h[3]*LMTD[3])/9.7];# kW\n",
    "print\"\\nDesign mass air flow=%1.2f kg/s\"%m_af\n",
    "print\"The cooling capacity at 100,95,90and 85 percentage mass air flow=%2.0f,%2.1f,%2.1fand %2.1f kW\"%(Capacity[0],Capacity[1],Capacity[2],Capacity[3])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.3,PAGE NUMBER:140"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Flow rate ratio,m_2/m_1=1.083\n",
      "\n",
      "Compressor capacity corrected for suction temperature change=9.44 kW\n",
      "\n",
      "Actual compressor capacity=10.09 kW\n",
      "\n",
      "Actual evaporator capacity=8.07 kW\n"
     ]
    }
   ],
   "source": [
    "# Variable declaration\n",
    "P_c=10;# kW\n",
    "T_e=-35;# Evaporating temperature in °C\n",
    "T_c=40;# Condensing temperature in °C\n",
    "T_s=5;# Subcooling temperature in K\n",
    "T_cin=20;# Compressor inlet temperature in °C\n",
    "T_cout=0;# Zero subcooling temperature in °C\n",
    "\n",
    "# Calculation\n",
    "#(a)\n",
    "v_s1=146.46;# m**3/kg\n",
    "v_s2=135.25;# m**3/kg\n",
    "v_sr=v_s1/v_s2;# The ratio of specific volume\n",
    "# Assuming the compressor pumps the same volume flowrate:\n",
    "m_1bym_2=v_sr;# Flow rate ratio\n",
    "print\"\\nFlow rate ratio,m_2/m_1=%1.3f\"%m_1bym_2\n",
    "#(b)\n",
    "h_1=392.51;# Suction gas enthalpy at 20°C in kJ/kg\n",
    "h_2=375.19;# Suction gas enthalpy at 0°C in kJ/kg\n",
    "h_f=257.77;# Liquid enthalpy at the expansion valve inlet at 40°C in kJ/kg\n",
    "dh_1=h_1-h_f;# Evaporator enthalpy difference at rating condition in kJ/kg\n",
    "dh_2=h_2-h_f;# Evaporator enthalpy difference with 0°C suction in kJ/kg\n",
    "dh_r=dh_2/dh_1;# Enthalpy difference ratio\n",
    "C_c=P_c*m_1bym_2*dh_r;# Compressor capacity corrected for suction temperature change in kW\n",
    "print\"\\nCompressor capacity corrected for suction temperature change=%1.2f kW\"%C_c\n",
    "#(c)\n",
    "h_f=249.67;# Liquid enthalpy at the expansion valve inlet at 35°C in kJ/kg\n",
    "dh=h_2-h_f;# Evaporator enthalpy difference at application condition in kJ/kg\n",
    "dh_r=dh/dh_1;# Enthalpy difference ratio\n",
    "C_cact=P_c*m_1bym_2*dh_r;# Actual compressor capacity in kW\n",
    "print\"\\nActual compressor capacity=%2.2f kW\"%C_cact\n",
    "#(d)\n",
    "h_g=350.13;# Suction gas enthalpy at evaporator outlet, -30°C (5 K superheat) in kJ/kg\n",
    "dh_e=h_g-h_f;# Useful evaporator enthalpy difference in kJ/kg\n",
    "dh_r=dh_e/dh_1;# Enthalpy difference ratio\n",
    "C_eact=P_c*m_1bym_2*dh_r;# Actual evaporator capacity in kW\n",
    "print\"\\nActual evaporator capacity=%1.2f kW\"%C_eact"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.4,PAGE NUMBER:142"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Break-even time=1.6 years\n"
     ]
    }
   ],
   "source": [
    "# Variable declaration\n",
    "T_c1=30;# Condensing temperature for larger condenser in °C\n",
    "T_c2=35;# Condensing temperature for smaller condenser in °C\n",
    "Rc_1=242;# Rated capacity of plant for larger condenser in kW\n",
    "Rc_2=218;# Rated capacity of plant for smaller condenser in kW\n",
    "Rt_1=1802;# Running time (kW-h)\n",
    "Rt_2=2000;# Running time (kW-h)\n",
    "Ci_1=60;# Compressor electrical input power in kW\n",
    "Ci_2=70;# Compressor electrical input power in kW\n",
    "Ec_1=11533;# Electricity cost per year (£)\n",
    "Ec_2=14933;# Electricity cost per year (£)\n",
    "C_1=14000;# Cost of the larger condenser in £\n",
    "C_2=8500;# Cost of the smaller condenser in £\n",
    "\n",
    "# Calculation\n",
    "Es=Ec_2-Ec_1;# Cost of the larger condenser in £\n",
    "Bet=(C_1-C_2)*Es**-1;# Break-even time in years\n",
    "print\"Break-even time=%1.1f years\"%Bet"
   ]
  }
 ],
 "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
}
