{
 "metadata": {
  "name": "",
  "signature": "sha256:5f5d6cc341d2ab999dbe1e5a4234f374f3f6728cc09cef7967ab9dd07f94519e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10 - Second law of thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - pg 249"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Change ine entropy\n",
      "#Initialization of variables\n",
      "import math\n",
      "T2=100+273.2 #K\n",
      "T1=50+273.2 #K\n",
      "n=1 #mol\n",
      "R=1.987 #cal/deg mol\n",
      "#calculations\n",
      "dS=5/2 *n*R*2.303*math.log10(T2/T1)\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Change in entropy =\",dS,\" eu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy = 0.572  eu\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - pg 255"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Entropy change\n",
      "#Initialization of variables\n",
      "H=380 #cal\n",
      "T=273.2+32.1 #K\n",
      "#calculations\n",
      "dS=H/T\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Entropy change =\",dS,\" eu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Entropy change = 1.24  eu\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - pg 257"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Work done\n",
      "#Initialization of variables\n",
      "Ha=0\n",
      "Hb=0\n",
      "#calculations\n",
      "H=Ha+Hb\n",
      "q=H\n",
      "U=0\n",
      "w=q-H\n",
      "#results\n",
      "print '%s %d %s' %(\"Work done =\",w,\"J\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done = 0 J\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - pg 260"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the change in entropy\n",
      "#Initialization of variables\n",
      "import math\n",
      "prob=0.001\n",
      "R=1.\n",
      "N=6.023*10**23\n",
      "#calculations\n",
      "dS=1.987*2.303*math.log10(prob) /N\n",
      "#results\n",
      "print '%s %.1e %s' %(\"change in entropy =\",dS,\" eu\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "change in entropy = -2.3e-23  eu\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7 - pg 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Change in A \n",
      "#Initialization of variables\n",
      "T=373.2 #K\n",
      "c=1.987 #cal/deg\n",
      "#calculations\n",
      "w=c*T\n",
      "A=-w\n",
      "#results\n",
      "print '%s %d %s' %(\"Change in A =\",A,\"cal\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in A = -741 cal\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}