{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 12:Thermodynamics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex12.1:pg-413"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The work done by the gas is= -220.0  J\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example 12_1\n",
    " \n",
    "  \n",
    "  #To find the work done by the gas\n",
    "d1=800           #Units in meter**3\n",
    "d2=500           #Units in meter**3\n",
    "p1=5*10**5       #Units in Pa\n",
    "w1=p1*(d1-d2)*10**-6      #Units in J\n",
    "p2=2*10**5       #Units in Pa\n",
    "d3=200*10**-6        #Units in meter**3\n",
    "p3=3*10**5         #Units in Pa\n",
    "w2=(p2*d3)+(0.5*p3*d3)        #Units in J\n",
    "print \"The work done by the gas is=\",round(-(w1+w2)),\" J\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex12.2:pg-415"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The estimated Cv value of nitric acid is Cv= 693.0  J/Kg K\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example 12_2\n",
    " \n",
    "  \n",
    "  #To estimate the Cv of nitric acid\n",
    "r=8314        #Units in J/Kmol K\n",
    "m=30        #Units in Kg/Kmol\n",
    "Cv=2.5*(r/m)         #Units in J/Kg K\n",
    "print \"The estimated Cv value of nitric acid is Cv=\",round(Cv),\" J/Kg K\"\n",
    "  #in textbook the answer is printed wrong as Cv=690 J/Kg K correct answer is 692 J/Kg K\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex12.3:pg-415"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The final temperature is T2= 886.0  K\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example 12_3\n",
    " \n",
    "  \n",
    "  #To find the final temperature\n",
    "t1=27      #units in Centigrade\n",
    "t1=t1+273   #Units in K\n",
    "gama=1.4     #Units in Constant\n",
    "p1=1        #units in Pa\n",
    "v1_v2=15      #Units of in ratio\n",
    "logT2=math.log10(t1)-((gama-1)*(math.log10(p1)-math.log10(v1_v2)))\n",
    "T2=10**logT2                #Uniys in K\n",
    "print \"The final temperature is T2=\",round(T2),\" K\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex12.4:pg-417## "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This type of process is termed as throttling process and described by the equation Delta U=- Delta W\n",
      "\n",
      "Where Delta W is the work done\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example 12_4\n",
    " \n",
    "  \n",
    "  #To describe the Temperature changes of the gas\n",
    "print \"This type of process is termed as throttling process and described by the equation Delta U=- Delta W\\n\"\n",
    "print \"Where Delta W is the work done\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex12.5:pg-418## "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The entropy is Delta S= 24.5  J/K\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example 12_5\n",
    " \n",
    "  \n",
    "  #To findout by how much the entropy of the system changes\n",
    "m=20         #Units in gm\n",
    "alpha=80      #Units in cal/gm\n",
    "t=4.184                 #Units in J/Cal\n",
    "Q=m*alpha*t        #Units in J\n",
    "T=273        #Units in K\n",
    "S=Q/T          #Units in J/K\n",
    "print \"The entropy is Delta S=\",round(S,1),\" J/K\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex12.6:pg-419## "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The amount of Electricity is required is Delta W= 11666.0  J\n"
     ]
    }
   ],
   "source": [
    "  import math   #Example 12_6\n",
    " \n",
    "  \n",
    "  #To findout how much electricity is needed\n",
    "Tc=278           #Units in K\n",
    "Th=293         #Units in K\n",
    "COP=Tc/(Th-Tc)            #Units in ratio\n",
    "Qc=210000            #Units in J\n",
    "W=Qc/COP                     #Units in J\n",
    "print \"The amount of Electricity is required is Delta W=\",round(W),\" J\"\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
}