{
 "metadata": {
  "name": "",
  "signature": "sha256:2261ff03ab51ed2922b0b6d063ddc383a313c6be373040c779faf21d1a2afd0b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 : PVT Behaviour And Heat Effects"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.1, , Page no:45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T = 350.; \t\t\t#temperature in K\n",
      "P = 10.**5; \t\t\t#pressure in N/m**2\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "# Calculations\n",
      "#To find the molar volume of air\n",
      "V = (R*T)/P; \t\t\t#molar volume in m**3\n",
      "\n",
      "# Results\n",
      "print 'Molar volume of air is %3.2e cubic m/mol'%V\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Molar volume of air is 2.91e-02 cubic m/mol\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.3, Page no:50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "Cp = 29.3; \t\t\t#specific heat at constant pressure(kJ/kmol K)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "# Calculations and Results\n",
      "#To determine heat and work effects for each step\n",
      "#Step 1: Gas is heated at constant volume\n",
      "T1 = 300.;   \t\t    \t#temperature in K\n",
      "P1 = 1.; \t    \t\t    #initial pressure in bar\n",
      "P2 = 2.; \t\t    \t    #final pressure in bar\n",
      "T2 = (P2/P1)*T1; \t\t\t#final temperature in K\n",
      "Cv = Cp-R; \t    \t    \t#specific heat at constant volume\n",
      "W1 = 0; \t\t    \t    #work done is zero as volume remains constant\n",
      "Q1 = Cv*(T2-T1); \t\t\t#heat supplied in kJ/kmol\n",
      "print 'For step 1'\n",
      "print 'Work done in step 1 is %i'%W1\n",
      "print 'Heat supplied in step 1 is %f kJ/kmol'%Q1\n",
      "\n",
      "#Step 2: The process is adiabatic\n",
      "Q2 = 0.; \t\t\t#the process is adiabatic\n",
      "P3 = 1.; \t\t\t#pressure after step 2 in bar\n",
      "gama = (Cp/Cv);\n",
      "T3 = ((P3/P2)**((gama-1)/gama))*T2; \t\t\t#temperature after step 2\n",
      "W2 = (Cv*(T2-T3)); \t\t\t#work done by system\n",
      "print 'For step 2'\n",
      "print 'Heat supplied in step 2 is %i'%Q2\n",
      "print 'Work done by system in step 2 is %f kJ/kmol'%W2\n",
      "\n",
      "#Step 3: The process is isobaric\n",
      "T4 = 300.; \t\t\t#temperature after step 3 (K)\n",
      "Q3 = Cp*(T4-T3); \t\t\t#heat supplied during step 3(kJ/kmol)\n",
      "U = (Cv*(T4-T3)); \t\t\t#change in internal energy during step 3(kJ/kmol)\n",
      "W3 = Q3-U; \t\t\t#Using first law of thermodynamics\n",
      "print 'For step 3'\n",
      "print 'Heat given out by the system in step 3 is %f kJ/kmol'%Q3\n",
      "print 'Work done on the system in step 3 is %f kJ/kmol'%W3\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For step 1\n",
        "Work done in step 1 is 0\n",
        "Heat supplied in step 1 is 6295.800000 kJ/kmol\n",
        "For step 2\n",
        "Heat supplied in step 2 is 0\n",
        "Work done by system in step 2 is 2248.222546 kJ/kmol\n",
        "For step 3\n",
        "Heat given out by the system in step 3 is -5651.101658 kJ/kmol\n",
        "Work done on the system in step 3 is -1603.524204 kJ/kmol\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.4, Page no:51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#Given:\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "Cp = 30.; \t\t\t#specific heat at constant pressure(J/mol K)\n",
      "\n",
      "# Calculations and Results\n",
      "#To calculate change in internal energy change in enthalpy work done and heat supplied\n",
      "import math\n",
      "#(a): Gas is expanded isothermally\n",
      "T = 600.; \t\t\t#temperature in K\n",
      "P1 = 5.; \t\t\t#initial pressure in bar\n",
      "P2 = 4.; \t\t\t#final pressure in bar\n",
      "U1 = 0; \t\t\t#since the process is isothermal\n",
      "H1 = 0; \t\t\t#since the process is isothermal\n",
      "W1 = (R*T*math.log(P1/P2)); \t\t\t#work done during the process\n",
      "Q1 = W1; \t\t\t#heat supplied during the process\n",
      "print 'When gas is expanded isothermally'\n",
      "print 'Change in internal energy in isothermal process is %i'%U1\n",
      "print 'Change in enthalpy in isothermal process is %i'%H1\n",
      "print \"Work done during the process is %f kJ/kmol\"%W1\n",
      "print 'Heat supplied during the process is %f kJ/kmol'%Q1\n",
      "\n",
      "#(b): Gas is heated at constant volume\n",
      "V = 0.1; \t\t\t#volume (m**3)\n",
      "P1 = 1.; \t\t\t#initial pressure(bar)\n",
      "T1 = 298.; \t\t\t#initial temperature(K)\n",
      "T2 = 400.; \t\t\t#final temperature(K)\n",
      "n = ((P1*V*10**5)/(R*T1)); \t\t\t#number of moles of gas\n",
      "Cv = Cp-R; \t\t\t#specific heat at constant volume(J/mol K)\n",
      "ans = round(Cv*(T2-T1))\n",
      "n = round(n,2)\n",
      "U2 = n*ans #Cv*round(T2-T1); \t\t\t#change in internal energy(J)\n",
      "H2 = n*Cp*(T2-T1); \t\t\t#change in enthalpy(J)\n",
      "W2 = 0; \t\t\t#isochoric process\n",
      "Q2 = U2+W2; \t\t\t#heat supplied(J)\n",
      "print '\\nWhen gas is heated at constant volume'\n",
      "print 'Change in internal energy is %.0f J'%U2\n",
      "print 'Change in enthalpy is %f J'%H2\n",
      "print 'Work done during the process is %i '% W2\n",
      "print 'Heat supplied during the process is %.0f J'%Q2\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "When gas is expanded isothermally\n",
        "Change in internal energy in isothermal process is 0\n",
        "Change in enthalpy in isothermal process is 0\n",
        "Work done during the process is 1113.129291 kJ/kmol\n",
        "Heat supplied during the process is 1113.129291 kJ/kmol\n",
        "\n",
        "When gas is heated at constant volume\n",
        "Change in internal energy is 8936 J\n",
        "Change in enthalpy is 12362.400000 J\n",
        "Work done during the process is 0 \n",
        "Heat supplied during the process is 8936 J\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.5, Page no:52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.integrate import quad\n",
      "\n",
      "\n",
      "def Cv(T):\n",
      "    y = 27.4528+(6.1839*(10**-3)*T)-(8.9932*(10**-7)*(T**2))-R;\n",
      "    return y\n",
      "\n",
      "# Variables\n",
      "m = 20.; \t\t\t#mass of air(kg)\n",
      "n = 1.25; \t\t\t#polytropic constant\n",
      "P1 = 1.; \t\t\t#initial pressure(bar)\n",
      "P2 = 5.; \t\t\t#final pressure(bar)\n",
      "T1 = 300.; \t\t\t#temperature(K)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "M = 29.; \t\t\t#molecular wt of air\n",
      "\n",
      "# Calculations\n",
      "#To determine work done and amount of heat transferred\n",
      "#(a): Work done by the compressor per cycle\n",
      "n_mole = m/M; \t\t\t#moles of air(kmol)\n",
      "V1 = ((n_mole*10**3*R*T1)/(P1*10**5)); \t\t\t#initial volume(m**3)\n",
      "V2 = (V1*((P1/P2)**(1/n))); \t\t\t        #final volume(m**3)\n",
      "\n",
      "#Since the process is polytropic P(V**n)=c(say constant)\n",
      "c = P1*10**5*(V1**n); \n",
      "\t\t\t#function[z] = f(V);\n",
      "\t\t\t#    z = c/(V**1.25);\n",
      "\t\t\t#W1 = intg(V1,V2,f); so\n",
      "W = (c/(1-n))*((V2**(-n+1))-(V1**(-n+1)))/1000;\n",
      "print 'Work done by compressor is %4.3e J'%(W*1000);\n",
      "\n",
      "#(b): Amount of heat transferred to surrounding\n",
      "T2 = ((T1*V2*P2)/(V1*P1)); \t\t\t#final temp in K\n",
      "U1 = quad(Cv,T1,T2)[0];\n",
      "U = U1*n_mole; \t\t\t            #change in internal energy(kJ)\n",
      "Q = U+W; \t\t\t                #heat supplied\n",
      "\n",
      "# Results\n",
      "print 'Chnage in internal energy is %f kJ'%U\n",
      "print 'Heat supplied is %f kJ'%Q\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done by compressor is -2.613e+06 J\n",
        "Chnage in internal energy is 1667.979893 kJ\n",
        "Heat supplied is -944.769684 kJ\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.6, Page no:55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "V = 0.3821*10**-3 \t\t\t#molar volume(m**3/mol)\n",
      "T = 313.; \t\t\t#temperature (K)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "a = 0.365; b = 4.28*10**-5; \t\t\t#Vander Waals constant\n",
      "\n",
      "\n",
      "# Calculations and Results\n",
      "#To compare the pressures\n",
      "#(a): Ideal gas equation\n",
      "P = ((R*T)/(V*10**5)); \t\t\t#pressure in bar\n",
      "print 'Pressure obtained by ideal gas equation is %f bar'%P\n",
      "\n",
      "#(b): Van der Waals equation\n",
      "P = ((((R*T)/(V-b))-(a/(V**2)))/(10**5));\n",
      "print 'Pressure obtained by Van der Waals equation is %f bar'%P\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure obtained by ideal gas equation is 68.104737 bar\n",
        "Pressure obtained by Van der Waals equation is 51.695679 bar\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.7, Page no:56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#To find Approx Value\n",
      "def approx(V,n):\n",
      "  A=round(V*10**n)/10**n;\t\t\t#V-Value  n-To what place\n",
      "  return A\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T = 300.; \t\t\t#temperature(K)\n",
      "P = 100.; \t\t\t#pressure(bar)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "a = 0.1378\n",
      "b = 3.18*10**-5; \t\t\t#Van der waals constant\n",
      "\n",
      "# Calculations and Results\n",
      "#(a): Ideal gas equation\n",
      "V_ideal = approx(((R*T)/(P*10**5)),6);\n",
      "print 'Volume calculated by ideal gas equation is %4.2e cubic m'%V_ideal\n",
      "\n",
      "#(b): Van der Waals equation\n",
      "def f(V):\n",
      "    y=((P*10**5)+(a/(V**2)))*(V-b)-(R*T); \t\t\t#function to calculate difference between calculated and assumed volume\n",
      "    return y\n",
      "    \n",
      "V_real = 0;\n",
      "i = 0.20\n",
      "while i<=.30:  \t\t\t#Van der waals volume should be nearly equal to Ideal gas valoume\n",
      "    res = approx(f(i*10**-3),0);\n",
      "    for j in range(-5,6):\n",
      "        if(j==res): \t\t\t#for very small difference i may be taken as exact volume\n",
      "            V_real = i*10**-3;\n",
      "    i += 0.01\n",
      "\n",
      "print 'Volume calculated by Van der Waals equation is %3.2e cubic m'%V_real\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume calculated by ideal gas equation is 2.49e-04 cubic m\n",
        "Volume calculated by Van der Waals equation is 2.30e-04 cubic m\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.9, Page no:59 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#To find Approx Value\n",
      "def approx(V,n):\n",
      "  A=round(V*10**n)/10**n;\t\t\t#V-Value  n-To what place\n",
      "  return A\n",
      "\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T = 500.; \t\t\t#temperature (K)\n",
      "P = 10.; \t\t\t#pressure(bar)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "B = -2.19*10**-4; C=-1.73*10**-8; \t\t\t#Virial coeffecients\n",
      "Tc = 512.6; \t\t\t#critical temperature\n",
      "Pc = 81.; \t\t\t#critical pressure\n",
      "\n",
      "#To calculate compressibility factor and molar volume\n",
      "\n",
      "# Calculations and Results\n",
      "#(a): Truncated form of virial equation\n",
      "V_ideal = approx(((R*T)/(P*10**5)),7); \t\t\t#ideal gas volume\n",
      "def f1(V):\n",
      "    z = (((R*T)/(P*10**5))*(1+(B/V)+(C/(V**2)))); \t\t\t#function for obtaining volume by virial equation\n",
      "    return z\n",
      "\n",
      "#loop for hit and trial method\n",
      "flag = 1;\n",
      "while(flag==1):\n",
      "    V_virial = approx(f1(V_ideal),7);\n",
      "    if(approx(V_ideal,5)==approx(V_virial,5)):\n",
      "        flag = 0;\n",
      "        break;\n",
      "    else:\n",
      "        V_ideal = V_virial;\n",
      "\n",
      "\n",
      "Z = approx(((P*10**5*V_virial)/(T*R)),3); \t\t\t#compressibility factor\n",
      "print 'Compressibilty factor for virial equation is %f '%Z\n",
      "\n",
      "#(b): Redlich Kwong Equation\n",
      "#Constants in Redlich Kwong equation\n",
      "a = approx(((0.4278*(R**2)*(Tc**2.5))/(Pc*10**5)),4);\n",
      "b = approx(((0.0867*R*Tc)/(Pc*10**5)),9);\n",
      "\n",
      "V_ideal = approx(((R*T)/(P*10**5)),7); \t\t\t#ideal gas volume\n",
      "\n",
      "#Function to find volume by Redlich Kwong equation \n",
      "def f2(V):\n",
      "    x = ((R*T)/(P*10**5))+b-((a*(V-b))/((T**0.5)*(P*10**5)*V*(V+b)));\n",
      "    return x\n",
      "\n",
      "#loop for hit and trial method\n",
      "flag = 1;\n",
      "while(flag==1):\n",
      "    V_redlich = approx(f2(V_ideal),7);\n",
      "    if(approx(V_ideal,5)==approx(V_redlich,5)):\n",
      "        flag = 0;\n",
      "        break;\n",
      "    else:\n",
      "\t    V_ideal = V_redlich;\n",
      "\n",
      "print 'Volume obtained by Redlich Kwong Equation is %4.3e cubic m/mol'%V_redlich\n",
      "Z = approx(((P*10**5*V_redlich)/(T*R)),3); \t\t\t#compressibility factor\n",
      "print 'Compressbility factor by Redlich Kwong equation is %f'%Z\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Compressibilty factor for virial equation is 0.943000 \n",
        "Volume obtained by Redlich Kwong Equation is 3.963e-03 cubic m/mol\n",
        "Compressbility factor by Redlich Kwong equation is 0.953000\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.10, Page no:64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "#Given:\n",
      "Ha = -890.94; \t\t\t#standard heat for reaction a (kJ)\n",
      "Hb = -393.78; \t\t\t#standard heat for reaction b (kJ)\n",
      "Hc = -286.03; \t\t\t#standard heat for reaction c (kJ)\n",
      "\n",
      "# Calculations\n",
      "#To calculate heat of formation of methane gas\n",
      "#c*2 + b - a gives the formation of methane from elements\n",
      "Hf = (2*Hc)+Hb-Ha;\n",
      "\n",
      "# Results\n",
      "print 'Heat of formation of methane is %f kJ/mol'%Hf\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat of formation of methane is -74.900000 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.11, Page no:65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "#Given:\n",
      "Ha = -509.93; \t\t\t#heat of combustion of reaction a (kJ) \n",
      "Hb = -296.03; \t\t\t#heat of combustion of reaction b (kJ)\n",
      "Hc = -393.78; \t\t\t#heat of combustion of reaction c (kJ)\n",
      "Hd = -167.57; \t\t\t#heat of combustion of reaction d (kJ)\n",
      "\n",
      "# Calculations\n",
      "#To calculate heat of formation of chloroform\n",
      "#c + (3*d) -a -b gives chloroform from its elements\n",
      "Hf = Hc+(3*Hd)-Ha-Hb;\n",
      "\n",
      "# Results\n",
      "print 'Heat of formation of chloroform is %f kJ/mol'%Hf"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat of formation of chloroform is -90.530000 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.12, Page no:67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "Ho = -164987.; \t\t\t#standard heat of reaction at 298 K in J\n",
      "T1 = 298.;\n",
      "T2 = 773.; \t\t\t#temperature(K)\n",
      "\n",
      "# Calculations\n",
      "#To calculate standard heat of reaction at 773 K\n",
      "alpha = (2*29.16)+13.41-26.75-(4*26.88);\n",
      "betta = ((2*14.49)+77.03-42.26-(4*4.35))*10**-3;\n",
      "gama = ((2*-2.02)-18.74+14.25+(4*0.33))*10**-6;\n",
      "#Using equation 3.54 (Page no. 67)\n",
      "H1 = Ho-(alpha*T1)-(betta*(T1**2)/2)-(gama*(T1**3)/3);\n",
      "#At 773 K\n",
      "Hr = H1+(alpha*T2)+(betta*(T2**2)/2)+(gama*(T2**3)/3);\n",
      "\n",
      "# Results\n",
      "print 'Heat of reaction at 773 K is %f kJ'%(Hr/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat of reaction at 773 K is -183.950273 kJ\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.13, Page no:68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "To = 298.; \t\t\t#standard temperature(K)\n",
      "T1 = 400.; \t\t\t#temperature of reactants(K)\n",
      "T2 = 600.; \t\t\t#temperature of products (K)\n",
      "Ho = -283.028; \t\t\t#standard heat of reaction(kJ/mol)\n",
      "\n",
      "# Calculations\n",
      "#To determine heat added or removed\n",
      "#Basis:\n",
      "n_CO = 1.; \t\t\t#moles of CO reacted\n",
      "n_O2 = 1.;\t\t\t#moles of oxygen supplied\n",
      "n_N2 = 1.*79./21; \t\t\t#moles of nitrogen\n",
      "n1_O2 = 0.5; \t\t\t#moles of oxygen required\n",
      "n_CO2 = 1.; \t\t\t#moles of carbon di oxide formed\n",
      "\n",
      "H1 = ((n_O2*29.70)+(n_N2*29.10)+(n_CO*29.10))*(To-T1)/1000; \t\t\t#enthalpy of cooling of reactants\n",
      "H2 = ((n1_O2*29.70)+(n_N2*29.10)+(n_CO2*41.45))*(T2-To)/1000; \t\t\t#enthalpy of heating the products\n",
      "Hr = H1+Ho+H2;\n",
      "\n",
      "# Results\n",
      "print 'Heat supplied is %f kJ'%Hr\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat supplied is -250.128714 kJ\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.14, Page no:69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "To = 298.; \t\t\t#standard temperature (K)\n",
      "T1 = 373.; \t\t\t#temperature of reactants (K)\n",
      "Ho = 283178.; \t\t\t#standard heat of combustion(J/mol)\n",
      "\n",
      "# Calculations\n",
      "#To calculate theoretical flame temperature\n",
      "#Basis:\n",
      "n_CO = 1.; \t\t\t#moles of CO\n",
      "n_O2 = 1.; \t\t\t#moles of oxygen supplied\n",
      "n1_O2 = 0.5; \t\t\t#moles of oxygen reacted\n",
      "n_CO2 = 1.; \t\t\t#moles of carbon di oxide formed\n",
      "n_N2 = 79./21; \t\t\t#moles of nitrogen\n",
      "\n",
      "H1 = ((n_O2*34.83)+(n_N2*33.03)+(n_CO*29.23))*(To-T1); \t\t\t#enthalpy of cooling of reactants\n",
      "#Using equation 3.55 (Page no. 69)\n",
      "H2 = Ho-H1;\n",
      "Tf = H2/((n1_O2*34.83)+(n_N2*33.03)+(n_CO2*53.59))+298; \t\t\t#flame temperature\n",
      "\n",
      "# Results\n",
      "print 'Theoretical flame temperature is %f K'%Tf\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Theoretical flame temperature is 1820.588298 K\n"
       ]
      }
     ],
     "prompt_number": 24
    }
   ],
   "metadata": {}
  }
 ]
}