{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 19 - Psychrometry"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1: pg 625"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 19.1\n",
      " (a) The mass of water vapor in the humid air is (kg) =  0.0087\n",
      "      The specific volume of humid air is (m^3/kg) =  0.811\n",
      " (b) The mass of water vapor in the humid air is (kg) =  0.029\n",
      "     The specific volume of humid air is (m^3/kg) =  0.881\n",
      " On the warm day the air contains  2.5  times the mass of water vapor as on the cool day \n",
      "\n"
     ]
    }
   ],
   "source": [
    "#pg 625\n",
    "print('Example 19.1');\n",
    "\n",
    "# aim : To compare the moisture content and the true specific volumes of  atmosphere air \n",
    "# (a) temperature is 12 C and the air is saturaded\n",
    "# (b) temperature is 31 C and air is .75 saturated\n",
    "\n",
    "# Given values\n",
    "P_atm = 101.4;# atmospheric pressure, [kN/m^2]\n",
    "R = .287;# [kJ/kg K]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "T = 273+12;# air temperature, [K]\n",
    "# From steam table at 12 C\n",
    "p = 1.4;# [kN/m^2]\n",
    "vg = 93.9;# [m^3/kg]\n",
    "pa = P_atm-p;# partial pressure of the dry air, [kN/m^2]\n",
    "va = R*T/pa;# [m^3/kg]\n",
    "\n",
    "mw = va/vg;# mass of water vapor in the air,[kg]\n",
    "v = va/(1+mw);# specific volume of humid air, [m^3/kg]\n",
    "\n",
    "print ' (a) The mass of water vapor in the humid air is (kg) = ',round(mw,4)\n",
    "print '      The specific volume of humid air is (m^3/kg) = ',round(v,3)\n",
    "\n",
    "# (b)\n",
    "x = .75;# dryness fraction\n",
    "T = 273.+31;# air temperature, [K]\n",
    "# From steam table\n",
    "p = 4.5;# [kN/m^2]\n",
    "vg = 31.1;# [m^3/kg]\n",
    "pa = P_atm-p;# [kN/m^2]\n",
    "va = R*T/pa;# [m^3/kg]\n",
    "mw1= va/vg;# mass of water vapor in the air, [kg]\n",
    "mw_actual = mw1*x;# actual mass of vapor, [kg]\n",
    "v = va/(1+mw_actual);# true specific volume of humid air,[m^3/kg] \n",
    "\n",
    "print ' (b) The mass of water vapor in the humid air is (kg) = ',round(mw1,4)\n",
    "print '     The specific volume of humid air is (m^3/kg) = ',round(v,3)\n",
    "\n",
    "ewv = mw_actual/mw ;\n",
    "print ' On the warm day the air contains ',round(ewv,1),' times the mass of water vapor as on the cool day \\n'\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2: pg 626"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 19.2\n",
      " (a) The partial pressure of vapor is (kN/m^2) =  1.521\n",
      "     The partial pressure of dry air is (kN/m^2) =  98.479\n",
      " (b) The specific humidity of the mixture is (kg/kg dry air) =  0.0096\n",
      " (c) The composition of the mixture is  =   0.99\n"
     ]
    }
   ],
   "source": [
    "#pg 626\n",
    "print('Example 19.2');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the partial pressures of the vapor and the dry air\n",
    "# (b) the specific humidity of the mixture\n",
    "# (c) the composition of the mixture\n",
    "\n",
    "#  Given values\n",
    "phi = .65;# Relative humidity\n",
    "T = 273.+20;# temperature, [K]\n",
    "p = 100.;# barometric pressure, [kN/m^2]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "#  From the steam table at 20 C\n",
    "pg = 2.34;# [kN/m^2]\n",
    "ps = phi*pg;# partial pressure of vapor, [kN/m^2]\n",
    "pa = p-ps;# partial pressure of dry air, [kN/m^2]\n",
    "print ' (a) The partial pressure of vapor is (kN/m^2) = ',ps\n",
    "print '     The partial pressure of dry air is (kN/m^2) = ',pa\n",
    "\n",
    "# (b)\n",
    "# from equation [15]\n",
    "omega = .622*ps/(p-ps);# specific humidity of the mixture\n",
    "print ' (b) The specific humidity of the mixture is (kg/kg dry air) = ',round(omega,4)\n",
    "\n",
    "# (c)\n",
    "# using eqn [1] from section 19.2\n",
    "y = 1/(1+omega);# composition of the mixture\n",
    "print ' (c) The composition of the mixture is  =  ',round(y,2)\n",
    "\n",
    "# End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3: pg 627"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 19.3\n",
      " (a) The specific humidity is (kg/kg air) =  0.0119\n",
      " (b) The dew point is (C) =  10.08\n",
      " (c) The degree of superheat is (C) =  14.92\n",
      " (d) The mass of condensate is (kg/kg dry air) =  0.003\n",
      "there is calculation mistake in the book so answer is no matching\n"
     ]
    }
   ],
   "source": [
    "#pg 627\n",
    "print('Example 19.3');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the specific humidity\n",
    "# (b) the dew point\n",
    "# (c) the degree of superheat of the superheated vapor\n",
    "# (d) the mass of condensate formed per kg of dry air if the moist air is cooled to 12 C\n",
    "\n",
    "# Given values\n",
    "t = 25.;# C\n",
    "T = 273.+25;# moist air temperature, [K]\n",
    "phi = .6;# relative humidity\n",
    "p = 101.3;# barometric pressure, [kN/m^2]\n",
    "R = .287;# [kJ/kg K]\n",
    "\n",
    "# solution\n",
    "# (a)\n",
    "# From steam table at 25 C\n",
    "pg = 3.17;# [kN/m^2]\n",
    "ps = phi*pg;# partial pressure of the vapor, [kN/m^2]\n",
    "omega = .622*ps/(p-ps);# the specific humidity of air\n",
    "\n",
    "print ' (a) The specific humidity is (kg/kg air) = ',round(omega,4)\n",
    "\n",
    "# (b)\n",
    "# Dew point is saturated temperature at ps is,\n",
    "t_dew = 16.+2*(1.092-1.817)/(2.062-1.817);# [C]\n",
    "print ' (b) The dew point is (C) = ',round(t_dew,2)\n",
    "\n",
    "# (c)\n",
    "Dos = t-t_dew;# degree of superheat, [C]\n",
    "print ' (c) The degree of superheat is (C) = ',round(Dos,2)\n",
    "\n",
    "# (d)\n",
    "# at 25 C\n",
    "pa = p-ps;# [kN/m^2]\n",
    "va = R*T/pa;# [m^3/kg]\n",
    "# at 16.69 C\n",
    "vg = 73.4-(73.4-65.1)*.69/2;# [m^3/kg]\n",
    "ms1= va/vg; \n",
    "# at 12 C\n",
    "vg = 93.8;# [m^3/kg]\n",
    "ms2 = va/vg;\n",
    "\n",
    "m = ms1-ms2;# mas of condensate\n",
    "print ' (d) The mass of condensate is (kg/kg dry air) = ',round(m,4)\n",
    "\n",
    "print 'there is calculation mistake in the book so answer is no matching'\n",
    "\n",
    "#  End\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4: pg 630"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Example 19.4\n",
      " (a) The volume of air required is (m^3/h) =  107057.0\n",
      " (b) The mass of water added is (kg/h) =  276.7\n",
      " (c) The heat transfer required by dry air is (MJ/h) =  458.226\n",
      " (d) The heat transferred required for vapor+supply water is (MJ/h) =  721.688\n",
      " there is minor variation in the answer reported in the book due to rounding off error\n"
     ]
    }
   ],
   "source": [
    "#pg 630\n",
    "print(' Example 19.4');\n",
    "\n",
    "# aim : To determine\n",
    "# (a) the volume of external saturated air\n",
    "# (b) the mass of air\n",
    "# (c) the heat transfer\n",
    "# (d) the heat transfer required by the combind water vapour\n",
    "\n",
    "# given values\n",
    "Vb = 56000.;# volume of building, [m^3]\n",
    "T2 = 273.+20;# temperature of air in thebuilding, [K]\n",
    "phi = .6;# relative humidity\n",
    "T1 = 8+273.;# external air saturated temperature, [K]\n",
    "p0 = 101.3;# atmospheric pressure, [kN/m^2]\n",
    "cp = 2.093;# heat capacity of saturated steam, [kJ/kg K]\n",
    "R = .287;# gas constant, [kJ/kg K]\n",
    "\n",
    "# solution\n",
    "# from steam table at 20 C saturation pressure of steam is,\n",
    "pg = 2.34;# [kN/m^2]\n",
    "\n",
    "# (a)\n",
    "pvap = phi*pg;# partial pressure of vapor, [kN/m^2] \n",
    "P = p0-pvap;# partial pressure of air, [kN/m^2]\n",
    "V = 2*Vb;# air required, [m^3]\n",
    "# at 8 C saturation pressure ia\n",
    "pvap = 1.072;# [kN/m^2]\n",
    "P2 = p0-pvap;# partial pressure of entry at 8 C, [kN/m^2]\n",
    "\n",
    "# using P1*V1/T1=P2*V2/T2;\n",
    "V2 = P*V*T1/(T2*P2);# air required at 8 C, [m^3/h]\n",
    "print ' (a) The volume of air required is (m^3/h) = ',round(V2)\n",
    "\n",
    "# (b)\n",
    "#  assuming\n",
    "pg = 1.401;# pressure, [kN/m^2]\n",
    "Tg = 273.+12;# [K]\n",
    "vg = 93.8;# [m^3/kg]\n",
    "# at constant pressure\n",
    "v = vg*T2/Tg;# volume[m^3/kg]\n",
    "mv = V/v;# mass of vapor in building at 20 C, [kg/h]\n",
    "# from steam table at 8 C\n",
    "vg2 = 121.;# [m^3/kg]\n",
    "mve = V2/vg2;# mass of vapor supplied with saturated entry air, [kg/h]\n",
    "mw = mv-mve;# mass of water added, [kg/h]\n",
    "print ' (b) The mass of water added is (kg/h) = ',round(mw,1)\n",
    "\n",
    "# (c)\n",
    "# for perfect gas\n",
    "m = P2*V2/(R*T1);# [kg/h]\n",
    "Cp = .287;# heat capacity, [kJ/kg K]\n",
    "Q = m*Cp*(T2-T1);# heat transfer by dry air,[kJ/h]\n",
    "print ' (c) The heat transfer required by dry air is (MJ/h) = ',round(Q*10**-3,3)\n",
    "\n",
    "# (d)\n",
    "# from steam table\n",
    "h1 = 2516.2;# specific enthalpy of saturated vapor at 8 C,[kJ/kg]\n",
    "hs = 2523.6;# specific enthalpy of saturated vapor at 20 C, [kJ/kg]\n",
    "h2 = hs+cp*(T2-T1);# specific enthalpy of vapor at 20 c, [kJ/kg]\n",
    "Q1 = mve*(h2-h1);# heat transfer required for vapor, [kJ]\n",
    "\n",
    "# again from steam table\n",
    "hf1 = 33.6;# [kJ/kg]\n",
    "hg3 = 2538.2;# [kJ/kg]\n",
    "Q2 = mw*(hg3-hf1);# heat transfer required for water, [kJ/h]\n",
    "Qt = Q1+Q2;# total heat transfer, [kJ/h]\n",
    "print ' (d) The heat transferred required for vapor+supply water is (MJ/h) = ',round(Qt*10**-3,3)\n",
    "\n",
    "print ' there is minor variation in the answer reported in the book due to rounding off error'\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
}