{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER 1:Fundmentals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.1,PAGE NUMBER:3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Carnot COP= 6.0 (error)\n"
     ]
    }
   ],
   "source": [
    "# Variable Declaration\n",
    "T_0=-5+273;# K\n",
    "T_1=35+273;# K\n",
    "\n",
    "# Calculation\n",
    "COP=(T_0)/(T_1-T_0);# Coefficient of performance\n",
    "print \"Carnot COP=\",round(COP,2),\"(error)\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.2,PAGE NUMBER:4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The average specific heat capacity is 4.186 kJ/(kg K)\n"
     ]
    }
   ],
   "source": [
    "# Variable Declaration\n",
    "T_f=80;# Final Temperature in °C\n",
    "T_i=0;# Initial Temperature in °C\n",
    "h_f=334.91;# The specific enthalpy of water in kJ/kg\n",
    "\n",
    "# Calculation\n",
    "C=h_f/(T_f-T_i);# The average specific heat capacity in kJ/(kg K)\n",
    "print \"The average specific heat capacity is\",round(C,3),\"kJ/(kg K)\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.3,PAGE NUMBER:4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The quantity of heat added is 2550.3 kJ\n"
     ]
    }
   ],
   "source": [
    "# Variable Declaration\n",
    "P=1.013;# Pressure in bar\n",
    "h_fg=2257;# The latent heat of boiling water in kJ/kg\n",
    "T_b=100; # The boiling point temperature of water in °C\n",
    "m=1; # The mass of water in kg\n",
    "T_i=30; # The initial temperature of water in °C\n",
    "C_p=4.19;# The specific heat of water in kJ/kg°C\n",
    "\n",
    "# Calculation\n",
    "Q=m*((C_p*(T_b-T_i))+h_fg);# The quantity of heat added in kJ\n",
    "print\"The quantity of heat added is\",round(Q,1),\"kJ\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.4,PAGE NUMBER:6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The new pressure,p_2= 2.0265 bar(abs.)\n"
     ]
    }
   ],
   "source": [
    "# Variable Declaration\n",
    "V_1byV_2=2;# Volumetric ratio (given)\n",
    "p_1=1.01325;# The atmospheric pressure in bar(101325 kPa)\n",
    "\n",
    "# Calculation\n",
    "p_2=V_1byV_2*p_1;# The new pressure in bar\n",
    "print\"The new pressure,p_2=\",round(p_2,4),\"bar(abs.)\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.5,PAGE NUMBER:7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The final volume,V_2= 0.75 m**3\n"
     ]
    }
   ],
   "source": [
    "# Variable Declaration\n",
    "V_1=0.75;# The initial volume in m**3\n",
    "T_1=273+20; # The initial temperature of water in K\n",
    "T_2=273+90; # The final temperature of water in K\n",
    "\n",
    "# Calculation\n",
    "V_2=V_1*(T_2/T_1);# The final volume in m**3\n",
    "print\"The final volume,V_2=\",round(V_2,2),\"m**3\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.6,PAGE NUMBER:7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The volume of an ideal gas is 4.22 m**3\n"
     ]
    }
   ],
   "source": [
    "# Variable Declaration\n",
    "R=287;# The specific gas constant in J/(kg K)\n",
    "m=5; # The mass of ideal gas in kg\n",
    "p=101.325;# The atmospheric pressure in kPa\n",
    "T=273+25;# The temperature of an ideal gas in K\n",
    "\n",
    "# Calculation\n",
    "V=(m*R*T)/(p*1000);# The volume of an ideal gas in m**3\n",
    "print\"The volume of an ideal gas is\",round(V,2),\"m**3\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.7,PAGE NUMBER:7,8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The total pressure is 100985.0 Pa ( 1.00985 bar)\n"
     ]
    }
   ],
   "source": [
    "# Variable Declaration\n",
    "m_N=0.906;# The mass of nitrogen in a cubic metre of air in kg\n",
    "R_N=297;# The specific gas constant of nitrogen in J/kg K\n",
    "m_O=0.278;# The mass of oxygen in a cubic metre of air in kg\n",
    "R_O=260;# The specific gas constant of oxygen in J/kg K\n",
    "m_A=0.015;# The mass of argon in a cubic metre of air in kg\n",
    "R_A=208;# The specific gas constant of argon in J/kg K\n",
    "T=273.15+20;# The temperature of air in K\n",
    "\n",
    "# Calculation\n",
    "p_N=m_N*R_N*T;# The pressure of nitrogen in Pa\n",
    "p_O=m_O*R_O*T;# The pressure of oxygen in Pa\n",
    "p_A=m_A*R_A*T;# The pressure of argon in Pa\n",
    "p_t=p_N+p_O+p_A;# The total pressure in Pa\n",
    "print\"The total pressure is\",round(p_t,0),\"Pa\",\"(\",round(p_t/10**5,5),\"bar)\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.8,PAGE NUMBER:8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The rate of heat conduction,Q_t= 2000.0 W(or) 2.0 kW)\n"
     ]
    }
   ],
   "source": [
    "# Variable declartion\n",
    "t=225;# The wall thickness in mm\n",
    "k=0.60;# Thermal conductivity in W/(m K)\n",
    "L=10;# Length in m\n",
    "h=3;# Height in m\n",
    "delT=25;# The temperature difference between the inside and outside faces in K\n",
    "\n",
    "# Calculation\n",
    "Q_t=(L*h*k*delT*1000)/(t);# The rate of heat conduction in W\n",
    "print\"The rate of heat conduction,Q_t=\",round(Q_t,0),\"W\"\"(or)\",round(Q_t/1000,0),\"kW)\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.9,PAGE NUMBER:10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The overall transmittance,U= 1.414  W/(m**2 K)\n"
     ]
    }
   ],
   "source": [
    "# Variable declartion\n",
    "R_i=0.3;# The inside surface resistance in (m**2 K)/W\n",
    "R_c=1/2.8;# The thermal conductance of plastered surface in (m**2 K)/W\n",
    "R_o=0.05;# The outside surface resistance in (m**2 K)/W\n",
    "\n",
    "# Calculation\n",
    "R_t=R_i+R_c+R_o;# The total thermal resistance in (m**2 K)/W\n",
    "U=1/R_t;# The overall transmittance in W/(m**2 K)\n",
    "print\"The overall transmittance,U=\",round(U,3),\" W/(m**2 K)\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 1.10,PAGE NUMBER:12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The logarithmic mean temperature difference is 5.566 K\n",
      "The amount of heat transfer is 257145.0 W (round off error) or 257.0 kW\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Variable declartion\n",
    "T_f=3;# The temperature of fluid in °C\n",
    "T_wi=11.5;# The temperature of water at inlet in °C\n",
    "T_wo=6.4;# The temperature of water at outlet in °C\n",
    "A=420;# The surface area in m**2\n",
    "U=110;# The thermal transmittance in W/(m**2 K) \n",
    "\n",
    "# Calculation\n",
    "delT_max=T_wi-T_f;# The maximum temperature difference in K\n",
    "delT_min=T_wo-T_f;# The minimum temperature difference in K\n",
    "LMTD=(delT_max-delT_min)/math.log(delT_max/delT_min);\n",
    "Q_f=U*A*LMTD;# The amount of heat transfer in W\n",
    "print\"The logarithmic mean temperature difference is\",round(LMTD,3),\"K\"\n",
    "print\"The amount of heat transfer is\",round(Q_f,0),\"W (round off error)\",\"or\",round(Q_f/1000,0),\"kW\""
   ]
  }
 ],
 "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
}
