{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3:The first Law of Thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1,Page no:18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "V1=14 \t\t\t\t#initial volume of cylinder in m3\n",
      "V2=9 \t\t\t\t#final volume of cylinder in m3\n",
      "P=2000 \t\t\t\t#pressure during the operation in N/m2\n",
      "U=(-6000) \t\t\t#internal energy of the system in J\n",
      "W=-P*(V2-V1) \t\t\t#work done during the operation in J\n",
      "Q=U-W \t\t\t\t#energy tranfered in form of heat in J\n",
      "print\"energy tranfered in form of heat is\",Q,\"J\"\n",
      " "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "energy tranfered in form of heat is -16000 J\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2,Page no:18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "R=8.314 \t\t\t\t#universal gas constant [J/K/mol]\n",
      "T=300\t\t\t\t\t#temperture for the process [K]\n",
      "U=0 \t\t\t\t\t#change in internal energy [J]\n",
      "V1=2.28 \t\t\t\t#initial volume [m3]\n",
      "V2=4.56 \t\t\t\t#final volume[m3]\n",
      "import math\n",
      "W=2.303*R*T*math.log10(V2/V1) \t\t#work done during the process[J]\n",
      "Q=W \t\t\t\t\t#heat lost or gained by the system[J]\n",
      "print\"The heat gained by the system is\",round(Q),\"J mol^-1\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The heat gained by the system is 1729.0 J mol^-1\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3,Page no:19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "H=29.2 \t\t\t\t\t#latent heat of vaporisation[KJ/mol]\n",
      "T=332 \t\t\t\t\t#temperature of the system[K]\n",
      "R=8.314 \t\t\t\t#universal gas constant [J/K/mol]\n",
      "Qp=H \t\t\t\t\t#at constant pressure [KJ]\n",
      "W=-R*0.001*T \t\t\t\t#workdone [KJ]\n",
      "U=Qp+W \t\t\t\t\t#change in internal energy[KJ]\n",
      "print\"Heat absorbed by the bromine vapours is\",Qp,\"KJ\"\n",
      "print\"\\nWorkdone during the process is\",round(W,2),\"KJ\"\n",
      "print\"\\nChange in internal energy of the system is\",round(U,2),\"KJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat absorbed by the bromine vapours is 29.2 KJ\n",
        "\n",
        "Workdone during the process is -2.76 KJ\n",
        "\n",
        "Change in internal energy of the system is 26.44 KJ\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4,Page no:20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "print\"C7H16(l) + 11O2(g) -> 7CO2(g) + 8H2O(l)\" \n",
      "n=-4 \t\t\t\t#change in no. of moles when reaction proceeds from reactants to \t\t\t\tproducts\n",
      "T=298 \t\t\t\t#temperature of the process [K]\n",
      "R=8.314 \t\t\t#universal gas constant [J/K/mol]\n",
      "Qv=-4800 \t\t\t#heat energy at constant volume [KJ]\n",
      "U=Qv \t\t\t\t#change in internal energy of system [KJ]\n",
      "H=U+n*R*0.001*T \t\t#change in enthalpy of the system[KJ]\n",
      "print\"the change in enthalpy of system is\",round(H,2),\"kJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C7H16(l) + 11O2(g) -> 7CO2(g) + 8H2O(l)\n",
        "the change in enthalpy of system is -4809.91 kJ\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5,Page no:21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "n=1 \t\t\t\t#number of moles of an given ideal gas\n",
      "T=298 \t\t\t\t#temperature for the process[K]\n",
      "V1=8.3 \t\t\t\t#initial volume of the ideal gas[m3]\n",
      "V2=16.8 \t\t\t#final volume of the ideal gas[m3]\n",
      "R=8.314 \t\t\t#universal gas constant[J#K#mol]\n",
      "import math\n",
      "W=-2.303*R*T*math.log10(V2/V1) #[J]\n",
      "Q=-W \t\t\t\t#[J]\n",
      "print\"H=U+PV ,where U is change in internal energy which is zero due to isothermal process\" \n",
      "print\"PV where V is change in volume of system ,PV=RT & RT==0 since T i.e change in temp is zero for system\" \n",
      "print\"Therefore,the change in enthalpy is 0J\" \n",
      "print\"The workdone by system is\",round(W,1),\"J mol^-1\"\n",
      "print\"\\nThe heat evolved is\",round(Q,1),\"J mol^-1\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "H=U+PV ,where U is change in internal energy which is zero due to isothermal process\n",
        "PV where V is change in volume of system ,PV=RT & RT==0 since T i.e change in temp is zero for system\n",
        "Therefore,the change in enthalpy is 0J\n",
        "The workdone by system is -1747.3 J mol^-1\n",
        "\n",
        "The heat evolved is 1747.3 J mol^-1\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6,Page no:24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "T1=323 \t\t\t#intial temperature of water[K]\n",
      "T2=373 \t\t\t#final temperature of water[K]\n",
      "Cp=75.29 \t\t#specific heat of water[J/K/mol]\n",
      "w=100.0 \t\t\t#weight of water[g]\n",
      "mol_wt=18.0 \t\t#molecular weight of water[g/mol]\n",
      "n=w/mol_wt \t\t#no. of moles of water[moles]\n",
      "H=(n*Cp*(T2-T1))*0.001 \t#change in enthalpy of water[J]\n",
      "print\"The change in enthalpy of water is\",round(H,2),\"kJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The change in enthalpy of water is 20.91 kJ\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7,Page no:29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print\"SO2 + 0.5O2 -> SO3\"\n",
      "U=-97030 \t\t\t#heat of reaction[J]\n",
      "n=1-(1+0.5) \t\t\t#change in no. of moles \n",
      "R=8.314 \t\t\t#universal gas constant[J/K/mol]\n",
      "T=298 \t\t\t\t#temperature during the reaction[K]\n",
      "H=U+n*R*T \t\t\t#change inenthalpy of reaction[J]\n",
      "print\"The change in enthalpy of reaction is\",round(H),\"J(approx)\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "SO2 + 0.5O2 -> SO3\n",
        "The change in enthalpy of reaction is -98269.0 J(approx)\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8,Page no:29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print\"i.C(s) + O2(g) -> CO2(g)\"\n",
      "H1=-393.5 \t\t#change in enthalpy [KJ/mol]\n",
      "T1=298 \t\t\t#temperature [K]\n",
      "n1=0 \t\t\t#change in no. of moles in reaction moving in forward direction\n",
      "R=0.008314 \t\t#universal gas constant [KJ/K/mol]\n",
      "\n",
      "U1=H1-n1*R*T1 \t\t#change in internal energy [KJ]\n",
      "print\"The change in internal energy is\",round(U1,1),\"KJ/mol\"\n",
      "\n",
      "print\"ii.C(s) + 0.5O2 -> CO(g)\" \n",
      "H2=-110.5 \t\t#change in enthalpy[KJ/mol]\n",
      "T2=298 \t\t\t#temperature[K]\n",
      "n2=1-0.5 \t\t#change in no. of moles in reaction moving in forward direction\n",
      "R=0.008314 \t\t#universal gas constant [KJ/K/mol]\n",
      "\n",
      "U2=H2-n2*R*T2 \t\t#change in internal energy [KJ]\n",
      "print\"The change in internal energy is\",round(U2,3),\"KJ/mol\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i.C(s) + O2(g) -> CO2(g)\n",
        "The change in internal energy is -393.5 KJ/mol\n",
        "ii.C(s) + 0.5O2 -> CO(g)\n",
        "The change in internal energy is -111.739 KJ/mol\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9,Page no:30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print\"The standard heat of combustion of\"\n",
      "print\"2C6H6(l)+ 15O2(g)-> 12 CO2(g)+ 6 H2O(l)\" \n",
      "print\"H1(standard heat of combustion)=-6536 KJ/mol\" \n",
      "H1=-6536 \t\t\t#standard heat of combustion [KJ/mol]\n",
      "print\"C6H6(l)+ 7.5 O2(g)-> 6 CO2(g)+ 6 H2O(l)\" \n",
      "H2=H1/2 \t\t\t#standard heat of combustion[KJ/mol]\n",
      "print\"H2(standard heat of combustion for 1 mole of C6H6)=\",H2,\"kJ/mol\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The standard heat of combustion of\n",
        "2C6H6(l)+ 15O2(g)-> 12 CO2(g)+ 6 H2O(l)\n",
        "H1(standard heat of combustion)=-6536 KJ/mol\n",
        "C6H6(l)+ 7.5 O2(g)-> 6 CO2(g)+ 6 H2O(l)\n",
        "H2(standard heat of combustion for 1 mole of C6H6)= -3268 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.10,Page no:32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print\"N2(g)+3H2(g)-> 2NH3(g)\" \n",
      "H=-92.22 \t\t\t#standard heat of reaction [KJ/mol]\n",
      "H1=H/2 \t\t\t\t#standard heat of formation of 1 mole [KJ/mol]\n",
      "print\"H(heat of formation of 1 mole of product)=\",H1,\"kJ mol^-1\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "N2(g)+3H2(g)-> 2NH3(g)\n",
        "H(heat of formation of 1 mole of product)= -46.11 kJ mol^-1\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.11,Page no:32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "print\"C2H5OH(l)+3O2(g)->2CO2(g)+3H2O(l)\" \n",
      "T=298 \t\t\t\t#temperature during the reaction[K]\n",
      "Hw=-285.83 \t\t\t#standard heat of formation of liquid water [KJ/mol]\n",
      "He=-277.69 \t\t\t#standard heat of formation of liquid ethanol[KJ/mol]\n",
      "Hco2=-393.51 \t\t\t#standard heat of formation of carbon dioxide[KJ/mol]\n",
      "Ho2=0 \t\t\t\t#standard heat of formation of oxygen gas[KJ/mol]\n",
      "H=2*Hco2+3*Hw-He-3*Ho2 \t\t#standard heat of reaction\n",
      "print\"H(standard heat of reaction)=\",H,\"kJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C2H5OH(l)+3O2(g)->2CO2(g)+3H2O(l)\n",
        "H(standard heat of reaction)= -1366.82 kJ\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.12,Page no:33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "print\"CO(g)+NO(g)->0.5N2(g)+CO2(g)\" \n",
      "Hrxn=-374 \t\t#standard heat of reaction[KJ/mol]\n",
      "Hno=90.25 \t\t#standard heat of formation of NO[KJ/mol]\n",
      "Hco2=-393.51 \t\t#standard heat of formation of CO2[KJ/mol]\n",
      "Hn2=0 \t\t\t#standard heat of formation of N2[KJ/mol]\n",
      "T=298 \t\t\t#temperature of reaction [K]\n",
      "Hco=0.5*Hn2+Hco2-Hno-Hrxn \t#standard heat of formation of CO[KJ/mol]\n",
      "print\"Hco(standard heat of formation)=\",Hco,\"kJ mol^-1\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "CO(g)+NO(g)->0.5N2(g)+CO2(g)\n",
        "Hco(standard heat of formation)= -109.76 kJ mol^-1\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.13,Page no:34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "H1=-29.6 \t\t#the standard heat of hydrogenation of gaseous propylene to propane[Kcal]\n",
      "H2=-530.6 \t\t#the heat of combustion of propane[Kcal] \n",
      "H3=-94.0 \t\t#the heat of formation of carbon dioxide[Kcal]\n",
      "H4=-68.3 \t\t#the heat of formation of liquid water[Kcal]\n",
      "\n",
      "\n",
      "print\"C3H6(g)+4.5O2(g)->3CO2(g)+3H2O(l)\" \n",
      "H5=(3*H3+4*H4)-(H1+H2)#[Kcal]\n",
      "print\"\\n H(standard heat of combustion)=\",H5,\"Kcal\"\n",
      "print\"3C(s)+3H2(g)->C3H6(g)\" \n",
      "H6=-H5+3*H3+3*H4 #[Kcal]\n",
      "print\"\\n H(standard heat of formation)=\",H6,\"Kcal\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C3H6(g)+4.5O2(g)->3CO2(g)+3H2O(l)\n",
        "\n",
        " H(standard heat of combustion)= 5.0 Kcal\n",
        "3C(s)+3H2(g)->C3H6(g)\n",
        "\n",
        " H(standard heat of formation)= -491.9 Kcal\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.14,Page no:34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "H1=-114.1 \t\t\t#standard heat of reaction:2NO(g)+O2(g)->2NO2(g) [KJ/mol]\n",
      "H2=-110.2 \t\t\t#standard heat of reaction:4NO2(g)+O2(g)->2N2O5(g) [KJ/mol]\n",
      "H3=180.5 \t\t\t#standard heat of reaction:N2(g)+O2(g)->2NO(g) [KJ/mol]\n",
      "\n",
      "\t#reacton:N2(g)+2.5O2(g)->N2O5(g)\n",
      "H4=(2*H1+H2+2*H3)/2 \t\t#standard heat of formation of N2O5[KJ/mol]\n",
      "print\"H(standard heat of formation of N2O5)=\",H4,\"kJ/mol\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "H(standard heat of formation of N2O5)= 11.3 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.15,Page no:35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Hc=-5645 \t\t#standard enthalpy of combustion of \t\t\treaction:C12H22O11(s)+12O2(g)->12CO2(g)+11H2O(l) [KJ/mol]\n",
      "Hf1=-393.51 \t\t#standard heat of formation of CO2: C(s)+O2(g)->CO2(g) [KJ/mol]\n",
      "Hf2=-285.83 \t\t#standard heat of formation of H2O: H2(g)+0.5O2(g)->H2O(l) [KJ/mol]\n",
      "\n",
      "\t#reaction:12C(s)+11H2(g)+5.5O2(g)->C12H22O11(s)\n",
      "Hf=12*Hf1+11*Hf2-Hc \t#[KJ/mol]\n",
      "print\"Hf(standard heat of formation of solid sucrose)=\",Hf,\"KJ/mol(approx)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hf(standard heat of formation of solid sucrose)= -2221.25 KJ/mol(approx)\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.16,Page no:37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Hf1=-46.11 \t\t\t#standard heat of formation of NH3 at 298K \t\t\t\t#reaction:0.5N2(g)+1.5H2(g)->NH3(g) [KJ/mol]\n",
      "Cp1=29.125 \t\t\t#molar heat capacity at constant pressure for N2(g)[J/K/mol]\n",
      "Cp2=28.824 \t\t\t#molar heat capacity at constant pressure for H2(g)[J/K/mol]\n",
      "Cp3=35.06 \t\t\t#molar heat capacity at constant pressure for NH3(g)[J/K/mol]\n",
      "T1=298 \t\t\t\t#initial temperature[K]\n",
      "T2=400 \t\t\t\t#final temperature[K]\n",
      "\n",
      "\t\n",
      "Cp=Cp3-0.5*Cp1-1.5*Cp2 \t\t#[J/K/mol]\n",
      "T=T2-T1 \t\t\t#[K]\n",
      "Hf2=Hf1+Cp*0.001*T \t\t#standard heat of formation for NH3 at 400K[KJ/mol]\n",
      "print\"\\n Hf2(standard heat of formation for NH3 at 400K =\",round(Hf2,3),\"kJ/mol\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " Hf2(standard heat of formation for NH3 at 400K = -48.429 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.17,Page no:38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.optimize import fsolve\n",
      "from scipy import integrate\n",
      "dH_298=-241.82       #Std Heat of formation at 298 K [kJ mol^-1]\n",
      "dH_298=dH_298*1000   # in  [J mol^-1]\n",
      "T1=298               #[K]\n",
      "T2=1273             #[K]\n",
      "def f(T):\n",
      "    Cp_H2g=(29.07-((0.836*10**-3)*T)+((20.1*10**-7)*T**2))\n",
      "    Cp_O2g=25.72+(12.98*10**-3)*T-(38.6*10**-7)*T**2\n",
      "    Cp_H2Og=30.36+(9.61*10**-3)*T+(11.8*10**-7)*T**2\n",
      "    delta_Cp=(Cp_H2Og-(Cp_H2g+(1.0/2.0)*Cp_O2g))\n",
      "    return(delta_Cp)\n",
      "\n",
      "dHK=integrate.quad(f,T1,T2)\n",
      "\n",
      "dH_1273=dH_298+dHK[0]\n",
      "dH_1273=dH_1273/1000\n",
      "print\"Heat of formation of H2O(g) at 1000 C=\",round(dH_1273,1),\"kJ mol^-1  (APPROXIMATE)\"\n",
      "\n",
      "print\"NOTE:\"\n",
      "print\"Slight variation in answer,because integration is not done precisely in the book\"\n",
      "print\"In the book,it is written as:-7497.46 instead of -7504.3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat of formation of H2O(g) at 1000 C= -249.3 kJ mol^-1  (APPROXIMATE)\n",
        "NOTE:\n",
        "Slight variation in answer,because integration is not done precisely in the book\n",
        "In the book,it is written as:-7497.46 instead of -7504.3\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.18,Page no:40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "H1=435.0 \t\t\t#bond dissociation energy for: CH4->CH3+H [KJ/mol]\n",
      "H2=364.0 \t\t\t#bond dissociation energy for:CH3->CH2+H [KJ/mol]\n",
      "H3=385.0 \t\t\t#bond dissociation energy for:CH2->CH+H [KJ/mol] \n",
      "H4=335.0 \t\t\t#bond dissociation energy for:CH->C+H [KJ/mol]\n",
      "H=(H1+H2+H3+H4)/4 \t#the bond energy for C-H bond in CH4 [KJ/mol]\n",
      "print\"\\n H(the C-H bond energy in CH4)=\",round(H,1),\"kJ/mol\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " H(the C-H bond energy in CH4)= 379.8 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.19,Page no:40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "H1=-84.68 \t\t\t#heat of formation : 2C(s)+3H2(g)->C2H6(g) [KJ/mol]\n",
      "H2=2*716.68 \t\t\t#heat of formation : 2C(s)->2C(g) [KJ]\n",
      "H3=3*436 \t\t\t#heat of formation : 3H2(g)->6H(g) [KJ]\n",
      "H4=412 \t\t\t\t#taking it as bond energy for one C-H bond[KJ/mol]\n",
      "\n",
      "\n",
      "H=H2+H3-H1 \t\t\t#heat of reaction : C2H6(g)->2C(g)+6H(g) [KJ/mol]\n",
      "H5=H-6*H4 \t\t\t#bond energy for one C-C bond in ethane bond [KJ/mol]\n",
      "print\"\\n Hc-c(bond energy for one C-C bond in ethane bond)=\",H5,\"kJ/mol\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " Hc-c(bond energy for one C-C bond in ethane bond)= 354.04 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.20,Page no:42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t#MgBr2(s)-->Mg(s)+Br2(l)-->Mg(g)+Br2(l)-->Mg(g)+Br2(g)-->Mg(g)+2Br(g)-->Mg+2(g) + 2e(g) + \t2Br(g)-->Mg+2(g) + 2Br-(g)\n",
      "H1=-524 \t\t#enthalpy of formation of MgBr2(s) from its element [KJ/mol]\n",
      "H2=148 \t\t\t#enthalpy of sublimation of Mg(s) [KJ/mol]\n",
      "H3=31 \t\t\t#enthalpy of vaporization of Br2(l) [KJ/mol]\n",
      "H4=193 \t\t\t#enthalpy of dissociation Br2 to 2Br(g) [KJ/mol]\n",
      "H5=2187 \t\t#enthalpy of ionization of Mg(g) to Mg+2(g) [KJ/mol]\n",
      "H6=-650 \t\t#enthalpy of formation of Br-(g) [KJ/mol]\n",
      "\n",
      "H=-H1+H2+H3+H4+H5+H6 \t#lattice enthalpy [KJ/mol]\n",
      "print\"\\n H(lattice enthalpy of magnesium bromide)=\",H,\"kJ/mol\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " H(lattice enthalpy of magnesium bromide)= 2433 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.21,Page no:44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.optimize import fsolve\n",
      "from scipy import integrate\n",
      "\n",
      "\n",
      "dH1_298=-881.25      #[kJ/mol]\n",
      "dH2_298=43.60        #[kJ/mol]\n",
      "dH3_298=2*dH2_298   #[kJ/mol]\n",
      "dH4_298=dH1_298+dH3_298     #[kJ/mol]\n",
      "dH_heat=-dH4_298*1000       #[J/mol]\n",
      "\n",
      "\n",
      "def f(T2):\n",
      "    def g(T):\n",
      "        Cp_CO2g=26.0+((43.5*10**-3)*T)-((148.3*10**-7)*T**2)\n",
      "        Cp_H2Og=30.36+((9.61*10**-3)*T)+((11.8*10**-7)*T**2)\n",
      "        Cp_N2g=27.30-((5.23*10**-3)*T)-((0.04*10**-7)*T**2)\n",
      "        sig_nCpf=Cp_CO2g+2*Cp_H2Og+8*Cp_N2g\n",
      "        return(sig_nCpf)\n",
      "    crt=integrate.quad(g,298,T2)\n",
      "    ct=crt[0]-dH_heat\n",
      "    return(ct)\n",
      "T2=fsolve(f,2)\n",
      "print \"T2,maximum flame temperature is :\",round(T2[0],2),\"K\"\n",
      "print\"Calculation mistake in book,wrongly written as:2250 K\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "T2,maximum flame temperature is : 2957.06 K\n",
        "Calculation mistake in book,wrongly written as:2250 K\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}