summaryrefslogtreecommitdiff
path: root/Thermodynamics_Demystified_by_M_C_Potter/5-The_Second_Law_of_Thermodynamics.ipynb
diff options
context:
space:
mode:
authorPrashant S2020-04-14 10:25:32 +0530
committerGitHub2020-04-14 10:25:32 +0530
commit06b09e7d29d252fb2f5a056eeb8bd1264ff6a333 (patch)
tree2b1df110e24ff0174830d7f825f43ff1c134d1af /Thermodynamics_Demystified_by_M_C_Potter/5-The_Second_Law_of_Thermodynamics.ipynb
parentabb52650288b08a680335531742a7126ad0fb846 (diff)
parent476705d693c7122d34f9b049fa79b935405c9b49 (diff)
downloadall-scilab-tbc-books-ipynb-master.tar.gz
all-scilab-tbc-books-ipynb-master.tar.bz2
all-scilab-tbc-books-ipynb-master.zip
Merge pull request #1 from prashantsinalkar/masterHEADmaster
Initial commit
Diffstat (limited to 'Thermodynamics_Demystified_by_M_C_Potter/5-The_Second_Law_of_Thermodynamics.ipynb')
-rw-r--r--Thermodynamics_Demystified_by_M_C_Potter/5-The_Second_Law_of_Thermodynamics.ipynb518
1 files changed, 518 insertions, 0 deletions
diff --git a/Thermodynamics_Demystified_by_M_C_Potter/5-The_Second_Law_of_Thermodynamics.ipynb b/Thermodynamics_Demystified_by_M_C_Potter/5-The_Second_Law_of_Thermodynamics.ipynb
new file mode 100644
index 0000000..ec2f0ba
--- /dev/null
+++ b/Thermodynamics_Demystified_by_M_C_Potter/5-The_Second_Law_of_Thermodynamics.ipynb
@@ -0,0 +1,518 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 5: The Second Law of Thermodynamics"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.10: Steam_in_a_rigid_container.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"T1=300+273 // initial temperature in kelvin\n",
+"P1=600 // initial pressure in kPa\n",
+"P2=40 // final pressure in kPa\n",
+"\n",
+"//solution\n",
+"//please refer to steam table for values\n",
+"v1=0.4344 // specific volume from steam table @ 573k and 600 kPa\n",
+"v2=v1 // rigid container\n",
+"u1=2801 // specific internal energy from steam table @ 573k and 600 kPa\n",
+"s1=7.372 // specific entropy @ 600 kPa and 573 K\n",
+"\n",
+"vg2=0.4625 // specific volume of saturated vapour @ 40 kPa and 573 K\n",
+"vf2=0.0011 // specific volume of saturated liquid @ 40 kPa and 573 K\n",
+"sf2=1.777 // specific entropy of saturated liquid @ 40 kPa and 573 K\n",
+"sg2=5.1197 // specific entropy of saturated vapour @ 40 kPa and 573 K\n",
+"x=(v2-vf2)/(vg2-vf2)// quality of steam using pure substance relation\n",
+"\n",
+"s2=sf2+x*sg2 // overall specific enthalpy at quality 'x' \n",
+"delS=s2-s1 // entropy change\n",
+"printf(' The entropy change is %0.3f kJ/kg.K \n ',delS)\n",
+"\n",
+"//heat transfer\n",
+"uf2=604.3 //specific internal energy of saturated liquid @ 40 kPa and 573 K\n",
+"ug2=1949.3 //specific internal energy of saturated vapour @ 40 kPa and 573 K\n",
+"u2=uf2+x*ug2 //specific internal energy @ quality x\n",
+"q=u2-u1 // heat transfer in kJ/kg from first law as W=0\n",
+"printf(' The heat transfer is %.0f kJ/kg',q)\n",
+"// the answers are approximated in textbook but here they are precise thus minute difference is there\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.11: Air_in_one_half_of_an_insulated_tank.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"v1=0.5 // assumed as air is filled in half of the tank\n",
+"v2=1 // final volume when partition is removed\n",
+"R=0.287 // gas contant for air\n",
+"//solution\n",
+"q=0 // heat transfer is zero\n",
+"w=0 // work done is zero\n",
+"// temperatue is constant as no change in internal energy by first law\n",
+"dels=R*log(v2/v1)// change in entropy when temperature is constant\n",
+"printf('The change in specific entropy is %.3f kJ/kg.K',dels)\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.12: Two_kilograms_of_steam.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"T1=400+273 // initial temperature in kelvin\n",
+"P=600 // pressure in kPa\n",
+"Tsurr=25+273 // surrounding temperature in K\n",
+"m=2 // mass of steam in kg\n",
+"\n",
+"//solution\n",
+"//please refer to steam table for values\n",
+"s1=7.708 // specific entropy of steam @ 400 degree celsius and 0.6 MPa\n",
+"s2=1.9316// specific enropy of condensed water @ 25 degree celsius and 0.6 MPa\n",
+"delSsys=m*(s2-s1) // entropy change in system i.e of steam\n",
+"\n",
+"h1=3270 // specific enthalpy of steam @ 400 degree celsius and 0.6 MPa\n",
+"h2=670.6//specific enropy of condensed water @ 25 degree celsius and 0.6 MPa\n",
+"\n",
+"Q=m*(h1-h2)// heat transfer at constant pressure\n",
+"delSsurr=Q/Tsurr // entropy change in surroundings\n",
+"\n",
+"sigma=delSsys+delSsurr // net entropy change\n",
+"\n",
+"printf('The net entropy production is %.1f kJ/K',sigma)\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.13: Superheated_steam_enters_a_turbine.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"T1=600+273 // initial temperature in kelvin\n",
+"P1=2 // initial pressure in MPa\n",
+"P2=10 // final pressure in kPa\n",
+"mdot=2 // mass flow rate in kg/s\n",
+"\n",
+"//solution\n",
+"//please refer to steam table for values\n",
+"h1=3690 // specific enthalpy in kJ/kg @ 2MPa and 600 degree celsius\n",
+"s1=7.702 //specific entropy in kJ/kg.K @ 2MPa and 600 degree celsius\n",
+"s2=s1 // Reversible adiabatic process thus entropy is constant\n",
+"sf2=0.6491 //specific entropy of saturated liquid from steam table @ 10 kPa\n",
+"sg2=8.151 //specific entropy of saturated vapour from steam table @ 10 kPa\n",
+"\n",
+"x2=(s2-sf2)/(sg2-sf2) // quality of steam at turbine exit\n",
+"\n",
+"h2f=191.8 //specific enthalpy of saturated liquid from steam table @ 10 kPa\n",
+"h2g=2584.8 //specific enthalpy of saturated vapour from steam table @ 10 kPa\n",
+"h2=h2f+x2*(h2g-h2f) // specific enthalpy @ quality 'x' \n",
+"\n",
+"WdotT=mdot*(h1-h2)// from work done in adiabatic process\n",
+"printf(' The maximum power output is %.0f kJ/s',WdotT)\n",
+"// the answers are approximated in textbook but here they are precise thus minute difference is there"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.14: turbine_is_assumed_to_be_80_percent_efficient.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"\n",
+"T1=600+273 // initial temperature in kelvin\n",
+"P1=2 // initial pressure in MPa\n",
+"P2=10 // final pressure in kPa\n",
+"mdot=2 // mass flow rate in kg/s\n",
+"EffT=0.8 // efficiency of turbine \n",
+"WdotT=2496 // theoritical power of turbine in kW\n",
+"\n",
+"//solution\n",
+"Wdota=EffT*WdotT // actual power output of turbine\n",
+"h1=3690 // specific enthalpy @ 2MPa and 600 degree celsius\n",
+"h2=h1-(Wdota/mdot) // final enthalpy from first law of thermodynamics\n",
+"\n",
+"T2=((h2-2688)/(2783-2688))*(150-100)+100 // by interpolating from steam table @ P2= 10 kPa, h2=2770 \n",
+"s2=8.46 // final specific entropy by interpolation from steam table\n",
+"\n",
+"printf('The temperature by interpolation is %.0f degree celsius \n',T2)\n",
+"printf('The final entropy by interpolation is %.2f kJ/kg.K',s2)\n",
+"// The temperature and entropy are found by interpolation from steam table and cannot be shown here.\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.15: preheater_is_used_in_a_power_plant_cycle.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"\n",
+"T2=250 // temperature of steam in degree celsius\n",
+"mdot2=0.5 // mass flow rate of steam in kg/s\n",
+"T1=45 // temperature of water in degree celsius\n",
+"mdot1=4 // mass flow rate of water in kg/s\n",
+"P=600 // pressure in kPa\n",
+"\n",
+"\n",
+"mdot3=mdot1+mdot2 // by mass balance\n",
+"\n",
+"h2=2957 // specific enthalpy in kJ/kg of steam @ 600 Kpa from steam table\n",
+"h1=188.4 // specific enthalpy in kJ/kg of water @ 600 Kpa from steam table\n",
+"\n",
+"h3=(mdot1*h1+mdot2*h2)/mdot3 // specific enthalpy in kJ/kg at exit\n",
+"\n",
+"// by interpolation from saturated steam table\n",
+"T3=(h3-461.3)*10/(503.7-461.3)+110 // temperature of mixture\n",
+"\n",
+"sf3=1.508 // entropy of saturated liquid in kJ/kg.K at 600Kpa and T3 temperature from steam table\n",
+"s3=sf3 \n",
+"s2=7.182 // entropy of superheated steam in kJ/kg.K @ 600Kpa from steam table\n",
+"s1=0.639 // entropy of entering water in kJ/kg.K at T= 45 degree celsius\n",
+"\n",
+"sigmaprod=mdot3*s3-mdot2*s2-mdot1*s1\n",
+"printf('The rate of entropy production is %0.3f kW/K ',sigmaprod)\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.4: Carnot_engine.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"Th=200+273 // higher temperture in kelvin \n",
+"Tl=20+273 // lower temperture in kelvin\n",
+"Wdot=15 // output of engine in kW\n",
+"\n",
+"ef=1-(Tl/Th) // carnot efficiency\n",
+"\n",
+"Qhdot=Wdot/ef // heat supplied by reservoir\n",
+"printf(' The heat suppled by higher temperature reservoir is %.2f kW \n ',Qhdot)\n",
+"// using forst law\n",
+"Qldot=Qhdot-Wdot // heat rejected to reservoir\n",
+"printf(' The heat suppled by lower temperature reservoir is %.2f kW',Qldot)\n",
+"\n",
+" \n",
+" "
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.5: percentage_increase_in_work.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"TL1=-5+273 // lower temperature in kelvin for first situation\n",
+"TH=20+273 // higher temperature in kelvin\n",
+"TL2=-25+273 //lower temperature in kelvin for second situation\n",
+"\n",
+"//solution\n",
+"\n",
+"COP1=TL1/(TH-TL1) // carnot refrigerator COP for first situation\n",
+"// Let Heat be 100 kJ\n",
+"QL=100 // assumption\n",
+"W1=QL/COP1 // work done for situation 1\n",
+"\n",
+"// for situation 2\n",
+"COP2=TL2/(TH-TL2) // COP carnot for second situation\n",
+"W2=QL/COP2 // work done\n",
+"\n",
+"Per=(W2-W1)*100/W1 // percentage increase in work done \n",
+"printf(' The perccentage increase in work is %.1f%%',Per)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.6: paddle_wheel_work.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"T1=20+273 // initial temperature in kelvin\n",
+"P=200 // pressure in kPa\n",
+"V=2 //volume in m^3\n",
+"R=0.287 // gas constant for air\n",
+"W=720 // work done on air in kJ\n",
+"Cv=0.717 // specific heat at constant volume for air\n",
+"\n",
+"//solution\n",
+"m=(P*V)/(R*T1)// mass of air\n",
+"\n",
+"T2=T1+(W/(m*Cv))// final temperature in kelvin\n",
+"\n",
+"delS=m*Cv*log(T2/T1) // ENROPY CHANGE FOR CONSTANT VOLUME PROCESS\n",
+"printf(' The Entropy increase is %.3f kJ/K ',delS)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.7: a_combustion_process_in_a_cylinder.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"T1=350+273 // initial temperature in kelvin\n",
+"P1=1200 // initial pressure in kPa\n",
+"P2=140 // final pressure in kPa\n",
+"k=1.4 // polytopic index for air\n",
+"Cv=0.717 // specific heat at constant volume for air\n",
+"//solution\n",
+"T2=T1*((P2/P1)**((k-1)/k)) // reversible adiabatic process relation\n",
+"\n",
+"w=-Cv*(T2-T1) // work done by gases in reversible adiabatic process\n",
+"printf(' The work done by gases is %.0f kJ/kg',w)\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.8: with_variable_specific_heats.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"T1=20+273 // initial temperature in kelvin\n",
+"P1=200 // pressure in kPa\n",
+"V=2 //volume in m^3\n",
+"R=0.287 // gas constant for air\n",
+"W=-720 // negative as work is done on air in kJ\n",
+"\n",
+"//solution\n",
+"\n",
+"m=(P1*V)/(R*T1)// mass of air\n",
+"\n",
+"u1=209.1 //specific internal energy of air at 293K and 200 kPa from table E.1\n",
+"s1=1.678 // by interpolation from table E.1\n",
+"// change in internal energy= work done\n",
+"u2=-(W/m)+u1 // final internal energy\n",
+"T2=501.2// final temperature interpolated from table E.1 corresponding to value of u2\n",
+"s2=2.222 // value of s from table E.3 by interpolating from corresponding to value of u2\n",
+"\n",
+"P2=P1*(T2/T1) // final pressure in kPa\n",
+"\n",
+"delS=m*(s2-s1-R*log(P2/P1))// entropy change\n",
+"printf(' The Entropy increase is %.3f kJ/K ',delS)\n",
+"\n",
+"\n",
+"\n",
+" "
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9: a_reversible_adiabatic_process.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"// initialization of variables\n",
+"T1=350+273 // initial temperature in kelvin\n",
+"P1=1200 // initial pressure in kPa\n",
+"P2=140 // final pressure in kPa\n",
+"k=1.4 // polytopic index for air\n",
+"\n",
+"//solution\n",
+"// The values are taken from table E.1\n",
+"Pr660=23.13// relative pressure @ 660K\n",
+"Pr620=18.36// relative pressure @ 620K\n",
+"Pr1=((Pr660-Pr620)*3/40)+Pr620 // relative pressure by interpolation\n",
+"Pr2=Pr1*(P2/P1) // relative pressure at state 2\n",
+"\n",
+"Pr340=2.149 // relative pressure @ 340K\n",
+"Pr380=3.176 // relative pressure @ 380K\n",
+"T2=((Pr2-Pr340)/(Pr380-Pr340))*40+340 // interpolating final temperature from table E.1\n",
+"\n",
+"// now interpolating u1 AND u2 from table E.1\n",
+"u620=451.0// specific internal energy @ 620k\n",
+"u660=481.0// specific internal energy @ 660k\n",
+"u1=(u660-u620)*(3/40)+u620 // initial internal energy\n",
+"\n",
+"u380=271.7 //specific internal energy @ 380k\n",
+"u340=242.8 //specific internal energy @ 340k\n",
+"u2=((Pr2-Pr340)/(Pr380-Pr340))*(u380-u340)+u340 // final internal energy\n",
+"\n",
+"w=u2-u1 // work= change in internal energy\n",
+"printf(' The work done by gas is %.0f kJ/kg',w)\n",
+"// The answer is slightly different as values are approximated in textbook\n",
+"\n",
+"\n",
+""
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}