summaryrefslogtreecommitdiff
path: root/Thermodynamics_by_Gaggioli_and_Obert/11-The_Ideal_gas_and_mixture_relationships.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_by_Gaggioli_and_Obert/11-The_Ideal_gas_and_mixture_relationships.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_by_Gaggioli_and_Obert/11-The_Ideal_gas_and_mixture_relationships.ipynb')
-rw-r--r--Thermodynamics_by_Gaggioli_and_Obert/11-The_Ideal_gas_and_mixture_relationships.ipynb611
1 files changed, 611 insertions, 0 deletions
diff --git a/Thermodynamics_by_Gaggioli_and_Obert/11-The_Ideal_gas_and_mixture_relationships.ipynb b/Thermodynamics_by_Gaggioli_and_Obert/11-The_Ideal_gas_and_mixture_relationships.ipynb
new file mode 100644
index 0000000..cbb9ad7
--- /dev/null
+++ b/Thermodynamics_by_Gaggioli_and_Obert/11-The_Ideal_gas_and_mixture_relationships.ipynb
@@ -0,0 +1,611 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 11: The Ideal gas and mixture relationships"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.10: Entropy_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"T2=546.6 //R\n",
+"T1=520 //R\n",
+"T3=560 //R\n",
+"v2=1389.2\n",
+"v1=186.2\n",
+"R0=1.986\n",
+"c1=5.02\n",
+"c2=4.97\n",
+"n1=1\n",
+"n2=2\n",
+"v3=1203\n",
+"//calculations\n",
+"ds1=n1*c1*log(T2/T1) + n1*R0*log(v2/v1)\n",
+"ds2=n2*c2*log(T2/T3)+n2*R0*log(v2/v3)\n",
+"ds=ds1+ds2\n",
+"ds3=n1*c1*log(T2/T1)+n2*c2*log(T2/T3)\n",
+"ds4=n2*R0*log(v2/v3)+ n1*R0*log(v2/v1)\n",
+"dss=ds3+ds4\n",
+"//results\n",
+"printf('Change in entropy for gas 1 = %.3f Btu/R',ds1)\n",
+"printf('\n Change in entropy for gas 1 = %.3f Btu/R',ds2)\n",
+"printf('\n Net change in entropy = %.3f Btu/R',ds)\n",
+"printf('\n In case 2, change in entropy = %.3f Btu/R',dss)\n",
+"disp('The answer is a bit different due to rounding off error in the textbook')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.11: Entropy_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"m1=1 //lbm\n",
+"m2=0.94 //lbm\n",
+"M1=29\n",
+"M2=18\n",
+"p1=50 //psia\n",
+"p2=100 //psia\n",
+"t1=250 +460 //R\n",
+"R0=1.986\n",
+"cpa=6.96\n",
+"cpb=8.01\n",
+"//calculations\n",
+"xa = (m1/M1)/((m1/M1)+ m2/M2)\n",
+"xb=1-xa\n",
+"t2=t1*(p2/p1)^(R0/(xa*cpa+xb*cpb))\n",
+"d=R0/(xa*cpa+xb*cpb)\n",
+"k=1/(1-d)\n",
+"dsa=cpa*log(t2/t1) -R0*log(p2/p1)\n",
+"dSa=(m1/M1)*dsa\n",
+"dSw=-dSa\n",
+"dsw=dSw*M2/m2\n",
+"//results\n",
+"printf('Final remperature = %d R',t2)\n",
+"printf('\n Change in entropy of air = %.3f btu/mole R and %.5f Btu/R',dsa,dSa)\n",
+"printf('\n Change in entropy of water = %.4f btu/mole R and %.5f Btu/R',dsw,dSw)\n",
+"disp('The answers are a bit different due to rounding off error in textbook')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.12: Volume_and_mass_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"T=250 + 460 //R\n",
+"p=29.825 //psia\n",
+"pt=50 //psia\n",
+"vg=13.821 //ft^3/lbm\n",
+"M=29\n",
+"R=10.73\n",
+"//calculations\n",
+"pa=pt-p\n",
+"V=1/M *R*T/pa\n",
+"ma=V/vg\n",
+"xa=p/pt\n",
+"mb=xa/M *18/(1-xa)\n",
+"//results\n",
+"printf('In case 1, volume occupied = %.2f ft^3',V)\n",
+"printf('\n In case 1, mass of steam = %.2f lbm steam',ma)\n",
+"printf('\n In case 2, mass of steam = %.3f lbm steam',mb)\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.13: Percentage_calculation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"ps=0.64 //psia\n",
+"p=14.7 //psia\n",
+"M=29\n",
+"M2=46\n",
+"//calculations\n",
+"xa=ps/p\n",
+"mb=xa*9/M *M2/(1-xa)\n",
+"//results\n",
+"printf('percentage = %.1f percent',mb*100)\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.14: Partial_Pressure_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"ps=0.5069 //psia\n",
+"p=20 //psia\n",
+"m1=0.01\n",
+"m2=1\n",
+"M1=18\n",
+"M2=29\n",
+"//calculations\n",
+"xw= (m1/M1)/(m1/M1+m2/M2)\n",
+"pw=xw*p\n",
+"//results\n",
+"printf('partial pressure of water vapor = %.3f psia',pw)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.1: Work_calculatio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"n=1.3\n",
+"T1=460+60 //R\n",
+"P1=14.7 //psia\n",
+"P2=125 //psia\n",
+"R=1545\n",
+"M=29\n",
+"//calculations\n",
+"T2=T1*(P2/P1)^((n-1)/n)\n",
+"wrev=R/M *(T2-T1)/(1-n)\n",
+"//results\n",
+"printf('Work done = %d ft-lbf/lbm',wrev)\n",
+"disp('The answer is a bit different due to rounding off error in textbook')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.2: Kinetic_energy_calculation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"P2=10 //psia\n",
+"P1=100 //psia\n",
+"T1=900 //R\n",
+"w=50 //Btu/lbm\n",
+"k=1.39\n",
+"cp=0.2418\n",
+"//calculations\n",
+"T2=T1*(P2/P1)^((k-1)/k)\n",
+"T2=477\n",
+"KE=-w-cp*(T2-T1)\n",
+"//results\n",
+"printf('Change in kinetic energy = %.1f Btu/lbm',KE)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.3: Temperature_calculatio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"T1=900 //R\n",
+"P1=100 //psia\n",
+"P2=10 //psia\n",
+"//calculations\n",
+"disp('From table B-9')\n",
+"pr1=8.411\n",
+"pr2=pr1*P2/P1\n",
+"T2=468 //R\n",
+"//results\n",
+"printf('Final temperature = %d R ',T2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.4: Temperature_work_and_Enthalpy_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"cr=6\n",
+"p1=14.7 //psia\n",
+"t1=60.3 //F\n",
+"M=29\n",
+"R=1.986\n",
+"//calculations\n",
+"disp('from table b-9')\n",
+"vr1=158.58 \n",
+"u1=88.62 //Btu/lbm\n",
+"pr1=1.2147\n",
+"vr2=vr1/cr\n",
+"T2=1050 //R\n",
+"u2=181.47 //Btu/lbm\n",
+"pr2=14.686\n",
+"p2=p1*(pr2/pr1)\n",
+"dw=u1-u2\n",
+"h2=u2+T2*R/M\n",
+"//results\n",
+"printf('final temperature = %d R',T2)\n",
+"printf('\n final pressure = %.1f psia',p2)\n",
+"printf('\n work done = %.2f Btu/lbm',dw)\n",
+"printf('\n final enthalpy = %.1f Btu/lbm',h2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.5: Weight_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"m1=10 //lbm\n",
+"m2=15 //lnm\n",
+"p=50 //psia\n",
+"t=60+460 //R\n",
+"M1=32\n",
+"M2=28.02\n",
+"R0=10.73 \n",
+"//calculations\n",
+"n1=m1/M1\n",
+"n2=m2/M2\n",
+"x1=n1/(n1+n2)\n",
+"x2=n2/(n1+n2)\n",
+"M=x1*M1+x2*M2\n",
+"R=R0/M\n",
+"V=(n1+n2)*R0*t/p\n",
+"rho=p/(R0*t)\n",
+"rho2=M*rho\n",
+"p1=x1*p\n",
+"p2=x2*p\n",
+"v1=x1*V\n",
+"v2=x2*V\n",
+"//results\n",
+"disp('part a')\n",
+"printf('Mole fractions of oxygen and nitrogen are %.3f and %.3f respectively',x1,x2)\n",
+"disp('part b')\n",
+"printf('Average molecular weight = %.1f ',M)\n",
+"disp('part c')\n",
+"printf('specific gas constant = %.4f psia ft^3/lbm R',R)\n",
+"disp('part d')\n",
+"printf('volume of mixture = %.1f ft^3',V)\n",
+"printf('density of mixture is %.5f mole/ft^3 and %.2f lbm/ft^3',rho,rho2)\n",
+"disp('part e')\n",
+"printf('partial pressures of oxygen and nitrogen are %.2f psia and %.2f psia respectively' ,p1,p2)\n",
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"m1=10 //lbm\n",
+"m2=15 //lnm\n",
+"p=50 //psia\n",
+"t=60+460 //R\n",
+"M1=32\n",
+"M2=28.02\n",
+"R0=10.73 \n",
+"//calculations\n",
+"n1=m1/M1\n",
+"n2=m2/M2\n",
+"x1=n1/(n1+n2)\n",
+"x2=n2/(n1+n2)\n",
+"M=x1*M1+x2*M2\n",
+"R=1545/M\n",
+"V=(n1+n2)*R0*t/p\n",
+"rho=p/(R0*t)\n",
+"rho2=M*rho\n",
+"p1=x1*p\n",
+"p2=x2*p\n",
+"v1=x1*V\n",
+"v2=x2*V\n",
+"pt=p1+p2\n",
+"vt=v1+v2\n",
+"//results\n",
+"disp('part a')\n",
+"printf('Mole fractions of oxygen and nitrogen are %.3f and %.3f respectively',x1,x2)\n",
+"disp('part b')\n",
+"printf('Average molecular weight = %.1f ',M)\n",
+"disp('part c')\n",
+"printf('specific gas constant = %.4f lbf ft/lbm R',R)\n",
+"disp('part d')\n",
+"printf('volume of mixture = %.1f ft^3',V)\n",
+"printf('\n density of mixture is %.5f mole/ft^3 and %.3f lbm/ft^3',rho,rho2)\n",
+"disp('part e')\n",
+"printf('partial pressures of oxygen and nitrogen are %.2f psia and %.2f psia respectively' ,p1,p2)\n",
+"printf('\n partial volumes of oxygen and nitrogen are %.2f ft^3 and %.2f ft^3 respectively',v1,v2)\n",
+"printf('\n Net partial pressure in case of oxygen = %.2f psia',pt)\n",
+"printf('\n Net partial volume =%.2f ft^3',vt)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.6: Analysis_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"\n",
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"m1=5.28\n",
+"m2=1.28\n",
+"m3=23.52\n",
+"//calculations\n",
+"m=m1+m2+m3\n",
+"x1=m1/m\n",
+"x2=m2/m\n",
+"x3=m3/m\n",
+"C=12/44 *m1/ m\n",
+"O=(32/44 *m1 + m2)/m\n",
+"N=m3/m\n",
+"sum1=(x1+x2+x3)*100\n",
+"sum2=(C+N+O)*100\n",
+"//results\n",
+"printf('From gravimetric analysis, co2 = %.1f percent , o2 = %.1f percent and n2 = %.1f percent',x1*100,x2*100,x3*100)\n",
+"printf('\n From ultimate analysis, co2 = %.2f percent , o2 = %.2f percent and n2 = %.2f percent',C*100,O*100,N*100)\n",
+"printf('\n Sum in case 1 = %.1f percent',sum1)\n",
+"printf('\n Sum in case 2 = %.1f percent',sum2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.7: Entropy_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"x1=1/3\n",
+"n1=1\n",
+"n2=2\n",
+"x2=2/3\n",
+"p=12.7 //psia\n",
+"cp1=7.01 //Btu/mole R\n",
+"cp2=6.94 //Btu/mole R\n",
+"R0=1.986\n",
+"T2=460+86.6 //R\n",
+"T1=460 //R\n",
+"p0=14.7 //psia\n",
+"//calculations\n",
+"p1=x1*p\n",
+"p2=x2*p\n",
+"ds1= cp1*log(T2/T1) - R0*log(p1/p0)\n",
+"ds2= cp2*log(T2/T1) - R0*log(p2/p0)\n",
+"S=n1*ds1+n2*ds2\n",
+"//results\n",
+"printf('Entropy of mixture = %.2f Btu/R',S)\n",
+"printf('\n the answer given in textbook is wrong. please check using a calculator')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.8: Internal_energy_and_entropy_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"c1=4.97 //Btu/mol R\n",
+"c2=5.02 //Btu/mol R\n",
+"n1=2\n",
+"n2=1\n",
+"T1=86.6+460 //R\n",
+"T2=50+460 //R\n",
+"//calculations\n",
+"du=(n1*c1+n2*c2)*(T2-T1)\n",
+"ds=(n1*c1+n2*c2)*log(T2/T1)\n",
+"//results\n",
+"printf('Change in internal energy = %d Btu',du)\n",
+"printf('\n Change in entropy = %.3f Btu/R',ds)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.9: Pressure_and_temperature_calculations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clc\n",
+"clear\n",
+"//Initialization of variables\n",
+"n1=1\n",
+"n2=2\n",
+"c1=5.02\n",
+"c2=4.97\n",
+"t1=60 //F\n",
+"t2=100 //F\n",
+"R0=10.73\n",
+"p1=30 //psia\n",
+"p2=10 //psia\n",
+"//calcualtions\n",
+"t=(n1*c1*t1+n2*c2*t2)/(n1*c1+n2*c2)\n",
+"V1= n1*R0*(t1+460)/p1\n",
+"V2=n2*R0*(t2+460)/p2\n",
+"V=V1+V2\n",
+"pm=(n1+n2)*R0*(t+460)/V\n",
+"//results\n",
+"printf('Pressure of mixture = %.1f psia',pm)\n",
+"printf('\n Mixing temperature = %.1f F',t)"
+ ]
+ }
+],
+"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
+}