summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornice2014-08-27 16:19:01 +0530
committernice2014-08-27 16:19:01 +0530
commitb721d76da67a847cf846ce17f7cf403a6f6fb974 (patch)
tree19ffffeece58df68b99caf44e1368df73ec88b19
parent238d7e632aecde748a97437c2b5774e136a3b4da (diff)
downloadPython-Textbook-Companions-b721d76da67a847cf846ce17f7cf403a6f6fb974.tar.gz
Python-Textbook-Companions-b721d76da67a847cf846ce17f7cf403a6f6fb974.tar.bz2
Python-Textbook-Companions-b721d76da67a847cf846ce17f7cf403a6f6fb974.zip
removing unwanted
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch10_1.ipynb2533
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch11_1.ipynb331
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch12_1.ipynb503
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch13_1.ipynb312
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch14_1.ipynb723
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch15_1.ipynb2075
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch16_1.ipynb753
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch17_1.ipynb2081
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch18_1.ipynb595
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch1_2.ipynb774
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch2_2.ipynb1287
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch3_2.ipynb1545
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch4_2.ipynb1513
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch5_2.ipynb747
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch6_2.ipynb851
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch7_2.ipynb1553
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch8_2.ipynb752
17 files changed, 0 insertions, 18928 deletions
diff --git a/Chemical_Engineering_Thermodynamics/ch10_1.ipynb b/Chemical_Engineering_Thermodynamics/ch10_1.ipynb
deleted file mode 100755
index 0a1b388b..00000000
--- a/Chemical_Engineering_Thermodynamics/ch10_1.ipynb
+++ /dev/null
@@ -1,2533 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:3b50ad151f89e9ea380ce80c8112ec5468586c82e236862a1e3d8e194fa15249"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 10 : Residual Properties by Equations of State"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.2 Page Number : 334"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "# Variables\n",
- "T = 40 + 273.15;\t\t\t#[C] - Temperature\n",
- "P_1 = 0;\t\t\t#[bar]\n",
- "P_2 = 10;\t\t\t#[bar]\n",
- "V_liq = 90.45;\t\t\t#[cm**(3)/mol]\n",
- "V_liq = V_liq*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "P_sat = 4.287;\t\t\t#[bar] \n",
- "\n",
- "# For butadiene\n",
- "T_c = 425.0;\t\t\t#[K] - Critical temperature\n",
- "P_c = 43.3;\t\t\t#[bar] - Critical pressure\n",
- "P_c = P_c*10**(5);\t\t\t#[N/m**(2)]\n",
- "w = 0.195;\t\t\t# Acentric factor\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "# Let us calculate second virial coefficient at 40 C\n",
- "Tr = T/T_c;\t\t\t# Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B = ((B_0 + (w*B_1))*(R*T_c))/P_c;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- "\n",
- "# math.log(f/P) = (B*P)/(R*T)\n",
- "# f = P*exp((B*P)/(R*T))\n",
- "\n",
- "print \" The table is as follows\"\n",
- "print \" Pbar \\t\\t fbar \\t\\t phi\";\n",
- "from numpy import zeros\n",
- "P = [1,2,3,4,4.287,5,6,8,10];\n",
- "f = zeros(9);\n",
- "phi = zeros(9);\n",
- "for i in range(5):\n",
- " f[i]=P[i]*(math.exp((B*P[i]*10**(5))/(R*T)));\t\t\t#[bar] # Pressure inside the exponential term has to be in N/m**(2)\n",
- " phi[i]= (f[i]/P[i]);\n",
- " print \" %f \\t %f \\t\\t\\t %f\"%(P[i],f[i],phi[i]) \n",
- "\n",
- "f_sat = f[4];\n",
- "\n",
- "# From pressure of 4.287 bar onwards the valid equation to compute fugacity of compressed liquid is given by\n",
- "# f = f_sat*exp[V_liq*(P-P_sat)/(R*T)]\n",
- "\n",
- "for j in range(5,9):\n",
- " f[j] = f_sat*math.exp((V_liq*(P[j]-P_sat)*10**(5))/(R*T));\t#[bar] # Pressure inside the exponential term has to be in N/m**(2)\n",
- " phi[j] = f[j]/P[j]; \n",
- " print \" %f \\t %f \\t\\t\\t %f\"%(P[j],f[j],phi[j]);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The table is as follows\n",
- " Pbar \t\t fbar \t\t phi\n",
- " 1.000000 \t 0.978336 \t\t\t 0.978336\n",
- " 2.000000 \t 1.914284 \t\t\t 0.957142\n",
- " 3.000000 \t 2.809221 \t\t\t 0.936407\n",
- " 4.000000 \t 3.664484 \t\t\t 0.916121\n",
- " 4.287000 \t 3.902801 \t\t\t 0.910380\n",
- " 5.000000 \t 3.912481 \t\t\t 0.782496\n",
- " 6.000000 \t 3.926097 \t\t\t 0.654349\n",
- " 8.000000 \t 3.953471 \t\t\t 0.494184\n",
- " 10.000000 \t 3.981037 \t\t\t 0.398104\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.3 Page Number : 334"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\n",
- "# Variables\n",
- "n = 100.;\t\t\t#[mol] - No of moles\n",
- "T_1 = 600.;\t\t\t#[K] - Initial temperature\n",
- "T_2 = 300.;\t\t\t#[K] - Final temperature\n",
- "P_1 = 10.;\t\t\t#[atm] - Initial pressure\n",
- "P_1 = P_1*101325;\t\t\t#[Pa]\n",
- "P_2 = 5.;\t\t\t#[atm] - Final presssure\n",
- "P_2 = P_2*101325;\t\t\t#[Pa]\n",
- "Tc = 369.8;\t\t\t#[K] - Critical temperature\n",
- "Pc = 42.48;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.152;\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations\n",
- "# At 600 K\n",
- "Tr = T_1/Tc;\t\t\t# Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B = ((B_0 + (w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- "dB0_dT = 0.422*1.6*Tc**(1.6)*T_1**(-2.6);\t\t\t# (dB_0/dT)\n",
- "dB1_dT = 0.172*4.2*Tc**(4.2)*T_1**(-5.2);\t\t\t# (dB_1/dT)\n",
- "dB_dT = ((R*Tc)/(Pc))*(dB0_dT + w*dB1_dT);\t\t\t# dB/dT\n",
- "\n",
- "# Now let us calculate B and dB/dT at 300 K\n",
- "Tr_prime = T_2/Tc;\t\t\t# Reduced temperature\n",
- "B_0_prime = 0.083-(0.422/(Tr_prime)**(1.6));\n",
- "B_1_prime = 0.139-(0.172/(Tr_prime)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B_prime = ((B_0_prime + (w*B_1_prime))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- "dB0_dT_prime = 0.422*1.6*Tc**(1.6)*T_2**(-2.6);\t\t\t# (dB_0/dT)\n",
- "dB1_dT_prime = 0.172*4.2*Tc**(4.2)*T_2**(-5.2);\t\t\t# (dB_1/dT)\n",
- "dB_dT_prime = ((R*Tc)/(Pc))*(dB0_dT_prime + w*dB1_dT_prime);\t\t\t# dB/dT\n",
- "\n",
- "# The change in enthalpy for ideal gas is given by\n",
- "\n",
- "def f16(T): \n",
- " return -0.966+7.279*10**(-2)*T-3.755*10**(-5)*T**(2)+7.58*10**(-9)*T**(3)\n",
- "\n",
- "delta_H_ig = quad(f16,T_1,T_2)[0]\n",
- "\n",
- "delta_H_ig = delta_H_ig*4.184;\t\t\t#[J/mol]\n",
- "\n",
- "# We know that delta_H_ig = delta_U_ig + R*delta_T. Therefore change in internal energy is given by \n",
- "delta_U_ig = delta_H_ig - R*(T_2 - T_1);\t\t\t#[J/mol]\n",
- "\n",
- "# The change in entropy of ideal gas is given by \n",
- "\n",
- "def f17(T): \n",
- " return Cp_0/T\n",
- "\n",
- "#delta_S_ig = quad(f17,T_1,T_2) - R*math.log(P_2/P_1)[0]\n",
- "\n",
- "\n",
- "def f18(T): \n",
- " return (-0.966+7.279*10**(-2)*T-3.755*10**(-5)*T**(2)+7.58*10**(-9)*T**(3))/T\n",
- "\n",
- "delta_S_ig = quad(f18,T_1,T_2)[0]*4.184 - R*math.log(P_2/P_1)\n",
- "\n",
- "\n",
- "# Now let us calculate the change in enthalpy of gas. We know that\n",
- "# delta_H = delta_H_ig + delta_H_R\n",
- "# delta_H_R = H_2_R - H_1_R\n",
- "H_2_R = B_prime*P_2 - P_2*T_2*dB_dT_prime;\t\t\t# [J/mol]\n",
- "H_1_R = B*P_1 - P_1*T_1*dB_dT;\t\t\t# [J/mol]\n",
- "delta_H_R = H_2_R - H_1_R;\t\t\t# [J/mol]\n",
- "delta_H = delta_H_ig + delta_H_R;\t\t\t# [J/mol]\n",
- "\n",
- "# Let us calculate the residual entropy of gas\n",
- "S_2_R = -P_2*dB_dT_prime;\t\t\t#[J/mol-K]\n",
- "S_1_R = -P_1*dB_dT;\t\t\t#[J/mol-K]\n",
- "delta_S = delta_S_ig + (S_2_R - S_1_R);\t\t\t#[J/mol-K]\n",
- "\n",
- "# Let us calculate the residual internal energy of gas\n",
- "U_2_R = -P_2*T_2*dB_dT_prime;\t\t\t#[J/mol-K]\n",
- "U_1_R = -P_1*T_1*dB_dT;\t\t\t#[J/mol-K]\n",
- "delta_U = delta_U_ig + (U_2_R - U_1_R);\t\t\t#[J/mol-K]\n",
- "\n",
- "# For 100 mol sample,\n",
- "delta_H_ig = delta_H_ig*n*10**(-3);\t\t\t#[kJ/mol]\n",
- "delta_H = delta_H*n*10**(-3);\t\t\t#[kJ/mol]\n",
- "\n",
- "delta_U_ig = delta_U_ig*n*10**(-3);\t\t\t#[kJ/mol]\n",
- "delta_U = delta_U*n*10**(-3);\t\t\t#[kJ/mol]\n",
- "\n",
- "delta_S_ig = delta_S_ig*n*10**(-3);\t\t\t#[kJ/mol]\n",
- "delta_S = delta_S*n*10**(-3);\t\t\t#[kJ/mol]\n",
- "\n",
- "# Results\n",
- "print \" The value of delta_H = %f kJ/mol\"%(delta_H);\n",
- "print \" The value of delta_H_ig ideal gas)= %f J/mol\"%(delta_H_ig);\n",
- "print \" The value of delta_U = %f kJ/mol\"%(delta_U);\n",
- "print \" The value of delta_U_ig ideal gas) = %f kJ/mol\"%(delta_U_ig);\n",
- "print \" The value of delta_S = %f kJ/mol\"%(delta_S);\n",
- "print \" The value of delta_S_ig ideal gas) = %f kJ/mol\"%(delta_S_ig);\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of delta_H = -3130.406247 kJ/mol\n",
- " The value of delta_H_ig ideal gas)= -3096.763542 J/mol\n",
- " The value of delta_U = -2867.753839 kJ/mol\n",
- " The value of delta_U_ig ideal gas) = -2847.343542 kJ/mol\n",
- " The value of delta_S = -6.466831 kJ/mol\n",
- " The value of delta_S_ig ideal gas) = -6.358994 kJ/mol\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.4 Page Number : 337"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 35 + 273.15;\t\t\t#[K] - Temperature\n",
- "P = 10;\t\t\t#[atm] - Pressure\n",
- "P = P*101325;\t\t\t#[Pa]\n",
- "# Methane obeys the equation of state\n",
- "# Z = 1 + (P*B)/(R*T)\n",
- "\n",
- "# Calculations\n",
- "# At 35 C,\n",
- "B = -50;\t\t\t#[cm**(3)/mol]\n",
- "dB_dT = 1.0;\t\t\t#[cm**(3)/mol-K] - dB/dT\n",
- "dB_dT = dB_dT*10**(-6);\t\t\t#[m**(3)/mol-K]\n",
- "d2B_dT2 = -0.01;\t\t\t#[cm**(3)/mol-K**(2)] - d**2(B)/d(T**2)\n",
- "d2B_dT2 = d2B_dT2*10**(-6);\t\t\t#[m**(3)/mol-K**(2)]\n",
- "\n",
- "# Ideal gas molar heat capacity of methane is given by\n",
- "# Cp_0 = 4.75 + 1.2*10**(-2)*T + 0.303*10**(-5)*T**(2) - 2.63*10**(-9)*T**(3)\n",
- "\n",
- "# The molar heat capacity is given by\n",
- "# Cp = Cp_0 + Cp_R\n",
- "# For virial gas equation of state \n",
- "Cp_R = -P*T*d2B_dT2;\t\t\t#[J/mol-K]\n",
- "\n",
- "# thus heat capacity is given by \n",
- "# Cp = a + b*T + c*T**(2) + d*T**(3) - P*T*d2B_dT2\n",
- "# Putting the values, we get\n",
- "Cp = (4.75 + 1.2*10**(-2)*T + 0.303*10**(-5)*T**(2) - 2.63*10**(-9)*T**(3))*4.184 - P*T*d2B_dT2;\t\t\t#[J/mol-K]\n",
- "\n",
- "# Results\n",
- "print \" The molar heat capacity of methane is %f J/mol-K\"%(Cp);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The molar heat capacity of methane is 39.349753 J/mol-K\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.5 Page Number : 338"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "\n",
- "# Variables\n",
- "T_1 = 360;\t\t\t#[K] - Initial temperature\n",
- "P_1 = 10;\t\t\t#[bar] - Initial pressure\n",
- "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
- "Tc = 408.1;\t\t\t#[K] - Critical temperature\n",
- "Pc = 36.48;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.181;\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "Cv_0 = 106.0;\t\t\t#[J/mol-K]\n",
- "\n",
- "# Calculations\n",
- "# At 360 K\n",
- "Tr = T_1/Tc;\t\t\t# Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B = ((B_0 + (w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- "dB0_dT = 0.422*1.6*Tc**(1.6)*T_1**(-2.6);\t\t\t# (dB_0/dT)\n",
- "dB1_dT = 0.172*4.2*Tc**(4.2)*T_1**(-5.2);\t\t\t# (dB_1/dT)\n",
- "dB_dT = ((R*Tc)/(Pc))*(dB0_dT + w*dB1_dT);\t\t\t# dB/dT\n",
- "\n",
- "# At state 1\n",
- "V_1 = B + (R*T_1)/P_1;\t\t\t#[m**(3)/mol] - Molar volume\n",
- "# At state 1\n",
- "V_2 = 10*V_1;\t\t\t#[m**(3)/mol] - Molar volume\n",
- "\n",
- "T_2 = -(P_1*T_1*(dB_dT))/Cv_0 + T_1;\t\t\t#[K]\n",
- "\n",
- "T = 350;\n",
- "\n",
- "fault = 10;\n",
- "def f(T): \n",
- " return 106*(T-T_1)+972.72-((R*T**(2))/(V_2-B_prime))*dB_dT_prime\n",
- "while(fault>0.007):\n",
- " Tr_prime = T/Tc;\t\t\t# Reduced temperature\n",
- " B_0_prime = 0.083-(0.422/(Tr_prime)**(1.6));\n",
- " B_1_prime = 0.139-(0.172/(Tr_prime)**(4.2));\n",
- " #We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- " B_prime = ((B_0_prime + (w*B_1_prime))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- " dB0_dT_prime = 0.422*1.6*Tc**(1.6)*T_2**(-2.6);\t\t\t# (dB_0/dT)\n",
- " dB1_dT_prime = 0.172*4.2*Tc**(4.2)*T_2**(-5.2);\t\t\t# (dB_1/dT)\n",
- " dB_dT_prime = ((R*Tc)/(Pc))*(dB0_dT_prime + w*dB1_dT_prime);\t\t\t# dB/dT\n",
- " T_prime = fsolve(f,0.15)\n",
- " fault=abs(T-T_prime);\n",
- " T = T + 0.001;\n",
- "\n",
- "# Results\n",
- "print \" The final temperature is %f K\"%(T);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The final temperature is 351.910000 K\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.6 Page Number : 339"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 220 + 273.15;\t\t\t#[K] - Temperature\n",
- "Tc = 562.2;\t\t\t#[K] - Critical temperature\n",
- "Pc = 48.98;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.210;\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "P_sat = 1912.86;\t\t\t#[kPa] - Saturation pressure at 220 C\n",
- "P_sat = P_sat*10**(3);\t\t\t#[Pa]\n",
- "Mol_wt = 78.114;\t\t\t#[g/mol] - Molecular weight of benzene\n",
- "\n",
- "# Calculations and Results\n",
- "#(1)\n",
- "# Since liquid and vapour are in equilibrium the fugacity is saturated fugacity (f_sat) and can be calculated using virial gas equation of state\n",
- "# At 220 C\n",
- "Tr = T/Tc;\t\t\t# Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B = ((B_0 + (w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- "\n",
- "# We know that math.log(f/P) = (B*P)/(R*T)\n",
- "# Thus at saturated conditions\n",
- "# math.log(f_sat/P_sat) = B*P_sat/(R*T)\n",
- "f_sat = P_sat*(math.exp((B*P_sat)/(R*T)));\t\t\t#[Pa]\n",
- "f_sat = f_sat*10**(-3);\t\t\t#[kPa]\n",
- "\n",
- "print \" 1).The fugacity of liquid benzene is %f kPa\"%(f_sat);\n",
- "\n",
- "#(2)\n",
- "P = 2014.7;\t\t\t# [psia] - Total gauge pressure\n",
- "P = 138.94;\t\t\t# [bar]\n",
- "P = P*10**(5);\t\t\t# [Pa]\n",
- "den = 0.63;\t\t\t# [g/cm**(3)] - density of benzene\n",
- "den = den*10**(3);\t\t\t# [kg/m**(3)]\n",
- "\n",
- "# Therefore specific volume is \n",
- "V = 1/den;\t\t\t#[m/**(3)/kg]\n",
- "# Molar volume is given by\n",
- "V = V*Mol_wt*10**(-3);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Thus fugacity at 220 C and pressure P is given by \n",
- "f = f_sat*(math.exp((V*(P-P_sat))/(R*T)));\n",
- "\n",
- "print \" 2).The fugacity of liquid benzene is %f kPa\"%(f);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The fugacity of liquid benzene is 1551.083216 kPa\n",
- " 2).The fugacity of liquid benzene is 2228.386532 kPa\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.7 Page Number : 341"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "# C = -0.067 + 30.7/T\n",
- "# D = 0.0012 - 0.416/T\n",
- "\n",
- "T = 80 + 273.15;\t\t\t#[K]\n",
- "P = 30;\t\t\t#[bar]\n",
- "#P = P;\t\t\t#[N/m**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\n",
- "# Calculations\n",
- "# We have the relation derived in the book\n",
- "# d(G/(R*T)) = (V/(R*T))dP - (H/(R*T**(2)))dT\n",
- "# Writing the same equation for ideal gas and subtracting it from the above equation we get\n",
- "# d(G_R/(R*T)) = (V_R/(R*T))dP - (H_R/(R*T**(2)))dT\n",
- "# Therefore, H_R/(R*T**(2)) = -[del((G_R)/(R*T))/del(T)]_P\n",
- "\n",
- "# Substituting the relation G_R/(R*T) = math.log(f/P), we get\n",
- "# H_R/(R*T**(2)) = -[del(math.log(f/P))/del(T)]_P = -[del(-C*P - D*P**(2))/del(T)]_P\n",
- "# or, H_R/(R*T**(2)) = P*(dC/dT) + P**(2)*dD/dT\n",
- "# Note that in the above equation the partial derivative is replaced by full derivative as C and D are functions of temperature. Therfore we get\n",
- "# H_R/(R*T**(2)) = (30.7*P)/T**(2) + (0.416*P**(2))/T**(2)\n",
- "# H_R/R = - 30.7*P + 0.416*P**(2)\n",
- "\n",
- "# Substituting the given conditions we get\n",
- "H_R = R*(-30.7*P + 0.416*P**(2));\t\t\t#[J/mol]\n",
- "\n",
- "# Results\n",
- "print \" The molar enthalpy of the gas relative to that of the ideal gas at 80 C and 30 bar pressure is H_R = %f J/mol\"%(H_R);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The molar enthalpy of the gas relative to that of the ideal gas at 80 C and 30 bar pressure is H_R = -4544.432400 J/mol\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.8 Page Number : 341"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "# (1)\n",
- "T = 311;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "# Pressure in 'bar' is given below\n",
- "P = [0.690,1.380,2.760,5.520,8.280,11.034,13.800,16.550];\n",
- "# Molar volume in 'm**(3)/mol' is given below\n",
- "V = [0.0373,0.0186,0.00923,0.00455,0.00298,0.00220,0.00175,0.00144];\n",
- "\n",
- "# Z = 1 + (B/V) + (C/V**(2))\n",
- "# (Z-1)*V = B + (C/V)\n",
- "\n",
- "from numpy import zeros\n",
- "Z=zeros(8);\n",
- "k=zeros(8);\n",
- "t=zeros(8);\n",
- "\n",
- "# Calculations and Results\n",
- "for i in range(8):\n",
- " Z[i]=(P[i]*10**(5)*V[i])/(R*T);\n",
- " k[i]=(Z[i]-1)*V[i];\n",
- " t[i]=1./V[i];\n",
- "\n",
- "from scipy.stats import linregress\n",
- "from numpy import array\n",
- "t = array(t)\n",
- "k = array(k)\n",
- "C,B,c,d,e = linregress(t.T,k.T)\n",
- "#[C,B,sig]=reglin(t',k');\n",
- "\n",
- "#From the regression, we get intercept = B and slope = C,and thus,\n",
- "\n",
- "print \" 1).The second virial coefficient of CO2 is given by B = %e m**3)/mol\"%(B);\n",
- "print \" The thied virial coefficient of CO2 is given by C = %e m**6)/mol**2)\"%(C);\n",
- "\n",
- "# (2)\n",
- "P_final = 13.8;\t\t\t#[bar]\n",
- "\n",
- "def f40(P): \n",
- "\t return V-(R*T)/P\n",
- "\n",
- "# We know that R*T*math.log(f/P) = quad(f40,0,P)[0]\n",
- "\n",
- "# Therefore we have to plot V - (R*T)/P versus P and calculate the area beneath the curve from 0 to 13.8 bar\n",
- "# For this we need the value of the term V - (R*T)/P at P = 0. At low pressure the virial equation becomes\n",
- "# Z = 1 + (B/V)\n",
- "#and V - (R*T)/P = (Z*R*T)/P - (R*T)/P = (1 + (B/V))*((R*T)/P) - (R*T)/P = (B*R*T)/(P*V) = (B/Z)\n",
- "# Thus lim P tending to zero (V - (R*T)/P) = B ( as P tend to zero, Z tend to 1 ) \n",
- "\n",
- "P_prime = [0.000,0.690,1.380,2.760,5.520,8.280,11.034,13.800];\n",
- "V_prime = [0.000,0.0373,0.0186,0.00923,0.00455,0.00298,0.00220,0.00175];\n",
- "summation = 0;\n",
- "x=zeros(8);\n",
- "y=zeros(8);\n",
- "z=zeros(8);\n",
- "for j in range(2,8):\n",
- " x[j]=V_prime[j]-(R*T)/(P_prime[j]*10**(5));\t\t\t#[m**(3)/mol]\n",
- " y[j]=(x[j] + x[j-1])/2;\n",
- " z[j]=y[j]*((P_prime[j]-P_prime[j-1]))*10**(5);\n",
- " summation = summation + z[j] ;\t\t\t#[J/mol]\n",
- "\n",
- "summation = summation + 2*z[1] - z[1];\t\t\t# Because in the above calculation,in order to calculate the average a summation of z(2) is not included,only half of it gets added\n",
- "\n",
- "\n",
- "def f41(P): \n",
- "\t return V - (R*T)/P\n",
- "\n",
- "\t\t\t# Now we have, area = quad(f41,0,13.8*10**(5))[0]\n",
- "\n",
- "\t\t\t# R*T*math.log(f/P) = summation\n",
- "f = P_final*(math.exp(summation/(R*T)));\t\t\t#[bar]\n",
- "\n",
- "\n",
- "print \" 2).The fugacity of steam at 311 K and 13.8 bar pressure is %f bar\"%(f);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The second virial coefficient of CO2 is given by B = -1.515264e-04 m**3)/mol\n",
- " The thied virial coefficient of CO2 is given by C = 5.618543e-08 m**6)/mol**2)\n",
- " 2).The fugacity of steam at 311 K and 13.8 bar pressure is 12.892780 bar\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.9 Page Number : 344"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 0 + 273.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\t\t\t# Pressure in 'atm' is given below\n",
- "P = [100,200,300,400,500,600,700,800,900,1000];\n",
- "\t\t\t# The compressibility factor values are\n",
- "Z = [1.069,1.138,1.209,1.283,1.356,1.431,1.504,1.577,1.649,1.720];\n",
- "\n",
- "# Z = 1 + (B/V) + (C/V**(2))\n",
- "# (Z-1)*V = B + (C/V)\n",
- "from numpy import zeros\n",
- "\n",
- "V = zeros(10);\n",
- "k = zeros(10);\n",
- "t = zeros(10);\n",
- "\n",
- "# Calculations and Results\n",
- "for i in range(10):\n",
- " V[i]=Z[i]*R*T/(P[i]*101325);\t\t\t#[m**(3)/mol]\n",
- " k[i]=(Z[i]-1)*V[i];\n",
- " t[i]=1/V[i];\n",
- "\n",
- "from scipy.stats import linregress\n",
- "C,B,c,d,e = linregress(t,k)\n",
- "\t\t\t#[C,B,sig]=reglin(t,k);\n",
- "\n",
- "\t\t\t#From the regression, we get intercept = B and slope = C,and thus,\n",
- "\n",
- "print \" 1).The second virial coefficient of H2 is given by B = %e m**3)/mol\"%(B);\n",
- "print \" The thied virial coefficient of H2 is given by C = %e m**6)/mol**2)\"%(C);\n",
- "\n",
- "\t\t\t# (2)\n",
- "\t\t\t# We know that, limit P tending to zero (V-(R*T)/P) = B, therfore P = 0, V-(R*T)/P = B\n",
- "\n",
- "def f42(P): \n",
- "\t return V-(R*T)/P \t\t\t#and determine the integral integrate((V-(R*T)/P)\n",
- "\n",
- "\t\t\t# Now let us tabulate V-(R*T)/P and determine the integral quad(f42,0,1000)[0]\n",
- "\n",
- "\n",
- "P_prime = [0,100,200,300,400,500,600,700,800,900,1000];\n",
- "Z_prime = [0,1.069,1.138,1.209,1.283,1.356,1.431,1.504,1.577,1.649,1.720];\n",
- "\n",
- "summation = 0;\n",
- "V_prime = zeros(11);\n",
- "x = zeros(11);\n",
- "y = zeros(11);\n",
- "z = zeros(11);\n",
- "for j in range(1,11):\n",
- " V_prime[j]=Z_prime[j]*R*T/(P_prime[j]*101325);\t\t\t#[m**(3)/mol]\n",
- " x[j]=V_prime[j]-(R*T)/(P_prime[j]*101325);\n",
- " y[j]=(x[j] + x[j-1])/2;\n",
- " z[j]=y[j]*((P_prime[j]-P_prime[j-1]))*101325;\n",
- " summation = summation + z[j] ;\t\t\t#[J/mol]\n",
- "\n",
- "summation = summation + 2*z[1] - z[1];\t\t\t# Because in the above calculation,in order to calculate the average a summation of z(2) is not included,only half of it gets added\n",
- "\n",
- "\t\t\t# Now we have\n",
- "\t\t\t# R*T*math.log(f/P) = summation\n",
- "P_dash = 1000;\t\t\t#[atm] - Pressure at which fugacity is to be calculated\n",
- "T_dash = 273.15;\t\t\t#[K] - Temperature at which fugacity is to be calculated\n",
- "f = P_dash*math.exp(summation/(R*T_dash));\t\t\t#[atm] \n",
- "\n",
- "print \" 2).The fugacity of H2 at 0 C and 1000 atm pressure is f = %f atm\"%(f);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The second virial coefficient of H2 is given by B = 1.345242e-05 m**3)/mol\n",
- " The thied virial coefficient of H2 is given by C = 5.286525e-10 m**6)/mol**2)\n",
- " 2).The fugacity of H2 at 0 C and 1000 atm pressure is f = 2030.305169 atm\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.10 Page Number : 345"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math\n",
- "from scipy.integrate import quad \n",
- "\n",
- "# Variables\n",
- "P_1 = 1*10.**(6.);\t\t\t#[Pa] - Initial pressure\n",
- "T_1 = 200. + 273.15;\t\t#[K] - Initial temperature\n",
- "P_2 = 8*10.**(6);\t\t\t#[Pa] - Final pressure\n",
- "Tc = 647.1;\t\t\t #[K] - Critical temperature of water\n",
- "Pc = 220.55; \t\t\t#[bar] - Critical pressure of water\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.345;\n",
- "R = 8.314;\t\t \t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# For the virial gas the following are the relations for residual enthalpy and entropy\n",
- "# H_R = B*P - P*T*(dB/dT) \n",
- "# S_R = -P*(dB/dT)\n",
- "# Where, (dB/dT) = ((R*Tc)/Pc)*((dB_0/dT) + w*(dB_1/dT))\n",
- "# dB0_dT = 0.422*1.6*Tc**(1.6)*T**(-2.6);\t\t\t# (dB_0/dT)\n",
- "# dB1_dT = 0.172*4.2*Tc**(4.2)*T**(-5.2);\t\t\t# (dB_1/dT)\n",
- "\n",
- "# (1)\n",
- "Cp_0 = 29.114;\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
- "# For the isentropic process entropy change is zero, thus\n",
- "# delta_S = Cp_0*math.log(T_2/T_1) - P_2*(dB/dT)_2 + P_1*(dB/dT)_1 = 0\n",
- "\n",
- "# Calculations\n",
- "# At state 1, \n",
- "Tr_1 = T_1/Tc;\n",
- "B0_1 = 0.083 - 0.422/(Tr_1**(1.6));\n",
- "B1_1 = 0.139 - 0.172/(Tr_1**(4.2));\n",
- "# (B*Pc)/(R*Tc) = B0 + w*B1\n",
- "B_1 = ((B0_1 + w*B1_1)*(R*Tc))/Pc;\t\t\t# [m**(3)/mol] - Second virial coefficient at state 1\n",
- "dB0_dT_1 = 0.422*1.6*Tc**(1.6)*T_1**(-2.6);\t\t\t# (dB_0/dT)\n",
- "dB1_dT_1 = 0.172*4.2*Tc**(4.2)*T_1**(-5.2);\t\t\t# (dB_1/dT)\n",
- "dB_dT_1 = ((R*Tc)/Pc)*((dB0_dT_1) + w*(dB1_dT_1));\t\t\t# (dB/dT)_1\n",
- "\n",
- "# Now let us assume the exit temperature to be 870 K, at this temperature\n",
- "# T_2 = 870;\t\t\t#[K] - \n",
- "# At this temperature\n",
- "# delta_S = Cp_0*math.log(T_2/T_1) - P_2*(dB/dT)_2 + P_1*(dB/dT)_1 = \n",
- "\n",
- "\n",
- "T_2 = 860.;\t\t\t#[K] - Exit temperature\n",
- "# Therefore at state 2, we have\n",
- "Tr_2 = T_2/Tc;\n",
- "B0_2 = 0.083 - 0.422/(Tr_2**(1.6));\n",
- "B1_2 = 0.139 - 0.172/(Tr_2**(4.2));\n",
- "# (B*Pc)/(R*Tc) = B0 + w*B1\n",
- "B_2 = ((B0_2 + w*B1_2)*(R*Tc))/Pc;\t\t\t# [m**(3)/mol] - Second virial coefficient at state 2\n",
- "dB0_dT_2 = 0.422*1.6*Tc**(1.6)*T_2**(-2.6);\t\t\t# (dB_0/dT)\n",
- "dB1_dT_2 = 0.172*4.2*Tc**(4.2)*T_2**(-5.2);\t\t\t# (dB_1/dT)\n",
- "dB_dT_2 = ((R*Tc)/Pc)*((dB0_dT_2) + w*(dB1_dT_2));\t\t\t# (dB/dT)_2\n",
- "\n",
- "delta_H_s = Cp_0*(T_2 - T_1) + B_2*P_2 -P_2*T_2*(dB_dT_2) - B_1*P_1 + P_1*T_1*(dB_dT_1);\t\t\t#[J/mol] - Enthalpy change\n",
- "\n",
- "# As no heat exchange is assumed to take place with the surroundings,work transfer is given by\n",
- "W_1 = - delta_H_s;\t\t\t# [J/mol]\n",
- "\n",
- "# Results\n",
- "print \" 1).The exit temperature is %f K\"%(T_2);\n",
- "print \" The required amount of work is %f J/mol\"%(W_1);\n",
- "\n",
- "\n",
- "# (2)\n",
- "eff = 0.8;\t\t\t# Adiabatic efficiency\n",
- "delta_H_a = delta_H_s/0.8;\t\t\t# Actual enthalpy change\n",
- "\n",
- "# Now for calculating the value of T_exit\n",
- "# delta_H_a = Cp_0*(T_exit - T_1) + B*P_2 -P_2*T_exit*(dB_dT) - B_1*P_1 + P_1*T_1*(dB_dT_1)\n",
- "# On simplification we get\n",
- "# 29.114*(T_2 - T_1)*B_2*8*10**(6)-8*10**(6)*T_2*(dB/dT)_2 = 12643.77 \n",
- "\n",
- "# Let us assume a temperature of say\n",
- "T = 900.;\t\t\t#[K]\n",
- "fault=10.;\n",
- "\n",
- "def f(T_exit): \n",
- "\t return delta_H_a - Cp_0*(T_exit - T_1) + B*P_2 -P_2*T_exit*(dB_dT) - B_1*P_1 + P_1*T_1*(dB_dT_1)\n",
- "\t \n",
- "while(fault>0.3):\n",
- " Tr = T/Tc;\n",
- " B0 = 0.083 - 0.422/(Tr**(1.6));\n",
- " B1 = 0.139 - 0.172/(Tr**(4.2));\n",
- " \t\t\t# (B*Pc)/(R*Tc) = B0 + w*B1\n",
- " B = ((B0 + w*B1)*(R*Tc))/Pc;\t\t\t# [m**(3)/mol] - Second virial coefficient at state 2\n",
- " dB0_dT = 0.422*1.6*Tc**(1.6)*T**(-2.6);\t\t\t# (dB_0/dT)\n",
- " dB1_dT = 0.172*4.2*Tc**(4.2)*T**(-5.2);\t\t\t# (dB_1/dT)\n",
- " dB_dT = ((R*Tc)/Pc)*((dB0_dT) + w*(dB1_dT));\t\t\t# (dB/dT)_1\n",
- "\n",
- " T_exit = fsolve(f,900)\n",
- " fault=abs(T-T_exit);\n",
- " T = T + 0.2;\n",
- "\n",
- "Texit = T;\n",
- "\n",
- "\t\t\t# As no heat exchange is assumed to take place with the surroundings,work transfer is given by\n",
- "W_2 = - delta_H_a;\t\t\t# [J/mol]\n",
- "\n",
- "print \" 2).The exit temperature is %f K\"%(Texit);\n",
- "print \" The required amount of work is %f J/mol\"%(W_2);\n",
- "\n",
- "\n",
- "def f20(T): \n",
- "\t return Cp_0/T\n",
- "\n",
- "T_prime = 700.;\t\t\t#[K]\n",
- "fault1=10.;\n",
- "\n",
- "def f1(T_out): \n",
- "\t return 32.2168*math.log(T_out) + 0.1922*10**(-2)*T_out + 0.5274*10**(-5) \\\n",
- "\t *T_2**(2) - 1.1976*10**(-9)*T_out**(3)-8*10**(6)*dB_dT_prime -216.64\n",
- "\n",
- "while(fault1>0.5):\n",
- " Tr_prime = T_prime/Tc;\n",
- " B0_prime = 0.083 - 0.422/(Tr_prime**(1.6));\n",
- " B1_prime = 0.139 - 0.172/(Tr_prime**(4.2));\n",
- " B_prime = ((B0_prime + w*B1_prime)*(R*Tc))/Pc;\t\t\t# [m**(3)/mol] - Second virial coefficient at state 2\n",
- " dB0_dT_prime = 0.422*1.6*Tc**(1.6)*T_prime**(-2.6);\t\t\t# (dB_0/dT)\n",
- " dB1_dT_prime = 0.172*4.2*Tc**(4.2)*T_prime**(-5.2);\t\t\t# (dB_1/dT)\n",
- " dB_dT_prime = ((R*Tc)/Pc)*((dB0_dT_prime) + w*(dB1_dT_prime));\t\t\t# (dB/dT)_1\n",
- " T_out = fsolve(f1,10)\n",
- " fault1=abs(T_prime-T_out);\n",
- " T_prime = T_prime + 0.5;\n",
- "\n",
- "T_out = T_prime;\n",
- "\n",
- "# Now we have to calculate enthalpy change as W = -delta_H\n",
- "\n",
- "def f21(T): \n",
- "\t return (7.7 + 0.04594*10**(-2.)*T + 0.2521*10**(-5.)*T**(2.) - 0.8587*10.**(-9.)*T**(3.))*4.184\n",
- "\n",
- "delta_H_3 = quad(f21,T_1,T_out)[0] + B_prime*P_2 - P_2*T_out*dB_dT_prime - B_1*P_1 + P_1*T_1*dB_dT_1\n",
- "print T_1,T_out\n",
- "\n",
- "\n",
- "W_3 = - delta_H_3;\t\t\t# [J/mol]\n",
- "\n",
- "print \" 3).The exit temperature is %f K\"%(T_out);\n",
- "print \" The required amount of work is %f J/mol\"%(W_3);\n",
- "\n",
- "#(4)\n",
- "n = 0.8;\t\t\t# Adiabatic efficiency\n",
- "delta_H_a_4 = delta_H_3/n;\t\t\t#[J/mol]\n",
- "W_4 = -delta_H_a_4;\t\t\t#[J/mol]\n",
- "\n",
- "\n",
- "T_prime1 = 700.;\t\t\t#[K]\n",
- "fault2=10.;\n",
- "\n",
- "def f2(T_2): \n",
- "\t return 7.7*4.184*(T_2-T_1) + ((0.04594*4.184*10**(-2))/2)* \\\n",
- "\t (T_2**(2)-T_1**(2)) + ((0.2521*4.184*10**(-5))/3)*(T_2**(3)-T_1**(3)) - \\\n",
- "\t ((0.8587*4.184*10**(-9))/4)*(T_2**(4)-T_1**(4)) + B_prime1*8*10**(6) \\\n",
- "\t - 8*10**(6)*T_2*dB_dT_prime1 + 191.7 + 496.81 - delta_H_a_4\n",
- "\n",
- "while(fault2>0.5):\n",
- " Tr_prime1 = T_prime1/Tc;\n",
- " B0_prime1 = 0.083 - 0.422/(Tr_prime1**(1.6));\n",
- " B1_prime1 = 0.139 - 0.172/(Tr_prime1**(4.2));\n",
- " \t\t\t# (B*Pc)/(R*Tc) = B0 + w*B1\n",
- " B_prime1 = ((B0_prime1 + w*B1_prime1)*(R*Tc))/Pc;\t\t\t# [m**(3)/mol] - Second virial coefficient at state 2\n",
- " dB0_dT_prime1 = 0.422*1.6*Tc**(1.6)*T_prime1**(-2.6);\t\t\t# (dB_0/dT)\n",
- " dB1_dT_prime1 = 0.172*4.2*Tc**(4.2)*T_prime1**(-5.2);\t\t\t# (dB_1/dT)\n",
- " dB_dT_prime1 = ((R*Tc)/Pc)*((dB0_dT_prime1) + w*(dB1_dT_prime1));\t\t\t# (dB/dT)_1\n",
- " T_out1 = fsolve(f2,100)\n",
- " fault2=abs(T_prime1-T_out1);\n",
- " T_prime1 = T_prime1 + 0.5;\n",
- "\n",
- "T_out1 = T_prime1;\n",
- "\n",
- "print \" 4).The exit temperature is %f K\"%(T_out1);\n",
- "print \" The required amount of work is %f J/mol\"%(W_4);\n",
- "\n",
- "\n",
- "# answers are varies because of rounding error. please check it manually."
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The exit temperature is 860.000000 K\n",
- " The required amount of work is -10667.724150 J/mol\n",
- " 2).The exit temperature is 916.600000 K\n",
- " The required amount of work is -13334.655188 J/mol\n",
- "473.15"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 755.5\n",
- " 3).The exit temperature is 755.500000 K\n",
- " The required amount of work is -9282.701079 J/mol\n",
- " 4).The exit temperature is 809.500000 K"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " The required amount of work is -11603.376349 J/mol\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.11 Page Number : 348"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "Vol = 0.15;\t\t\t #[m**(3)] - Volume of the cylinder\n",
- "P_1 = 100.;\t\t\t #[bar] - Initial pressure\n",
- "P_1 = P_1*10**(5);\t\t#[Pa]\n",
- "T_1 = 170.;\t\t\t #[K] - Initial temperature\n",
- "n_withdrawn = 500.;\t\t#[mol] - Withdrawn number of moles\n",
- "R = 8.314;\t\t \t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "#(1)\n",
- "Y = 1.4;\t\t\t# Coefficient of adiabatic expansion\n",
- "n_total = (P_1*Vol)/(R*T_1);\t\t\t#[mol] - Total number of moles\n",
- "n_2 = n_total - n_withdrawn;\t\t\t#[mol] - Left number of moles\n",
- "V_1 = Vol/n_total;\t\t\t#[m**(3)/mol] - Molar volume at initial state.\n",
- "# At final state\n",
- "V_2 = Vol/n_2;\t\t\t#[m**(3)/mol] - Molar volume at final state\n",
- "\n",
- "# During duscharging P_1*V_1**(Y) = P_2*V_2**(Y), therefore\n",
- "P_2_1 = P_1*((V_1/V_2)**(Y));\t\t\t#[Pa] - Final pressure\n",
- "P_2_1 = P_2_1*10**(-5);\t\t\t#[bar]\n",
- "T_2_1 = ((P_2_1*10**(5))*V_2)/R;\t\t\t#[K] - Final temperature\n",
- "\n",
- "print \" 1).The final temperature %f K\"%(T_2_1);\n",
- "print \" The final pressure %f bar\"%(P_2_1);\n",
- "\n",
- "\n",
- "def f53(T): \n",
- "\t return Cp_0/T\n",
- "\n",
- "T_prime = 150;\t\t\t#[K]\n",
- "error = 10;\n",
- "while(error>1):\n",
- " f_T = 18.886*math.log(T_prime) + 4.2*10**(-3)*T_prime - 92.4;\n",
- " f_T_dash = 18.886/T_prime + 4.2*10**(-3);\n",
- " T_new = T_prime - (f_T/f_T_dash);\n",
- " error=abs(T_prime - T_new);\n",
- " T_prime = T_new;\n",
- "\n",
- "T_2_2 = T_prime;\t\t\t#[K] - Final temperature\n",
- "P_2_2 = ((n_2*R*T_2_2)/Vol)*10**(-5);\t\t\t#[bar] - Final pressure\n",
- "\n",
- "print \" 2).The final temperature %f K\"%(T_2_2);\n",
- "print \" The final pressure %f bar\"%(P_2_2);\n",
- "\n",
- "#(3)\n",
- "Tc = 126.2;\t\t\t#[K] - Critical temperature of nitrogen\n",
- "Pc = 34.0;\t\t\t#[bar] - Critical pressure of nitrogen\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.038;\t\t\t# Acentric factor\n",
- "\n",
- "\n",
- "dB0_dT = 0.422*1.6*Tc**(1.6)*T_1**(-2.6);\t\t\t# (dB_0/dT) at state 1\n",
- "dB1_dT = 0.172*4.2*Tc**(4.2)*T_1**(-5.2);\t\t\t# (dB_1/dT) at state 1\n",
- "dB_dT = ((R*Tc)/Pc)*((dB0_dT) + w*(dB1_dT));\t\t\t# (dB/dT) at state 1\n",
- "# The residual entropy at the initial state is given by \n",
- "S_R_1 = -P_1*(dB_dT);\t\t\t#[J/mol-K]\n",
- "\n",
- "# Now let us calculate molar volume at initial state\n",
- "Tr = T_1/Tc;\t\t\t# Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2));\n",
- "\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "V_1_3 = B + (R*T_1)/P_1;\t\t\t#[m**(3)/mol]\n",
- "# Therefore number of moles in the initial state is\n",
- "n_1_3 = Vol/V_1_3;\t\t\t#[mol]\n",
- "# Therefore final number of moles is\n",
- "n_2_3 = n_1_3 - n_withdrawn;\n",
- "\n",
- "# Therefore molar volume at final state is\n",
- "V_2_3 = Vol/n_2_3;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Now let us determine the relation between pressure and temperature in the final state\n",
- "# P_2_3 = (R*T_2_3)/(V_2_3 - B_2)\n",
- "#delta_S = 0, thus delta_S_ig + delta_S_R = 0\n",
- "delta_S_R = - S_R_1;\n",
- "\n",
- "def f54(T): \n",
- "\t return Cp_0/T\n",
- "\n",
- "\n",
- "T_2_prime = 135;\t\t\t#[K]\n",
- "delta = 0.1;\n",
- "error = 10;\n",
- "while(error>0.01):\n",
- " T_r = T_2_prime/Tc;\t\t\t# Reduced temperature\n",
- " B_0_3 = 0.083-(0.422/(T_r)**(1.6));\n",
- " B_1_3 = 0.139-(0.172/(T_r)**(4.2));\n",
- " B_3 = ((B_0_3+(w*B_1_3))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- " dB0_dT_3 = 0.422*1.6*Tc**(1.6)*T_2_prime**(-2.6);\t\t\t# (dB_0/dT)\n",
- " dB1_dT_3 = 0.172*4.2*Tc**(4.2)*T_2_prime**(-5.2);\t\t\t# (dB_1/dT)\n",
- " dB_dT_3 = ((R*Tc)/Pc)*((dB0_dT_3) + w*(dB1_dT_3));\t\t\t# (dB/dT)\n",
- " P_2_3 = (R*T_2_prime)/(V_2_3 - B_3);\n",
- " delta_S = 27.2*(math.log(T_2_prime/T_1)) + 4.2*10**(-3)*(T_2_prime - T_1) - R*(math.log(P_2_3/P_1)) - P_2_3*(dB_dT_3) + delta_S_R;\n",
- " T_new = T_2_prime + delta;\n",
- " error=abs(delta_S);\n",
- " T_2_prime = T_new;\n",
- "\n",
- "T_2_3 = T_2_prime;\t\t\t#[K] - Final temperature\n",
- "\t\t\t# Therefore at T_2_3\n",
- "P_2_3 = P_2_3*10**(-5);\t\t\t#[bar] - Final pressure\n",
- "\n",
- "print \" 3).The final temperature %f K\"%(T_2_3);\n",
- "print \" The final pressure %f bar\"%(P_2_3);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The final temperature 131.761821 K\n",
- " The final pressure 40.991361 bar\n",
- " 2).The final temperature 129.504151 K\n",
- " The final pressure 40.288995 bar\n",
- " 3).The final temperature 141.300000 K\n",
- " The final pressure 57.079997 bar\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.12 Page Number : 351"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P_1 = 80.;\t\t\t #[bar] - Initial pressure\n",
- "P_1 = P_1*10.**(5);\t\t\t#[Pa]\n",
- "T_1 = 300. + 273.15;\t\t#[T] - Initial temperature\n",
- "P_2 = 40.;\t\t\t #[bar] - Final pressure\n",
- "P_2 = P_2*10**(5);\t\t\t#[Pa]\n",
- "T_2 = 300. + 273.15;\t\t#[K] - Final temperature\n",
- "T_0 = 25. + 273.15;\t\t\t#[K] - Surrounding temperature\n",
- "P_0 = 1.;\t\t\t #[atm] - Surrounding pressure\n",
- "P_0 = P_0*101325;\t\t\t#[Pa]\n",
- "Tc = 647.1;\t\t\t #[K]\n",
- "Pc = 220.55;\t\t\t #[bar]\n",
- "Pc = Pc*10.**(5);\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t #[J/mol*K] - Universal gas constant\n",
- "\n",
- "\n",
- "# Calculations\n",
- "# For van der Walls equation of state\n",
- "a = (27*R**(2)*Tc**(2))/(64*Pc);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\n",
- "def f(V): \n",
- "\t return V**(3)-(b+(R*T_1)/P_1)*V**(2)+(a/P_1)*V-(a*b)/P_1\n",
- "V_1_1=fsolve(f,0.1)\n",
- "V_1_2=fsolve(f,10)\n",
- "V_1_2=fsolve(f,100)\n",
- "# The largest root is considered because of vapour\n",
- "V_1 = V_1_1;\n",
- "\n",
- "U_R_1 = -a/V_1;\t\t\t#[J/mol] - Internal energy\n",
- "H_R_1 = P_1*V_1 - R*T_1 - a/V_1;\t\t\t#[J/mol] - Enthalpy\n",
- "S_R_1 = R*math.log((P_1*(V_1-b))/(R*T_1));\n",
- "\n",
- "def f1(V): \n",
- "\t return V**(3)-(b+(R*T_2)/P_2)*V**(2)+(a/P_2)*V-(a*b)/P_2\n",
- "V_2_1 = fsolve(f1,0.1)\n",
- "V_2_2 = fsolve(f1,10)\n",
- "V_2_3 = fsolve(f1,100)\n",
- "V_2 = V_2_1;\n",
- "\n",
- "U_R_2 = -a/V_2;\t\t\t#[J/mol] - Internal energy\n",
- "H_R_2 = P_2*V_2 - R*T_2 - a/V_2;\t\t\t#[J/mol] - Enthalpy\n",
- "S_R_2 = R*math.log((P_2*(V_2-b))/(R*T_2));\n",
- "\n",
- "delta_U_R = U_R_2 - U_R_1;\t\t\t#\n",
- "delta_H_R = H_R_2 - H_R_1;\t\t\t#\n",
- "delta_S_R = S_R_2 - S_R_1;\t\t\t#\n",
- "\n",
- "delta_U_ig = 0;\t\t\t#[J/mol] - As temperature is constant\n",
- "delta_H_ig = 0;\t\t\t#[J/mol] - As temperature is constant\n",
- "delta_S_ig = - R*math.log(P_2/P_1);\t\t\t# [J/mol-K]\n",
- "delta_U = delta_U_R + delta_U_ig;\t\t\t#[J/mol]\n",
- "delta_H = delta_H_R + delta_H_ig;\t\t\t#[J/mol]\n",
- "delta_S = delta_S_R + delta_S_ig;\t\t\t#[J/mol-K]\n",
- "\n",
- "\t\t\t# Change in exergy is given by\n",
- "\t\t\t# delta_phi = phi_1 - phi_2 = U_1 - U_2 + P_0*(V_1 - _V_2) - T_0*(S_1 - S_2)\n",
- "delta_phi = - delta_U + P_0*(V_1 - V_2) - T_0*(-delta_S);\t\t\t#[J/mol]\n",
- "\n",
- "# Results\n",
- "print \" The change in internal energy is %f J/mol\"%(delta_U);\n",
- "print \" The change in enthalpy is %f J/mol\"%(delta_H);\n",
- "print \" The change in entropy is %f J/mol-K\"%(delta_S);\n",
- "print \" The change in exergy is %f J/mol\"%(delta_phi);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The change in internal energy is 615.070900 J/mol\n",
- " The change in enthalpy is 1053.220316 J/mol\n",
- " The change in entropy is 6.930264 J/mol-K\n",
- " The change in exergy is 1389.940735 J/mol\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.13 Page Number : 353"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T_1 = 500.;\t\t\t#[K] - Initial temperature\n",
- "P_1 = 30.;\t\t\t#[atm] - Initial pressure\n",
- "P_1 = P_1*101325;\t\t\t#[Pa]\n",
- "P_2 = 1;\t\t\t#[atm] - Final pressure\n",
- "P_2 = P_2*101325;\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\t\t\t# For chlorine\n",
- "Tc = 417.2;\t\t\t#[K] - Critical temperature\n",
- "Pc = 77.10;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "\n",
- "#Redlich Kwong equation of state,\n",
- "a = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t# [Pa*m**(6)*K**(1/2)/mol]\n",
- "b = (0.08664*R*Tc)/Pc;\t\t\t# [m**(3)/mol]\n",
- "\n",
- "# Calculations\n",
- "def f1(V): \n",
- "\t return V**(3)-((R*T_1)/P_1)*V**(2)-((b**(2))+((b*R*T_1)/P_1)-(a/(T_1**(1./2)*P_1)))*V-(a*b)/(T_1**(1./2)*P_1)\n",
- "V_1=fsolve(f1,1)\n",
- "V_2=fsolve(f1,10)\n",
- "V_3=fsolve(f1,100)\n",
- "\n",
- "V = V_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\n",
- "Z = (P_1*V_1)/(R*T_1);\t\t\t#compressibility factor\n",
- "\n",
- "# The residual enthalpy at state 1 is given by\n",
- "H_R_1 = (Z-1)*R*T_1 + ((3*a)/(2*b*T_1**(1./2)))*(math.log(V/(V+b)));\t\t\t#[J/mol]\n",
- " \n",
- "# Since chlorine is assumed to behave ideally under the final condition,therefore\n",
- "H_R_2 = 0;\t\t\t# Residual enthalpy at state 2\n",
- "delta_H_R = H_R_2 - H_R_1;\t\t\t#[J/mol] - Residual enthalpy change\n",
- "# and since isothermal conditions are maintained, therfore\n",
- "delta_H_ig = 0;\t\t\t# Enthalpy change under ideal condition\n",
- "delta_H = delta_H_R + delta_H_ig;\t\t\t#[J/mol]\n",
- "\n",
- "# Results\n",
- "print \" The change in enthalpy is given by delta_H = %f J/mol\"%(delta_H);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The change in enthalpy is given by delta_H = 1053.558471 J/mol\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.14 Page Number : 353"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "Vol_1 = 0.1;\t\t\t#[m**(3)] - Initial volume of each compartment\n",
- "n_1 = 400;\t\t\t#[mol] - Initial number of moles in compartment 1\n",
- "V_1 = Vol_1/n_1;\t\t\t#[m**(3)/mol] - Molar volume at state 1\n",
- "T_1 = 294;\t\t\t#[K]\n",
- "Vol_2 = 0.2;\t\t\t#[m**(3)] - Final volume of the compartment after removing the partition.\n",
- "n_2 = n_1;\t\t\t#[mol] - Number of moles remains the same\n",
- "V_2 = Vol_2/n_2;\t\t\t#[m**(3)/mol] - Molar volume at state 2\n",
- "\n",
- "a = 0.1362;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = 3.215*10**(-5);\t\t\t#[m**(3)/mol]\n",
- "Cv_0 = 12.56;\t\t\t#[J/mol-K] - Heat capacity in ideal gas state\n",
- "\n",
- "# Calculations\n",
- "# For overall system q = 0, and no work is done, therefore delta_U = 0\n",
- "# Therfore from the relation proved in part (1), we have\n",
- "T_2 = T_1 + (a/Cv_0)*(1/V_2 - 1/V_1);\t\t\t#[K]\n",
- "\n",
- "# Results\n",
- "print \" 2).The final temperatutre is %f K\"%(T_2)\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 2).The final temperatutre is 272.312102 K\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.17 Page Number : 356"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P_1 = 1*10**(6);\t\t\t#[Pa] - Initial pressure\n",
- "T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 8*10**(6);\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "Y = 1.4;\t\t\t# Index of expansion\n",
- "Cp_0 = 29.114;\t\t\t#[J/mol-K]\n",
- "\t\n",
- "a = 0.55366;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = 3.049*10**(-5);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Calculations\n",
- "V_1 = 3.816*10**(-3);\t\t\t#[m**(3)/mol]\n",
- "Z_1 = (P_1*V_1)/(R*T_1);\n",
- "\n",
- "T_2 = T_1*(P_2/P_1)**((Y-1)/Y);\t\t\t#[K]\n",
- "\n",
- "# At 8 MPa and T_2,\n",
- "# The molar volume of steam following van der Walls equation of state (as reported in the book) is\n",
- "V_2 = 8.41*10**(-4);\t\t\t#[m**(3)/mol]\n",
- "# And the compressibility factor is \n",
- "Z_2 = (P_2*V_2)/(R*T_2);\n",
- "\n",
- "# For van der Walls equation of state we know that\n",
- "# delta_S_R/R = math.log(Z_2/Z_1) + math.log((V_2 - b)/V_2) - math.log((V_1 - b)/V_1)\n",
- "delta_S_R = R*(math.log(Z_2/Z_1) + math.log((V_2 - b)/V_2) - math.log((V_1 - b)/V_1));\t\t\t#[J/mol]\n",
- "\n",
- "# delta_S_ig = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1)\n",
- "# The entropy change is therefore\n",
- "# delta_S = delta_S_ig + delta_S_R\n",
- "# But during an isentropic process the total entropy change is zero\n",
- "# Therefore we have to modify the exit temperature so that the entropy change is zero\n",
- "\n",
- "# Let us assume a temperature, say T = 870 K\n",
- "# At 870 K the molar volume of steam following van der Walls equation of state (as reported in the book) is\n",
- "# V_3 = 8.57*10**(-4);\t\t\t# [m**(3)/mol]\n",
- "# Therefore\n",
- "# Z_3 = (P_2*V_3)/(R*T_2);\n",
- "# At this temperature,\n",
- "# delta_S = Cp_0*math.log(T/T_1) - R*math.log(P_2/P_1) + R*(math.log(Z/Z_1) + R*math.log((V - b)/V) - R*math.log((V_1 - b)/V_1))\n",
- "\n",
- "T = 800;\t\t\t#[K]\n",
- "fault=10;\n",
- "\n",
- "def f1(V): \n",
- "\t return V**(3)-(b+(R*T)/P_2)*V**(2)+(a/P_2)*V-(a*b)/P_2\n",
- "\t \n",
- "def f2(T): \n",
- "\t return Cp_0*math.log(T/T_1) - R*math.log(P_2/P_1) + R*(math.log(Z/Z_1) + R*(math.log((V - b)/V)) - R*(math.log((V_1 - b)/V_1)))\n",
- "\n",
- "\n",
- "while(fault>0.3):\n",
- " \t\t\t# At T and 8 MPa\n",
- " V = fsolve(f1,1)\n",
- " Z = (P_2*V)/(R*T);\n",
- " \n",
- " T_exit = fsolve(f2,0.1)\n",
- " fault=abs(T-T_exit);\n",
- " T = T + 0.5;\n",
- "\n",
- "Texit = T;\n",
- "\n",
- "# Now applying the first law to an adiabatic process we get\n",
- "# W = - delta_H\n",
- "\n",
- "# For van der Walls gas the enthalpy change is given by\n",
- "delta_H_s = Cp_0*(T_exit - T_1) + (Z - 1)*R*T_exit - a/V - (Z_1-1)*R*T_1 + a/V_1;\t\t\t#[J/mol]\n",
- "W = - delta_H_s;\t\t\t#[J/mol]\n",
- "\n",
- "# Results\n",
- "print \" 1).The exit temperature is %f K\"%(Texit);\n",
- "print \" The work required is given by W = %f J/mol\"%(W);\n",
- "\n",
- "#(2)\n",
- "eff = 0.8;\t\t\t# Adiabatic efficiency\n",
- "delta_H_a = eff*delta_H_s;\t\t\t#[J/mol] - Actual enthalpy change\n",
- "W_2 = - delta_H_a;\n",
- "\n",
- "\t\t\t# Let us assume a temperature, say\n",
- "T_prime= 900;\t\t\t#[K]\n",
- "fault1=10;\n",
- "def f22(V): \n",
- "\t return V**(3)-(b+(R*T_prime)/P_2)*V**(2)+(a/P_2)*V-(a*b)/P_2\n",
- "\n",
- "def f3(T_prime): \n",
- "\t return Cp_0*(T_prime - T_1) + (Z_prime - 1)*R*T_prime - a/V_prime - 13230.49\n",
- "\t \n",
- "while(fault1>0.3):\n",
- " \t\t\t# At T_prime and 8 MPa\n",
- " V_prime=fsolve(f22,1)\n",
- " Z_prime = (P_2*V_prime)/(R*T_prime);\n",
- " T_exit1 = fsolve(f3,100)\n",
- " fault1=abs(T_prime-T_exit1);\n",
- " T_prime = T_prime + 0.2;\n",
- "\n",
- "Texit1 = T_prime;\n",
- "\n",
- "print \" 2).The exit temperature is %f K\"%(Texit1);\n",
- "print \" The work required is given by W = %f J/mol\"%(W_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The exit temperature is 916.500000 K\n",
- " The work required is given by W = -12195.093996 J/mol\n",
- " 2).The exit temperature is 958.400000 K"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " The work required is given by W = -9756.075197 J/mol\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.19 Page Number : 359"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 100 + 273.15;\t\t\t#[K] - Temperature\n",
- "Tc = 647.1;\t\t\t#[K] - Critical temperature of water\n",
- "Pc = 220.55;\t\t\t#[bar] - Critical pressure of water\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations\n",
- "a = (27*R**(2)*Tc**(2))/(64*Pc);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The cubic form of van der Walls equation of state is given by,\n",
- "# V**(3) - (b + (R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "\n",
- "# For water vapour at 100 C under saturated conditions pressure is 1 atm, therefore\n",
- "P = 1;\t\t\t#[atm]\n",
- "P = P*101325;\t\t\t#[Pa]\n",
- "\n",
- "# At 100 C and 1 atm \n",
- "def f(V): \n",
- "\t return V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P\n",
- "V_1 = fsolve(f,0.1)\n",
- "V_1 = fsolve(f,10)\n",
- "V_1 = fsolve(f,100)\n",
- "V = V_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\n",
- "f = P*(math.exp(math.log((R*T)/(P*(V-b))) + b/(V-b) - (2*a)/(R*T*V)));\t\t\t#[Pa]\n",
- "f = f/101325;\t\t\t#[atm]\n",
- "\n",
- "# Results\n",
- "print \" The molar volume is %f m**3)/mol\"%(V);\n",
- "print \" The fugacity is %f atm\"%(f);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The molar volume is 0.030469 m**3)/mol\n",
- " The fugacity is 0.995168 atm\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.20 Page Number : 359"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 6;\t\t\t#[bar] - Initial pressure\n",
- "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
- "T_1 = 100 + 273.15;\t\t\t#[T] - Initial temperature\n",
- "P_2 = 12;\t\t\t#[bar] - Final pressure\n",
- "P_2 = P_2*10**(5);\t\t\t#[Pa]\n",
- "T_2 = 500 + 273.15;\t\t\t#[K] - Final temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "Y = 1.126;\t\t\t# Index of expansion\n",
- "Cp_0 = (R*Y)/(Y-1);\t\t\t#[J/mol-K]\n",
- "\n",
- "# For propane\n",
- "Tc = 369.8;\t\t\t#[K]\n",
- "Pc = 42.48;\t\t\t#[bar]\n",
- "Pc = Pc*10**(5);\n",
- "w = 0.152;\n",
- "\n",
- "# Calculations and Results\n",
- "#(1)\n",
- "# For van der Walls equation of state\n",
- "a = (27*R**(2)*Tc**(2))/(64*Pc);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The cubic form of van der Walls equation of state is given by,\n",
- "# V**(3) - (b + (R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "\n",
- "# At state 1 (100 C and 6 bar) \n",
- "def f(V): \n",
- "\t return V**(3)-(b+(R*T_1)/P_1)*V**(2)+(a/P_1)*V-(a*b)/P_1\n",
- "V_1_1 = fsolve(f,1)\n",
- "V_1_2 = fsolve(f,10)\n",
- "V_1_3 = fsolve(f,100)\n",
- "# The largest root is considered because of molar volume of vapour phase is to determined\n",
- "V_1 = V_1_1;\t\t\t#[m**(3)/mol]\n",
- "# Thus compressibility factor is\n",
- "Z_1 = (P_1*V_1)/(R*T_1);\t\t\t#compressibility factor\n",
- "\n",
- "H_R_1 = (Z_1 - 1)*R*T_1 - (a/V_1);\t\t\t# [J/mol]\n",
- "S_R_1 = R*math.log((P_1*(V_1-b))/(R*T_1));\t\t\t# [J/mol-K]\n",
- "\n",
- "# At state 2 (500 C and 12 bar) \n",
- "def f1(V): \n",
- " return V**(3)-(b+(R*T_2)/P_2)*V**(2)+(a/P_2)*V-(a*b)/P_2\n",
- "V_2_1 = fsolve(f1,1)\n",
- "V_2_2 = fsolve(f1,10)\n",
- "V_2_3 = fsolve(f1,100)\n",
- "# The largest root is considered because of molar volume of vapour phase is to determined\n",
- "V_2 = V_2_1;\t\t\t#[m**(3)/mol]\n",
- "# Thus compressibility factor is\n",
- "Z_2 = (P_2*V_2)/(R*T_2);\t\t\t#compressibility factor\n",
- "\n",
- "H_R_2 = (Z_2 - 1)*R*T_2 - (a/V_2);\t\t\t# [J/mol]\n",
- "S_R_2 = R*math.log((P_2*(V_2-b))/(R*T_2));\t\t\t# [J/mol-K]\n",
- "\n",
- "# Ideal gas entropy change is given by\n",
- "delta_S_ig = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
- "# Entropy change is given by\n",
- "delta_S = delta_S_ig + (S_R_2 - S_R_1);\t\t\t#[J/mol-k]\n",
- "\n",
- "# Ideal gas enthalpy change is given by\n",
- "delta_H_ig = Cp_0*(T_2 - T_1);\t\t\t#[J/mol]\n",
- "# Enthalpy change is given by\n",
- "delta_H = delta_H_ig + (H_R_2 - H_R_1);\t\t\t#[J/mol]\n",
- "\n",
- "print \"1).The change in enthalpy is %f J/mol\"%(delta_H);\n",
- "print \" The change in entropy is %f J/mol-K\"%(delta_S);\n",
- "\n",
- "#(2)\n",
- "# Virial equation of state\n",
- "\n",
- "# At state 1 (372.15 K, 6 bar) let us calculate B and dB/dT\n",
- "Tr = T_1/Tc;\t\t\t# Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2));\n",
- "\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- "dB0_dT = 0.422*1.6*Tc**(1.6)*T_1**(-2.6);\t\t\t# (dB_0/dT) at state 1\n",
- "dB1_dT = 0.172*4.2*Tc**(4.2)*T_1**(-5.2);\t\t\t# (dB_1/dT) at state 1\n",
- "dB_dT = ((R*Tc)/Pc)*((dB0_dT) + w*(dB1_dT));\t\t\t# (dB/dT) at state 1\n",
- "\n",
- "H_R_1_2 = B*P_1 - P_1*T_1*dB_dT;\t\t\t#[J/mol] - Residual enthalpy at state 1\n",
- "S_R_1_2 = -P_1*(dB_dT);\t\t\t#[J/mol-K] - Residual entropy at state 1\n",
- "\n",
- "# At state 2 (773.15 K, 12 bar)\n",
- "Tr_2 = T_2/Tc;\t\t\t# Reduced temperature\n",
- "B_0_2 = 0.083-(0.422/(Tr_2)**(1.6));\n",
- "B_1_2 = 0.139-(0.172/(Tr_2)**(4.2));\n",
- "\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B_2 = ((B_0_2+(w*B_1_2))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- "dB0_dT_2 = 0.422*1.6*Tc**(1.6)*T_2**(-2.6);\t\t\t# (dB_0/dT) at state 1\n",
- "dB1_dT_2 = 0.172*4.2*Tc**(4.2)*T_2**(-5.2);\t\t\t# (dB_1/dT) at state 1\n",
- "dB_dT_2 = ((R*Tc)/Pc)*((dB0_dT_2) + w*(dB1_dT_2));\t\t\t# (dB/dT) at state 1\n",
- "\n",
- "H_R_2_2 = B_2*P_2 - P_2*T_2*dB_dT_2;\t\t\t#[J/mol] - Residual enthalpy at state 1\n",
- "S_R_2_2 = -P_2*(dB_dT_2);\t\t\t#[J/mol-K] - Residual entropy at state 1\n",
- "\n",
- "delta_H_2 = delta_H_ig + (H_R_2_2 - H_R_1_2);\t\t\t#[J/mol]\n",
- "delta_S_2 = delta_S_ig + (S_R_2_2 - S_R_1_2);\t\t\t#[J/mol]\n",
- "\n",
- "print \"2).The change in enthalpy is %f J/mol\"%(delta_H_2);\n",
- "print \" The change in entropy is %f J/mol-K\"%(delta_S_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1).The change in enthalpy is 29798.211799 J/mol\n",
- " The change in entropy is 48.649067 J/mol-K\n",
- "2).The change in enthalpy is 29992.807365 J/mol\n",
- " The change in entropy is 49.021724 J/mol-K\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.21 Page Number : 362"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P = 2.76*10**(6);\t\t\t#[N/m**(2)] - Pressure\n",
- "T = 310.93;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# For n-butane\n",
- "Tc = 425.18;\t\t\t#[K] - Critical temperature\n",
- "Pc = 37.97;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.193;\n",
- "den = 0.61;\t\t\t#[g/cm**(3)]\n",
- "mol_wt = 58;\t\t\t#[g/mol] - Molecular weight of butane\n",
- "\n",
- "# Calculations and Results\n",
- "# math.log(P_sat) = 15.7374 - 2151.63/(T-36.24)\n",
- "P_sat = math.exp(15.7374 - 2151.63/(T-36.24));\t\t\t#[mm Hg]\n",
- "P_sat = (P_sat/760)*101325;\t\t\t#[N/m**(2)]\n",
- "\n",
- "#(1)\n",
- "# Let us determine the second virial coefficient at 310.93 K\n",
- "Tr = T/Tc;\t\t\t# Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n",
- "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Fugacity under saturated conditions is given by\n",
- "# math.log(f_sat/P_sat) = (B*P_sat)/(R*T)\n",
- "f_sat = P_sat*(math.exp((B*P_sat)/(R*T)));\t\t\t#[N/m**(2)]\n",
- "\n",
- "# The molar volume is given by\n",
- "V_liq = (1/(den*1000))*(mol_wt/1000);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "f = f_sat*math.exp(V_liq*(P-P_sat)/(R*T));\n",
- "\n",
- "print \" 1).The fugacity of n-butane is %e N/m**2)\"%(f);\n",
- "\n",
- "#(2)\n",
- "# For van der Walls equation of state\n",
- "a = (27*R**(2)*Tc**(2))/(64*Pc);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The cubic form of van der Walls equation of state is given by,\n",
- "# V**(3) - (b + (R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "\n",
- "# At 100 C and 1 atm \n",
- "def f(V): \n",
- " return V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P\n",
- "V_1 = fsolve(f,0.1)\n",
- "V_1 = fsolve(f,10)\n",
- "V_1 = fsolve(f,100)\n",
- "# The above equation has only 1 real root, other two roots are imaginary\n",
- "V = V_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# math.log(f/P) = math.log((R*T)/(P*(V-b))) + b/(V-b) -(2*a)/(R*T*V)\n",
- "f_2 = P*(math.exp(math.log((R*T)/(P*(V-b))) + b/(V-b) -(2*a)/(R*T*V)));\n",
- "\n",
- "print \" 2).The fugacity of n-butane is %e N/m**2)\"%(f_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The fugacity of n-butane is 3.293476e+05 N/m**2)\n",
- " 2).The fugacity of n-butane is 8.997352e+05 N/m**2)\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.22 Page Number : 363"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 50+273.15;\t\t\t#[K] - Temperature\n",
- "P = 25.*10**(3);\t\t\t#[Pa] - Pressure\n",
- "y1 = 0.5;\t\t\t#[mol] - mole fraction of equimolar mixture\n",
- "y2 = 0.5;\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "#For component 1 (methyl ethyl ketone)\n",
- "Tc_1 = 535.5;\t\t\t#[K] - Critical temperature\n",
- "Pc_1 = 41.5*10**(5);\t\t\t#[N/m**(2)] - Critical pressure\n",
- "Vc_1 = 267.;\t\t\t#[cm**(3)/mol] - Critical volume\n",
- "Zc_1 = 0.249;\t\t\t# Critical compressibility factor\n",
- "w_1 = 0.323;\t\t\t# acentric factor\n",
- "\n",
- "#For component 2 (toluene)\n",
- "Tc_2 = 591.8;\t\t\t#[K]\n",
- "Pc_2 = 41.06*10**(5);\t\t\t#[N/m**(2)]\n",
- "Vc_2 = 316.;\t\t\t#[cm**(3)/mol]\n",
- "Zc_2 = 0.264;\n",
- "w_2 = 0.262;\n",
- "\n",
- "# Calculations and Results\n",
- "# For equation of state Z = 1 + B/V\n",
- "#For component 1, let us calculate B and dB/dT\n",
- "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n",
- "#At reduced temperature\n",
- "B1_0 = 0.083-(0.422/(Tr_1)**(1.6));\n",
- "B1_1 = 0.139-(0.172/(Tr_1)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t# [m**(3)/mol-K] \n",
- "dB0_dT_1 = 0.422*1.6*Tc_1**(1.6)*T**(-2.6);\t\t\t# [m**(3)/mol-K] - (dB_0/dT)\n",
- "dB1_dT_1 = 0.172*4.2*Tc_1**(4.2)*T**(-5.2);\t\t\t# [m**(3)/mol-K] - (dB_1/dT)\n",
- "dB_dT_1 = ((R*Tc_1)/Pc_1)*((dB0_dT_1) + w_1*(dB1_dT_1));\t\t\t#[m**(3)/mol-K] - (dB/dT)_\n",
- "\n",
- "#Similarly for component 2\n",
- "Tr_2 = T/Tc_2;\t\t\t#Reduced temperature\n",
- "#At reduced temperature Tr_2,\n",
- "B2_0 = 0.083 - (0.422/(Tr_2)**(1.6));\n",
- "B2_1 = 0.139 - (0.172/(Tr_2)**(4.2));\n",
- "B_22 = ((B2_0+(w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "dB0_dT_2 = 0.422*1.6*Tc_2**(1.6)*T**(-2.6);\t\t\t# [m**(3)/mol-K] - (dB_0/dT)\n",
- "dB1_dT_2 = 0.172*4.2*Tc_2**(4.2)*T**(-5.2);\t\t\t# [m**(3)/mol-K] - (dB_1/dT)\n",
- "dB_dT_2 = ((R*Tc_2)/Pc_2)*((dB0_dT_2) + w_2*(dB1_dT_2));\t\t\t#[m**(3)/mol-K] - (dB/dT)_\n",
- "\n",
- "#For cross coeffcient, let us calculate B and dB/dT\n",
- "Tc_12 = (Tc_1*Tc_2)**(1./2);\t\t\t#[K]\n",
- "w_12 = (w_1 + w_2)/2.;\n",
- "Zc_12 = (Zc_1 + Zc_2)/2;\n",
- "Vc_12 = (((Vc_1)**(1./3) + (Vc_2)**(1./3))/2)**(3);\t\t\t#[cm**(3)/mol]\n",
- "Vc_12 = Vc_12*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "\n",
- "#Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0+(w_12*B_1)\n",
- "#where B_0 and B_1 are to be evaluated at Tr_12\n",
- "Tr_12 = T/Tc_12;\n",
- "#At reduced temperature Tr_12\n",
- "B_0 = 0.083 - (0.422/(Tr_12)**(1.6));\n",
- "B_1 = 0.139 - (0.172/(Tr_12)**(4.2));\n",
- "B_12 = ((B_0 + (w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "dB0_dT_12 = 0.422*1.6*Tc_12**(1.6)*T**(-2.6);\t\t\t# [m**(3)/mol-K] - (dB_0/dT)\n",
- "dB1_dT_12 = 0.172*4.2*Tc_12**(4.2)*T**(-5.2);\t\t\t# [m**(3)/mol-K] - (dB_1/dT)\n",
- "dB_dT_12 = ((R*Tc_12)/Pc_12)*((dB0_dT_12) + w_12*(dB1_dT_12));\t\t\t#[m**(3)/mol-K] - (dB/dT)_12\n",
- "\n",
- "#For the mixture\n",
- "B = y1**(2)*B_11 + 2*y1*y2*B_12 + y2**(2)*B_22;\t\t\t#[m**(3)/moL]\n",
- "\n",
- "# The equation of state can be written as\n",
- "# V**(2) - ((R*T)/P) - (B*R*T)/P = 0\n",
- "# V**(2) - 0.1075*V + 1.737*10**(-4) = 0\n",
- "def f(V): \n",
- " return V**(2) - 0.1075*V + 1.737*10**(-4)\n",
- "V1 = fsolve(f,0.1)\n",
- "V2 = fsolve(f,1)\n",
- "# We will consider the root which is near to R*T/P\n",
- "V = V1;\n",
- "# dB/dT = y_1**(2)*dB_11/dT + y_2**(2)*dB_22/dT + 2*y_1*y_2*dB_12/dT\n",
- "dB_dT = y1**(2)*dB_dT_1 + y2**(2)*dB_dT_2 + 2*y1*y2*dB_dT_12;\t\t\t#[m**(3)/mol-K]\n",
- "\n",
- "# For equation of state Z = 1 + B/V\n",
- "H_R = (B*R*T)/V - ((R*T**(2))/V)*dB_dT;\t\t\t#[J/mol]\n",
- "\n",
- "print \" 1).The value of H_R for the mixture using virial equation of state is %f J/mol\"%(H_R);\n",
- "\n",
- "#(2)\n",
- "# For van der Walls equation of state \n",
- "a_11 = (27*R**(2)*Tc_1**(2))/(64*Pc_1);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "a_22 = (27*R**(2)*Tc_2**(2))/(64*Pc_2);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "a_12 = (a_11*a_22)**(1./2);\n",
- "b_1 = (R*Tc_1)/(8*Pc_1);\t\t\t#[m**(3)/mol]\n",
- "b_2 = (R*Tc_2)/(8*Pc_2);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# For the mixture\n",
- "a = y1**(2)*a_11 + y2**(2)*a_22 + 2*y1*y2*a_12;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = y1*b_1 + y2*b_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# From the cubic form of van der Walls equation of state\n",
- "def f1(V): \n",
- " return V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P\n",
- "V2_1 = fsolve(f1,0.1)\n",
- "V2_2 = fsolve(f1,10)\n",
- "V2_3 = fsolve(f1,100)\n",
- "# The largest root is considered\n",
- "V_2 = V2_1;\n",
- "\n",
- "# The residual enthalpy is given by\n",
- "H_R_2 = P*V_2 - R*T -a/V_2;\t\t\t#[J/mol]\n",
- "\n",
- "print \" 2).The value of H_R for the mixture using van der Walls equation of state is %f J/mol\"%(H_R_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The value of H_R for the mixture using virial equation of state is -151.289795 J/mol\n",
- " 2).The value of H_R for the mixture using van der Walls equation of state is -38.476127 J/mol\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.23 Page Number : 366"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 320 + 273.15;\t\t\t#[K]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# For water\n",
- "Tc = 647.1;\t\t\t#[K]\n",
- "Pc = 220.55;\t\t\t#[bar]\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "\n",
- "# The cubic form of Redlich Kwong equation of state is given by,\n",
- "# V**(3) - ((R*T)/P)*V**(2) - ((b_1**(2)) + ((b_1*R*T)/P) - (a/(T**(1/2)*P))*V - (a*b)/(T**(1/2)*P) = 0\n",
- "\n",
- "# At 320 C and 70 bar pressure\n",
- "P_1 = 70;\t\t\t#[bar]\n",
- "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
- "\n",
- "# Calculations and Results\n",
- "a = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "# Solving the cubic equation\n",
- "def f1(V): \n",
- " return V**(3)-((R*T)/P_1)*V**(2)-((b**(2))+((b*R*T)/P_1)-(a/(T**(1./2)*P_1)))*V-(a*b)/(T**(1./2)*P_1)\n",
- "V1=fsolve(f1,1)\n",
- "V2=fsolve(f1,10)\n",
- "V3=fsolve(f1,100)\n",
- "# The largest root is considered because at 320 C and 70 bar vapour phase exists.\n",
- "V_1 = V1;\t\t\t#[m**(3)/mol]\n",
- "# Thus compressibility factor is\n",
- "Z_1 = (P_1*V_1)/(R*T);\n",
- "\n",
- "# For Redlich-Kwong equation of state\n",
- "# math.log(f/P) = Z - 1 - math.log(V_1/(V_1-b)) + (a/(b*R*(T**(3/2))))*math.log(V/(V+b))\n",
- "f_1 = P_1*(math.exp(Z_1-1-math.log(Z_1)+math.log(V_1/(V_1-b))+(a/(b*R*(T**(3./2))))*math.log(V_1/(V_1+b))));\t\t\t#[Pa]\n",
- "f_1 = f_1*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "print \" The fugacity of water vapour at 320 C and 70 bar pressure is %f bar\"%(f_1);\n",
- "\n",
- "# At 320 C and 170 bar pressure, we have\n",
- "P_2 = 170;\t\t\t#[bar]\n",
- "P_2 = P_2*10**(5);\t\t\t#[Pa]\n",
- "\n",
- "# Solving the cubic equation\n",
- "def f2(V): \n",
- " return V**(3)-((R*T)/P_2)*V**(2)-((b**(2))+((b*R*T)/P_2)-(a/(T**(1./2)*P_2)))*V-(a*b)/(T**(1./2)*P_2)\n",
- "V4 = fsolve(f2,1)\n",
- "V5 = fsolve(f2,10)\n",
- "V6 = fsolve(f2,100)\n",
- "# The above equation has only 1 real root,other two roots are imaginary. Therefore,\n",
- "V_2 = V6;\t\t\t#[m**(3)/mol]\n",
- "# Thus compressibility factor is\n",
- "Z_2 = (P_2*V_2)/(R*T);\n",
- "\n",
- "# For Redlich-Kwong equation of state\n",
- "# math.log(f/P) = Z - 1 - math.log(V_1/(V_1-b)) + (a/(b*R*(T**(3/2))))*math.log(V/(V+b))\n",
- "f_2 = P_2*(math.exp(Z_2-1-math.log(Z_2)+math.log(V_2/(V_2-b))+(a/(b*R*(T**(3./2))))*math.log(V_2/(V_2+b))));\t\t\t#[Pa]\n",
- "f_2 = f_2*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "print \" The fugacity of water vapour at 320 C and 170 bar pressure is %f bar\"%(f_2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The fugacity of water vapour at 320 C and 70 bar pressure is 60.456239 bar\n",
- " The fugacity of water vapour at 320 C and 170 bar pressure is 101.590989 bar\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stderr",
- "text": [
- "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
- " improvement from the last ten iterations.\n",
- " warnings.warn(msg, RuntimeWarning)\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.24 Page Number : 367"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "Vol = 0.057;\t\t\t#[m**(3)] - Volume of car tyre\n",
- "P_1 = 300.;\t\t\t#[kPa] - Initial pressure\n",
- "P_1 = P_1*10**(3);\t\t\t#[Pa]\n",
- "T_1 = 300.;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 330.;\t\t\t#[kPa] - Finnal pressure\n",
- "P_2 = P_2*10**(3);\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "Cv_0 = 21.;\t\t\t#[J/mol-K] - Heat capacity for air \n",
- "\n",
- "# For oxygen\n",
- "Tc_O2 = 154.6;\t\t\t#[K] - Critical temperature\n",
- "Pc_O2 = 50.43;\t\t\t#[bar] - Critical pressure\n",
- "Pc_O2 = Pc_O2*10**(5);\t\t\t#[Pa]\n",
- "y1 = 0.21;\t\t\t# - Mole fraction of oxygen\n",
- "# For nitrogen\n",
- "Tc_N2 = 126.2;\t\t\t#[K] - Critical temperature\n",
- "Pc_N2 = 34.00;\t\t\t#[bar] - Critical pressure\n",
- "Pc_N2 = Pc_N2*10**(5);\t\t\t#[Pa]\n",
- "y2 = 0.79;\t\t\t# - Mole fraction of nitrogen\n",
- "\n",
- "# Calculations and Results\n",
- "# (1)\n",
- "# Assuming ideal gas behaviour. The volume remains the same,therefore,we get\n",
- "# P_1/T_1 = P_2/T_2\n",
- "T_2 = P_2*(T_1/P_1);\t\t\t#[K]\n",
- "\n",
- "n = (P_1*Vol)/(R*T_1);\t\t\t#[mol] - Number of moles\n",
- "delta_U = n*Cv_0*(T_2-T_1);\t\t\t#[J]\n",
- "\n",
- "print \" 1).The change in internal energy for ideal gas behaviour) is %f J\"%(delta_U);\n",
- "\n",
- "#(2)\n",
- "# For van der Walls equation of state \n",
- "a_O2 = (27*R**(2)*Tc_O2**(2))/(64*Pc_O2);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "a_N2 = (27*R**(2)*Tc_N2**(2))/(64*Pc_N2);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "a_12 = (a_O2*a_N2)**(1./2);\n",
- "b_O2 = (R*Tc_O2)/(8*Pc_O2);\t\t\t#[m**(3)/mol]\n",
- "b_N2 = (R*Tc_N2)/(8*Pc_N2);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# For the mixture\n",
- "a = y1**(2)*a_O2 + y2**(2)*a_N2 + 2*y1*y2*a_12;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = y1*b_O2 + y2*b_N2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# From the cubic form of van der Walls equation of state\n",
- "# At 300 K and 300 kPa,\n",
- "def f1(V): \n",
- " return V**(3)-(b+(R*T_1)/P_1)*V**(2)+(a/P_1)*V-(a*b)/P_1\n",
- "V_1 = fsolve(f1,0.1)\n",
- "V_2 = fsolve(f1,10)\n",
- "V_3 = fsolve(f1,100)\n",
- "# The above equation has only 1 real root, other two roots are imaginary\n",
- "V = V_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Now at P = 330 kPa and at molar volume V\n",
- "# The van der Walls equation of state is\n",
- "# (P + a/V**(2))*(V - b) = R*T\n",
- "T_2_prime = ((P_2 + a/V**(2))*(V - b))/R;\t\t\t#[K]\n",
- "n_prime = Vol/V;\t\t\t#[mol]\n",
- "\n",
- "# Total change in internal energy is given by\n",
- "# delta_U_prime = n_prime*delta_U_ig + n_prime*(U_R_2 - U_R_1)\n",
- "# delta_U_prime = n_prime*Cv_0*(T_2_prime - T_1) + n_prime*a(1/V_2 - 1/V_1);\n",
- "# Since V_1 = V_2 = V, therefore\n",
- "delta_U_prime = n_prime*Cv_0*(T_2_prime - T_1);\n",
- "\n",
- "print \" 2).The change in internal energy for van der Walls equation of state) is %f J\"%(delta_U_prime);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The change in internal energy for ideal gas behaviour) is 4319.220592 J\n",
- " 2).The change in internal energy for van der Walls equation of state) is 4299.872282 J\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.25 Page Number : 369"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T_1 = 150 + 273.15;\t\t\t#[K] - Initial emperature\n",
- "T_2 = T_1;\t\t\t# Isothermal process\n",
- "P_1 = 100.*10**(3);\t\t\t#[Pa] - Initial pressure\n",
- "P_2 = 450.*10**(3);\t\t\t#[Pa] - Final pressure\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "# For water\n",
- "Tc = 647.1;\t\t\t#[K] - Critical temperature\n",
- "Pc = 220.55;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10.**(5);\n",
- "w = 0.345;\n",
- "Mol_wt = 18.015;\t\t\t#[g/mol] - Molecular weight of water\n",
- "Cp_0 = 4.18;\t\t\t#[J/mol-K] - Smath.tan(math.radiansard heat capacity of water\n",
- "\n",
- "# Calculations\n",
- "# Both phases are superheated vapour phases because at 150 C the vapour pressure of steam is 4.67 bar and both operating pressures are below saturated pressure.\n",
- "# In Peng-Robinson equation of state\n",
- "m = 0.37464 + 1.54226*w - 0.26992*w**(2);\n",
- "# At T_1 and P_1, we have\n",
- "Tr = T_1/Tc;\n",
- "alpha = (1 + m*(1 - Tr**(1./2)))**(2);\n",
- "a = ((0.45724*(R*Tc)**(2))/Pc)*alpha;\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b = (0.07780*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Cubuc form of Peng-Robinson equation of stste is given by\n",
- "# V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2))/P)-((a*b)/P)=0;\n",
- "# Solving the cubic equation\n",
- "def f(V): \n",
- " return V**(3)+(b-(R*T_1)/P_1)*V**(2)-((3*b**(2))+((2*R*T_1*b)/P_1)-(a/P_1))*V+b**(3)+((R*T_1*(b**(2)))/P_1)-((a*b)/P_1)\n",
- "V1 = fsolve(f,-1)\n",
- "V2 = fsolve(f,0)\n",
- "V3 = fsolve(f,1)\n",
- "#The largest root is for vapour phase,\n",
- "#The largest root is only considered as the systemis gas\n",
- "V_1 = V3;\t\t\t#[m**(3)/mol]\n",
- "# Thus compressibility factor is\n",
- "Z_1 = (P_1*V_1)/(R*T_1);\n",
- "\n",
- "# At T_2 and P_2, we have\n",
- "# Cubuc form of Peng-Robinson equation of stste is given by\n",
- "# V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2))/P)-((a*b)/P)=0;\n",
- "# Solving the cubic equation\n",
- "def f1(V): \n",
- " return V**(3)+(b-(R*T_2)/P_2)*V**(2)-((3*b**(2))+((2*R*T_2*b)/P_2)-(a/P_2))*V+b**(3)+((R*T_2*(b**(2)))/P_2)-((a*b)/P_2)\n",
- "V4 = fsolve(f1,-1)\n",
- "V5 = fsolve(f1,0)\n",
- "V6 = fsolve(f1,1)\n",
- "#The largest root is for vapour phase,\n",
- "#The largest root is only considered as the systemis gas\n",
- "V_2 = V6;\t\t\t#[m**(3)/mol]\n",
- "# Thus compressibility factor is\n",
- "Z_2 = (P_2*V_2)/(R*T_2);\n",
- "\n",
- "# In the Peng-Robinson equation of stste\n",
- "# da/dT = -(a*m)/((alpha*T*Tc)**(1/2))\n",
- "# The residual enthalpy is given by\n",
- "# H_R = R*T*(Z-1) + (((T*(da_dT))-a)/(2*2**(1/2)*b))*math.log((Z+(1+2**(1/2)*((P*b)/(R*T))))/(Z+(1-2**(1/2)*((P*b)/(R*T)))))\n",
- "\n",
- "# At state 1\n",
- "da_dT_1 = -(a*m)/((alpha*T_1*Tc)**(1./2));\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "H_R_1 = R*T_1*(Z_1-1) + (((T_1*(da_dT_1))-a)/(2*(2**(1./2))*b))* \\\n",
- "math.log((Z_1+(1+2**(1./2))*((P_1*b)/(R*T_1)))/(Z_1+(1-2**(1./2))*((P_1*b)/(R*T_1))));\n",
- "\n",
- "# At state 2\n",
- "da_dT_2 = -(a*m)/((alpha*T_2*Tc)**(1/2.));\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "H_R_2 = R*T_2*(Z_2-1) + (((T_2*(da_dT_2))-a)/(2*2**(1./2)* \\\n",
- "b))*math.log((Z_2+(1+2**(1./2))*((P_2*b)/(R*T_1)))/(Z_2+(1-2**(1./2))*((P_2*b)/(R*T_1))));\n",
- "\n",
- "# Since the temperature is the same,therefore ideal gas change in enthalpy is zero and thus\n",
- "delta_H = H_R_2 - H_R_1;\t\t\t#[J/mol]\n",
- "delta_H = delta_H/Mol_wt;\t\t\t#[kJ/kg]\n",
- "\n",
- "# The residual entropy relation for a substance following Peng - Robinson equation of state ia\n",
- "# S_R = R*math.log(Z - (P*b)/(R*T)) + (da_dT/(2*2**(1/2)*b))*math.log((Z+(1+2**(1/2))*((P*b)/(R*T)))/(Z+(1-2**(1/2))*((P*b)/(R*T))))\n",
- "\n",
- "# The residual entropy at state 1 is\n",
- "S_R_1 = R*math.log(Z_1 - (P_1*b)/(R*T_1)) + (da_dT_1/(2*2**(1./2)*b))* \\\n",
- "math.log((Z_1+(1+2**(1./2))*((P_1*b)/(R*T_1)))/(Z_1+(1-2**(1./2))*((P_1*b)/(R*T_1))));\n",
- "\n",
- "# The residual entropy at state 2 is\n",
- "S_R_2 = R*math.log(Z_2 - (P_2*b)/(R*T_2)) + (da_dT_2/(2*2**(1./2)*b)) \\\n",
- "*math.log((Z_2+(1+2**(1./2))*((P_2*b)/(R*T_2)))/(Z_2+(1-2**(1./2))*((P_2*b)/(R*T_2))));\n",
- "\n",
- "delta_S_R = S_R_2 - S_R_1;\t\t\t#[J/mol-K]\n",
- "\n",
- "# The ideal gas change in entropy is\n",
- "delta_S_ig = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
- "\n",
- "# Therefore\n",
- "delta_S = delta_S_R + delta_S_ig;\t\t\t#[J/mol-K]\n",
- "\n",
- "# Results\n",
- "print \" The enthalpy change is given by delta_H = %f kJ/mol\"%(delta_H);\n",
- "print \" The entropy change is given by delta_S = %f J/mol-K\"%(delta_S);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The enthalpy change is given by delta_H = -11.747722 kJ/mol\n",
- " The entropy change is given by delta_S = -12.826050 J/mol-K\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.26 Page Number : 370"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# Variables\n",
- "Vol = 0.15;\t\t\t#[m**(3)]\n",
- "T_1 = 170;\t\t\t#[K] - Initial emperature\n",
- "P_1 = 100;\t\t\t#[bar] - Initial pressure\n",
- "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "# For nitrogen\n",
- "Tc = 126.2;\t\t\t#[K] - Critical tempeature\n",
- "Pc = 34;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.038;\n",
- "# Cp_0 = 27.2+4.2*10**(-3)*T\n",
- "\n",
- "# Calculations and Results\n",
- "#(1)\n",
- "# For van der Walls equation of state\n",
- "a = (27*R**(2)*Tc**(2))/(64*Pc);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The cubic form of van der Walls equation of state is given by,\n",
- "# V**(3) - (b + (R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "# On simplification the equation changes to\n",
- "# V**(3) - 1.799*10**(4)*V**(2) + 1.366*10**(-8)*V - 5.269*10**(-13) = 0\n",
- "\n",
- "# Solving the cubic equation \n",
- "def f(V): \n",
- " return V**(3)-1.799*10**(-4)*V**(2) + 1.366*10**(-8)*V - 5.269*10**(-13)\n",
- "V1 = fsolve(f,1)\n",
- "V2 = fsolve(f,10)\n",
- "V3 = fsolve(f,100)\n",
- "# The above equation has only 1 real root, other two roots are imagimnary\n",
- "V_1 = V1;\t\t\t#[m**(3)/mol]\n",
- "# Thus total number of moles is given by\n",
- "n_1 = Vol/V_1;\t\t\t#[mol]\n",
- "\n",
- "# After 500 mol are withdrawn, the final number of moles is given by\n",
- "n_2 = n_1 - 500;\t\t\t#[mol]\n",
- "# Thus molar volume at final state is \n",
- "V_2 = Vol/n_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The ideal entropy change is guven by\n",
- "\n",
- "def f24(T): \n",
- " return 27.2+4.2*10**(-3)*T\n",
- "\n",
- "# delta_S_ig = quad(f24,T_1,T_2) - R*math.log(P_2/P_1)[0]\n",
- "\n",
- "# The residual entropy change is given by\n",
- "# delta_S_R = R*math.log((P_2*(V_2-b))/(R*T_2)) - R*math.log((P_1*(V_1-b))/(R*T_1)) \n",
- "# delta_S = delta_S_ig = delta_S_R\n",
- "\n",
- "def f25(T): \n",
- " return 27.2+4.2*10**(-3)*T\n",
- "\n",
- "# delta_S = quad(f25,T_1,T_2) + R*math.log((V_2-b)/(V_1-b))[0]\n",
- "\n",
- "# During discharging delta_S = 0, thus on simplification we get\n",
- "# 18.886*math.log(T_2) + 4.2*10**(-3)*T_2 - 92.937 = 0\n",
- "# Solving the above equation we get\n",
- "def f1(T_2): \n",
- " return 18.886*math.log(T_2) + 4.2*10**(-3)*T_2 - 92.937\n",
- "T_2 = fsolve(f1,1)\n",
- "\n",
- "# Thus at T_2, \n",
- "P_2 = (R*T_2)/(V_2-b) - a/V_2**(2);\t\t\t#[N/m**(2)]\n",
- "P_2 = P_2*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "print \" 1).The final temperature is %f K\"%(T_2);\n",
- "print \" The final pressure is %f bar\"%(P_2);\n",
- "\n",
- "#(2)\n",
- "# In Peng-Robinson equation of state\n",
- "m = 0.37464 + 1.54226*w - 0.26992*w**(2);\n",
- "# At T_1 and P_1, we have\n",
- "Tr = T_1/Tc;\n",
- "alpha = (1 + m*(1 - Tr**(1./2)))**(2);\n",
- "a_2 = ((0.45724*(R*Tc)**(2))/Pc)*alpha;\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b_2 = (0.07780*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Cubuc form of Peng-Robinson equation of stste is given by\n",
- "# V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2))/P)-((a*b)/P)=0;\n",
- "# Solving the cubic equation\n",
- "def f2(V): \n",
- " return V**(3)+(b_2-(R*T_1)/P_1)*V**(2)-((3*b_2**(2))+((2*R*T_1*b_2)/P_1)-(a_2/P_1))*V+b_2**(3)+((R*T_1*(b_2**(2)))/P_1)-((a_2*b_2)/P_1)\n",
- "V4 = fsolve(f2,-1)\n",
- "V5 = fsolve(f2,0)\n",
- "V6 = fsolve(f2,0.006)\n",
- "#The above equation has only 1 real root,the other two roots are imaginary\n",
- "V_1_2 = V6;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The number of moles in the initial state is given by\n",
- "n_1_2 = Vol/V_1_2;\t\t\t#[mol]\n",
- "# After 500 mol are withdrawn, the final number of moles is given by\n",
- "n_2_2 = n_1_2 - 500;\t\t\t#[mol]\n",
- "# Thus molar volume at final state is \n",
- "V_2_2 = Vol/n_2_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# At the final state the relation between pressure and temperature is\n",
- "# P_2_2 = (R*T_2_2)/(V_2_2-b_2) - a_2/V_2_2**(2)\n",
- "# P_2_2 = 7.23*10**(4)*T_2 - 3.93*10**(7)*a_2\n",
- "\n",
- "# Now let us calculate the residual entropy at initial state\n",
- "Z_1 = (P_1*V_1_2)/(R*T_1);\n",
- "da_dT_1 = -(a*m)/((alpha*T_1*Tc)**(1./2));\t\t\t#[Pa*m**(6)/mol**(2)] - da/dT\n",
- "\n",
- "# The residual entropy change for Peng-Robinson equatiob of state is given by\n",
- "# S_R = R*math.log(Z-(P*b)/(R*T)) + (da_dT/(2*2**(1/2)*b))*math.log((V+(1+2**(1/2))*b))/((V+(1-2**(1/2)*b))));\n",
- "S_R_1 = R*(math.log(Z_1-(P_1*b_2)/(R*T_1))) + (da_dT_1/(2*2**(1.2)*b_2))*(math.log((V_1_2+(1+2**(1./2))*b_2)/(V_1_2+(1-2**(1./2))*b_2)));\n",
- "\n",
- "# The total entropy change is given by\n",
- "# delta_S = delta_S_ig + delta_S_R\n",
- "\n",
- "def f26(T): \n",
- " return 27.2+4.2*10**(-3)*T\n",
- "\n",
- "# where, delta_S_ig = quad(f26,T_1,T_2_2) - R*math.log(P_2_2/P_1)[0]\n",
- "\n",
- "# and, P_2_2 = (R*T_2_2)/(V_2_2-b_2) - a_2/V_2_2**(2)\n",
- "# On simplification we get\n",
- "# delta_S = 27.2*math.log(T_2_2-T_1) + 4.2*10**(-3)*(T_2_2-T_1) - R*math.log(P_2_2/P_1) + R*math.log(Z_2-(P_2_2*b)/(R*T_2_2)) + 6226*(da_dT_2) + 9.22\n",
- "\n",
- "# Now we have the determine the value of T_2_2 such that delta_S = 0\n",
- "# Starting with a temperature of 150 K\n",
- "T_prime = 100.;\t\t\t#[K]\n",
- "error = 10.;\n",
- "while(error>0.1):\n",
- " Tr_prime = T_prime/Tc;\n",
- " alpha_prime = (1 + m*(1 - Tr_prime**(1./2)))**(2);\n",
- " a_prime = ((0.45724*(R*Tc)**(2))/Pc)*alpha_prime;\n",
- " P_prime = 7.23*10**(4)*T_prime - 3.93*10**(7)*a_prime;\n",
- " Z_prime = (P_prime*V_2_2)/(R*T_prime);\n",
- " da_dT_prime = -(a_prime*m)/((alpha_prime*T_prime*Tc)**(1./2));\n",
- " delta_S = 27.2*math.log(T_prime/T_1) + 4.2*10**(-3)*(T_prime-T_1) - R*math.log(P_prime/P_1) + R*math.log(Z_prime-((P_prime*b_2)/(R*T_prime))) + 6226*(da_dT_prime) + 9.22;\n",
- " error=abs(delta_S);\n",
- " T_prime = T_prime + 0.3;\n",
- "\n",
- "T_2_2 = T_prime;\t\t\t#[K] - Final temperature\n",
- "P_2_2 = P_prime*10**(-5);\t\t\t#[bar] - Final pressure\n",
- "\n",
- "print \" 2).The final temperature is %f K\"%(T_2_2);\n",
- "print \" The final pressure is %f bar\"%(P_2_2);\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The final temperature is 133.131844 K\n",
- " The final pressure is 39.636659 bar\n",
- " 2).The final temperature is 134.200000 K\n",
- " The final pressure is 40.130674 bar\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.27 Page Number : 374"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 373.15;\t\t\t#[K]\n",
- "Tc = 562.16;\t\t\t#[K]\n",
- "Pc = 48.98;\t\t\t#[bar]\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
- "\n",
- "# The cubic form of Redlich Kwong equation of state is given by,\n",
- "# V**(3) - ((R*T)/P)*V**(2) - ((b_1**(2)) + ((b_1*R*T)/P) - (a/(T**(1/2)*P))*V - (a*b)/(T**(1/2)*P) = 0\n",
- "\n",
- "# Calculations\n",
- "a = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# At 373.15 K, let us assume the pressure to be 2.5 bar and under these conditions \n",
- "P_1 = 2.5;\t\t\t#[bar]\n",
- "P_1 = P_1*10**(5);\t\t\t#[bar]\n",
- "\n",
- "# Putting the values in Redlich Kwong equation of state, the equation becomes\n",
- "# V**(3) - 0.0124*V**(2) + 8.326*10**(-6)*V - 7.74*10**(-10) = 0\n",
- "# Solving the cubic equation\n",
- "\n",
- "def f(V): \n",
- " return V**(3) - 0.0124*V**(2) + 8.326*10**(-6)*V - 7.74*10**(-10)\n",
- "V1=fsolve(f,-9)\n",
- "V2=fsolve(f,10)\n",
- "V3=fsolve(f,0.1)\n",
- "# The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n",
- "V_liq = V1;\t\t\t#[m**(3)/mol] - Molar volume in liquid phase\n",
- "V_vap = V3;\t\t\t#[m**(3)/mol] - Molar volume in vapour phase\n",
- "\n",
- "# Let us calculate the fugacity of vapour phase\n",
- "# math.log(f_vap/P) = b/(V-b) + math.log((R*T)/(P*(V-b))) - (a/(R*T**(1.5)))*(1/(V+b) - (1/b)*math.log(V/(V+b)))\n",
- "f_vap = P_1*math.exp(b/(V_vap-b) + math.log((R*T)/(P_1*(V_vap-b))) - (a/(R*T**(1.5)))*(1/(V_vap+b) - (1/b)*math.log(V_vap/(V_vap+b))));\t\t\t#[Pa]\n",
- "\n",
- "# Let us calculate the fugacity of the liquid phase\n",
- "f_liq = P_1*math.exp(b/(V_liq-b) + math.log((R*T)/(P_1*(V_liq-b))) - (a/(R*T**(1.5)))*(1/(V_liq+b) - (1/b)*math.log(V_liq/(V_liq+b))));\n",
- "\n",
- "\n",
- "# The two fugacities are not same; therefore another pressure is to be assumed. The new pressure is\n",
- "P_new = P_1*(f_liq/f_vap);\t\t\t#[Pa]\n",
- "\n",
- "# At P_new\n",
- "def f1(V): \n",
- " return V**(3) - ((R*T)/P_new)*V**(2) - (b**(2) + ((b*R*T)/P_new) - a/(T**(1/2)*P_new))*V - (a*b)/(T**(1/2)*P_new)\n",
- "V4=fsolve(f1,-9)\n",
- "V5=fsolve(f1,10)\n",
- "V6=fsolve(f1,0.1)\n",
- "# The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n",
- "V_liq_2 = V4;\t\t\t#[m**(3)/mol] - Molar volume in liquid phase\n",
- "V_vap_2 = V6;\t\t\t#[m**(3)/mol] - Molar volume in vapour phase\n",
- "\n",
- "f_vap_prime = P_new*math.exp(b/(V_vap_2-b) + math.log((R*T)/(P_new*(V_vap_2-b))) - (a/(R*T**(1.5)))*(1/(V_vap_2+b) - (1/b)*math.log(V_vap_2/(V_vap_2+b))));\t\t\t#[Pa]\n",
- "f_liq_prime = P_new*math.exp(b/(V_liq_2-b) + math.log((R*T)/(P_new*(V_liq_2-b))) - (a/(R*T**(1.5)))*(1/(V_liq_2+b) - (1/b)*math.log(V_liq_2/(V_liq_2+b))));\n",
- "\n",
- "# Since the fugacities of liquid and vapour phasesare almost same the assumed pressure may be taken as vapour pressure at 373.15 K\n",
- "P_new = P_new*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "# Results\n",
- "print \" The vapour pressure of benzene using Redlich Kwong equation of state is %f bar\"%(P_new);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The vapour pressure of benzene using Redlich Kwong equation of state is 2.666995 bar\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 10.28 Page Number : 374"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 150 + 273.15;\t\t\t#[K]\n",
- "Tc = 647.1;\t\t\t#[K]\n",
- "Pc = 220.55;\t\t\t#[bar]\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "w = 0.345;\n",
- "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
- "\n",
- "# Let us assume a pressure of 100 kPa.\n",
- "P_1 = 100.*10**(3);\t\t\t#[Pa]\n",
- "\n",
- "# Calculations\n",
- "# At 100 kPa and 423.15 K, from Peng-Robinson equation of stste \n",
- "m = 0.37464 + 1.54226*w - 0.26992*w**(2);\n",
- "Tr = T/Tc;\n",
- "alpha = (1 + m*(1 - Tr**(1./2)))**(2);\n",
- "a = ((0.45724*(R*Tc)**(2))/Pc)*alpha;\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b = (0.07780*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "# Cubic form of Peng-Robinson equation of stste is given by\n",
- "# V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2))/P)-((a*b)/P)=0;\n",
- "# Solving the cubic equation\n",
- "def f(V): \n",
- " return V**(3)+(b-(R*T)/P_1)*V**(2)-((3*b**(2))+((2*R*T*b)/P_1)-(a/P_1))*V+b**(3)+((R*T*(b**(2)))/P_1)-((a*b)/P_1)\n",
- "V1 = fsolve(f,-1)\n",
- "V2 = fsolve(f,0)\n",
- "V3 = fsolve(f,1)\n",
- "# The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n",
- "V_liq = V1;\t\t\t#[m**(3)/mol] - Molar volume in liquid phase\n",
- "V_vap = V3;\t\t\t#[m**(3)/mol] - Molar volume in vapour phase\n",
- "\n",
- "# The compressibility factor is given by\n",
- "Z_vap = (P_1*V_vap)/(R*T);\t\t\t# For liquid phase\n",
- "Z_liq = (P_1*V_liq)/(R*T);\t\t\t# For vapour phase\n",
- "\n",
- "# The math.expression for fugacity of Peng Robinson equation is\n",
- "# math.log(f/P) = (Z-1) - math.log(Z-((P*b)/(R*T))) - (a/(2*2**(1/2)*b*R*T))*math.log((Z+(1+2**(1/2))*((P*b)/(R*T)))/((Z+(1-2**(1/2))*((P*b)/(R*T)))\n",
- "# For vapour phase\n",
- "f_P_vap = math.exp((Z_vap-1) - math.log(Z_vap-((P_1*b)/(R*T))) - (a/(2*2**(1./2)*b*R*T))*math.log((Z_vap+(1+2**(1./2))*((P_1*b)/(R*T)))/(Z_vap+(1-2**(1./2))*((P_1*b)/(R*T)))));\n",
- "# For liquid phase\n",
- "f_P_liq = math.exp((Z_liq-1) - math.log(Z_liq-((P_1*b)/(R*T))) - (a/(2*2**(1./2)*b*R*T))*math.log((Z_liq+(1+2**(1./2))*((P_1*b)/(R*T)))/(Z_liq+(1-2**(1./2))*((P_1*b)/(R*T)))));\n",
- "\n",
- "# Therefore f_liq/f_vap can be calculated as\n",
- "fL_fV = (f_P_liq/f_P_vap);\n",
- "\n",
- "# The two values (f/P)_vap and (f/P)_vap are not same [ (f_P_liq/f_P_vap) >1 ]; therefore another pressure is to be assumed. The new pressure be\n",
- "P_new = P_1*(f_P_liq/f_P_vap);\t\t\t#[Pa]\n",
- "\n",
- "# At P_new and 423.15 K, from Peng-Robinson equation of stste \n",
- "\n",
- "# V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2))/P)-((a*b)/P)=0;\n",
- "# Solving the cubic equation\n",
- "def f(V): \n",
- " return V**(3)+(b-(R*T)/P_new)*V**(2)-((3*b**(2))+((2*R*T*b)/P_new)-(a/P_new))*V+b**(3)+((R*T*(b**(2)))/P_new)-((a*b)/P_new)\n",
- "V4 = fsolve(f,-1)\n",
- "V5 = fsolve(f,0)\n",
- "V6 = fsolve(f,1)\n",
- "# The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n",
- "V_liq_2 = V4;\t\t\t#[m**(3)/mol] - Molar volume in liquid phase\n",
- "V_vap_2 = V6;\t\t\t#[m**(3)/mol] - Molar volume in vapour phase\n",
- "\n",
- "# The compressibility factor is given by\n",
- "Z_vap_2 = (P_new*V_vap_2)/(R*T);\t\t\t# For liquid phase\n",
- "Z_liq_2 = (P_new*V_liq_2)/(R*T);\t\t\t# For vapour phase\n",
- "\n",
- "# For vapour phase\n",
- "f_P_vap_2 = math.exp((Z_vap_2-1) - math.log(Z_vap_2-((P_new*b)/(R*T))) - (a/(2*2**(1./2)*b*R*T))*math.log((Z_vap_2+(1+2**(1./2))*((P_new*b)/(R*T)))/(Z_vap_2+(1-2**(1./2))*((P_new*b)/(R*T)))));\n",
- "# For liquid phase\n",
- "f_P_liq_2 = math.exp((Z_liq_2-1) - math.log(Z_liq_2-((P_new*b)/(R*T))) - (a/(2*2**(1./2)*b*R*T))*math.log((Z_liq_2+(1+2**(1./2))*((P_new*b)/(R*T)))/(Z_liq_2+(1-2**(1./2))*((P_new*b)/(R*T)))));\n",
- "\n",
- "# Therefore f_liq/f_vap can be calculated as\n",
- "fL_fV_2 = (f_P_liq_2/f_P_vap_2);\n",
- "\n",
- "# And new pressure is given by\n",
- "P_new_prime = P_new*(f_P_liq_2/f_P_vap_2);\t\t\t#[Pa]\n",
- "P_new_prime = P_new_prime*10**(-5);\n",
- "\n",
- "# Since the change in pressure is small, so we can take this to be the vapour pressure at 150 C\n",
- "\n",
- "# Results\n",
- "print \" The vapour pressure of water using Peng-Robinson equation of stste is %f bar\"%(P_new_prime);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The vapour pressure of water using Peng-Robinson equation of stste is 4.675976 bar\n"
- ]
- }
- ],
- "prompt_number": 24
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch11_1.ipynb b/Chemical_Engineering_Thermodynamics/ch11_1.ipynb
deleted file mode 100755
index 79f48f9c..00000000
--- a/Chemical_Engineering_Thermodynamics/ch11_1.ipynb
+++ /dev/null
@@ -1,331 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:ea5fa2ce45062851dc4892fcc5b621c33d72fa0443d476b1ef4133dade9e39b0"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 11 : Properties of a Component in a Mixture"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 11.1 Page Number : 385"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "Vol_total = 3;\t\t\t#[m**(3)] - Total volume of solution\n",
- "x_ethanol = 0.6;\t\t\t#Mole fraction of ethanol\n",
- "x_water = 0.4;\t\t\t#Mole fraction of water\n",
- "\n",
- "# Calculations\n",
- "#The partial molar volumes of the components in the mixture are\n",
- "V_ethanol_bar = 57.5*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "V_water_bar = 16*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#The molar volumes of the pure components are\n",
- "V_ethanol = 57.9*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "V_water = 18*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#The molar volume of the solution is\n",
- "V_sol = x_ethanol*V_ethanol_bar + x_water*V_water_bar;\t\t\t#[m**(3)/mol]\n",
- "#Total number of moles can be calculated as \n",
- "n_total = Vol_total/V_sol;\t\t\t#[mol]\n",
- "\n",
- "#Moles of the components are\n",
- "n_ethanol = n_total*x_ethanol;\t\t\t#[mol]\n",
- "n_water = n_total*x_water;\t\t\t#[mol]\n",
- "\n",
- "#Finally the volume of the pure components required can be calculated as\n",
- "Vol_ethanol = V_ethanol*n_ethanol;\n",
- "Vol_water = V_water*n_water;\n",
- "\n",
- "# Results\n",
- "print \"Required volume of ethanol is %f cubic metre\"%(Vol_ethanol);\n",
- "print \"Required volume of water is %f cubic metre\"%(Vol_water);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Required volume of ethanol is 2.548166 cubic metre\n",
- "Required volume of water is 0.528117 cubic metre\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 11.2 Page Number : 385"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 25+273.15;\t\t\t#[K] - Temperature\n",
- "P = 1;\t\t\t#[atm]\n",
- "#Component 1 = water\n",
- "#component 2 = methanol\n",
- "a = -3.2;\t\t\t#[cm**(3)/mol] - A constant\n",
- "V2 = 40.7;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2 (methanol)\n",
- "#V1_bar = 18.1 + a*x_2**(2)\n",
- "\n",
- "# Calculations and Results\n",
- "#From Gibbs-Duhem equation at constant temperature and pressure we have\n",
- "#x_1*dV1_bar + x_2*dV2_bar = 0\n",
- "#dV2_bar = -(x_1/x_2)*dV1_bar = -(x_1/x_2)*a*2*x_2*dx_2 = -2*a*x_1*dx_2 = 2*a*x_1*dx_1\n",
- "\n",
- "#At x_1 = 0: x_2 = 1 and thus V2_bar = V2\n",
- "#Integrating the above equation from x_1 = 0 to x_1 in the RHS, and from V2_bar = V2 to V2 in the LHS, we get\n",
- "#V2_bar = V2 + a*x_1**(2) - Molar volume of component 2(methanol) in the mixture \n",
- "\n",
- "print \"The expression for the partial molar volume of methanol2 isV2_bar = V2 + a*x_1**2 [cm**3/mol]\";\n",
- "\n",
- "#At infinite dilution, x_2 approach 0 and thus x_1 approach 1, therefore\n",
- "x_1 = 1;\t\t\t# Mole fraction of component 1(water) at infinite dilution\n",
- "V2_bar_infinite = V2 + a*(x_1**(2));\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "print \"The partial molar volume of methanol at infinite dilution is %f cm**3/mol\"%(V2_bar_infinite);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The expression for the partial molar volume of methanol2 isV2_bar = V2 + a*x_1**2 [cm**3/mol]\n",
- "The partial molar volume of methanol at infinite dilution is 37.500000 cm**3/mol\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 11.4 Page Number : 387"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "#H = a*x_1 + b*x_2 +c*x_1*x_2\n",
- "\n",
- "#The values of the constants are\n",
- "a = 15000;\t\t\t#[J/mol]\n",
- "b = 20000;\t\t\t#[J/mol]\n",
- "c = -2000;\t\t\t#[J/mol]\n",
- "\n",
- "# Calculations and Results\n",
- "#(1)\n",
- "#Enthalpy of pure component 1 = H1 is obtained at x_2 = 0, thus \n",
- "x_2 = 0;\n",
- "x_1 = 1;\n",
- "H1 = a*x_1 + b*x_2 +c*x_1*x_2;\t\t\t#[J/mol]\n",
- "print \"a).The enthalpy of pure component 1 is %f J/mol\"%(H1);\n",
- "\n",
- "#Similarly for component 2,\n",
- "#Enthalpy of pure component 2 = H2 is obtained at x_1 = 0, thus \n",
- "x_1_prime = 0;\n",
- "x_2_prime = 1;\n",
- "H2 = a*x_1_prime + b*x_2_prime +c*x_1_prime*x_2_prime;\t\t\t#[J/mol]\n",
- "print \" The enthalpy of pure component 2 is %f J/mol\"%(H2);\n",
- "\n",
- "#(b)\n",
- "#This part involves proving a relation in which no mathematics and no calculations are involved.\n",
- "#For prove refer to this example 11.4 on page number 387 of the book.\n",
- "\n",
- "#(c)\n",
- "#From part (b), we have the relation\n",
- "#H1_bar = a + c*(x_2**(2))\n",
- "#H2_bar = b + c*(x_1**(2))\n",
- "\n",
- "#For enthalpy of component 1 at infinite dilution, x_1 approach 0 and thus x_2 approach 1, therefore\n",
- "x_1_c = 0;\n",
- "x_2_c = 1;\n",
- "H1_infinite = a + c*(x_2_c**(2));\t\t\t#[cm**(3)/mol]\n",
- "print \"C).The enthalpy of componenet 1 at infinite dilution at x_1 = 0) is %f J/mol\"%(H1_infinite);\n",
- "\n",
- "#At x_1 = 0.2\n",
- "x_1_c1 = 0.2;\n",
- "x_2_c1 = 0.8;\n",
- "H1_bar_c1 = a + c*(x_2_c1**(2));\t\t\t#[J/mol]\n",
- "print \" The enthalpy of componenet 1 at at x_1 = 0.2) is %f J/mol\"%(H1_bar_c1);\n",
- "\n",
- "#At x_1 = 0.8\n",
- "x_1_c2 = 0.8;\n",
- "x_2_c2 = 0.2;\n",
- "H1_bar_c2 = a + c*(x_2_c2**(2));\t\t\t#[J/mol]\n",
- "print \" The enthalpy of componenet 1 at at x_1 = 0.8) is %f J/mol\"%(H1_bar_c2);\n",
- "\n",
- "#As x_1 increases, 'H1_bar' approaches the value of 'H1' \n",
- "\n",
- "#(d)\n",
- "#This part involves proving a relation in which no mathematics and no calculations are involved.\n",
- "#For prove refer to this example 11.4 on page number 387 of the book.\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a).The enthalpy of pure component 1 is 15000.000000 J/mol\n",
- " The enthalpy of pure component 2 is 20000.000000 J/mol\n",
- "C).The enthalpy of componenet 1 at infinite dilution at x_1 = 0) is 13000.000000 J/mol\n",
- " The enthalpy of componenet 1 at at x_1 = 0.2) is 13720.000000 J/mol\n",
- " The enthalpy of componenet 1 at at x_1 = 0.8) is 14920.000000 J/mol\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 11.9 Page Number : 395"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "n = 1*10**(3);\t\t\t#[mol] - No of moles\n",
- "P = 0.1;\t\t\t#[MPa] - Pressure of the surrounding\n",
- "T = 300;\t\t\t#[K] - Temperature of the surrounding\n",
- "x_1 = 0.79;\t\t\t#Mole fraction of N2 in the air\n",
- "x_2 = 0.21;\t\t\t#Mole fraction of O2 in the air\n",
- "R=8.314;\t\t\t#[J/mol*K]\n",
- "\n",
- "# Calculations\n",
- "#Change in availability when x_1 moles of component 1 goes from pure state to that in the mixture is\n",
- "#x_1*(si_1 - si_2) = x_1*[H1 - H1_bar - T_0*(S1 - S1_bar)]\n",
- "#Similarly change in availability of x_2 moles of component 2 is\n",
- "#x_2*(si_1 - si_2) = x_2*[H2 - H2_bar - T_0*(S2 - S2_bar)]\n",
- "\n",
- "#and thus total availability change when 1 mol of mixture is formed from x_1 mol of component 1 and x_2 mol of component 2 is equal to reversible work\n",
- "#W_rev = x_1*[H1 - H1_bar - T_0*(S1 - S1_bar)] + x_2*[H2 - H2_bar - T_0*(S2 - S2_bar)]\n",
- "#W_rev = -[x_1*(H1_bar - H1) + x_2*(H2_bar - H2)] + T_0*[x_1*(S1_bar - S1) + x_2*(S2_bar - S2)]\n",
- "#W_rev = -[delta_H_mix] +T_0*[delta_S_mix]\n",
- "\n",
- "#If T = T_0 that is,temperature of mixing is same as that of surroundings, W_rev = -delta_G_mix.\n",
- "#W_rev = -delta_G_mix = R*T*(x_1*math.log(x_1) + x_2*math.log(x_2))\n",
- "W_rev = R*T*(x_1*math.log(x_1) + x_2*math.log(x_2));\t\t\t#[J/mol]\n",
- "\n",
- "#Therefore total work transfer is given by\n",
- "W_min = (n*W_rev)/1000;\t\t\t#[kJ]\n",
- "\n",
- "# Results\n",
- "print \"The minimum work required is %f kJ\"%(W_min);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The minimum work required is -1281.910728 kJ\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 11.10 Page Number : 400"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "x_A = 0.20;\t\t\t# Mole fraction of A\n",
- "x_B = 0.35;\t\t\t# Mole fraction of B\n",
- "x_C = 0.45;\t\t\t# Mole fraction of C\n",
- "\n",
- "phi_A = 0.7;\t\t\t# Fugacity coefficient of A\n",
- "phi_B = 0.6;\t\t\t# Fugacity coefficient of B\n",
- "phi_C = 0.9;\t\t\t# Fugacity coefficient of C\n",
- "\n",
- "P = 6.08;\t\t\t#[MPa] - Pressure\n",
- "T = 384;\t\t\t#[K] - Temperature\n",
- "\n",
- "# Calculations\n",
- "#We know that\n",
- "#math.log(phi) = x_1*math.log(phi_) + x_2*math.log(phi_2) + x_3*math.log(phi_3)\n",
- "math.log_phi = x_A*math.log(phi_A) + x_B*math.log(phi_B) + x_C*math.log(phi_C);\t\t\t# Fugacity coefficient\n",
- "phi = math.exp(math.log_phi);\n",
- "\n",
- "#Thus fugacity is given by,\n",
- "f_mixture = phi*P;\t\t\t#[MPa]\n",
- "\n",
- "# Results\n",
- "print \"The fugacity of the mixture is %f MPa\"%(f_mixture);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The fugacity of the mixture is 4.515286 MPa\n"
- ]
- }
- ],
- "prompt_number": 5
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch12_1.ipynb b/Chemical_Engineering_Thermodynamics/ch12_1.ipynb
deleted file mode 100755
index 0ee70a67..00000000
--- a/Chemical_Engineering_Thermodynamics/ch12_1.ipynb
+++ /dev/null
@@ -1,503 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:acb0234cca7ef04cf2e231ae1d04809101d746587fbd14cf847d456347c563ea"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 12 : Partial Molar Volume and Enthalpy from Experimental Data "
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 12.1 Page Number : 419"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "import math \n",
- "from numpy import *\n",
- "\n",
- "\n",
- "# Variables\n",
- "T = 0 + 273.15;\t\t\t#[K] - Temperature\n",
- "P = 1;\t\t\t#[atm] - Pressure\n",
- "x_methanol = 0.5;\t\t\t#Mole fraction of methanol at which molar volume is to be calculated\n",
- "x_water = 0.5;\t\t\t#Mole fraction at which molar volume is to be calculated\n",
- "\n",
- "#V = V1 at x1 = 1 and V = V2 at x1 = 0, therefore\n",
- "V1 = 40.7;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 1\n",
- "V2 = 18.1;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2\n",
- "from numpy import zeros,linalg\n",
- "x1=[0.114,0.197,0.249,0.495,0.692,0.785,0.892];\t\t\t# Values of mole fraction of component 1\n",
- "V=[20.3,21.9,23.0,28.3,32.9,35.2,37.9];\t\t\t# Values of molar volume\n",
- "x2=zeros(7);\t\t\t# Mole fraction of component 2\n",
- "x_V=zeros(7);\t\t\t# x_V = x1*V_1 + x2*V_2\n",
- "V_mix=zeros(7);\t\t\t# V_mix = V - x1*V_1 - x2*V_2\n",
- "del_V=zeros(7);\t\t\t#del_V = V_mix/(x1*x2)\n",
- "\n",
- "# Calculations\n",
- "for i in range(7):\n",
- " x2[i]=1-x1[i];\n",
- " x_V[i]=x1[i]*V1 + x2[i]*V2;\n",
- " V_mix[i]=V[i]-x1[i]*V1- x2[i]*V2;\n",
- " del_V[i]=V_mix[i]/(x1[i]*x2[i]);\n",
- "\n",
- "x1 = array(x1)\n",
- "\t\t\t#From the matrix method to solve simultaneous linear equations, we have\n",
- "a=array([[7, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2), sum(x1**3)],[sum(x1**2), sum(x1**3), sum(x1**4)]])\n",
- "b=array([sum(del_V),sum(x1*del_V),sum((x1**2)*del_V)])\n",
- "\n",
- "soln=linalg.solve(a,b);\n",
- "\n",
- "a0=soln[0]\n",
- "a1=soln[1]\n",
- "a2=soln[2]\n",
- "#del_V = V_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)\n",
- "#V_mix = (a0 + a1*x1 + a2*x1**(2))*(x1*(1 - x1))\n",
- "# For x1 = 0.5\n",
- "x1 = 0.5;\n",
- "V_mix_prime = (a0+(a1*x1)+(a2*x1**2))*(x1*(1-x1));\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "#Now differentiating the above equation with respect to x we get\n",
- "#d/dx(V_mix) = (-4*a2*x1**3) + (3*(a2-a1)*x1**2) + (2*(a1-a0)*x1)+ a0\n",
- "#Again for x1 = 0.5\n",
- "x1_prime = 0.5;\n",
- "del_V_mix_prime = (-4*a2*x1_prime**3)+(3*(a2-a1)*x1_prime**2)+(2*(a1-a0)*x1_prime)+a0;\n",
- "\n",
- "#Finally,calculating the partial molar volumes\n",
- "V1_bar = V1 + V_mix_prime + x_water*del_V_mix_prime;\t\t\t#[cm**(3)/mol] \n",
- "V2_bar = V2 + V_mix_prime - x_methanol*del_V_mix_prime;\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "# Results\n",
- "print \"The partial molar volume of methanol component 1) is %f cm**3)/mol\"%(V1_bar);\n",
- "print \"The partial molar volume of water component 2) is %f cm**3)/mol\"%(V2_bar);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The partial molar volume of methanol component 1) is 39.721188 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 17.079639 cm**3)/mol\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 12.2 Page Number : 421"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "#component 1 = water\n",
- "#component 2 = methanol\n",
- "T = 25 + 273.15;\t\t\t#[K] - Temperature\n",
- "\n",
- "#delta_V_mix = x_1*x_2*(-3.377 - 2.945*x_1 + 3.31*x_1**(2))\n",
- "V1 = 18.0684;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 1\n",
- "V2 = 40.7221;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2\n",
- "Vol_1 = 1000;\t\t\t#[cm**(3)] - Volume of pure component 1\n",
- "Vol_2 = 1000;\t\t\t#[cm**(3)] - Volume of pure component 2\n",
- "\n",
- "# Calculations\n",
- "#Moles of the componenets can be calculated as \n",
- "n_1 = round(Vol_1/V1,4);\t\t\t#[mol]\n",
- "n_2 = round(Vol_2/V2,4);\t\t\t#[mol]\n",
- "\n",
- "#Mole fraction of the components \n",
- "x_1 = round(n_1/(n_1 + n_2),4);\n",
- "x_2 = round(n_2/(n_1 + n_2),4);\n",
- "\n",
- "delta_V_mix = round(x_1*x_2*(-3.377 - 2.945*x_1 + 3.31*x_1**(2)),4);\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "#Differentiating the above equation, we get\n",
- "#d/dx(delta_V_mix) = (1 - 2*x_1)*(-3.377 - 2.945*x_1 + 3.31*x_1**(2)) + (x_1 - x_1**(2))*(-2.945 + 6.62*x_1)\n",
- "del_delta_V_mix = round((1 - 2*x_1)*(-3.377 - 2.945*x_1 + 3.31*x_1**(2)) + (x_1 - x_1**(2))*(-2.945 + 6.62*x_1),4);\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "#Now calculating the partial molar volumes\n",
- "V1_bar = V1 + delta_V_mix + x_2*del_delta_V_mix;\t\t\t#[cm**(3)/mol] \n",
- "V2_bar = V2 + delta_V_mix - x_1*del_delta_V_mix;\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "print del_delta_V_mix, V1_bar, V2_bar\n",
- "#Finally molar volume of the solution is given by\n",
- "V_sol = x_1*V1_bar + x_2*V2_bar;\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "# Total volume of the solution is given by\n",
- "V_total = (n_1 + n_2)*V_sol;\t\t\t#[cm**(3)]\n",
- "\n",
- "# Results\n",
- "print \"The molar volume of the solution is %.4f cm**3)/mol\"%(V_sol);\n",
- "print \"The total volume of the solution is %.2f cm**3)\"%(V_total);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1.8248 17.81416104 38.64306104\n",
- "The molar volume of the solution is 24.2149 cm**3)/mol\n",
- "The total volume of the solution is 1934.82 cm**3)\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 12.3 Page Number : 422"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- " \n",
- "\n",
- "Vol = 20;\t\t\t#[cm**(3)] - Volume of the solution\n",
- "T = 22 + 273.15;\t\t\t#[K] - Temperature\n",
- "W_bottle = 11.5485;\t\t\t#[g] - Weight of density bottle\n",
- "Mol_meth = 32.04;\t\t\t#Molecular weight of methanol\n",
- "Mol_water = 18.015;\t\t\t# Molecular weight of water\n",
- "\n",
- "#Density of pure components can be found out at 0% and 100% of volume percent.\n",
- "den_meth = 0.7929;\t\t\t#[cm**(3)/mol] - Density of pure methanol\n",
- "den_water = 0.9937;\t\t\t#[cm**(3)/mol] - Density of pure water\n",
- "\n",
- "\n",
- "Vol_perc=[5,10,20,30,40,50,60,70,80,90,95];\t\t\t# Volumes percent of component 1 (methanol)\n",
- "W_total=[31.2706,31.1468,30.8907,30.6346,30.3396,30.0053,29.5865,29.1453,28.5978,28.0325,27.7320];\t\t\t# Weight of solution + weight of density bottle\n",
- "\n",
- "W_sol=zeros(11);\t\t\t# Weight of 20 cm**(3) of solution\n",
- "den=zeros(11);\t\t\t# density of the solution\n",
- "x1=zeros(11);\t\t\t# Mole fraction of methanol\n",
- "x2=zeros(11);\t\t\t# Mole fraction of water\n",
- "\n",
- "# Calculations\n",
- "for i in range(11):\n",
- " W_sol[i]=W_total[i]-W_bottle;\n",
- " den[i]=W_sol[i]/Vol;\n",
- " x1[i]=((Vol_perc[i]*den_meth)/Mol_meth)/(((Vol_perc[i]*den_meth)/Mol_meth)+(((100-Vol_perc[i])*den_water)/Mol_water));\n",
- " x2[i]=1-x1[i];\n",
- "\n",
- "\n",
- "#Again we have,\n",
- "V_kg=zeros(11);\t\t\t#[cm**(3)] - Volume of 1 kg of solution\n",
- "n_mol=zeros(11);\t\t\t#[mol] - Number of moles in 1 kg of solution\n",
- "V_mol=zeros(11);\t\t\t#[cm**(3)/mol] - Volume of 1 mol of solution\n",
- "x_V=zeros(11);\t\t\t#[cm**(3)/mol] - x_V = x1*V_meth + x2*V_water\n",
- "V_mix=zeros(11);\t\t\t#[cm**(3)/mol] - V_mix = V_mol - x1*V_meth - x2*V_water\n",
- "del_V=zeros(11);\t\t\t# [cm**(3)/mol] - del_V = V_mix/(x1*x2)\n",
- "\n",
- "#V_mol = V_meth at x1 = 1 and V_mol = V_water at x1 = 0, therefore\n",
- "V_meth = 40.4114;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 1 (methanol)\n",
- "V_water = 18.1286;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2 (water)\n",
- "\n",
- "for i in range(11):\n",
- " V_kg[i]=1000/den[i];\n",
- " n_mol[i]=1000/(x1[i]*Mol_meth+x2[i]*Mol_water);\n",
- " V_mol[i]=V_kg[i]/n_mol[i];\n",
- " x_V[i]=V_meth*x1[i]+V_water*x2[i];\n",
- " V_mix[i]=V_mol[i]-x1[i]*V_meth-x2[i]*V_water;\n",
- " del_V[i]=V_mix[i]/(x1[i]*x2[i]);\n",
- "\n",
- "#Now employing the concept of quadratic regression of the data ( x1 , del_V ) to solve the equation of the type\n",
- "#y = a0 + a1*x + a2*x**(2) \n",
- "#Here the above equation is in the form of\n",
- "#del_V = V_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2) \n",
- "\n",
- "#From the matrix method to solve simultaneous linear equations, we have\n",
- "a = array([[11, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2), sum(x1**3)],[sum(x1**2), sum(x1**3), sum(x1**4)]])\n",
- "b = array([sum(del_V),sum(x1*del_V),sum((x1**2)*del_V)])\n",
- "\n",
- "soln=linalg.solve(a,b);\n",
- "a0=soln[0]\n",
- "a1=soln[1]\n",
- "a2=soln[2]\n",
- "\n",
- "#del_V = V_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)\n",
- "#V_mix = (a0 + a1*x1 + a2*x1**(2))*(x1*(1 - x1))\n",
- "#Solving the above equation for x1,\n",
- "def f(x1): \n",
- " return (a0+(a1*x1)+(a2*x1**2))*(x1*(1-x1))\n",
- "\n",
- "#Now differentiating the above equation with respect to x we get\n",
- "#d/dx(V_mix) = (-4*a2*x1**3) + (3*(a2-a1)*x1**2) + (2*(a1-a0)*x1)+ a0\n",
- "#Again solving it for x1\n",
- "def f1(x1): \n",
- " return (-4*a2*x1**3)+(3*(a2-a1)*x1**2)+(2*(a1-a0)*x1)+a0\n",
- "\n",
- "#Now \n",
- "\n",
- "x1_prime=[0,0.25,0.50,0.75,1.0];\n",
- "V_mix_prime=zeros(5);\t\t\t#[cm**(3)/mol] - V_mix = V - x1*V_meth - x2*V_water\n",
- "del_V_prime=zeros(5);\t\t\t#[cm**(3)/mol] - del_V = V_mix/(x1*x2)\n",
- "V1_bar=zeros(5);\t\t\t#[cm**(3)/mol] - Partial molar volume of component 1\n",
- "V2_bar=zeros(5);\t\t\t#[cm**(3)/mol] - Partial molar volume of component 1\n",
- "\n",
- "# Results\n",
- "for j in range(5):\n",
- " V_mix_prime[j]=f(x1_prime[j]);\n",
- " del_V_prime[j]=f1(x1_prime[j]);\n",
- " V1_bar[j]=V_meth+V_mix_prime[j]+(1-x1_prime[j])*del_V_prime[j];\n",
- " V2_bar[j]=V_water+V_mix_prime[j]-x1_prime[j]*del_V_prime[j];\n",
- " print \"For x1 = %f\"%(x1_prime[j]);\n",
- " print \"The partial molar volume of methanol component 1) is %f cm**3)/mol\"%(V1_bar[j])\n",
- " print \"The partial molar volume of water component 2) is %f cm**3)/mol\"%(V2_bar[j])\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "For x1 = 0.000000\n",
- "The partial molar volume of methanol component 1) is 37.937941 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 18.128600 cm**3)/mol\n",
- "For x1 = 0.250000\n",
- "The partial molar volume of methanol component 1) is 38.124350 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 18.031910 cm**3)/mol\n",
- "For x1 = 0.500000\n",
- "The partial molar volume of methanol component 1) is 39.496329 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 17.177237 cm**3)/mol\n",
- "For x1 = 0.750000\n",
- "The partial molar volume of methanol component 1) is 40.332855 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 15.841550 cm**3)/mol\n",
- "For x1 = 1.000000\n",
- "The partial molar volume of methanol component 1) is 40.411400 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 15.800306 cm**3)/mol\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 12.4 Page Number : 424"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from numpy import *\n",
- "\n",
- "\n",
- "# Variables\n",
- "T = 20 + 273.15;\t\t\t#[K] - Temperature\n",
- "Mol_form = 46.027;\t\t\t#Molecular weight of formic acid\n",
- "Mol_water = 18.015;\t\t\t# Molecular weight of water\n",
- "\n",
- "Wt_perc=[10,18,30,50,72,78];\t\t\t#Weight percent of formic acid\n",
- "den=[1.0246,1.0441,1.0729,1.1207,1.1702,1.1818];\t\t\t#[g/cm**(3)] - Density of solution\n",
- "\n",
- "V_g=zeros(6);\t\t\t#[cm**(3)/g] - Volume of 1 g of solution\n",
- "x1=zeros(6);\t\t\t# Mole fraction of component 1\n",
- "x2=zeros(6);\t\t\t# Mole fraction of component 2\n",
- "n=zeros(6);\t\t\t# Number of moles in 1 g\n",
- "V_mol=zeros(6);\t\t\t#[cm**(3)/mol] - Volume of 1 mol of solution\n",
- "x_V=zeros(6);\t\t\t#[cm**(3)/mol] - x_V = x1*V_form + x2*V_water\n",
- "V_mix=zeros(6);\t\t\t#[cm**(3)/mol] - V_mix = V - x1*V_form - x2*V_water\n",
- "del_V=zeros(6);\t\t\t# [cm**(3)/mol] - del_V = V_mix/(x1*x2)\n",
- "\n",
- "#V_mol = V_form at x1 = 1 and V_mol = V_water at x1 = 0, therefore\n",
- "V_form = 37.737;\t\t\t#[cm**(3)/mol] - Molar volume of pure formic acid (component 1)\n",
- "V_water = 18.050;\t\t\t#[cm**(3)/mol] - Molar volume of pure water (component 2)\n",
- "\n",
- "# Calculations\n",
- "for i in range(6):\n",
- " V_g[i]=1/den[i];\n",
- " x1[i]=(Wt_perc[i]/Mol_form)/((Wt_perc[i]/Mol_form)+((100-Wt_perc[i])/Mol_water));\n",
- " x2[i]=1-x1[i];\n",
- " n[i]=((Wt_perc[i]/100.)/Mol_form)+(((100-Wt_perc[i])/100.)/Mol_water);\n",
- " V_mol[i]=V_g[i]/n[i];\n",
- " x_V[i]=V_form*x1[i]+V_water*x2[i];\n",
- " V_mix[i]=V_mol[i]-x1[i]*V_form-x2[i]*V_water;\n",
- " del_V[i]=V_mix[i]/(x1[i]*x2[i]);\n",
- "\n",
- "\n",
- "a = array([[11, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2) ,sum(x1**3)],[sum(x1**2), sum(x1**3) ,sum(x1**4)]])\n",
- "b = array([sum(del_V),sum(x1*del_V),sum((x1**2)*del_V)])\n",
- "\n",
- "soln = linalg.solve(a,b)\n",
- "\n",
- "a0=soln[0]\n",
- "a1=soln[1]\n",
- "a2=soln[2]\n",
- "\n",
- "def f(x1): \n",
- "\t return (a0+(a1*x1)+(a2*x1**2))*(x1*(1-x1))\n",
- "\n",
- "def f1(x1): \n",
- "\t return (-4*a2*x1**3)+(3*(a2-a1)*x1**2)+(2*(a1-a0)*x1)+a0\n",
- "\n",
- "#At 15 Wt% of formic acid, x1 is given by\n",
- "x1_prime_1 = round((15/Mol_form)/((15/Mol_form)+((100-15)/Mol_water)),3); \n",
- "#Similarly at 75 Wt% of formic acid, x1 is given by\n",
- "x1_prime_2 = round((75/Mol_form)/((75/Mol_form)+((100-75)/Mol_water)),4); \n",
- "\n",
- "Wt_perc_prime=[15,75];\n",
- "x1_prime=[x1_prime_1,x1_prime_2];\n",
- "V_mix_prime=zeros(2);\t\t\t#[cm**(3)/mol] - V_mix = V - x1*V_meth - x2*V_water\n",
- "del_V_prime=zeros(2);\t\t\t#[cm**(3)/mol] - del_V = V_mix/(x1*x2)\n",
- "V1_bar=zeros(2);\t\t\t#[cm**(3)/mol] - Partial molar volume of component 1\n",
- "V2_bar=zeros(2);\t\t\t#[cm**(3)/mol] - Partial molar volume of component 1\n",
- "\n",
- "# Results\n",
- "for j in range(2):\n",
- " V_mix_prime[j]=f(x1_prime[j]);\n",
- " del_V_prime[j]=f1(x1_prime[j]);\n",
- " V1_bar[j]=V_form+V_mix_prime[j]+(1-x1_prime[j])*del_V_prime[j];\n",
- " V2_bar[j]=V_water+V_mix_prime[j]-x1_prime[j]*del_V_prime[j];\n",
- " print \"For weight percent of formic acid = %f percent\"%(Wt_perc_prime[j]);\n",
- " print \"The partial molar volume of formic acid component 1) is %f cm**3)/mol\"%(V1_bar[j]);\n",
- " print \"The partial molar volume of water component 2) is %f cm**3)/mol\"%(V2_bar[j]);\n",
- "\n",
- "# answers are vary because of rounding error. Please review it manually. "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "For weight percent of formic acid = 15.000000 percent\n",
- "The partial molar volume of formic acid component 1) is 35.429311 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 18.102339 cm**3)/mol\n",
- "For weight percent of formic acid = 75.000000 percent\n",
- "The partial molar volume of formic acid component 1) is 38.853189 cm**3)/mol\n",
- "The partial molar volume of water component 2) is 15.646974 cm**3)/mol\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 12.5 Page Number : 426"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 40 + 273.15;\t\t\t#[K] - Temperature\n",
- "\n",
- "x1=array([0.083,0.176,0.268,0.353,0.428,0.720,0.780,0.850,0.900]) \t\t\t# Mole fraction of component 1\n",
- "delta_H_mix=array([0.250,0.488,0.670,0.790,0.863,0.775,0.669,0.510,0.362])\t\t\t#[kJ/mol] - Enthalpy of the solution\n",
- "\n",
- "x2=zeros(9);\t\t\t# Mole fraction of component 2\n",
- "del_H=zeros(9);\t\t\t#[kJ/mol] - del_H = delta_H_mix/(x1*x2)\n",
- "\n",
- "for i in range(9):\n",
- " x2[i]=1-x1[i];\n",
- " del_H[i]=delta_H_mix[i]/(x1[i]*x2[i]);\n",
- "\n",
- "\n",
- "# Calculations\n",
- "#Now employing the concept of quadratic regression of the data ( x1 , del_H ) to solve the equation of the type\n",
- "#y = a0 + a1*x + a2*x**(2) \n",
- "#Here the above equation is in the form of\n",
- "#del_H = delta_H_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2) \n",
- "\n",
- "#From the matrix method to solve simultaneous linear equations, we have\n",
- "a = array([[9, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2), sum(x1**3)],[sum(x1**2), sum(x1**3), sum(x1**4)]])\n",
- "b = array([sum(del_H),sum(x1*del_H),sum((x1**2)*del_H)])\n",
- "soln= linalg.solve(a,b)\n",
- "a0=soln[0]\n",
- "a1=soln[1]\n",
- "a2=soln[2]\n",
- "\n",
- "#del_H = delta_H_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)\n",
- "#delta_H_mix = (a0 + a1*x1 + a2*x1**(2))*(x1*(1 - x1))\n",
- "#At x1 = 0.25,\n",
- "x_1 = 0.25;\t\t\t#[mol]\n",
- "delta_H_mix = (a0+(a1*x_1)+(a2*x_1**2))*(x_1*(1-x_1));\t\t\t#[kJ/mol]\n",
- "\n",
- "#Now differentiating the above equation with respect to x we get\n",
- "#d/dx(delta_H_mix) = del_delta_H_mix = (-4*a2*x1**3) + (3*(a2-a1)*x1**2) + (2*(a1-a0)*x1)+ a0\n",
- "#Again for x1 = 0.25\n",
- "x_1_prime = 0.25;\t\t\t#[mol]\n",
- "del_delta_H_mix = (-4*a2*x_1_prime**3)+(3*(a2-a1)*x_1_prime**2)+(2*(a1-a0)*x_1_prime)+a0;\t\t\t#[kJ/mol]\n",
- "\n",
- "#We have the relation\n",
- "# H1_bar - H1 = delta_H_mix + x2*del_delta_H_mix, and\n",
- "# H2_bar - H2 = delta_H_mix - x1*del_delta_H_mix\n",
- "\n",
- "#Let us suppose\n",
- "#k_1 = H1_bar - H1 , and\n",
- "#k_2 = H2_bar - H2\n",
- "\n",
- "k_1 = delta_H_mix + (1-x_1_prime)*del_delta_H_mix;\t\t\t#[kJ/mol]\n",
- "k_2 = delta_H_mix - x_1_prime*del_delta_H_mix;\t\t\t#[kJ/mol]\n",
- "\n",
- "# Results\n",
- "print \"The value of H1_bar - H1) at x1 = 0.25 is %f kJ/mol\"%(k_1);\n",
- "print \"The value of H2_bar - H2) at x1 = 0.25 is %f kJ/mol\"%(k_2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of H1_bar - H1) at x1 = 0.25 is 2.010734 kJ/mol\n",
- "The value of H2_bar - H2) at x1 = 0.25 is 0.179079 kJ/mol\n"
- ]
- }
- ],
- "prompt_number": 5
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch13_1.ipynb b/Chemical_Engineering_Thermodynamics/ch13_1.ipynb
deleted file mode 100755
index 3cee342e..00000000
--- a/Chemical_Engineering_Thermodynamics/ch13_1.ipynb
+++ /dev/null
@@ -1,312 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:894f18dec91baf4a10867e0d301a68220274d02a1e24c4e2bef1038061daa009"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "\n",
- "Chapter 13 : Fugacity of a Component in a Mixture by Equations of State"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 13.2 Page Number : 433"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "\n",
- "\n",
- "# Variables\n",
- "T = 310.93;\t\t\t#[K] - Temperature\n",
- "P = 2.76*10**(6);\t\t\t#[Pa] - Pressure\n",
- "y1 = 0.8942;\t\t\t#[mol] - mole fraction of component 1\n",
- "y2 = 1 - y1;\t\t\t#[mol] - mole fraction of component 2\n",
- "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "#For component 1 (methane)\n",
- "Tc_1 = 190.6;\t\t\t#[K] - Critical temperature\n",
- "Pc_1 = 45.99*10**(5);\t\t\t#[N/m**(2)] - Critical pressure\n",
- "Vc_1 = 98.6;\t\t\t#[cm**(3)/mol] - Critical molar volume\n",
- "Zc_1 = 0.286;\t\t\t# - Critical compressibility factor\n",
- "w_1 = 0.012;\t\t\t# - Critical acentric factor\n",
- "#Similarly for component 2 (n-Butane)\n",
- "Tc_2 = 425.1;\t\t\t#[K]\n",
- "Pc_2 = 37.96*10**(5);\t\t\t#[N/m**(2)]\n",
- "Vc_2 = 255;\t\t\t#[cm**(3)/mol]\n",
- "Zc_2=0.274;\n",
- "w_2=0.2;\n",
- "\n",
- "# Calculations\n",
- "#For component 1\n",
- "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n",
- "#At reduced temperature\n",
- "B1_0 = 0.083-(0.422/(Tr_1)**(1.6));\n",
- "B1_1 = 0.139-(0.172/(Tr_1)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#Similarly for component 2\n",
- "Tr_2 = T/Tc_2;\t\t\t#Reduced temperature\n",
- "#At reduced temperature Tr_2,\n",
- "B2_0 = 0.083-(0.422/(Tr_2)**(1.6));\n",
- "B2_1 = 0.139-(0.172/(Tr_2)**(4.2));\n",
- "B_22 = ((B2_0+(w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#For cross coeffcient\n",
- "Tc_12 = (Tc_1*Tc_2)**(1./2);\t\t\t#[K]\n",
- "w_12 = (w_1+w_2)/2;\n",
- "Zc_12 = (Zc_1+Zc_2)/2;\n",
- "Vc_12 = (((Vc_1)**(1./3)+(Vc_2)**(1./3))/2)**(3);\t\t\t#[cm**(3)/mol]\n",
- "Vc_12 = Vc_12*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "\n",
- "# Variables, Z = 1 + (B*P)/(R*T)\n",
- "#Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n",
- "#where B_0 and B_1 are to be evaluated at Tr_12\n",
- "Tr_12 = T/Tc_12;\n",
- "#At reduced temperature Tr_12\n",
- "B_0 = 0.083-(0.422/(Tr_12)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr_12)**(4.2));\n",
- "B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "#For the mixture\n",
- "B = y1**(2)*B_11+2*y1*y2*B_12+y2**(2)*B_22;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#Now del_12 can be calculated as,\n",
- "del_12 = 2*B_12 - B_11 - B_22;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#We have the relation, math.log(phi_1) = (P/(R*T))*(B_11 + y2**(2)*del_12), therefore\n",
- "phi_1 = math.exp((P/(R*T))*(B_11 + y2**(2)*del_12));\n",
- "#Similarly for component 2\n",
- "phi_2 = math.exp((P/(R*T))*(B_22 + y1**(2)*del_12));\n",
- "\n",
- "# Results\n",
- "print \" The value of fugacity coefficient of component 1 phi_1) is %f\"%(phi_1);\n",
- "print \" The value of fugacity coefficient of component 2 phi_2) is %f\"%(phi_2);\n",
- "\n",
- "#Finally fugacity coefficient of the mixture is given by\n",
- "#math.log(phi) = y1*math.log(phi_1) + y2*math.log(phi_2);\n",
- "phi = math.exp(y1*math.log(phi_1) + y2*math.log(phi_2));\n",
- "\n",
- "print \" The value of fugacity coefficient of the mixture phi) is %f \"%(phi);\n",
- "#The fugacity coefficient of the mixture can also be obtained using\n",
- "#math.log(phi) = (B*P)/(R*T)\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of fugacity coefficient of component 1 phi_1) is 0.965152\n",
- " The value of fugacity coefficient of component 2 phi_2) is 0.675374\n",
- " The value of fugacity coefficient of the mixture phi) is 0.929376 \n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 13.7 Page Number : 447"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "# Variables\n",
- "T = 460.;\t\t\t#[K] - Temperature\n",
- "P = 40.*10**(5);\t\t\t#[Pa] - Pressure\n",
- "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "# component 1 = nitrogen\n",
- "# component 2 = n-Butane\n",
- "y1 = 0.4974;\t\t\t# Mole percent of nitrogen\n",
- "y2 = 0.5026;\t\t\t# Mole percent of n-Butane\n",
- "Tc_nit = 126.2;\t\t\t#[K]\n",
- "Pc_nit = 34.00*10**(5);\t\t\t#[Pa]\n",
- "Tc_but = 425.1;\t\t\t#[K]\n",
- "Pc_but = 37.96*10**(5);\t\t\t#[Pa]\n",
- "\n",
- "# (1). van der Walls equation of state\n",
- "\n",
- "# The fugacity coefficient of component 1 in a binary mixture following van der Walls equation of state is given by,\n",
- "# math.log(phi_1) = b_1/(V-b) - math.log(Z-B) -2*(y1*a_11 + y2*a_12)/(R*T*V)\n",
- "# and for component 2 is given by,\n",
- "# math.log(phi_2) = b_2/(V-b) - math.log(Z-B) -2*(y1*a_12 + y2*a_22)/(R*T*V)\n",
- "# Where B = (P*b)/(R*T)\n",
- "\n",
- "# Calculations\n",
- "# For componenet 1 (nitrogen)\n",
- "a_1 = (27*R**(2)*Tc_nit**(2))/(64*Pc_nit);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_1 = (R*Tc_nit)/(8*Pc_nit);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Similarly for componenet 2 (n-Butane)\n",
- "a_2 = (27*R**(2)*Tc_but**(2))/(64*Pc_but);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_2 = (R*Tc_but)/(8*Pc_but);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Here\n",
- "a_11 = a_1;\n",
- "a_22 = a_2;\n",
- "# For cross coefficient\n",
- "a_12 = (a_1*a_2)**(1./2);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "\n",
- "# For the mixture \n",
- "a = y1**(2)*a_11 + y2**(2)*a_22 + 2*y1*y2*a_12;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = y1*b_1 + y2*b_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The cubic form of the van der Walls equation of state is given by,\n",
- "# V**(3) - (b+(R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "# Substituting the value and solving for V, we get\n",
- "# Solving the cubic equation\n",
- "def f(V): \n",
- " return V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P\n",
- "V_1=fsolve(f,-1)\n",
- "V_2=fsolve(f,0)\n",
- "V_3=fsolve(f,1)\n",
- "# The molar volume V = V_3, the other two roots are imaginary\n",
- "V = V_3;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The comprssibility factor of the mixture is \n",
- "Z = (P*V)/(R*T);\n",
- "# And B can also be calculated as\n",
- "B = (P*b)/(R*T);\n",
- "\n",
- "# The fugacity coefficient of component 1 in the mixture is\n",
- "phi_1 = math.exp(b_1/(V-b) - math.log(Z-B) -2*(y1*a_11 + y2*a_12)/(R*T*V));\n",
- "# Similarly fugacity coefficient of component 2 in the mixture is \n",
- "phi_2 = math.exp(b_2/(V-b) - math.log(Z-B) -2*(y1*a_12 + y2*a_22)/(R*T*V));\n",
- "\n",
- "# The fugacity coefficient of the mixture is given by,\n",
- "# math.log(phi) = y1*math.log(phi_1) + y2*math.log(phi_2)\n",
- "phi = math.exp(y1*math.log(phi_1) + y2*math.log(phi_2));\n",
- "\n",
- "# Also the fugacity coefficient of the mixture following van der Walls equation of state is given by,\n",
- "# math.log(phi) = b/(V-b) - math.log(Z-B) -2*a/(R*T*V)\n",
- "phi_dash = math.exp(b/(V-b) - math.log(Z-B) -2*a/(R*T*V));\n",
- "# The result is same as obtained above\n",
- "\n",
- "# Results\n",
- "print \" 1van der Walls equation of state\";\n",
- "print \" The value of fugacity coefficient of component 1 nitrogen) is %f\"%(phi_1);\n",
- "print \" The value of fugacity coefficient of component 2 n-butane) is %f\"%(phi_2);\n",
- "print \" The value of fugacity coefficient of the mixture is %f\"%(phi);\n",
- "print \" Also the fugacity coefficient of the mixture from van der Walls equation of state is %f which is same as above)\"%(phi_dash);\n",
- "\n",
- "# (2). Redlich-Kwong equation of state\n",
- "\n",
- "# For component 1,\n",
- "a_1_prime = (0.42748*R**(2)*Tc_nit**(2.5))/Pc_nit;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_1_prime = (0.08664*R*Tc_nit)/Pc_nit;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#similarly for component 2,\n",
- "a_2_prime = (0.42748*R**(2)*Tc_but**(2.5))/Pc_but;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_2_prime = (0.08664*R*Tc_but)/Pc_but;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# For cross coefficient\n",
- "a_12_prime = (a_1_prime*a_2_prime)**(1./2);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "# For the mixture\n",
- "a_prime = y1**(2)*a_1_prime + y2**(2)*a_2_prime +2*y1*y2*a_12_prime;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_prime = y1*b_1_prime +y2*b_2_prime;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\n",
- "#The cubic form of Redlich Kwong equation of state is given by,\n",
- "# V**(3)-((R*T)/P)*V**(2)-((b**(2))+((b*R*T)/P)-(a/(T**(1/2)*P))*V-(a*b)/(T**(1/2)*P)=0\n",
- "# Solving the cubic equation\n",
- "def f1(V): \n",
- " return V**(3)-((R*T)/P)*V**(2)-((b_prime**(2))+((b_prime*R*T)/P)-(a_prime/(T**(1./2)*P)))*V-(a_prime*b_prime)/(T**(1./2)*P)\n",
- "V_4=fsolve(f1,1)\n",
- "V_5=fsolve(f1,0)\n",
- "V_6=fsolve(f1,-1)\n",
- "# The molar volume V = V_4, the other two roots are imaginary\n",
- "V_prime = V_4;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The compressibility factor of the mixture is\n",
- "Z_prime = (P*V_prime)/(R*T);\n",
- "# And B can also be calculated as\n",
- "B_prime = (P*b_prime)/(R*T);\n",
- "\n",
- "# The fugacity coefficient of component 1 in the binary mixture is given by\n",
- "# math.log(phi_1) = b_1/(V-b) - math.log(Z-B) + ((a*b_1)/((b**(2)*R*T**(3/2))))*(math.log((V+b)/V)-(b/(V+b)))-(2*(y1*a_1+y2*a_12)/(R*T**(3/2)b))*(math.log(V+b)/b)\n",
- "\n",
- "phi_1_prime = math.exp((b_1_prime/(V_prime-b_prime))-math.log(Z_prime-B_prime)+((a_prime*b_1_prime)/((b_prime**(2))*R*(T**(3./2))))*(math.log((V_prime+b_prime)/V_prime)-(b_prime/(V_prime+b_prime)))-(2*(y1*a_1_prime+y2*a_12_prime)/(R*(T**(3./2))*b_prime))*(math.log((V_prime+b_prime)/V_prime)));\n",
- "\n",
- "\n",
- "# Similarly fugacity coefficient of component 2 in the mixture is \n",
- "phi_2_prime = math.exp((b_2_prime/(V_prime-b_prime))-math.log(Z_prime-B_prime)+((a_prime*b_2_prime)/((b_prime**(2))*R*(T**(3./2))))*(math.log((V_prime+b_prime)/V_prime)-(b_prime/(V_prime+b_prime)))-(2*(y1*a_12_prime+y2*a_2_prime)/(R*(T**(3./2))*b_prime))*(math.log((V_prime+b_prime)/V_prime)));\n",
- "\n",
- "# The fugacity coefficient of the mixture is given by,\n",
- "# math.log(phi) = y1*math.log(phi_1) + y2*math.log(phi_2)\n",
- "phi_prime = math.exp(y1*math.log(phi_1_prime) + y2*math.log(phi_2_prime));\n",
- "\n",
- "# Also the fugacity coefficient for the mixture following Redlich-kwong equation of state is also given by\n",
- "# math.log(phi) = b/(V-b) - math.log(Z-B) - (a/(R*T**(3/2)))*(1/(V+b)+(1/b)*math.log((V+b)/V))\n",
- "phi_prime_dash = math.exp(b_prime/(V_prime-b_prime) - math.log(Z_prime-B_prime) - (a_prime/(R*T**(3./2)))*(1/(V_prime+b_prime)+(1./b_prime)*math.log((V_prime+b_prime)/ V_prime)));\n",
- "\n",
- "print \" \\nRedlich-Kwong equation of state\";\n",
- "print \" The value of fugacity coefficient of component 1 nitrogen) is %f\"%(phi_1_prime);\n",
- "print \" The value of fugacity coefficient of component 2 n-butane) is %f\"%(phi_2_prime);\n",
- "print \" The value of fugacity coefficient of the mixture is %f\"%(phi_prime);\n",
- "print \" Also the fugacity coefficient for the mixture from Redlich-kwong equation of state is %f which is same as above)\"%(phi_prime_dash);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1van der Walls equation of state\n",
- " The value of fugacity coefficient of component 1 nitrogen) is 1.057500\n",
- " The value of fugacity coefficient of component 2 n-butane) is 0.801865\n",
- " The value of fugacity coefficient of the mixture is 0.920192\n",
- " Also the fugacity coefficient of the mixture from van der Walls equation of state is 0.920192 which is same as above)\n",
- " \n",
- "Redlich-Kwong equation of state\n",
- " The value of fugacity coefficient of component 1 nitrogen) is 1.071129\n",
- " The value of fugacity coefficient of component 2 n-butane) is 0.793063\n",
- " The value of fugacity coefficient of the mixture is 0.920948\n",
- " Also the fugacity coefficient for the mixture from Redlich-kwong equation of state is 0.920948 which is same as above)\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch14_1.ipynb b/Chemical_Engineering_Thermodynamics/ch14_1.ipynb
deleted file mode 100755
index be081f3c..00000000
--- a/Chemical_Engineering_Thermodynamics/ch14_1.ipynb
+++ /dev/null
@@ -1,723 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:98f2e1e0f1c561d3ee302fd629093b7572c8b263613f73036059e7020f90d8cc"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 14 : Activity Coefficients Models for Liquid Mixtures"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.4 Page Number : 461"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables,\n",
- "T = 300;\t\t\t#[K] - Temperature\n",
- "b = 100;\t\t\t#[cal/mol]\n",
- "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
- "# R*T*math.log(Y_1) = b*x_2**(2)\n",
- "# R*T*math.log(Y_2) = b*x_1**(2)\n",
- "\n",
- "#For equimolar mixture\n",
- "x_1 = 0.5;\t\t\t#Mole fraction of component 1\n",
- "x_2 = 0.5;\t\t\t#Mole fraction of component 2\n",
- "\n",
- "# Calculations and Results\n",
- "#The excess Gibbs free energy is given by\n",
- "# G_excess = R*T*(x_1*math.log(Y_1) + x_2*math.log(Y_2)) = b*x_1*x_2**(2) + b*x_2*x_1**(2) = b*x_1*(x_1 + x_2) = b*x_1*x_2\n",
- "G_excess = b*x_1*x_2;\t\t\t#[cal/mol]\n",
- "\n",
- "#The ideal Gibbs free energy change of mixing is given by,\n",
- "delta_G_id_mix = R*T*(x_1*math.log(x_1)+x_2*math.log(x_2));\t\t\t#[cal/mol]\n",
- "\n",
- "#The Gibbs free energy of mixing is given by\n",
- "delta_G_mix = delta_G_id_mix + G_excess;\t\t\t#[cal/mol]\n",
- "\n",
- "#It is given that entropy change of mixing is that of ideal mixture,therefore\n",
- "# delta_S_mix = delta_S_id_mix = - R*sum(x_i*math.log(x_i))\n",
- "\n",
- "#delta_G_mix = delta_H_mix - T*delta_S_mix = delta_H_mix + R*T*(x_1*math.log(x_1)+x_2*math.log(x_2))\n",
- "delta_H_mix = b*x_1*x_2;\t\t\t#[cal/mol]\n",
- "\n",
- "print \"The value of Gibbs free energy change for equimolar mixture formation is %f cal/mol\"%(delta_G_mix);\n",
- "print \"The value of enthalpy change for equimolar mixture formation is %f cal/mol\"%(delta_H_mix);\n",
- "\n",
- "#Work required for separation of mixture into pure components is\n",
- "W = delta_G_mix;\n",
- "print \"The least amount of work required for separation at 300 K is %f cal/mol\"%(W);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of Gibbs free energy change for equimolar mixture formation is -388.185034 cal/mol\n",
- "The value of enthalpy change for equimolar mixture formation is 25.000000 cal/mol\n",
- "The least amount of work required for separation at 300 K is -388.185034 cal/mol\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.10 Page Number : 466"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "from numpy import zeros\n",
- "from scipy.stats import linregress\n",
- "\n",
- "# Variables,\n",
- "T = 25 +173.15;\t\t\t#[K] - Temperature\n",
- "x_1=[0.0115,0.0160,0.0250,0.0300,0.0575,0.1125,0.1775,0.2330,0.4235,0.5760,0.6605,0.7390,0.8605,0.9250,0.9625];\n",
- "y_1=[8.0640,7.6260,7.2780,7.2370,5.9770,4.5434,3.4019,2.8023,1.7694,1.3780,1.2302,1.1372,1.0478,1.0145,1.0070];\n",
- "y_2=[1.0037,1.0099,1.0102,1.0047,1.0203,1.0399,1.1051,1.1695,1.4462,1.8520,2.2334,2.6886,3.7489,4.8960,5.6040];\n",
- "\n",
- "x_2 = zeros(15);\t\t\t# x_2 = (1 - x_1)\n",
- "G_RT = zeros(15);\t\t\t# G_RT = G_excess/(R*T)\n",
- "x1x2_G_RT = zeros(15);\t\t\t# x1x2_G_RT = (x_1*x_2/(G_excess/(R*T)))\n",
- "G_RTx1x2 = zeros(15);\t\t\t# G_RTx1x1 = G_excess/(R*T*x_1*x_2)\n",
- "\n",
- "# Calculations and Results\n",
- "for i in range(15):\n",
- " x_2[i]=(1-x_1[i]);\n",
- " G_RT[i]=(x_1[i]*math.log(y_1[i]))+(x_2[i]*math.log(y_2[i]));\n",
- " x1x2_G_RT[i]=(x_1[i]*x_2[i])/G_RT[i];\n",
- " G_RTx1x2[i]=1/x1x2_G_RT[i];\n",
- "\n",
- "\n",
- "slop,intr,sig,d,e=linregress(x_1,x1x2_G_RT);\n",
- "\n",
- "A = 1/intr;\n",
- "B = 1/(slop+(1/A));\n",
- "print \" The value of van Laar parameters are A = %f and B = %f\"%(A,B);\n",
- "\n",
- "# Now from Margules equation\n",
- "# G_RTx1x2 = G_excess/(R*T*x_1*x_2) = B1*x_1 + A1*x_1 = A1 + (B1 - A1)*x_1\n",
- "#slope = (B1 - A1) and intercept = A1\n",
- "\n",
- "# Again employing the concept of linear regression of the data ( x_1 , G_RTx1x2 ) to find the value of intercept and slope of the above equation\n",
- "#Let slope = slop1 and intercept = intr1\n",
- "\n",
- "slop1,intr1,sig1,d,e=linregress(x_1,G_RTx1x2);\n",
- "\n",
- "A1 = intr1;\n",
- "B1 = slop1 + A1;\n",
- "print \" The value of Margules parameters are A = %f and B = %f\"%(A1,B1);\n",
- "\n",
- "print \" Because of the higher value of correlation factor for Van Laar model it fits the data better.\"\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of van Laar parameters are A = 2.271326 and B = 1.781420\n",
- " The value of Margules parameters are A = 2.293274 and B = 1.746000\n",
- " Because of the higher value of correlation factor for Van Laar model it fits the data better.\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.11 Page Number : 470"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables,\n",
- "T = 60 + 273.15;\t\t\t#[K] - Temperature\n",
- "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
- "#component 1 = acetone\n",
- "#component 2 = water\n",
- "x_1 = 0.3;\t\t\t# Mole fraction of component 1\n",
- "x_2 = 1 - x_1;\t\t\t#Mole fraction of component 2\n",
- "V_mol_1 = 74.05;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 1\n",
- "V_mol_2 = 18.07;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2\n",
- "\n",
- "#for Wilson equation\n",
- "a_12 = 291.27;\t\t\t#[cal/mol]\n",
- "a_21 = 1448.01;\t\t\t#[cal/mol]\n",
- "\n",
- "#For NRTL\n",
- "b_12 = 631.05;\t\t\t#[cal/mol]\n",
- "b_21 = 1197.41;\t\t\t#[cal/mol]\n",
- "alpha = 0.5343;\n",
- "\n",
- "# Calculations and Results\n",
- "#Froom wilson equation\n",
- "A_12=(V_mol_2/V_mol_1)*(math.exp(-a_12/(R*T)));\n",
- "A_21 = (V_mol_1/V_mol_2)*(math.exp(-a_21/(R*T)));\n",
- "Beta = A_12/(x_1+x_2*A_12) - A_21/(x_2+x_1*A_21);\n",
- "#math.log(Y1) = -math.log(x_1 + x_2*A_12) + x_2*Beta; \n",
- "Y1 = math.exp(-math.log(x_1+x_2*A_12)+x_2*Beta);\n",
- "#similarly for Y2\n",
- "Y2 = math.exp(-math.log(x_2+x_1*A_21)-x_1*Beta);\n",
- "print \"The value of activity coefficients for Wilson equation are Y1 = %f \\t and \\t Y2 = %f\"%(Y1,Y2);\n",
- "\n",
- "#From NRTL equation,\n",
- "t_12 = b_12/(R*T);\n",
- "t_21 = b_21/(R*T);\n",
- "G_12 = math.exp(-alpha*t_12);\n",
- "G_21 = math.exp(-alpha*t_21);\n",
- "\n",
- "#math.log(Y1) = x_1**(2)*[t_12*(G_12/(x_1+x_2*G_12))**(2) + (G_12*t_12)/((G_12/(x_1+x_2*G_12))**(2))]\n",
- "Y1_prime = math.exp(x_2**(2)*(t_21*(G_21/(x_1+x_2*G_21))**(2)+(G_12*t_12)/(((x_2+x_1*G_12))**(2))));\n",
- "#Similarly for Y2\n",
- "Y2_prime = math.exp(x_1**(2)*(t_12*(G_12/(x_2+x_1*G_12))**(2)+(G_21*t_21)/(((x_1+x_2*G_21))**(2))));\n",
- "\n",
- "print \"The value of activity coefficients for NRTL equation are Y1 = %f \\t and \\t Y2 = %f\"%(Y1_prime,Y2_prime);\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of activity coefficients for Wilson equation are Y1 = 2.172258 \t and \t Y2 = 1.254121\n",
- "The value of activity coefficients for NRTL equation are Y1 = 2.143030 \t and \t Y2 = 1.262506\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.12 Page Number : 474"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables \n",
- "T = 307;\t\t\t#[K]\n",
- "x_1 = 0.047;\n",
- "x_2 = 1 - x_1;\n",
- "\n",
- "# The subgroups in the two components are\n",
- "# Acetone (1) : 1 CH3, 1 CH3CO\n",
- "# n-pentane (2) : 2 CH3, 3 CH2\n",
- "\n",
- "#Group volume (Rk) and surface area (Qk) parameters of the subgroup are\n",
- "k_CH3 = 1;\n",
- "k_CH2 = 2;\n",
- "k_CH3CO = 19;\n",
- "Rk_CH3 = 0.9011;\n",
- "Rk_CH2 = 0.6744;\n",
- "Rk_CH3CO = 1.6724;\n",
- "Qk_CH3 = 0.848;\n",
- "Qk_CH2 = 0.540;\n",
- "Qk_CH3CO = 1.4880;\n",
- "\n",
- "# Interaction parameters of the subgroups in kelvin (K) are\n",
- "a_1_1 = 0;\n",
- "a_1_2 = 0;\n",
- "a_1_19 = 476.40;\n",
- "a_2_1 = 0;\n",
- "a_2_2 = 0;\n",
- "a_2_19 = 476.40;\n",
- "a_19_1 = 26.76;\n",
- "a_19_2 = 26.76;\n",
- "a_19_19 = 0;\n",
- "\n",
- "# Calculations\n",
- "r_1 = 1*Rk_CH3 + 1*Rk_CH3CO;\n",
- "r_2 = 2*Rk_CH3 + 3*Rk_CH2;\n",
- "q_1 = 1*Qk_CH3 + 1*Qk_CH3CO;\n",
- "q_2 = 2*Qk_CH3 + 3*Qk_CH2;\n",
- "\n",
- "J_1 = r_1/(r_1*x_1+r_2*x_2);\n",
- "J_2 = r_2/(r_1*x_1+r_2*x_2);\n",
- "L_1 = q_1/(q_1*x_1+q_2*x_2);\n",
- "L_2 = q_2/(q_1*x_1+q_2*x_2);\n",
- "t_1_1 = math.exp(-a_1_1/T);\n",
- "t_1_2 = math.exp(-a_1_2/T);\n",
- "t_1_19 = math.exp(-a_1_19/T);\n",
- "t_2_1 = math.exp(-a_2_1/T);\n",
- "t_2_2 = math.exp(-a_2_2/T);\n",
- "t_2_19 = math.exp(-a_2_19/T);\n",
- "t_19_1 = math.exp(-a_19_1/T);\n",
- "t_19_2 = math.exp(-a_19_2/T);\n",
- "t_19_19 = math.exp(-a_19_19/T);\n",
- "\n",
- "e_1_1 = 1*Qk_CH3/q_1;\n",
- "e_2_1 = 0;\n",
- "e_19_1 = (1*Qk_CH3CO/q_1);\n",
- "e_1_2 = 2*Qk_CH3/q_2;\n",
- "e_2_2 = 3*Qk_CH2/q_2;\n",
- "e_19_2 = 0;\n",
- "\n",
- "B_1_1 = e_1_1*t_1_1 + e_2_1*t_2_1 + e_19_1*t_19_1;\n",
- "B_1_2 = e_1_1*t_1_2 + e_2_1*t_2_2 + e_19_1*t_19_2;\n",
- "B_1_19 = e_1_1*t_1_19 + e_2_1*t_2_19 + e_19_1*t_19_19;\n",
- "B_2_1 = e_1_2*t_1_1 + e_2_2*t_2_1 + e_19_2*t_19_1;\n",
- "B_2_2 = e_1_2*t_1_2 + e_2_2*t_2_2 + e_19_2*t_19_2;\n",
- "B_2_19 = e_1_2*t_1_19 + e_2_2*t_2_19 + e_19_2*t_19_19;\n",
- "\n",
- "theta_1 = (x_1*q_1*e_1_1 + x_2*q_2*e_1_2)/(x_1*q_1 + x_2*q_2);\n",
- "theta_2 = (x_1*q_1*e_2_1 + x_2*q_2*e_2_2)/(x_1*q_1 + x_2*q_2);\n",
- "theta_19 = (x_1*q_1*e_19_1 + x_2*q_2*e_19_2)/(x_1*q_1 + x_2*q_2);\n",
- "\n",
- "s_1 = theta_1*t_1_1 + theta_2*t_2_1 + theta_19*t_19_1;\n",
- "s_2 = theta_1*t_1_2 + theta_2*t_2_2 + theta_19*t_19_2;\n",
- "s_19 = theta_1*t_1_19 + theta_2*t_2_19 + theta_19*t_19_19;\n",
- "\n",
- "# math.log(Y1_C) = 1 - J_1 + math.log(J_1) - 5*q_1*(1- (J_1/L_1) + math.log(J_1/L_1))\n",
- "# math.log(Y2_C) = 1 - J_2 + math.log(J_2) - 5*q_2*(1- (J_2/L_2) + math.log(J_2/L_2))\n",
- "Y1_C = math.exp(1 - J_1 + math.log(J_1) - 5*q_1*(1- (J_1/L_1) + math.log(J_1/L_1)));\n",
- "Y2_C = math.exp(1 - J_2 + math.log(J_2) - 5*q_2*(1- (J_2/L_2) + math.log(J_2/L_2)));\n",
- "\n",
- "# For species 1\n",
- "summation_theta_k_1 = theta_1*(B_1_1/s_1) + theta_2*(B_1_2/s_2) + theta_19*(B_1_19/s_19);\n",
- "summation_e_ki_1 = e_1_1*math.log(B_1_1/s_1) + e_2_1*math.log(B_1_2/s_2) + e_19_1*math.log(B_1_19/s_19);\n",
- "\n",
- "# For species 2\n",
- "summation_theta_k_2 = theta_1*(B_2_1/s_1) + theta_2*(B_2_2/s_2) + theta_19*(B_2_19/s_19);\n",
- "summation_e_ki_2 = e_1_2*math.log(B_2_1/s_1) + e_2_2*math.log(B_2_2/s_2) + e_19_2*math.log(B_2_19/s_19);\n",
- "\n",
- "# math.log(Y1_R) = q_1(1 - summation_theta_k_1 + summation_e_ki_1)\n",
- "# math.log(Y2_R) = q_2(1 - summation_theta_k_2 + summation_e_ki_2)\n",
- "Y1_R = math.exp(q_1*(1 - summation_theta_k_1 + summation_e_ki_1));\n",
- "Y2_R = math.exp(q_2*(1 - summation_theta_k_2 + summation_e_ki_2));\n",
- "\n",
- "# math.log(Y1) = math.log(Y1_C) + math.log(Y1_R)\n",
- "# math.log(Y2) = math.log(Y2_C) + math.log(Y2_R)\n",
- "Y1 = math.exp(math.log(Y1_C) + math.log(Y1_R));\n",
- "Y2 = math.exp(math.log(Y2_C) + math.log(Y2_R));\n",
- "\n",
- "# Results\n",
- "print \" The activity coefficients are Y1 = %f and Y2 = %f\"%(Y1,Y2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The activity coefficients are Y1 = 4.992034 and Y2 = 1.005260\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.13 Page Number : 481"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables,\n",
- "T = 25 + 273.15;\t\t\t#[K] - Temperature\n",
- "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
- "#component 1 = chloroform\n",
- "#component 2 = carbon tetrachloride\n",
- "x_1 = 0.5;\t\t\t#Mole fraction of component 1 \t\t\t#Equimolar mixture\n",
- "x_2 = 0.5;\t\t\t#Mole fraction of component 2\n",
- "V_mol_1 = 81;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 1\n",
- "V_mol_2 = 97;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2\n",
- "del_1 = 9.2;\t\t\t#[(cal/cm**(3))**(1/2)] - Mole fraction of component 1\n",
- "del_2 = 8.6;\t\t\t#[(cal/cm**(3))**(1/2)] - Mole fraction of component 2\n",
- "\n",
- "# Calculations\n",
- "#Scatchard - Hilderbrand model\n",
- "phi_1 = (x_1*V_mol_1)/(x_1*V_mol_1+x_2*V_mol_2);\n",
- "phi_2 = (x_2*V_mol_2)/(x_1*V_mol_1+x_2*V_mol_2);\n",
- "\n",
- "#math.log(Y1) = (V_mol_1/(R*T))*phi_1**(2)*(del_1-del_2)**(2)\n",
- "Y1 = math.exp((V_mol_1/(R*T))*(phi_1**(2))*((del_1-del_2)**(2)));\n",
- "\n",
- "#Similarly, for Y2\n",
- "Y2 = math.exp((V_mol_2/(R*T))*(phi_2**(2))*((del_1-del_2)**(2)));\n",
- "\n",
- "# Results\n",
- "print \"The value of activity coefficients for Scatchard-Hilderbrand model are Y1 = %f \\t and \\t Y2 = %f\"%(Y1,Y2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of activity coefficients for Scatchard-Hilderbrand model are Y1 = 1.010245 \t and \t Y2 = 1.017658\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.14 Page Number : 485"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables,\n",
- "T = 25 + 273.15;\t\t\t#[K] - Temperature\n",
- "mol_HCl = 0.001;\t\t\t#[mol/kg] - Molality of HCl\n",
- "A = 0.510;\t\t\t#[(kg/mol)**(1/2)]\n",
- "Z_positive = 1;\t\t\t#Stoichiometric coefficient of 'H' ion\n",
- "Z_negative = -1;\t\t\t#Stoichiometric coefficient of 'Cl' ion\n",
- "m_H_positive = mol_HCl;\t\t\t#\n",
- "m_Cl_negative = mol_HCl;\n",
- "\n",
- "# Calculations and Results\n",
- "# I = 1/2*[((Z_positive)**(2))*m_H_positive + ((Z_negative)**(2))*m_Cl_negative]\n",
- "I = 1./2*(((Z_positive)**(2))*m_H_positive + ((Z_negative)**(2))*m_Cl_negative);\n",
- "\n",
- "#Using Debye-Huckel limiting law wee get,\n",
- "# math.log(Y1) = -A*(abs(Z_positive*Z_negative))*(I**(1/2)))\n",
- "Y = 10**(-A*(abs(Z_positive*Z_negative))*(I**(1./2)));\n",
- "print \"The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = %f\"%(Y);\n",
- "\n",
- "#Using Debye-Huckel extended model we get\n",
- "#math.log(Y_prime) = (-A*(abs(Z_positive*Z_negative))*(I**(1/2)))/(1 + (I**(1/2)));\n",
- "Y_prime = 10**((-A*(abs(Z_positive*Z_negative))*(I**(1./2)))/(1 + (I**(1./2))));\n",
- "print \"The mean activity coefficient at 25 C using Debye-Huckel extended model is Y = %f\"%(Y_prime);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = 0.963546\n",
- "The mean activity coefficient at 25 C using Debye-Huckel extended model is Y = 0.964643\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.15 Page Number : 485"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables,\n",
- "T = 25 + 273.15;\t\t\t#[K] - Temperature\n",
- "mol_CaCl2 = 0.001;\t\t\t#[mol/kg] - Molality of HCl\n",
- "A = 0.510;\t\t\t#[(kg/mol)**(1/2)]\n",
- "Z_positive = 2;\t\t\t#Stoichiometric coefficient of 'Ca' ion\n",
- "Z_negative = -1;\t\t\t#Stoichiometric coefficient of 'Cl' ion\n",
- "m_Ca_positive = mol_CaCl2;\n",
- "m_Cl_negative = 2*mol_CaCl2;\n",
- "\n",
- "# Calculations\n",
- "# I = 1/2*[((Z_positive)**(2))*m_Ca_positive + ((Z_negative)**(2))*m_Cl_negative]\n",
- "I = 1./2*(((Z_positive)**(2))*m_Ca_positive + ((Z_negative)**(2))*m_Cl_negative);\n",
- "\n",
- "#Using Debye-Huckel limiting law wee get,\n",
- "# math.log(Y1) = -A*(abs(Z_positive*Z_negative))*(I**(1/2)))\n",
- "Y = 10**(-A*(abs(Z_positive*Z_negative))*(I**(1./2)));\n",
- "\n",
- "# Results\n",
- "print \"The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = %f\"%(Y);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = 0.879290\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.17 Page Number : 488"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables,\n",
- "T = 50 + 273.15;\t\t\t#[K] - Temperature\n",
- "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "x_1 = 0.3;\t\t\t# Mole fraction of component 1\n",
- "x_2 = (1-x_1);\t\t\t# Mole fraction of component 2\n",
- "#Increment of 1% means Y2 = 1.01*Y1\n",
- "\n",
- "# Calculations\n",
- "#Excess volume of the mixture is given by,\n",
- "V_excess = 4*x_1*x_2;\t\t\t#[cm**(3)/mol]\n",
- "#Amd threfore\n",
- "V_1_excess = 4*x_2*x_2*10**(-6);\t\t\t#[m**(3)/mol] - Exces volume of component 1\n",
- "V_2_excess = 4*x_1*x_1*10**(-6);\t\t\t#[m**(3)/mol] - Exces volume of component 2\n",
- "\n",
- "#We have from equation 14.89 of the book,\n",
- "#V_i_excess/(R*T) = (del_math.log(Y_i)/del_P)_T,x\n",
- "\n",
- "#Rearranging above equation\n",
- "#d(math.log(Y1)) = (V1_excess/(R*T))dP\n",
- "#Integrating the above equation at constant 'T' and 'x' in the limit from 'Y1' to '1.01*Y1' in the LHS and from 'P' to 'P+delta_P' in the RHS\n",
- "#On simplification we get\n",
- "#math.log(1.01*Y1/Y1) = (V_1_exces/(R*T))*delta_P\n",
- "delta_P = math.log(1.01)/(V_1_excess/(R*T));\t\t\t#[N/m**(2)]\n",
- "delta_P = delta_P*10**(-6);\t\t\t#[MPa]\n",
- "\n",
- "# Results\n",
- "print \"The required pressure to increase the activity coefficient by 1%% is %f MPa\"%(delta_P);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The required pressure to increase the activity coefficient by 1% is 13.639411 MPa\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.21 Page Number : 490"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 293.15;\t\t\t#[K] - Temperature\n",
- "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "A = 1280;\t\t\t#[J/mol]\n",
- "\n",
- "#(dA/dT)_P,x = del_A (say)\n",
- "dA_dT = -7.0;\t\t\t#[J/mol-K]\n",
- "\n",
- "#For equilomar mixture,\n",
- "x_1 = 0.5;\t\t\t# Mole fraction of component 1\n",
- "x_2 = 0.5;\t\t\t# Mole fraction of component 2\n",
- "\n",
- "# Calculations\n",
- "#math.log(Y1) = (A/(R*T))*x_2**(2)\n",
- "#math.log(Y2) = (A/(R*T))*x_1**(2)\n",
- "Y1 = math.exp((A/(R*T))*x_2**(2));\n",
- "Y2 = math.exp((A/(R*T))*x_1**(2));\n",
- "\n",
- "#G_excess/(R*T*) = x_1*math.log(Y1) + x_2*math.log(Y2) = (A/(R*T))*x_1*x_2\n",
- "G_excess = A*x_1*x_2;\t\t\t#[J/mol] - Excess Gibbs free energy\n",
- "\n",
- "#H_excess/(R*T**(2)) = -[d/dT(G_excess/(R*T))]_P,x\n",
- "#H_excess/(R*T**(2)) = -((x_1*x_2)/R)*[d/dT(A/T)]_P,x\n",
- "#On simplification and putting the values we get\n",
- "H_excess = A*x_1*x_2 - T*dA_dT*x_1*x_2;\t\t\t#[J/mol] - Excess enthalpy\n",
- "\n",
- "#Now excess entropy is given by\n",
- "S_excess = (H_excess - G_excess)/T;\t\t\t#[J/mol-K] - Excess entropy\n",
- "\n",
- "# Results\n",
- "print \"For equimolar mixture\";\n",
- "print \"Excess Gibbs free energy G_excess) is %f J/mol\"%(G_excess);\n",
- "print \"Excess enthalpy H_excess) is %f J/mol\"%(H_excess);\n",
- "print \"Excess entropy S_excess) is %f J/mol\"%(S_excess);\n",
- "print \"The value of activity coefficient Y1 is %f\"%(Y1);\n",
- "print \"The value of activity coefficient Y2 is %f\"%(Y2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "For equimolar mixture\n",
- "Excess Gibbs free energy G_excess) is 320.000000 J/mol\n",
- "Excess enthalpy H_excess) is 833.012500 J/mol\n",
- "Excess entropy S_excess) is 1.750000 J/mol\n",
- "The value of activity coefficient Y1 is 1.140305\n",
- "The value of activity coefficient Y2 is 1.140305\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 14.22 Page Number : 491"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Given\n",
- "T = 60 + 273.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# math.log(Y1_inf) = math.log(Y2_inf) = 0.15 + 10/T\n",
- "\n",
- "# Since the two liquids are slightly dissimilar , we assume the activity coeffiecients to follow van Laar equation \n",
- "# From van L# Variablesr equation \n",
- "# A = math.log(Y1_inf) and B = math.log(Y2_inf) and since it is given that math.log(Y1_inf) = math.log(Y2_inf), therefore A = B\n",
- "#(x_1*x_2)/(G_excess/R*T) = x_1/B + x_2/A = X_1/A + x_2/A = 1/A\n",
- "# G_excess/(R*T) = A*x_1*x_2\n",
- "\n",
- "# For equilomar mixture,\n",
- "x_1 = 0.5;\t\t\t# Mole fraction of component 1\n",
- "x_2 = 0.5;\t\t\t# Mole fraction of component 2\n",
- "\n",
- "# Calculations and Results\n",
- "# Expression for A can be written as\n",
- "# A = 0.15 + 10/T, where T is in C. Therefore\n",
- "A = 0.15 + 10/(T - 273.15);\n",
- "# Differentiating it with respect to temprature we get\n",
- "dA_dT = - 10/((T-273.15)**(2));\n",
- "\n",
- "# The excess Gibbs free energy can be calculated as\n",
- "G_excess = A*x_1*x_2*(R*T);\t\t\t#[J/mol]\n",
- "\n",
- "# The ideal Gibbs free energy change can be calculated as\n",
- "delta_G_id_mix = R*T*(x_1*math.log(x_1) + x_2*math.log(x_2));\t\t\t#[J/mol]\n",
- "\n",
- "# Finally we have,\n",
- "delta_G_mix = G_excess + delta_G_id_mix;\t\t\t#[J/mol]\n",
- "\n",
- "print \"The Gibbs free energy change of mixing for equimolar mixture is %f J/mol\"%(delta_G_mix);\n",
- "\n",
- "\n",
- "# Now let us determine the excess enthalpy. We know that\n",
- "# H_excess/(R*T**(2)) = -[d/dT(G_excess/R*T)]_P,x = - x_1*x_2*[d/dT(A)]_P,x\n",
- "# Therefore at 'T' = 60 C the excess enthalpy is given by\n",
- "H_excess = -R*(T**(2))*x_1*x_2*dA_dT;\t\t\t#[J/mol]\n",
- "\n",
- "delta_H_id_mix = 0;\t\t\t#[J/mol] - Enthalpy change of mixing for ideal solution is zero.\n",
- "\n",
- "#Thus enthalpy change of mixing for an equimolar mixture at 333.15 K is given by\n",
- "delta_H_mix = delta_H_id_mix + H_excess;\t\t\t#[J/mol]\n",
- "\n",
- "\n",
- "print \"The enthalpy change of mixing for equimolar mixture is %f J/mol\"%(delta_H_mix);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The Gibbs free energy change of mixing for equimolar mixture is -1700.608815 J/mol\n",
- "The enthalpy change of mixing for equimolar mixture is 640.806876 J/mol\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch15_1.ipynb b/Chemical_Engineering_Thermodynamics/ch15_1.ipynb
deleted file mode 100755
index fcfb0cd5..00000000
--- a/Chemical_Engineering_Thermodynamics/ch15_1.ipynb
+++ /dev/null
@@ -1,2075 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:aa6f699613cdf9bcba2dda4617212630ca1760d21939d5cd99d17e7e03b7e885"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 15 : Vapour Liquid Equilibrium"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.1 Page Number : 503"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 90+ 273.15;\t\t\t#[K] - Temperature\n",
- "P = 1;\t\t\t#[atm] - Pressure\n",
- "x_1 = 0.5748;\t\t\t# Equilibrium composition of liquid phase\n",
- "y_1 = 0.7725;\t\t\t# Equilibrium composition of vapour phase\n",
- "\n",
- "\t\t\t# We start with 1 mol of mixture of composition z_1 = 0.6, from marterial balance we get\n",
- "\t\t\t# (L + V)*z_1 = L*x_1 + V*y_1\n",
- "\t\t\t# Since total number of moles is 1, we get\n",
- "\t\t\t# z_1 = L*x_1 + (1-L)*y_1\n",
- "\n",
- "# Calculations and Results\n",
- "z_1_1 = 0.6;\t\t\t# - Mole fraction of benzene\n",
- "L_1 = (z_1_1 - y_1)/(x_1 - y_1);\n",
- "V_1 = 1 - L_1;\n",
- "\n",
- "print \" For z_1 = 0.6\";\n",
- "print \" The moles in the liquid phase is %f mol\"%(L_1);\n",
- "print \" The moles in the vapour phase is %f mol\"%(V_1);\n",
- "\n",
- "z_1_2 = 0.7;\t\t\t# - Mole fraction of benzene\n",
- "L_2 = (z_1_2 - y_1)/(x_1 - y_1);\n",
- "V_2 = 1 - L_2;\n",
- "\n",
- "print \" For z_1 = 0.7\";\n",
- "print \" The moles in the liquid phase is %f mol\"%(L_2);\n",
- "print \" The moles in the vapour phase is %f mol\"%(V_2);\n",
- "\n",
- "\n",
- "\t\t\t# For z = 0.8\n",
- "\t\t\t# The feed remains vapour and the liquid is not formed at all as it is outside the two-phase region (x_1 = 0.5748 and y_1 = 0.7725).\n",
- "print \" For z_1 = 0.8\";\n",
- "print \" The feed remains vapour and the liquid is not formed at all as it is outside the two-phase region x_1 = 0.5748 and y_1 = 0.7725\"\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " For z_1 = 0.6\n",
- " The moles in the liquid phase is 0.872534 mol\n",
- " The moles in the vapour phase is 0.127466 mol\n",
- " For z_1 = 0.7\n",
- " The moles in the liquid phase is 0.366717 mol\n",
- " The moles in the vapour phase is 0.633283 mol\n",
- " For z_1 = 0.8\n",
- " The feed remains vapour and the liquid is not formed at all as it is outside the two-phase region x_1 = 0.5748 and y_1 = 0.7725\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.2 Page Number : 515"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "\t\t\t# math.log(P_1_sat) = 14.39155 - 2795.817/(t + 230.002)\n",
- "\t\t\t# math.log(P_2_sat) = 16.26205 - 3799.887/(t + 226.346)\n",
- "\n",
- "\t\t\t#(a)\n",
- "x_1_a =0.43;\t\t\t# Equilibrium composition of liquid phase\n",
- "t_a = 76;\t\t\t#[C] - Temperature\n",
- "x_2_a = 1 - x_1_a;\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# Since liquid phase composition is given we use the relation \n",
- "\t\t\t# P = x_1*P_1_sat + x_2*P_2_sat\n",
- "\t\t\t# At t = 76 C\n",
- "P_1_sat_a = math.exp(14.39155 - 2795.817/(t_a + 230.002));\n",
- "P_2_sat_a = math.exp(16.26205 - 3799.887/(t_a + 226.346));\n",
- "\t\t\t# Therefore total pressure is\n",
- "P_a = x_1_a*P_1_sat_a + x_2_a*P_2_sat_a;\t\t\t#[kPa]\n",
- "y_1_a = (x_1_a*P_1_sat_a)/(P_a);\n",
- "y_2_a = (x_2_a*P_2_sat_a)/(P_a);\n",
- "\n",
- "print \"a).The system pressure is = %f kPa\"%(P_a);\n",
- "print \" The vapour phase composition is y_1 = %f\"%(y_1_a);\n",
- "\n",
- "\t\t\t#(b)\n",
- "y_1_b = 0.43;\t\t\t# Equilibrium composition of vapour phase\n",
- "y_2_b = 1 - y_1_b;\n",
- "t_b = 76;\t\t\t#[C] - Temperature\n",
- "\n",
- "P_1_sat_b = math.exp(14.39155 - 2795.817/(t_b + 230.002));\n",
- "P_2_sat_b = math.exp(16.26205 - 3799.887/(t_b + 226.346));\n",
- "\n",
- "\t\t\t# Since vapour phase composition is given ,the system pressure is given by\n",
- "\t\t\t# 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
- "P_b = 1/(y_1_b/P_1_sat_b + y_2_b/P_2_sat_b);\n",
- "\n",
- "x_1_b = (y_1_b*P_b)/P_1_sat_b;\n",
- "x_2_b = (y_2_b*P_b)/P_2_sat_b;\n",
- "\n",
- "print \"b).The system pressure is P = %f kPa\"%(P_b);\n",
- "print \" The liquid phase composition is x_1 = %f\"%(x_1_b);\n",
- "\n",
- "\t\t\t#(c)\n",
- "x_1_c = 0.32;\t\t\t# Equilibrium composition of liquid phase\n",
- "x_2_c = 1 - x_1_c;\n",
- "P_c = 101.33;\t\t\t#[kPa] - Pressure of the system\n",
- "\n",
- "\t\t\t# We have, P = x_1*P_1_sat + x_2*P_2_sat\n",
- "t_1_sat = 2795.817/(14.39155 - math.log(P_c)) - 230.002;\n",
- "t_2_sat = 3799.887/(16.26205 - math.log(P_c)) - 226.346;\n",
- "t = x_1_c*t_1_sat + x_2_c*t_2_sat;\n",
- "\n",
- "error = 10;\n",
- "while(error>0.1):\n",
- " P_1_sat = math.exp(14.39155 - 2795.817/(t + 230.002));\n",
- " P_2_sat = math.exp(16.26205 - 3799.887/(t + 226.346));\n",
- " P = x_1_c*P_1_sat + x_2_c*P_2_sat;\n",
- " error=abs(P - P_c);\n",
- " t = t - 0.1;\n",
- "\n",
- "P_1_sat_c = math.exp(14.39155 - 2795.817/(t + 230.002));\n",
- "P_2_sat_c = math.exp(16.26205 - 3799.887/(t + 226.346));\n",
- "\n",
- "y_1_c = (x_1_c*P_1_sat_c)/(P_c);\n",
- "y_2_c = 1 - y_1_c;\n",
- "\n",
- "print \"c).The system temperature is t = %f C\"%(t);\n",
- "print \" The vapour phase composition is y_1 = %f\"%(y_1_c);\n",
- "\n",
- "\t\t\t#(d)\n",
- "y_1_d = 0.57;\t\t\t# Vapour phase composition\n",
- "y_2_d = 1 - y_1_d;\n",
- "P_d = 101.33;\t\t\t#[kPa] - Pressure of the system\n",
- "\n",
- "\t\t\t# Since vapour phase composition is given, we can use the relation\n",
- "\t\t\t# 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
- "t_1_sat_d = 2795.817/(14.39155 - math.log(P_d)) - 230.002;\n",
- "t_2_sat_d = 3799.887/(16.26205 - math.log(P_d)) - 226.346;\n",
- "t_d = y_1_d*t_1_sat_d + y_2_d*t_2_sat_d;\n",
- "\n",
- "fault = 10;\n",
- "while(fault>0.1):\n",
- " P_1_sat_prime = math.exp(14.39155 - 2795.817/(t_d + 230.002));\n",
- " P_2_sat_prime = math.exp(16.26205 - 3799.887/(t_d + 226.346));\n",
- " P_prime = 1/(y_1_d/P_1_sat_prime + y_2_d/P_2_sat_prime);\n",
- " fault=abs(P_prime - P_d);\n",
- " t_d = t_d + 0.01;\n",
- "\n",
- "P_1_sat_d = math.exp(14.39155 - 2795.817/(t_d + 230.002));\n",
- "P_2_sat_d = math.exp(16.26205 - 3799.887/(t_d + 226.346));\n",
- "\n",
- "x_1_d = (y_1_d*P_d)/(P_1_sat_d);\n",
- "x_2_d = 1 - x_1_d;\n",
- "\n",
- "print \"d).The system temperature is t = %f C\"%(t_d);\n",
- "print \" The liquid phase composition is x_1 = %f\"%(x_1_d);\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a).The system pressure is = 105.268363 kPa\n",
- " The vapour phase composition is y_1 = 0.782290\n",
- "b).The system pressure is P = 60.894254 kPa\n",
- " The liquid phase composition is x_1 = 0.136725\n",
- "c).The system temperature is t = 79.943314 C\n",
- " The vapour phase composition is y_1 = 0.679347\n",
- "d).The system temperature is t = 84.600005 C\n",
- " The liquid phase composition is x_1 = 0.234934\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.3 Page Number : 516"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "x_1_a = 0.25;\t\t\t# Equilibrium composition of liquid phase\n",
- "x_2_a = 0.35;\n",
- "x_3_a = 1 - x_1_a - x_2_a;\n",
- "t_a = 80;\t\t\t#[C] - Temperature\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# At t = 80 C\n",
- "P_1_sat_a = math.exp(14.3916 - 2795.82/(t_a + 230.00));\n",
- "P_2_sat_a = math.exp(14.2724 - 2945.47/(t_a + 224.00));\n",
- "P_3_sat_a = math.exp(14.2043 - 2972.64/(t_a + 209.00));\n",
- "\n",
- "\t\t\t# Since liquid phase composition is given we use the relation \n",
- "P_a = x_1_a*P_1_sat_a + x_2_a*P_2_sat_a + x_3_a*P_3_sat_a;\t\t\t#[kPa]\n",
- "\n",
- "y_1_a = (x_1_a*P_1_sat_a)/(P_a);\n",
- "y_2_a = (x_2_a*P_2_sat_a)/(P_a);\n",
- "y_3_a = (x_3_a*P_3_sat_a)/(P_a);\n",
- "\n",
- "print \"a).The system pressure is P = %f kPa\"%(P_a);\n",
- "print \" The vapour phase composition is given by y_1 = %f y_2 = %f and y_3 = %f \"%(y_1_a,y_2_a,y_3_a);\n",
- "\n",
- "\t\t\t#(2)\n",
- "y_1_b = 0.50;\t\t\t# Equilibrium composition of liquid phase\n",
- "y_2_b = 0.30;\n",
- "y_3_b = 1 - y_1_a - y_2_a;\n",
- "t_b = 85;\t\t\t#[C] - Temperature\n",
- "\n",
- "\t\t\t# At t = 80 C\n",
- "P_1_sat_b = math.exp(14.3916 - 2795.82/(t_b + 230.00));\n",
- "P_2_sat_b = math.exp(14.2724 - 2945.47/(t_b + 224.00));\n",
- "P_3_sat_b = math.exp(14.2043 - 2972.64/(t_b + 209.00));\n",
- "\n",
- "\t\t\t# Since vapour phase composition is given we use the relation \n",
- "P_b = 1/(y_1_b/P_1_sat_b + y_2_b/P_2_sat_b + y_3_b/P_3_sat_b);\t\t\t#[kPa]\n",
- "\n",
- "\t\t\t# Therefore we have\n",
- "x_1_b = (y_1_b*P_b)/P_1_sat_b;\n",
- "x_2_b = (y_2_b*P_b)/P_2_sat_b;\n",
- "x_3_b = (y_3_b*P_b)/P_3_sat_b;\n",
- "\n",
- "print \"b).The system pressure is P = %f kPa\"%(P_b);\n",
- "print \" The liquid phase composition is given by x_1 = %f x_2 = %f and x_3 = %f \"%(x_1_b,x_2_b,x_3_b);\n",
- "\n",
- "\t\t\t#(c)\n",
- "x_1_c = 0.30;\t\t\t# Equilibrium composition of liquid phase\n",
- "x_2_c = 0.45;\n",
- "x_3_c = 1 - x_1_c - x_2_c;\n",
- "P_c = 80;\t\t\t#[kPa] - Pressure of the system\n",
- "\n",
- "\t\t\t# We have, P = x_1*P_1_sat + x_2*P_2_sat + x_3*P_3_sat\n",
- "t_1_sat = 2795.82/(14.3916 - math.log(P_c)) - 230.00;\t\t\t#[C]\n",
- "t_2_sat = 2945.47/(14.2724 - math.log(P_c)) - 224.00;\t\t\t#[C]\n",
- "t_3_sat = 2972.64/(14.2043 - math.log(P_c)) - 209.00;\t\t\t#[C]\n",
- "t = x_1_c*t_1_sat + x_2_c*t_2_sat + x_3_c*t_3_sat;\n",
- "\n",
- "error = 10;\n",
- "while(error>0.5):\n",
- " P_1_sat = math.exp(14.3916 - 2795.82/(t + 230.00));\n",
- " P_2_sat = math.exp(14.2724 - 2945.47/(t + 224.00));\n",
- " P_3_sat = math.exp(14.2043 - 2972.64/(t + 209.00));\n",
- " P = x_1_c*P_1_sat + x_2_c*P_2_sat + x_3_c*P_3_sat;\n",
- " error=abs(P - P_c);\n",
- " t = t - 0.2;\n",
- "\n",
- "P_1_sat_c = math.exp(14.3916 - 2795.82/(t + 230.00));\n",
- "P_2_sat_c = math.exp(14.2724 - 2945.47/(t + 224.00));\n",
- "P_3_sat_c = math.exp(14.2043 - 2972.64/(t + 209.00));\n",
- "\n",
- "y_1_c = (x_1_c*P_1_sat_c)/(P_c);\n",
- "y_2_c = (x_2_c*P_2_sat_c)/(P_c);\n",
- "y_3_c = 1 - y_1_c - y_2_c;\n",
- "\n",
- "print \"c).The system temperature is t = %f C\"%(t);\n",
- "print \" The vapour phase composition is y_1 = %f y_2 %f and y_3 = %f\"%(y_1_c,y_2_c,y_3_c);\n",
- "\n",
- "\t\t\t#(d)\n",
- "y_1_d = 0.6;\t\t\t# Vapour phase composition\n",
- "y_2_d = 0.2;\n",
- "y_3_d = 1 - y_1_d - y_2_d;\n",
- "P_d = 90;\t\t\t#[kPa] - Pressure of the system\n",
- "\n",
- "\t\t\t# Since vapour phase composition is given, we can use the relation\n",
- "\t\t\t# 1/P = y_1/P_1_sat + y_2/P_2_sat + y_3/P_3_sat\n",
- "t_1_sat_d = 2795.82/(14.3916 - math.log(P_d)) - 230.00;\n",
- "t_2_sat_d = 2945.47/(14.2724 - math.log(P_d)) - 224.00;\n",
- "t_3_sat_d = 2972.64/(14.2043 - math.log(P_d)) - 209.00;\n",
- "t_d = y_1_d*t_1_sat_d + y_2_d*t_2_sat_d + y_3_d*t_3_sat_d;\n",
- "\n",
- "fault = 10;\n",
- "while(fault>0.5):\n",
- " P_1_sat_prime = math.exp(14.3916 - 2795.82/(t_d + 230.00));\n",
- " P_2_sat_prime = math.exp(14.2724 - 2945.47/(t_d + 224.00));\n",
- " P_3_sat_prime = math.exp(14.2043 - 2972.64/(t_d + 209.00));\n",
- " P_prime = 1/(y_1_d/P_1_sat_prime + y_2_d/P_2_sat_prime + y_3_d/P_3_sat_prime);\n",
- " fault=abs(P_prime - P_d);\n",
- " t_d = t_d + 0.2;\n",
- "\n",
- "P_1_sat_d = math.exp(14.3916 - 2795.82/(t_d + 230.00));\n",
- "P_2_sat_d = math.exp(14.2724 - 2945.47/(t_d + 224.00));\n",
- "P_3_sat_d = math.exp(14.2043 - 2972.64/(t_d + 209.00));\n",
- "\n",
- "x_1_d = (y_1_d*P_d)/(P_1_sat_d);\n",
- "x_2_d = (y_2_d*P_d)/(P_2_sat_d);\n",
- "x_3_d = 1 - x_1_d - x_2_d;\n",
- "\n",
- "print \"d).The system temperature is t = %f C\"%(t_d);\n",
- "print \" The liquid phase composition is x_1 = %f x_2 = %f and x_3 = %f\"%(x_1_d,x_2_d,x_3_d);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a).The system pressure is P = 108.239332 kPa\n",
- " The vapour phase composition is given by y_1 = 0.497672 y_2 = 0.316379 and y_3 = 0.185948 \n",
- "b).The system pressure is P = 129.287998 kPa\n",
- " The liquid phase composition is given by x_1 = 0.259997 x_2 = 0.338895 and x_3 = 0.401108 \n",
- "c).The system temperature is t = 67.020387 C\n",
- " The vapour phase composition is y_1 = 0.544826 y_2 0.357251 and y_3 = 0.097922\n",
- "d).The system temperature is t = 73.127683 C\n",
- " The liquid phase composition is x_1 = 0.307471 x_2 = 0.230183 and x_3 = 0.462346\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.4 Page Number : 519"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "T = 120;\t\t\t#[C] - Temperature\n",
- "P_1 = 1;\t\t\t#[atm] - Initial pressure\n",
- "P_1 = P_1*101.325;\t\t\t#[kPa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "y_1 = 0.3;\t\t\t# Mole fraction of propane\n",
- "y_2 = 0.5;\t\t\t# Mole fraction of butane\n",
- "y_3 = 0.2;\t\t\t# Mole fraction of hexane\n",
- "\n",
- "\t\t\t# math.log(P_1_sat) = 13.7713 - 1892.47/(t + 248.82)\n",
- "\t\t\t# math.log(P_2_sat) = 13.7224 - 2151.63/(t + 236.91)\n",
- "\t\t\t# math.log(P_3_sat) = 13.8216 - 2697.55/(t + 224.37)\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(a)\n",
- "P_1_sat = math.exp(13.7713 - 1892.47/(T + 248.82));\n",
- "P_2_sat = math.exp(13.7224 - 2151.63/(T + 236.91));\n",
- "P_3_sat = math.exp(13.8216 - 2697.55/(T + 224.37));\n",
- "\n",
- "\t\t\t# Since vapour phase composition is given we can use the relation,\n",
- "P_2 = 1/(y_1/P_1_sat + y_2/P_2_sat + y_3/P_3_sat);\t\t\t#[kPa]\n",
- "\n",
- "print \" a).The pressure of the mixture when first drop condenses is given by P = %f kPa\"%(P_2);\n",
- "\n",
- "\t\t\t#(b)\n",
- "x_1 = (y_1*P_2)/P_1_sat;\n",
- "x_2 = (y_2*P_2)/P_2_sat;\n",
- "x_3 = (y_3*P_2)/P_3_sat;\n",
- "\n",
- "print \" b).The liquid phase composition is given by x_1 propane = %f x_2 butane = %f and x_3 hexane = %f \"%(x_1,x_2,x_3);\n",
- "\n",
- "\t\t\t# (c)\n",
- "\t\t\t# Work transfer per mol is given by\n",
- "\t\t\t# W = integral(P*dV) = integral((R*T/V)*dV) = R*T*math.log(V_2/V_1) = R*T*math.log(P_1/P_2)\n",
- "w = R*(T+273.15)*math.log(P_1/P_2);\t\t\t#[J/mol]\n",
- "\t\t\t# For 100 mol\n",
- "W = w*100;\t\t\t#[J]\n",
- "W = W*10**(-3);\t\t\t#[kJ]\n",
- "print \" c).The work required for 100 mol of mixture handeled is %f kJ\"%(W);\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The pressure of the mixture when first drop condenses is given by P = 1278.060855 kPa\n",
- " b).The liquid phase composition is given by x_1 propane = 0.067811 x_2 butane = 0.291139 and x_3 hexane = 0.641049 \n",
- " c).The work required for 100 mol of mixture handeled is -828.526086 kJ\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.5 Page Number : 520"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "# Variables\n",
- "T = 27;\t\t\t#[C] - Temperature\n",
- "\n",
- "\t\t\t# math.log(P_1_sat) = 13.8216 - 2697.55/(t + 224.37)\n",
- "\t\t\t# math.log(P_2_sat) = 13.8587 - 2911.32/(t + 216.64)\n",
- "\n",
- "\t\t\t#(a)\n",
- "x_1_a = 0.2;\n",
- "x_2_a = 1 - x_1_a;\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# At t = 27 C\n",
- "P_1_sat = math.exp(13.8216 - 2697.55/(T + 224.37));\t\t\t#[kPa]\n",
- "P_2_sat = math.exp(13.8587 - 2911.32/(T + 216.64));\t\t\t#[kPa]\n",
- "P_a = x_1_a*P_1_sat + x_2_a*P_2_sat;\t\t\t#[kPa]\n",
- "\n",
- "y_1_a = x_1_a*P_1_sat/P_a;\n",
- "y_2_a = x_2_a*P_2_sat/P_a;\n",
- "\n",
- "print \"a).The total pressure is P = %f kPa\"%(P_a);\n",
- "print \" The vapour phase composition is given by y_1 = %f and y_2 = %f\"%(y_1_a,y_2_a);\n",
- "\n",
- "\t\t\t#(b)\n",
- "y_1_b = 0.2;\n",
- "y_2_b = 1 - y_1_b;\n",
- "\t\t\t# Since vapour phase composition is given we can use the relation \n",
- "P_b = 1/(y_1_b/P_1_sat + y_2_b/P_2_sat);\t\t\t#[kPa]\n",
- "\n",
- "\t\t\t# Therefore we have\n",
- "x_1_b = (y_1_b*P_b)/P_1_sat;\n",
- "x_2_b = (y_2_b*P_b)/P_2_sat;\n",
- "\n",
- "print \"b).The total pressure is, P = %f kPa\"%(P_b);\n",
- "print \" The liquid phase composition is given by x_1 = %f and x_2 = %f\"%(x_1_b,x_2_b);\n",
- "\n",
- "\t\t\t#(c)\n",
- "P_c = 30;\t\t\t#[kPa] - Total pressure\n",
- "x_1_c = 0.2;\n",
- "x_2_c = 1 - x_1_c;\n",
- "\n",
- "\t\t\t# We have, P = x_1*P_1_sat + x_2*P_2_sat\n",
- "t_1_sat = 2697.55/(13.8216 - math.log(P_c)) - 224.37;\n",
- "t_2_sat = 2911.32/(13.8587 - math.log(P_c)) - 216.64;\n",
- "t = x_1_c*t_1_sat + x_2_c*t_2_sat;\n",
- "\n",
- "fault = 10;\n",
- "while(fault>0.3):\n",
- " P_1_sat = math.exp(13.8216 - 2697.55/(t + 224.37));\n",
- " P_2_sat = math.exp(13.8587 - 2911.32/(t + 216.64));\n",
- " P = x_1_c*P_1_sat + x_2_c*P_2_sat;\n",
- " fault = abs(P - P_c);\n",
- " t = t - 0.1;\n",
- "\n",
- "P_1_sat_c = math.exp(13.8216 - 2697.55/(t + 224.37));\n",
- "P_2_sat_c = math.exp(13.8587 - 2911.32/(t + 216.64));\n",
- "\n",
- "y_1_c = (x_1_c*P_1_sat_c)/(P_c);\n",
- "y_2_c = 1 - y_1_c;\n",
- "\n",
- "print \"c).The system temperature is t = %f C\"%(t);\n",
- "print \" The vapour phase composition is y_1 = %f and y_2 = %f \"%(y_1_c,y_2_c);\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a).The total pressure is P = 9.795726 kPa\n",
- " The vapour phase composition is given by y_1 = 0.448801 and y_2 = 0.551199\n",
- "b).The total pressure is, P = 7.835131 kPa\n",
- " The liquid phase composition is given by x_1 = 0.071288 and x_2 = 0.928712\n",
- "c).The system temperature is t = 53.904663 C\n",
- " The vapour phase composition is y_1 = 0.413592 and y_2 = 0.586408 \n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.6 Page Number : 521"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P = 90;\t\t\t#[kPa] - Pressure\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\t\t\t# math.log(P_sat) = A - B/(t + C)\n",
- "\n",
- "\t\t\t# For benzene\n",
- "A_1 = 13.8594;\n",
- "B_1 = 2773.78;\n",
- "C_1 = 220.07;\n",
- "\t\t\t# For ethyl benzene\n",
- "A_2 = 14.0045;\n",
- "B_2 = 3279.47;\n",
- "C_2 = 213.20;\n",
- "\n",
- "x_1 = 0.5;\t\t\t# Equimolar mixture\n",
- "x_2 = 0.5;\n",
- "\n",
- "\t\t\t# The bubble point temperature equation is\n",
- "\t\t\t# P = x_1*P_1_sat + x_2*P_2_sat\n",
- "\n",
- "# Calculations and Results\n",
- "t_1_sat = B_1/(A_1 - math.log(P)) - C_1;\n",
- "t_2_sat = B_2/(A_2 - math.log(P)) - C_2;\n",
- "t = x_1*t_1_sat + x_2*t_2_sat;\n",
- "\n",
- "fault = 10;\n",
- "while(fault>0.3):\n",
- " P_1_sat = math.exp(A_1 - B_1/(t + C_1));\n",
- " P_2_sat = math.exp(A_2 - B_2/(t + C_2));\n",
- " P_net = x_1*P_1_sat + x_2*P_2_sat;\n",
- " fault=abs(P_net - P);\n",
- " t = t - 0.1;\n",
- "\n",
- "print \" The bubble point temperature is %f C\"%(t);\n",
- "\n",
- "\t\t\t# Now let us determine dew point temperature for y_1 = 0.5, and P = 90 kPa\n",
- "y_1 = 0.5;\t\t\t# Equimolar mixture\n",
- "y_2 = 0.5;\n",
- "\n",
- "\t\t\t# 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
- "\t\t\t# Let us statrt with t = 104.07\n",
- "t_old = 104.07;\n",
- "error = 10;\n",
- "while(error>0.3):\n",
- " P_1_sat_prime = math.exp(A_1 - B_1/(t_old + C_1));\n",
- " P_2_sat_prime = math.exp(A_2 - B_2/(t_old + C_2));\n",
- " P_net_prime = 1/(y_1/P_1_sat_prime + y_2/P_2_sat_prime);\n",
- " error=abs(P_net_prime - P);\n",
- " t_old = t_old + 0.1;\n",
- "\n",
- "print \" The dew point temperature is %f C\"%(t_old);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The bubble point temperature is 93.862003 C\n",
- " The dew point temperature is 114.470000 C\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.7 Page Number : 522"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P = 1;\t\t\t#[bar] - Pressure\n",
- "P = P*10**(2);\t\t\t#[kPa]\n",
- "\n",
- "\t\t\t# math.log(P_1_sat) = 13.8594 - 2773.78/(t + 220.07)\n",
- "\t\t\t# math.log(P_2_sat) = 14.0098 - 3103.01/(t + 219.79)\n",
- "\n",
- "\t\t\t# The bubble point equation is\n",
- "\t\t\t# P = x_1*P_1_sat + x_2*P_2_sat;\n",
- "\n",
- "t_1_sat = 2773.78/(13.8594 - math.log(P)) - 220.07;\n",
- "t_2_sat = 3103.01/(14.0098 - math.log(P)) - 219.79;\n",
- "\n",
- "\t\t\t# For x_1 = 0.1\n",
- "\t\t\t# t = x_1_1*t_1_sat + x_2_1*t_2_sat;\n",
- "x_1 = [0.1,0.5,0.9];\n",
- "x_2 = [0,0,0]\n",
- "\n",
- "# Calculations and Results\n",
- "for i in range(3):\n",
- " x_2[i] = 1 - x_1[i];\n",
- " t = x_1[i]*t_1_sat + x_2[i]*t_2_sat;\n",
- " fault = 10;\n",
- " while(fault>0.3):\n",
- " P_1_sat = math.exp(13.8594 - 2773.78/(t + 220.07));\n",
- " P_2_sat = math.exp(14.0098 - 3103.01/(t + 219.79));\n",
- " P_net = x_1[i]*P_1_sat + x_2[i]*P_2_sat;\n",
- " fault=abs(P_net - P);\n",
- " t = t - 0.1;\n",
- " print \" The bubble point temperature for x_1 = %f) is %f C\"%(x_1[i],t);\n",
- "\n",
- "\n",
- "\n",
- "\t\t\t# Now let us determine dew point temperature\n",
- "\t\t\t# 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
- "\n",
- "y_1 = [0.1,0.5,0.9];\n",
- "y_2 = [0,0,0]\n",
- "for j in range(3):\n",
- " y_2[j] = 1 - y_1[j];\n",
- " t_prime = y_1[j]*t_1_sat + y_2[j]*t_2_sat;\n",
- " error = 10;\n",
- " while(error>0.3):\n",
- " P_1_sat = math.exp(13.8594 - 2773.78/(t_prime + 220.07));\n",
- " P_2_sat = math.exp(14.0098 - 3103.01/(t_prime + 219.79));\n",
- " P_net = 1/(y_1[j]/P_1_sat + y_2[j]/P_2_sat);\n",
- " error=abs(P_net - P);\n",
- " t_prime = t_prime + 0.1;\n",
- " \n",
- " print \" The dew point temperature for y_1 = %f is %f C\"%(y_1[j],t_prime);\n",
- "\n",
- "\n",
- "\t\t\t#Therefore\n",
- "print \" The temperature range for z_1 = 0.1 which two phase exist is 105.61 C to 108.11 C\";\n",
- "print \" The temperature range for z_1 = 0.5 which two phase exist is 91.61 C to 98.40 C\";\n",
- "print \" The temperature range for z_1 = 0.9 which two phase exist is 81.71 C to 84.51 C\";\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The bubble point temperature for x_1 = 0.100000) is 105.605549 C\n",
- " The bubble point temperature for x_1 = 0.500000) is 91.607993 C\n",
- " The bubble point temperature for x_1 = 0.900000) is 81.710437 C\n",
- " The dew point temperature for y_1 = 0.100000 is 108.105549 C\n",
- " The dew point temperature for y_1 = 0.500000 is 98.407993 C\n",
- " The dew point temperature for y_1 = 0.900000 is 84.510437 C\n",
- " The temperature range for z_1 = 0.1 which two phase exist is 105.61 C to 108.11 C\n",
- " The temperature range for z_1 = 0.5 which two phase exist is 91.61 C to 98.40 C\n",
- " The temperature range for z_1 = 0.9 which two phase exist is 81.71 C to 84.51 C\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.8 Page Number : 524"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "# Variables\n",
- "x_1 = 0.20;\n",
- "x_2 = 0.45;\n",
- "x_3 = 0.35;\n",
- "P = 10;\t\t\t#[atm]\n",
- "P = P*101325*10**(-3);\t\t\t#[kPa]\n",
- "\n",
- "\t\t\t# math.log(P_1_sat) = 13.7713 - 1892.47/(t + 248.82)\n",
- "\t\t\t# math.log(P_2_sat) = 13.7224 - 2151.63/(t + 236.91)\n",
- "\t\t\t# math.log(P_3_sat) = 13.8183 - 2477.07/(t + 233.21)\n",
- "\n",
- "\t\t\t#(a)\n",
- "\t\t\t# The bubble point equation is\n",
- "\t\t\t# P = x_1*P_1_sat + x_2*P_2_sat + x_3*P_3_sat\n",
- "\n",
- "# Calculations and Results\n",
- "t_1_sat = 1892.47/(13.7713 - math.log(P)) - 248.82;\n",
- "t_2_sat = 2151.63/(13.7224 - math.log(P)) - 236.91;\n",
- "t_3_sat = 2477.07/(13.8183 - math.log(P)) - 233.21;\n",
- "t = x_1*t_1_sat + x_2*t_2_sat + x_3*t_3_sat;\n",
- "\n",
- "fault = 10;\n",
- "while(fault>0.1):\n",
- " P_1_sat = math.exp(13.7713 - 1892.47/(t + 248.82));\n",
- " P_2_sat = math.exp(13.7224 - 2151.63/(t + 236.91));\n",
- " P_3_sat = math.exp(13.8183 - 2477.07/(t + 233.21));\n",
- " P_net = x_1*P_1_sat + x_2*P_2_sat + x_3*P_3_sat;\n",
- " fault=abs(P_net - P);\n",
- " t = t - 0.003;\n",
- "\n",
- "BPT = t;\n",
- "print \" a).The bubble point temperature is %f C\"%(BPT);\n",
- "\n",
- "\t\t\t# (b)\n",
- "\t\t\t# Now let us determine dew point temperature for y_1 = 0.5, and P = 90 kPa\n",
- "y_1 = 0.20;\n",
- "y_2 = 0.45;\n",
- "y_3 = 0.35;\n",
- "\n",
- "\t\t\t# 1/P = y_1/P_1_sat + y_2/P_2_sat + y_3/P_3_sat\n",
- "\n",
- "t_old = 90;\t\t\t#[C]\n",
- "error = 10;\n",
- "while(error>0.1):\n",
- " P_1_sat_prime = math.exp(13.7713 - 1892.47/(t_old + 248.82));\n",
- " P_2_sat_prime = math.exp(13.7224 - 2151.63/(t_old + 236.91));\n",
- " P_3_sat_prime = math.exp(13.8183 - 2477.07/(t_old + 233.21));\n",
- " P_net_prime = 1/(y_1/P_1_sat_prime + y_2/P_2_sat_prime + y_3/P_3_sat_prime);\n",
- " error=abs(P_net_prime - P);\n",
- " t_old = t_old + 0.003;\n",
- "\n",
- "DPT = t_old;\n",
- "print \" b).The dew point temperature is %f C\"%(DPT);\n",
- "\n",
- "\t\t\t# (c)\n",
- "\t\t\t# For the given composition and pressure the two phase region exists in the temperature range of DPT and BPT\n",
- "\t\t\t# Therefore at 82 C two phase exists\n",
- "\t\t\t# At 82 C and P = 1013.25 kPa pressure\n",
- "T_c = 82;\t\t\t#[C]\n",
- "P_c = 1013.25;\t\t\t#[kPa]\n",
- "z_1 = 0.20;\n",
- "z_2 = 0.45;\n",
- "z_3 = 0.35;\n",
- "\n",
- "P_1_sat_c = math.exp(13.7713 - 1892.47/(T_c + 248.82));\n",
- "P_2_sat_c = math.exp(13.7224 - 2151.63/(T_c + 236.91));\n",
- "P_3_sat_c = math.exp(13.8183 - 2477.07/(T_c + 233.21));\n",
- "\n",
- "K_1 = P_1_sat_c/P_c;\n",
- "K_2 = P_2_sat_c/P_c;\n",
- "K_3 = P_3_sat_c/P_c;\n",
- "\n",
- "\t\t\t# We have to find such a V that the following equation is satisfied.\n",
- "\t\t\t# summation(y_i) = K_i*z_i/(1-V+V*K_i) = 1\n",
- "\t\t\t# K_1*z_1/(1-V+V*K_1) + K_2*z_2/(1-V+V*K_2) + K_3*z_3/(1-V+V*K_3) = 1\n",
- "\n",
- "def f1(V): \n",
- "\t return K_1*z_1/(1-V+V*K_1) + K_2*z_2/(1-V+V*K_2) + K_3*z_3/(1-V+V*K_3)-1\n",
- "V = fsolve(f1,0.4)\n",
- "\n",
- "\t\t\t# Therefore now we have\n",
- "y_1_c = K_1*z_1/(1-V+V*K_1);\n",
- "y_2_c = K_2*z_2/(1-V+V*K_2);\n",
- "y_3_c = K_3*z_3/(1-V+V*K_3);\n",
- "x_1_c = y_1_c/K_1;\n",
- "x_2_c = y_2_c/K_2;\n",
- "x_3_c = y_3_c/K_3;\n",
- "\n",
- "print \" c).The proportion of vapour is given by V = %f\"%(V);\n",
- "print \" The composition of vapour foemed is given by y_1 = %f y_2 = %f and y_3 = %f \"%(y_1_c,y_2_c,y_3_c);\n",
- "print \" The composition of liquid formed is given by x_1 = %f x_2 = %f and x_3 = %f \"%(x_1_c,x_2_c,x_3_c);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The bubble point temperature is 71.833954 C\n",
- " b).The dew point temperature is 97.254000 C\n",
- " c).The proportion of vapour is given by V = 0.332143\n",
- " The composition of vapour foemed is given by y_1 = 0.365018 y_2 = 0.466574 and y_3 = 0.168408 \n",
- " The composition of liquid formed is given by x_1 = 0.117932 x_2 = 0.441757 and x_3 = 0.440311 \n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.9 Page Number : 526"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "# Variables\n",
- "T = 27;\t\t\t#[C] - Temperature\n",
- "z_1 = 0.4;\n",
- "z_2 = 0.3;\n",
- "z_3 = 0.3;\n",
- "\n",
- "\t\t\t# math.log(P_sat) = A - B/(t + C)\n",
- "\n",
- "\t\t\t# For propane\n",
- "A_1 = 13.7713;\n",
- "B_1 = 1892.47;\n",
- "C_1 = 248.82;\n",
- "\t\t\t# For i-butane\n",
- "A_2 = 13.4331;\n",
- "B_2 = 1989.35;\n",
- "C_2 = 236.84;\n",
- "\t\t\t# For n-butane\n",
- "A_3 = 13.7224;\n",
- "B_3 = 2151.63;\n",
- "C_3 = 236.91;\n",
- "\n",
- "\t\t\t#(a)\n",
- "\t\t\t# The pressure range for the existence of two phase region lies between dew point and bubble point pressures.\n",
- "\t\t\t# At the dew point the whole feed lies in the vapour phase and a drop of liquid is formed, therefore\n",
- "y_1 = z_1;\n",
- "y_2 = z_2;\n",
- "y_3 = z_3;\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# At 27 C,\n",
- "P_1_sat = math.exp(A_1 - B_1/(T + C_1));\n",
- "P_2_sat = math.exp(A_2 - B_2/(T + C_2));\n",
- "P_3_sat = math.exp(A_3 - B_3/(T + C_3));\n",
- "\n",
- "\t\t\t# The dew point pressure is given by\n",
- "P_1 = 1/(y_1/P_1_sat + y_2/P_2_sat + y_3/P_3_sat); \n",
- "\n",
- "\t\t\t# At the bubble point the whole feed lies in the liquid phase and an infinitesimal amount of vapour is formed, therefore\n",
- "x_1 = z_1;\n",
- "x_2 = z_2;\n",
- "x_3 = z_3;\n",
- "\n",
- "\t\t\t# The bubble point pressure is given by\n",
- "P_2 = x_1*P_1_sat + x_2*P_2_sat + x_3*P_3_sat;\n",
- "\n",
- "print \" a).The two phase region exists between %f and %f kPa\"%(P_1,P_2);\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t# The mean of the two-phase pressure range is given by\n",
- "P_mean = (P_1 + P_2)/2;\n",
- "\n",
- "\t\t\t# Now let us calculate the K values of the components\n",
- "K_1 = P_1_sat/P_mean;\n",
- "K_2 = P_2_sat/P_mean;\n",
- "K_3 = P_3_sat/P_mean;\n",
- "\n",
- "\t\t\t# summation of y_i = 1, gives\n",
- "\t\t\t# (K_1*z_1)/(1-V-K_1*V) + (K_2*z_2)/(1-V-K_2*V) + (K_3*z_3)/(1-V-K_3*V) = 1\n",
- "\t\t\t# Solving we get\n",
- "def f(V): \n",
- "\t return (K_1*z_1)/(1-V+K_1*V) + (K_2*z_2)/(1-V+K_2*V) + (K_3*z_3)/(1-V+K_3*V)-1\n",
- "V = fsolve(f,0.1)\n",
- "\n",
- "y_1_prime = (z_1*K_1)/(1-V+K_1*V);\n",
- "\n",
- "print \" b).The mole fraction of propane in vapour phase is %f whereas in the feed is %f and fraction of vapour in the system is %f\"%(y_1_prime,z_1,V);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The two phase region exists between 421.886904 and 588.370027 kPa\n",
- " b).The mole fraction of propane in vapour phase is 0.559489 whereas in the feed is 0.400000 and fraction of vapour in the system is 0.425313\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.10 Page Number : 527"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 50;\t\t\t#[C] - Temperature\n",
- "P = 64;\t\t\t#[kPa] - Pressure\n",
- "z_1 = 0.7;\n",
- "z_2 = 0.3;\n",
- "\n",
- "# math.log(P_sat) = A - B/(t + C)\n",
- "\n",
- "# For acetone\n",
- "A_1 = 14.37824;\n",
- "B_1 = 2787.498;\n",
- "C_1 = 229.664;\n",
- "# For acetonitrile\n",
- "A_2 = 14.88567;\n",
- "B_2 = 3413.099;\n",
- "C_2 = 250.523;\n",
- "\n",
- "# Calculations\n",
- "# At 50 C,\n",
- "P_1_sat = math.exp(A_1 - B_1/(T + C_1));\t\t\t#[kPa]\n",
- "P_2_sat = math.exp(A_2 - B_2/(T + C_2));\t\t\t#[kPa]\n",
- "\n",
- "# Now let us calculate the K values of the components\n",
- "K_1 = P_1_sat/P;\n",
- "K_2 = P_2_sat/P;\n",
- "\n",
- "# summation of y_i = 1, gives\n",
- "# (K_1*z_1)/(1-V-K_1*V) + (K_2*z_2)/(1-V-K_2*V) = 1\n",
- "# Solving we get\n",
- "def f(V): \n",
- " return (K_1*z_1)/(1-V+K_1*V) + (K_2*z_2)/(1-V+K_2*V) -1\n",
- "V = fsolve(f,0.1)\n",
- "L = 1 - V;\n",
- "# Therefore\n",
- "y_1 = (K_1*z_1)/(1-V+K_1*V);\n",
- "y_2 = (K_2*z_2)/(1-V+K_2*V);\n",
- "\n",
- "x_1 = y_1/K_1;\n",
- "x_2 = y_2/K_2;\n",
- "\n",
- "# Results\n",
- "print \" The value of V = %f\"%(V);\n",
- "print \" The value of L = %f\"%(L);\n",
- "print \" The liquid phase composition is x_1 = %f and x_2 = %f\"%(x_1,x_2);\n",
- "print \" The vapour phase composition is y_1 = %f and y_2 = %f\"%(y_1,y_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of V = 0.450368\n",
- " The value of L = 0.549632\n",
- " The liquid phase composition is x_1 = 0.619963 and x_2 = 0.380037\n",
- " The vapour phase composition is y_1 = 0.797678 and y_2 = 0.202322\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.11 Page Number : 528"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P = 12.25*101325*10**(-3);\t\t\t#[kPa]\n",
- "z_1 = 0.8;\n",
- "z_2 = 1 - z_1;\n",
- "V = 0.4;\n",
- "# math.log(P_1_sat) = 13.7713 - 2892.47/(T + 248.82)\n",
- "# math.log(P_2_sat) = 13.7224 - 2151.63/(T + 236.91)\n",
- "\n",
- "# P_1_sat = math.exp(13.7713 - 21892.47/(T + 248.82));\n",
- "# P_2_sat = math.exp(13.7224 - 2151.63/(T + 236.91));\n",
- "\n",
- "# Let the total mixture be 1 mol\n",
- "# We have to assume a temperature such that,\n",
- "# y_1 + y_2 = (K_1*z_1)/(1-V-K_1*V) + (K_2*z_2)/(1-V-K_2*V) = 1\n",
- "\n",
- "# To assume a temperature we have to determine the BPT and DPT and take a temperature in between the range BPT to DPT\n",
- "\n",
- "# At the bubble point the whole feed lies in the liquid phase and an infinitesimal amount of vapour is formed, therefore\n",
- "x_1 = z_1;\n",
- "x_2 = z_2;\n",
- "\n",
- "# The bubble point pressure is given by\n",
- "# P = x_1*(math.exp(13.7713 - 21892.47/(T + 248.82))) + x_2*(math.exp(13.7224 - 2151.63/(T + 236.91)));\n",
- "\n",
- "# Calculations\n",
- "def f(T): \n",
- "\t return x_1*(math.exp(13.7713 - 1892.47/(T + 248.82))) + x_2*(math.exp(13.7224 - 2151.63/(T + 236.91))) - P\n",
- "T_1 = fsolve(f,0.1)\n",
- "BPT = T_1;\n",
- "\n",
- "# At the dew point the whole feed lies in the vapour phase and a drop of liquid is formed, therefore\n",
- "y_1 = z_1;\n",
- "y_2 = z_2;\n",
- "\n",
- "# The dew point equation is given by\n",
- "# 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
- "def f1(T): \n",
- "\t return 1/(y_1/(math.exp(13.7713 - 1892.47/(T + 248.82))) + y_2/(math.exp(13.7224 - 2151.63/(T + 236.91)))) - P\n",
- "T_2 = fsolve(f1,0.1)\n",
- "DPT = T_2;\n",
- "\n",
- "T = 47;\t\t\t#[C]\n",
- "error = 10;\n",
- "while(error>0.001):\n",
- " P_1_sat = math.exp(13.7713 - 1892.47/(T + 248.82));\n",
- " P_2_sat = math.exp(13.7224 - 2151.63/(T + 236.91));\n",
- " K_1 = P_1_sat/P;\n",
- " K_2 = P_2_sat/P;\n",
- " y1 = (K_1*z_1)/(1-V+K_1*V);\n",
- " y2 = (K_2*z_2)/(1-V+K_2*V);\n",
- " y = y1 + y2;\n",
- " error=abs(y - 1);\n",
- " T = T - 0.0001;\n",
- "\n",
- "# Results\n",
- "print \" The temperature when 40 mol of mixture is in the vapour is %f C\"%(T);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The temperature when 40 mol of mixture is in the vapour is 45.333000 C\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.12 Page Number : 529"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 105;\t\t\t#[C]\n",
- "P = 1.5;\t\t\t#[atm]\n",
- "P = P*101325*10**(-3);\t\t\t#[kPa]\n",
- "z = [0.4,0.3667,0.2333];\t\t\t# Feed composition\n",
- "x = [0.3,0.3,0.4];\t\t\t# Equilibrium liquid phase composition\n",
- "y = [0.45,0.40,0.15];\t\t\t# Equilibrium vapour phase composition\n",
- "\n",
- "# From the material balance equation of component 1, we get\n",
- "# (L + V)*z_1 = L*x_1 + V*y_1\n",
- "\n",
- "# Since total moles are one, therefore L + V = 1 and thus\n",
- "# z_1 = L*x_1 + (1-L)*y_1\n",
- "# Calculations and Results\n",
- "for i in range(3):\n",
- " L = (z[i] - y[i])/(x[i] - y[i]);\n",
- " V = 1 - L;\n",
- " print \" The number of moles in liquid phase z = %f is given by L = %f\"%(z[i],L);\n",
- " print \" The number of moles in vapour phase z = %f is given by V = %f\"%(z[i],V);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The number of moles in liquid phase z = 0.400000 is given by L = 0.333333\n",
- " The number of moles in vapour phase z = 0.400000 is given by V = 0.666667\n",
- " The number of moles in liquid phase z = 0.366700 is given by L = 0.333000\n",
- " The number of moles in vapour phase z = 0.366700 is given by V = 0.667000\n",
- " The number of moles in liquid phase z = 0.233300 is given by L = 0.333200\n",
- " The number of moles in vapour phase z = 0.233300 is given by V = 0.666800\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.13 Page Number : 530"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 90;\t\t\t#[C]\n",
- "P = 1;\t\t\t#[atm]\n",
- "P = P*101325*10**(-3);\t\t\t#[kPa]\n",
- "z_1 = [0.1,0.5,0.8];\n",
- "\n",
- "# Calculations\n",
- "# math.log(P_1_sat) = 13.8594 - 2773.78/(t + 220.07)\n",
- "# math.log(P_2_sat) = 14.0098 - 3103.01/(t + 219.79)\n",
- "\n",
- "#At T = 90 C\n",
- "P_1_sat = math.exp(13.8594 - 2773.78/(T + 220.07));\n",
- "P_2_sat = math.exp(14.0098 - 3103.01/(T + 219.79));\n",
- "K_1 = P_1_sat/P;\n",
- "K_2 = P_2_sat/P;\n",
- "\n",
- "# For z_1 = 0.1\n",
- "# y1 = (K_1*z_1(i))/(1-V+K_1*V);\n",
- "# y2 = (K_2*z_2)/(1-V+K_2*V);\n",
- "# We do not get a value between 0 and 1 such that, y = y1 + y2 = 1; \n",
- "# This means that at z_1 = 0.1 two phases do not exist.\n",
- "# At given temperature and pressure, let us determine the equilibrium liquid and vapour phase compositions\n",
- "\n",
- "x_1 = (P - P_2_sat)/(P_1_sat - P_2_sat);\n",
- "y_1 = (x_1*P_1_sat)/(P);\n",
- "\n",
- "# For two phase region to exist at 90 C and 101.325 kPa,z_1 sholud lie between x_1 and y_1\n",
- "\n",
- "# Results\n",
- "print \" For two phase region to exist at 90 C and 101.325 kPa, z_1 sholud lie between %f and %f\"%(x_1,y_1);\n",
- "print \" For z_1 = 0.1 and z_1 = 0.5 only liquid phase exists V = 0.\"\n",
- "print \" For z_1 = 0.8 only vapour exists V = 1.\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " For two phase region to exist at 90 C and 101.325 kPa, z_1 sholud lie between 0.574884 and 0.772458\n",
- " For z_1 = 0.1 and z_1 = 0.5 only liquid phase exists V = 0.\n",
- " For z_1 = 0.8 only vapour exists V = 1.\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.14 Page Number : 531"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from numpy import zeros\n",
- "\n",
- "# Variables\n",
- "T = 90;\t\t\t#[C]\n",
- "P = 1;\t\t\t#[atm]\n",
- "P = P*101325*10**(-3);\t\t\t#[kPa]\n",
- "z_1 = [0.1,0.5,0.8];\n",
- "\n",
- "# math.log(P_1_sat) = 13.8594 - 2773.78/(t + 220.07)\n",
- "# math.log(P_2_sat) = 14.0098 - 3103.01/(t + 219.79)\n",
- "\n",
- "# Calculations and Results\n",
- "#(a)\n",
- "#At T = 90 C\n",
- "P_1_sat = math.exp(13.8594 - 2773.78/(T + 220.07));\n",
- "P_2_sat = math.exp(14.0098 - 3103.01/(T + 219.79));\n",
- "K_1 = P_1_sat/P;\n",
- "\n",
- "x_1 = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0];\n",
- "P_prime = zeros(11);\n",
- "x_2 = zeros(11);\n",
- "y_1 = zeros(11);\n",
- "\n",
- "print \" a.\";\n",
- "print \" x_1 \\t\\t P \\t\\t y_1 \";\n",
- "\n",
- "for i in range(11):\n",
- " x_2[i] = 1 - x_1[i];\n",
- " P_prime[i] = x_1[i]*P_1_sat + x_2[i]*P_2_sat;\n",
- " y_1[i] = (x_1[i]*P_1_sat)/P_prime[i];\n",
- " print \" %f \\t %f \\t %f \"%(x_1[i],P_prime[i],y_1[i]);\n",
- "\n",
- "\t\t\t#(b)\n",
- "T_1_sat = 2773.78/(13.8594-math.log(P)) - 220.07;\t\t\t#[C]\n",
- "T_2_sat = 3103.01/(14.0098-math.log(P)) - 219.79;\t\t\t#[C]\n",
- "\n",
- "T_prime = [110.62,107,104,101,98,95,92,89,86,83,80.09];\n",
- "\n",
- "P1_sat = zeros(11);\n",
- "P2_sat = zeros(11);\n",
- "x_1 = zeros(11);\n",
- "y_1 = zeros(11);\n",
- "\n",
- "print \" b.\";\n",
- "print \" TC \\t\\t P_1_sat kPa \\t\\t P_2_sat kPa \\t\\t x_1 \\t\\t y_1 \";\n",
- "\n",
- "for j in range(11):\n",
- " P1_sat[j] = math.exp(13.8594 - 2773.78/(T_prime[j] + 220.07));\n",
- " P2_sat[j] = math.exp(14.0098 - 3103.01/(T_prime[j] + 219.79));\n",
- " x_1[j] = (P-P2_sat[j])/(P1_sat[j]-P2_sat[j]);\n",
- " y_1[j] = (x_1[j]*P1_sat[j])/P;\n",
- " print \" %f \\t %f \\t %f \\t %f \\t %f \"%(T_prime[j],P1_sat[j],P2_sat[j],x_1[j],y_1[j]);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a.\n",
- " x_1 \t\t P \t\t y_1 \n",
- " 0.000000 \t 54.233834 \t 0.000000 \n",
- " 0.100000 \t 62.425251 \t 0.218098 \n",
- " 0.200000 \t 70.616668 \t 0.385597 \n",
- " 0.300000 \t 78.808085 \t 0.518277 \n",
- " 0.400000 \t 86.999502 \t 0.625971 \n",
- " 0.500000 \t 95.190920 \t 0.715131 \n",
- " 0.600000 \t 103.382337 \t 0.790162 \n",
- " 0.700000 \t 111.573754 \t 0.854176 \n",
- " 0.800000 \t 119.765171 \t 0.909433 \n",
- " 0.900000 \t 127.956588 \t 0.957615 \n",
- " 1.000000 \t 136.148005 \t 1.000000 \n",
- " b.\n",
- " TC \t\t P_1_sat kPa \t\t P_2_sat kPa \t\t x_1 \t\t y_1 \n",
- " 110.620000 \t 237.827187 \t 101.332530 \t -0.000055 \t -0.000129 \n",
- " 107.000000 \t 216.742019 \t 91.320455 \t 0.079767 \t 0.170629 \n",
- " 104.000000 \t 200.376847 \t 83.629571 \t 0.151570 \t 0.299740 \n",
- " 101.000000 \t 184.975751 \t 76.460482 \t 0.229134 \t 0.418300 \n",
- " 98.000000 \t 170.500977 \t 69.787769 \t 0.313139 \t 0.526923 \n",
- " 95.000000 \t 156.915208 \t 63.586616 \t 0.404360 \t 0.626206 \n",
- " 92.000000 \t 144.181607 \t 57.832824 \t 0.503680 \t 0.716718 \n",
- " 89.000000 \t 132.263848 \t 52.502830 \t 0.612106 \t 0.799008 \n",
- " 86.000000 \t 121.126156 \t 47.573718 \t 0.730789 \t 0.873601 \n",
- " 83.000000 \t 110.733338 \t 43.023234 \t 0.861050 \t 0.941001 \n",
- " 80.090000 \t 101.331285 \t 38.950606 \t 0.999899 \t 0.999961 \n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.15 Page Number : 533"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P_1_sat = 79.80;\t\t\t#[kPa]\n",
- "P_2_sat = 40.45;\t\t\t#[kPa]\n",
- "\n",
- "#(1)\n",
- "T = 373.15;\t\t\t#[K]\n",
- "x_1 = 0.05;\n",
- "x_2 = 1 - x_1;\n",
- "Y1 = math.exp(0.95*x_2**(2));\n",
- "Y2 = math.exp(0.95*x_1**(2));\n",
- "\n",
- "# Calculations and Results\n",
- "# The total pressure of the system is given by\n",
- "P = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;\t\t\t#[kPa]\n",
- "y_1 = x_1*Y1*P_1_sat/P;\n",
- "y_2 = x_2*Y2*P_2_sat/P;\n",
- "\n",
- "print \" 1).The first bubble is formed at %f kPa and the composition y_1 = %f\"%(P,y_1);\n",
- "\n",
- "#(2)\n",
- "T = 373.15;\t\t\t#[K]\n",
- "y_1_prime = 0.05;\n",
- "y_2_prime = 1 - y_1_prime;\n",
- "\n",
- "# Let us assume a value of x_1,\n",
- "x_1_prime = 0.0001;\n",
- "\n",
- "error = 10;\n",
- "while(error>0.001):\n",
- " x_2_prime = 1 - x_1_prime;\n",
- " Y1_prime = math.exp(0.95*x_2_prime**(2));\n",
- " Y2_prime = math.exp(0.95*x_1_prime**(2));\n",
- " P_prime = x_1_prime*Y1_prime*P_1_sat + x_2_prime*Y2_prime*P_2_sat;\n",
- " x_1 = (y_1_prime*P_prime)/(Y1_prime*P_1_sat);\n",
- " error=abs(x_1_prime - x_1);\n",
- " x_1_prime = x_1_prime + 0.00001;\n",
- "\n",
- "P_2 = x_1_prime*Y1_prime*P_1_sat + x_2_prime*Y2_prime*P_2_sat;\n",
- "\n",
- "print \" 2).The first drop is formed at %f kPa and has the composition x_1 = %f\"%(P_2,x_1_prime);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The first bubble is formed at 47.923166 kPa and the composition y_1 = 0.196237\n",
- " 2).The first drop is formed at 41.974204 kPa and has the composition x_1 = 0.009370\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.16 Page Number : 534"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "T = 78.15;\t\t\t#[C]\n",
- "P_1_sat = 755;\t\t\t#[mm Hg]\n",
- "P_2_sat = 329;\t\t\t#[mm Hg]\n",
- "\n",
- "z_1 = 0.3;\n",
- "V = 0.5;\n",
- "\n",
- "# math.log(Y1) = 0.845/(1 + 0.845*(x_1/x_2))**(2)\n",
- "# math.log(Y2) = 1/(1 + 1.183*(x_2/x_1))**(2)\n",
- "\n",
- "# A value of x_1 is to determined for which V = 0.5\n",
- "# Let us assume a value of x_1, say x_1 = 0.150\n",
- "x_1 = 0.150;\n",
- "\n",
- "# Calculations\n",
- "error = 10;\n",
- "while(error>0.001):\n",
- " x_2 = 1 - x_1;\n",
- " Y1 = math.exp(0.845/(1 + 0.845*(x_1/x_2))**(2));\n",
- " Y2 = math.exp(1/(1 + 1.183*(x_2/x_1))**(2));\n",
- " P = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;\n",
- " y_1 = (x_1*Y1*P_1_sat)/P;\n",
- " V_prime = (z_1 - x_1)/(y_1 - x_1);\n",
- " error=abs(V_prime - V);\n",
- " x_1 = x_1 + 0.00001;\n",
- "\n",
- "P_prime = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;\t\t\t#[mm hg]\n",
- "\n",
- "# At x_1 , V = 0.5, \n",
- "# Therefore when the mixture is 50 % vaporized at 78.15 C the mole fraction of component 1 in the liquid phase is x_1 and the system pressure is P_prime\n",
- "\n",
- "# Results\n",
- "print \" The required pressure is %f mm Hg\"%(P_prime);\n",
- "print \" and the mole fraction of component 1 in the liquid phase for this pressure is x_1 = %f\"%(x_1);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The required pressure is 505.838606 mm Hg\n",
- " and the mole fraction of component 1 in the liquid phase for this pressure is x_1 = 0.157650\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.17 Page Number : 536"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.stats import linregress\n",
- "\n",
- "# Variables\n",
- "T = 25;\t\t\t#[C] - Temperature\n",
- "P = [118.05,124.95,137.90,145.00,172.90,207.70,227.70,237.85,253.90,259.40,261.10,262.00,258.70,252.00,243.80];\t\t\t#[mm Hg]\n",
- "x_1 = [0.0115,0.0160,0.0250,0.0300,0.0575,0.1125,0.1775,0.2330,0.4235,0.5760,0.6605,0.7390,0.8605,0.9250,0.9625];\n",
- "y_1 = [0.1810,0.2250,0.3040,0.3450,0.4580,0.5670,0.6110,0.6325,0.6800,0.7050,0.7170,0.7390,0.8030,0.8580,0.9160];\n",
- "\n",
- "# Pressure value for which x_1 = y_1 = 0, corresponds to P_2_sat,therefore\n",
- "P_2_sat = 97.45;\t\t\t#[mm Hg]\n",
- "# Pressure value for which x_1 = y_1 = 1, corresponds to P_1_sat,therefore\n",
- "P_1_sat = 230.40;\t\t\t#[mm Hg]\n",
- "\n",
- "x_2 = zeros(15);\n",
- "y_2 = zeros(15);\n",
- "Y1 = zeros(15);\n",
- "Y2 = zeros(15);\n",
- "GE_RT = zeros(15);\n",
- "x1x2_GE_RT = zeros(15);\n",
- "\n",
- "# Calculations\n",
- "for i in range(15):\n",
- " x_2[i] = 1 - x_1[i];\n",
- " y_2[i] = 1 - y_1[i];\n",
- " Y1[i] = (y_1[i]*P[i])/(x_1[i]*P_1_sat);\n",
- " Y2[i] = (y_2[i]*P[i])/(x_2[i]*P_2_sat);\n",
- " GE_RT[i] = x_1[i]*math.log(Y1[i]) + x_2[i]*math.log(Y2[i]);\t\t\t# G_E/(R*T)\n",
- " x1x2_GE_RT[i] = (x_1[i]*x_2[i])/GE_RT[i];\n",
- "\n",
- "\n",
- "#[M,N,sig]=reglin(x_1,x1x2_GE_RT);\n",
- "M,N,sig,d,e = linregress(x_1,x1x2_GE_RT);\n",
- "\n",
- "# Linear regression between x_1 and x_1*x_2/(G_E/R*T) gives intercept = N and slope = M\n",
- "\n",
- "# van Laar equation is x_1*x_2/(G_E/R*T) = 1/A + (1/B - 1/A)\n",
- "# 1/A = N\n",
- "A = 1/N;\n",
- "B = 1/(M + 1/A);\n",
- "\n",
- "# Results\n",
- "print \" The value of Van Laar coefficient A = %f\"%(A);\n",
- "print \" The value of Van Laar coefficient B = %f\"%(B);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of Van Laar coefficient A = 2.270624\n",
- " The value of Van Laar coefficient B = 1.781821\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.18 Page Number : 541"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "# Variables\n",
- "T = 343.15;\t\t\t#[K] - Temperature\n",
- "# At 343.15 K\n",
- "# math.log(Y1) = 0.95*x_2**(2)\n",
- "# math.log(Y2) = 0.95*x_1**(2)\n",
- "P_1_sat = 79.80;\t\t\t#[kPa]\n",
- "P_2_sat = 40.50;\t\t\t#[kPa]\n",
- "\n",
- "# Calculations\n",
- "# At x_1 = 0,\n",
- "Y1_infinity = math.exp(0.95);\n",
- "alpha_12_x0 = (Y1_infinity*P_1_sat)/(P_2_sat);\n",
- "# At x_1 = 1,\n",
- "Y2_infinity = math.exp(0.95);\n",
- "alpha_12_x1 = (P_1_sat)/(Y2_infinity*P_2_sat);\n",
- "\n",
- "# Within the range alpha_12_x0 and alpha_12_x1, the relative volatility continuously decrease and thus a value of 1.0 is obtained and thus azeotrope is formed.\n",
- "# At azeotrope, Y1*P1_sat = Y2*P2_sat\n",
- "# Y2/Y1 = P_1_sat/P_2_sat\n",
- "# Taking math.logarithm of both sides we get\n",
- "# math.log(Y2) - math.log(Y1) = math.log(P_1_sat/P_2_sat)\n",
- "# 0.95*x_1**(2) - 0.95*x_2**(2) = math.log(P_1_sat/P_2_sat)\n",
- "# Solving the above equation\n",
- "def f(x_1): \n",
- "\t return 0.95*x_1**(2) - 0.95*(1-x_1)**(2) - math.log(P_1_sat/P_2_sat)\n",
- "x_1 = fsolve(f,0.1)\n",
- "\n",
- "# At x_1\n",
- "x_2 = 1 - x_1;\n",
- "Y1 = math.exp(0.95*x_2**(2));\n",
- "Y2 = math.exp(0.95*x_1**(2));\n",
- "P = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;\t\t\t#[kPa] - Azeotrope pressure\n",
- "y_1 = (x_1*Y1*P_1_sat)/P;\n",
- "\n",
- "# Since x_1 = y_1, (almost equal) ,the above condition is of azeotrope formation\n",
- "\n",
- "# Since alpha_12 is a continuous curve and in between a value of alpha_12 = 1, shall come and at this composition the azeotrope shall get formed.\n",
- "\n",
- "# Results\n",
- "print \" Since alpha_12_x=0 = %f and alpha_12_x=1 = %f \"%(alpha_12_x0,alpha_12_x1);\n",
- "print \" and since alpha_12 is a continuous curve and in between a value of alpha_12 = 1, shall come and at this composition the azeotrope shall get formed.\"\n",
- "print \" The azeotrope composition is x_1 = y_1 = %f\"%(x_1);\n",
- "print \" The azeotrope presssure is %f kPa\"%(P);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Since alpha_12_x=0 = 5.094806 and alpha_12_x=1 = 0.762023 \n",
- " and since alpha_12 is a continuous curve and in between a value of alpha_12 = 1, shall come and at this composition the azeotrope shall get formed.\n",
- " The azeotrope composition is x_1 = y_1 = 0.856959\n",
- " The azeotrope presssure is 81.366308 kPa\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.19 Page Number : 541"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 45;\t\t\t#[C] - Temperature\n",
- "\n",
- "x_1 = [0.0455,0.0940,0.1829,0.2909,0.3980,0.5069,0.5458,0.5946,0.7206,0.8145,0.8972,0.9573];\n",
- "y_1 = [0.1056,0.1818,0.2783,0.3607,0.4274,0.4885,0.5098,0.5375,0.6157,0.6913,0.7869,0.8916];\n",
- "P = [31.957,33.553,35.285,36.457,36.996,37.068,36.978,36.778,35.792,34.372,32.331,30.038];\n",
- "\n",
- "\t\t\t# Pressure value for which x_1 = y_1 = 0, corresponds to P_2_sat,therefore\n",
- "P_2_sat = 29.819;\t\t\t#[kPa]\n",
- "\t\t\t# Pressure value for which x_1 = y_1 = 1, corresponds to P_1_sat,therefore\n",
- "P_1_sat = 27.778;\t\t\t#[kPa]\n",
- "\n",
- "x_2 = zeros(12);\n",
- "y_2 = zeros(12);\n",
- "Y1 = zeros(12);\n",
- "Y2 = zeros(12);\n",
- "alpha_12 = zeros(12);\n",
- "GE_RT = zeros(12);\n",
- "x1x2_GE_RT = zeros(12);\n",
- "# Calculations and Results\n",
- "print \" x_1 \\t\\t y_1 \\t P \\t\\t Y1 \\t\\tY2 \\t alpha_12 \\t G_E/RT \\t x1*x2/G_E/RT\";\n",
- "\n",
- "for i in range(12):\n",
- " x_2[i] = 1 - x_1[i];\n",
- " y_2[i] = 1 - y_1[i];\n",
- " Y1[i] = (y_1[i]*P[i])/(x_1[i]*P_1_sat);\n",
- " Y2[i] = (y_2[i]*P[i])/(x_2[i]*P_2_sat);\n",
- " alpha_12[i] = (y_1[i]/x_1[i])/(y_2[i]/x_2[i]);\n",
- " GE_RT[i] = x_1[i]*math.log(Y1[i]) + x_2[i]*math.log(Y2[i]);\t\t\t# G_E/(R*T)\n",
- " x1x2_GE_RT[i] = (x_1[i]*x_2[i])/GE_RT[i];\n",
- " print \" %f\\t %f\\t %f \\t %f \\t %f \\t %f\\t %f \\t%f\"%(x_1[i],y_1[i],P[i],Y1[i],Y2[i],alpha_12[i],GE_RT[i],x1x2_GE_RT[i]);\n",
- "\n",
- "\t\t\t#[M,N,sig]=reglin(x_1,x1x2_GE_RT);\n",
- "M,N,sig,d,e=linregress(x_1,x1x2_GE_RT);\n",
- "\n",
- "\t\t\t# Linear regression between x_1 and x_1*x_2/(G_E/R*T) gives intercept = N and slope = M\n",
- "\n",
- "\t\t\t# Now let us assume the system to follow van Laar activity coefficient model. \n",
- "\t\t\t# x_1*x_2/(G_E/(R*T)) = x_1/B + x_2/A = x_1/B + (1 - x_1)/A = 1/A + (1/B - 1/A)*x_1 = N + M*x_1\n",
- "\n",
- "\t\t\t# 1/A = N\n",
- "A = 1/N;\n",
- "\t\t\t# (1/B - 1/A) = M\n",
- "B = 1/(M + 1/A);\n",
- "\n",
- "print \"\"\n",
- "print \" The value of van Laar parameters are, A = %f and B = %f \"%(A,B);\n",
- "\n",
- "Y1_infinity = math.exp(A);\n",
- "Y2_infinity = math.exp(B);\n",
- "\n",
- "\n",
- "\t\t\t# Azeotrope is formed when maxima ( or mainina) in pressure is observed and relative volatility becomes 1.\n",
- "\t\t\t# This is the case for x_1 between 0.2980 and 0.5458. \n",
- "\t\t\t# The ezeotropr os maximum pressure (and thus minimum boiling) because at azeotrope the system pressure is greater than vapour pressure of pure components.\n",
- "\n",
- "\t\t\t# Now let us calculate the azeotrope composition.\n",
- "\t\t\t# At azeotrope, Y1*P1_sat = Y2*P2_sat\n",
- "\t\t\t# math.log(Y1/Y2) = math.log(P_2_sat/P_1_sat)\n",
- "\t\t\t# From van Laar model we get\n",
- "\t\t\t# math.log(P_2_sat/P_1_sat) = (A*B**(2)*2*x_2**(2))/(A*x_1 + B*x_2)**(2) + (B*A**(2)*2*x_1**(2))/(A*x_1 + B*x_2)**(2)\n",
- "\t\t\t# Solving the above equation\n",
- "def f(x_1): \n",
- "\t return math.log(P_2_sat/P_1_sat) - (A*B**(2)*(1-x_1)**(2))/(A*x_1 + B*(1-x_1))**(2) + (B*A**(2)*x_1**(2))/(A*x_1 + B*(1-x_1))**(2)\n",
- "x_1 = fsolve(f,0.1)\n",
- "\n",
- "print \" The azeotrope composition is given by x_1 = y_1 = %f\"%(x_1);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " x_1 \t\t y_1 \t P \t\t Y1 \t\tY2 \t alpha_12 \t G_E/RT \t x1*x2/G_E/RT\n",
- " 0.045500\t 0.105600\t 31.957000 \t 2.670039 \t 1.004220 \t 2.476833\t 0.048705 \t0.891698\n",
- " 0.094000\t 0.181800\t 33.553000 \t 2.336127 \t 1.016177 \t 2.141582\t 0.094298 \t0.903137\n",
- " 0.182900\t 0.278300\t 35.285000 \t 1.932808 \t 1.045150 \t 1.722733\t 0.156610 \t0.954268\n",
- " 0.290900\t 0.360700\t 36.457000 \t 1.627355 \t 1.102263 \t 1.375325\t 0.210697 \t0.979023\n",
- " 0.398000\t 0.427400\t 36.996000 \t 1.430228 \t 1.180094 \t 1.129007\t 0.242105 \t0.989635\n",
- " 0.506900\t 0.488500\t 37.068000 \t 1.285998 \t 1.289486 \t 0.929034\t 0.252871 \t0.988458\n",
- " 0.545800\t 0.509800\t 36.978000 \t 1.243394 \t 1.338371 \t 0.865446\t 0.251278 \t0.986567\n",
- " 0.594600\t 0.537500\t 36.778000 \t 1.196853 \t 1.407094 \t 0.792366\t 0.245302 \t0.982671\n",
- " 0.720600\t 0.615700\t 35.792000 \t 1.100930 \t 1.650961 \t 0.621199\t 0.209369 \t0.961630\n",
- " 0.814500\t 0.691300\t 34.372000 \t 1.050218 \t 1.918247 \t 0.510015\t 0.160745 \t0.939933\n",
- " 0.897200\t 0.786900\t 32.331000 \t 1.020818 \t 2.247586 \t 0.423097\t 0.101740 \t0.906550\n",
- " 0.957300\t 0.891600\t 30.038000 \t 1.007145 \t 2.557286 \t 0.366877\t 0.046909 \t0.871410\n",
- "\n",
- " The value of van Laar parameters are, A = 1.049085 and B = 1.064514 \n",
- " The azeotrope composition is given by x_1 = y_1 = 0.468254\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.20 Page Number : 541"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 25;\t\t\t#[C] - Temperature\n",
- "P_1_sat = 230.4;\t\t\t#[mm Hg]\n",
- "P_2_sat = 97.45;\t\t\t#[mm Hg]\n",
- "Y1_infinity = 8.6;\n",
- "Y2_infinity = 6.6;\n",
- "\n",
- "\t\t\t# Assuming ideal vpour behaviour means that phi = 1 and since system pressure is low, therefore\n",
- "\t\t\t# f_i = P_i_sat \n",
- "\t\t\t# Assuming the activity coefficients to follow van Laar model we get\n",
- "A = math.log(Y1_infinity);\n",
- "B = math.log(Y2_infinity);\n",
- "\n",
- "\t\t\t#math.log(Y1) = A/(1+ (A*x_1)/(B*x_2))**(2)\n",
- "\t\t\t# math.log(Y2) = B/(1+ (B*x_2)/(A*x_1))**(2)\n",
- "\n",
- "x_1 = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9];\n",
- "\n",
- "x_2 = zeros(9);\n",
- "Y1 = zeros(9);\n",
- "Y2 = zeros(9);\n",
- "y1_P = zeros(9);\n",
- "y2_P = zeros(9);\n",
- "P = zeros(9);\n",
- "y_1 = zeros(9);\n",
- "\n",
- "print \" a.\";\n",
- "print \" x_1 \\t\\t Y1 \\t\\t Y2 \\t\\t y1*P \\t\\t y2*P \\t\\t P \\t\\t y_1 \";\n",
- "# Calculations and Results\n",
- "for i in range(9):\n",
- " x_2[i] = 1 - x_1[i];\n",
- " Y1[i] = math.exp(A/(1+ (A*x_1[i])/(B*x_2[i]))**(2));\n",
- " Y2[i] = math.exp(B/(1+ (B*x_2[i])/(A*x_1[i]))**(2));\n",
- " y1_P[i] = x_1[i]*Y1[i]*P_1_sat;\n",
- " y2_P[i] = x_2[i]*Y2[i]*P_2_sat;\n",
- " P[i] = x_1[i]*Y1[i]*P_1_sat + x_2[i]*Y2[i]*P_2_sat;\n",
- " y_1[i] = (x_1[i]*Y1[i]*P_1_sat)/P[i];\n",
- " print \" %f\\t\\t %f\\t\\t %f \\t\\t %f \\t\\t %f \\t\\t %f \\t %f\"%(x_1[i],Y1[i],Y2[i],y1_P[i],y2_P[i],P[i],y_1[i]);\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t# The total system pressure versus x_1 shows a maxima and thus azeotrope is formed by the VLE system\n",
- "\t\t\t# The maxima occurs in the range of x_1 = 0.6 to 0.8, so an azeotrope is formed in this composition range\n",
- "\n",
- "\t\t\t# At the azeotrope point, Y1*P1_sat = Y2*P2_sat\n",
- "\t\t\t# math.log(Y1) - math.log(Y2) = math.log(P_2_sat/P_1_sat)\n",
- "\t\t\t# On putting the values and then solving the above equation we get\n",
- "def f(x_1): \n",
- "\t return A/(1+1.14*x_1/(1-x_1))**(2)- B/(1+0.877*(1-x_1)/x_1)**(2) - math.log(P_2_sat/P_1_sat)\n",
- "x_1_prime = fsolve(f,0.1)\n",
- "\n",
- "\t\t\t# At x_1\n",
- "x_2_prime = 1 - x_1_prime;\n",
- "Y1_prime = math.exp(A/(1+ (A*x_1_prime)/(B*x_2_prime))**(2));\n",
- "Y2_prime = math.exp(B/(1+ (B*x_2_prime)/(A*x_1_prime))**(2));\n",
- "P_prime = x_1_prime*Y1_prime*P_1_sat + x_2_prime*Y2_prime*P_2_sat;\t\t\t#[kPa] - Azeotrope pressure\n",
- "y_1_prime = (x_1_prime*Y1_prime*P_1_sat)/P_prime;\n",
- "\n",
- "\t\t\t# Since x_1 = y_1,azeotrope formation will take place\n",
- "print \" b\";\n",
- "print \" The total system pressure versus x_1 shows a maxima and thus azeotrope is formed by the VLE system\";\n",
- "print \" The azeotrope composition is x_1 = y_1 = %f\"%(x_1_prime);\n",
- "print \" The azeotrope presssure is %f mm Hg\"%(P_prime);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a.\n",
- " x_1 \t\t Y1 \t\t Y2 \t\t y1*P \t\t y2*P \t\t P \t\t y_1 \n",
- " 0.100000\t\t 5.446877\t\t 1.024149 \t\t 125.496041 \t\t 89.822961 \t\t 215.319002 \t 0.582838\n",
- " 0.200000\t\t 3.680305\t\t 1.097308 \t\t 169.588473 \t\t 85.546152 \t\t 255.134625 \t 0.664702\n",
- " 0.300000\t\t 2.640401\t\t 1.225500 \t\t 182.504521 \t\t 83.597451 \t\t 266.101972 \t 0.685844\n",
- " 0.400000\t\t 2.002736\t\t 1.421865 \t\t 184.572186 \t\t 83.136461 \t\t 267.708646 \t 0.689452\n",
- " 0.500000\t\t 1.599580\t\t 1.708524 \t\t 184.271623 \t\t 83.247849 \t\t 267.519472 \t 0.688816\n",
- " 0.600000\t\t 1.340316\t\t 2.120132 \t\t 185.285311 \t\t 82.642744 \t\t 267.928055 \t 0.691549\n",
- " 0.700000\t\t 1.174189\t\t 2.709824 \t\t 189.373156 \t\t 79.221704 \t\t 268.594861 \t 0.705051\n",
- " 0.800000\t\t 1.072057\t\t 3.558780 \t\t 197.601501 \t\t 69.360613 \t\t 266.962114 \t 0.740186\n",
- " 0.900000\t\t 1.017109\t\t 4.791470 \t\t 210.907696 \t\t 46.692876 \t\t 257.600573 \t 0.818739\n",
- " b\n",
- " The total system pressure versus x_1 shows a maxima and thus azeotrope is formed by the VLE system\n",
- " The azeotrope composition is x_1 = y_1 = 0.706548\n",
- " The azeotrope presssure is 268.599631 mm Hg\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.21 Page Number : 544"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 50;\t\t\t#[C]\n",
- "\t\t\t# At 50 C\n",
- "P_1_sat = 0.67;\t\t\t#[atm]\n",
- "P_2_sat = 0.18;\t\t\t#[atm]\n",
- "Y1_infinity = 2.5;\n",
- "Y2_infinity = 7.2;\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t# alpha_12 = (y_1/x_1)/(y_2/x_2) = (Y1*P_1_sat)/((Y2*P_2_sat))\n",
- "\t\t\t# At x_1 tending to zero,\n",
- "alpha_12_x0 = (Y1_infinity*P_1_sat)/(P_2_sat);\n",
- "\t\t\t# At x_1 tending to 1,\n",
- "alpha_12_x1 = (P_1_sat)/((Y2_infinity*P_2_sat));\n",
- "\n",
- "\t\t\t# Since alpha_12 is a continuous curve and in between a value of alpha_12 = 1, shall come and at this composition the azeotrope shall get formed.\n",
- "print \" 1).Since alpha_12_x=0) = %f and alpha_12_x=1) = %f \"%(alpha_12_x0,alpha_12_x1);\n",
- "print \" and since alpha_12 is a continuous curve and in between a value of alpha_12 = 1 shall come and at this composition azeotrope shall get formed.\"\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t# Since the activity coefficient values are greater than 1 ,therefore the deviations from Roult's law is positive\n",
- "\t\t\t# and the azeotrope is maximum pressure (or minimum boiling)\n",
- "print \" 2).Since the activity coefficient values are greater than 1 therefore the deviations from Roults law is positive\"\n",
- "print \" and the azeotrope is maximum pressure or minimum boiling\";\n",
- "\n",
- "\t\t\t#(3)\n",
- "\t\t\t# Let us assume the system to follow van Laar activity coefficient model\n",
- "A = math.log(Y1_infinity);\n",
- "B = math.log(Y2_infinity);\n",
- "\n",
- "\t\t\t# math.log(Y1) = A/(1+ (A*x_1)/(B*x_2))**(2)\n",
- "\t\t\t# math.log(Y2) = B/(1+ (B*x_2)/(A*x_1))**(2)\n",
- "\n",
- "\t\t\t# At the azeotrope point, Y1*P1_sat = Y2*P2_sat\n",
- "\t\t\t# math.log(Y1) - math.log(Y2) = math.log(P_2_sat/P_2_sat)\n",
- "\t\t\t# On putting the values and then solving the above equation\n",
- "def f(x_1): \n",
- "\t return A/(1+ (A*x_1)/(B*(1-x_1)))**(2)- B/(1+ (B*(1-x_1))/(A*x_1))**(2) - math.log(P_2_sat/P_1_sat)\n",
- "x_1 = fsolve(f,0.1)\n",
- "\n",
- "\t\t\t# At x_1\n",
- "x_2 = 1 - x_1;\n",
- "Y1 = math.exp(A/(1+ (A*x_1)/(B*x_2))**(2));\n",
- "Y2 = math.exp(B/(1+ (B*x_2)/(A*x_1))**(2));\n",
- "P = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;\t\t\t#[kPa] - Azeotrope pressure\n",
- "y_1 = (x_1*Y1*P_1_sat)/P;\n",
- "\n",
- "\t\t\t# Since x_1 = y_1,the azeotrope formation will take place\n",
- "\n",
- "print \" 3).The azeotrope composition is x_1 = y_1 = %f\"%(x_1);\n",
- "print \" The azeotrope presssure is %f atm\"%(P);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).Since alpha_12_x=0) = 9.305556 and alpha_12_x=1) = 0.516975 \n",
- " and since alpha_12 is a continuous curve and in between a value of alpha_12 = 1 shall come and at this composition azeotrope shall get formed.\n",
- " 2).Since the activity coefficient values are greater than 1 therefore the deviations from Roults law is positive\n",
- " and the azeotrope is maximum pressure or minimum boiling\n",
- " 3).The azeotrope composition is x_1 = y_1 = 0.910173\n",
- " The azeotrope presssure is 0.689143 atm\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.22 Page Number : 545"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 25;\t\t\t#[C]\n",
- "\t\t\t# At 50 C\n",
- "P_1_sat = 7.866;\t\t\t#[kPa]\n",
- "P_2_sat = 3.140;\t\t\t#[kPa]\n",
- "\n",
- "\t\t\t# G_E/(R*T) = 1.4938*x_1*x_2/(1.54*x_1 + 0.97*x_2)\n",
- "\n",
- "\t\t\t# The excess Gibbs free energy math.expression can be written as\n",
- "\t\t\t# x_1*x_2/(G_E/(R*T)) = 1.54*x_1/1.4938 + 0.97*x_2/1.4938 = x_1/0.97 + x_2/1.54\n",
- "\n",
- "\t\t\t# Comparing with the van Laar math.expression\n",
- "\t\t\t# x_1*x_2/(G_E/(R*T)) = x_1/B + x_2/A, we get\n",
- "A = 1.54;\n",
- "B = 0.97;\n",
- "\n",
- "\t\t\t# The activity coefficients are thus given by\n",
- "\t\t\t# math.log(Y1) = A/(1+ (A*x_1)/(B*x_2))**(2)\n",
- "\t\t\t# math.log(Y2) = B/(1+ (B*x_2)/(A*x_1))**(2)\n",
- "\n",
- "x_1 = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.95];\n",
- "\n",
- "x_2 = zeros(10);\n",
- "Y1 = zeros(10);\n",
- "Y2 = zeros(10);\n",
- "P = zeros(10);\n",
- "y_1 = zeros(10);\n",
- "\n",
- "print \" x_1 \\t\\t Y1 \\t\\t Y2 \\t\\t P kPa \\t\\t y_1 \";\n",
- "\n",
- "# Calculations and Results\n",
- "for i in range(10):\n",
- " x_2[i] = 1 - x_1[i];\n",
- " Y1[i] = math.exp(A/(1+ (A*x_1[i])/(B*x_2[i]))**(2));\n",
- " Y2[i] = math.exp(B/(1+ (B*x_2[i])/(A*x_1[i]))**(2));\n",
- " P[i] = x_1[i]*Y1[i]*P_1_sat + x_2[i]*Y2[i]*P_2_sat;\n",
- " y_1[i] = (x_1[i]*Y1[i]*P_1_sat)/P[i];\n",
- " print \" %f\\t\\t %f\\t\\t %f \\t\\t %f \\t\\t %f \"%(x_1[i],Y1[i],Y2[i],P[i],y_1[i]);\n",
- "\n",
- "\n",
- "\t\t\t# The azeotrope is formed near x_1 = 0.95 as in this region a maxima in pressure is obtained.\n",
- "\n",
- "\t\t\t# At the azeotrope point, Y1*P1_sat = Y2*P2_sat\n",
- "\t\t\t# math.log(Y1) - math.log(Y2) = math.log(P_2_sat/P_2_sat)\n",
- "\t\t\t# On putting the values and then solving the above equation\n",
- "def f(x_1): \n",
- "\t return A/(1+ (A*x_1)/(B*(1-x_1)))**(2)- B/(1+ (B*(1-x_1))/(A*x_1))**(2) - math.log(P_2_sat/P_1_sat)\n",
- "x_1_prime = fsolve(f,0.1)\n",
- "\n",
- "\t\t\t# At x_1\n",
- "x_2_prime = 1 - x_1_prime;\n",
- "Y1_prime = math.exp(A/(1+ (A*x_1_prime)/(B*x_2_prime))**(2));\n",
- "Y2_prime = math.exp(B/(1+ (B*x_2_prime)/(A*x_1_prime))**(2));\n",
- "P_prime = x_1_prime*Y1_prime*P_1_sat + x_2_prime*Y2_prime*P_2_sat;\t\t\t#[kPa] - Azeotrope pressure\n",
- "y_1_prime = (x_1_prime*Y1_prime*P_1_sat)/P_prime;\n",
- "\n",
- "\t\t\t# Since x_1_prime = y_1_prime,the azeotrope formation will take place\n",
- "\n",
- "print \" Part II \";\n",
- "print \" The azeotrope composition is x_1 = y_1 = %f\"%(x_1_prime);\n",
- "print \" The azeotrope presssure is %f kPa \"%(P_prime);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " x_1 \t\t Y1 \t\t Y2 \t\t P kPa \t\t y_1 \n",
- " 0.100000\t\t 3.042798\t\t 1.022050 \t\t 5.281779 \t\t 0.453155 \n",
- " 0.200000\t\t 2.201629\t\t 1.081457 \t\t 6.180223 \t\t 0.560433 \n",
- " 0.300000\t\t 1.725242\t\t 1.172375 \t\t 6.648107 \t\t 0.612389 \n",
- " 0.400000\t\t 1.438293\t\t 1.292347 \t\t 6.960227 \t\t 0.650186 \n",
- " 0.500000\t\t 1.258593\t\t 1.440723 \t\t 7.211980 \t\t 0.686364 \n",
- " 0.600000\t\t 1.144175\t\t 1.617876 \t\t 7.432102 \t\t 0.726584 \n",
- " 0.700000\t\t 1.072060\t\t 1.824770 \t\t 7.621913 \t\t 0.774475 \n",
- " 0.800000\t\t 1.028913\t\t 2.062721 \t\t 7.770131 \t\t 0.833286 \n",
- " 0.900000\t\t 1.006610\t\t 2.333241 \t\t 7.858834 \t\t 0.906775 \n",
- " 0.950000\t\t 1.001587\t\t 2.481217 \t\t 7.874109 \t\t 0.950528 \n",
- " Part II \n",
- " The azeotrope composition is x_1 = y_1 = 0.958680\n",
- " The azeotrope presssure is 7.874467 kPa \n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.23 Page Number : 547"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 58.7;\t\t\t#[C]\n",
- "P = 1;\t\t\t#[atm]\n",
- "P = P*101325*10**(-3);\t\t\t#[kPa]\n",
- "\n",
- "\t\t\t# math.log(P_sat) = 16.6758 - 3674.49/(t + 226.45) - For ethyl alcohol\n",
- "\t\t\t# math.log(P_sat) = 13.8216 - 2697.55/(t + 224.37) - For hexane\n",
- "\n",
- "\t\t\t# Let us take hexane as (1) and ethanol as (2)\n",
- "\t\t\t# At 58.7 C\n",
- "P_1_sat = math.exp(13.8216 - 2697.55/(T + 224.37));\t\t\t#[kPa]\n",
- "P_2_sat = math.exp(16.6758 - 3674.49/(T + 226.45));\t\t\t#[kPa]\n",
- "\n",
- "# Calculations and Results\n",
- "Y1 = P/P_1_sat;\n",
- "Y2 = P/P_2_sat;\n",
- "\n",
- "x_2 = 0.332;\t\t\t# Mol % of ethanol (given)\n",
- "x_1 = 1 - x_2;\t\t\t# Mol % of hehane\n",
- "\n",
- "\t\t\t# The van Laar parameters are given by\n",
- "A = ((1 + (x_2*math.log(Y2))/(x_1*math.log(Y1)))**(2))*math.log(Y1);\n",
- "B = ((1 + (x_1*math.log(Y1))/(x_2*math.log(Y2)))**(2))*math.log(Y2);\n",
- "\n",
- "print \" The value of van Laar parameters are A = %f and B = %f \"%(A,B);\n",
- "\n",
- "\t\t\t# Now let us calvulate the distribution coefficient K\n",
- "x_1_prime = 0.5;\t\t\t#[given]\n",
- "x_2_prime = 1 - x_1_prime;\n",
- "\n",
- "\t\t\t# The activity coefficients are thus given by\n",
- "\t\t\t# math.log(Y1) = A/(1+ (A*x_1)/(B*x_2))**(2)\n",
- "\t\t\t# math.log(Y2) = B/(1+ (B*x_2)/(A*x_1))**(2)\n",
- "\n",
- "Y1_prime = math.exp(A/(1+ (A*x_1_prime)/(B*x_2_prime))**(2));\n",
- "Y2_prime = math.exp(B/(1+ (B*x_2_prime)/(A*x_1_prime))**(2));\n",
- "P_prime = x_1_prime*Y1_prime*P_1_sat + x_2_prime*Y2_prime*P_2_sat;\n",
- "\n",
- "\t\t\t# We have, K_1 = y_1/x_1 = Y1*P_1_sat/P\n",
- "K_1 = Y1_prime*P_1_sat/P_prime;\n",
- "\n",
- "print \" The distribution coefficient is given by K_1 = %f\"%(K_1)\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of van Laar parameters are A = 1.669879 and B = 2.662289 \n",
- " The distribution coefficient is given by K_1 = 1.352866\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch16_1.ipynb b/Chemical_Engineering_Thermodynamics/ch16_1.ipynb
deleted file mode 100755
index 69003cd3..00000000
--- a/Chemical_Engineering_Thermodynamics/ch16_1.ipynb
+++ /dev/null
@@ -1,753 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:a00a89ec39a5812cdf143d7f00f601a0bb401404f1638737e2689f71d07acb65"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 16 : Other Phase Equilibria"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.1 Page Number : 564"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "\n",
- "# Variables\t\t\t\n",
- "T = 0 + 273.15;\t\t\t#[K] - Temperature\n",
- "P = 20*10**(5);\t\t\t#[Pa] - Pressure\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\t\t\t#componenet 1 : methane (1)\n",
- "\t\t\t#componenet 2 : methanol (2)\n",
- "\n",
- "H_constant = 1022;\t\t\t#[bar] - Henry's law constant\n",
- "H_constant = H_constant*10**(5);\t\t\t#[Pa]\n",
- "\n",
- "\t\t\t# The second virial coefficients are\n",
- "B_11 = -53.9;\t\t\t#[cm**(3)/mol]\n",
- "B_11 = B_11*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "B_12 = -166;\t\t\t#[cm**(3)/mol]\n",
- "B_12 = B_12*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "B_22 = -4068;\t\t\t#[cm**(3)/mol]\n",
- "B_22 = B_22*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "den_meth = 0.8102;\t\t\t#[g/cm**(3)] - Density of methanol at 0 C\n",
- "Mol_wt_meth = 32.04;\t\t\t# Molecular weight of methanol\n",
- "P_2_sat = 0.0401;\t\t\t#[bar] - Vapour pressure of methanol at 0 C\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#The molar volume of methanol can be calculated as\n",
- "V_2_liq = (1/(den_meth/Mol_wt_meth))*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#The phase equilibrium equation of the components at high pressure\n",
- "\t\t\t#y1*phi_1*P = x_1*H_1\n",
- "\t\t\t#y2*phi_2*P = x_2*H_2\n",
- "\n",
- "\t\t\t#Since methane follows Henry's law therefore methanol follows the lewis-Rnadall rule\n",
- "\t\t\t#f_2 is the fugacity of the compressed liquid which is calculated using\n",
- "\t\t\t#f_2 = f_2_sat*math.exp[V_2_liq*(P - P_sat_2)/(R*T)]\n",
- "\t\t\t#where f_2_sat can be calculated using virial equation \n",
- "\t\t\t# math.log(phi_2_sat) = math.log(f_2_sat/P_2_sat) = (B_22*P_2_sat)/(R*T)\n",
- "\n",
- "f_2_sat = P_2_sat*math.exp((B_22*P_2_sat*10**(5))/(R*T));\t\t\t#[bar]\n",
- "\n",
- "\t\t\t#Putting the value of 'f_2_sat' in the math.expression of f_2 , we get\n",
- "f_2 = f_2_sat*math.exp(V_2_liq*(P - P_2_sat*10**(5))/(R*T));\t\t\t#[bar]\n",
- "\n",
- "\t\t\t#Now let us calculate the fugacity coefficients of the species in the vapour mixture\n",
- "del_12 = 2*B_12 - B_11 - B_22;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#math.log(phi_1) = (P/(R*T))*(B_11 + y2**(2)*del_12)\n",
- "\t\t\t#math.log(phi_2) = (P/(R*T))*(B_22 + y1**(2)*del_12)\n",
- "\n",
- "\n",
- "\t\t\t#The calculation procedure is to assume a value of y1, calculate 'phi_1' and 'phi_2' and calculate 'x_1' and 'x_2' from the phase equilibrium equations and see whether x_1 + x_2 = 1,if not then another value of y1 is assumed.\n",
- "\n",
- "y2 = 0.1;\n",
- "error=10;\n",
- "\n",
- "while(error>0.001):\n",
- " y1=1-y2;\n",
- " phi_1 = math.exp((P/(R*T))*((B_11 + y2**(2)*del_12)));\n",
- " phi_2 = math.exp((P/(R*T))*((B_22 + y1**(2)*del_12)));\n",
- " x_1 = (y1*phi_1*P)/H_constant;\n",
- " x_2 = (y2*phi_2*P)/(f_2*10**(5));\n",
- " x = x_1 + x_2;\n",
- " error=abs(1-x);\n",
- " y2=y2 - 0.000001;\n",
- "\n",
- "# Results\n",
- "print \" The solubility of methane in methanol is given by x1 = %f\"%(x_1);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The solubility of methane in methanol is given by x1 = 0.018614\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.2 Page Number : 566"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\n",
- "# Variables\n",
- "x_C2H6_1 = 0.33*10**(-4);\t\t\t# Solubility of ethane in water at 25 C and 1 bar\n",
- "\n",
- "\t\t\t#componenet 1 : ethane (1)\n",
- "\t\t\t#componenet 2 : water (2)\n",
- "\n",
- "\t\t\t# Z = 1 - 7.63*10**(3)*P - 7.22*10**(-5)*P**(2)\n",
- "\n",
- "\t\t\t#The phase equilibrium equation of ethane is\n",
- "\t\t\t#f_1_V = x_1*H_1\n",
- "\t\t\t#since vapour is pure gas, f_1_V = x_1*H_1 or, phi_1*P = x_1*H_1, where 'phi_1' is fugacity coefficient of pure ethane\n",
- "\t\t\t# math.log(phi) = integral('Z-1)/P) from limit '0' to 'P'\n",
- "\n",
- "P1 = 0;\n",
- "P2 = 1;\n",
- "P3 = 35;\n",
- "\n",
- "# Calculations\n",
- "def f51(P): \n",
- "\t return (1-7.63*10**(-3)*P-7.22*10**(-5)*P**(2)-1)/P\n",
- "\n",
- "intgral = quad(f51,P1,P2)[0]\n",
- "\n",
- "phi_1_1 = math.exp(intgral);\t\t\t# - Fugacity coefficient of ethane at 1 bar\n",
- "f_1_1 = phi_1_1*P2;\t\t\t#[bar] - Fugacity of ethane at 1 bar\n",
- "\n",
- "\t\t\t#Similarly\n",
- "\n",
- "def f52(P): \n",
- "\t return (1-7.63*10**(-3)*P-7.22*10**(-5)*P**(2)-1)/P\n",
- "\n",
- "intgral_1 = quad(f52,P1,P3)[0]\n",
- "\n",
- "phi_1_35 = math.exp(intgral_1);\t\t\t# Fugacity coefficient of ethane at 35 bar\n",
- "f_1_35 = phi_1_35*P3;\t\t\t#[bar] - Fugacity of ethane at 35 bar\n",
- "\n",
- "\t\t\t# At ethane pressure of 1 bar , x_C2H6_1*H_1 = phi_1_1\n",
- "H_1 = phi_1_1/x_C2H6_1;\t\t\t#[bar] - Henry's constant\n",
- "\n",
- "\t\t\t# At ethane pressure of 35 bar , x_C2H6_35*H_1 = phi_1_35\n",
- "x_C2H6_35 = f_1_35/H_1;\t\t\t# Solubility of ethane at 35 bar pressure\n",
- "\n",
- "# Results\n",
- "print \"The solubility of ethane at 35 bar is given by x_C2H6 = %e \"%(x_C2H6_35);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The solubility of ethane at 35 bar is given by x_C2H6 = 8.525648e-04 \n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.4 Page Number : 571"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "# Variables\n",
- "T = 200;\t\t\t#[K]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
- "\t\t\t# G_E = A*x_1*x_2\n",
- "A = 4000;\t\t\t#[J/mol]\n",
- "x_1 = 0.6;\t\t\t# Mle fraction of feed composition\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# Since A is given to be independent of temperature\n",
- "UCST = A/(2*R);\t\t\t#[K] - Upper critical solution temperature\n",
- "print \" The UCST of the system is %f K\"%(UCST);\n",
- "\n",
- "\t\t\t# Since the given temperature is less than UCST therefore two phase can get formed at the given temperature.\n",
- "\n",
- "\t\t\t# x1_alpha = 1 - x1_beta\n",
- "\t\t\t# We know that, x1_alpha*Y_1_alpha = x2_alpha*Y_2_alpha\n",
- "\t\t\t# x1_alpha*math.exp[(A/(R*T))*(x2_alpha)**(2)] = (1 - x1_alpha)*math.exp[(A/(R*T))*(x1_alpha)**(2)]\n",
- "\t\t\t# where use has beeen made of the fact that x1_alpha = 1 - x1_beta and x2_beta = 1 - x1_beta = x1_alpha .Taking math.logarithm of both side we get\n",
- "\t\t\t# math.log(x1_alpha) + (A/(R*T))*(1 - x1_alpha)**(2) = math.log(1 - x1_alpha) + (A/(R*T))*x1_alpha**(2)\n",
- "\t\t\t# math.log(x1_alpha/(1-x1_alpha)) = (A/(R*T))*(2*x1_alpha - 1)\n",
- "\n",
- "def f(x1_alpha): \n",
- "\t return math.log(x1_alpha/(1-x1_alpha)) - (A/(R*T))*(2*x1_alpha - 1)\n",
- "x1_alpha = fsolve(f,0.1)\n",
- "x1_beta = fsolve(f,0.9)\n",
- "\t\t\t# Because of symmetry 1 - x1_beta = x1_alpha\n",
- "\n",
- "\t\t\t# It can be seen that the equation, math.log(x1/(1-x1)) = (A/(R*T))*(2*x1 - 1) has two roots.\n",
- "\t\t\t# The two roots acn be determined by taking different values \n",
- "\t\t\t# Starting with x1 = 0.1, we get x1 = 0.169 as the solution and starting with x1 = 0.9,we get x1 = 0.831 as the solution.\n",
- "\t\t\t# Thus x1 = 0.169 is the composition of phase alpha and x1 = 0.831 is of phase beta\n",
- "print \" The composition of two liquid phases in equilibrium is given by x1_alpha = %f and x1_beta = %f\"%(x1_alpha,x1_beta);\n",
- "\n",
- "\t\t\t# From the equilibrium data it is seen that if the feed has composition x1 less than 0.169 or more than 0.831 the liquid mixture is of single phase\n",
- "\t\t\t# whereas if the overall (feed) composition is between 0.169 and 0.831 two phases shall be formed.\n",
- "\t\t\t# The amounts of phases can also be calculated. The feed composition is given to be z1 = 0.6\n",
- "z1 = 0.6;\n",
- "\t\t\t# z1 = x1_alpha*alpha + x1_beta*beta\n",
- "\t\t\t# beta = 1 - alpha\n",
- "alpha = (z1-x1_beta)/(x1_alpha-x1_beta);\t\t\t#[mol]\n",
- "Beta = 1 - alpha;\t\t\t#[mol]\n",
- "print \" The relative amount of phases is given by alpha = %f mol and beta = %f mol\"%(alpha,Beta);\n",
- "\n",
- "\t\t\t# the relative amounts of the phases changes with the feed composition \n",
- "\n",
- "\t\t\t#math.log(x1/(1-x1)) = (A/(R*T))*(2*x1 - 1)\n",
- "\t\t\t# If the above equation has two real roots of x1 (one for phase alpha and the other for phase beta) then two liquid phases get formed\n",
- "\t\t\t# and if it has no real roots then a homogeneous liquid mixtures is obtained.\n",
- "\n",
- "print \" math.logx1/1-x1 = A/R*T*2*x1 - 1\";\n",
- "print \" If the above equation has two real roots of x1 one for phase alpha and the other for phase beta then two liquid phases get formed\";\n",
- "print \" and if it has no real roots then a homogeneous liquid mixture is obtained\";\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The UCST of the system is 240.558095 K\n",
- " The composition of two liquid phases in equilibrium is given by x1_alpha = 0.169102 and x1_beta = 0.830898\n",
- " The relative amount of phases is given by alpha = 0.348896 mol and beta = 0.651104 mol\n",
- " math.logx1/1-x1 = A/R*T*2*x1 - 1\n",
- " If the above equation has two real roots of x1 one for phase alpha and the other for phase beta then two liquid phases get formed\n",
- " and if it has no real roots then a homogeneous liquid mixture is obtained\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.5 Page Number : 573"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 300;\t\t\t#[K]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
- "A = 7000;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# math.log(x_1/(1-x_1)) = (A/(R*T))*(2*x_1-1)\n",
- "\n",
- "# Calculations\n",
- "def f(x_1): \n",
- "\t return math.log(x_1/(1-x_1))-((A/(R*T))*(2*x_1-1))\n",
- "\n",
- "x1_alpha=fsolve(f,0.1)\n",
- "\n",
- "x1_beta=1-x1_alpha;\n",
- "\n",
- "# Results\n",
- "print \"The equilibrium compositin of the two liquid phase system is given by x1_alpha \\t = %f x1_beta \\t = %f\"%(x1_alpha,x1_beta);"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The equilibrium compositin of the two liquid phase system is given by x1_alpha \t = 0.091897 x1_beta \t = 0.908103\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.7 Page Number : 579"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "M_wt_meth = 32;\t\t\t# Molecular weight of methanol \n",
- "M_wt_water = 18;\t\t\t# Molecular weight of water \n",
- "m_meth = 0.01;\t\t\t#[g] - Mass of methanol added per cm**(3) of solution\n",
- "\n",
- "\t\t\t#Since the concentration of methanol is very small therefore we can assume that the density of solution = pure water\n",
- "den_sol = 1;\t\t\t#[g/cm**(3)]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#The mole fraction of solute is given by\n",
- "\t\t\t#x_2 = (moles of solute in cm**(3) of solution)/(moles of solute + moles of water) in 1 cm**(3) of solution\n",
- "x_2 = (m_meth/M_wt_meth)/((m_meth/M_wt_meth)+((1-m_meth)/M_wt_water));\n",
- "\n",
- "\t\t\t#We know that heat of fusion of water is\n",
- "H_fus = -80;\t\t\t#[cal/g] - Enthalpy change of fusion at 0 C\n",
- "H_fus = H_fus*4.186*M_wt_water;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t#Therefore freezing point depression is given by\n",
- "\t\t\t# T - T_m = (R*(T**(2))*x_2)/H_fus\n",
- "T_f = 273.15;\t\t\t#[K] - Freezing point of water\n",
- "delta_T_f = (R*(T_f**(2))*x_2)/H_fus;\t\t\t#[K]\n",
- "\n",
- "# Results\n",
- "print \"The depression in freezing point is given by delta_T = %f K\"%(delta_T_f);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The depression in freezing point is given by delta_T = -0.581403 K\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.8 Page Number : 580"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
- "T_f = 273.15;\t\t\t#[K] - Freezing point of water\n",
- "m_water = 100;\t\t\t#[g] - Mass of water\n",
- "m_NaCl = 3.5;\t\t\t#[g] - Mass of NaCl\n",
- "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
- "M_wt_NaCl = 58.5;\t\t\t# Molecular weight of NaCl\n",
- "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
- "mol_NaCl = m_NaCl/M_wt_NaCl;\t\t\t#[mol] - Moles of NaCl\n",
- "\n",
- "H_fus = -80;\t\t\t#[cal/g] - Enthalpy change of fusion at 0 C\n",
- "H_fus = H_fus*4.186*M_wt_water;\t\t\t#[J/mol]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#Mole fraction of the solute (NaCl) is given by\n",
- "x_2 = mol_NaCl/(mol_NaCl+mol_water);\n",
- "\n",
- "\t\t\t#But NaCl is compietely ionized and thus each ion acts independently to lower the water mole fraction.\n",
- "x_2_act = 2*x_2;\t\t\t# Actual mole fraction\n",
- "\n",
- "\t\t\t#Now depression in freezing point is given by\n",
- "\t\t\t# T - T_m = (R*(T**(2))*x_2_act)/H_fus\n",
- "delta_T_f = (R*(T_f**(2))*x_2_act)/H_fus;\t\t\t#[C]\n",
- "\n",
- "\t\t\t#Thus freezing point of seawater = depression in freezing point\n",
- "\n",
- "# Results\n",
- "print \"The freezing point of seawater is %f C\"%(delta_T_f);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The freezing point of seawater is -2.192853 C\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.10 Page Number : 583"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
- "T_b = 373.15;\t\t\t#[K] - Boiling point of water\n",
- "m_water = 100.;\t\t\t#[g] - Mass of water\n",
- "m_C12H22 = 5.;\t\t\t#[g] - Mass of glucise (C12H22)\n",
- "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
- "M_wt_C12H22 = 342.30;\t\t\t# Molecular weight of C12H22\n",
- "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
- "mol_C12H22 = m_C12H22/M_wt_C12H22;\t\t\t#[mol] - Moles of C12H22\n",
- "\n",
- "# Calculations\n",
- "H_vap = 540.;\t\t\t#[cal/g] - Enthalpy change of vaporisation\n",
- "H_vap = H_vap*4.186*M_wt_water;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t#Mole fraction of the solute (C12H22) is given by\n",
- "x_2 = mol_C12H22/(mol_C12H22+mol_water);\n",
- "\n",
- "\t\t\t#The boiling point elevation is given by\n",
- "\t\t\t# T - T_b = (R*T_b**(2)*x_2**(2))/H_vap**(2)\n",
- "\n",
- "delta_T_b = (R*T_b**(2)*x_2)/(H_vap);\n",
- "\n",
- "# Results\n",
- "print \"The elevation in boiling point is given by delta_T = %f C\"%(delta_T_b)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The elevation in boiling point is given by delta_T = 0.074611 C\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.11 Page Number : 584"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "T = 25 + 273.15;\t\t\t#[K] - Surrounding temperature \n",
- "den_water = 1000.;\t\t\t#[kg/m**(3)] - Density of water\n",
- "m_water = 100.;\t\t\t#[g] - Mass of water\n",
- "m_C12H22 = 5.;\t\t\t#[g] - Mass of glucise (C12H22)\n",
- "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
- "M_wt_C12H22 = 342.30;\t\t\t# Molecular weight of C12H22\n",
- "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
- "mol_C12H22 = m_C12H22/M_wt_C12H22;\t\t\t#[mol] - Moles of C12H22\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#Mole fraction of the water is given by\n",
- "x_1 = mol_water/(mol_C12H22+mol_water);\n",
- "\n",
- "\t\t\t#Molar volume of water can be calculated as\n",
- "V_l_water = (1./den_water)*M_wt_water*10**(-3);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#The osmotic pressure is given by\n",
- "pi = -(R*T*math.log(x_1))/V_l_water;\t\t\t#[N/m**(2)]\n",
- "pi = pi*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "# Results\n",
- "print \"The osmotic pressure of the mixture is %f bar\"%(pi);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The osmotic pressure of the mixture is 3.616073 bar\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.12 Page Number : 585"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# Variables\n",
- "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
- "T = 25 + 273.15;\t\t\t#[K] - Surrounding temperature\n",
- "den_water = 1000.;\t\t\t#[kg/m**(3)] - Density of water\n",
- "m_water = 100.;\t\t\t#[g] - Mass of water\n",
- "m_NaCl = 3.5;\t\t\t#[g] - Mass of NaCl\n",
- "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
- "M_wt_NaCl = 58.5;\t\t\t# Molecular weight of NaCl\n",
- "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
- "mol_NaCl = m_NaCl/M_wt_NaCl;\t\t\t#[mol] - Moles of NaCl\n",
- "\n",
- "# Calculations\n",
- "H_fus = -80.;\t\t\t#[cal/g] - Enthalpy change of fusion at 0 C\n",
- "H_fus = H_fus*4.186*M_wt_water;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t#Mole fraction of the solute (NaCl) is given by\n",
- "x_2 = mol_NaCl/(mol_NaCl+mol_water);\n",
- "\n",
- "\t\t\t#But NaCl is compietely ionized and thus each ion acts independently to lower the water mole fraction.\n",
- "x_2_act = 2*x_2;\t\t\t# Actual mole fraction\n",
- "\n",
- "x_1 = 1 - x_2_act;\n",
- "\n",
- "\t\t\t#Molar volume of water can be calculated as\n",
- "V_l_water = (1/den_water)*M_wt_water*10**(-3);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#The osmotic pressure is given by\n",
- "pi = -(R*T*math.log(x_1))/V_l_water;\t\t\t#[N/m**(2)]\n",
- "pi = pi*10**(-5);\t\t\t#[bar]\n",
- "\t\t\t#The minimum pressure to desalinate sea water is nothing but the osmotic pressure\n",
- "\n",
- "# Results\n",
- "print \"The minimum pressure to desalinate sea water is %f bar\"%(pi);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The minimum pressure to desalinate sea water is 29.662232 bar\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.13 Page Number : 586"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
- "T = 173.15;\t\t\t#[K] - Surrounding temperature\n",
- "P = 60;\t\t\t#[bar]\n",
- "P = P*10**(5);\t\t\t#[Pa] \n",
- "\n",
- "\t\t\t#componenet 1 : CO2 (1)\n",
- "\t\t\t#componenet 2 : H2 (2)\n",
- "P_1_sat = 0.1392;\t\t\t#[bar] - Vapour pressre of pure solid CO2\n",
- "P_1_sat = P_1_sat*10**(5);\t\t\t#[bar]\n",
- "V_s_1 = 27.6;\t\t\t#[cm**(3)/mol] - Molar volume of solid CO2\n",
- "V_s_1 = V_s_1*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "n_1 = 0.01;\t\t\t#[mol] - Initial number of moles of CO2\n",
- "n_2 = 0.99;\t\t\t#[mol] - Initial number of moles of H2\n",
- "\n",
- "\t\t\t#Let us determine the fugacity of solid CO2 (1) at 60 C and 173.15 K\n",
- "\t\t\t# f_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T))\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#Since vapour pressure of pure solid CO2 is very small, therefore\n",
- "f_1_sat = P_1_sat;\n",
- "f_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T));\n",
- "\n",
- "\t\t\t#Since gas phase is ideal therefore\n",
- "\t\t\t# y1*P = f_1\n",
- "y1 = f_1/P;\n",
- "\n",
- "\t\t\t#Number of moles of H2 in vapour phase at equilibrium remains the same as initial number of moles.\n",
- "\t\t\t#Number of moles of CO2 in vapour phase at equilibrium can be calculated as\n",
- "\t\t\t#y1 = (n_1_eq/(n_1_eq + n_2)). Therefore\n",
- "n_1_eq = n_2*y1/(1-y1);\n",
- "\n",
- "\t\t\t#Therefore moles of CO2 precipitated is\n",
- "n_ppt = n_1 - n_1_eq;\t\t\t#[mol]\n",
- "\n",
- "# Results\n",
- "print \"The moles of CO2 precipitated is %f mol\"%(n_ppt);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The moles of CO2 precipitated is 0.007417 mol\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.14 Page Number : 586"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
- "T = 350.;\t\t\t#[K] - Surrounding temperature\n",
- "\n",
- "\t\t\t#componenet 1 : organic solid (1)\n",
- "\t\t\t#componenet 2 : CO2 (2)\n",
- "\n",
- "P_1_sat = 133.3;\t\t\t#[N/m**(2)] - Vapour pressre of organic solid\n",
- "V_s_1 = 200.;\t\t\t#[cm**(3)/mol] - Molar volume of organic solid\n",
- "V_s_1 = V_s_1*10.**(-6);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#/At 350 K, the values of the coefficients \n",
- "B_11 = -500.;\t\t\t#[cm**(3)/mol]\n",
- "B_22 = -85.;\t\t\t#[cm****(3)/mol]\n",
- "B_12 = -430.;\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#From phase equilibrium equation of component 1, we get\n",
- "\t\t\t# y1*P*phi_1 = f_1\n",
- "\t\t\t# f_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T))\n",
- "\n",
- "\t\t\t#Since vapour pressure of organic solid is very small, therefore\n",
- "f_1_sat = P_1_sat;\n",
- "\n",
- "\t\t\t# Now let us determine the fugacity coefficient of organic solid in the vapour mixture.\n",
- "\t\t\t# math.log(phi_1) = (P/(R*T))*(B_11 + y2**(2)*del_12) \n",
- "del_12 = (2*B_12 - B_11 - B_22)*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#It is given that the partial pressure of component 1 in the vapour mixture is 1333 N?m**(2)\n",
- "\t\t\t# y1*P = 1333 N/m**(2) or, y1 = 1333/P\n",
- "\t\t\t# y2 = 1- 1333/P\n",
- "\t\t\t# math.log(phi_1) = (P/(R*T))*(B_11 + (1- 1333/P)**(2)*del_12)\n",
- "\n",
- "\t\t\t#The phase equilibrium equation becomes\n",
- "\t\t\t# y1*P*phi_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T))\n",
- "\t\t\t#Taking math.log on both side we have\n",
- "\t\t\t# math.log(y1*P) + math.log(phi_1) = math.log(f_1_sat) + (V_s_1*(P-P_1_sat)/(R*T))\n",
- "\t\t\t# (V_s_1*(P-P_1_sat)/(R*T)) - math.log(phi_1) = math.log(1333/133.3) = math.log(10)\n",
- "\n",
- "\t\t\t#substituting for math.log(phi_1) from previous into the above equation we get\n",
- "\t\t\t# (V_s_1*(P-P_1_sat)/(R*T)) - (P/(R*T))*(B_11 + (1- 1333/P)**(2)*del_12) - math.log(10) = 0\n",
- "\t\t\t# On simplification we get,\n",
- "\t\t\t# 975*P**(2) - 6.7*10**(9)*P + 4.89*10**(8) = 0\n",
- "\t\t\t# Solving the above qyadratic equation using shreedharcharya rule\n",
- "\n",
- "P3 = (6.7*10**(9) + ((-6.7*10**(9))**(2)-4*975*4.98*10**(8))**(1./2))/(2*975);\t\t\t#[Pa]\n",
- "P4 = (6.7*10**(9) - ((-6.7*10**(9))**(2)-4*975*4.98*10**(8))**(1./2))/(2*975);\t\t\t#[Pa]\n",
- "\t\t\t# The second value is not possible, therefore pressure of the system is P3\n",
- "P3 = P3*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "# Results\n",
- "print \" The total pressure of the system is %f bar\"%(P3);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The total pressure of the system is 68.717948 bar\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 11
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch17_1.ipynb b/Chemical_Engineering_Thermodynamics/ch17_1.ipynb
deleted file mode 100755
index 004b3bab..00000000
--- a/Chemical_Engineering_Thermodynamics/ch17_1.ipynb
+++ /dev/null
@@ -1,2081 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:e354b0525ce1aff27214eb76f8a2c9be56cfff2939a8a4b8688a7fe1cea4959c"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 17 : Chemical Reactions Equilibria"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.2 Page Number : 598"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "\n",
- "# Variables\n",
- "P = 1;\t\t\t#[atm] - Reactor pressure\n",
- "T = 749;\t\t\t#[K] - Reactor temperature\n",
- "K = 74;\t\t\t# Equlibrium constant\n",
- "\n",
- "\t\t\t# SO2 + (1/2)*O2 - SO3\n",
- "\n",
- "# Calculations and Results\n",
- "Kp = P**(1);\n",
- "Ky = K/Kp;\n",
- "\n",
- "\t\t\t#(1)\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_SO2_1_in = 12;\n",
- "n_O2_1_in = 9;\n",
- "n_SO3_1_in = 0;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_SO2_1_eq = 12 - X\n",
- "\t\t\t# n_O2_1_eq = 9 - 0.5*X\n",
- "\t\t\t# n_SO3_1_eq = X\n",
- "\t\t\t# Total moles = 21 - 0.5*X\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "\t\t\t# y_SO3 = X/(21-0.5*X)\n",
- "\t\t\t# y_SO2 = (12-X)/(21-0.5*X)\n",
- "\t\t\t# y_O2 = (9-0.5*X)/(21-0.5*X)\n",
- "\n",
- "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
- "\t\t\t# Ky = (X*(21-0.5*X)**(1/2))/((12-X)*(9-0.5*X)**(1/2))\n",
- "def f(X): \n",
- "\t return Ky-(X*(21-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n",
- "X_1 = fsolve(f,11)\n",
- "\n",
- "y_SO3_1 = X_1/(21-0.5*X_1);\n",
- "y_SO2_1 = (12-X_1)/(21-0.5*X_1);\n",
- "y_O2_1 = (9-0.5*X_1)/(21-0.5*X_1);\n",
- "\n",
- "print \" 1).The moles of SO3 formed = %f mol\"%(X_1);\n",
- "print \" The mole fractions at equilibrium are y_S03 = %f y_SO2 = %f and y_O2 = %f\"%(y_SO3_1,y_SO2_1,y_O2_1);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_SO2_2_in = 24;\n",
- "n_O2_2_in = 18;\n",
- "n_SO3_2_in = 0;\n",
- "\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_SO2_1_eq = 24 - X\n",
- "\t\t\t# n_O2_1_eq = 18 - 0.5*X\n",
- "\t\t\t# n_SO3_1_eq = X\n",
- "\t\t\t# Total moles = 42 - 0.5*X\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "\t\t\t# y_SO3 = X/(42-0.5*X)\n",
- "\t\t\t# y_SO2 = (24-X)/(42-0.5*X)\n",
- "\t\t\t# y_O2 = (18-0.5*X)/(42-0.5*X)\n",
- "\n",
- "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
- "\t\t\t# Ky = (X*(42-0.5*X)**(1/2))/((24-X)*(18-0.5*X)**(1/2))\n",
- "def f1(X): \n",
- "\t return Ky-(X*(42-0.5*X)**(1./2))/((24-X)*(18-0.5*X)**(1./2))\n",
- "X_2 = fsolve(f1,22)\n",
- "\n",
- "y_SO3_2 = X_2/(42-0.5*X_2);\n",
- "y_SO2_2 = (24-X_2)/(42-0.5*X_2);\n",
- "y_O2_2 = (18-0.5*X_2)/(42-0.5*X_2);\n",
- "print \" 2).The moles of SO3 formed = %f mol\"%(X_2);\n",
- "print \" The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\"%(y_SO3_2,y_SO2_2,y_O2_2);\n",
- "\n",
- "\t\t\t#(3)\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_SO2_3_in = 12;\n",
- "n_O2_3_in = 9;\n",
- "n_SO3_3_in = 0;\n",
- "n_N2 = 79;\n",
- "\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_SO2_1_eq = 12 - X\n",
- "\t\t\t# n_O2_1_eq = 9 - 0.5*X\n",
- "\t\t\t# n_SO3_1_eq = X\n",
- "\t\t\t# Total moles = 100 - 0.5*X\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "\t\t\t# y_SO3 = X/(100-0.5*X)\n",
- "\t\t\t# y_SO2 = (12-X)/(100-0.5*X)\n",
- "\t\t\t# y_O2 = (9-0.5*X)/(100-0.5*X)\n",
- "\n",
- "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
- "\t\t\t# Ky = (X*(100-0.5*X)**(1/2))/((12-X)*(9-0.5*X)**(1/2))\n",
- "def f2(X): \n",
- "\t return Ky-(X*(100-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n",
- "X_3 = fsolve(f2,10)\n",
- "\n",
- "y_SO3_3 = X_3/(100-0.5*X_3);\n",
- "y_SO2_3 = (12-X_3)/(100-0.5*X_3);\n",
- "y_O2_3 = (9-0.5*X_3)/(100-0.5*X_3);\n",
- "\n",
- "print \" 3).The moles of SO3 formed = %f mol\"%(X_3);\n",
- "print \" The mole fractions at equilibrium are y_S03 = %f y_SO2 = %f and y_O2 = %f\"%(y_SO3_3,y_SO2_3,y_O2_3);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The moles of SO3 formed = 11.655537 mol\n",
- " The mole fractions at equilibrium are y_S03 = 0.768215 y_SO2 = 0.022704 and y_O2 = 0.209081\n",
- " 2).The moles of SO3 formed = 23.311074 mol\n",
- " The mole fractions at equilibrium are y_S03 = 0.768215, y_SO2 = 0.022704 and y_O2 = 0.209081\n",
- " 3).The moles of SO3 formed = 11.202213 mol\n",
- " The mole fractions at equilibrium are y_S03 = 0.118669 y_SO2 = 0.008451 and y_O2 = 0.036006\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.3 Page Number : 599"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 600;\t\t\t#[K] - Reactor temperature\n",
- "P = 300;\t\t\t#[atm] - Reactor pressure\n",
- "K = 0.91*10**(-4);\t\t\t# Equilibrium constant\n",
- "\n",
- "\t\t\t# The fugacity coefficients of the components are\n",
- "phi_CO = 1.0;\n",
- "phi_H2 = 1.2;\n",
- "phi_CH3OH = 0.47;\n",
- "\n",
- "\t\t\t# CO + 2*H2 - CH3OH \n",
- "\n",
- "\t\t\t# For gas phase reactions the smath.tan(math.radiansard state is pure ideal gas and thus fi_0 = 1 atm and thus\n",
- "\t\t\t# ai_cap = fi_cap/fi_0 = yi*P*phi_i_cap/1\n",
- "\t\t\t# Thus K = Ky*Kp*K_phi\n",
- "# Calculations and Results \n",
- "Kp = P**(1-3);\n",
- "K_phi = phi_CH3OH/(phi_CO*phi_H2**(2));\n",
- "Ky = K/(Kp*K_phi);\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium ,the moles of the components be \n",
- "\t\t\t# n_CO = 1 - X\n",
- "\t\t\t# n_H2 = 3 - 2*X\n",
- "\t\t\t# n_CH3OH = X\n",
- "\t\t\t# Total moles = 4 - 2*X\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "\t\t\t# y_CO = (1-X)/(4-2*X)\n",
- "\t\t\t# y_H2 = (3-2*X)/(4-2*X)\n",
- "\t\t\t# y_CH3OH = (X)/(4-2*X)\n",
- "\n",
- "\t\t\t# Ky = y_CH3OH/(y_CO*y_H2**(2)) = (X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))**(2))\n",
- "def f(X): \n",
- "\t return Ky-(X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))**(2))\n",
- "X = fsolve(f,0.1)\n",
- "\n",
- "\t\t\t# Therefore at equilibrium \n",
- "y_CO = (1-X)/(4-2*X);\n",
- "y_H2 = (3-2*X)/(4-2*X);\n",
- "y_CH3OH = (X)/(4-2*X);\n",
- "\n",
- "print \" The mole fractions at equilibrium are y_CO = %f y_H2 = %f and y_CH3OH = %f\"%(y_CO,y_H2,y_CH3OH);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The mole fractions at equilibrium are y_CO = 0.051857 y_H2 = 0.551857 and y_CH3OH = 0.396286\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.4 Page Number : 600"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\t\t\n",
- "T = 600;\t\t\t#[K] - Reactor temperature\n",
- "P = 4;\t\t\t#[atm] - Reactor pressure\n",
- "K = 1.175;\t\t\t# Equilibrium constant\n",
- "\n",
- "\t\t\t# (1/2)*N2 + (3/2)*H_2 - NH3\n",
- "\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_N2 = 1;\n",
- "n_H2 = 3;\n",
- "n_HN3 = 0;\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X.\n",
- "\t\t\t# At equilibrium ,the moles of the components be \n",
- "\t\t\t# n_N2 = 1 - 0.5*X\n",
- "\t\t\t# n_H2 = 3 - 1.5*X\n",
- "\t\t\t# n_NH3 = X\n",
- "\t\t\t# Total moles = 4 - X\n",
- "\n",
- "\t\t\t# We have, K = Ky*Kp\n",
- "Kp = P**(1-2);\t\t\t#[atm**(-1)]\n",
- "Ky = K/(Kp);\n",
- "\n",
- "\t\t\t# Ky = y_NH3/(y_N2**(1/2)*y_H2**(3/2)) = (X/(4-X))/(((1-0.5*X)/(4-X))**(1/2)*((3-1.5*X)/(4-X))**(3/2))\n",
- "\t\t\t# Solving the above equation we get\n",
- "def f(X): \n",
- "\t return Ky - (X/(4-X))/(((1-0.5*X)/(4-X))**(1./2)*((3-1.5*X)/(4-X))**(3./2))\n",
- "X = fsolve(f,0.1)\n",
- "\n",
- "y_NH3 = X/(4-X);\t\t\t# Mole fraction of NH3 at equilibrium\n",
- "\n",
- "print \" The value of Kp = %f and Ky = %f \"%(Kp,Ky);\n",
- "print \" The mole fractions of NH3 at equilibrium is %f\"%(y_NH3);\n",
- "\n",
- "\t\t\t# If reaction carried out at constant temperature and volume\n",
- "\n",
- "\t\t\t# We know that for ideal gas, P*V = n*R*T and thus P is directly proportional to n at constant V and T.\n",
- "\t\t\t# Let P = k*n\n",
- "\t\t\t# Initially P = 4 atm and n = 4 moles, thus K = 1 and we get p = n, where P is in atm. \n",
- "\t\t\t# Thus at equilibrium P = 4 - X\n",
- "\n",
- "\t\t\t# Ky = K/Kp = 1.175*P = 1.175*(4 - X)\n",
- "\t\t\t# (X/(4-X))/(((1-0.5*X)/(4-X))**(1/2)*((3-1.5*X)/(4-X))**(3/2)) = 1.175*(4 - X)\n",
- "\t\t\t# Solving the above equation we get\n",
- "def f1(X): \n",
- "\t return (X/(4-X))/(((1-0.5*X)/(4-X))**(1./2)*((3-1.5*X)/(4-X))**(3./2))-1.175*(4-X)\n",
- "X_prime = fsolve(f1,1)\n",
- "\n",
- "\t\t\t# Therefore at equilibrium \n",
- "P_prime = 4 - X_prime;\n",
- "y_NH3_prime = X_prime/(4-X_prime);\n",
- "\n",
- "print \" If reaction is carried out at constant temperature and volumethen\"\n",
- "print \" The equilibrium pressure is %f atm\"%(P_prime);\n",
- "print \" The equilibrium mole fractions of NH3 in the reactor is %f\"%(y_NH3_prime);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of Kp = 0.250000 and Ky = 4.700000 \n",
- " The mole fractions of NH3 at equilibrium is 0.454388\n",
- " If reaction is carried out at constant temperature and volumethen"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " The equilibrium pressure is 2.863057 atm\n",
- " The equilibrium mole fractions of NH3 in the reactor is 0.397108\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.5 Page Number : 601"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 400;\t\t\t#[K] - Reactor temperature\n",
- "P = 1;\t\t\t#[atm] - Reactor pressure\n",
- "K = 1.52;\t\t\t# Equilibrium constant\n",
- "y_H2 = 0.4;\t\t\t# Equilibrium mole fraction of hydrogen\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# CO(g) + 2*H_2(g) - CH3OH(g)\n",
- "\n",
- "\t\t\t# K = y_CH3OH/(y_CO*y_H2**(2)*P**(2))\n",
- "\t\t\t# Let total number of moles at equilibrium be 1\n",
- "\t\t\t# y_CH3OH = 0.6 - y_CO;\n",
- "\t\t\t# (0.6 - y_CO)/y_CO = K*P**(2)*y_H2**(2)\n",
- "\n",
- "y_CO = 0.6/(1 + K*P**(2)*y_H2**(2));\n",
- "y_CH3OH = 0.6 - y_CO;\n",
- "\n",
- "\n",
- "# Results\n",
- "print \" The mole fractions are y_CO = %f and y_CH3OH = %f \"%(y_CO,y_CH3OH);"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The mole fractions are y_CO = 0.482625 and y_CH3OH = 0.117375 \n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.6 Page Number : 602"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 749.;\t\t\t#[K] - Reactor temperature\n",
- "P = 1.;\t\t\t#[atm] - Reactor pressure\n",
- "K = 74.;\n",
- "\n",
- "# Calculations and Results\n",
- "Kp = P**(-1./2);\t\t\t#[atm**(-1/2)]\n",
- "Ky = K/Kp;\n",
- "\n",
- "\t\t\t# SO2 + (1/2)*O2 - SO3\n",
- "\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_SO2_1_in = 10;\n",
- "n_O2_1_in = 8;\n",
- "n_SO3_1_in = 0;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_SO2_1_eq = 10 - X\n",
- "\t\t\t# n_O2_1_eq = 8 - 0.5*X\n",
- "\t\t\t# SO3_1_eq = X\n",
- "\t\t\t# Total moles = 18 - 0.5*X\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "\t\t\t# y_SO3 = X/(18-0.5*X)\n",
- "\t\t\t# y_SO2 = (10-X)/(18-0.5*X)\n",
- "\t\t\t# y_O2 = (8-0.5*X)/(18-0.5*X)\n",
- "\n",
- "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
- "\t\t\t# Ky = (X*(18-0.5*X)**(1/2))/((10-X)*(8-0.5*X)**(1/2))\n",
- "def f(X): \n",
- "\t return Ky-(X*(18-0.5*X)**(1./2))/((10-X)*(8-0.5*X)**(1./2))\n",
- "X_1 = fsolve(f,11)\n",
- "\n",
- "n_SO3 = X_1;\n",
- "n_SO2 = 10 - X_1;\n",
- "n_O2 = 8 - 0.5*X_1;\n",
- "\n",
- "print \" 1).The moles of the components at equilibrium are n_SO3 = %f mol n_SO2 = %f mol and n_O2 = %f mol\"%(n_SO3,n_SO2,n_O2);\n",
- "\n",
- "\t\t\t# Now for the reaction\n",
- "\t\t\t# 2*SO2 + O2 - 2*SO3\n",
- "\n",
- "\t\t\t# The equilibrium constant for this reaction is KP**(2)\n",
- "Ky_prime = Ky**(2);\n",
- "\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_SO2_1_eq = 10 - 2*X\n",
- "\t\t\t# n_O2_1_eq = 8 - X\n",
- "\t\t\t# SO3_1_eq = 2*X\n",
- "\t\t\t# Total moles = 18 - X\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "\t\t\t# y_SO3 = 2*X/(18-X)\n",
- "\t\t\t# y_SO2 = (10-2*X)/(18-X)\n",
- "\t\t\t# y_O2 = (8- X)/(18-X)\n",
- "\n",
- "\t\t\t# Ky_prime = y_SO3**(2)/(y_SO2**(2)*y_O2)\n",
- "\t\t\t# Ky_prime = ((2*X)**(2)*(18-X))/((10-2*X)**(2)*(8-X))\n",
- "def f1(X): \n",
- "\t return Ky_prime-((2*X)**(2)*(18-X))/(((10-2*X)**(2))*(8-X))\n",
- "X_2 = fsolve(f1,6)\n",
- "\n",
- "n_SO3_prime = 2*X_2;\n",
- "n_SO2_prime = 10 - 2*X_2;\n",
- "n_O2_prime = 8 - X_2;\n",
- "\n",
- "print \" 2).The moles of the components at equilibrium are n_SO3 = %f mol n_SO2 = %f mol and n_O2 = %f mol\"%(n_SO3_prime,n_SO2_prime,n_O2_prime);\n",
- "print \" Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The moles of the components at equilibrium are n_SO3 = 9.730824 mol n_SO2 = 0.269176 mol and n_O2 = 3.134588 mol\n",
- " 2).The moles of the components at equilibrium are n_SO3 = 9.730824 mol n_SO2 = 0.269176 mol and n_O2 = 3.134588 mol\n",
- " Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.7 Page Number : 603"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 500;\t\t\t#[K]\n",
- "\t\t\t# For the reaction, 0.5*A2 + 0.5*B2 - AB\n",
- "delta_G = -4200;\t\t\t#[J/mol]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\t\t\t#(1)\n",
- "\t\t\t# A2 + B2 - 2*AB\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# We know delta_G_rkn_0 = -R*T*math.log(K) \n",
- "delta_G_1 = 2*delta_G;\n",
- "K_1 = math.exp(-delta_G_1/(R*T));\t\t\t# Equilibrium constant at 500 K for the above reaction\n",
- "\t\t\t# As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n",
- "Ky = K_1;\n",
- "\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_A2_1_in = 0.5;\n",
- "n_B2_1_in = 0.5;\n",
- "n_AB_1_in = 0;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_A2_1_eq = 0.5 - X\n",
- "\t\t\t# n_B2_1_eq = 0.5- X\n",
- "\t\t\t# n_AB_1_eq = 2*X\n",
- "\t\t\t# Total moles = 1\n",
- "\n",
- "\t\t\t# Ky = (2*X)**(2)/(0.5-X)**(2)\n",
- "def f(X): \n",
- "\t return Ky-(2*X)**(2)/(0.5-X)**(2)\n",
- "X_1 = fsolve(f,0.2)\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "y_A2_1 = 0.5 - X_1;\n",
- "y_B2_1 = 0.5- X_1;\n",
- "y_AB_1 = 2*X_1;\n",
- "\n",
- "print \" 1).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_1,y_B2_1,y_AB_1);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# 0.5*A2 + 0.5*B2 - AB\n",
- "\n",
- "\t\t\t# We know delta_G_rkn_0 = -R*T*math.log(K) \n",
- "delta_G_2 = delta_G;\n",
- "K_2 = math.exp(-delta_G_2/(R*T));\t\t\t# Equilibrium constant at 500 K for the above reaction\n",
- "\n",
- "\t\t\t# As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n",
- "Ky_2 = K_2;\n",
- "\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_A2_2_in = 0.5;\n",
- "n_B2_2_in = 0.5;\n",
- "n_AB_2_in = 0;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_A2_2_eq = 0.5 - 0.5*X\n",
- "\t\t\t# n_B2_2_eq = 0.5- 0.5*X\n",
- "\t\t\t# n_AB_2_eq = X\n",
- "\t\t\t# Total moles = 1\n",
- "\n",
- "\t\t\t# Ky = y_AB/(y_A2**(1/2)*y_B2**(1/2))\n",
- "\t\t\t# Ky = X/(0.5 - 0.5*X)\n",
- "X_2 = 0.5*Ky_2/(1+0.5*Ky_2);\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "y_A2_2 = 0.5 - 0.5*X_2;\n",
- "y_B2_2 = 0.5- 0.5*X_2;\n",
- "y_AB_2 = X_2;\n",
- "\n",
- "print \" 2).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_2,y_B2_2,y_AB_2);\n",
- "\n",
- "\t\t\t#(3)\n",
- "\t\t\t# 2*AB - A2 + B2\n",
- "\n",
- "K_3 = 1/K_1;\t\t\t# Equilibrium constant at 500 K for the above reaction\n",
- "\t\t\t# As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n",
- "Ky_3 = K_3;\n",
- "\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "n_AB_3_in = 1;\n",
- "n_A2_3_in = 0;\n",
- "n_B2_3_in = 0;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_AB_3_eq = 1 - X\n",
- "\t\t\t# n_A2_3_eq = X/2\n",
- "\t\t\t# n_B2_3_eq = X/2\n",
- "\t\t\t# Total moles = 1\n",
- "\n",
- "\t\t\t# Ky = (X/2)**(2)/(1-X)**(2)\n",
- "def f1(X): \n",
- "\t return Ky_3-(X/2)**(2)/(1-X)**(2)\n",
- "X_3 = fsolve(f1,0.4)\n",
- "\n",
- "\t\t\t# The mole fractions of the components at equilibrium are\n",
- "y_A2_3 = X_3/2;\n",
- "y_B2_3 = X_3/2;\n",
- "y_AB_3 = 1-X_3;\n",
- "\n",
- "print \" 3).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_3,y_B2_3,y_AB_3);"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n",
- " 2).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n",
- " 3).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.9 Page Number : 606"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\t\t\n",
- "\n",
- "# Variables\n",
- "R = 1.987;\t\t\t#[cal/mol-K]\n",
- "\n",
- "delta_H_SO2_298 = -70.96;\t\t\t#[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n",
- "delta_H_SO3_298 = -94.45;\t\t\t#[kcal/mol] - Enthalpy of formation of S03 at 298.15 K\n",
- "delta_G_SO2_298 = -71.79;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n",
- "delta_G_SO3_298 = -88.52;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO3 at 298.15 K\n",
- "\n",
- "\t\t\t# Cp_0 = a + b*T + c*T**(2) + d*T**(3)\n",
- "\n",
- "a_SO2 = 6.157;\n",
- "a_SO3 = 3.918;\n",
- "a_O2 = 6.085;\n",
- "b_SO2 = 1.384*10**(-2);\n",
- "b_SO3 = 3.483*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "c_SO2 = -0.9103*10**(-5);\n",
- "c_SO3 = -2.675*10**(-5);\n",
- "c_O2 = -0.1709*10**(-5);\n",
- "d_SO2 = 2.057*10**(-9);\n",
- "d_SO3 = 7.744*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "\n",
- "\t\t\t#(1)\n",
- "T_1 = 298.15;\t\t\t#[K]\n",
- "\n",
- "# Calculations and Results\n",
- "delta_H_rkn_298 = delta_H_SO3_298 - delta_H_SO2_298;\t\t\t#[kcal]\n",
- "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
- "delta_G_rkn_298 = delta_G_SO3_298 - delta_G_SO2_298;\t\t\t#[kcal]\n",
- "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
- "\n",
- "delta_a = a_SO3 - a_SO2 - (a_O2/2);\n",
- "delta_b = b_SO3 - b_SO2 - (b_O2/2);\n",
- "delta_c = c_SO3 - c_SO2 - (c_O2/2);\n",
- "delta_d = d_SO3 - d_SO2 - (d_O2/2);\n",
- "\n",
- "\n",
- "def f60(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f60,T_1,T)[0]\n",
- "\n",
- "\t\t\t# On simplification we get\n",
- "\t\t\t# delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10**(-2)*T**(2) - 0.5598*10**(-5)*T**(3) + 1.3826*10**(-9)*T**(4)\n",
- "\n",
- "print \" 1.The math.expression for delta_H_rkn_T as a function of T is given by\";\n",
- "print \" delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10**-2*T**2 - 0.5598*10**-5*T**3 + 1.3826*10**-9*T**4\";\n",
- "\n",
- "\t\t\t#(2)\n",
- "\n",
- "\n",
- "\t\t\t#def f61(T): \n",
- "\t\t\t#\t return K_T/K_298) = integrate(delta_H_rkn_T/T**(2)\n",
- "\n",
- "\t\t\t# R*math.log(K_T/K_298) = quad(f61,T_1,T)[0]\n",
- "\n",
- "\t\t\t# First let us calculate K_298.\n",
- "\t\t\t# delta_G_rkn_T = - R*T*math.log(K)\n",
- "K_298 = math.exp(-delta_G_rkn_298/(R*T_1));\n",
- "\n",
- "\t\t\t# On substituting the values and simplifying we get the math.expression\n",
- "\t\t\t# math.log(K) = 3.87 + 11380.10/T - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3)\n",
- "\n",
- "print \" 2.The math.expression for math.logK as a function of T is given by\";\n",
- "print \" math.logK = 3.87 + 11380.10/T - 2.6580*math.logT + 0.4825*10**-2*T - 0.1409*10**-5*T**2 + 0.2320*10**-9*T**3\";\n",
- "\n",
- "\t\t\t#(3)\n",
- "P = 1;\t\t\t#[atm]\n",
- "T = 880;\t\t\t#[K]\n",
- "K = math.exp(3.87 + 11380.10/T - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3));\n",
- "Kp = P**(-1./2);\t\t\t#[atm**(-1/2)]\n",
- "Ky = K/Kp;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_SO2_eq = 1 - X\n",
- "\t\t\t# n_O2_eq = 0.5- 0.5*X\n",
- "\t\t\t# n_SO3_1_eq = X\n",
- "\t\t\t# Total moles = 1.5-0.5*X\n",
- "\n",
- "\t\t\t# Ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
- "def f(X): \n",
- "\t return Ky - (X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
- "X = fsolve(f,0.8)\n",
- "\n",
- "\t\t\t# The mole fraction of SO3 at equilibrium is given by\n",
- "y_SO3 = X/(1.5-0.5*X);\n",
- "\n",
- "print \" 3).The mole fraction of SO3 at equilibrium is given by y_SO3 = %f\"%(y_SO3);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1.The math.expression for delta_H_rkn_T as a function of T is given by\n",
- " delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10**-2*T**2 - 0.5598*10**-5*T**3 + 1.3826*10**-9*T**4\n",
- " 2.The math.expression for math.logK as a function of T is given by\n",
- " math.logK = 3.87 + 11380.10/T - 2.6580*math.logT + 0.4825*10**-2*T - 0.1409*10**-5*T**2 + 0.2320*10**-9*T**3\n",
- " 3).The mole fraction of SO3 at equilibrium is given by y_SO3 = 0.649167\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.10 Page Number : 609"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "from numpy import *\n",
- "\n",
- "# Variables\n",
- "\t\t\t# (1/2)*N2 + (1/2)*O2 - NO\n",
- "\n",
- "R = 1.987;\t\t\t#[cal/mol-K]\n",
- "\n",
- "delta_H_NO_298 = 21.600;\t\t\t#[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n",
- "delta_G_NO_298 = 20.719;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n",
- "\n",
- "\t\t\t# Cp_0 = a + b*T + c*T**(2) + d*T**(3)\n",
- "\n",
- "a_N2 = 6.157;\n",
- "a_O2 = 6.085;\n",
- "a_NO = 6.461;\n",
- "b_N2 = -0.03753*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "b_NO = 0.2358*10**(-2);\n",
- "c_N2 = 0.1930*10**(-5);\n",
- "c_O2 = -0.1709*10**(-5);\n",
- "c_NO = -0.07705*10**(-5);\n",
- "d_N2 = -0.6861*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "d_NO = 0.08729*10**(-9);\n",
- "\n",
- "\t\t\t#(1)\n",
- "T_1 = 298.15;\t\t\t#[K]\n",
- "\n",
- "# Calculations and Results\n",
- "delta_H_rkn_298 = delta_H_NO_298;\t\t\t#[kcal]\n",
- "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
- "delta_G_rkn_298 = delta_G_NO_298;\t\t\t#[kcal]\n",
- "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
- "\n",
- "delta_a = a_NO - (a_N2/2) - (a_O2/2);\n",
- "delta_b = b_NO - (b_N2/2) - (b_O2/2);\n",
- "delta_c = c_NO - (c_N2/2) - (c_O2/2);\n",
- "delta_d = d_NO - (d_N2/2) - (d_O2/2);\n",
- "\n",
- "\n",
- "def f49(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f49,T_1,T)[0]\n",
- "\n",
- "\t\t\t# On simplification we get\n",
- "\t\t\t# delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10**(-2)*T**(2) - 0.0293*10**(-5)*T**(3) + 0.0685*10**(-9)*T**(4)\n",
- "\n",
- "print \" The math.expression for delta_H_rkn_T as a function of T is given by\";\n",
- "print \" delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10**-2*T**2 - 0.0293*10**-5*T**3 + 0.0685*10**-9*T**4\";\n",
- "\n",
- "\t\t\t# Now let us calculate K_298 (at 298 K)\n",
- "\t\t\t# We know delta_G_rkn_298 = -R*T*math.log(K_298) \n",
- "K_298 = math.exp(-delta_G_rkn_298/(R*T_1));\t\t\t# Equilibrium constant at 298.15 K\n",
- "\n",
- "\n",
- "\t\t\t#def f50(T): \n",
- "\t\t\t#\t return K_2/K_1) = integrate(delta_H_rkn_298/(R*T**(2))\n",
- "\n",
- "\t\t\t# math.log(K_2/K_1) = quad(f50,T_1,T)[0]\n",
- "\n",
- "\t\t\t# On substituting the values and simplifying we get the math.expression\n",
- "\t\t\t# math.log(K) = 1.5103 - 10862.92/T - 0.0166*math.log(T) + 1.84*10**(-4)*T - 7.35*10**(-8)*T**(2) + 1.15*10**(-11)*T**(3)\n",
- "\n",
- "print \" The math.expression for math.logK as a function of T is given by\";\n",
- "print \" math.logK = 1.5103 - 10862.92/T - 0.0166*math.logT + 1.84*10**-4*T - 7.35*10**-8*T**2 + 1.15*10**-11*T**3\"\n",
- "\n",
- "T = [500,1000,1500,2000,2500];\n",
- "K = zeros(5);\n",
- "\n",
- "print \" T K \\t\\t\\t K \";\n",
- "\n",
- "for i in range(5):\n",
- " K[i] = math.exp(1.5103-10862.92/T[i] - 0.0166*math.log(T[i]) + 1.84*10**(-4)*T[i] - 7.35*10**(-8)*T[i]**(2) + 1.15*10**(-11)*T[i]**(3));\n",
- " \n",
- " print \" %f \\t\\t %e \"%(T[i],K[i]);\n",
- "\n",
- "\n",
- "\t\t\t# It can be seen that for endothermic reactions equilibrium constant increases with temperature.\n",
- "print \" It can be seen that for endothermic reactions equilibrium constant increases with temperature\";\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The math.expression for delta_H_rkn_T as a function of T is given by\n",
- " delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10**-2*T**2 - 0.0293*10**-5*T**3 + 0.0685*10**-9*T**4\n",
- " The math.expression for math.logK as a function of T is given by\n",
- " math.logK = 1.5103 - 10862.92/T - 0.0166*math.logT + 1.84*10**-4*T - 7.35*10**-8*T**2 + 1.15*10**-11*T**3\n",
- " T K \t\t\t K \n",
- " 500.000000 \t\t 1.615470e-09 \n",
- " 1000.000000 \t\t 8.737610e-05 \n",
- " 1500.000000 \t\t 3.333913e-03 \n",
- " 2000.000000 \t\t 2.062328e-02 \n",
- " 2500.000000 \t\t 6.176400e-02 \n",
- " It can be seen that for endothermic reactions equilibrium constant increases with temperature\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.11 Page Number : 611"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "\t\t\t# SO2 + (1/2)*O2 - SO3\n",
- "R = 8.314;\t\t\t#[J/mol-K]\n",
- "\n",
- "K_800 = 0.0319;\t\t\t# Equilibrium constant at 800 K\n",
- "K_900 = 0.153;\t\t\t# Equilibrium constant at 900 K\n",
- "T_1 = 800.;\t\t\t#[K]\n",
- "T_2 = 900.;\t\t\t#[K]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# We have the relation \n",
- "\t\t\t# math.log(K_2/K_1) = -(delta_H_rkn/R)*(1/T_2 - 1/T_1)\n",
- "\t\t\t# math.log(K_900/K_800) = -(delta_H_rkn_850/R)*(1/T_2 - 1/T_1)\n",
- "delta_H_rkn_850 = -R*math.log(K_900/K_800)/(1/T_2 - 1/T_1);\t\t\t#[J]\n",
- "delta_H_rkn_850 = delta_H_rkn_850*10**(-3);\t\t\t#[kJ]\n",
- "\n",
- "# Results\n",
- "print \" The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = %f KJ\"%(delta_H_rkn_850);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = 93.851672 KJ\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.13 Page Number : 611"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K]\n",
- "T = 2600;\t\t\t#[K]\n",
- "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n",
- "\n",
- "\t\t\t# Cp_0 = a + b*T + c*T**(2) + d*T**(3)\n",
- "delta_H_CO_298 = -26.416;\t\t\t#[kcal/mol] - Enthalpy of formation of CO at 298.15 K\n",
- "delta_G_CO_298 = -32.808;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n",
- "delta_H_CO2_298 = -94.052;\t\t\t#[kcal/mol] - Enthalpy of formation of C02 at 298.15 K\n",
- "delta_G_CO2_298 = -94.260;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n",
- "\n",
- "\t\t\t# CO + (1/2)*O2 - CO2\n",
- "\n",
- "a_CO = 6.726;\n",
- "a_O2 = 6.0685;\n",
- "a_CO2 = 5.316;\n",
- "b_CO = 0.04001*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "b_CO2 = 1.4285*10**(-2);\n",
- "c_CO = 0.1283*10**(-5);\n",
- "c_O2 = -0.1709*10**(-5);\n",
- "c_CO2 = -0.8362*10**(-5);\n",
- "d_CO = -0.5307*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "d_CO2 = 1.784*10**(-9);\n",
- "\n",
- "# Calculations and Results\n",
- "delta_H_rkn_298 = delta_H_CO2_298 - delta_H_CO_298;\t\t\t#[kcal]\n",
- "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
- "delta_G_rkn_298 = delta_G_CO2_298 - delta_G_CO_298;\t\t\t#[kcal]\n",
- "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
- "\n",
- "delta_a = a_CO2 - (a_CO) - (a_O2/2);\n",
- "delta_b = b_CO2 - (b_CO) - (b_O2/2);\n",
- "delta_c = c_CO2 - (c_CO) - (c_O2/2);\n",
- "delta_d = d_CO2 - (d_CO) - (d_O2/2);\n",
- "\n",
- "\n",
- "def f47(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f47,T_1,T)[0]\n",
- "\n",
- "\t\t\t# On simplification we get\n",
- "delta_H_rkn_T = -66773.56 - 4.45*T + 0.605*10**(-2)*T**(2) - 0.29*10**(-5)*T**(3) + 0.54*10**(-9)*T**(4);\n",
- "\n",
- "\n",
- "\t\t\t#def f48(T): \n",
- "\t\t\t#\t return K/K_298) = integrate(delta_H_rkn_T/(R*T**(2))\n",
- "\n",
- "\t\t\t# math.log(K/K_298) = quad(f48,T_1,T)[0]\n",
- "\n",
- "\n",
- "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
- "\t\t\t# At 298.15 K\n",
- "K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
- "\n",
- "\t\t\t# Therfore on simplification we get\n",
- "\t\t\t#math.log(K) = 2.94 + 33605.2/T - 2.24*math.log(T) + 0.304*10(-2)*T - 0.073*10**(-5)*T**(2) + 0.09*10**(-9)*T**(3)\n",
- "K = math.exp(2.94 + 33605.2/T - 2.24*math.log(T) + 0.304*10**(-2)*T - 0.073*10**(-5)*T**(2) + 0.09*10**(-9)*T**(3));\n",
- "\n",
- "print \" The value of equilibrium constant at 2600 K is given by K_298 = %f\"%(K);\n",
- "\n",
- "\n",
- "\t\t\t#(a)\n",
- "P_1 = 1;\t\t\t#[atm]\n",
- "Kp_1 = P_1**(-1./2);\n",
- "Ky_1 = K/Kp_1;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_CO_1_eq = 1 - X\n",
- "\t\t\t# n_02_1_eq = 0.5- 0.5X\n",
- "\t\t\t# n_CO2_1_eq = X\n",
- "\t\t\t# Total moles = 1.5 - 0.5*X\n",
- "\n",
- "\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n",
- "\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
- "\n",
- "def f(X): \n",
- "\t return Ky_1-(X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
- "X_1 = fsolve(f,0.9)\n",
- "\n",
- "y_CO2_1 = X_1/(1.5-0.5*X_1);\n",
- "y_CO_1 = (1-X_1)/(1.5-0.5*X_1);\n",
- "y_O2_1 = (0.5-0.5*X_1)/(1.5-0.5*X_1);\n",
- "\n",
- "print \" a).The equilibrium composition at 1 atm) is given by y_CO2 = %f y_CO = %f and y_O2 = %f\"%(y_CO2_1,y_CO_1,y_O2_1);\n",
- "\n",
- "\t\t\t#(b)\n",
- "P_2 = 10;\t\t\t#[atm]\n",
- "Kp_2 = P_2**(-1./2);\n",
- "Ky_2 = K/Kp_2;\n",
- "\n",
- "\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n",
- "\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
- "\n",
- "def f1(X): \n",
- "\t return Ky_2-(X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
- "X_2 = fsolve(f1,0.9)\n",
- "\n",
- "y_CO2_2 = X_2/(1.5-0.5*X_2);\n",
- "y_CO_2 = (1-X_2)/(1.5-0.5*X_2);\n",
- "y_O2_2 = (0.5-0.5*X_2)/(1.5-0.5*X_2);\n",
- "\n",
- "print \" b).The equilibrium composition at 10 atm) is given by y_CO2 = %f y_CO = %f and y_O2 = %f\"%(y_CO2_2,y_CO_2,y_O2_2);\n",
- "\n",
- "\t\t\t#(c)\n",
- "P_3 = 1;\t\t\t#[atm]\n",
- "Kp_3 = P_3**(-1./2);\n",
- "Ky_3 = K/Kp_3;\n",
- "\n",
- "\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n",
- "\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
- "\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_CO_3_eq = 1 - X\n",
- "\t\t\t# n_02_3_eq = 0.5- 0.5X\n",
- "\t\t\t# n_CO2_3_eq = X\n",
- "\t\t\t# n_N2_eq = 1;\n",
- "\t\t\t# Total moles = 2.5 - 0.5*X\n",
- "\n",
- "def f2(X): \n",
- "\t return Ky_3-(X*(2.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
- "X_3 = fsolve(f2,0.9)\n",
- "\n",
- "y_CO2_3 = X_3/(2.5-0.5*X_3);\n",
- "y_CO_3 = (1-X_3)/(2.5-0.5*X_3);\n",
- "y_O2_3 = (0.5-0.5*X_3)/(2.5-0.5*X_3);\n",
- "y_N2 = 1./(2.5-0.5*X_3);\n",
- "\n",
- "print \" c).The equilibrium composition at 1 atm and 1 mol N2) is given by y_CO2 = %f y_CO = %f y_O2 = %f and y_N2 = %f\"%(y_CO2_3,y_CO_3,y_O2_3,y_N2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of equilibrium constant at 2600 K is given by K_298 = 16.484152\n",
- " a).The equilibrium composition at 1 atm) is given by y_CO2 = 0.757531 y_CO = 0.161646 and y_O2 = 0.080823\n",
- " b).The equilibrium composition at 10 atm) is given by y_CO2 = 0.876008 y_CO = 0.082662 and y_O2 = 0.041331\n",
- " c).The equilibrium composition at 1 atm and 1 mol N2) is given by y_CO2 = 0.373822 y_CO = 0.100943 y_O2 = 0.050471 and y_N2 = 0.474764\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.14 Page Number : 614"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 25 + 298.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol-K]\n",
- "delta_G_298 = -1000;\t\t\t#[J] - Gibbs free energy change at 298 K\n",
- "\n",
- "\t\t\t# G_E/(R*T) = x_1*x_2\n",
- "# Calculations and Results\n",
- "\t\t\t# We know that delta_G_rkn = - R*T*math.log(K), therefore\n",
- "K = math.exp(-delta_G_298/(R*T));\n",
- "\n",
- "\t\t\t#(1)\n",
- "\t\t\t# Let x_1 is the mole fraction of A and x_2 be the mole fraction of B\n",
- "\t\t\t# If A and B form an ideal mixture then,\n",
- "Ky = 1;\n",
- "\t\t\t# and K = Kx = x_2/x_1\n",
- "\t\t\t# and at equilibrium x_2/x_1 = K\n",
- "\t\t\t# (1-x_1)/x_1 = K\n",
- "x_1 = 1/(1+K);\n",
- "\n",
- "print \" 1).The equilibrium composition for ideal behaviour) is given by x_1 = %f\"%(x_1);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# The activity coefficients are given by\n",
- "\t\t\t# math.log(Y1) = [del(n*G_E/(R*T))/del(n_1)]_T,P,n_2 = x_2**(2)\n",
- "\t\t\t# similarly, math.log(Y2) = x_1**(2)\n",
- "\n",
- "\t\t\t# The equilibrium constant for the liquid phase reaction is given by\n",
- "\t\t\t# K = Kx*Ky = (x_2*Y2)/(x_1*Y1) = (x_2*math.exp(x_1**(2)))/(x_1*math.exp(x_2**(2)))\n",
- "\t\t\t# Solving the above equation we get\n",
- "\n",
- "def f2(x_1): \n",
- "\t return K -((1-x_1)*math.exp(x_1**(2)))/(x_1*math.exp((1-x_1)**(2)))\n",
- "x_1_prime = fsolve(f2,0.9)\n",
- "\n",
- "print \" 2).The equilibrium composition for non-ideal behaviour) is given by x_1 = %f\"%(x_1_prime);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The equilibrium composition for ideal behaviour) is given by x_1 = 0.408008\n",
- " 2).The equilibrium composition for non-ideal behaviour) is given by x_1 = 0.328409\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.15 Page Number : 615"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\t\t\t\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "T_2 = 373.;\t\t\t#[K] - Reaction temperature\n",
- "P = 1.;\t\t\t#[atm]\n",
- "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n",
- "\n",
- "\t\t\t# CH3COOH (l) + C2H5OH (l) - CH3COOC2H5 (l) + H2O (l)\n",
- "\n",
- "delta_H_CH3COOH_298 = -116.2*10**(3.);\t\t\t# [cal/mol]\n",
- "delta_H_C2H5OH_298 = -66.35*10**(3.);\t\t\t# [cal/mol]\n",
- "delta_H_CH3COOC2H5_298 = -110.72*10**(3.);\t\t\t# [cal/mol]\n",
- "delta_H_H2O_298 = -68.3174*10**(3.);\t\t\t# [cal/mol]\n",
- "\n",
- "delta_G_CH3COOH_298 = -93.56*10**(3.);\t\t\t# [cal/mol]\n",
- "delta_G_C2H5OH_298 = -41.76*10**(3.);\t\t\t# [cal/mol]\n",
- "delta_G_CH3COOC2H5_298 = -76.11*10**(3.);\t\t\t# [cal/mol]\n",
- "delta_G_H2O_298 = -56.6899*10**(3.);\t\t\t# [cal/mol]\n",
- "\n",
- "# Calculations and Results\n",
- "delta_H_rkn_298 = delta_H_CH3COOC2H5_298 + delta_H_H2O_298 - delta_H_CH3COOH_298 - delta_H_C2H5OH_298;\t\t\t#[cal/mol]\n",
- "delta_G_rkn_298 = delta_G_CH3COOC2H5_298 + delta_G_H2O_298 - delta_G_CH3COOH_298 - delta_G_C2H5OH_298;\t\t\t#[cal/mol]\n",
- "\n",
- "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
- "\t\t\t# At 298.15 K\n",
- "K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
- "\n",
- "\t\t\t# We know that dmath.log(K)/dT = delta_H_rkn/(R*T**(2))\n",
- "\t\t\t# If delta_H_rkn is assumed constant we get\n",
- "\t\t\t# math.log(K_2/K_1) = (-delta_H_rkn/R)*(1/T_2 - 1/T_1)\n",
- "\t\t\t# math.log(K_373/K_298) = (-delta_H_rkn_298/R)*(1/T_2 - 1/T_1)\n",
- "\n",
- "K_373 = math.exp(math.log(K_298) + (-delta_H_rkn_298/R)*(1./T_2 - 1./T_1));\n",
- "\t\t\t# Note that the equilibrium constant value rises becauses the reaction is endothermic\n",
- "\n",
- "print \" The value of equilibrium constant at 373 K is K_373 = %f\"%(K_373);\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_CH3COOH = 1 - X\n",
- "\t\t\t# n_C2H5OH = 1 - X\n",
- "\t\t\t# n_CH3COOC2H5 = X\n",
- "\t\t\t# n_H20 = X\n",
- "\t\t\t# Total moles = 2\n",
- "\n",
- "\t\t\t# Kx = (x_CH3COOH*x_C2H5OH)/(x_CH3COOC2H5*x_H2O)\n",
- "\t\t\t# Assuming the liquid mixture to be ideal,that is Ky = 1, therefore K_x = K\n",
- "K_x = K_373;\n",
- "\t\t\t# X**(2)/(1-X)**(2) = K_x\n",
- "X = (K_x)**(1./2)/(1+(K_x)**(1./2));\n",
- "\n",
- "\t\t\t# The mole fraction of ethyl acetate is given by\n",
- "x_CH3COOC2H5 = X/2;\n",
- "\n",
- "print \" The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by x_CH3COOC2H5 = %f\"%(x_CH3COOC2H5);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of equilibrium constant at 373 K is K_373 = 0.046697\n",
- " The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by x_CH3COOC2H5 = 0.088848\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.16 Page Number : 617"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "\t\t\t# CaCO3 (s1) - CaO (s2) + CO2 (g)\n",
- "T_1 = 898 + 273.15;\t\t\t#[K]\n",
- "T_2 = 700 + 273.15;\t\t\t#[K]\n",
- "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
- "\n",
- "P_CO2_T_1 = 1;\t\t\t#[atm] - Decomposition pressure of CO2 over CaCO3 at 898 C\n",
- "P_CO2_T_2 = 0.0333;\t\t\t#[atm] - Decomposition pressure of CO2 over CaCO3 at 700 C\n",
- "\n",
- "\t\t\t# The equilibrium constant of the reaction is given by\n",
- "\t\t\t# K = (a_CO2*a_CaO)/a_CaCO3\n",
- "\n",
- "\t\t\t# Since the pressure is small therefore carbon dioxide can be assumed to behave as ideal gas and thus\n",
- "\t\t\t# a_CO2 = y_CO2*P/1 = P_CO2\n",
- "\n",
- "\t\t\t# The activity of CaO is (CaO is pure)\n",
- "\t\t\t# a_CaO = f_CaO/f_0_CaO = exp[V_CaO*(P - P_0)/(R*T)] = 1 (since pressure is low)\n",
- "\n",
- "\t\t\t# The activity of CaCO3 is (CaCO3 is pure)\n",
- "\t\t\t# a_CaCO3 = f_CaCO3/f_0_CaCO3 = exp[V_CaCO3*(P - P_0)/(R*T)] = 1 (since pressure is low)\n",
- "\n",
- "\t\t\t#Since pressures are around 1 atm,therefore Poynting factors are also near 1, and thus activity of CaO and CaCO3 is unity and equilibrium constant is given by\n",
- "\t\t\t#K = P_CO2 , therefore\n",
- "# Calculations \n",
- "\t\t\t# At 898 C\n",
- "K_T_1 = P_CO2_T_1;\n",
- "delta_G_T_1 = -R*T_1*math.log(K_T_1);\n",
- "\n",
- "\t\t\t# At 700 C\n",
- "K_T_2 = P_CO2_T_2;\n",
- "delta_G_T_2 = -R*T_2*math.log(K_T_2);\n",
- "\n",
- "# Results\n",
- "print \" The value of delta_G_rkn at 700 C is %f J\"%(delta_G_T_1);\n",
- "print \" The value of delta_G_rkn at 898 C is %f J\"%(delta_G_T_2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of delta_G_rkn at 700 C is -0.000000 J\n",
- " The value of delta_G_rkn at 898 C is 27526.397496 J\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.17 Page Number : 618"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 700 + 273.15;\t\t\t#[K]\n",
- "K = 7.403;\t\t\t# Equilibrium constant for the reaction at 700 C\n",
- "\n",
- "\t\t\t# CH4 - C (s) + 2*H2 \n",
- "\n",
- "\t\t\t# The equilibrium constant of the reaction is given by\n",
- "\t\t\t# K = (a_C*a_H2**(2))/a_CH4\n",
- "\n",
- "\t\t\t# Since carbon is pure therefore its activity is given by\n",
- "\t\t\t# a_C = f/f_0 = 1 as pressure is 1 atm.\n",
- "\t\t\t# Since the pressure is low,therefore the gas phase can be taken to be ideal,therefore\n",
- "\t\t\t# K = (y_H2**(2)*P**(2))/(y_CH4*P) = y_H2**(2)/y_CH4 (as P = 1 atm)\n",
- "Ky = K;\t\t\t# (Kp = 1 atm)\n",
- "\n",
- "\t\t\t# Initial moles of the species are\n",
- "n_CH4 = 1;\n",
- "n_H2 = 0;\n",
- "n_C = 0;\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
- "\t\t\t# Moles at equilibrium be\n",
- "\t\t\t# n_CH4_eq = 1 -X\n",
- "\t\t\t# n_H2_eq = 2*x\n",
- "\t\t\t# n_C_eq = X\n",
- "\n",
- "\t\t\t# Moles present in gas phase\n",
- "\t\t\t# n_CH4_gas = 1 -X\n",
- "\t\t\t# n_H2_gas = 2*x\n",
- "\t\t\t# Total moles = 1 + X\n",
- "\n",
- "\t\t\t# gas phase mole fraction \n",
- "\t\t\t# y_CH4_gas = (1 -X)/(1+X)\n",
- "\t\t\t# y_H2_gas = 2*x/(1+X)\n",
- "\n",
- "# Calculations and Results\n",
- "# Ky = y_H2_gas**(2)/y_CH4_gaS\n",
- "X = (K/(4+K))**(1./2);\n",
- "\n",
- "print \" The number of moles of carbon black formed from one mole of methane is %f mol\"%(X);\n",
- "\n",
- "\t\t\t# Therefore mole fraction of components in the gas phase at equilibrium is \n",
- "y_CH4 = (1-X)/(1+X);\n",
- "y_H2 = 2*X/(1+X);\n",
- "\n",
- "print \" The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = %f and y_H2 = %f \"%(y_CH4,y_H2);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The number of moles of carbon black formed from one mole of methane is 0.805739 mol\n",
- " The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = 0.107580 and y_H2 = 0.892420 \n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.18 Page Number : 619"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "T_2 = 1042;\t\t\t#[K] - Reaction temperature\n",
- "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n",
- "\n",
- "\t\t\t# CaCO3 (s1) - CaO (s2) + CO2 (g)\n",
- "\n",
- "delta_H_CaCO3_298 = -289.5;\t\t\t#[kcal/mol] - Enthalpy of formation of CaCO3 at 298.15 K\n",
- "delta_H_CaO_298 = -151.7;\t\t\t#[kcal/mol] - Enthalpy of formation of CaO at 298.15 K\n",
- "delta_H_CO2_298 = -94.052;\t\t\t#[kcal/mol] - Enthalpy of formation of CO2 at 298.15 K\n",
- "delta_G_CaCO3_298 = -270.8;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CaCO3 at 298.15 K\n",
- "delta_G_CaO_298 = -144.3;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CaO at 298.15 K\n",
- "delta_G_CO2_298 = -94.260;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard heat capacity data as a function of temperature are given below\n",
- "\t\t\t# Cp_CO2 = 5.316 + 1.4285*10**(2)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3)\n",
- "\t\t\t# Cp_CaO = 12.129 + 0.88*10**(-3)*T - 2.08*10**(5)*T**(-2)\n",
- "\t\t\t# Cp_CaCO3 = 24.98 + 5.240*10**(-3)*T - 6.199*10**(5)*T**(-2)\n",
- "\t\t\t# Therefore Cp_0 is given by\n",
- "\t\t\t# Cp_0 = Cp_CO2 + Cp_CaO - Cp_CaCO3\n",
- "\t\t\t# Cp_0 = -7.535 + 9.925*10**(-3)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3) + 4.119*10**(5)*T**(-2)\n",
- "# Calculations and Results\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy change of the reaction at 298.15 K is given by\n",
- "delta_H_rkn_298 = delta_H_CO2_298 + delta_H_CaO_298 - delta_H_CaCO3_298;\t\t\t#[kcal]\n",
- "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
- "delta_G_rkn_298 = delta_G_CO2_298 + delta_G_CaO_298 - delta_G_CaCO3_298;\t\t\t#[kcal]\n",
- "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy change of the reaction at temperature T is given by\n",
- "\n",
- "def f7(T): \n",
- "\t return -7.535 + 9.925*10**(-3)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3) + 4.119*10**(5)*T**(-2)\n",
- "\n",
- "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f7,T_1,T)[0]\n",
- "\n",
- "\t\t\t# On simplification we get\n",
- "\t\t\t# delta_H_rkn_T = 47005.3 - 7.535*T + 4.9625*10**(-3)*T**(2) - 0.2787*10**(-5)*T**(3) + 0.446*10**(-9)*T**(4) - 4.119*10**(5)*T**(-1)\n",
- "\n",
- "\n",
- "\n",
- "\t\t\t#def f8(T): \n",
- "\t\t\t#\t return K_2/K_1) = integrate(delta_H_rkn_T/(R*T**(2))\n",
- "\n",
- "\t\t\t# math.log(K_2/K_1) = quad(f8,T_1,T)[0]\n",
- "\n",
- "\n",
- "def f9(T): \n",
- "\t return (47005.3-7.535*T+4.9625*10**(-3)*T**(2)-0.2787*10**(-5)*T**(3)+0.446*10**(-9)*T**(4) - 4.119*10**(5)*T**(-1))/T**(2)\n",
- "\n",
- "math.log_K2_K1 = quad(f9,T_1,T_2)[0];\t\t\t# math.log(K_2/K_1)[0]\n",
- "\n",
- "\n",
- "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
- "\t\t\t# At 298.15 K\n",
- "K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
- "\n",
- "\t\t\t# Putting the values in the above math.expression we get\n",
- "\t\t\t# math.log(K_1042/K_298) = math.log_K2_K1/R\n",
- "K_1042 = K_298*math.exp(math.log_K2_K1/R);\n",
- "\n",
- "print \" The value of equilibrium constant at 1042 K is K_1042 = %f\"%(K_1042);\n",
- "\n",
- "\t\t\t# Since for the given reaction K = P_CO2,where P is in atm, therefore,\n",
- "P_CO2 = K_1042;\n",
- "\t\t\t# and thus decomposition takes place till the partial pressure of CO2 reaches 0.095 atm\n",
- "\t\t\t# After that the decomposition in the closed vessel stops as equilibrium is achieved.\n",
- "\n",
- "print \" The equilibrium pressure of CO2 is P_CO2 = %f atm \"%(P_CO2);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of equilibrium constant at 1042 K is K_1042 = 0.095017\n",
- " The equilibrium pressure of CO2 is P_CO2 = 0.095017 atm \n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.19 Page Number : 620"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables \n",
- "T_1 = 298.15;\t\t\t#[k] - Smath.tan(math.radiansard reaction temperature\n",
- "T_2 = 1200;\t\t\t#[K] - Reaction temperature\n",
- "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n",
- "\n",
- "\t\t\t# C (s) + CO2 (g) - 2*CO2 (g) \t\t\t# Reaction 1\n",
- "\t\t\t# CO2 + H2 - CO + H2O \t\t\t# Reacction 2\n",
- "\n",
- "K_1 = 63;\t\t\t# Equilibrium constant for the first reaction\n",
- "K_2 = 1.4;\t\t\t# Equilibrium constant for the secind reaction\n",
- "\n",
- "delta_G_H2O_298 = -54640;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of water vapour\n",
- "delta_H_H2O_298 = -57800;\t\t\t#[cal/mol] - Smath.tan(math.radiansard enthalpy change of formation of water vapour\n",
- "delta_G_rkn_298 = delta_G_H2O_298;\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard heat capacity data of the components in cal/mol-K are given below\n",
- "\t\t\t# Cp_H2 = 6.947 - 0.2*10**(-3)*T + 4.8*10**(-7)*T**(2)\n",
- "\t\t\t# Cp_O2 = 6.148 + 3.1*10**(-3)*T - 9.2*10**(-7)*T**(2)\n",
- "\t\t\t# Cp_H2O = 7.256 + 2.3*10**(-3)*T + 2.8*10**(-7)*T**(2)\n",
- "\n",
- "\t\t\t# Let us consider two more reactions\n",
- "\t\t\t# C (s) + (1/2)*O2 - CO \t\t\t# Reaction 3\n",
- "\t\t\t# H2 + (1/2)*O2 - H2O \t\t\t# Reaction 4\n",
- "\n",
- "\t\t\t# Considering the above 4 reactions, it can be shown that reaction (3) = reaction (1) + reaction (4) - reaction (2)\n",
- "\t\t\t# Thus, delta_G_rkn_3 = delta_G_rkn_1 + delta_G_rkn_4 - delta_G_rkn_2\n",
- "\t\t\t# or, -R*T*math.log(K_3) = -R*T*math.log(K_1) + -R*T*math.log(K_4) - -R*T*math.log(K_2)\n",
- "\t\t\t# K_3 = (K_1*K_4/K_2)\n",
- "\n",
- "\t\t\t# Now we have to determine K_4 at 1200 K.\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy change of reaction (4) as a fuction of temperature is given by\n",
- "\t\t\t# delta_H_rkn_T = -57020 - 2.765*T + 0.475*10**(-3)*T**(2) + 8.67*10**(-8)*T**(3);\n",
- "\n",
- "\n",
- "\t\t\t#def f2(T): \n",
- "\t\t\t#\t return K_4_2/K_4_1) = integrate(delta_H_rkn_T/(R*T**(2))\n",
- "\n",
- "\t\t\t# math.log(K_4_2/K_4_1) = quad(f2,T_1,T)[0]\n",
- "\n",
- "# Calculations\n",
- "def f3(T): \n",
- "\t return (-57020-2.765*T+0.475*10**(-3)*T**(2)+8.67*10**(-8)*T**(3))/T**(2)\n",
- "\n",
- "math.log_K2_K1_4 = quad(f3,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
- "\t\t\t# At 298.15 K\n",
- "K_4_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
- "\n",
- "\t\t\t# Putting the values in the above math.expression we get\n",
- "\t\t\t# math.log(K_4_1200/K_4_298) = math.log_K2_K1_R/R\n",
- "K_4_1200 = K_4_298*math.exp(math.log_K2_K1_4/R);\n",
- "K_4 = K_4_1200;\n",
- "\n",
- "\t\t\t# Therefore the equilibrium constant for reaction (3) at 1200 K is given by\n",
- "K_3 = (K_1*K_4)/K_2;\n",
- "\n",
- "# Results\n",
- "print \" The equilibrium constant at 1200 K for the given reaction is K = %e\"%(K_3);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The equilibrium constant at 1200 K for the given reaction is K = 3.622432e+09\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.20 Page Number : 622"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "delta_G_H2O_298 = -237.034;\t\t\t#[kJ/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of H2O (l) at 298 K\n",
- "F = 96485;\t\t\t#[C/mol] - Faraday constant\n",
- "\n",
- "\t\t\t#(1)\n",
- "\t\t\t# For the reaction\n",
- "\t\t\t# H2 (g) + (1/2)*O2 (g) - H2O (l)\n",
- "n = 2;\t\t\t# Number of electrons transferred in the reaction\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The smath.tan(math.radiansard Gibbs free energy change of the reaction is given by\n",
- "\t\t\t# delta_G_rkn = delta_G_for_H2O(l) - delta_G_for_H2(g) - (1/2/)*delta_G_for_O2(g)\n",
- "\t\t\t# Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n",
- "delta_G_rkn = delta_G_H2O_298;\t\t\t#[kJ]\n",
- "delta_G_rkn = delta_G_rkn*10**(3);\t\t\t#[J]\n",
- "\n",
- "\t\t\t# delta_G_rkn = -n*F*E_0\n",
- "\t\t\t# Thus smath.tan(math.radiansard equilibrium cell voltage is given by\n",
- "E_0 = - delta_G_rkn/(n*F);\t\t\t#/[V]\n",
- "\n",
- "print \" 1).The standard equilibrium cell voltage is %f V\"%(E_0);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# For the reaction\n",
- "\t\t\t# 2*H2 (g) + O2 (g) - 2*H2O (l)\n",
- "n_prime = 4;\t\t\t# Number of electrons transferred in the reaction\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard Gibbs free energy change of the reaction is given by\n",
- "\t\t\t# delta_G_rkn = 2*delta_G_for_H2O(l) - 2*delta_G_for_H2(g) - delta_G_for_O2(g)\n",
- "\t\t\t# Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n",
- "delta_G_rkn_prime = 2*delta_G_H2O_298;\t\t\t#[kJ]\n",
- "delta_G_rkn_prime = delta_G_rkn_prime*10**(3);\t\t\t#[J]\n",
- "\n",
- "\t\t\t# delta_G_rkn = -n*F*E_0\n",
- "\t\t\t# Thus smath.tan(math.radiansard equilibrium cell voltage is given by\n",
- "E_0_prime = - delta_G_rkn_prime/(n_prime*F);\t\t\t#/[V]\n",
- "\n",
- "print \" 2).The standard equilibrium cell voltage is %f V\"%(E_0_prime);\n",
- "\n",
- "\t\t\t# Thus the result obtained is same for both the reactions\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The standard equilibrium cell voltage is 1.228346 V\n",
- " 2).The standard equilibrium cell voltage is 1.228346 V\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.21 Page Number : 624"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\t\t\t\n",
- "P = 2;\t\t\t# Number of phases\n",
- "C = 5;\t\t\t# Number of components\n",
- "\n",
- "# Calculations\t\n",
- " \t\t# First we write chemical equations for formation of each component from basic elements\n",
- "\t\t\t# C + 2*H2 = CH4 \t\t\t# (reaction 1) \n",
- "\t\t\t# H2 + (1/2)*O2 = H20 \t\t\t# (reaction 2)\n",
- "\t\t\t# C + (1/2)*O2 = CO \t\t\t# (reaction 3)\n",
- "\t\t\t# C + O2 = CO2 \t\t\t# (reaction 4)\n",
- "\n",
- "\t\t\t# We do not have C in the equilibrium reaction mixture, therefore we have to eliminate it.\n",
- "\t\t\t# Substituting for C from reaction (1) into reactions (3) and (4) we get the following set of reactions\n",
- "\t\t\t# H2 + (1/2)*O2 = H20\n",
- "\t\t\t# CH4 - 2*H2 + (1/2)*O2 = CO\n",
- "\t\t\t# CH4 - 2*H2 + O2 = CO2\n",
- "\n",
- "\t\t\t# or,\n",
- "\t\t\t# H2 + (1/2)*O2 = H2O\n",
- "\t\t\t# CH4 + (1/2)*O2 = CO + 2*H2\n",
- "\t\t\t# CH4 + O2 = CO2 + 2*H2\n",
- "\n",
- "\t\t\t# We do not have O2 in the equilibrium reaction mixture,therefore we have to eliminateit\n",
- "\t\t\t# Substituting for O2 from the first reaction of the above set into seecond and third reactions of the above set we get the following set of reactions.\n",
- "\t\t\t# CH4 + H2O - H2 = CO + 2*H2\n",
- "\t\t\t# CH4 + 2*H20 - 2*H2 = CO2 + 2*H2 \n",
- "\n",
- "\t\t\t# Therefore one set of independent reactions is\n",
- "\t\t\t# CH4 + H20 = CO + 3*H2\n",
- "\t\t\t# CH4 + 2*H2O = CO2 + 4*H2\n",
- "\n",
- "\t\t\t# Another set of independent reactions can be obtained by substituting for CH4 from the first reaction into second and we get\n",
- "\t\t\t# CH4 + H2O = CO + 3*H2\n",
- "\t\t\t# CO + 3*H2 - H2O + 2*H2O = CO2 4*H2\n",
- "\n",
- "\t\t\t# Or, \n",
- "\t\t\t# CH4 + H2O = CO + 3*H2\n",
- "\t\t\t# CO + H2O = CO2 + H2\n",
- "\t\t\t# This is another set of independent reactions. Thus whatever be the set of independent reactions, the number of independent reactions are two\n",
- "\t\t\t# If different set of reactions are considered, then we get different equilibrium constants,different reaction coordinates but the final composition will be same\n",
- "\t\t\t# Thus only 2 independent reactions occur,therefore \n",
- "r = 2;\n",
- "\n",
- "\t\t\t# and the number of degree of freedom becomes,\n",
- "F = r - P + C;\n",
- "\n",
- "# Results\n",
- "print \" The number of independent chemical reactions are %f \"%(r);\n",
- "\n",
- "print \" The first set of independent reactions are given below\";\n",
- "print \" CH4 + H20 = CO + 3*H2\";\n",
- "print \" CH4 + 2*H2O = CO2 + 4*H2\";\n",
- "\n",
- "print \" The second set of independent reactions are given below\";\n",
- "print \" CH4 + H20 = CO + 3*H2\";\n",
- "print \" CO + H2O = CO2 + H2\";\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The number of independent chemical reactions are 2.000000 \n",
- " The first set of independent reactions are given below\n",
- " CH4 + H20 = CO + 3*H2\n",
- " CH4 + 2*H2O = CO2 + 4*H2\n",
- " The second set of independent reactions are given below\n",
- " CH4 + H20 = CO + 3*H2\n",
- " CO + H2O = CO2 + H2\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.22 Page Number : 626"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\t\t\t\n",
- "T = 400.;\t\t\t#[K] - Temperature\n",
- "P = 1.;\t\t\t#[atm] - Pressure\n",
- "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n",
- "\n",
- "delta_G_n_pentane_400 = 9600.;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of n-pentane at 400 K\n",
- "delta_G_iso_pentane_400 = 8200.;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of iso-pentane at 400 K\n",
- "delta_G_neo_pentane_400 = 9000.;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of neo-pentane at 400 K\n",
- "\n",
- "\t\t\t# The three reactions for the formation of these isomers can be written as follows\n",
- "\t\t\t# 5*C + 6*H2 = n-pentane\n",
- "\t\t\t# 5*C + 6*H2 = iso-pentane\n",
- "\t\t\t# 5*C + 6*H2 = neo-pentane\n",
- "\n",
- "\t\t\t# We can eliminate elemental carbon and hydrogen as they are not present in equilibrium reaction mixture and get the following two sets of independent reactions\n",
- "\t\t\t# n-pentane = iso-pentane \n",
- "\t\t\t# n-pentane = neo-pentane \n",
- "\n",
- "\t\t\t# or,\n",
- "\t\t\t# iso-pentane = n-pentane \n",
- "\t\t\t# iso-pentane = neo-pentane \n",
- "\n",
- "\t\t\t# or,\n",
- "\t\t\t# noe-pentane = iso-pentane \n",
- "\t\t\t# neo-pentane = n-pentane \n",
- "# Calculations and Results\n",
- "\t\t\t# Let us take the following set of independent reactions\n",
- "\t\t\t# iso-pentane = n-pentane \t\t\t# (reaction 1)\n",
- "delta_G_rkn_1 = delta_G_n_pentane_400 - delta_G_iso_pentane_400;\t\t\t#[cal]\n",
- "K_1 = math.exp(-delta_G_rkn_1/(R*T));\n",
- "\t\t\t# iso-pentane = neo-pentane \t\t\t# (reaction 2)\n",
- "delta_G_rkn_2 = delta_G_neo_pentane_400 - delta_G_iso_pentane_400;\t\t\t#[cal]\n",
- "K_2 = math.exp(-delta_G_rkn_2/(R*T));\n",
- "\n",
- "\t\t\t# Let the initial number of moles be\n",
- "\t\t\t# n_iso_pentane = 1\n",
- "\t\t\t# n_n_pentane = 0\n",
- "\t\t\t# n_neo_pentane = 0\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_iso_pentane_eq = 1 - X_1 - X_2\n",
- "\t\t\t# n_n_pentane_eq = X_1\n",
- "\t\t\t# n_neo_pentane_eq = X_2\n",
- "\t\t\t# Total moles = 1 \n",
- "\n",
- "\t\t\t# Pressure has no effect on these reactions ( P = 1 atm) and therefore\n",
- "Ky_1 = K_1;\n",
- "Ky_2 = K_2;\n",
- "\n",
- "\t\t\t# From reaction (1), we get\n",
- "\t\t\t# Ky_1 = X_1/(1-X_1-X_2)\n",
- "\n",
- "\t\t\t# From reaction (2), we get\n",
- "\t\t\t# Ky_2 = X_2/(1-X_1-X_2)\n",
- "\n",
- "\t\t\t# Putting the value of X_1 from first equation into the second we get\n",
- "\t\t\t# X_1 = (Ky_1*(1-X_2))/(1+Ky_1)\n",
- "\t\t\t# Now putting it into the second equation we grt\n",
- "\t\t\t# Ky_2 = X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n",
- "\t\t\t# Now solving for X_2\n",
- "def f(X_2): \n",
- "\t return Ky_2 - X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n",
- "X_2 = fsolve(f,0.8)\n",
- "\n",
- "\t\t\t# Therefore X_1 can be calculated as\n",
- "X_1 = (Ky_1*(1-X_2))/(1+Ky_1);\n",
- "\n",
- "\t\t\t# Finally the mole fractions of the components at equilibrium\n",
- "y_n_pentane = X_1;\n",
- "y_neo_pentane = X_2;\n",
- "y_iso_pentane = 1 -X_1 - X_2;\n",
- "\n",
- "print \" The equilibrium composition is given by y_n_pentane = %f y_neo_pentane = %f and y_iso_pentane = %f\"%(y_n_pentane,y_neo_pentane,y_iso_pentane);\n",
- "\n",
- "\t\t\t# Let us consider another set of independent reactions\n",
- "\n",
- "\t\t\t# n-pentane = iso-pentane \t\t\t# (reaction 3)\n",
- "delta_G_rkn_3 = delta_G_iso_pentane_400 - delta_G_n_pentane_400;\t\t\t#[cal]\n",
- "K_3 = math.exp(-delta_G_rkn_3/(R*T));\n",
- "\t\t\t# n-pentane = neo-pentane \t\t\t# (reaction 4)\n",
- "delta_G_rkn_4 = delta_G_neo_pentane_400 - delta_G_n_pentane_400;\t\t\t#[cal]\n",
- "K_4 = math.exp(-delta_G_rkn_4/(R*T));\n",
- "\n",
- "\t\t\t# Let the initial number of moles be\n",
- "\t\t\t# n_n_pentane = 1\n",
- "\t\t\t# n_iso_pentane = 0\n",
- "\t\t\t# n_neo_pentane = 0\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_3 and X_4 respectively\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_n_pentane_eq = 1 - X_3 - X_4\n",
- "\t\t\t# n_iso_pentane_eq = X_4\n",
- "\t\t\t# n_neo_pentane_eq = X_4\n",
- "\t\t\t# Total moles = 1 \n",
- "\n",
- "\t\t\t# Pressure has no effect on these reactions (P = 1 atm) and therefore\n",
- "Ky_3 = K_3;\n",
- "Ky_4 = K_4;\n",
- "\n",
- "\t\t\t# From reaction (3), we get\n",
- "\t\t\t# Ky_3 = X_3/(1-X_3-X_4)\n",
- "\n",
- "\t\t\t# From reaction (4), we get\n",
- "\t\t\t# Ky_4 = X_4/(1-X_3-X_4)\n",
- "\n",
- "\t\t\t# Putting the value of X_3 from first equation into the second we get\n",
- "\t\t\t# X_3 = (Ky_3*(1-X_4))/(1+Ky_3)\n",
- "\t\t\t# Now putting it into the second equation we grt\n",
- "\t\t\t# Ky_4 = X_4/(1-((Ky_1*(1-X_4))/(1+Ky_3))-X_4)\n",
- "\t\t\t# Now solving for X_4\n",
- "def f1(X_4): \n",
- "\t return Ky_4 - X_4/(1-((Ky_3*(1-X_4))/(1+Ky_3))-X_4)\n",
- "X_4 = fsolve(f1,0.8)\n",
- "\n",
- "\t\t\t# Therefore X_3 can be calculated as\n",
- "X_3 = (Ky_3*(1-X_4))/(1+Ky_3);\n",
- "\n",
- "\t\t\t# Finally the mole fractions of the components at equilibrium\n",
- "y_n_pentane1 = 1 - X_3 - X_4;\n",
- "y_neo_pentane1 = X_4;\n",
- "y_iso_pentane1 = X_3;\n",
- "\n",
- "\t\t\t# The final composition does not depend on the set of reactions considered. \n",
- "\n",
- "print \" For another set of independent reactions considered\";\n",
- "print \" The equilibrium composition is given by y_n_pentane = %f y_neo_pentane = %f and y_iso_pentane = %f\"%(y_n_pentane1,y_neo_pentane1,y_iso_pentane1);\n",
- "print \" Thus the final composition does not depend on the set of reactions considered\";\n",
- "print \" The number of independent reactions taking place is two\";\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The equilibrium composition is given by y_n_pentane = 0.111753 y_neo_pentane = 0.237745 and y_iso_pentane = 0.650501\n",
- " For another set of independent reactions considered\n",
- " The equilibrium composition is given by y_n_pentane = 0.111753 y_neo_pentane = 0.237745 and y_iso_pentane = 0.650501\n",
- " Thus the final composition does not depend on the set of reactions considered\n",
- " The number of independent reactions taking place is two\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.23 Page Number : 628"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 600;\t\t\t#[K] - Temperature\n",
- "P = 1;\t\t\t#[atm] - Pressure\n",
- "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n",
- "\n",
- "\t\t\t# CH4 + H2O = CO + 3*H2 \t\t\t# (Reaction 1)\n",
- "\t\t\t# CO + H2O = CO2 + H2 \t\t\t# (Reaction 2)\n",
- "\n",
- "K_1 = 0.574;\t\t\t# Equilibrium constant of first reaction\n",
- "K_2 = 2.21;\t\t\t# Equilibrium constant of second reaction\n",
- "\n",
- "\t\t\t# Initial number of moles of the components are\n",
- "\t\t\t# n_CH4 = 1\n",
- "\t\t\t# n_H2O = 5\n",
- "\t\t\t# n_CO = 0\n",
- "\t\t\t# n_H2 = O\n",
- "\t\t\t# n_CO2 = 0\n",
- "\n",
- "\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n",
- "\t\t\t# At equilibrium, the moles of the components be\n",
- "\t\t\t# n_CH4_eq = 1 - X_1\n",
- "\t\t\t# n_H20_eq = 5 - X_1 - X_2\n",
- "\t\t\t# n_CO_eq = X_1 - X_2\n",
- "\t\t\t# n_H2_eq = 3*X_1 + X_2\n",
- "\t\t\t# n_CO2_eq = X_2\n",
- "\t\t\t# Total moles = 6 + 2*X_1\n",
- "\n",
- "\t\t\t# Since the pressure is 1 atm, K = Kp, Ky = K\n",
- "Ky_1 = K_1;\n",
- "Ky_2 = K_2;\n",
- "\n",
- "\t\t\t# From reaction (1), we get\n",
- "\t\t\t# Ky_1 = ((X_1-X_2)*(3*X_1+X_2)**(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)**(2))\n",
- "\n",
- "\t\t\t# From reaction (2), we get\n",
- "\t\t\t# Ky_2 = (X_2*(3*X_1+X_2))/((X_1-X_2)*(5-X_1-X_2))\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# Let us assume a value of X_1\n",
- "X_1 = 0.1;\n",
- "def f(X_2): \n",
- "\t return Ky_1-((X_1-X_2)*(3*X_1+X_2)**(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)**(2))\n",
- "\n",
- "def f1(X_1_prime): \n",
- "\t return Ky_2-(X_2_prime*(3*X_1_prime+X_2_prime))/((X_1_prime-X_2_prime)*(5-X_1_prime-X_2_prime))\n",
- "\n",
- "fault = 10;\n",
- "while(fault>0.05):\n",
- " X_2 = fsolve(f,0.8)\n",
- " X_2_prime = X_2;\n",
- " X_1_prime = fsolve(f1,0.8)\n",
- " fault=abs(X_1 - X_1_prime);\n",
- " X_1 = X_1 + 0.001;\n",
- "\n",
- "n_CH4 = 1 - X_1;\n",
- "n_H20 = 5 - X_1 - X_2;\n",
- "n_CO = X_1 - X_2;\n",
- "n_H2 = 3*X_1 + X_2;\n",
- "n_CO2 = X_2;\n",
- "Total_moles = 6 + 2*X_1;\n",
- "\n",
- "# Results\n",
- "print \" The equilibrium composition of the resulting mixture is given by\";\n",
- "print \" n_CH4 = % f mol n_H2O = %f mol n_CO = %f mol n_H2 = %f mol and n_CO2 = %f mol\"%(n_CH4,n_H20,n_CO,n_H2,n_CO2);\n",
- "print \" The total number of moles is %f mol\"%(Total_moles);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The equilibrium composition of the resulting mixture is given by\n",
- " n_CH4 = 0.089000 mol n_H2O = 3.471420 mol n_CO = 0.293420 mol n_H2 = 3.350580 mol and n_CO2 = 0.617580 mol\n",
- " The total number of moles is 7.822000 mol\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stderr",
- "text": [
- "/home/jovina/virtualenvs/scipy/local/lib/python2.7/site-packages/scipy/optimize/minpack.py:236: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
- " improvement from the last ten iterations.\n",
- " warnings.warn(msg, RuntimeWarning)\n",
- "/home/jovina/virtualenvs/scipy/local/lib/python2.7/site-packages/scipy/optimize/minpack.py:236: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
- " improvement from the last five Jacobian evaluations.\n",
- " warnings.warn(msg, RuntimeWarning)\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 17.24 Page Number : 631"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 600 + 273.15;\t\t\t#[K] - Reaction temperature\n",
- "P = 1;\t\t\t#[atm] - Reaction pressure\n",
- "\n",
- "\t\t\t# The Gibbs free energy of formation of various species at 873.15 K are\n",
- "delta_G_CH4_RT = -2.82;\t\t\t# delta_G_CH4/(R*T)\n",
- "delta_G_H2O_RT = -29.73;\t\t\t# delta_G_CH4/(R*T)\n",
- "delta_G_CO_RT = -27.51;\t\t\t# delta_G_CH4/(R*T)\n",
- "delta_G_H2_RT = -1.46;\t\t\t# delta_G_CH4/(R*T)\n",
- "delta_G_CO2_RT = -56.68;\t\t\t# delta_G_CH4/(R*T)\n",
- "\n",
- "# Calculations\t\t\n",
- " \t# Initial number of moles of the components are\n",
- "\t\t\t# n_CH4 = 1\n",
- "\t\t\t# n_H2O = 5\n",
- "\t\t\t# n_CO = 0\n",
- "\t\t\t# n_H2 = O\n",
- "\t\t\t# n_CO2 = 0\n",
- "\n",
- "\t\t\t# The del(F)/del(n_i) = 0 equations for CH4 (1), H2O (2), CO (3), H2 (4) and CO2 (5) becomes\n",
- "\t\t\t# delta_G_1_T + R*T*math.log((n_1*P)/n) + lambda_C + 4*lambda_H = 0\n",
- "\t\t\t# delta_G_2_T + R*T*math.log((n_2*P)/n) + 2*lambda_C + lambda_O = 0\n",
- "\t\t\t# delta_G_3_T + R*T*math.log((n_3*P)/n) + lambda_c + lambda_O = 0\n",
- "\t\t\t# delta_G_4_T + R*T*math.log((n_4*P)/n) + 2*lambda_H = 0\n",
- "\t\t\t# delta_G_5_T + R*T*math.log((n_5*P)/n) + lambda_C + 2*lambda_O = 0\n",
- "\n",
- "\t\t\t# Where n is the total number of moles in the equilibrium reaction mixture. Dividing the above equations by R*T we get\n",
- "\t\t\t# delta_G_1_T/(R*T) + math.log((n_1*P)/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n",
- "\t\t\t# delta_G_2_T/(R*T) + math.log((n_2*P)/n) + 2*lambda_C/(R*T) + lambda_O/(R*T) = 0\n",
- "\t\t\t# delta_G_3_T/(R*T) + math.log((n_3*P)/n) + lambda_c/(R*T) + lambda_O/(R*T) = 0\n",
- "\t\t\t# delta_G_4_T/(R*T) + math.log((n_4*P)/n) + 2*lambda_H/(R*T) = 0\n",
- "\t\t\t# delta_G_5_T/(R*T) + math.log((n_5*P)/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n",
- "\n",
- "\t\t\t# Substituting the values of delta_G_i_T/(R*T) in the above equations,the full set of equations (including elemental balance) becomes\n",
- "\t\t\t# -2.82 + math.log(n_1/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n",
- "\t\t\t# -29.73 + math.log(n_2/n) + 2*lambda_H/(R*T) + lambda_O/(R*T) = 0\n",
- "\t\t\t# -27.51 + math.log(n_3/n) + lambda_C/(R*T) + lambda_O/(R*T) = 0\n",
- "\t\t\t# -1.46 + math.log(n_4/n) + 2*lambda_H/(R*T) = 0\n",
- "\t\t\t# -56.68 + math.log(n_5/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n",
- "\n",
- "\t\t\t# The constraint equations are\n",
- "\t\t\t# n_1 + n_3 + n_5 = 1 \t\t\t# (moles of C in the reaction mixture = 1)\n",
- "\t\t\t# 4*n_1 + 2*n_2 + 2*n_4 = 14 \t\t\t# (moles of H in the reaction mixture = 14)\n",
- "\t\t\t# n_2 + n_3 + 2*n_5 = 5 \t\t\t# (moles of O in the raection mixture = 5)\n",
- "\n",
- "\t\t\t# The total moles are given by\n",
- "\t\t\t# n = n_1 + n_2 + n_3 + n_4 + n_5\n",
- "\n",
- "def solution(x):\n",
- " f = [0,0,0,0,0,0,0,0,0]\n",
- " f[0]= -2.82 + math.log(x[0]/x[5]) + x[6] + 4*x[7];\n",
- " f[1] = -29.73 + math.log(x[1]/x[5]) + 2*x[7] + x[8];\n",
- " f[2] = -27.51 + math.log(x[2]/x[5]) + x[6] + x[8];\n",
- " f[3] = -1.46 + math.log(x[3]/x[5]) + 2*x[7];\n",
- " f[4] = -56.68 + math.log(x[4]/x[5]) + x[6] + 2*x[8];\n",
- " f[5] = x[0] + x[2] +x[4] - 1;\n",
- " f[6] = 4*x[0] + 2*x[1] + 2*x[3] - 14;\n",
- " f[7] = x[1] + x[2] +2*x[4] - 5;\n",
- " f[8] = x[0]+ x[1] + x[2] + x[3] + x[4] - x[5]; \n",
- " return f\n",
- "\n",
- "\n",
- "x = [0.01,3.5,0.2,3.0,0.5,5.0,2.0,1.0,25.0];\n",
- "y = fsolve(solution,x)\n",
- "\n",
- "# Results\n",
- "print \" n_1 = %f mol\"%(y[0]);\n",
- "print \" n_2 = %f mol\"%(y[1]);\n",
- "print \" n_3 = %f mol\"%(y[2]);\n",
- "print \" n_4 = %f mol\"%(y[3]);\n",
- "print \" n_5 = %f mol\"%(y[4]);\n",
- "print \" n = %f mol\"%(y[5]);\n",
- "print \" lambda_C/RT = %f\"%(y[6]);\n",
- "print \" lambda_H/RT = %f\"%(y[7]);\n",
- "print \" lambda_O/RT = %f\"%(y[8]);\n",
- "\n",
- "print \" The Lagrange multiplier values do not have any physical significance\";\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " n_1 = 0.091556 mol\n",
- " n_2 = 3.442034 mol\n",
- " n_3 = 0.258922 mol\n",
- " n_4 = 3.374855 mol\n",
- " n_5 = 0.649522 mol\n",
- " n = 7.816888 mol\n",
- " lambda_C/RT = 2.667225\n",
- " lambda_H/RT = 1.149967\n",
- " lambda_O/RT = 28.250290\n",
- " The Lagrange multiplier values do not have any physical significance\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch18_1.ipynb b/Chemical_Engineering_Thermodynamics/ch18_1.ipynb
deleted file mode 100755
index 46865b0c..00000000
--- a/Chemical_Engineering_Thermodynamics/ch18_1.ipynb
+++ /dev/null
@@ -1,595 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:32121f42f5b148741ef15da1993d191234c228c3ab7dcf05f69114fbe323a883"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 18 : Adiabatic Reaction Temperature"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 18.1 Page Number : 650"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\n",
- "\n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "T_2 = 500;\t\t\t#[K] - Reaction temperature\n",
- "P = 1;\t\t\t#[atm] - Pressure \n",
- "\n",
- "a_CO2 = 5.316;\n",
- "a_O2 = 6.085;\n",
- "a_N2 = 6.903;\n",
- "a_H2O = 7.700;\n",
- "a_C3H8 = -0.966;\n",
- "b_CO2 = 1.4285*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "b_N2 = -0.03753*10**(-2);\n",
- "b_H2O = 0.04594*10**(-2);\n",
- "b_C3H8 = 7.279*10**(-2);\n",
- "c_CO2 = -0.8362*10**(-5);\n",
- "c_O2 = -0.1709*10**(-5);\n",
- "c_N2 = 0.1930*10**(-5);\n",
- "c_H2O = 0.2521*10**(-5);\n",
- "c_C3H8 = -3.755*10**(-5);\n",
- "d_CO2 = 1.784*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "d_N2 = -0.6861*10**(-9);\n",
- "d_H2O = -0.8587*10**(-9);\n",
- "d_C3H8 = 7.580*10**(-9);\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy of formation at 298.15 K is given by\n",
- "delta_H_for_CO2 = -94.052;\t\t\t#[kcal/mol]\n",
- "delta_H_for_C3H8 = -24.820;\t\t\t#[kcal/mol]\n",
- "delta_H_for_H2O = -57.7979;\t\t\t#[kcal/mol]\n",
- "\n",
- "\t\t\t# The reaction with stoichiometric amount of air is\n",
- "\t\t\t# C3H8 + 5(O2 + 3.7N2) - 3CO2 + 4H2O + 18.8N2\n",
- "\n",
- "\t\t\t# The reaction with 100% excess air is\n",
- "\t\t\t# C3H8 + 10(O2 + 3.7N2) - 3CO2 + 4H2O + 5O2 + 37.6N2\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy change of reaction at 298.15 K\n",
- "delta_H_rkn_298 = 3*delta_H_for_CO2 + 4*delta_H_for_H2O - delta_H_for_C3H8;\n",
- "\n",
- "\t\t\t# For exit stream\n",
- "sum_ai_ni = 3*a_CO2 + 4*a_H2O + 5*a_O2 + 37.6*a_N2;\n",
- "sum_bi_ni = 3*b_CO2 + 4*b_H2O + 5*b_O2 + 37.6*b_N2;\n",
- "sum_ci_ni = 3*c_CO2 + 4*c_H2O + 5*c_O2 + 37.6*c_N2;\n",
- "sum_di_ni = 3*d_CO2 + 4*d_H2O + 5*d_O2 + 37.6*d_N2;\n",
- "\n",
- "\n",
- "\t\t\t# To raise the exit species from 298.15 to 500 K the enthalpy change is\n",
- "\n",
- "def f1(T): \n",
- "\t return sum_ai_ni+sum_bi_ni*T+sum_ci_ni*T**(2)+sum_di_ni*T**(3)\n",
- "\n",
- "delta_H_rkn = quad(f1,T_1,T_2)[0]\n",
- "\n",
- "delta_H_rkn = delta_H_rkn*10**(-3);\t\t\t#[kcal]\n",
- "\n",
- "\t\t\t# Therefore per mole of fuel the heat exchange is\n",
- "\t\t\t# Q = Heat exchange in step 1 + Heat exchange in step 2\n",
- "Q = delta_H_rkn_298 + delta_H_rkn;\n",
- "\n",
- "# Results\n",
- "print \" The heat transfer from the combustion chamber per mole of fuel is %f kcal (per mol of C3H8)\"%(Q);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The heat transfer from the combustion chamber per mole of fuel is -415.328732 kcal (per mol of C3H8)\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 18.2 Page Number : 650"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "from scipy.optimize import fsolve \n",
- "\n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "\n",
- "a_CO2 = 5.316;\n",
- "a_H2O = 7.700;\n",
- "a_O2 = 6.085;\n",
- "a_C2H6 = 1.648;\n",
- "b_CO2 = 1.4285*10**(-2);\n",
- "b_H2O = 0.04595*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "b_C2H6 = 4.124*10**(-2);\n",
- "c_CO2 = -0.8362*10**(-5);\n",
- "c_H2O = 0.2521*10**(-5);\n",
- "c_O2 = -0.1709*10**(-5);\n",
- "c_C2H6 = -1.530*10**(-5);\n",
- "d_CO2 = 1.784*10**(-9);\n",
- "d_H2O = -0.8587*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "d_C2H6 = 1.740*10**(-9);\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy of formation at 298.15 K is given by\n",
- "delta_H_for_CO2 = -94.052;\t\t\t#[kcal/mol]\n",
- "delta_H_for_C2H6 = -20.236;\t\t\t#[kcal/mol]\n",
- "delta_H_for_H2O = -57.7979;\t\t\t#[kcal/mol]\n",
- "\n",
- "# Calculations\t\t\n",
- " \t# The reaction with stoichiometric amount of air is\n",
- "\t\t\t# C2H6 + (7/2)O2 - 2CO2 + 3H2O\n",
- "\n",
- "\t\t\t# The reaction with 4 mol of O2 and 10 mol CO2 is\n",
- "\t\t\t# C2H6 + 4O2 + 10CO2 - 12H2O + 3H2O + 0.5O2\n",
- "\t\t\t# The product consists of 12 mol of CO2, 3 mol of water vapour and 0.5 mol of oxygen\n",
- "delta_H_rkn_298 = 2*delta_H_for_CO2 + 3*delta_H_for_H2O - delta_H_for_C2H6;\t\t\t#[kcal]\n",
- "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
- "\n",
- "\t\t\t# For exit stream\n",
- "sum_ai_ni = 12*a_CO2 + 3*a_H2O + 0.5*a_O2;\n",
- "sum_bi_ni = 12*b_CO2 + 3*b_H2O + 0.5*b_O2;\n",
- "sum_ci_ni = 12*c_CO2 + 3*c_H2O + 0.5*c_O2;\n",
- "sum_di_ni = 12*d_CO2 + 3*d_H2O + 0.5*d_O2;\n",
- "\n",
- "\t\t\t# From energy balance equation we get\n",
- "\t\t\t# delta_H_rkn_298 + sum_ai_ni*(T_2 - T_1) + (sum_bi_ni/2)*(T_2**(2) - T_1**(2)) + (sum_ci_ni/3)*(T_2**(3) - T_1**(3)) + (sum_di_ni/4)*(T_2**(4) - T_1**(4))\n",
- "\t\t\t# Solving above equation for T_2\n",
- "def f(T_2): \n",
- "\t return delta_H_rkn_298 +sum_ai_ni*(T_2-T_1)+(sum_bi_ni/2)*(T_2**(2)-T_1**(2))+(sum_ci_ni/3)*(T_2**(3)-T_1**(3))+(sum_di_ni/4)*(T_2**(4)-T_1**(4))\n",
- "T_2 = fsolve(f,-1)\n",
- "\n",
- "# Results\n",
- "print \" The adiabatic flame temperature is %f K\"%(T_2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The adiabatic flame temperature is 2090.385277 K\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 18.3 Page Number : 651"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "\n",
- "\t\t\t# The reaction with theoritical air is\n",
- "\t\t\t# CH4 + 2(O2 + 3.76N2) - CO2 + 2H20 + 7.52N2\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "n_product = (1 + 2 + 7.52);\t\t\t# Total number of moles of product\n",
- "\t\t\t# The mole fraction of water vapour is\n",
- "y_H2O = 2/(n_product);\n",
- "print \" 1).The mole fraction of water vapour is %f\"%(y_H2O);\n",
- "\n",
- "\t\t\t#(2)\n",
- "delta_H_rkn_298 = -730*10**(3);\t\t\t#[J/mol]\n",
- "C = 40;\t\t\t#[J/mol-K] - Average molar heat capacity\n",
- "\n",
- "\t\t\t# From energy balance we have\n",
- "\t\t\t# delta_H_rkn_298 + n_product*C(T_2 - T_1) = 0\n",
- "T_2 = - delta_H_rkn_298/(n_product*C) + T_1;\t\t\t#[K]\n",
- "T_max = T_2 - T_1;\n",
- "\n",
- "print \" 2).The maximum temperature rise of the exhaust gases is %f K\"%(T_max);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The mole fraction of water vapour is 0.190114\n",
- " 2).The maximum temperature rise of the exhaust gases is 1734.790875 K\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 18.4 Page Number : 651"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "\n",
- "\n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy of formation at 298.15 K is given by\n",
- "delta_H_for_CO2 = -94.052;\t\t\t#[kcal/mol]\n",
- "delta_H_for_C8H18 = -59.780;\t\t\t#[kcal/mol]\n",
- "delta_H_for_H2O = -57.7979;\t\t\t#[kcal/mol]\n",
- "\n",
- "a_CO2 = 5.316;\n",
- "a_H2O = 7.700;\n",
- "a_N2 = 6.903;\n",
- "b_CO2 = 1.4285*10**(-2);\n",
- "b_H2O = 0.04595*10**(-2);\n",
- "b_N2 = -0.03753*10**(-2);\n",
- "c_CO2 = -0.8362*10**(-5);\n",
- "c_H2O = 0.2521*10**(-5);\n",
- "c_N2 = 0.1930*10**(-5);\n",
- "d_CO2 = 1.784*10**(-9);\n",
- "d_H2O = -0.8587*10**(-9);\n",
- "d_N2 = -0.6861*10**(-9);\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(a)\n",
- "\t\t\t# The reaction with stoichiometric amount of air is\n",
- "\t\t\t# C3H18 + 12.5(O2 + 3.76N2) - 8CO2 + 9H2O + 47N2\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy change of reaction at 298.15 K is\n",
- "delta_H_rkn_298 = 8*delta_H_for_CO2 + 9*delta_H_for_H2O - delta_H_for_C8H18;\t\t\t#[kcal]\n",
- "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
- "\n",
- "\t\t\t# For exit stream\n",
- "sum_ai_ni = 8*a_CO2 + 9*a_H2O + 47*a_N2;\n",
- "sum_bi_ni = 8*b_CO2 + 9*b_H2O + 47*b_N2;\n",
- "sum_ci_ni = 8*c_CO2 + 9*c_H2O + 47*c_N2;\n",
- "sum_di_ni = 8*d_CO2 + 9*d_H2O + 47*d_N2;\n",
- "\n",
- "\t\t\t# From energy balance equation we get\n",
- "\t\t\t# delta_H_rkn_298 + sum_ai_ni*(T_2 - T_1) + (sum_bi_ni/2)*(T_2**(2) - T_1**(2)) + (sum_ci_ni/3)*(T_2**(3) - T_1**(3)) + (sum_di_ni/4)*(T_2**(4) - T_1**(4))\n",
- "\t\t\t# Solving above equation for T_2\n",
- "def f(T_2): \n",
- "\t return delta_H_rkn_298 +sum_ai_ni*(T_2-T_1)+(sum_bi_ni/2)*(T_2**(2)-T_1**(2))+(sum_ci_ni/3)*(T_2**(3)-T_1**(3))+(sum_di_ni/4)*(T_2**(4)-T_1**(4))\n",
- "T_2 = fsolve(f,-1)\n",
- "\n",
- "print \" 1).The adiabatic flame temperature is %f K\"%(T_2);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# The mean smath.tan(math.radiansard heat capacity of various components over the temperature range from 25 to 3000 C is \n",
- "Cp_CO2 = 13.91;\t\t\t#[cal/mol-K]\n",
- "Cp_H2O = 10.16;\t\t\t#[cal/mol-K]\n",
- "Cp_O2 = 7.88;\t\t\t#[cal/mol-K]\n",
- "Cp_N2 = 7.45;\t\t\t#[cal/mol-K]\n",
- "\n",
- "\t\t\t# From energy balance equation we get\n",
- "\t\t\t# delta_H_rkn_298 + (8*Cp_CO2 + 9*Cp_H2O + 47*Cp_N2)*(T_2_prime)\n",
- "T_2_prime = - delta_H_rkn_298/(8*Cp_CO2 + 9*Cp_H2O + 47*Cp_N2);\t\t\t#[K]\n",
- "print \" 2).The adiabatic flame temperature is %f K\"%(T_2_prime);\n",
- "\n",
- "# The answer is correct. Please calculate it manually. Wrong answer is given in book."
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The adiabatic flame temperature is 2415.861178 K\n",
- " 2).The adiabatic flame temperature is 2193.675005 K\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 18.5 Page Number : 652"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "\t\t\t# N2 + 3H2 - 2NH3\n",
- "T_1 = 700;\t\t\t#[K] - Reaction temperature\n",
- "Max_adia_rise = 100;\t\t\t#/[K] - Maximum adiabatic rise in temperature\n",
- "T_2 = T_1 + Max_adia_rise;\t\t\t#[K] - \n",
- "\n",
- "delta_H_rkn_700 = -94.2;\t\t\t#[kJ] - Smath.tan(math.radiansard enthalpy of reaction at 700 K\n",
- "delta_H_rkn_700 = delta_H_rkn_700*10**(3);\t\t\t#[J]\n",
- "\n",
- "\t\t\t# The mean smath.tan(math.radiansard heat capacity of various components over the temperature range from 700 to 800 K is \n",
- "Cp_N2 = 30.0;\t\t\t#[cal/mol-K]\n",
- "Cp_H2 = 28.9;\t\t\t#[cal/mol-K]\n",
- "Cp_NH3 = 49.2;\t\t\t#[cal/mol-K]\n",
- "\n",
- "# Calculations\t\t\t\n",
- " # The energy balance equation is\n",
- "\n",
- "def f46(T): \n",
- "\t return (sum_ni_Cpi_exit)*dT\n",
- "\n",
- "\t\t\t# X*delta_H_rkn_700 + quad(f46,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t#At exit, let moles of NH3 = (1-X), moles of H2 = (3-3X), moles of NH3 = 2X . Therefore we have,\n",
- "\t\t\t# delta_H_rkn_700*X + {(1-X)*Cp_N2 + (3-3X)*Cp_H2 + (2X)*Cp_NH3}*(T_2 - T_1)\n",
- "\t\t\t# On simplification we get, 960.3*X = 116.7\n",
- "X = 116.7/960.3;\n",
- "\n",
- "# Results\n",
- "print \" The maximum allowable conversion fraction in the reactor is given by X = %f \"%(X);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The maximum allowable conversion fraction in the reactor is given by X = 0.121525 \n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 18.6 Page Number : 653"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\n",
- "\n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "V = 2.0*10**(-3);\t\t\t#[m**(3)] - Volume of calorimeter\n",
- "m = 10.;\t\t\t#[g] - Mass of liquid octane\n",
- "Mol_wt = 114.;\t\t\t#[g/mol] - Molecular weight of octane\n",
- "n = m/Mol_wt;\t\t\t#[mol] - No of moles of octane\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy of formation at 298.15 K is given by\n",
- "delta_H_for_CO2 = -94.052;\t\t\t#[kcal/mol]\n",
- "delta_H_for_C8H18 = -59.780;\t\t\t#[kcal/mol]\n",
- "delta_H_for_H2O = -57.7979;\t\t\t#[kcal/mol]\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard molar heat capacity of various components in high temperature range from is given by \n",
- "\t\t\t# Cp_H2O = 6.970 + 0.3464*10**(-2)*T - 0.04833*10**(-5)*T**(2);\n",
- "\t\t\t# Cp_O2 = 6.732 + 0.1505*10**(-2)*T - 0.01791*10**(-5)*T**(2);\n",
- "\t\t\t# Cp_CO2 = 18.036 - 4.474*10**(-5)*T - 158.08/(T**(1/2));\n",
- "\t\t\t# Therefore we have\n",
- "\t\t\t# Sum_ni_Cpi_exit = 249.09 + 0.04*T - 0.547*10**(-5)*T**(2) - 1264.64/(T**(1/2))\n",
- "\n",
- "\t\t\t# The reaction with stoichiometric amount of oxygen is\n",
- "\t\t\t# C8H18 + 12.5O2 - 8CO2 + 9H2O\n",
- "\n",
- "\t\t\t# The reaction with 50% excess oxygen is\n",
- "\t\t\t# C8H18 + 18.75O2 - 8CO2 +9H2O + 6.25O2\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy change of reaction at 298.15 K is\n",
- "delta_H_rkn_298 = 8*delta_H_for_CO2 + 9*delta_H_for_H2O - delta_H_for_C8H18;\t\t\t#[kcal]\n",
- "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
- "\n",
- "\t\t\t# From the energy balance equation we get\n",
- "\n",
- "def f10(T): \n",
- "\t return (sum_ni_Cpi_exit)*dT\n",
- "\n",
- "\t\t\t# delta_H_rkn_298 + quad(f10,T_1,T_2)[0]\n",
- "\n",
- "\t\t\t# delta_H_rkn_298 + 249.09*(T_2 - T_1) + (0.04/2)*(T_2**(2) - T_1**(2)) - ((0.547*10**(-5))/3)*(T_2**(3)-T_1**(3)) - (1264.64*2)*(T_2**(1/2)-T_1**(1/2))\n",
- "\t\t\t# Solving above equation for T_2\n",
- "def f(T_2): \n",
- "\t return delta_H_rkn_298 + 249.09*(T_2 - T_1) + (0.04/2)*(T_2**(2)-T_1**(2)) - ((0.547*10**(-5))/3)*(T_2**(3)-T_1**(3)) - (1264.64*2)*(T_2**(1./2)-T_1**(1./2))\n",
- "T_2 = fsolve(f,1000)\n",
- "\n",
- "\t\t\t# When 1 mol of octane reacts the final number of moles in the calorimeter is 23.25\n",
- "\t\t\t# When n mol of octane reacts the final number of moles in the calorimeter is\n",
- "n_total = n*23.25;\t\t\t#[mol]\n",
- "\n",
- "\t\t\t# The maximum explosion pressure is calculated when no heat is dissipated to the surroundings and thus bomb calorimeter attains the adiabatic flame temperature\n",
- "\t\t\t# Thus maximum explosion pressure is given by\n",
- "P = (n_total*R*T_2)/V;\t\t\t#[N/m**(2)]\n",
- "P = P*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "# Results\n",
- "print \" The maximum explosion pressure inside the bomb calorimeter is %f bar\"%(P);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The maximum explosion pressure inside the bomb calorimeter is 397.138166 bar\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 18.7 Page Number : 656"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "from scipy.optimize import fsolve\n",
- "import math\n",
- " \n",
- "\n",
- "# Variables\n",
- "T_1 = 400 + 273.15;\t\t\t#[K]\n",
- "\t\t\t# SO2(g) + 1./2*(O2) (g) - SO3 (g)\n",
- "\n",
- "a_SO2 = 6.157;\n",
- "a_SO3 = 3.918;\n",
- "a_O2 = 6.085;\n",
- "a_N2 = 6.903;\n",
- "b_SO2 = 1.384*10**(-2);\n",
- "b_SO3 = 3.483*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "b_N2 = -0.03753*10**(-2);\n",
- "c_SO2 = -0.9103*10**(-5);\n",
- "c_SO3 = -2.675*10**(-5);\n",
- "c_O2 = -0.01709*10**(-5);\n",
- "c_N2 = 0.1930;\n",
- "d_SO2 = 2.057*10**(-9);\n",
- "d_SO3 = 7.744*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "d_N2 = -0.6861*10**(-9);\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# At 400 C, from the given math.expressions\n",
- "delta_H_rkn_T_1 = -22630.14 - 5.2815*T_1 + 0.9587*10**(-2)*T_1**(2) - 0.5598*10**(-5)*T_1**(3) + 1.3826*10**(-9)*T_1**(4);\t\t\t#[cal]\n",
- "\t\t\t# This is the smath.tan(math.radiansard enthalpy change of reaction for 1 mol of SO2 reacted. Since X moles of SO2 are reactants therefore \n",
- "\t\t\t# delta_H_rkn_T_X (for X moles of SO2 reacted) = delta_H_rkn_T_1*X\n",
- "\n",
- "\t\t\t# Let the number of moles at equilibrium be\n",
- "\t\t\t# n_O2 = 9-0.5*X\n",
- "\t\t\t# n_SO2 = 12-X\n",
- "\t\t\t# n_SO3 = X\n",
- "\t\t\t# n_N2 = 79\n",
- "\t\t\t# Total moles at equilibrium = 100-0.5X\n",
- "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(1./2))\n",
- "\t\t\t# Ky = (X*(100-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n",
- "\t\t\t# We know that K = Ky*Kp. Since P = 1 atm, therefore Ky = K\n",
- "\n",
- "\t\t\t# Now we have to account for the heat required to raise 9-0.5*X mol of O2, 12-X mol of SO2, X mol of SO3 and 79 mol of N2 from T to ART\n",
- "\t\t\t# sum_ni_Cp_i = (12-X)*(a + b*T + c*T**(2) + d*T**(3)) + (9-0.5*X)*(a + b*T + c*T**(2) + d*T**(3)) + X*(a + b*T + c*T**(2) + d*T**(3)) + 79*(a + b*T + c*T** (2) + d*T**(3))\n",
- "\n",
- "\t\t\t# From energy balance equation we get\n",
- "\n",
- "def f19(T): \n",
- "\t return sum_ni_Cp_i\n",
- "\n",
- "\t\t\t# delta_H_rkn_T_1 + quad(f19,T_1,T)[0]\n",
- "\n",
- "\t\t\t# The above equation on simplification becomes\n",
- "\t\t\t# (673.99-5.2815*X)*(T-T_1) + (16.91+1.9175*X)*(10**(-2)/2)*(T**(2)-T_1**(2)) + (2.79-1.6793*X)*(10**(-5)/3)*(T**(3)-T_1**(3)) + (-26.70+5.5304*X)*(10**(-9) /4)*(T**(4)-T_1**(4)) = delta_H_rkn_T_1*X\n",
- "\n",
- "\t\t\t# Let us assume a temperature, say\n",
- "T = 800;\t\t\t#[K]\n",
- "fault = 10;\n",
- "def f(X): \n",
- "\t return K - (X*(100-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n",
- "\n",
- "def f1(X): \n",
- "\t return (673.99-5.2815*X)*(T-T_1)+(16.91+1.9175*X)*(10**(-2)/2)*(T**(2)-T_1**(2))+(2.79-1.6793*X)*(10**(-5)/3)*(T**(3)-T_1**(3))+(-26.70+5.5304*X)*(10**(-9)/4)*(T**(4)-T_1**(4))+delta_H_rkn_T_1*X\n",
- "\n",
- "while(fault>0.01):\n",
- " K = math.exp(3.87 + (11389.10/T) - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3));\n",
- " X1 = fsolve(f,0.1)\n",
- " X2 = fsolve(f1,1)\n",
- " fault = abs(X1-X2);\n",
- " T = T + 0.01;\n",
- "\n",
- "# Results\n",
- "print \" The moles of SO2 reacted are %f mol\"%(X1);\n",
- "print \" The adiabatic reaction temperature is %f K\"%(T);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The moles of SO2 reacted are 7.594592 mol\n",
- " The adiabatic reaction temperature is 886.860000 K\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch1_2.ipynb b/Chemical_Engineering_Thermodynamics/ch1_2.ipynb
deleted file mode 100755
index b7e6716d..00000000
--- a/Chemical_Engineering_Thermodynamics/ch1_2.ipynb
+++ /dev/null
@@ -1,774 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:05ef5db2afef7232054abda0278780d1df8c92b807546fcd7648e8885fa4539f"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 1 : Introduction"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.1 Page number - 6"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# \n",
- "# Variables\n",
- "#(a)\n",
- " \n",
- "m = 50.;\t\t\t#[kg] - Mass of piston\n",
- "A = 0.05;\t\t\t#[m**(2)] - Area of piston\n",
- "g = 9.81;\t\t\t#[m/s**(2)] - Acceleration due to gravity\n",
- "Po = 101325;\t\t\t#[N/m**(2)] - Atmospheric pressure\n",
- "\n",
- "# Calculations and Results\n",
- "P = (m*g/A)+Po;\t\t\t#[N/m**(2)]\n",
- "P = P/100000.;\t\t\t#[bar]\n",
- "print \" (a).Pressure = %f bar\"%P\n",
- "\n",
- "#(b)\n",
- "print \" (b).Since the piston weight and surroundings pressure are the same, \\\n",
- "the gas pressure in the piston-cylinder assembly remains %f bar\"%P\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (a).Pressure = 1.111350 bar\n",
- " (b).Since the piston weight and surroundings pressure are the same, the gas pressure in the piston-cylinder assembly remains 1.111350 bar\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.2 Page number - 8\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "P = 1.;\t\t\t#[atm] - Atmospheric pressure\n",
- "P = 101325.;\t\t\t#[N/m**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "T = 30.;\t\t\t#[C] - Temperature of air\n",
- "T = 30.+273.15;\t\t\t#[K]\n",
- "V = 5.*5*5;\t\t\t#[m**(3)] - Volume of the room\n",
- "\n",
- "# Calculations\n",
- "#The number of moles of air is given by\n",
- "n = (P*V)/(R*T)\t\t\t#[mol]\n",
- "\n",
- "#Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n",
- "m = n*28.84;\t\t\t#[g]\n",
- "m = m/1000.;\t\t\t#[kg]\n",
- "\n",
- "# Results\n",
- "print \"The mass of air is, m = %f kg\"%m\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The mass of air is, m = 144.928664 kg\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.3 Page number - 13\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "P1 = 3.;\t\t\t# [bar] - initial pressure\n",
- "V1 = 0.5;\t\t\t# [m**(3)] - initial volume\n",
- "V2 = 1.0;\t\t\t# [m**(3)] - final volume\n",
- "import math\n",
- "#(a)\n",
- "n = 1.5;\n",
- "\n",
- "# Calculations and Results\n",
- "#Let P*V**(n)=C \t\t\t# Variables relation\n",
- "#W (work done per mole)= (integrate('P'%'V'%V1%V2))\n",
- "#W = (integrate('(C/V**(n))'%'V'%V1%V2)) = (C*((V2***(1-n))-(V1***(1-n))))/(1-n)\n",
- "#Where C=P*V**(n)=P1*V1**(n)=P2*V2**(n)\n",
- "#Thus w=((P2*V2**(n)*V2**(1-n))-(P1*V1**(n)*V1**(1-n)))/(1-n)\n",
- "#w = ((P2*V2**(n))-(P1*V1**(n)))/(1-n)\n",
- "#and thus W=((P2*V2)-(P1*V1))/(1-n)\n",
- "#The above math.expression is valid for all values of n%except n=1.0\n",
- "P2 = (P1*((V1/V2)**(n)))\t\t\t#[bar] \t\t\t#pressure at state 2\n",
- "\n",
- "#we have%(V1/V2)=(V1t/(V2t)%since the number of moles are constant.Thus\n",
- "W = ((P2*V2)-(P1*V1))/(1-n)*10**(5)\t\t\t#[J]\n",
- "W = W/1000.;\t\t\t#[kJ]\n",
- "print \" (a).The work done (for n=1.5) is %f kJ\"%W\n",
- "\n",
- "#(b)\n",
- "#For n=1.0%we have% PV=C.\n",
- "# w(wok done per mol)= (integrate('P'%'V'%V1%V2)) = (integrate('C/V'%'V'%V1%V2)) = C*ln(V2/V1)=P1*V1*ln(V2/V1)\n",
- "W1 = P1*V1*math.log(V2/V1)*10**(5)\t\t\t#[J]\n",
- "W1 = W1/1000.;\t\t\t#[kJ]\n",
- "print \" (b).The work done (for n=1.0) is %f kJ\"%W1\n",
- "\n",
- "#(c)\n",
- "#For n=0%we get P=Constant and thus\n",
- "P = P1;\t\t\t#[bar]\n",
- "# w =(integrate('P'%'V'%V1%V2)) = P*(V2-V1)\n",
- "W2 = P*(V2-V1)*10**(5)\t\t\t#[J]\n",
- "W2 = W2/1000.;\t\t\t#[kJ]\n",
- "print \" (c).The work done (for n=0) is %f kJ\"%W2\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (a).The work done (for n=1.5) is 87.867966 kJ\n",
- " (b).The work done (for n=1.0) is 103.972077 kJ\n",
- " (c).The work done (for n=0) is 150.000000 kJ\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.4 Page number - 17\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "#(a)\n",
- "# Variables\n",
- "V = 9.;\t\t\t# [m/s] - velocity\n",
- "d = 1.;\t\t\t#[m] - diameter\n",
- "A = 3.14*(d/2)**(2)\t\t\t#[m**(2)] - area\n",
- "P = 1.;\t\t\t#[atm] - pressure\n",
- "P = 101325.;\t\t\t# [N/m**(2)]\n",
- "T = 300.;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "E = (V**(2))/2.;\t\t\t#[J/kg]\n",
- "print \" (a).The wind energy per unit mass of air is %f J/kg\"%E\n",
- "\n",
- "#(b)\n",
- "# Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n",
- "M = 28.84*10**(-3)\t\t\t#[kg/mol]\n",
- "r = (P*M)/(R*T)\t\t\t#[kg/m**(3)] - density\n",
- "m = r*V*A;\t\t\t# [kg/s] - mass flow rate of air\n",
- "pi = m*E;\t\t\t#[Watt] - power input\n",
- "print \" (b).The wind power input to the turbine is %f Watt\"%pi\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (a).The wind energy per unit mass of air is 40.500000 J/kg\n",
- " (b).The wind power input to the turbine is 335.233787 Watt\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.5 Page number - 23\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Given\n",
- "P = 1.;\t\t\t # [bar] - atospheric pressure\n",
- "P1guz = 0.75;\t\t\t# [bar] - gauze pressure in 1st evaporator\n",
- "P2Vguz = 0.25;\t\t\t# [bar] - vaccum gauze pressure in 2nd evaporator\n",
- "\n",
- "# Calculations\n",
- "P1abs = P + P1guz;\t\t\t# [bar] - absolute pressure in 1st evaporator\n",
- "P2abs = P - P2Vguz;\t\t\t# [bar] -absolute pressure in 2nd evaporator\n",
- "\n",
- "# Results\n",
- "#From saturated steam table as reported in the book\n",
- "print \" For P1abs (absolute pressure) = %f bar\"%P1abs\n",
- "print \" The saturation temperature in first evaporator is 116.04 C\"\n",
- "print \" For P2abs (absolute pressure) = %f bar\"%P2abs\n",
- "print \" The saturation temperature in second evaporator is 91.76 C\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " For P1abs (absolute pressure) = 1.750000 bar\n",
- " The saturation temperature in first evaporator is 116.04 C\n",
- " For P2abs (absolute pressure) = 0.750000 bar\n",
- " The saturation temperature in second evaporator is 91.76 C\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.6 Page number - 23\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "V = 1.;\t\t\t # [kg] - volume of tank\n",
- "P = 10.;\t\t\t# [bar] - pressure\n",
- "\n",
- "#Here degree of freedom =1(C=1%P=2%threfore F=1)\n",
- "#From steam table at 10 bar as reported in the book\n",
- "V_liq = 0.001127;\t\t\t# [m**(3)/kg] - volume in liquid phase\n",
- "V_vap = 0.19444;\t\t\t# [m**(3)/kg] - volume in vapour phase\n",
- "\n",
- "# Calculations\n",
- "#x*Vv=(1-x)*Vl \t\t\t# since two volumes are equal\n",
- "x = (V_liq/(V_liq+V_vap))\t\t\t# [kg]\n",
- "y = (1-x)\t\t\t#[kg]\n",
- "\n",
- "# Results\n",
- "print \" Mass of saturated vapour is %f kg\"%x\n",
- "print \" Mass of saturated liquid is %f kg\"%y\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Mass of saturated vapour is 0.005763 kg\n",
- " Mass of saturated liquid is 0.994237 kg\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.7 Page number - 23"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "V = 1.;\t\t\t# [m**(3)] - volume of tank\n",
- "M = 10.;\t\t\t# [m**(3)] - total mass\n",
- "T = (90+273.15)\t\t\t#[K] - temperature\n",
- "\n",
- "#From steam table at 90 C as reported in the book\n",
- "#vapour pressure(pressure of rigid tank) = 70.14[kPa] = 0.7014[bar]\n",
- "print \" Pressure of tank = 0.7014 bar\"\n",
- "\n",
- "# Calculations and Results\n",
- "V_liq_sat=0.001036;\t\t\t# [m**(3)/kg] - saturated liquid specific volume\n",
- "V_vap_sat=2.36056;\t\t\t# [m**(3)/kg] - saturated vapour specific volume\n",
- "\n",
- "#1=(V_liq_sat*(10-x))+(V_vap_sat*x)\n",
- "x = (1-(10*V_liq_sat))/(V_vap_sat-V_liq_sat)\t\t\t#[kg]\n",
- "y = (10-x)\t\t\t#[kg]\n",
- "\n",
- "print \" The amount of saturated liquid is %f kg\"%y\n",
- "print \" The amount of saturated vapour is %f kg \"%x\n",
- "\n",
- "z = y*V_liq_sat;\t\t\t#[m**(3)] - Volume of saturated liquid \n",
- "w = x*V_vap_sat;\t\t\t#[m**(3)] - Volume of saturated vapour\n",
- "\n",
- "print \" Total volume of saturated liquid is %f m**(3)\"%z\n",
- "print \" Total volume of saturated vapour is %f m**(3)\"%w\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Pressure of tank = 0.7014 bar\n",
- " The amount of saturated liquid is 9.580576 kg\n",
- " The amount of saturated vapour is 0.419424 kg \n",
- " Total volume of saturated liquid is 0.009925 m**(3)\n",
- " Total volume of saturated vapour is 0.990075 m**(3)\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.8 Page number - 24"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "V = 10.;\t\t\t# [m**(3)] - volume of vessel\n",
- "P_1 = 1.;\t\t\t# [bar] - initial pressure\n",
- "V_liq_sat = 0.05;\t\t\t# [m**(3)] - saturated liquid volume\n",
- "V_gas_sat = 9.95;\t\t\t# [m**(3)] - saturated vapour volume\n",
- "\n",
- "#At 1 bar pressure\n",
- "V_liq_1 = 0.001043;\t\t\t# [m**(3/kg)] - specific saturated liquid volume\n",
- "U_liq_1 = 417.33;\t\t\t# [kJ/kg] - specific internal energy\n",
- "V_gas_1 = 1.69400;\t\t\t# [m**(3/kg)] - specific saturated vapour volume\n",
- "U_gas_1 = 2506.06;\t\t\t# [kJ/kg]\n",
- "\n",
- "# Calculations\n",
- "M_liq_1 = V_liq_sat/V_liq_1;\t\t\t# [kg] - mass of saturated liqid\n",
- "M_gas_1 = V_gas_sat/V_gas_1;\t\t\t# [kg] - mass of saturated vapour\n",
- "M = (M_liq_1+M_gas_1)\t\t\t# [kg] - total mass\n",
- "U_1t = (M_liq_1*U_liq_1)+(M_gas_1*U_gas_1)\t\t\t# [kJ] - initial internal energy\n",
- "V_gas_2 = (V/M)\t\t\t#[m**(3/kg)]\n",
- "\n",
- "#from steam table at 10 bar pressure as reported in the book\n",
- "V_vap_2 = 0.19444;\t\t\t# [m**(3/kg)]\n",
- "U_vap_2 = 2583.64;\t\t\t# [kJ/kg]\n",
- "\n",
- "#from steam table at 11 bar pressure as reported in the book\n",
- "V_vap_3 = 0.17753;\t\t\t#[m**(3/kg)]\n",
- "U_vap_3 = 2586.40;\t\t\t#[kJ/kg]\n",
- "\n",
- "#Now computing pressure when molar volume of saturated vapour=Vg_2\n",
- "#By interpolation (P2-10)/(11-10)=(Vg_2-Vv_2)/(Vv_3-Vv_2)\n",
- "P_2 = (((V_gas_2 - V_vap_2)/(V_vap_3 - V_vap_2)*1)+10)\t\t\t# [bar] - final pressure\n",
- "\n",
- "#By interpolation calculating internal energy at state 2\n",
- "#(P2-10)/(11-10)=(U2-Uv_2)/(Uv_3-Uv_2)\n",
- "U_2 = (((P_2-10)/(11-10))*(U_vap_3 - U_vap_2))+U_vap_2;\t\t\t#[kJ/kg]\n",
- "U_2t = U_2*M;\t\t\t#[kJ]\n",
- "H = U_2t - U_1t;\t\t\t#[kJ] - Heat supplied\n",
- "H = H/1000;\t\t\t#[MJ]\n",
- "\n",
- "# Results\n",
- "print \" Total heat supplied is %f MJ\"%H\n",
- "# since volume is constant%no work is done by the system and heat supplied is used in increasing the internal energy of the system.\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Total heat supplied is 104.381244 MJ\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.9 Page number - 26"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "#Antoine equation for water ln(Psat)=16.262-(3799.89/(T_sat + 226.35))\n",
- "P = 2.;\t\t\t#[atm] - Pressure\n",
- "P = (2.*101325)/1000;\t\t\t#[kPa]\n",
- "\n",
- "# Calculations\n",
- "P_sat = P;\t\t\t# Saturation pressure\n",
- "T_sat = (3799.89/(16.262-math.log(P_sat)))-226.35;\t\t\t#[C] - Saturation temperature\n",
- "#Thus boiling at 2 atm occurs at Tsat = 120.66 C.\n",
- "\n",
- "#From steam tables%at 2 bar%Tsat = 120.23 C and at 2.25 bar%Tsat = 124.0 C\n",
- "#From interpolation for T_sat = 120.66 C%P = 2.0265 bar\n",
- "#For P_= 2.0265 bar%T_sat% from steam table by interpolation is given by\n",
- "#((2.0265-2)/(2.25-2))=((Tsat-120.23)/(124.0-120.23))\n",
- "T_sat_0 = (((2.0265-2)/(2.25-2))*(124.0-120.23))+120.23;\t\t\t#[C]\n",
- "\n",
- "# Results\n",
- "print \" Saturation temperature (Tsat) = %f C which is close \\\n",
- "to %f C as determined from Antoine equation\"%(T_sat_0,T_sat)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Saturation temperature (Tsat) = 120.629620 C which is close to 120.655450 C as determined from Antoine equation\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.10 Page number - 27"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "# math.log(P)=-(1640/T)+10.56 (solid)\n",
- "# math.log(P)=-(1159/T)+7.769 (liquid)%where T is in K\n",
- "# F+P=C+2% at triple point F+3=1+2 or%F=0 i.e%vapour pressure of liquid and solid at triple point are same%we get\n",
- "# -(1640/T)+10.56 = -(1159/T)+7.769\n",
- "\n",
- "# Calculations\n",
- "T = (1640-1159)/(10.56-7.769)\t\t\t#[K]\n",
- "P = 10**((-1640/T)+10.56)\t\t\t#[torr]\n",
- "\n",
- "# Results\n",
- "print \" The temperature is %f K\"%T\n",
- "print \" The pressure is %f torr (or mm Hg)\"%P\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The temperature is 172.339663 K\n",
- " The pressure is 11.063907 torr (or mm Hg)\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.11 Page number - 29"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "M_O2 = 31.999;\t\t\t#molecular weight of oxygen\n",
- "M_N2 = 28.014;\t\t\t#molecular weight of nitrogen\n",
- "Y = 1.4;\t\t\t#molar heat capacities ratio for air\n",
- "\n",
- "# Calculations and Results\n",
- "#Molecular weight of air(21 vol% O2 and 79 vol% N2)is given by\n",
- "M_air = (0.21*M_O2)+(0.79*M_N2)\t\t\t#(vol% = mol%)\n",
- "\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "R = (R*1/M_air)\t\t\t#[kJ/kg*K]\n",
- "\n",
- "print \" The value of universal gas constant (R) = %f kJ/kg-K \"%R\n",
- "\n",
- "#Y=Cp0/Cv0 and Cp0-Cv0=R\n",
- "Cv_0 = R/(Y-1)\t\t\t#[kJ/kg*K] \n",
- "Cp_0 = Y*Cv_0;\t\t\t#[kJ/kg*K]\n",
- "print \" The value of Cp_0 for air is %f kJ/kg-K\"%Cp_0\n",
- "print \" The value of Cv_0 for air is %f kJ/kg-K\"%Cv_0\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of universal gas constant (R) = 0.288172 kJ/kg-K \n",
- " The value of Cp_0 for air is 1.008601 kJ/kg-K\n",
- " The value of Cv_0 for air is 0.720429 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.12 Page number - 30"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "Y = 1.4;\t\t\t#molar heat capacities ratio for air\n",
- "R = 8.314;\t\t\t# [J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations\n",
- "Cv_0 = R/(Y-1)\t\t\t# [J/mol*K]\n",
- "Cp_0 = Y*Cv_0;\t\t\t# [J/mol*K]\n",
- "\n",
- "# Results\n",
- "print \" The molar heat capacity at constant volume (Cv_0) is %f J/mol-K\"%Cv_0\n",
- "print \" The molar heat capacity at constant pressure (Cp_0) is %f J/mol-K\"%Cp_0\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The molar heat capacity at constant volume (Cv_0) is 20.785000 J/mol-K\n",
- " The molar heat capacity at constant pressure (Cp_0) is 29.099000 J/mol-K\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.13 Page number - 30"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.integrate import quad\n",
- "\n",
- "# Variables\n",
- "# Cp0=7.7+(0.04594*10**(-2)*T)+(0.2521*10**(-5)*T**(2))-(0.8587*10**(-9)*T**(3))\n",
- "T_1 = 400.;\t\t\t#[K]\n",
- "T_2 = 500.;\t\t\t#[K]\n",
- "\n",
- "# Calculations\n",
- "def f(T):\n",
- " return 7.7+(0.04594*10**(-2)*T)+(0.2521*10**(-5)*T**(2))-(0.8587*10**(-9)*T**(3))\n",
- "#(C)avg = q/(T_2 - T_1) = 1/(T_2 - T_1)*{(integrate('C'%'T'%T_1%T_2))}\n",
- "#(Cp0)avg = 1/(T_2 - T_1)*{(integrate('Cp0'%'T'%T_1%T_2))}\n",
- "Cp0_avg = (1/(T_2 - T_1))*quad(f,T_1,T_2)[0]\n",
- "\n",
- "# Results\n",
- "print \" The mean heat capacity (Cp0_avg) for temerature range of 400 to 500 K is %f cal/mol-K\"%Cp0_avg\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The mean heat capacity (Cp0_avg) for temerature range of 400 to 500 K is 8.340118 cal/mol-K\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 1.14 Page number - 31"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "#(a)\n",
- "P_1 = 0.2;\t\t\t# [MPa] - pressure\n",
- "x_1 = 0.59;\t\t\t# mole fraction\n",
- "\n",
- "# Calculations and Results\n",
- "#From saturated steam tables at 0.2 MPa\n",
- "H_liq_1 = 504.7;\t\t\t# [kJ/kg] - Enthalpy of saturated liquid\n",
- "H_vap_1 = 2706.7;\t\t\t# [kJ/kg]- Enthalpy of saturated vapour\n",
- "H_1 = (H_liq_1*(1-x_1))+(x_1*H_vap_1)\t\t\t# [kJ/kg]\n",
- "print \" (a).Enthalpy of 1 kg of water in tank is %f kJ/kg\"%H_1\n",
- "\n",
- "#(b)\n",
- "T_2 = 120.23;\t\t\t# [C] - temperature\n",
- "V_2 = 0.6;\t\t\t# [m**(3)/kg] - specific volume\n",
- "\n",
- "#From saturated steam tables at 120.23 C% as reported in the book\n",
- "V_liq_2=0.001061;\t\t\t# [m**(3)/kg]\n",
- "V_vap_2=0.8857;\t\t\t# [m**(3)/kg]\n",
- "#since V_2 < Vv_2%dryness factor will be given by% V = ((1-x)*V_liq)+(x*V_vap)\n",
- "x_2 = (V_2- V_liq_2)/(V_vap_2 - V_liq_2)\n",
- "\n",
- "#From steam table%at 120.2 C%the vapour pressure of water is 0.2 MPa.So%enthalpy is given by\n",
- "H_2 = (H_liq_1*(1-x_2))+(H_vap_1*x_2)\t\t\t#kJ/kg]\n",
- "print \" (b).Enthalpy of saturated steam is %f kJ/kg\"%H_2\n",
- "\n",
- "#(c)\n",
- "P_3 = 2.5;\t\t\t#[MPa]\n",
- "T_3 = 350;\t\t\t#[C]\n",
- "#From steam tables at 2.5 MPa%T_sat = 223.99 C%as reported in the book\n",
- "#since%T_3 > Tsat% steam is superheated\n",
- "print \" (c).As steam is superheated%from steam table%enthalpy (H) is 3126.3 kJ/kg\"\n",
- "\n",
- "#(d)\n",
- "T_4 = 350;\t\t\t#[C]\n",
- "V_4 = 0.13857;\t\t\t#[m**(3)/kg]\n",
- "#From steam table%at 350 C% V_liq = 0.001740 m**(3)/kg and V_vap = 0.008813 m**(3)/kg.Since%V > V_vap%therefore it is superheated.\n",
- "#From steam table at 350 C and 1.6 MPa% V = 0.17456 m**(3)/kg\n",
- "#At 350 C and 2.0 MPa% V = 0.13857 m**(3)/kg. So%\n",
- "print \" (d).The enthalpy of superheated steam (H) is 3137.0 kJ/kg\"\n",
- "\n",
- "#(e)\n",
- "P_4 = 2.0;\t\t\t#[MPa]\n",
- "U_4 = 2900;\t\t\t# [kJ/kg] - internal energy\n",
- "#From saturated table at 2.0 MPa% U_liq = 906.44kJ and U_vap = 2600.3 kJ/kg\n",
- "#scince%U_4 > Uv% it is saturated.\n",
- "#From superheated steam table at 2.0 MPa and 350 C% as reported in the book\n",
- "U_1 = 2859.8;\t\t\t#[kJ/kg]\n",
- "H_1 = 3137.0;\t\t\t#[kJ/kg]\n",
- "#At 2.0 MPa and 400 C%\n",
- "U_2 = 2945.2;\t\t\t#[kJ/kg]\n",
- "H_2 = 3247.6;\t\t\t#[kJ/kg]\n",
- "T = (((U_4 - U_1)/(U_2 - U_1))*(400 - 350)) + 350;\t\t\t#[C] - By interpolation\n",
- "H = (((T - 350)/(400 - 350))*(H_2 - H_1)) + H_1;\t\t\t#[kJ/kg]\n",
- "print \" (e).The enthalpy value (of superheated steam) obtained after interpolation is %f kJ/kg\"%H\n",
- "\n",
- "#(f)\n",
- "P_5 = 2.5;\t\t\t#[MPa]\n",
- "T_5 = 100;\t\t\t#[C]\n",
- "#At 100 C%P_sat=101350 N/m**(2). Since P_5 > P_sat%it is compressed liquid\n",
- "P_sat = 0.101350;\t\t\t#[MPa]\n",
- "H_liq = 419.04;\t\t\t#[kJ/kg] - At 100 C and 0.10135 MPa\n",
- "V_liq = 0.001044;\t\t\t#[m**(3)/kg] - At 100 C and 0.10135 MPa\n",
- "H_0 = H_liq + (V_liq*(P_5 - P_sat))*1000;\t\t\t#kJ/kg]\n",
- "print \" (f).The enthalpy of compressed liquid is %f kJ/kg\"%H_0\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (a).Enthalpy of 1 kg of water in tank is 1803.880000 kJ/kg\n",
- " (b).Enthalpy of saturated steam is 1995.549576 kJ/kg\n",
- " (c).As steam is superheated%from steam table%enthalpy (H) is 3126.3 kJ/kg\n",
- " (d).The enthalpy of superheated steam (H) is 3137.0 kJ/kg\n",
- " (e).The enthalpy value (of superheated steam) obtained after interpolation is 3189.062295 kJ/kg\n",
- " (f).The enthalpy of compressed liquid is 421.544191 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 15
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch2_2.ipynb b/Chemical_Engineering_Thermodynamics/ch2_2.ipynb
deleted file mode 100755
index b3f8bd13..00000000
--- a/Chemical_Engineering_Thermodynamics/ch2_2.ipynb
+++ /dev/null
@@ -1,1287 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:6aa23fb1475338cf467e7afb5732b8b9e456bbb3ad63c14224d73232d920457e"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "\n",
- "Chapter 2 : Equations of state"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.2 Page number - 42"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "Tc = 647.1;\t\t\t#[K] - Critical temperature\n",
- "Pc = 220.55;\t\t#[bar] - Critical pressure\n",
- "Tr = 0.7;\t\t\t# Reduced temperature\n",
- "\n",
- "# Calculations\n",
- "T = Tr*Tc;\t\t\t#[K]\n",
- "\t\t\t#From steam table%vapour pressure of H2O at T is 10.02 [bar]% as reported in the book\n",
- "P = 10.02;\t\t\t#[bar]\n",
- "w = -1-math.log10((P/Pc))\n",
- "\n",
- "# Results\n",
- "print \" The acentric factor (w) of water at given condition is %f \"%w\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The acentric factor (w) of water at given condition is 0.342639 \n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.3 Page number - 42"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "\t\t\t#math.log10(Psat)=8.1122-(1592.864/(t+226.184))\t\t\t# 'Psat' in [mm Hg] and 't' in [c]\n",
- "Tc = 513.9;\t\t\t#[K] - Critical temperature\n",
- "Pc = 61.48;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5)\t\t\t#[N/m**(2)]\n",
- "Tr = 0.7;\t\t\t# Reduced temperature\n",
- "\n",
- "# Calculations\n",
- "T = Tr*Tc;\t\t\t#[K] - Temperature\n",
- "T = T - 273.15;\t\t\t#[C]\n",
- "P_sat = 10**(8.1122 - (1592.864/(T + 226.184)))\t\t\t#[mm Hg]\n",
- "P_sat = (P_sat/760)*101325;\t\t\t#[N/m**(2)]\n",
- "Pr_sat = P_sat/Pc;\n",
- "w = -1-math.log10(Pr_sat)\t\t\t# Acentric factor\n",
- "\n",
- "# Results\n",
- "print \" The acentric factor (w) for ethanol at given condition is %f\"%w\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The acentric factor (w) for ethanol at given condition is 0.644493\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.4 Page number - 45"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 380;\t\t\t#[K] - Temperature\n",
- "Tc = 562.1;\t\t\t#[K] - Critical temperature\n",
- "P = 7;\t\t\t#[atm] - Pressure\n",
- "P = P*101325;\t\t\t#[N/m**(2)]\n",
- "Pc = 48.3;\t\t\t#[atm] - Critical pressure\n",
- "Pc = Pc*101325;\t\t\t#[N/m**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "w = 0.212;\t\t\t# acentric factor\n",
- "Tr = T/Tc;\t\t\t# Reduced temperature\n",
- "\n",
- "# Calculations and Results\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6))\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2))\n",
- "\n",
- "\t\t\t#We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- "print \" The second virial coefficient for benzene is %e m**(3)/mol\"%B\n",
- "\n",
- "\t\t\t#Compressibility factor is given by\n",
- "Z = 1 + ((B*P)/(R*T))\n",
- "print \" The compressibility factor at 380 K is %f\"%Z\n",
- "\n",
- "\t\t\t#We know thar Z=(P*V)/(R/*T)%therfore\n",
- "V = (Z*R*T)/P;\t\t\t#[m**(3)/mol]\n",
- "print \" The molar volume is %e m**(3)/mol\"%V\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The second virial coefficient for benzene is -8.267963e-04 m**(3)/mol\n",
- " The compressibility factor at 380 K is 0.814382\n",
- " The molar volume is 3.627499e-03 m**(3)/mol\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.5 Page number - 46"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "V_1 = 0.3;\t\t\t#[m**(3)]\t\t\t#volume of cylinder\n",
- "T = 60+273.15;\t\t\t#[K] - Temperature\n",
- "P = 130*10**(5)\t\t\t#[N/m**(2)] - Pressure\n",
- "Tc = 305.3;\t\t\t#[K] - Critical temperature\n",
- "Pc = 48.72*10**(5)\t\t\t#[N/m**(2)] - Critical pressure\n",
- "w = 0.100;\t\t\t#acentric factor\n",
- "M = 30.07;\t\t\t#molecular weight of ethane\n",
- "Tr = T/Tc;\t\t\t# Reduced temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6))\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2))\n",
- "\n",
- "\t\t\t#We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B = ((B_0 + (w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- "Z = 1 + ((B*P)/(R*T))\t\t\t#Compressibility factor\n",
- "V = (Z*R*T)/P;\t\t\t#[m**(3)/mol] - Molar volume\n",
- "\n",
- "\t\t\t#No.of moles in 0.3 m**(3) cylinder is given by\n",
- "n1 = V_1/V;\t\t\t#[mol]\n",
- "\n",
- "\t\t\t#Mass of gas in cylinder is given by \n",
- "m1 = (n1*M)/1000.;\t\t\t#[kg]\n",
- "print \" Under actual conditions, the mass of ethane is, %f kg\"%m1\n",
- "\n",
- "\t\t\t#Under ideal condition% taking Z = 1%\n",
- "V_ideal = (R*T)/P;\t\t\t#[m**(3)/mol]\n",
- "n2 = V_1/V_ideal;\t\t\t#[mol]\n",
- "m2 = (n2*M)/1000;\t\t\t#[kg]\n",
- "print \" Under ideal conditions,the mass of ethane is, %f kg\"%m2\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Under actual conditions, the mass of ethane is, 136.395203 kg\n",
- " Under ideal conditions,the mass of ethane is, 42.339741 kg\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.6 Page number - 47"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 373.15;\t\t\t#[K] - Temperature\n",
- "P = 101325;\t\t\t#[N/m**(2)] - Pressure\n",
- "Tc = 647.1;\t\t\t#[K] - Critical temperature\n",
- "Pc = 220.55*10**(5)\t#[N/m**(2)] - Critical pressure\n",
- "w = 0.345;\t\t\t#acentric factor\n",
- "Tr = T/Tc;\t\t\t# Reduced temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - UNiversal gas constant\n",
- "\n",
- "# Calculations\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6))\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2))\n",
- "\n",
- "\t\t\t#We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol] - Second virial coefficient\n",
- "\n",
- "\t\t\t#We have% Z = 1+(B/V) and Z = (P*V)/(R*T). Substituting the value of Z%we get\n",
- "\t\t\t# V**(2)-((R*T)/P)*V-((B*R*T)/P)=0 .Solving the quadratic equation by shreedharcharya rule\n",
- "V1 = (((R*T)/P) + (((R*T)/P)**(2) + 4*1*((B*R*T)/P))**(1./2))/2*1;\n",
- "\n",
- "# Results\n",
- "print \" The molar volume of water vapour is %f m**(3)/mol\"%V1\n",
- "\n",
- "\t\t\t#The roots are%V1 = 0.0003670 [m**(3)/mol] and V2 = 0.0302510 [m**(3)/mol].\n",
- "\t\t\t#As 'V2' is near to ideal volume (0.030618 [m**(3)/mol])%it is taken as the molar volume\n",
- "\t\t\t#The other root 'V1' hss no physical significance\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The molar volume of water vapour is 0.030251 m**(3)/mol\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.7 Page number - 47"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 50+273.15;\t\t\t#[K] - Temperature\n",
- "P = 15*10**(5)\t\t\t#[N/m**(2)] - Pressure\n",
- "Tc = 305.3;\t\t\t#[K] - Critical temperature\n",
- "Pc = 48.72*10**(5)\t\t\t#[N/m**(2)] - Critical pressure\n",
- "w = 0.100;\t\t\t# Acentric factor\n",
- "B = -157.31;\t\t\t#[cm**(3)/mol] - second virial coefficient\n",
- "B = B*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "C = 9650;\t\t\t#[cm**(6)/mol**(2)] - third virial coefficient\n",
- "C = C*10**(-12)\t\t\t#[cm**(6)/mol**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (1)\n",
- "V_1 = (R*T)/P;\t\t\t#[m**(3)/mol] - Molar volume\n",
- "print \" (1).The molar volume for ideal equation of state is %e m**(3)/mol\"%V_1\n",
- "\n",
- "\t\t\t# (2)\n",
- "Tr = T/Tc;\t\t\t# Reduced temperature\n",
- "\t\t\t# At this temperature\n",
- "B_0 = 0.083-(0.422/(Tr)**(1.6))\n",
- "B_1 = 0.139-(0.172/(Tr)**(4.2))\n",
- "\n",
- "\t\t\t# We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_2 = ((B_0 + (w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\t\t\t#second virial coefficient\n",
- "print \" (2).The second virial coefficent using Pitzer correlation is \\\n",
- "found to be %e m**(3)/mol which is same as given value\"%B_2\n",
- "\n",
- "\t\t\t# (3)\n",
- "\t\t\t# Given (virial equation)%Z=1+(B/V)\n",
- "V_3 = B + (R*T)/P;\t\t\t#[m**(3)/mol] - Molar volume\n",
- "print \" (3).The molar volume using virial equation of state is %e m**(3)/mol\"%V_3\n",
- "\n",
- "\t\t\t# (4)\n",
- "\t\t\t# Given (virial equation)%Z = 1 + ((B*P)/(R*T)) + ((C - B**(2))/(R*T)**(2))*P**(2)\n",
- "V_4 = B + (R*T)/P + ((C - B**(2))/(R*T))*P;\t\t\t# [m**(3)/mol]\n",
- "print \" (4).The molar volume using given virial equation of state is %e m**(3)/mol\"%V_4\n",
- "\n",
- "\t\t\t# (5)\n",
- "\t\t\t# Given%Z = 1 + (B/V)\n",
- "\t\t\t# Also%Z = (P*V)/(R*T). Substituting the value of Z%we get\n",
- "\t\t\t# V**(2)-((R*T)/P)*V-((B*R*T)/P)=0.Solving the quadratic equation\n",
- "from scipy.optimize import fsolve\n",
- "def f(V):\n",
- " global R,T,P,B\n",
- " return V**(2)-((R*T)/P)*V-((B*R*T)/P)\n",
- "V_5_1 = fsolve(f,0)\n",
- "V_5_2 = fsolve(f,1)\n",
- "\n",
- "print \" (5).The molar volume using given virial equation of state is %e m**(3)/mol\"%V_5_2\n",
- "\n",
- "\t\t\t# The roots are%V_5_1=0.0001743 [m**(3)/mol] and V_5_2=0.0016168 [m**(3)/mol].\n",
- "\t\t\t# As 'V_2' is near to ideal volume (0.0017911 [m**(3)/mol])%it is taken as the molar volume\n",
- "\n",
- "\t\t\t# (6)\n",
- "\t\t\t# Given%Z = 1 + (B/V) + (C/V**(2))\n",
- "\t\t\t# Also%Z = (P*V)/(R*T). Substituting the value of Z%we get\n",
- "\t\t\t# V**(3)-((R*T)/P)*V**(2)-((B*R*T)/P)*V-((C*R*T)/P)=0. Solving the cubic equation\n",
- "def f1(V):\n",
- " global P,R,T,B,C\n",
- " return V**(3)-((R*T)/P)*V**(2)-((B*R*T)/P)*V-((C*R*T)/P)\n",
- " \n",
- "V_6_3=fsolve(f1,-1)\n",
- "V_6_4=fsolve(f1,0)\n",
- "V_6_5=fsolve(f1,1)\n",
- "\t\t\t#The above equation has 1 real and 2 imaginary roots. We consider only real root.\n",
- "print \" (6).The molar volume using given virial equation of state is %e m**(3)/mol\"%V_6_5\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (1).The molar volume for ideal equation of state is 1.791113e-03 m**(3)/mol\n",
- " (2).The second virial coefficent using Pitzer correlation is found to be -1.573258e-04 m**(3)/mol which is same as given value\n",
- " (3).The molar volume using virial equation of state is 1.633803e-03 m**(3)/mol\n",
- " (4).The molar volume using given virial equation of state is 1.625374e-03 m**(3)/mol\n",
- " (5).The molar volume using given virial equation of state is 1.616848e-03 m**(3)/mol"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " (6).The molar volume using given virial equation of state is 1.624187e-03 m**(3)/mol\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stderr",
- "text": [
- "/home/jovina/virtualenvs/scipy/local/lib/python2.7/site-packages/scipy/optimize/minpack.py:236: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
- " improvement from the last ten iterations.\n",
- " warnings.warn(msg, RuntimeWarning)\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.8 Page number - 49"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 0 + 273.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "from numpy import linalg,array\n",
- "from scipy.stats import linregress\n",
- "\t\t\t#Virial equation of state% Z=1+(B/V)+(C/V**(2))\n",
- "\t\t\t#From above equation we get (Z-1)*V=B+(C/V)\n",
- "\n",
- "P=[50,100,200,400,600,1000];\n",
- "Z=[0.9846,1.0000,1.0365,1.2557,1.7559,2.0645];\n",
- "V=[0,0,0,0,0,0]\n",
- "k= []\n",
- "t=array([0,0,0,0,0,0])\n",
- "\n",
- "# Calculations\n",
- "for i in range(6):\n",
- " V[i]=(Z[i]*R*T)/(P[i]*101325.)\t\t\t#[m**(3)/mol]\n",
- " k.append((Z[i]-1.)*V[i])\n",
- " t[i]=1./V[i]\n",
- " \n",
- "k = array(k)\n",
- "\n",
- "\t\t\t#w = linalg.lstsq(t.T,k.T)\n",
- "\t\t\t#[C,B,sig]=reglin(t',k')\n",
- "C,B,c,d,e = linregress(t.T,k.T)\n",
- "\n",
- "# Results\n",
- "#From the regression% we get intercept=B and slope=C%and thus%\n",
- "print \" The value of second virial coefficient (B) is %e m**(3)/mol\"%B\n",
- "print \" The value of third virial coefficient (C) is %e m**(6)/mol**(2)\"%C\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of second virial coefficient (B) is -1.563305e-05 m**(3)/mol\n",
- " The value of third virial coefficient (C) is 3.133359e-09 m**(6)/mol**(2)\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.9 Page number - 51"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 444.3;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "B_11 = -8.1;\t\t\t#[cm**(3)/mol]\n",
- "B_11 = -8.1*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "B_22 = -293.4*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "y1 = 0.5;\t\t\t# mole fraction \t\t\t# equimolar mixture\n",
- "y2 = 0.5;\n",
- "\n",
- "# For component 1 (methane)\n",
- "Tc_1 = 190.6;\t\t\t#[K] - cricitical temperature\n",
- "Vc_1 = 99.2;\t\t\t#[cm**(3)/mol] - cricitical molar volume\n",
- "Zc_1 = 0.288;\t\t\t# critical compressibility factor\n",
- "w_1 = 0.012;\t\t\t# acentric factor\n",
- "\n",
- "# For component 2 (n-butane)\n",
- "Tc_2 = 425.2;\t\t\t#[K]\n",
- "Vc_2 = 255.0;\t\t\t#[cm**(3)/mol]\n",
- "Zc_2 = 0.274;\n",
- "w_2 = 0.199;\n",
- "\n",
- "# Calculations\n",
- "#Using virial mixing rule%we get\n",
- "Tc_12 = (Tc_1*Tc_2)**(1./2)\t\t\t#[K]\n",
- "w_12 = (w_1 + w_2)/2.;\n",
- "Zc_12 = (Zc_1+Zc_2)/2.;\n",
- "Vc_12 = (((Vc_1)**(1./3) + (Vc_2)**(1./3))/2.)**(3)\t\t\t#[cm**(3)/mol]\n",
- "Vc_12 = Vc_12*10**(-6)\t\t\t#[cm**(3)/mol]\n",
- "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "Tr_12 = T/Tc_12;\t\t\t#Reduced temperature\n",
- "B_0 = 0.083 - (0.422/(Tr_12)**(1.6))\n",
- "B_1 = 0.139 - (0.172/(Tr_12)**(4.2))\n",
- "\n",
- "\t\t\t#We know%(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n",
- "B_12 = ((B_0+(w_12*B_1))*(R*Tc_12))/Pc_12;\t\t\t#[m**(3)/mol] - Cross coefficient\n",
- "B = y1**(2)*B_11+2*y1*y2*B_12+y2**(2)*B_22;\t\t\t#[m**(3)/mol] - Second virial coefficient for mixture\n",
- "B = B*10**(6)\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "# Results\n",
- "print \" The second virial coefficient,(B) for the mixture of gas is %f cm**(3)/mol\"%B\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The second virial coefficient,(B) for the mixture of gas is -108.309380 cm**(3)/mol\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 2.10 Page number - 52"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 71+273.15;\t\t\t#[K] - Temperature\n",
- "P = 69*10**(5)\t\t\t#[N/m**(2)] - Pressure\n",
- "y1 = 0.5;\t\t\t#[mol] - mole fraction of equimolar mixture\n",
- "y2 = 0.5;\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\t\t\t#For component 1 (methane)\n",
- "Tc_1 =190.6;\t\t\t#[K] - Critical temperature\n",
- "Pc_1 = 45.99*10**(5)\t\t\t#[N/m**(2)] - Critical pressure\n",
- "Vc_1 = 98.6;\t\t\t#[cm**(3)/mol] - Critical volume\n",
- "Zc_1 = 0.286;\t\t\t# Critical compressibility factor\n",
- "w_1 = 0.012;\t\t\t# acentric factor\n",
- "\n",
- "\t\t\t#For component 2 (hydrogen sulphide)\n",
- "Tc_2 = 373.5;\t\t\t#[K]\n",
- "Pc_2 = 89.63*10**(5)\t\t\t#[N/m**(2)]\n",
- "Vc_2 = 98.5;\t\t\t#[cm**(3)/mol]\n",
- "Zc_2 = 0.284;\n",
- "w_2 = 0.094;\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#For component 1\n",
- "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n",
- "\t\t\t#At reduced temperature\n",
- "B1_0 = 0.083-(0.422/(Tr_1)**(1.6))\n",
- "B1_1 = 0.139-(0.172/(Tr_1)**(4.2))\n",
- "\t\t\t#We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#Similarly for component 2\n",
- "Tr_2 = T/Tc_2;\t\t\t#Reduced temperature\n",
- "\t\t\t#At reduced temperature Tr_2%\n",
- "B2_0 = 0.083 - (0.422/(Tr_2)**(1.6))\n",
- "B2_1 = 0.139 - (0.172/(Tr_2)**(4.2))\n",
- "B_22 = ((B2_0+(w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For cross coeffcient\n",
- "Tc_12 = (Tc_1*Tc_2)**(1./2)\t\t\t#[K]\n",
- "w_12 = (w_1 + w_2)/2;\n",
- "Zc_12 = (Zc_1 + Zc_2)/2;\n",
- "Vc_12 = (((Vc_1)**(1./3) + (Vc_2)**(1./3))/2)**(3)\t\t\t#[cm**(3)/mol]\n",
- "Vc_12 = Vc_12*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "\n",
- "\t\t\t#Now we have%(B_12*Pc_12)/(R*Tc_12) = B_0+(w_12*B_1)\n",
- "\t\t\t#where B_0 and B_1 are to be evaluated at Tr_12\n",
- "Tr_12 = T/Tc_12;\n",
- "\t\t\t#At reduced temperature Tr_12\n",
- "B_0 = 0.083 - (0.422/(Tr_12)**(1.6))\n",
- "B_1 = 0.139 - (0.172/(Tr_12)**(4.2))\n",
- "B_12=((B_0 + (w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For the mixture\n",
- "B = y1**(2)*B_11+2*y1*y2*B_12 + y2**(2)*B_22;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#Now given virial equation is% Z=1+(B*P)/(R*T)\n",
- "Z = 1 + (B*P)/(R*T)\n",
- "\n",
- "\t\t\t#Also Z = (P*V)/(R*T).Therefore%\n",
- "V = (Z*R*T)/P;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Results\n",
- "print \" The molar volume of the mixture is %e m**(3)/mol\"%V\n",
- "\t\t\t#The value obtained is near the math.experimental value of V_math.exp = 3.38*10**(-4) m**(3)/mol\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The molar volume of the mixture is 3.390411e-04 m**(3)/mol\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- " Example - 2.11 Page number - 53"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P = 6.*10**(6)\t\t\t# [Pa] - Pressure\n",
- "P_max = 12.*10**(6)\t\t\t# [Pa] - Max pressure to which cylinder may be math.exposed\n",
- "T = 280.;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1).Assuming ideal gas behaviour%\n",
- "V_ideal = (R*T)/P;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t#Now when temperature and pressure are increased%the molar volume remains same%as total volume and number of moles are same.\n",
- "\t\t\t#For max pressure of 12 MPa%temperature is\n",
- "T_max_ideal = (P_max*V_ideal)/R;\n",
- "print \" (1).The maximum temperature assuming ideal behaviour is %f K\"%T_max_ideal\n",
- "\n",
- "\t\t\t# (2).Assuming virial equation of state\n",
- "\t\t\t# For component 1 (methane)%at 280 K\n",
- "Tc_1 = 190.6;\t\t\t#[K]\n",
- "Pc_1 = 45.99*10**(5)\t\t\t#[N/m**(2)]\n",
- "Vc_1 = 98.6;\t\t\t#[cm**(3)/mol]\n",
- "Zc_1 = 0.286;\n",
- "w_1 = 0.012;\n",
- "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n",
- "B1_0 = 0.083 - (0.422/(Tr_1)**(1.6))\n",
- "B1_1 = 0.139 - (0.172/(Tr_1)**(4.2))\n",
- "\n",
- "\t\t\t#We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_11 = ((B1_0 + (w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For component 2 (Propane)\n",
- "Tc_2 = 369.8;\t\t\t#[K]\n",
- "Pc_2 = 42.48*10**(5)\t\t\t#[N/m**(2)]\n",
- "Vc_2 = 200;\t\t\t#[cm**(3)/mol]\n",
- "Zc_2 = 0.276;\n",
- "w_2 = 0.152;\n",
- "Tr_2 = T/Tc_2;\t\t\t# Reduced temperature\n",
- "B2_0 = 0.083 - (0.422/(Tr_2)**(1.6))\n",
- "B2_1 = 0.139 - (0.172/(Tr_2)**(4.2))\n",
- "B_22 = ((B2_0 + (w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For cross coeffcient\n",
- "y1 = 0.8;\t\t\t#mole fraction of component 1\n",
- "y2 = 0.2;\t\t\t#mole fraction of component 2\n",
- "Tc_12 = (Tc_1*Tc_2)**(1/2.)\t\t\t#[K]\n",
- "w_12 = (w_1 + w_2)/2;\n",
- "Zc_12 = (Zc_1 + Zc_2)/2;\n",
- "Vc_12 = (((Vc_1)**(1./3) + (Vc_2)**(1./3))/2)**(3)\t\t\t#[cm**(3)/mol]\n",
- "Vc_12 = Vc_12*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "Tr_12 = T/Tc_12;\n",
- "\n",
- "\t\t\t#At reduced temperature%Tr_12%\n",
- "B_0 = 0.083 - (0.422/(Tr_12)**(1.6))\n",
- "B_1 = 0.139 - (0.172/(Tr_12)**(4.2))\n",
- "B_12 = ((B_0 + (w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For the mixture\n",
- "B = y1**(2)*B_11+2*y1*y2*B_12 + y2**(2)*B_22;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#Now given virial equation is% Z=1+(B*P)/(R*T)\n",
- "Z = 1 + (B*P)/(R*T)\n",
- "\t\t\t#Also Z = (P*V)/(R*T).Therefore%\n",
- "V_real = (Z*R*T)/P;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t# This molar volume remains the same as the volume and number of moles remains fixed.\n",
- "\t\t\t# Sice Z is a function of presure and temperature%we shall assume a temperature%calculate Z and again calculate temperature%till convergence is obtained.\n",
- "\t\t\t# We will use the concept of iteration to compute the convergent value of temperature\n",
- "\t\t\t# Let us start with the temperature at ideal conditions i.e T = 560 K%\n",
- "\n",
- "T_prime = 560.;\t\t\t#[K]\n",
- "fault = 10.;\n",
- "\n",
- "while(fault > 1):\n",
- " T_prime_r1 = T_prime/Tc_1;\n",
- " B_prime1_0 = 7.7674*10**(-3)\n",
- " B_prime1_1 = 0.13714;\n",
- " B_prime_11 = ((B_prime1_0 + (w_1*B_prime1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- " \t\t\t#Similarly for component 2%\n",
- " T_prime_r2 = T_prime/Tc_2;\n",
- " B_prime2_0 = -0.1343;\n",
- " B_prime2_1 = 0.10887;\n",
- " B_prime_22 = ((B_prime2_0 + (w_2*B_prime2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- " \t\t\t#For cross coefficient (assuming k12=0)\n",
- " \t\t\t#Tc_12 % w_12 % Zc_12 % Vc_12 and Pc_12 have already been calculated above%now\n",
- " T_prime_r12 = T_prime/Tc_12;\t\t\t#\n",
- " \t\t\t#At reduced temperature%T_prime_r12%\n",
- " B_prime_0 = 0.083 - (0.422/(T_prime_r12)**(1.6))\n",
- " B_prime_1 = 0.139 - (0.172/(T_prime_r12)**(4.2))\n",
- " B_prime_12 = ((B_prime_0+(w_12*B_prime_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "\n",
- " \t\t\t#For the mixture\n",
- " B_prime = y1**(2)*B_prime_11 + 2*y1*y2*B_prime_12 + y2**(2)*B_prime_22;\t\t\t#[m**(3)/mol]\n",
- " Z_prime = 1 + (B_prime*P_max)/(R*T_prime)\n",
- " T_new = (P_max*V_real)/(Z_prime*R)\n",
- " fault = abs(T_prime - T_new)\n",
- " T_prime = T_new;\n",
- "\n",
- "print \" (2).The maximum temperature assuming the gas to follow virial equation of state is %f K\"%T_new\n",
- "\n",
- "# Note : Answers varies because of rounding error. Please check it manually."
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (1).The maximum temperature assuming ideal behaviour is 560.000000 K\n",
- " (2).The maximum temperature assuming the gas to follow virial equation of state is 440.112497 K\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- " Example - 2.12 Page number - 64"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "V_vessel = 0.1;\t\t\t#[m**(3)]\t\t\t# Volume of vessel\n",
- "T = 25 + 273.15;\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "m = 25*1000;\t\t\t#[g]\t\t\t# Mass of ethylene\n",
- "Tc = 282.3;\t\t\t#[K] - Critical temperature\n",
- "Pc = 50.40;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5)\t\t\t#[N/m**(2)]\n",
- "Zc = 0.281;\t\t\t# Critical compressibility factor\n",
- "Vc = 131;\t\t\t#[cm**(3)/mol] - Critical volume\n",
- "Vc = Vc*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "w = 0.087;\t\t\t# Acentric factor\n",
- "M = 28.054;\t\t\t# Molecular weight of ethylene\n",
- "\n",
- "# Calculations\n",
- "n = m/M;\t\t\t#[mole] - No. of moles of ethylene\n",
- "V = V_vessel/n;\t\t#[m**(3)/mol] - Molar volume\n",
- "\n",
- "\t\t\t#Under Redlich Kwong equation of state% we have\n",
- "a = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "P = ((R*T)/(V-b))-(a/(T**(1./2)*V*(V+b)))\t\t\t#[N/m**(2)]\n",
- "\n",
- "# Results\n",
- "print \" The required pressure using Redlich Kwong equation of state is %e N/m**(2)\"%P\n",
- "\n",
- "\t\t\t#For ideal gas equation of state%\n",
- "P_ideal = (R*T)/V;\t\t\t#[N/m**(2)]\n",
- "print \" For ideal gas equation of state,the required pressure is %e N/m**(2)\"%P_ideal\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The required pressure using Redlich Kwong equation of state is 7.934745e+06 N/m**(2)\n",
- " For ideal gas equation of state,the required pressure is 2.208971e+07 N/m**(2)\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- " Example - 2.13 Page number - 65"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "V_vessel = 360*10**(-3)\t\t\t#[m**(3)] - volume of vessel\n",
- "T = 62+273.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "m = 70.*1000;\t\t\t#[g]/ - Mass of carbon dioxide\n",
- "\n",
- "\t\t\t#For carbon dioxide\n",
- "Tc = 304.2;\t\t\t#[K] - Cricitical temperature\n",
- "Pc = 73.83;\t\t\t#[bar] - Cricitical pressure\n",
- "Pc = Pc*10**(5)\t\t\t# [N/m**(2)]\n",
- "Zc = 0.274;\t\t\t# Critical compressibility factor\n",
- "Vc = 94.0;\t\t\t#[cm**(3)/mol]\n",
- "Vc = Vc*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "w = 0.224;\t\t\t# Acentric factor\n",
- "M = 44.01;\t\t\t# Molecular weight of carbon dioxide\n",
- "\n",
- "# Calculations and Results\n",
- "n = m/M;\t\t\t#[mol] - No. of moles\n",
- "V = V_vessel/n;\t\t\t#[m**(3)/mol]\t\t\t#molar volume\n",
- "\n",
- "\t\t\t# (1)\n",
- "\t\t\t# Ideal gas behaviour\n",
- "P_1 = (R*T)/V;\t\t\t#[N/m**(2)]\n",
- "print \" (1).The required pressure using ideal equation of state is %e N/m**(2)\"%P_1\n",
- "\n",
- "\t\t\t# (2)\n",
- "\t\t\t# Virial equation of state% Z = 1 + (B*P)/(R*T)\n",
- "\t\t\t# (P*V)/(R*T) = 1 + (B*P)/(R*T)% and thus P = (R*T)/(V - B). Now\n",
- "Tr = T/Tc;\t\t\t#Reduced temperature\n",
- "\t\t\t# At reduced temperature Tr%\n",
- "B_0 = 0.083 - (0.422/(Tr)**(1.6))\n",
- "B_1 = 0.139 - (0.172/(Tr)**(4.2))\n",
- "B = ((B_0 + (w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- "P_2 = (R*T)/(V - B)\t\t\t#[N/m**(2)]\n",
- "print \" (2).The required pressure using given virial equation of state is %e N/m**(2)\"%P_2\n",
- "\n",
- "\t\t\t# (3)\n",
- "\t\t\t# Virial equation of state% Z = 1 + (B/V)\n",
- "\t\t\t# (P*V)/(R*T) = 1 + (B/V)\n",
- "P_3 = ((R*T)/V) + (B*R*T)/(V**(2))\t\t\t#[N/m**(2)]\n",
- "print \" (3).The required pressure using given virial equation of state is %e N/m**(2)\"%P_3\n",
- "\n",
- "\t\t\t# (4)\n",
- "\t\t\t# Van der Walls equation of state%P = ((R*T)/(V-b)) - a/(V**(2))\n",
- "a = (27*(R**(2))*(Tc**(2)))/(64*Pc)\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc)\t\t\t#[m**(3)/mol]\n",
- "P_4 = ((R*T)/(V-b)) - a/(V**(2))\t\t\t#[N/m**(2)]\n",
- "print \" (4).The required pressure using van der Walls equation of state is %e N/m**(2)\"%P_4\n",
- "\n",
- "\t\t\t#(5)\n",
- "\t\t\t# Redlich Kwong equation of state%\n",
- "a_1 = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b_1 = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "P_5 = ((R*T)/(V - b_1)) - (a_1/(T**(1./2)*V*(V + b_1)))\t\t\t#[N/m**(2)]\n",
- "print \" (5).The required pressure using Redlich Kwong equation of state is %e N/m**(2)\"%P_5\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (1).The required pressure using ideal equation of state is 1.231100e+07 N/m**(2)\n",
- " (2).The required pressure using given virial equation of state is 8.712394e+06 N/m**(2)\n",
- " (3).The required pressure using given virial equation of state is 7.226009e+06 N/m**(2)\n",
- " (4).The required pressure using van der Walls equation of state is 8.048790e+06 N/m**(2)\n",
- " (5).The required pressure using Redlich Kwong equation of state is 8.079803e+06 N/m**(2)\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- " Example - 2.14 Page number - 66"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 500+273.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "P = 325*1000;\t\t\t#[Pa] - Pressure\n",
- "Tc = 647.1;\t\t\t#[K] - Cricitical temperature\n",
- "Pc = 220.55;\t\t\t#[bar] - Cricitical pressure\n",
- "Pc = Pc*10**(5)\t\t\t#[N/m**(2)]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t# Van der Walls equation of state%\n",
- "a = (27*(R**(2))*(Tc**(2)))/(64*Pc)\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc)\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# The cubic form of van der Walls equation of state is given by%\n",
- "\t\t\t# V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P=0\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f(V):\n",
- " global b,R,T,P,a\n",
- " return V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P\n",
- "from scipy.optimize import fsolve\n",
- "V_1 = fsolve(f,1)\n",
- "V_2 = fsolve(f,10)\n",
- "V_3 = fsolve(f,100)\n",
- "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root%\n",
- "Z_1 = (P*V_1)/(R*T)\t\t\t#compressibility factor\n",
- "print \" (1).The compressibility factor of steam using van der Walls equation of state is %f\"%Z_1\n",
- "\n",
- "\t\t\t#(2)\n",
- "\n",
- "\t\t\t#Redlich Kwong equation of state%\n",
- "a_1 = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b_1 = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# The cubic form of Redlich Kwong equation of state is given by%\n",
- "\t\t\t# V**(3)-((R*T)/P)*V**(2)-((b_1**(2))+((b_1*R*T)/P)-(a/(T**(1/2)*P))*V-(a*b)/(T**(1/2)*P)=0\n",
- "\t\t\t#Solving the cubic equation\n",
- "def f1(V):\n",
- " return V**(3)-((R*T)/P)*V**(2)-((b_1**(2))+((b_1*R*T)/P)-(a_1/(T**(1./2)*P)))*V-(a_1*b_1)/(T**(1./2)*P)\n",
- " \n",
- "V_4=fsolve(f1,1)\n",
- "V_5=fsolve(f1,10)\n",
- "V_6=fsolve(f1,100)\n",
- "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root%\n",
- "\t\t\t# Thus compressibility factor is\n",
- "Z_2 = (P*V_4)/(R*T)\t\t\t#compressibility factor\n",
- "print \" (2).The compressibility factor of steam using Redlich Kwong equation of state is %f\"%Z_2\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (1).The compressibility factor of steam using van der Walls equation of state is 0.997181\n",
- " (2).The compressibility factor of steam using Redlich Kwong equation of state is 0.997028\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- " Example - 2.15 Page number - 67"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve\n",
- "\n",
- "\n",
- "# Variables\n",
- "T = 250+273.15;\t\t\t#[K]\n",
- "R = 8.314;\t\t\t#[J/mol*K]\n",
- "P = 39.76;\t\t\t#[bar] Vapour pressure of water at T\n",
- "P = P*10**(5)\t\t\t#[N/m**(2)]\n",
- "Tc = 647.1;\t\t\t#[K] - Cricitical temperature\n",
- "Pc = 220.55*10**(5)\t\t\t#[N/m**(2)] - Cricitical pressure\n",
- "w = 0.345;\t\t\t#Acentric factor\n",
- "M = 18.015;\t\t\t# Molecular weight of water\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# Using peng-Robinson equation of stste \n",
- "m = 0.37464 + 1.54226*w - 0.26992*w**(2)\n",
- "Tr = T/Tc;\n",
- "alpha = (1 + m*(1 - Tr**(1./2)))**(2)\n",
- "a = ((0.45724*(R*Tc)**(2))/Pc)*alpha;\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b = (0.07780*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# Cubuc form of Peng-Robinson equation of stste is given by\n",
- "\t\t\t# V**(3) + (b-(R*T)/P)*V**(2) - ((3*b**(2)) + ((2*R*T*b)/P) - (a/P))*V+b**(3) + ((R*T*(b**(2))/P) - ((a*b)/P) = 0;\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f(V):\n",
- " global b,R,T,P,a\n",
- " return V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2)))/P)-((a*b)/P)\n",
- "V_1 = fsolve(f,-1)\n",
- "V_2 = fsolve(f,0)\n",
- "V_3 = fsolve(f,1)\n",
- "\t\t\t#The largest root is for vapour phase%\n",
- "V_vap = V_3;\t\t\t#[m**(3)/mol] - Molar volume (saturated vapour)\n",
- "V_vap = V_vap*10**(6)/M;\t\t\t#[cm**(3)/g]\n",
- "\n",
- "print \" The moar volume of saturated water in the vapour phase (V_vap) is %f cm**(3)/g\"%V_vap\n",
- "\n",
- "\t\t\t#The smallest root is for liquid phase%\n",
- "V_liq = V_1;\t\t\t#[m**(3)/mol] - molar volume (saturated liquid)\n",
- "V_liq = V_liq*10**(6)/M;\t\t\t#[cm**(3)/g]\n",
- "print \" The moar volume of saturated water in the liquid phase (V_liq) is %f cm**(3)/g\"%V_liq\n",
- "\n",
- "\t\t\t#From steam table at 250 C% V_vap = 50.13 [cm**(3)/g] and V_liq = 1.251 [cm**(3)/g].\n",
- "print \" From steam table at 250 C, V_vap = 50.13 [cm**(3)/g] and V_liq = 1.251 [cm**(3)/g]\"\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The moar volume of saturated water in the vapour phase (V_vap) is 51.757097 cm**(3)/g\n",
- " The moar volume of saturated water in the liquid phase (V_liq) is 1.554560 cm**(3)/g\n",
- " From steam table at 250 C, V_vap = 50.13 [cm**(3)/g] and V_liq = 1.251 [cm**(3)/g]\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- " Example - 2.16 Page number - 68"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 500+273.15;\t\t\t#[K] - Temperature\n",
- "P = 15.;\t\t\t#[atm] - Pressure\n",
- "P = P*101325;\t\t\t#[N/m**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "Tc = 190.6;\t\t\t#[K] - Cricitical temperature\n",
- "Pc = 45.99*10**(5)\t\t\t#[N/m**(2)] - Cricitical pressure\n",
- "Vc = 98.6;\t\t\t#[cm**(3)/mol] - Cricitical molar volume\n",
- "Zc = 0.286;\t\t\t# Critical compressibility factor\n",
- "w = 0.012;\t\t\t# Acentric factor\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t#Virial equation of state%Z = 1 + (B*P)/(R*T)\n",
- "Tr_1 = T/Tc;\t\t\t#Reduced temperature\n",
- "B_0 = 0.083-(0.422/(Tr_1)**(1.6))\n",
- "B_1 = 0.139-(0.172/(Tr_1)**(4.2)) \t\t\t# We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\t\t\t#second virial coefficient\n",
- "Z = 1 + (B*P)/(R*T)\t\t\t#compressibility factor\n",
- "\t\t\t#(P*V)/(R*T)=1+(B*P)/(R*T)%and thus%\n",
- "V_1 = (Z*R*T)/P;\t\t\t#[m**(3)/mol]\n",
- "print \" (1).The molar volume of methane using given virial equation is %e m**(3)/mol\"%V_1\n",
- "\n",
- "\t\t\t#(2).\n",
- "\t\t\t#Virial equation of state%Z = 1 + (B/V)\n",
- "\t\t\t#Also%Z = (P*V)/(R*T). Substituting the value of Z%we get\n",
- "\t\t\t# V**(2) - ((R*T)/P)*V - ((B*R*T)/P) = 0.Solving the quadratic equation\n",
- "def f(V):\n",
- " global R,T,P,B\n",
- " return V**(2)-((R*T)/P)*V-((B*R*T)/P)\n",
- "V2_1=fsolve(f,0)\n",
- "V2_2=fsolve(f,1)\n",
- "\t\t\t# Out of two roots%we will consider only positive root\n",
- "print \" (2).The molar volume of methane using given virial equation is %e m**(3)/mol\"%V2_2\n",
- "\n",
- "\t\t\t# (3)\n",
- "\t\t\t# Van der Walls equation of state%\n",
- "\t\t\t# (P + (a/V**(2)))*(V - b) = R*T\n",
- "a_3 = (27*(R**(2))*(Tc**(2)))/(64*Pc)\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b_3 = (R*Tc)/(8*Pc)\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# The cubic form of van der Walls equation of state is given by%\n",
- "\t\t\t# V**(3) - (b + (R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f1(V):\n",
- " global b,R,T,P,a_3\n",
- " return V**(3)-(b_3+(R*T)/P)*V**(2)+(a_3/P)*V-(a_3*b_3)/P\n",
- "V3_1=fsolve(f1,1)\n",
- "V3_2=fsolve(f1,10)\n",
- "V3_3=fsolve(f1,100)\n",
- "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root.\n",
- "print \" (3).The molar volume of methane using van der Walls equation of state is %e m**(3)/mol\"%V3_1\n",
- "\n",
- "\t\t\t# (4)\n",
- "\t\t\t# Redlich Kwong equation of state\n",
- "a_4 = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b_4 = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# The cubic form of Redlich Kwong equation of state is given by%\n",
- "\t\t\t# V**(3) - ((R*T)/P)*V**(2) - ((b_1**(2)) + ((b_1*R*T)/P) - (a/(T**(1/2)*P))*V - (a*b)/(T**(1/2)*P) = 0\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f2(V):\n",
- " global R,T,P,b_4,a_4\n",
- " return V**(3)-((R*T)/P)*V**(2)-((b_4**(2))+((b_4*R*T)/P)-(a_4/(T**(1./2)*P)))*V-(a_4*b_4)/(T**(1./2)*P)\n",
- "V4_1=fsolve(f2,1)\n",
- "V4_2=fsolve(f2,10)\n",
- "V4_3=fsolve(f2,100)\n",
- "\t\t\t#The above equation has 1 real and 2 imaginary roots. We consider only real root.\n",
- "print \" (4).The molar volume of methane using Redlich Kwong equation of state is %e m**(3)/mol\"%V4_1\n",
- "\n",
- "\t\t\t# (5)\n",
- "\t\t\t# Using Peng-Robinson equation of state \n",
- "m = 0.37464 + 1.54226*w - 0.26992*w**(2)\n",
- "Tr_5 = T/Tc;\n",
- "alpha = (1 + m*(1 - Tr_5**(1./2)))**(2)\n",
- "a = ((0.45724*(R*Tc)**(2))/Pc)*alpha;\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b = (0.07780*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# Cubic form of Peng-Robinson equation of stste is given by\n",
- "\t\t\t# V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2))/P)-((a*b)/P)=0;\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f3(V):\n",
- " global b,R,T,P,a\n",
- " return V**(3)+(b-(R*T)/P)*V**(2)-((3*b**(2))+((2*R*T*b)/P)-(a/P))*V+b**(3)+((R*T*(b**(2)))/P)-((a*b)/P)\n",
- "V5_1=fsolve(f3,-1)\n",
- "V5_2=fsolve(f3,0)\n",
- "V5_3=fsolve(f3,1)\n",
- "\t\t\t#The largest root is for vapour phase%\n",
- "\t\t\t#The largest root is only considered as the systemis gas\n",
- "print \" (5).The molar volume of methane using Peng-Robinson equation of state is %e m**(3)/mol\"%V5_3\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (1).The molar volume of methane using given virial equation is 4.242974e-03 m**(3)/mol\n",
- " (2).The molar volume of methane using given virial equation is 4.242930e-03 m**(3)/mol\n",
- " (3).The molar volume of methane using van der Walls equation of state is 4.236938e-03 m**(3)/mol\n",
- " (4).The molar volume of methane using Redlich Kwong equation of state is 4.241402e-03 m**(3)/mol\n",
- " (5).The molar volume of methane using Peng-Robinson equation of state is 4.242341e-03 m**(3)/mol\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- " Example - 2.17 Page number - 70"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 310.93;\t\t\t#[K] - Temperature\n",
- "P = 2.76*10**(6)\t\t\t#[N/m**(2)] - Pressure\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "y1 = 0.8942;\t\t\t# Mole fraction of component 1 (methane)\n",
- "y2 = 1-y1;\t\t\t# Mole fraction of component 2 (n-butane)\n",
- "\n",
- "#For component 1 (methane)\n",
- "Tc_1 = 190.58;\t\t\t#[K] - Cricitical temperature\n",
- "Pc_1 = 46.05;\t\t\t#[bar] - Cricitical pressure\n",
- "Pc_1 = Pc_1*10**(5)\t\t\t#[N/m**(2)]\n",
- "Zc_1 = 0.288;\t\t\t# Critical compressibility factor\n",
- "Vc_1 = 99.1;\t\t\t#[cm**(3)/mol]\n",
- "Vc_1 = Vc_1*10**(-6)\t\t\t#[m**(3)/mol]\n",
- "w_1 = 0.011;\t\t\t# Acentric factor\n",
- "\n",
- "\t\t\t#For component 2 (n-butane)\n",
- "Tc_2 = 425.18;\t\t\t#[K] - Cricitical temperature\n",
- "Pc_2 = 37.97;\t\t\t#[bar] - Cricitical pressure\n",
- "Pc_2 = Pc_2*10**(5)\t\t\t# [N/m**(2)]\n",
- "Zc_2 = 0.274;\t\t\t# Critical compressibility factor\n",
- "Vc_2 = 255.1;\t\t\t# [cm**(3)/mol]\n",
- "Vc_2 = Vc_2*10**(-6)\t\t\t# [m**(3)/mol]\n",
- "w_2 = 0.193;\t\t\t# Acentric factor\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (1)\n",
- "\t\t\t# Virial equation of state% Z = 1 + (B*P)/(R*T)\n",
- "\t\t\t# For component 1 (methane)\n",
- "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n",
- "\t\t\t# At reduced temperature\n",
- "B1_0 = 0.083 - (0.422/(Tr_1)**(1.6))\n",
- "B1_1 = 0.139 - (0.172/(Tr_1)**(4.2))\n",
- "\t\t\t# We know%(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#Similarly for component 2\n",
- "Tr_2 = T/Tc_2;\t\t\t#Reduced temperature\n",
- "\t\t\t#At reduced temperature Tr_2%\n",
- "B2_0 = 0.083 - (0.422/(Tr_2)**(1.6))\n",
- "B2_1 = 0.139 - (0.172/(Tr_2)**(4.2))\n",
- "B_22 = ((B2_0 + (w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For cross coeffcient\n",
- "Tc_12 = (Tc_1*Tc_2)**(1./2)\t\t\t#[K]\n",
- "w_12 = (w_1 + w_2)/2;\n",
- "Zc_12 = (Zc_1 + Zc_2)/2;\n",
- "Vc_12 = (((Vc_1)**(1./3)+(Vc_2)**(1./3))/2)**(3)\t\t\t#[m**(3)/mol]\n",
- "Pc_12 =(Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "\n",
- "\t\t\t#Now we have%(B_12*Pc_12)/(R*Tc_12) = B_0+(w_12*B_1)\n",
- "\t\t\t#where B_0 and B_1 are to be evaluated at Tr_12\n",
- "Tr_12 = T/Tc_12;\n",
- "\t\t\t#At reduced temperature Tr_12\n",
- "B_0 = 0.083 - (0.422/(Tr_12)**(1.6))\n",
- "B_1 = 0.139 - (0.172/(Tr_12)**(4.2))\n",
- "B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For the mixture\n",
- "B = y1**(2)*B_11+2*y1*y2*B_12+y2**(2)*B_22;\t\t\t#[m**(3)/mol]\n",
- "Z_1 = 1+(B*P)/(R*T)\t\t\t#compressibility factor\n",
- "print \" (1).The compressibility factor of mixture using Virial equation of state is %f\"%Z_1\n",
- "\n",
- "\t\t\t# (2)\n",
- "\t\t\t# Pseudo reduced method.\n",
- "T_pc = (y1*Tc_1)+(y2*Tc_2)\t\t\t#[K] - Cricitical temperature\n",
- "P_pc = (y1*Pc_1)+(y2*Pc_2)\t\t\t#[N/m**(2)] - Cricitical pressure\n",
- "w = (y1*w_1)+(y2*w_2)\t\t\t# Acentric factor\n",
- "T_pr = T/T_pc;\t\t\t# Reduced temperature\n",
- "P_pr = P/P_pc;\t\t\t# Reduced pressure\n",
- "\t\t\t#At this value of Tpr%\n",
- "B0 = 0.083 - (0.422/(T_pr)**(1.6))\n",
- "B1 = 0.139 - (0.172/(T_pr)**(4.2))\n",
- "Z0 = 1 + B0*(P_pr/T_pr)\n",
- "Z1 = B1*(P_pr/T_pr)\n",
- "Z = Z0 + w*Z1;\n",
- "print \" (2).The compressibility factor of mixture using pseudo reduced method is %f\"%Z\n",
- "\n",
- "\t\t\t# (3)\n",
- "\t\t\t# Redlich Kwong equation of state is given by\n",
- "\t\t\t# P = ((R*T)/(V-b)) - (a/(T**(1/2)*V*(V+b)))\n",
- "\t\t\t# For methane%component 1\n",
- "a_1 = (0.42748*(R**(2))*(Tc_1**(2.5)))/Pc_1;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b_1 = (0.08664*R*Tc_1)/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t#For n-butane%component 2\n",
- "a_2 = (0.42748*(R**(2))*(Tc_2**(2.5)))/Pc_2;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b_2 = (0.08664*R*Tc_2)/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t#For the mixture\n",
- "a_12 = (a_1*a_2)**(1./2)\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "a = y1**(2)*a_1 + 2*y1*y2*a_12 + y2**(2)*a_2;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b = (y1*b_1) + (y2*b_2)\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# The cubic form of Redlich Kwong equation of state is given by%\n",
- "\t\t\t# V**(3) - ((R*T)/P)*V**(2) - ((b_1**(2)) + ((b_1*R*T)/P) - (a/(T**(1/2)*P))*V - (a*b)/(T**(1/2)*P) = 0\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f(V):\n",
- " global R,T,P,b,a\n",
- " return V**(3)-((R*T)/P)*V**(2)-((b**(2))+((b*R*T)/P)-(a/(T**(1./2)*P)))*V-(a*b)/(T**(1./2)*P)\n",
- "V_1=fsolve(f,1)\n",
- "V_2=fsolve(f,10)\n",
- "V_3=fsolve(f,100)\n",
- "\t\t\t# Thus compressibility factor is\n",
- "Z_3 = (P*V_1)/(R*T)\t\t\t#compressibility factor\n",
- "print \" (3).The compressibility factor of mixture using Redlich Kwong equation of state is %f\"%Z_3\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (1).The compressibility factor of mixture using Virial equation of state is 0.926842\n",
- " (2).The compressibility factor of mixture using pseudo reduced method is 0.937191\n",
- " (3).The compressibility factor of mixture using Redlich Kwong equation of state is 0.927540\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch3_2.ipynb b/Chemical_Engineering_Thermodynamics/ch3_2.ipynb
deleted file mode 100755
index 1dbe2b34..00000000
--- a/Chemical_Engineering_Thermodynamics/ch3_2.ipynb
+++ /dev/null
@@ -1,1545 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:8255c3a74c7b52da7fb922c8e6e009ed3e07e5e50a88f1302c38a2c832cbdc1f"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 3 : The First Law and Its Applications"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.1 Page number - 80 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "\n",
- "# Variables\n",
- "V_vessel = 4.*10**(-3);\t\t\t#[m**(-3)] - Volume of vessel\n",
- "T = 200+273.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal fas constant\n",
- "P = 1.5*10**(6);\t\t\t#[Pa] - Pressure\n",
- "Q = 40.*1000;\t\t\t#[J] - Heat input\n",
- "\t\t\t# From steam table at 200 C,Psat=1.55549 MPa,therefore the steam is superheated.\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (1)\n",
- "\t\t\t# Using steam table,at 1.5 MPa and 200 C,\n",
- "V_1 = 0.1325;\t\t\t#[m**(3)/mol] - Specific volume\n",
- "U_1 = 2598.1;\t\t\t#[kJ/kg] - Specific internal energy\n",
- "\t\t\t# From first law under constant pressure,\n",
- "\t\t\t# Q - m*P*(V2 - V1) = m*(U2 - U1)\n",
- "m = V_vessel/V_1;\t\t\t#[kg] - Mass of system\n",
- "\t\t\t# Putting the values,the above equation becomes\n",
- "\t\t\t# 45283*(V2 - 0.1325) + 30.1887*(U2 - 2598.1) = 40000\n",
- "\t\t\t# From steam table at 700 C LHS is 33917.0 and at 800 C,it is 40925.3.\n",
- "\t\t\t# Therefore the final temperature lies between 700 and 800 C\n",
- "print \" 1.From steam table the final temperature lies between 700 and 800 C\";\n",
- "\n",
- "\t\t\t# Alternate method\n",
- "\t\t\t# Here we use first law at constant pressure,\n",
- "\t\t\t# Q = m*(H_2 - H_1)\n",
- "H_1 = 2796.8;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Substituting the values,\n",
- "\t\t\t# 40 = 0.0301887*(H_2 - 2796.8)\n",
- "H_2 = (40/0.0301887) + 2796.9;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Threfore,final enthalpy is (H2) 4121.8 [kJ/kg] and pressure is 1.5 [MPa].\n",
- "\t\t\t# From steam table at 1.5 [MPa]and 700 C,enthalpy is 3920.3 [kj/kg] and at 1.5 [MPa]and 800 C,enthalpy is 4152.6 [kj/kg]\n",
- "print \"\\tAlternate method\";\n",
- "print \"\\tBy linear interpolation we get the temperature at which enthlpy is 4121.8 kJ/kg to be 786.74 C\";\n",
- "\n",
- "\t\t\t# (2)\n",
- "\t\t\t# Assuming ideal behaviour.\n",
- "n = (P*V_vessel)/(R*T);\t\t\t#[mol] - No of moles\n",
- "M = 18.015;\t\t\t# Molecular weight of water\n",
- "m_2 = n*M;\t\t\t#[g] - mass of moles\n",
- "Cp_1 = 7.7 + 0.04594*10**(-2)*T + 0.2521*10**(-5)*T**(2) - 0.8587*10**(-9)*T**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant presure\n",
- "R0 = 1.987;\t\t\t#[cal/mol*K] - universal gas constant\n",
- "Cv_1 = Cp_1 - R0;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n",
- "Cv_1 = Cv_1*4.184/M;\t\t\t#[J/g*K]\n",
- "T1 = T;\n",
- "\t\t\t# From 1st law energy balance for constant pressure, we have Q-W= m*(delta_U)\n",
- "\t\t\t# Q = P*(V2 - V1)*m = m*Cv*(T2 - T1)\n",
- "\t\t\t# Q = P*((T2/T1)-1)*V1*m = m*Cv*(T2-T1)\n",
- "\t\t\t# But, (V1*Cv)=initial total volume of system = V_vessel\n",
- "\t\t\t# Q-P((T2/T1)-1)*V_vessel = m_2*Cv_0*(T2-T1);\n",
- "def f(T2): \n",
- "\t return Q-P*((T2/T1)-1)*V_vessel-m_2*Cv_1*(T2-T1)\n",
- "T2_1 = fsolve(f,1)\n",
- "\t\t\t#The heat capacity should be evaluted at mean temperature\n",
- "T_mean = (T1 + T2_1)/2;\n",
- "Cp_2 = 7.7 + 0.04594*10**(-2)*T_mean+0.2521*10**(-5)*T_mean**(2) - 0.8587*10**(-9)*T_mean**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant presure\n",
- "Cv_2 = Cp_2-R0;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n",
- "Cv_2 = Cv_2*4.184/M;\t\t\t#[J/g*K]\n",
- "\t\t\t#Now again solving the equation Q=P*((T2/T1)-1)*V1*m = m*Cv*(T2-T1),for Cv=Cv_2\n",
- "def f1(T2): \n",
- "\t return Q-P*((T2/T1)-1)*V_vessel-m_2*Cv_2*(T2-T1)\n",
- "T2_2 = fsolve(f1,1)\n",
- "print \" 2).The temperature assuming ideal behaviour is %f K\"%(T2_2);\n",
- "\n",
- "\t\t\t# Alternate method\n",
- "\t\t\t# From 1st law at constant pressure, we have Q = m*Cp(T2-T1)\n",
- "T2_3 = Q/(m_2*(Cp_1*4.184/M))+T1;\n",
- "\t\t\t#We can calculate the mean temperature as done above\n",
- "T_mean1 = (T1 + T2_3)/2;\t\t\t#[J/g*K]\n",
- "\t\t\t#The heat capacity should be evaluted at mean temperature\n",
- "Cp_3 = 7.7 + 0.04594*10**(-2)*T_mean1 + 0.2521*10**(-5)*T_mean1**(2)-0.8587*10**(-9)*T_mean1**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant presure\n",
- "Cp_3 = Cp_3*4.184/M;\t\t\t#[J/g*K]\n",
- "\t\t\t# Again solving the equation Q = m*Cp(T2-T1), for Cp=Cp_3\n",
- "T2_4 = Q/(m_2*Cp_3) + T1;\n",
- "print \"\\tAlternate method\";\n",
- "print \"\\tThe temperature assuming ideal behaviour alternate method) is %f K\"%(T2_4);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1.From steam table the final temperature lies between 700 and 800 C\n",
- "\tAlternate method\n",
- "\tBy linear interpolation we get the temperature at which enthlpy is 4121.8 kJ/kg to be 786.74 C\n",
- " 2).The temperature assuming ideal behaviour is 1141.732355 K\n",
- "\tAlternate method\n",
- "\tThe temperature assuming ideal behaviour alternate method) is 1141.738180 K\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stderr",
- "text": [
- "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
- " improvement from the last ten iterations.\n",
- " warnings.warn(msg, RuntimeWarning)\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.2 Page number - 83"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "V_tank = 1;\t\t\t#[m**(3)] - Volume of the tank\n",
- "V_liq = 0.05;\t\t\t#[m**(3)] - Volume of saturated water\n",
- "V_vap = 0.95;\t\t\t#[m**(3)] - Volume of saturated vapour\n",
- "P = 1;\t\t\t#[bar] - Pressure\n",
- "V_liq_sat = 0.001043;\t\t\t#[m**(3)/kg] - Specific volume of saturated water\n",
- "V_vap_sat = 1.6940;\t\t\t#[m**(3)/kg] - Specific volume of saturated vapour\n",
- "U_liq_sat = 417.4;\t\t\t#[kJ/kg] - Saturated liquid internal energy\n",
- "U_vap_sat = 2506.1;\t\t\t#[kJ/kg] - Saturated vapour internal energy\n",
- "\n",
- "# Calculations\n",
- "m = (V_liq/V_liq_sat) + (V_vap/V_vap_sat);\t\t\t#[kg] - Total mass of water\n",
- "U_1 = (V_liq/V_liq_sat)*U_liq_sat + (V_vap/V_vap_sat)*U_vap_sat;\t\t\t#[kJ] - Total internal energy\n",
- "\n",
- "\t\t\t# At final state,which is saturated vapour\n",
- "V = V_tank/m;\t\t\t#[m**(3)/kg] - Molar volume\n",
- "\t\t\t# From saturated steam table at 8 MPa,as reported in the book V_vap = 0.02352[m**(3)/kg] and U_vap = 2569.8[kJ/kg]\n",
- "\t\t\t# At 9 MPa, Vv = 0.02048[m**(3)/kg] and Uv = 2557.8[kJ/kg]\n",
- "\t\t\t# Therefore final state pressure of the system (from interpolation) is 8.954 [MPa] and internal energy of saturated vapour is 2558.35 [kJ/kg]\n",
- "U_2 = m*2558.35;\t\t\t#[kJ] - Final total internal energy\n",
- "del_Ut = U_2 - U_1;\t\t\t#[kJ] \n",
- "\t\t\t#we have, del_U = Q - W\n",
- "\t\t\t#Here work done is zero because volume is rigid.\n",
- "Q = del_Ut;\t\t\t#[kJ]\n",
- "Q = del_Ut*10**(-3);\t\t\t#[MJ]\n",
- "\n",
- "# Results\n",
- "print \" The amount of heat to be added is %f MJ\"%( Q);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The amount of heat to be added is 102.663530 MJ\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.3 Page number - 83"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "M_vap_sat = 0.22;\t\t\t#[kg] - mass of saturated vapour\n",
- "M_liq_sat = 1.78;\t\t\t#[kg] - mass of saturated liquid\n",
- "P = 700;\t\t\t#[kPa] - Pressure\n",
- "\n",
- "#At P=700 kPa,the systen is saturated,from steam table as reported in the book\n",
- "T_sat1 = 164.97;\t\t\t#[C]\n",
- "V_liq_1 = 0.001108;\t\t\t#[m**(3)/kg] \n",
- "V_vap_1 = 0.2729;\t\t\t#[m**(3)/kg]\n",
- "\n",
- "# Calculations and Results\n",
- "Vt_1 = V_liq_1*M_liq_sat + V_vap_1*M_vap_sat;\t\t\t#[m**(3)] - total volume\n",
- "\n",
- "\t\t\t#At final state,P = 8 MPa\n",
- "T_sat2 = 295.06;\t\t\t#[C]\n",
- "V_liq_2 = 0.001384;\t\t\t#[m**(3)/kg] \n",
- "V_vap_2=0.02352;\t\t\t#[m**(3)/kg]\n",
- "Vt_2 = Vt_1;\t\t\t# Since the volume is rigid.\n",
- "\t\t\t# Since the volume of 2 kg of vapour is 0.062 [m**(3)]\n",
- "V = Vt_2/2;\t\t\t#[m**(3)/kg] - specific volume\n",
- "\n",
- "\t\t\t# (a)\n",
- "\t\t\t# From steam table at 8 [MPa]and 350 [C],V=0.02995[m**(3)/kg]; \n",
- "V_1 = 0.02995;\t\t\t#[m**(3)/kg]\n",
- "\t\t\t# And at 8 [MPa]and 400 [C],\n",
- "V_2 = 0.03432;\t\t\t#[m**(3)/kg]\n",
- "\t\t\t# By interpolation,\n",
- "T = ((V-V_1)/(V_2 - V_1))*(400-350)+350;\n",
- "print \" a).The final temperature is %f c\"%(T);\n",
- "\n",
- "\t\t\t# (b)\n",
- "\t\t\t# From steam table \n",
- "U_1 = 2747.7;\t\t\t#[kJ/kg]\n",
- "H_1 = 2987.3;\t\t\t#[kJ/kg]\n",
- "\t\t\t# And at 8 [MPa]and 400 C,\n",
- "U_2 = 2863.8;\t\t\t#[kJ/kg]\n",
- "H_2 = 3138.3;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Therefore at T = 362.01 C\n",
- "U = U_1+((U_2 - U_1)/(400 - 350))*(T - 350);\n",
- "print \" b).The internal energy is %f kJ/kg\"%(U);\n",
- "\n",
- "\t\t\t#(c)\n",
- "H = H_1+((H_2 - H_1)/(400 - 350))*(T - 350);\n",
- "print \" b).The enthalpy is %f kJ/kg\"%(H);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The final temperature is 362.072311 c\n",
- " b).The internal energy is 2775.731907 kJ/kg\n",
- " b).The enthalpy is 3023.758380 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.4 Page number - 85"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\n",
- "# Variables\n",
- "T = 300;\t\t\t#[K] - Temperature\n",
- "P1 = 1;\t\t\t#[bar] - Initial pressure\n",
- "P1 = P1*10**(5);\t\t\t#[N/m**(2)]\n",
- "P2 = 8;\t\t\t#[bar] - Final pressure\n",
- "P2 = P2*10**(5);\t\t\t#[N/m**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "Tc = 126.2;\t\t\t#[K] - Critical temperature\n",
- "Pc = 34;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[N/m**(2)]\n",
- "w = 0.038;\t\t\t# Acentric factor\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# w = integral(Pdv)\n",
- "\t\t\t# Z = 1 + (B/V)\n",
- "\t\t\t# (P*V)/(R*T) = 1 + (B/V)\n",
- "\t\t\t# P = (R*T)/V + (B*R*T)/V**(2)\n",
- "\n",
- "def f29(V): \n",
- "\t return (R*T/V) + (B*R*T)/V**(2)\n",
- "\n",
- "\t\t\t# w = quad(f29,V1,V2)[0]\n",
- "\n",
- "\t\t\t# Under isothermal conditions,\n",
- "\t\t\t# w = R*T*math.log(V2/V1) - B*R*T*((1/V2) - (1/V1));\n",
- "\t\t\t# The second virial coefficient at state 1 is same as at state 2,as the temperature is the same i.e, T=300 [K]\n",
- "Tr = T/Tc;\n",
- "B_0 = 0.083 - (0.422/(Tr)**(1.6));\n",
- "B_1 = 0.139 - (0.172/(Tr)**(4.2));\n",
- "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t# Now we have to calculate molar volume i.e V1 and V2 at given conditions\n",
- "\t\t\t# At state 1,\n",
- "def f(V): \n",
- "\t return V**(2)-(R*T/P1)*V-(B*R*T)/P1\n",
- "V_1 = fsolve(f,-1)\n",
- "V_2 = fsolve(f,1)\n",
- "\t\t\t# We will take root near to (R*T)/P, i.e V_2\n",
- "V1 = V_2;\n",
- "\n",
- "\t\t\t# At state 2,\n",
- "def f1(V): \n",
- "\t return V**(2)-(R*T/P2)*V-(B*R*T)/P2\n",
- "V_3=fsolve(f1,-1)\n",
- "V_4=fsolve(f1,1)\n",
- "V2 = V_4;\n",
- "\t\t\t# The work done is thus,\n",
- "w = R*T*math.log(V2/V1) - B*R*T*((1/V2) - (1/V1));\t\t\t#[J]\n",
- "w = w*10**(-3);\t\t\t#[kJ]\n",
- "\n",
- "print \" The work done is %f kJ/mol\"%(w);\n",
- "print \" Negative sign indicates that work is done on the gas\";\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The work done is -5.186547 kJ/mol\n",
- " Negative sign indicates that work is done on the gas\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.5 Page number - 86"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "\n",
- "T = 300;\t\t\t#[K] - Temperature\n",
- "P1 = 1;\t\t\t#[bar] - Initial pressure\n",
- "P1 = P1*10**(5);\t\t\t#[N/m**(2)]\n",
- "P2 = 8;\t\t\t#[bar] - Final pressure\n",
- "P2 = P2*10**(5);\t\t\t#[N/m**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "y1 = 0.21;\t\t\t# Mole fraction of component 1 (oxygen)\n",
- "y2 = 0.79;\t\t\t# Mole fraction of component 1 (nitroen)\n",
- "\n",
- "# For component 1 (Oxygen)\n",
- "Tc_1 = 154.6;\t\t\t#[K]\n",
- "Pc_1 = 50.43*10**(5);\t\t\t#[N/m**(2)]\n",
- "Vc_1 = 73.4;\t\t\t#[cm**(3)/mol]\n",
- "Zc_1 = 0.288;\n",
- "w_1 = 0.022;\n",
- "\n",
- "\t\t\t#For component 2 (Nitrogen)\n",
- "Tc_2 = 126.2;\t\t\t#[K]\n",
- "Pc_2 = 34*10**(5);\t\t\t#[N/m**(2)]\n",
- "Vc_2 = 89.2;\t\t\t#[cm**(3)/mol]\n",
- "Zc_2 = 0.289;\n",
- "w_2 = 0.038;\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#For component 1\n",
- "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n",
- "\t\t\t#At reduced temperature\n",
- "B1_0 = 0.083 - (0.422/(Tr_1)**(1.6));\n",
- "B1_1 = 0.139 - (0.172/(Tr_1)**(4.2));\n",
- "\t\t\t# We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t# Similarly for component 2\n",
- "Tr_2 = T/Tc_2;\t\t\t#Reduced temperature\n",
- "\t\t\t# At reduced temperature Tr_2,\n",
- "B2_0 = 0.083 - (0.422/(Tr_2)**(1.6));\n",
- "B2_1 = 0.139 - (0.172/(Tr_2)**(4.2));\n",
- "B_22 = ((B2_0 + (w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t#For cross coeffcient\n",
- "Tc_12 = (Tc_1*Tc_2)**(1/2);\t\t\t#[K]\n",
- "w_12 = (w_1 + w_2)/2;\n",
- "Zc_12 = (Zc_1+Zc_2)/2;\n",
- "Vc_12 = (((Vc_1)**(1/3)+(Vc_2)**(1/3))/2)**(3);\t\t\t#[cm**(3)/mol]\n",
- "Vc_12 = Vc_12*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "\n",
- "\t\t\t# Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n",
- "\t\t\t# where B_0 and B_1 are to be evaluated at Tr_12\n",
- "Tr_12 = T/Tc_12;\n",
- "\t\t\t# At reduced temperature Tr_12\n",
- "B_0 = 0.083 - (0.422/(Tr_12)**(1.6));\n",
- "B_1 = 0.139 - (0.172/(Tr_12)**(4.2));\n",
- "B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t# For the mixture\n",
- "B = y1**(2)*B_11 + 2*y1*y2*B_12+y2**(2)*B_22;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# Now we have to calculate molar volume i.eV1 and V2 at given conditions\n",
- "\n",
- "\t\t\t# At state 1,\n",
- "def f(V): \n",
- "\t return V**(2)-(R*T/P1)*V-(B*R*T)/P1\n",
- "V_1=fsolve(f,-1)\n",
- "V_2=fsolve(f,1)\n",
- "\t\t\t# We will take root near to (R*T)/P, i.e V_2\n",
- "V1 = V_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t# At state 2,\n",
- "def f1(V): \n",
- "\t return V**(2)-(R*T/P2)*V-(B*R*T)/P2\n",
- "V_3=fsolve(f1,-1)\n",
- "V_4=fsolve(f1,1)\n",
- "V2 = V_4;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\t\t\t# Work done per mole of air is given by, w=integral(Pdv)\n",
- "\t\t\t# Z = 1 + (B/V)\n",
- "\t\t\t# (P*V)/(R*T) = 1 +( B/V)\n",
- "\t\t\t# P = (R*T)/V+(B*R*T)/V**(2)\n",
- "\n",
- "def f43(V): \n",
- "\t return (R*T/V)+(B*R*T)/V**(2)\n",
- "\n",
- "\t\t\t# w = quad(f43,V1,V2)[0]\n",
- "\n",
- "\t\t\t# Under isothermal conditions,\n",
- "w = R*T*math.log(V2/V1)-B*R*T*((1/V2)-(1/V1));\n",
- "w = w*10**(-3);\t\t\t#[kJ/mol]\n",
- "\n",
- "# Results\n",
- "print \" The work done is %f kJ/mol\"%(w);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The work done is -5.186545 kJ/mol\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.6 Page number - 88"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 125+273.15;\t\t\t#[K] - Temperature\n",
- "P1 = 1;\t\t\t#[bar] - Initial pressure\n",
- "P1 = P1*10**(5);\t\t\t#[N/m**(2)]\n",
- "P2 = 60;\t\t\t#[bar] - Final pressure\n",
- "P2 = P2*10**(5);\t\t\t#[N/m**(2)]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "Tc = 416.3;\t\t\t#[K] - Critical temperature\n",
- "Pc = 66.80*10**(5);\t\t\t#[N/m**(2)] - Critical pressure\n",
- "\n",
- "\t\t\t# (1)\n",
- "\t\t\t# Virial equation of state, Z = 1 + (B/V)+(C/V**(2))\n",
- "\t\t\t# (P*V)/(R*T) = 1 + (B/V)+(C/V**(2))\n",
- "\t\t\t# P = (R*T)/V+(B*R*T)/V**(2)+(C*R*T)/V**(3)\n",
- "\t\t\t# w = integral(PdV)=R*T*math.log(V2/V1)-(B*R*T)*(1/V2-1/V1)-(C*R*T/2)*(1/V2**(2)-1/V1**(2))\n",
- "\n",
- "B = -207.5;\t\t\t#[cm**(3)/mol] - Second virial coefficient\n",
- "B = -207.5*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "C = 18200;\t\t\t#[cm**(6)/mol**(2)] - Third virial coefficient\n",
- "C = 18200*10**(-12);\t\t\t#[m**(6)/mol**(2)]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# We need to calculate molar volume at state 1 and 2,\n",
- "\t\t\t# At state 1,P = P1,\n",
- "\t\t\t# V**(3)-(R*T/P)*V**(2)-(B*R*T/P)*V-(C*R*T/P)=0\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f1(V): \n",
- "\t return V**(3)-(R*T/P1)*V**(2)-(B*R*T/P1)*V-(C*R*T/P1)\n",
- "V_1=fsolve(f1,-1)\n",
- "V_2=fsolve(f1,0)\n",
- "V_3=fsolve(f1,10)\n",
- "\t\t\t# The cubic equation has only 1 real root,other two roots are imaginary.\n",
- "V1 = V_3;\n",
- "\n",
- "\t\t\t# Similarly at state 2,P=P2\n",
- "\t\t\t# V**(3) - (R*T/P)*V**(2) - (B*R*T/P)*V - (C*R*T/P) = 0\n",
- "\t\t\t# Solving the cubic equation\n",
- "def f2(V): \n",
- "\t return V**(3)-(R*T/P2)*V**(2)-(B*R*T/P2)*V-(C*R*T/P2)\n",
- "V_4=fsolve(f2,-1)\n",
- "V_5=fsolve(f2,0)\n",
- "V_6=fsolve(f2,1)\n",
- "V2 = V_6;\n",
- "\t\t\t# Finally work done is given by,\n",
- "w1 = R*T*math.log(V2/V1)-(B*R*T)*(1/V2-1/V1)-(C*R*T/2)*(1/V2**(2)-1/V1**(2));\t\t\t#[J/mol]\n",
- "w1 = w1*10**(-3);\t\t\t#[kJ/mol]\n",
- "print \" 1).The work done using given virial equation of state is %f kJ/mol\"%(w1);\n",
- "\n",
- "\t\t\t# (2)\n",
- "\t\t\t# Virial equation of state, Z = 1+(B*P)/(R*T)+((C-B**(2))/(R*T)**(2))*P**(2)\n",
- "\t\t\t# (P*V)/(R*T)= 1+(B*P)/(R*T)+((C-B**(2))/(R*T)**(2))*P**(2)\n",
- "\t\t\t# V = (R*T)/P+B+((C-B**(2))/(R*T))*P\n",
- "\t\t\t# Differentiating both sides by P and integrating we get,\n",
- "\t\t\t# w = integral(PdV)=-(R*T)*math.log(P2/P1)+((C-B**(2))/(2*R*T))*(P2**(2)-P1**(2))\n",
- "w2 = -(R*T)*math.log(P2/P1) + ((C-B**(2))/(2*R*T))*(P2**(2)-P1**(2));\t\t\t#[J/mol]\n",
- "w2 = w2*10**(-3);\t\t\t#[kJ/mol]\n",
- "print \" 2).The work done using given virial equation of state is %f kJ/mol\"%(w2);\n",
- "\n",
- "\t\t\t# (3)\n",
- "\t\t\t# Van der Walls equation of state is given by,\n",
- "a = (27*(R**(2))*(Tc**(2)))/(64*Pc);\t\t\t#[Pa*m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# P = ((R*T)/(V-b))-a/(V**(2));\t\t\t#[N/m**(2)]\n",
- "\t\t\t# w = integral(PdV)=R*T*math.log((V2-b)/(V1-a))+a*(1/V2-1/V1)\n",
- "\t\t\t# The cubic form of van der Walls equation of state is given by,\n",
- "\t\t\t# V**(3) - (b+(R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "\t\t\t# Solving the cubic equation for P=P1\n",
- "def f3(V): \n",
- "\t return V**(3)-(b+(R*T)/P1)*V**(2)+(a/P1)*V-(a*b)/P1\n",
- "V2_1=fsolve(f3,1)\n",
- "V2_2=fsolve(f3,10)\n",
- "V2_3=fsolve(f3,100)\n",
- "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V2_3).\n",
- "\n",
- "\t\t\t# Similarly at state 2,for P=P2,\n",
- "def f4(V): \n",
- "\t return V**(3)-(b+(R*T)/P2)*V**(2)+(a/P2)*V-(a*b)/P2\n",
- "V2_4=fsolve(f4,1)\n",
- "V2_5=fsolve(f4,10)\n",
- "V2_6=fsolve(f4,100)\n",
- "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V2_6).\n",
- "\t\t\t# Finally work done is given by\n",
- "w3 = R*T*math.log((V2_6-b)/(V2_3-b))+a*(1/V2_6-1/V2_3);\t\t\t#[J/mol]\n",
- "w3 = w3*10**(-3);\t\t\t#[kJ/mol]\n",
- "print \" 3).The work done using van der Walls equation of state is %f kJ/mol\"%(w3);\n",
- "\n",
- "\t\t\t# (4)\n",
- "\t\t\t# Redlich Kwong equation of state,\n",
- "a_1 = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n",
- "b_1 = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# P = ((R*T)/(V-b_1))-(a_1/(T**(1/2)*V*(V+b_1)));\t\t\t#[N/m**(2)]\n",
- "\t\t\t# Work done is given by\n",
- "\n",
- "def f4(V): \n",
- "\t return (V2-b)/(V1-b)-a/T**(1./2)*integrate(1/V*(V+b))\n",
- "\n",
- "\t\t\t# w = R*T*math.log((V2-b)/(V1-b))-a/T**(1/2)* quad(f4,V1,V2)[0]\n",
- "\n",
- "\t\t\t# Using the factorization 1/(V*(V+b))=(1/b)*((1/V)-(1/V+b)),we get\n",
- "\t\t\t# w = R*T*math.log((V2-b)/(V1-b))-(a/(b*T**(1/2)))*(math.log(V2/V1)-math.log((V2+b)/(V1+b))\n",
- "\t\t\t# Now we have calculate V1 and V2,\n",
- "\t\t\t# The cubic form of Redlich Kwong equation of state is given by,\n",
- "\t\t\t# V**(3) - ((R*T)/P)*V**(2) - ((b_1**(2)) + ((b_1*R*T)/P) - (a/(T**(1/2)*P))*V - (a*b)/(T**(1/2)*P) = 0\n",
- "\t\t\t# Solving the cubic equation at state 1,\n",
- "def f5(V): \n",
- "\t return V**(3)-((R*T)/P1)*V**(2)-((b_1**(2))+((b_1*R*T)/P1)-(a_1/(T**(1./2)*P1)))*V-(a_1*b_1)/(T**(1./2)*P1)\n",
- "V3_1=fsolve(f5,1)\n",
- "V3_2=fsolve(f5,10)\n",
- "V3_3=fsolve(f5,100)\n",
- "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V3_3).\n",
- "\n",
- "\t\t\t# Similarly at state 2,for P = P2,\n",
- "def f6(V): \n",
- "\t return V**(3)-((R*T)/P2)*V**(2)-((b_1**(2))+((b_1*R*T)/P2)-(a_1/(T**(1./2)*P2)))*V-(a_1*b_1)/(T**(1./2)*P2)\n",
- "V3_4=fsolve(f6,1)\n",
- "V3_5=fsolve(f6,10)\n",
- "V3_6=fsolve(f6,100)\n",
- "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V3_6).\n",
- "\t\t\t# Finally work done is given by\n",
- "w4 = R*T*math.log((V3_6-b_1)/(V3_3-b_1))-(a_1/(b_1*T**(1./2)))*(math.log(V3_6/V3_3)-math.log((V3_6+b_1)/(V3_3+b_1)));\t\t\t#[J/mol]\n",
- "w4 = w4*10**(-3);\t\t\t#[kJ/mol]\n",
- "print \" 3).The work done using Redlich Kwong equation of state is %f kJ/mol\"%(w4);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The work done using given virial equation of state is -13.848149 kJ/mol\n",
- " 2).The work done using given virial equation of state is -13.688301 kJ/mol\n",
- " 3).The work done using van der Walls equation of state is -14.802420 kJ/mol\n",
- " 3).The work done using Redlich Kwong equation of state is -14.704965 kJ/mol\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stderr",
- "text": [
- "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
- " improvement from the last five Jacobian evaluations.\n",
- " warnings.warn(msg, RuntimeWarning)\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.8 Page number - 93"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 20 + 273.15;\t\t\t#[K] - Temperature\n",
- "P_1 = 140.;\t\t\t#[kPa] - Initial pressure\n",
- "P_1 = P_1*10.**(3);\t\t\t#[Pa]\n",
- "P_2 = 560.;\t\t\t#[kPa] - Final pressure\n",
- "P_2 = P_2*10.**(3);\t\t\t#[Pa]\n",
- "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# Cp_0 = 1.648+4.124*10**(-2)*T - 1.53*10**(-5)*T**(2) + 1.74*10**(-9)*T**(3)\n",
- "\t\t\t# Using adiabatic compression, P*V**(Y)=constant. For ideal gases\n",
- "\t\t\t# P*(R*T/P)**(Y) = constant\n",
- "\t\t\t# P**(1-Y)*T**(Y) = constant or,P1**(1-Y)*T1**(Y)=P2**(1-Y)*T2**(Y)\n",
- "\t\t\t# Now,at state 1, i.e at T=20[C]\n",
- "Cp_1 = 1.648+4.124*10**(-2)*T-1.53*10**(-5)*T**(2)+1.74*10**(-9)*T**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant pressure\n",
- "Cv_1 = Cp_1 - R;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n",
- "Y1 = Cp_1/Cv_1;\t\t\t# Ratio of heat capacities\n",
- "\n",
- "\t\t\t# Now calculatung the temperature at state 2 (T2)\n",
- "\t\t\t# (T2/T1)=(P1/P2)**((1-Y1)/Y1)\n",
- "T_1 = T;\n",
- "T_2 = ((P_1/P_2)**((1-Y1)/Y1))*T_1;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# Now calculating the mean temperature\n",
- "T_mean = (T_1 + T_2)/2;\t\t\t#[K]\n",
- "\t\t\t# At mean temperature\n",
- "Cp_2 = 1.648+4.124*10**(-2)*T_mean - 1.53*10**(-5)*T_mean**(2) + 1.74*10**(-9)*T_mean**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant pressure\n",
- "Cv_2 = Cp_2 - R;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n",
- "Y2 = Cp_2/Cv_2;\n",
- "\n",
- "\t\t\t# Calculating exit temperature\n",
- "\t\t\t# Again using the realation,(T2/T1)=(P1/P2)**((1-Y1)/Y1)\n",
- "T_exit = ((P_1/P_2)**((1-Y2)/Y2))*T_1;\t\t\t#[K]\n",
- "\t\t\t# Since value of mean temperature has not changed much the molar heat capacity ratio can be assumed to be same.Therefore\n",
- "\t\t\t# w = -delta(U)=Cv_0*(T2-T1)\n",
- "w = Cv_2*(T_1 - T_exit);\t\t\t#[cal/mol]\n",
- "w = w*4.184;\t\t\t#[J/mol]\n",
- "\n",
- "# Results\n",
- "print \" The work done for adiabatic compression is %f J/mol\"%(w);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The work done for adiabatic compression is -3198.427072 J/mol\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.9 Page number - 93"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "m_ice = 1000;\t\t\t#[g] - Mass of ice\n",
- "m_water = 1000;\t\t\t#[g] - Mass of water\n",
- "T_ice = 273.15;\t\t\t#[K] - Temperature of ice\n",
- "T_water = 373.15;\t\t\t#[K] - Temperature of water\n",
- "L = 79.71;\t\t\t#[cal/g] - Latent heat of melting of ice.\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "Cp_1 = 1;\t\t\t#[cal/g-K] - Heat capacity at constant pressure\n",
- "\t\t\t# Let the final temperature be T\n",
- "\t\t\t# We assume that all of the ice melts.Energy taken up by ice is\n",
- "\t\t\t# E1 = L*m_ice + m_ice*Cp_1*(T - T_ice)\n",
- "\t\t\t# Energy given by hot water is,\n",
- "\t\t\t# E2 = m_water*Cp_1*(T_water - T)\n",
- "\t\t\t# No heat exchange with surrounding.Solving for T\n",
- "T_1 = (m_ice*Cp_1*T_ice + m_water*Cp_1*T_water - L*m_ice)/(m_ice*Cp_1 + m_water*Cp_1);\t\t\t#[K]\n",
- "T_1 = T_1 - 273.15;\t\t\t#[C]\n",
- "\n",
- "print \" 1).The final temperature taking Cp_water = 1 cal/g-K) is %f C\"%(T_1);\n",
- "\t\t\t#Since the final temperature is greater than 273.15 K,so our assumption that all of ice melts is correct\n",
- "\n",
- "\t\t\t# (2)\n",
- "\t\t\t# Cp_2 = 1.00874-0.7067*10**(-3)*T+15.93*10**(-6)*T**(2)-83.8*10**(-9)*T**(3);\n",
- "\n",
- "def f15(T): \n",
- "\t return Cp_2\n",
- "\n",
- "\t\t\t# From energy balance,we get L*m_ice + m_ice* quad(f15,0,T) + m_water*integrate(Cp_2)[0]\n",
- "\n",
- "\t\t\t# On putting the values and then simplifying we get\n",
- "\t\t\t# 2.01748*T - 0.0007067*T**(2) + 1.062*10**(-5)*T**(3) - 4.19*10**(-8)*T**(4) - 20.8455 = 0\n",
- "\t\t\t# Solving the above equation we get\n",
- "def f1(T): \n",
- "\t return 2.01748*T - 0.0007067*T**(2) + 1.062*10**(-5)*T**(3) - 4.19*10**(-8)*T**(4) - 20.8455\n",
- "T_0 = fsolve(f1,1)\n",
- "print \" 2).The final temperature using specific heat capacity equation is %f C\"%(T_0);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The final temperature taking Cp_water = 1 cal/g-K) is 10.145000 C\n",
- " 2).The final temperature using specific heat capacity equation is 10.364452 C\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.11 Page number - 97"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "n = 1.5;\t\t\t# - ratio of heat capacities\n",
- "T_1 = 500.;\t\t\t#[K] - Initial temperature\n",
- "T_2 = 1000.;\t\t\t#[K] - Final temperature\n",
- "P_1 = 1.;\t\t\t#[bar] - Initial pressure\n",
- "P_1 = P_1*10.**(5);\t\t\t#[Pa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The compression path is given by, P*V**(1.5) = constant\n",
- "\t\t\t# P*(R*T/P)**(1.5) = constant\n",
- "\t\t\t# P1**(-0.5)*T1**(1.5) = P2**(-0.5)*T2**(1.5)\n",
- "P_2 = P_1*(T_1/T_2)**(-3);\t\t\t#[Pa]\n",
- "P_2_final = P_2*10**(-5);\t\t\t#[bar] - Final pressure in bar\n",
- "print \" The final pressure is %f bar\"%(P_2_final);\n",
- "\n",
- "\t\t\t# From first law q - w = delta(U). \n",
- "\t\t\t# First w and delta(U) are calculated and thereafter heat exchange is determined.\n",
- "V_1 = R*T_1/P_1;\t\t\t#[m**(3)/mol] - Initial volume\n",
- "V_2 = R*T_2/P_2;\t\t\t#[m**(3)/mol] - Final volume\n",
- "w = ((P_1*V_1)/(n - 1))*(1 - (P_2/P_1)**(1 - 1/n));\t\t\t#[J/mol] - work done\n",
- "\n",
- "\t\t\t# Mean temperature is given by,\n",
- "T_mean = (T_1 + T_2)/2;\t\t\t#[K]\n",
- "\n",
- "\t\t\t#Now, heat capacity at T_mean is given by,\n",
- "Cp_0 = R*(3.3 + 0.63*10**(-3)*T_mean);\t\t\t#[J/mol*K]\n",
- "Cv_0 = Cp_0 - R;\t\t\t#[J/mol*K]\n",
- "\t\t\t#Therefore delta(U) is given by\n",
- "del_U = Cv_0*(T_2 - T_1);\t\t\t#[J/mol] - Change in internal energy\n",
- "q = w + del_U;\t\t\t#[J/mol] - heat change\n",
- "print \" The amount of heat supplied to the system is %f J/mol\"%(q);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The final pressure is 8.000000 bar\n",
- " The amount of heat supplied to the system is 3211.282500 J/mol\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.12 Page number - 99"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 150*10**(3);\t\t\t#[Pa] - Initial pressure\n",
- "V_1 = 0.001;\t\t\t#[m**(3)] - Initial volume\n",
- "P_2 = 1000*10**(3);\t\t\t#[Pa] - Final pressure\n",
- "V_2 = 0.003;\t\t\t#[m**(3)] - Final volume\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# At x = 0, Vt(total volume) = 0.001 m**(3), therefore x = (V_t - V_1)/A; where A is area of cross section and x is length\n",
- "\t\t\t# Force exerted b sprig is given by, F = Ps*A = k*x = k*(V_t - V_1)/A\n",
- "\t\t\t# Ps = (k/A**(2))*(V_t - V_1)\n",
- "\t\t\t# Total pressure = Initial pressre + Pressre due to spring\n",
- "\t\t\t# P = P_1 + (k/A**(2))*(V_t - V_1)\n",
- "\t\t\t# Let (k/A**(2)) = t (say)\n",
- "\t\t\t# At state 2, i.e at P2 and V_t = V_2.\n",
- "def f(t): \n",
- "\t return P_2-P_1 - t*(V_2-V_1)\n",
- "t = fsolve(f,1000)\n",
- "\t\t\t# Therefore,pressure is related to total volume as P = P_1-t*(V_t - V_1)\n",
- "\n",
- "\t\t\t# (a)\n",
- "\t\t\t#slope = (k/A**(2))\n",
- "print \" a).The slope of the line on P-Vt diagram is %e N/m**5)\"%(t);\n",
- "\n",
- "\t\t\t# (b)\n",
- "\t\t\t# Work done by the gas is given by w=integral(PdVt)\n",
- "\n",
- "def f30(V_t): \n",
- "\t return P_1+t*(V_t-V_1)\n",
- "\n",
- "w = quad(f30,V_1,V_2)[0]\n",
- "\n",
- "w = w*10**(-3);\t\t\t#[kJ]\n",
- "print \" b).The work done by gas is %f kJ\"%(w);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The slope of the line on P-Vt diagram is 4.250000e+08 N/m**5)\n",
- " b).The work done by gas is 1.150000 kJ\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.13 Page number - 99"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "V = 36;\t\t\t#[L] - Vol of gas on each side\n",
- "P_1 = 1;\t\t\t#[atm] - pressure on left side of the piston\n",
- "P_1 = P_1*101325;\t\t\t#[Pa]\n",
- "T = 273.15;\t\t\t#[K]\n",
- "P_2 = 3.375;\t\t\t#[atm] - Pressure on right side of the piston\n",
- "P_2 = P_2*101325;\t\t\t#[Pa]\n",
- "Y = 1.44;\t\t\t# Ratio of heat capacities\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constnt\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (a)\n",
- "\t\t\t# For total system, del(U_total) = Q. \n",
- "\t\t\t# Onto gas on right hand side no heat is supplied,as the piston is non conducting. Therefore,for gas on the right hand side, del(U) = -W.\n",
- "\t\t\t# As heat is slowly supplied to the left hand side,expansion on right hand side is slow and process is adiabatic.\n",
- "\t\t\t# For gas on right hand side, PV**(Y) = constant.\n",
- "\t\t\t# T_2/T_1 = (P_2/P_1)**((Y - 1)/Y)\n",
- "T_right = T*(P_2/P_1)**((Y - 1)/Y);\t\t\t#[K]\n",
- "\n",
- "Cv_0 = R/(Y-1);\t\t\t#[J/mol*K] - Heat capacity at constant volume.\n",
- "\t\t\t# Now work done on the gas on right hand side is given by\n",
- "\t\t\t# W = (P_1*V_1 - P_2*V_2)/(Y - 1) = R*(T_2 - T_1)/(Y - 1) = Cv_0*(T_1 - T_2)\n",
- "W_left = Cv_0*(T - T_right);\t\t\t#[J/mol]\n",
- "\t\t\t# Negative sign for the work done on LHS gas implies work is done on the gas\n",
- "\n",
- "\t\t\t# For right hand side of the gas\n",
- "\t\t\t# P*Vt = n*R*T\n",
- "n = P_1*(V*10**(-3))/(R*T);\t\t\t# number of moles\n",
- "W_right = (-W_left)*n;\t\t\t#[J] - We used negative sign for 'W_left' because it is negative in magnitude.\n",
- "W_right = W_right/1000;\t\t\t#[kJ]\n",
- "print \" a).Total work done on gas on the right hand side is %f kJ\"%(W_right);\n",
- "\n",
- "\t\t\t#(b)\n",
- "print \" b).The final temperature of the gas on right side is %f K\"%(T_right);\n",
- "\n",
- "\t\t\t# (c)\n",
- "\t\t\t# Pressure is same on both sides as piston is frictionless.\n",
- "\t\t\t# The number of moles on both sides are also same as they have same temperature,presure and volume.\n",
- "\t\t\t# We have (P_left*V_left)/T_left = (P_right*V_right)/T_right.\n",
- "\t\t\t# Since P_left = P_right, (V_left/T_left) = (V_right/T-right) and also P*V**(Y) = constant.\n",
- "V_right = V*(P_1/P_2)**(1/Y);\t\t\t#[L] - The total volume on right side \n",
- "\n",
- "\t\t\t# The total volume on right side can also be calculated using P2*V2 = n*R*T2.\n",
- "\t\t\t# Since total volume = 72 [L], therefore volume of left side is\n",
- "V_left = 2*V - V_right;\t\t\t#[L]\n",
- "T_left = T_right*(V_left/V_right);\n",
- "print \" c).Final temperature of the gas on the left side is %f K\"%(T_left);\n",
- "\n",
- "\t\t\t#(d)\n",
- "\t\t\t#The first law applied to the total system (left side and right side) gives.\n",
- "\t\t\t#Q - W = del(U_left) + del(U_right)\n",
- "\t\t\t#There is no net work done by the total system as the cylinder is closed at both ends.\n",
- "Q = n*Cv_0*(T_left-T) + n*Cv_0*(T_right-T);\t\t\t#[J]\n",
- "Q = Q/1000;\t\t\t#[kJ]\n",
- "print \" d).Amount of heat added to the gas on the left side is %f kJ\"%(Q);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).Total work done on gas on the right hand side is 3.731958 kJ\n",
- " b).The final temperature of the gas on right side is 396.112176 K\n",
- " c).Final temperature of the gas on the left side is 1447.650324 K\n",
- " d).Amount of heat added to the gas on the left side is 39.378580 kJ\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.14 Page number - 105"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_2 = 0.2;\t\t\t#[bar]\n",
- "P_2 = P_2*10**(5);\t\t\t#[Pa]\n",
- "int_dia_2 = 2.4*10**(-2);\t\t\t#[m] - internal diameter at state 2.\n",
- "Q = 5*10**(-3);\t\t\t#[cubic metre/s] - Flow rate at point 2.\n",
- "den = 1000;\t\t\t#[kg/cubic metre] - density\n",
- "delta_z = 1;\t\t\t#[m] - Difference in height\n",
- "g = 9.81;\t\t\t#[m/s**(2)] - Acceleration due to gravity\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (1)\n",
- "\t\t\t# Pressure at state 1 is atmospheric pressure and at state 2 is gauze pressure at state 2 + atmospheric pressure,thus\n",
- "\t\t\t# (delta(P)/den) = (P2-P1)/den = P2/den\n",
- "Vel_2 = Q/(3.14*(int_dia_2/2)**(2));\t\t\t#[m/s] - Velocity of water at state 2.\n",
- "\t\t\t# Velocity at state 1 i negligible as compared to velocity at state 2,because the diameter of reservoir is very large as compared to diameter of pipe at state 2\n",
- "\n",
- "\t\t\t# From bernaulli equation we get,\n",
- "\t\t\t# -w = (delta(P)/den) + delta(v**(2))/2 + g*delta_z\n",
- "w = -((P_2/den )+ (Vel_2**(2)/2) + (g*delta_z));\t\t\t#[J/kg]\n",
- "\t\t\t# w multiplied by m = (den*Q), will give the fluid power.\n",
- "m = den*Q;\t\t\t#[kg/s]\n",
- "W_net = m*w;\t\t\t#[Watt]\n",
- "print \" 1).The fluid power is %f Watt\"%(W_net);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# Total discharge head developed by the pump is given by\n",
- "\t\t\t# h = (delta(P)/den*g) + (Vel_2**(2)/2*g) + delta_z\n",
- "h = (P_2/(den*g)) + (Vel_2**(2)/(2*g)) + delta_z;\t\t\t#[m]\n",
- "print \" 2).Total discharge head developed by the pump is given by h = %f m\"%(h);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The fluid power is -454.750210 Watt\n",
- " 2).Total discharge head developed by the pump is given by h = 9.271156 m\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.15 Page number - 106"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 1000.;\t\t\t#[K] - Temperature at entry\n",
- "P_1 = 0.6;\t\t\t#[MPa] - Pressure at entry\n",
- "P_2 = 0.2;\t\t\t#[MPa] - Exit pressure\n",
- "Vel_1 = 50.;\t\t\t#[m/s] - Entry velocity \n",
- "Y = 1.4;\t\t\t# Ratio of heat capacities\n",
- "Mol_wt = 28.;\t\t\t#[g/mol] - Molecular weight of air\n",
- "Cp = 29.099;\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
- "Cp = (Cp/Mol_wt)*1000;\t\t\t#[J/kg-K]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# We know that for a flow process \n",
- "\t\t\t# delta_H + delta_V**(2)/2 + delta_(g*z) = q - w\n",
- "\t\t\t# Since process is adiabatic,therefore q = 0 and since no work is done by the gas, therefore w = 0\n",
- "\t\t\t# Assuming there is no change in the potenial energy between entry and exit, we have\n",
- "\t\t\t# delta_H + delta_V**(2)/2 = 0\n",
- "\n",
- "\t\t\t# For a reversible process P*V**(Y) = constant and thus (T_2/T_1) = (P_2/P_1)**((Y-1)/Y)\n",
- "T_2 = T_1*(P_2/P_1)**((Y-1)/Y);\t\t\t#[K] - Exit temperature\n",
- "\n",
- "\t\t\t# delta_H + delta_V**(2)/2 = 0\n",
- "\t\t\t# Vel_2**(2)/2 - Vel_1**(2)/2 - (H_1 - H_2)= 0\n",
- "\t\t\t# Vel_2**(2)/2 - Vel_1**(2)/2 - Cp*(T_1 - T_2) = 0\n",
- "Vel_2_square = 2*(Vel_1**(2.)/2 - Cp*(T_2 - T_1));\t\t\t#[m**(2)/s**(2)]\n",
- "Vel_2 = (Vel_2_square)**(1./2);\t\t\t#[m/s]\n",
- "\n",
- "# Results\n",
- "print \" The discharge velocity is %f m/s\"%(Vel_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The discharge velocity is 749.965327 m/s\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.16 Page number - 107"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_entry = 10;\t\t\t#[bar] - Pressure at entry\n",
- "V_entry = 200;\t\t\t#[m/s] - Velocity at entry\n",
- "P_exit = 1;\t\t\t#[bar] - Vressure at exit\n",
- "V_exit = 800;\t\t\t#[m/s] - Velocity at exit\n",
- "g = 9.81;\t\t\t#[m/s**(2)] - Acceleration due to gravity\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#Heat balance gives\n",
- "\t\t\t# delta_H + (delta_V**(2))/2 + g*delta_z = q - w\n",
- "\t\t\t#delta_H = q - w - (delta_V**(2))/2 \n",
- "\t\t\t#From nozzle no work is extracted,therefore\n",
- "delta_H = -(V_exit**(2)- V_entry**(2))/2;\t\t\t#[J/kg]\n",
- "delta_H = delta_H*10**(-3);\t\t\t#[kJ/kg]\n",
- "\n",
- "# Results\n",
- "print \" The change in enthalpy per kg of steam is %f kJ/kg\"%(delta_H);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The change in enthalpy per kg of steam is -300.000000 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.17 Page number - 111"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 280;\t\t\t#[K] - Temperature at entry\n",
- "P_1 = 100;\t\t\t#[kPa] - Pressure at entry\n",
- "T_2 = 400;\t\t\t#[K] - Temperature at exit\n",
- "P_2 = 600;\t\t\t#[kPa] - Pressure at exit\n",
- "m = 0.02;\t\t\t#[kg/s] - Mass flow rate\n",
- "m = m*10**(3);\t\t\t#[g/s]\n",
- "heat_loss = 16;\t\t\t#[kJ/kg]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Cp_0 = 28.11 + 0.1967*10**(-2)*T + 0.4802*10**(-5)*T**(2) - 1.966*10**(-9)*T**(3)\n",
- "\t\t\t#delta_H = q - w (neglecting kinetic and potential changes)\n",
- "\t\t\t#delta_H = integral(Cp_0*dT)\n",
- "\n",
- "def f22(T): \n",
- "\t return 28.11 + 0.1967*10**(-2)*T + 0.4802*10**(-5)*T**(2) - 1.966*10**(-9)*T**(3)\n",
- "\n",
- "delta_H = quad(f22,T_1,T_2)[0]\n",
- "\n",
- "print \" Change in enthalpy is %f J/mol\"%(delta_H);\n",
- "\n",
- "\t\t\t#Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n",
- "Mol_wt = 28.84;\t\t\t#[g/mol]\n",
- "q = - (heat_loss*Mol_wt);\t\t\t#[J/mol]\n",
- "w = q - delta_H;\t\t\t#[J/mol]\n",
- "print \" The work done per mole of air is %f J/mol\"%(w);\n",
- "\t\t\t#the negative sign implies that work is done on the compressor.\n",
- "\n",
- "n = m/Mol_wt;\t\t\t#[mol/s] - Mole flow rate\n",
- "W_net = delta_H*n;\t\t\t#[W]\n",
- "W_net = -W_net*10**(-3);\t\t\t#[kW]\n",
- "print \" And the necessary power input to the compressor is %f kW\"%(W_net);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Change in enthalpy is 3511.197066 J/mol\n",
- " The work done per mole of air is -3972.637066 J/mol\n",
- " And the necessary power input to the compressor is -2.434949 kW\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.18 Page number - 112"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 300;\t\t\t#[K] - Temperature at entry\n",
- "P_1 = 100;\t\t\t#[kPa] - Pressure at entry\n",
- "P_2 = 900;\t\t\t#[kPa] - Pressure at exit\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (a)\n",
- "\t\t\t# Reversible adiabatic compression\n",
- "Y = 1.4;\t\t\t#Ratio of specific heat capacities\n",
- "\t\t\t# For ideal gas, P*V**(Y)= constant and it takes the form of (T_2/T_1) = (P_2/P_1)**((Y-1)/Y)\n",
- "T_2 = T_1*(P_2/P_1)**((Y - 1)/Y);\t\t\t#[K]\n",
- "\t\t\t# The work exchange for adiabatic process is given by\n",
- "\t\t\t# W_adia = -delta_H = -Cp*(T2-T1) = Cp*(T1-T2) = ((Y*R)/(Y-1))*(T1-T2)\n",
- "W_adia = ((Y*R)/(Y - 1))*(T_1 - T_2);\t\t\t#[J/mol] -work done\n",
- "\t\t\t# Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n",
- "Mol_wt = 28.84;\t\t\t#[g/mol]\n",
- "W_adia = W_adia/Mol_wt;\t\t\t#[J/g]\n",
- "print \" a).The compressor work done for reversible adiabatic compession is %f J/g\"%(W_adia);\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t#Isothermal compression\n",
- "\t\t\t#W_iso = -integral(V*dP) = -integral((R*T/P)*dP) = R*T*ln(P_2/P_1)\n",
- "W_iso = -R*T_1*math.log(P_2/P_1);\t\t\t#[J/mol]\n",
- "W_iso = W_iso/Mol_wt;\t\t\t#[J/g]\n",
- "print \" b).The compressor work done for isothermal compession is %f J/g\"%(W_iso);\n",
- "\t\t\t#Note that in isothermal compression between the same states work done is less as compared to reversible adiabatic compression.\n",
- "\n",
- "\t\t\t#(c)\n",
- "\t\t\t#Ideal two-stage compression \n",
- "n = 1.3;\t\t\t#Polytropic exponent.\n",
- "\t\t\t#Minimum work done in two stage compression is given by\n",
- "\t\t\t#W_comp = ((2*n*R*T_1)/(n-1))*[1-(P_x/P_1)**(n-1)/n]\n",
- "\t\t\t#where for minimum work, (P_x/P_1) = (P_x/P_2), and thus\n",
- "P_x = (P_1*P_2)**(1./2);\t\t\t#[kPa]\n",
- "\t\t\t#therefore, work done is given by,\n",
- "W_comp = ((2*n*R*T_1)/(n-1))*(1-(P_x/P_1)**((n-1)/n));\t\t\t#[J/mol]\n",
- "W_comp = W_comp/Mol_wt;\t\t\t#[J/g]\n",
- "print \" c).The compressor work done for ideal two-stage compession is %f J/g\"%(W_comp);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The compressor work done for reversible adiabatic compession is -264.386412 J/g\n",
- " b).The compressor work done for isothermal compession is -190.024880 J/g\n",
- " c).The compressor work done for ideal two-stage compession is -216.284501 J/g\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.19 Page number - 113"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 600;\t\t\t#[C] - Temperature at entry\n",
- "P_1 = 15;\t\t\t#[MPa] - Pressure at entry\n",
- "T_2 = 400;\t\t\t#[K] - Temperature at exit\n",
- "P_2 = 100;\t\t\t#[kPa] - Pressure at exit\n",
- "A_in = 0.045;\t\t\t#[metre square] - flow in area\n",
- "A_out = 0.31;\t\t\t#[metre square] - flow out area\n",
- "m = 30;\t\t\t#[kg/s] - mass flow rate.\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#At 15 MPa and 600 C,it has been reported in the book that the properties of steam are,\n",
- "Vol_1 = 0.02491;\t\t\t#[m**(3)/kg] - Specific volume\n",
- "H_1 = 3582.3;\t\t\t#[kJ/kg] - Enthalpy\n",
- "\t\t\t# m = den*vel*A = (Vel*A)/Vol, substituting the values\n",
- "vel_1 = (m*Vol_1)/A_in;\t\t\t#[m/s] - Velocity at point 1.\n",
- "print \" The inlet velocity is %f m/s\"%(vel_1);\n",
- "\n",
- "\t\t\t#At 100 MPa (saturated vapour),it has been reported in the book that the properties of steam are, T_sat = 99.63 C, and\n",
- "Vol_vap_2 = 1.6940;\t\t\t#[m**(3)/kg] - specific volume of saturated vapour.\n",
- "H_vap_2 = 2675.5;\t\t\t#[kJ/kg] - Enthalpy os saturated vapour.\n",
- "vel_2 = (m*Vol_vap_2)/A_out;\t\t\t#[m/s] - Velocity at point 2.\n",
- "print \" The exit velocity is %f m/s\"%(vel_2);\n",
- "\n",
- "\t\t\t#From first law we get, q - w =delta_H + delta_V**(2)/2\n",
- "\t\t\t#q = 0, therefore, -w = delta_H + delta_V**(2)/2\n",
- "delta_H = H_vap_2 - H_1;\t\t\t#[kJ/kg] - change in enthalpy.\n",
- "delta_V_square = (vel_2**(2) - vel_1**(2))/2;\t\t\t#[J/kg]\n",
- "delta_V_square = delta_V_square*10**(-3);\t\t\t#[kJ/kg]\n",
- "w = -(delta_H + delta_V_square);\t\t\t#[J/kg] \n",
- "W_net = w*m;\t\t\t#[kW]\n",
- "W_net = W_net*10**(-3);\t\t\t#[MW] - power produced.\n",
- "print \" The power that can be produced by the turbine is %f MW\"%(W_net);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The inlet velocity is 16.606667 m/s\n",
- " The exit velocity is 163.935484 m/s\n",
- " The power that can be produced by the turbine is 26.805014 MW\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.20 Page number - 117"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
- "Cp_0 = 2.5*R;\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
- "Cv_0 = 1.5*R;\t\t\t#[J/mol-K] - Specific heat capacity at constant volume\n",
- "T_L = 300;\t\t\t#[K] - Temperature at which port properties are constant.\n",
- "\n",
- "# Calculations\n",
- "Y = Cp_0/Cv_0;\t\t\t# Ratio of heat capacities.\n",
- "\t\t\t#From part(1) we obtained the relation,\n",
- "\t\t\t# T_2 = 1/(((P_2-P_1)/(Y*T_L*P_2))+(P_1/(P_2*T_1)))\n",
- "\t\t\t# Not that when P_2 >> P_1 ,T_2 approaches Y*T_L and thus\n",
- "T_2 = Y*T_L;\t\t\t#[K]\n",
- "\n",
- "# Results\n",
- "print \" b).The final temperature is %f K\"%(T_2);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " b).The final temperature is 500.000000 K\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.21 Page number - 119"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 40 + 273.15;\t\t\t#[K] - Initial temperature.\n",
- "P_1 = 1;\t\t\t#[bar] - Initial pressure.\n",
- "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
- "Vol_1 = 0.01;\t\t\t#[cubic metre] - Initial volume of the cylinder.\n",
- "T_2 = 100 + 273.15;\t\t\t#[K] - Final temperature.\n",
- "P_2 = 100;\t\t\t#[kPa] - Final pressure.\n",
- "P_2 = P_2*10**(5);\t\t\t#[Pa]\n",
- "Vol_2 = 0.02;\t\t\t#[cubic metre] - Final volume of the cylinder.\n",
- "Cp = 1.005;\t\t\t#[J/g-K] - Specific heat capacity at constant pressure.\n",
- "Cv = 0.718;\t\t\t#[J/g-K] - Specific heat capacity at constant volume.\n",
- "Mol_wt = 28.84;\t\t\t#[g/mol] - Molecular weight of air.\n",
- "R = 8.314;\t\t\t#[J/mol-K] - universal gas constant\n",
- "\n",
- "# Calculations\n",
- "delta_Vol = Vol_2 - Vol_1;\t\t\t# [cubic metre] - Change in volume.\n",
- "\t\t\t# Assuming ideal gas P*V = R*T\n",
- "V_1 = (R*T_1)/P_1;\t\t\t# [m**(3)/mol] - Initial specific volume.\n",
- "\t\t\t# Therefore,the total number of moles initially in the system is,\n",
- "n_1 = (Vol_1/V_1);\t\t\t# [mol]\n",
- "m_1 = n_1*Mol_wt;\t\t\t# [g] - Initial mass of the system.\n",
- "Y = Cp/Cv;\t\t\t#Ratio of heat capacities\n",
- "\n",
- "\t\t\t# The energy balance equation is given by\n",
- "\t\t\t# -P*delta_Vol + H_liq*(m_2 - m_1) = m_2*Cv*(P*V2)/R - m_1*Cv*T_1\n",
- "\t\t\t# m_2*Cv*(P*V2)/R = (Cv*P_1*Vol_2)/R\n",
- "\t\t\t# Cv/R = 1/(Y-1)\n",
- "\t\t\t# Since pressure of the gas in system is assumed constant,therefore it remains at 1 bar and thus P = P_1,\n",
- "H_liq = Cp*T_2;\t\t\t# [J/g] - Enthalpy of liquid\n",
- "m_2 = (P_1*delta_Vol + ((P_1*Vol_2)/(Y-1)) + H_liq*m_1 - m_1*Cv*T_1)/H_liq;\t\t\t#[g]\n",
- "\n",
- "\t\t\t#The mass entering the assembly during the filling process is given by\n",
- "m = m_2 - m_1;\t\t\t#[g]\n",
- "n_2 = m_2/Mol_wt;\t\t\t#[mol] - Number of moles in the final state.\n",
- "V_2 = Vol_2/n_2;\t\t\t#[m**(3)/mol] - Final specific volume.\n",
- "\t\t\t# Therfore,final temperature is given by,\n",
- "T_2 = (P_1*V_2)/R;\t\t\t#[K] - Final temperature.\n",
- "\n",
- "# Results\n",
- "print \" The final equilibrium temperature is %f K\"%(T_2);\n",
- "print \" The mass entering through the valve is %f g\"%(m);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The final equilibrium temperature is 339.343160 K\n",
- " The mass entering through the valve is 9.367211 g\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example - 3.22 Page number - 122"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "V_total = 5;\t\t\t#[L] - Volume of pressure cooker.\n",
- "V_total = V_total*10**(-3);\t\t\t#m**(3)\n",
- "P_gauze = 15;\t\t\t#[psi] - Operating pressure (gauze)of pressure cooker.\n",
- "P_gauze = (P_gauze/14.5)*10**(5);\t\t\t#[N/m**(2)]\n",
- "P_atm = 0.966*10**(5);\t\t\t#[N/m**(2)] - Atmospheric pressure.\n",
- "m_1 = 1;\t\t\t#[kg] - Initial mass.\n",
- "t = 30*60;\t\t\t#[s] - Total time.\n",
- "J = 500;\t\t\t#[W] - Rate of heat supply\n",
- "\n",
- "# Calculations\n",
- "P_abs = P_gauze + P_atm;\t\t\t#[N/m**(2)] - Absolute pressure.\n",
- "\t\t\t#The energy balance equqtion gives,\n",
- "\t\t\t# Q = m_e*H_e +(m_2*U_2 - m_1*U_1), where 'm_e' is the mass exit from the system and 'H_e' is enthalpy at exit conditions.\n",
- "\n",
- "\t\t\t#It has been reported in the book that from steam table at P_abs,\n",
- "T_sat = 120.23;\t\t\t#[K]- Saturated temperature\n",
- "V_liq = 0.001061;\t\t\t#[m**(3)/kg] - specific volume of liquid.\n",
- "V_vap = 0.8857;\t\t\t#[m**(3)/kg] - specific volume of vapour.\n",
- "U_liq = 504.49;\t\t\t#[kJ/kg] - specific internal energy of liquid.\n",
- "U_vap = 2529.5;\t\t\t#[kJ/kg] - specific internal energy of vapour.\n",
- "H_liq = 504.70;\t\t\t#[kJ/kg] - specific enthalpy of liquid.\n",
- "H_vap = 2706.7;\t\t\t#[kJ/kg] - specific internal energy of vapour.\n",
- "\n",
- "\t\t\t#We know that total volume occupied by 1 kg of fluid is \n",
- "\t\t\t#V_total = (1-x)*V_liq + x*V_vap\n",
- "x1 = (V_liq - V_total)/(V_liq - V_vap);\t\t\t#[g]\n",
- "\n",
- "\t\t\t#Internal energy at this state is\n",
- "U_1 = (1-x1)*U_liq + x1*U_vap;\t\t\t#[kJ/kg] - specific internal energy\n",
- "U_1_net = m_1*U_1;\t\t\t#[kJ] - Internal energy\n",
- "\n",
- "\t\t\t#The amount of heat suplied is given by,\n",
- "J_net = J*t;\t\t\t#[J] - Net heat supplied.\n",
- "J_net = J_net*10**(-3);\t\t\t#[kJ]\n",
- "\n",
- "\t\t\t#Let the dryness factor at the end of the process be x\n",
- "\t\t\t#The specific properties of the liquid and vapour remain same as P and T_sat are the same in the cooker.\n",
- "\t\t\t#Let the total mass of H2O (liquid + vapour) at the end of the process be 'm' kg.\n",
- "\t\t\t# V_total/m = (1-x)*(V_liq) + x*V_vap ......equqtion(1)\n",
- "\n",
- "\t\t\t#the specific internal energy at the end of process is\n",
- "\t\t\t#U = (1-x)*U_liq + x*U_vap\n",
- "\t\t\t#The total internal energy at the end of the process is\n",
- "\t\t\t#U_net = m*U = x*[(1-x)*U_liq + x*U_vap]\n",
- "\n",
- "\t\t\t#The energy balance equqtion gives,\n",
- "\t\t\t# Q = m_e*H_e +(m_2*U_2 - m_1*U_1), where 'm_e' is the mass exit from the system and 'H_e' is enthalpy at exit conditions.\n",
- "\t\t\t#Since the vapour which exits out have enthalpy equal to that of saturated vapour,we get on simplification\n",
- "\t\t\t# 900 = (1-m)*(2706.7) + m*((1-x)*504.49 + x*2529.5) - 513.5..........equation(2)\n",
- "\t\t\t# The second equation on simplification becomes\n",
- "\t\t\t# x = ((0.005/m) - 0.001061)/0.884639\n",
- "\n",
- "\t\t\t# Putting the expression of x in first equation and then simplifying, we get\n",
- "\t\t\t# - 1293.2 = -2202.21*m + 11.445 - 2.429*m\n",
- "m = (11.445+1293.2)/(2202.21+2.429);\t\t\t#[kg]\n",
- "\n",
- "\t\t\t# Therefore x can be calculated as\n",
- "x = ((0.005/m) - 0.001061)/0.884639;\n",
- "\n",
- "\t\t\t# Therfore total water (liquid + vapour) present in the pressure cooker at the end of the process is m kg.\n",
- "m_vapour = x*m;\t\t\t#[kg] - Mass of vapour\n",
- "m_liquid = (1-x)*m;\t\t\t#[kg] - Mass of vapour\n",
- "\n",
- "# Results\n",
- "print \" Total water liquid + vapour) present in the pressure cooker at the end of the process is %f kg\"%(m);\n",
- "print \" The mass of vapour is %f kg\"%(m_vapour);\n",
- "print \" The mass of liquid is %f kg\"%(m_liquid);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Total water liquid + vapour) present in the pressure cooker at the end of the process is 0.591773 kg\n",
- " The mass of vapour is 0.004942 kg\n",
- " The mass of liquid is 0.586830 kg\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 20
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch4_2.ipynb b/Chemical_Engineering_Thermodynamics/ch4_2.ipynb
deleted file mode 100755
index 52c2044d..00000000
--- a/Chemical_Engineering_Thermodynamics/ch4_2.ipynb
+++ /dev/null
@@ -1,1513 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:8185298e7063d37f738c422b0f9a0946dd677189cdf544f54e436d8d650cb521"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 4 : The Secomd Law and Its Applications"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.1 Page Number : 148"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "n = 1000.;\t\t\t#[mol]\n",
- "T = 400.;\t\t\t#[K]\n",
- "P_1 = 100.;\t\t\t#[kPa]\n",
- "P_2 = 1000.;\t\t\t#[kPa]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(a)\n",
- "T_surr = 400.;\t\t\t#[K] - surrounding temperature\n",
- "\t\t\t# Total change in entropy of the system is given by\n",
- "\t\t\t# delta_S_sys = n*(Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1))\n",
- "\t\t\t# The process being isothermal the first term is zero and the total entropy change of the system is\n",
- "delta_S_sys_a = - n*R*math.log(P_2/P_1);\t\t\t#[J/K]\n",
- "delta_S_sys_a = delta_S_sys_a*10**(-3);\t\t\t#[kJ/K]\n",
- "\n",
- "\t\t\t# Since the process is reversible therefore\n",
- "Q_sys = T_surr*delta_S_sys_a;\t\t\t#[kJ] - Heat change in the system\n",
- "\t\t\t# Negative sign in the value of Q_sys implies that heat is released from the system and is released to the surroundings,therefore\n",
- "Q_surr = - Q_sys;\t\t\t#[kJ] - Heat change in the surrounding\n",
- "delta_S_surr_a = Q_surr/T_surr;\t\t\t#[kJ/K]\n",
- "\n",
- "delta_S_univ_a = delta_S_sys_a + delta_S_surr_a;\t\t\t#[kJ/K]\n",
- "\t\t\t# We get delta_S_univ = 0, which is true for a reversible process\n",
- "\n",
- "print \" a).The entropy change of the gas is given by delta_S_sys = %f kJ/K \"%(delta_S_sys_a);\n",
- "print \" The entropy change of the surrounding is delta_S_surr = %f kJ/K \"%(delta_S_surr_a);\n",
- "print \" The total entropy change of the gas is delta_S_univ = %f kJ/K \"%(delta_S_univ_a);\n",
- "\n",
- "\t\t\t#(b)\n",
- "T_surr_b = 300.;\t\t\t#[K] - surrounding temperature\n",
- "\t\t\t# Since the initial and final states are fixed therefore the entropy change of the system is same whether the process is carried out reversibly or irreversibly.\n",
- "delta_S_sys_b = delta_S_sys_a;\n",
- "\n",
- "\t\t\t# Work done under reversible condition is given by\n",
- "\t\t\t# W = integral(P*dV) = integral(((R*T)/V)*dV) = R*T*math.log(V_2/V_1)\n",
- "\t\t\t# For ideal gas we have, P1*V1/T1 = P2*V2/T2 or, V2/V1 = P1/P2 (for isothermal conditions)\n",
- "W = R*T*math.log(P_1/P_2);\t\t\t#[J/mol]\n",
- "W = W*10**(-3);\t\t\t#[kJ/mol]\n",
- "\t\t\t# 20% extra work has to be done for the system to reach the same final state as under reversible conditions. Therefore\n",
- "W = W*(120./100);\t\t\t#[kJ/mol]\n",
- "W = W*n;\t\t\t#[kJ] - Total work done for n moles\n",
- "\n",
- "\t\t\t# Using the first law we have delta_U = Q - W. Now under isothermal conditions for ideal gas, delta_U = 0. Therefore,\n",
- "Q = -W;\n",
- "\t\t\t# It implies that whatever work is done on the system is lost as heat to the surroundings.\n",
- "\t\t\t# Since heat is gained by the surroundings therefore\n",
- "delta_S_surr_b = Q/T_surr_b;\t\t\t#[kJ/K]\n",
- "\n",
- "delta_S_univ_b = delta_S_sys_b + delta_S_surr_b;\t\t\t#[kJ/K]\n",
- "\n",
- "print \" b).The entropy change of the gas is given by delta_S_sys = %f kJ/K \"%(delta_S_sys_b);\n",
- "print \" The entropy change of the surrounding is delta_S_surr = %f kJ/K \"%(delta_S_surr_b);\n",
- "print \" The total entropy change of the gas is delta_S_univ = %f kJ/K \"%(delta_S_univ_b);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The entropy change of the gas is given by delta_S_sys = -19.143692 kJ/K \n",
- " The entropy change of the surrounding is delta_S_surr = 19.143692 kJ/K \n",
- " The total entropy change of the gas is delta_S_univ = 0.000000 kJ/K \n",
- " b).The entropy change of the gas is given by delta_S_sys = -19.143692 kJ/K \n",
- " The entropy change of the surrounding is delta_S_surr = 30.629908 kJ/K \n",
- " The total entropy change of the gas is delta_S_univ = 11.486215 kJ/K \n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.2 Page Number : 148"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 400.;\t\t\t#[K] - Temperature\n",
- "P_1 = 500.*10**(3);\t\t\t#[Pa] - Initial pressure\n",
- "P_2 = 100.*10**(3);\t\t\t#[Pa] - Final pressure\n",
- "V_1 = 750.*10**(-6);\t\t\t#[m**(3)] - Initial volume\n",
- "W_actual = 0.55*10**(3);\t\t\t#[J] - Actual work done\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal fas constant\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# Suppose that the surroundings are at 400 K.\n",
- "\t\t\t# Therefore the process is externally reversible as temperature of the surroundings is same as system temperature.\n",
- "\t\t\t# The number of moles is given by\n",
- "n = (P_1*V_1)/(R*T);\t\t\t#[mol]\n",
- "\t\t\t# The entropy change of ideal gas under isothermal condition is given by\n",
- "delta_S_sys = - n*R*math.log(P_2/P_1);\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# The heat supplied to the system in the internally reversible process is\n",
- "Q_theot = T*delta_S_sys;\t\t\t#[J]\n",
- "\t\t\t# Since the process is isothermal therefore, workdone is given by\n",
- "W_theot = Q_theot;\t\t\t#[J] - Theoritical work done\n",
- "\t\t\t# Since actual work done by the gas is 0.55 kJ therefore actual heat supplied is also 0.55 kJ because under isothermal conditions delta_U = 0\n",
- "Q_actual = W_actual;\n",
- "\n",
- "# Results\n",
- "\t\t\t# Since Q_theot > Q_actual, so the process is irreversible\n",
- "print \" Since Q_theot = %f J is greater than Q_actual = %f J\"%(Q_theot,Q_actual);\n",
- "print \" Therefore, the process is internally irreversible\"\n",
- "\n",
- "\t\t\t# Moreover delta_S_sys is same whether the process is reversible or irreversible as the initial and final states is the same.\n",
- "\t\t\t# In the reversible process higher amount of heat is supplied (as compared to irreversible) due to which delta_S_sys take place.\n",
- "\t\t\t# In the irreversible process the entropy of system increases due two reasons : heat supplied and entropy generation\n",
- "\t\t\t# So in the irreversible case amount of heat supplied is less as compared to reversible case as entropy generation term also adds to the entropy change of system\n",
- "\t\t\t# delta_S_sys = Q/T_b + S_gen\n",
- "S_gen = delta_S_sys - (Q_theot/T);\t\t\t#[J/K]\n",
- "\t\t\t# The entropy generated may be due to friction and other dissipayive effects or due to non-quasi-static expansion\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Since Q_theot = 603.539217 J is greater than Q_actual = 550.000000 J\n",
- " Therefore, the process is internally irreversible\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.3 Page Number : 150"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\t\t\t# For side A\n",
- "V_A = 1;\t\t\t#[L] - Volume\n",
- "V_A = V_A*10**(-3);\t\t\t#[m**(3)]\n",
- "T_A = 300;\t\t\t#[K] - Temperature\n",
- "P_A = 2;\t\t\t#[atm] - Pressure\n",
- "P_A = P_A*101325;\t\t\t#[Pa]\n",
- "\n",
- "\t\t\t# For side B\n",
- "V_B = 1;\t\t\t#[L] - volume\n",
- "V_B = V_B*10**(-3);\t\t\t#[m**(3)]\n",
- "T_B = 300;\t\t\t#[K] - Temperature\n",
- "P_B = 1;\t\t\t#[atm] - Pressure\n",
- "P_B = P_B*101325;\t\t\t#[Pa]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# From first law final temperature and pressure are given by (example 3.30)\n",
- "\t\t\t# T = ((n_A*T_A) + (n_B*T_B))/(n_A + n_B)\n",
- "\t\t\t# P = ((P_A*V_A) + (P_A*V_B))/(V_A + V_B)\n",
- "\n",
- "\t\t\t# Since in this case T_A = T_B, therefore final pressure is given by\n",
- "P = ((P_A*V_A) + (P_B*V_B))/(V_A + V_B);\t\t\t#[Pa]\n",
- "P = P/101325;\t\t\t#[atm]\n",
- "\n",
- "print \" The final temperature is %f K\"%(T_A);\n",
- "print \" The final pressure is %f atm\"%(P);\n",
- "\n",
- "\t\t\t# The number of moles of air on each side are\n",
- "n_A = (P_A*V_A)/(R*T_A);\t\t\t#[mol]\n",
- "n_B = (P_B*V_B)/(R*T_B);\t\t\t#[mol]\n",
- "\n",
- "delta_S_A = -n_A*R*math.log((P*101325)/P_A);\t\t\t#[J/K] - Entropy change on side A\n",
- "delta_S_B = -n_B*R*math.log((P*101325)/P_B);\t\t\t#[J/K] - Entropy change on side B\n",
- "delta_S_sys = delta_S_A + delta_S_B;\t\t\t#[J/K] - Total entropy change of system\n",
- "\n",
- "\t\t\t# Since the system is insulated there is no heat exchange with the surroundings, therefore entropy change of surrounding is zero\n",
- "delta_S_surr = 0;\t\t\t#[J/K]\n",
- "delta_S_univ = delta_S_sys + delta_S_surr;\t\t\t#[J/K]\n",
- "print \" The total increase in entropy is %f J/K\"%(delta_S_univ);\n",
- "\n",
- "\t\t\t# The entropy change of the system can also be writtten as\n",
- "\t\t\t# delta_s_sys = Q/T_b + S_gen\n",
- "\t\t\t# Since there is no heat transfer, therefore\n",
- "S_gen = delta_S_univ;\t\t\t#[J/K]\n",
- "\t\t\t# The process is reversible because of entropy generation due to spontaneous release of piston.\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The final temperature is 300.000000 K\n",
- " The final pressure is 1.500000 atm\n",
- " The total increase in entropy is 0.057383 J/K\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.4 Page Number : 151"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "V_vessel = 0.2;\t\t\t#[m**(3)] - Volume of the vessel\n",
- "P_1 = 10;\t\t\t#[bar] - Initial pressure inside the vessel\n",
- "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
- "P_2 = 3.5;\t\t\t#[bar] - Final pressure inside the vessel\n",
- "P_2 = P_2*10**(5);\t\t\t#Pa\n",
- "T_1 = 250 + 273.15;\t\t\t#[K] - Initial temperature of the vesssel\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (a)\n",
- "\t\t\t# At 10 bar and 250 C the steam is superheated. From steam table as reported in book we have\n",
- "V_1 = 0.2327;\t\t\t#[m**(3)/kg] - specific volume\n",
- "U_1 = 2709.9;\t\t\t#[kJ/kg] - specific internal energy\n",
- "H_1 = 2942.6;\t\t\t#[kj/kg] - Specific enthalpy\n",
- "S_1 = 6.9247;\t\t\t#[kJ/kg-K] - Specific entropy\n",
- "\t\t\t# the quantity of steam is given by\n",
- "m = V_vessel/V_1;\t\t\t#[kg]\n",
- "\n",
- "\t\t\t# At final state \n",
- "V_2 = 0.2327;\t\t\t#[m**(3)/kg] - Molar volume\n",
- "V_liq_2 = 0.001079;\t\t\t# [m**(3)/kg]\n",
- "V_vap_2 = 0.5243;\t\t\t# [m**(3)/kg]\n",
- "\t\t\t# Since overall volume lies between saturated liquid and saturated vapour therefore the steam is saturated and its dryness fraction at final state is given by\n",
- "x = (V_2 - V_liq_2)/(V_vap_2 - V_liq_2);\n",
- "\t\t\t# Final temperature = T_sat (at 3 bar) from steam table\n",
- "T_final = 138.88;\t\t\t#[C]\n",
- "\n",
- "\t\t\t# At 3.5 bar saturated conditions \n",
- "S_liq = 1.7275;\t\t\t#[kJ/kg-K] - Entropy of saturated liquid\n",
- "S_vap = 6.9405;\t\t\t#[kJ/kg-K] - Entropy of saturated vapour\n",
- "U_liq = 583.95;\t\t\t#[kJ/kg] - Internal energy of saturated liquid\n",
- "U_vap = 2548.9;\t\t\t#[kJ/kg] - Internal energy of saturated vapour\n",
- "\t\t\t# Therefore at final state \n",
- "U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg]\n",
- "S_2 = S_liq*(1 - x) + x*S_vap;\t\t\t#[kJ/kg-K]\n",
- "Q_1 = m*(U_2 - U_1);\t\t\t#[kJ]\n",
- "delta_S_1 = m*(S_2 - S_1);\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" a).The final temperature is %f C\"%(T_final);\n",
- "print \" The amount of heat transfer is %f kJ\"%(Q_1);\n",
- "print \" The change of entropy is %f kJ/kg-K\"%(delta_S_1);\n",
- "\n",
- "\t\t\t# (b)\n",
- "Y = 1.4;\t\t\t# Ratio of heat capacities for air\n",
- "\t\t\t# (P_1*V_1)/T_1 = (P_2*V_2)/T_2 and since V_1 = V_2\n",
- "T_2 = (P_2/P_1)*T_1;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# Since the volume is fixed therefore work done (W) = 0 and from first law we get\n",
- "\t\t\t# Q = delta_U = n*Cv_0*(T_2 - T_1)\n",
- "Cv_0 = R/(Y - 1);\t\t\t#[J/mol-K] - Heat capacity at constant volume\n",
- "Cp_0 = (Y*R)/(Y - 1);\t\t\t#[J/mol-K] - Heat capacity at constant pressure\n",
- "n = (P_1*V_vessel)/(R*T_1);\t\t\t#[mol] - No. of moles\n",
- "Q_2 = n*Cv_0*(T_2 - T_1);\t\t\t#[J] - Heat change\n",
- "Q_2 = Q_2*10**(-3);\t\t\t#[kJ]\n",
- "\n",
- "delta_S_2 = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
- "delta_S_2 = n*delta_S_2*10**(-3);\t\t\t#[kJ/K]\n",
- "\n",
- "print \" b).The final temperature is %f C\"%(T_2);\n",
- "print \" The amount of heat transfer is %f kJ\"%(Q_2);\n",
- "print \" The change of entropy is %f kJ/K\"%(delta_S_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The final temperature is 138.880000 C\n",
- " The amount of heat transfer is -1079.587621 kJ\n",
- " The change of entropy is -2.483450 kJ/kg-K\n",
- " b).The final temperature is 183.102500 C\n",
- " The amount of heat transfer is -325.000000 kJ\n",
- " The change of entropy is -1.003366 kJ/K\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.5 Page Number : 153"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from math import *\n",
- "# Variables\n",
- "m = 1000.;\t\t\t#[g] - Mass of fluid\n",
- "P_1 = 20.;\t\t\t#[bar] - Initial pressure\n",
- "P_1 = P_1*10.**(5);\t\t\t#[Pa]\n",
- "P_2 = 2;\t\t\t#[bar] - Final pressure\n",
- "P_2 = P_2*10.**(5);\t\t\t#Pa\n",
- "T_1 = 250 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "n = 1.25;\n",
- "R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
- "Y = 1.4;\t\t\t# Index of expansion\n",
- "Cv_0 = R/(Y- 1);\t\t\t#[J/mol-K]\n",
- "Cp_0 = R + Cv_0;\t\t\t#[J/mol-K]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(a)\n",
- "\t\t\t# For steam at 20 bar and 250 C, from steam table as reported in the book\n",
- "V_1 = 0.11144;\t\t\t#[m**(3)/kg]\n",
- "U_1 = 2679.6;\t\t\t#[kJ/kg]\n",
- "S_1 = 6.5453;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t# P_1*V_1**(n) = P_2*V_2**(n)\n",
- "V_2 = ((P_1*V_1**(n))/P_2)**(1/n);\t\t\t#[m**(3)/kg]\n",
- "\n",
- "\t\t\t# At 2 bar under saturated conditions,from steam table as reported in the book\n",
- "V_liq = 0.001061;\t\t\t#[m**(3)/kg]\n",
- "V_vap = 0.8857;\t\t\t#[m**(3)/kg]\n",
- "x = (V_2 - V_liq)/(V_vap - V_liq);\t\t\t# Dryness fraction\n",
- "T_sat = 120.23;\t\t\t#[C] - The final temperature\n",
- "U_liq = 504.49;\t\t\t#[kJ/kg] - Internal energy of saturate liquid\n",
- "U_vap = 2529.5;\t\t\t#[kJ/kg] - Internal energy of saturate vapour\n",
- "\t\t\t# Therefore, internal energy at state 2 is given by\n",
- "U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# Work transfer is given by\n",
- "W = (P_1*V_1 - P_2*V_2)/(n - 1);\t\t\t#[J/kg]\n",
- "W = W*10**(-3);\t\t\t#[kJ/kg]\n",
- "delta_U = U_2 - U_1;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# From first law, q - W = delta_U\n",
- "q = W + delta_U;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# At final state (2 bar saturated), as reported in the book\n",
- "S_liq = 1.5301;\t\t\t#[kJ/kg-K] - Entropy of saturated liquid\n",
- "S_vap = 7.1271;\t\t\t#[kJ/kg-K] - Entropy of saturated vapour\n",
- "\t\t\t# Therefore, entropy at state 2 is given by\n",
- "S_2 = S_liq*(1 - x) + x*S_vap;\t\t\t#[kJ/kg-K]\n",
- "delta_S = S_2 - S_1;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" a).The final temperature is %f C\"%(T_sat);\n",
- "print \" The work done is equal to %f kJ/kg\"%(W);\n",
- "print \" The heat change is equal to %f kJ/kg\"%(q);\n",
- "print \" The entropy change is equal to %f kJ/kg-K\"%(delta_S);\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t# P*V**(n) = constant\n",
- "\t\t\t# Since the gas behaves as ideal we can write\n",
- "\t\t\t# P_1**(1-n)*T_1**(n) = P_2**(1-n)*T_2**(n)\n",
- "T_2 = T_1*(P_1/P_2)**((1-n)/n);\t\t\t#[K]\n",
- "\n",
- "\t\t\t# Molar volume is given by\n",
- "V_2_1 = (R*T_1)/P_1;\t\t\t#[m**(3)/mol] - At state 1\n",
- "V_2_2 = (R*T_2)/P_2;\t\t\t#[m**(3)/mol] - At state 2\n",
- "\n",
- "\t\t\t# Work transfer is given by\n",
- "w_2 = ((P_1*V_2_1) - (P_2*V_2_2))/(n-1);\t\t\t#[J/mol]\n",
- "Mol_wt_air = 0.21*32 + 0.79*28;\t\t\t#[g/mol] - Molecular weight of air\n",
- "n_mole = m/Mol_wt_air;\n",
- "\t\t\t# Total work transfer is given by\n",
- "W_2 = w_2*n_mole*10**(-3);\t\t\t#[kJ]\n",
- "\t\t\t# Internal energy change is given by\n",
- "delta_U = n_mole*Cv_0*(T_2 - T_1)*10**(-3);\t\t\t#[kJ]\n",
- "\n",
- "\t\t\t# Heat transfer is given by\n",
- "Q = W_2 + delta_U;\t\t\t#[kJ]\n",
- "\n",
- "\t\t\t# Entropy change is given by\n",
- "delta_S_2 = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);\t\t\t#[J/mol-K]\n",
- "delta_S_2 = delta_S_2*n_mole;\t\t\t#[J/mol]\n",
- "\n",
- "print \" b).The final temperature is %f C\"%(T_2);\n",
- "print \" The work done is equal to %f kJ/kg\"%(W_2);\n",
- "print \" The total heat change is equal to %f kJ\"%(Q);\n",
- "print \" The entropy change is equal to %f J/kg-K\"%(delta_S_2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The final temperature is 120.230000 C\n",
- " The work done is equal to 329.008908 kJ/kg\n",
- " The heat change is equal to -238.988250 kJ/kg\n",
- " The entropy change is equal to -0.573241 kJ/kg-K\n",
- " b).The final temperature is 330.085335 C\n",
- " The work done is equal to 222.626855 kJ/kg\n",
- " The total heat change is equal to 83.485071 kJ\n",
- " The entropy change is equal to 199.136884 J/kg-K\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.6 Page Number : 154"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "m = 1000;\t\t\t#[g] - Mass of fluid\n",
- "P_1 = 20;\t\t\t#[bar] - Initial pressure\n",
- "P_2 = 2;\t\t\t#[bar] - Final ressure\n",
- "T_1 = 250 + 273.15;\t\t\t#[K] - Initial tempearture\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\t\t\t# (a).\n",
- "\t\t\t# At 20 bar and 250 C as reported in the book\n",
- "V_1 = 0.11144;\t\t\t#[m**(3)/kg] - Specific volume\n",
- "U_1 = 2679.6;\t\t\t#[kJ/kg] - Specific internal energy\n",
- "S_1 = 6.5453;\t\t\t#[kJ/kg-K] - Specific entropy\n",
- "S_2 = S_1;\t\t\t# Isentropic expansion\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# At 2 bar under saturated conditions \n",
- "S_liq = 1.5301;\t\t\t#[kJ/kg-K]\n",
- "S_vap = 7.1271;\t\t\t#[kJ/kg-K]\n",
- "U_liq = 504.49;\t\t\t#[kJ/kg-K]\n",
- "U_vap = 2529.5;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t# Therefore dryness factor can be determined as\n",
- "x = (S_1 - S_liq)/(S_vap - S_liq);\n",
- "U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg] - Specific internal energy at final state\n",
- "delta_U = U_2 - U_1;\t\t\t#[kJ/kg] - change in internal energy\n",
- "W = - delta_U;\t\t\t# - Work done\n",
- "\n",
- "\t\t\t# The final saturated temperature at 2 bar from steam table is\n",
- "T_2 = 120.23;\t\t\t#[C]\n",
- "\n",
- "print \" a).The final temperature is %f C\"%(T_2);\n",
- "print \" The work done is equal to %f kJ/kg\"%(W);\n",
- "\n",
- "\t\t\t# (b).\n",
- "Y = 1.4;\t\t\t# Index of expansion for air\n",
- "Cv_0 = R/(Y-1);\t\t\t#[J/mol*K] - Specific heat capacity at constant volume\n",
- "\t\t\t# Ideal gas under isentropic expansion P_1**(1-Y)*T_1**(Y) =P_2**(1-Y)*T_2**(Y)\n",
- "T_2_prime = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K] - Final temperature\n",
- "delta_U_prime = Cv_0*(T_2_prime - T_1);\t\t\t#[J/mol] - change in internal energy\n",
- "\n",
- "\t\t\t# Number of moles is given by\n",
- "n = m/28.84;\t\t\t#[mol]\n",
- "delta_U_prime = delta_U_prime*n*10**(-3);\t\t\t#[kJ]\n",
- "W_prime = - delta_U_prime;\t\t\t# Work done\n",
- "\n",
- "print \" b).The final temperature is %f C\"%(T_2_prime);\n",
- "print \" The work done is equal to %f kJ/kg\"%(W_prime);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The final temperature is 120.230000 C\n",
- " The work done is equal to 360.596841 kJ/kg\n",
- " b).The final temperature is 270.964218 C\n",
- " The work done is equal to 181.750398 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.7 Page Number : 155"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P_1 = 15.;\t\t\t#[bar] - Initial pressure\n",
- "P_2 = 0.15;\t\t\t#[bar] - Final pressure\n",
- "\n",
- "\t\t\t# We know that during isentropic expansion\n",
- "\t\t\t# W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n",
- "\n",
- "\t\t\t# At 15 bar (saturated vapour), from steam table as reported in the book\n",
- "V_1 = 0.13177;\t\t\t#[m**(3)/kg]\n",
- "U_1 = 2594.5;\t\t\t#[kJ/kg]\n",
- "S_1 = 6.4448;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t# Now at state 2 (P_2 = 0.15 bar),from steam table as reported in the book\n",
- "S_2 = S_1;\t\t\t# Isentropic expansion\n",
- "S_liq = 0.7549;\t\t\t#[kJ/kg-K]\n",
- "S_vap = 8.0085;\t\t\t#[kJ/kg-K]\n",
- "U_liq = 225.92;\t\t\t#[kJ/kg]\n",
- "U_vap = 2448.7;\t\t\t#[kJ/kg]\n",
- "V_liq = 0.001014;\t\t\t#[m**(3)/kg]\n",
- "V_vap = 10.02;\t\t\t#[m**(3)/kg]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# Therefore dryness factor can be calculated as\n",
- "x = round((S_1 - S_liq)/(S_vap - S_liq),3);\n",
- "U_2 = round(U_liq*(1 - x) + x*U_vap,2);\t\t\t#[kJ/kg] - Specific internal energy at final state\n",
- "delta_U = U_2 - U_1;\t\t\t#[kJ/kg] - change in internal energy\n",
- "W = - delta_U;\t\t\t# - Work done\n",
- "\n",
- "\t\t\t# The specific volume at the final state is\n",
- "V_2 = round(V_liq*(1 - x) + x*V_vap,3);\t\t\t#[m**(3)/kg]\n",
- "\n",
- "\t\t\t# From work done under adiabatic conditions we get\n",
- "\t\t\t# W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n",
- "Y = (((P_1*V_1) - (P_2*V_2))*10**2/W) + 1;\n",
- "\n",
- "# Results\n",
- "print \" The index of expansion is given by Y = %.4f\"%(Y);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The index of expansion is given by Y = 1.1275\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.8 Page Number : 157"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 40;\t\t\t#[bar] - Initial pressure\n",
- "T_1 = 500;\t\t\t#[C] - Initial temperature\n",
- "Vel_1 = 140;\t\t\t#[m/s] - Initial velocity\n",
- "T_2 = 100;\t\t\t#[C] - Final temperature\n",
- "Vel_2 = 80;\t\t\t#[m/s] - Final velocity\n",
- "W = 746.0;\t\t\t#[kJ/kg] - Work output\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# (a).\n",
- "\t\t\t# From steam table as reported in the book\n",
- "H_1 = 3445.3;\t\t\t#[kJ/kg]\n",
- "H_2 = 2676.1;\t\t\t#[kJ/kg]\n",
- "S_1 = 7.0901;\t\t\t#[kJ/kh-K]\n",
- "S_2 = 7.3549;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t# The temperature at which heat exchange take place is given by \n",
- "T_b =(T_1 + T_2)/2 + 273.15;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# From first law in a control volume \n",
- "\t\t\t# q - W = delta_H + (delta_V**(2))/2 , therefore\n",
- "q = W*10**(3) + (H_2 - H_1)*10**(3) + (Vel_2**(2) - Vel_1**(2))/2;\t\t\t#[J/kg]\n",
- "q = q*10**(-3);\t\t\t#[kJ/kg]\n",
- "\n",
- "S_gen = (S_2 - S_1) - (q/T_b);\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" a).The specific entropy production within turbine is %f kJ/kg-K\"%(S_gen);\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t# If control volume is too large to include the turbine and the environment then T_b becomes equal to 289 K. In this case\n",
- "T_b_prime = 298;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# The entropy change of the sysytem is given by \n",
- "\t\t\t#delta_S = q/T_b + S_gen\n",
- "S_gen = (S_2 - S_1) - (q/T_b_prime);\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" b).The specific entropy production within turbine is %f kJ/kg-K\"%(S_gen);\n",
- "\n",
- "\t\t\t# In the first part only irreversibilities within the turbine are evaluated\n",
- "\t\t\t# whereas in part (2) irreversible heat transfer between the turbine cover and environment are also included.\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The specific entropy production within turbine is 0.316793 kJ/kg-K\n",
- " b).The specific entropy production within turbine is 0.364800 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.9 Page Number : 160"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 1.;\t\t\t#[MPa] - Initial pressure\n",
- "T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 8.;\t\t\t#[MPa] - Final pressure\n",
- "Y = 1.4;\t\t\t# Index of expansion of gas\n",
- "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t# The exit temperature for ideal gas under isentropic conditions is given by \n",
- "T_2 = round(T_1*(round((P_2/P_1)**((Y-1)/Y),2)),1);\t\t\t#[K] - Exit temperature\n",
- "\n",
- "Cp_0 = round(Y*R/(Y-1),1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
- "\t\t\t# For isentropic conditions the enthalpy change for ideal gas is given by\n",
- "delta_H_s = Cp_0*(T_2 - T_1);\t\t\t#[J/mol]\n",
- "\t\t\t# Therefore work is given by\n",
- "W = - delta_H_s;\t\t\t#[J/mol]\n",
- "\n",
- "print \" 1).The exit temperature of steam is %.2f K\"%(T_2);\n",
- "print \" The required work is %.2f J/mol\"%(W);\n",
- "\n",
- "\t\t\t#(2)\n",
- "eff = 0.8;\t\t\t# Adiabatic efficiency\n",
- "\t\t\t# delta_H_s/delta_H_a = 0.8\n",
- "delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
- "W_a = - delta_H_a;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# The ideal gas enthalpy is a function only of temperature,therefore actual exit temperature T_2a is given by \n",
- "\t\t\t# delta_H_a = Cp_0*(T_2a - T_1)\n",
- "T_2a = (delta_H_a/Cp_0) + T_1;\n",
- "\n",
- "print \" 2).The exit temperature of steam is %.2f K\"%(T_2a);\n",
- "print \" The required work is %.2f J/mol\"%(W_a);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The exit temperature of steam is 856.40 K\n",
- " The required work is -11152.58 J/mol\n",
- " 2).The exit temperature of steam is 952.21 K\n",
- " The required work is -13940.72 J/mol\n"
- ]
- }
- ],
- "prompt_number": 30
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.10 Page Number : 161"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\t\t\t\n",
- "\n",
- "# Variables\n",
- "P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
- "T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 8;\t\t\t#[MPa] - Final pressure\n",
- "Y = 1.4;\t\t\t# Index of expansion of gas\n",
- "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
- "\t\t\t# Cp_0 = 7.7 + 0.04594*10**(-2)*T + 0.2521*10**(-5)*T**(2) - 0.8587*10**(-9)*T**(3), here T is in K and Cp_0 is in cal/mol-K\n",
- "a = 7.7;\n",
- "b = 0.04594*10**(-2);\n",
- "c = 0.2521*10**(-5);\n",
- "d = - 0.8587*10**(-9);\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# delta_S = integral((Cp_0/T)*dT) - R*math.log(P_2/P_1) = 0\n",
- "\t\t\t# delta_S = integral(((a + b*T + c*T**(2) + d*T**(3))/T)*dT) - R*math.log(P_2/P_1) = 0\n",
- "\t\t\t# delta_S = a*math.log(T_2/T_1) + b*(T_2 - T_1) + (c/2)*(T_2**(2) - T_1**(2)) + (d/3)*(T_2**(3) - T_1**(3)) - R*math.log(P_2/P_1) = 0\n",
- "\t\t\t# Solving for T_2 in the above equation we get\n",
- "def f(T_2): \n",
- "\t return a*math.log(T_2/T_1)+b*(T_2-T_1)+(c/2)*(T_2**(2)-T_1**(2))+(d/3)*(T_2**(3)-T_1**(3))-R*math.log(P_2/P_1)\n",
- "T_2 = fsolve(f,100)\n",
- "\n",
- "\t\t\t# Now let us calculate the enthalpy change under these conditions \n",
- "\n",
- "def f0(T): \n",
- "\t return 7.7+0.04594*10**(-2)*T+0.2521*10**(-5)*T**(2)-0.8587*10**(-9)*T**(3)\n",
- "\n",
- "delta_H_s = quad(f0,T_1,T_2)[0]\n",
- "\n",
- "delta_H_s = delta_H_s*4.184;\t\t\t#[J/mol]\n",
- "\t\t\t# Therefore isentropic work done is\n",
- "W = - delta_H_s;\n",
- "\n",
- "print \" 1).The exit temperature of steam is %f K\"%(T_2);\n",
- "print \" The required work is %f J/mol\"%(W);\n",
- "\n",
- "\t\t\t#(2)\n",
- "eff = 0.8;\n",
- "delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
- "\t\t\t# Therefore actual work done is given by \n",
- "W_a = - delta_H_a;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# Now we have to determine the exit temperature under actual conditions\n",
- "\t\t\t# delta_H_a = integral(Cp_0*dT) from limit T_1 = 473.15 K to T_2\n",
- "\t\t\t# On putting the values and simplifying we get\n",
- "\t\t\t# 7.7*T_2 + 0.02297*10**(-2)*T_2**(2) + 0.084*10**(-5)*T_2**(3) - 0.214675*10**(-9)*T_2**(4) - 6907.106 = 0\n",
- "\n",
- "def f1(T_2_prime): \n",
- "\t return a*(T_2_prime-T_1)+(b/2)*(T_2_prime**(2)-T_1**(2))+(c/3)*(T_2_prime**(3)-T_1**(3))+(d/4)*(T_2_prime**(4)-T_1**(4))-(delta_H_a/4.184)\n",
- "T_2_prime = fsolve(f1,100)\n",
- "\n",
- "print \" 2).The exit temperature of steam is %f K\"%(T_2_prime);\n",
- "print \" The required work is %f J/mol\"%(W_a);\n",
- "\n",
- "# Answers are vary because of rounding error. Calculations are correct. "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The exit temperature of steam is 760.037501 K\n",
- " The required work is -10499.128839 J/mol\n",
- " 2).The exit temperature of steam is 828.044888 K\n",
- " The required work is -13123.911049 J/mol\n"
- ]
- }
- ],
- "prompt_number": 31
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.11 Page Number : 162"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
- "T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 8;\t\t\t#[MPa] - Final pressure\n",
- "Y = 1.4;\t\t\t# Index of expansion of gas\n",
- "\n",
- "\t\t\t# At state 1 (1 MPa and 200 C) from steam table as reported in the book\n",
- "H_1 = 2827.9;\t\t\t#[kJ/kg]\n",
- "S_1 = 6.694;\t\t\t#[kJ/kg]\n",
- "\t\t\t# At state 2 (8 MPa)\n",
- "S_2 = S_1;\t\t\t# Isentropic process\n",
- "\t\t\t# From steam table at 8 MPa and 450 C\n",
- "S_21 = 6.5551;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t# From steam table at 8 MPa and 500 C\n",
- "S_22 = 6.7240;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t# Therefore temperature at which entropy of steam is 6.694 kJ/kg-K is given by\n",
- "T_2 = 450 + (500-450)/(S_22-S_21)*(S_2-S_21);\t\t\t#[C]\n",
- "T_2 = T_2 + 273.15;\t\t\t#[K]\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# Enthalpy of steam at 8 MPa and 450 C from steam table as reported in the book \n",
- "H_21 = 3272.0;\t\t\t#[kJ/kg]\n",
- "\t\t\t# And at 8 MPA and 500 C\n",
- "H_22 = 3398.3;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Therefore enthalpy of steam at 8 MPa and T_2 \n",
- "H_2 = H_21 + ((H_22-H_21)/(500-450))*((T_2-273.15) - 450); \n",
- "\t\t\t# Work done is given by \n",
- "\t\t\t# W = - delta_H_s\n",
- "W = - (H_2 - H_1);\t\t\t#[J/g]\n",
- "W = W*18.015;\t\t\t#[J/mol]\n",
- "delta_H_s = - W;\n",
- "\n",
- "print \" 1).The exit temperature of steam is %f K\"%(T_2);\n",
- "print \" The required work is %f J/mol\"%(W);\n",
- "\n",
- "\t\t\t#(2)\n",
- "eff = 0.8;\t\t\t# Adiabatic efficiency\n",
- "\t\t\t# delta_H_s/delta_H_a = 0.8\n",
- "delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
- "\t\t\t# Therefore actual work done \n",
- "W_a = - delta_H_a;\t\t\t#[J/mol]\n",
- "\t\t\t# Enthalpy at actual exit conditions is \n",
- "H_2_a = H_1 + delta_H_a/18.015;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# Enthalpy of steam at 8 MPa and 500 C from steam table as reported in the book \n",
- "H_21_a = 3398.3;\t\t\t#[kJ/kg]\n",
- "\t\t\t# And at 8 MPA and 550 C\n",
- "H_22_a = 3521.0;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Therefore temperature at H_22_a is given by\n",
- "T_2_a = 500 + ((550-500)*(H_2_a - H_21_a))/(H_22_a - H_21_a);\t\t\t#[C]\n",
- "T_2_a = T_2_a + 273.15;\t\t\t#[K]\n",
- "\n",
- "print \" 2).The exit temperature of steam is %f K\"%(T_2_a);\n",
- "print \" The required work is %f J/mol\"%(W_a);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The exit temperature of steam is 764.269005 K\n",
- " The required work is -9871.618433 J/mol\n",
- " 2).The exit temperature of steam is 819.832257 K\n",
- " The required work is -12339.523042 J/mol\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.12 Page Number : 163"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 140.;\t\t\t#[kPa] - Initial pressure\n",
- "T_1 = 20. + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 560.;\t\t\t#[kPa] - Final pressure\n",
- "eff = 0.75;\t\t\t# Compressor efficiency\n",
- "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
- "\t\t\t# Cp_0 = 4.750 + 1.200*10**(-2)*T + 0.3030*10**(-5)*T**(2) - 2.630*10**(-9)*T**(3), here T is in K and Cp_0 is in cal/mol-K\n",
- "a = 7.7;\n",
- "b = 0.04594*10**(-2);\n",
- "c = 0.2521*10**(-5);\n",
- "d = - 0.8587*10**(-9);\n",
- "\n",
- "# Calculations and Results\n",
- "# At 20 C,as reported in the book\n",
- "Cp_0 = 8.46;\t\t\t#[cal/mol-K] - Specific heat capacity at constant pressure\n",
- "Cv_0 = Cp_0 - R;\t\t\t#[cal/mol-K] - Specific heat capacity at constant volume\n",
- "Y = Cp_0/Cv_0;\t\t\t# Index of expansion\n",
- "\n",
- "\t\t\t# Assuming 100 % efficiency,for reversible and adiabatic process the final temperature is given by\n",
- "\t\t\t# P*V**(Y) = constant or, P*((R*T)/P)**(Y) = constant\n",
- "T_2 = ((P_1/P_2)**((1-Y)/Y))*T_1;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# Since at final temperature the value of heat capacity ratio would have changed \n",
- "\t\t\t# So let us determine Y at mean temperature and then calculating final temperature\n",
- "T_mean = (T_1 + T_2)/2;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# At T_mean,as reported in the book\n",
- "Cp_0_new = 9.153;\t\t\t#[cal/mol-K]\n",
- "Cv_0_new = Cp_0_new - R;\t\t\t#[cal/mol-K]\n",
- "Y_new = Cp_0_new/Cv_0_new;\n",
- "T_2_new = T_1*((P_1/P_2)**((1-Y_new)/Y_new));\t\t\t#[K]\n",
- "\n",
- "\t\t\t# The enthalpy change is given by \n",
- "\n",
- "def f23(T): \n",
- "\t return 4.750+1.200*10**(-2)*T+0.3030*10**(-5)*T**(2)-2.630*10**(-9)*T**(3)\n",
- "\n",
- "delta_H = quad(f23,T_1,T_2_new)[0]\n",
- "\n",
- "\n",
- "\t\t\t#For adiabatic process\n",
- "W = - delta_H;\t\t\t#[cal/mol]\n",
- "\t\t\t# Now actual work done on the system is given by \n",
- "W_a = W/eff;\t\t\t#[cal/mol]\n",
- "\n",
- "\t\t\t# Since the actual process is adiabatic the work done is change in negative of enthalpy\n",
- "\t\t\t# Therefore actual change in enthalpy is - W_a, or\n",
- "\t\t\t# - W_a = 4.750*(T_2-T_1) + (1.2*10**(-2)/2)*(T_2**(2)-T_1**(2)) + (0.3030*10**(-5)/3)*(T_2**(3)-T_1**(3)) - (2.63*10**(-9)/4)*(T_2***(4)-T_1**(4));\n",
- "\t\t\t# Solving for T_2 in the above equation\n",
- "def f1(T_2_prime): \n",
- "\t return 4.750*(T_2_prime-T_1)+((1.2*10**(-2))/2)*(T_2_prime**(2)-T_1**(2))+((0.3030*10**(-5))/3)*(T_2_prime**(3)-T_1**(3))-((2.63*10**(-9))/4)*(T_2_prime**(4)-T_1**(4))+W_a\n",
- "T_2_prime=fsolve(f1,100)\n",
- "\n",
- "print \" The required work is %f cal/mol\"%(W_a);\n",
- "print \" The discharge temperature of methane is %f K\"%(T_2_prime);\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The required work is -1254.158148 cal/mol\n",
- " The discharge temperature of methane is 427.374758 K\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.13 Page Number : 164"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 10;\t\t\t#[bar] - Initial pressure\n",
- "T_1 = 500 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 2;\t\t\t#[psia] - Final pressure\n",
- "P_2 = P_2/14.5;\t\t\t#[bar]\n",
- "P_2 = P_2*10**(2);\t\t\t#[kPa]\n",
- "m = 1.8;\t\t\t#[kg/s] - Mass flux\n",
- "eff = 0.8;\t\t\t# Efficiency\n",
- "\n",
- "\t\t\t# At state 1, from steam table\n",
- "H_1 = 3478.5;\t\t\t#[kJ/kg]\n",
- "S_1 = 7.7622;\t\t\t#[kJ/kg-K]\n",
- "S_2 = S_1;\t\t\t# Adiabatic process\n",
- "\n",
- "\t\t\t# From saturated steam table at 10 kPa\n",
- "S_liq_1 = 0.6493;\t\t\t#[kJ/kg-K]\n",
- "S_vap_1 = 8.1502;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t# From saturated steam table at 15 kPa\n",
- "S_liq_2 = 0.7549;\t\t\t#[kJ/kg-K]\n",
- "S_vap_2 = 8.0085;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# Threfore at P_2 \n",
- "S_liq = S_liq_1 + ((S_liq_2-S_liq_1)/(15-10))*(P_2-10);\n",
- "S_vap = S_vap_1 + ((S_vap_2-S_vap_1)/(15-10))*(P_2-10);\n",
- "\n",
- "\t\t\t# The dryness fraction at exit state is\n",
- "x_2 = (S_1-S_liq)/(S_vap-S_liq);\n",
- "\t\t\t# The enthalpy at exit to be determined. At 10 kPa\n",
- "H_liq_1 = 191.83;\t\t\t#[kJ/kg]\n",
- "H_vap_1 = 2584.7;\t\t\t#[kJ/kg]\n",
- "\t\t\t# At 15 kPa\n",
- "H_liq_2 = 225.94;\t\t\t#[kJ/kg]\n",
- "H_vap_2 = 2599.1;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Therfore at P_2\n",
- "H_liq = H_liq_1 + ((H_liq_2-H_liq_1)/(15-10))*(P_2-10);\n",
- "H_vap = H_vap_1 + ((H_vap_2-H_vap_1)/(15-10))*(P_2-10);\n",
- "\n",
- "\t\t\t# Enthalpy at state 2\n",
- "H_2_s = H_liq*(1-x_2) + x_2*H_vap;\t\t\t#[kJ/kg]\n",
- "W = m*(H_1 - H_2_s);\t\t\t#[kW]\n",
- "\n",
- "print \" 1).The power output is %f kW\"%(W);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# If the process is 80 % efficient the enthalpy change is\n",
- "\t\t\t# H_1 - H_2_a = eff*(H_1 - H_2_s)\n",
- "H_2_a = H_1 - (0.8*(H_1 - H_2_s));\n",
- "\n",
- "\t\t\t# Now under these conditions temperature and entropy have to be determined. From superheated steam tables,as reported in the book\n",
- "\t\t\t# At 10 kPa and 100 C\n",
- "H_2_1 = 2687.5;\t\t\t#[kJ/kg]\n",
- "S_2_1 = 8.4479;\t\t\t#[kJ/kg-k]\n",
- "\t\t\t# At 10 kPa and 150 C\n",
- "H_2_2 = 2783.0;\t\t\t#[kJ/kg]\n",
- "S_2_2 = 8.6882;\t\t\t#[kJ/kg-k]\n",
- "\t\t\t# At 50 kPa and 100 C\n",
- "H_3_1 = 2682.5;\t\t\t#[kJ/kg]\n",
- "S_3_1 = 7.6947;\t\t\t#[kJ/kg-k]\n",
- "\t\t\t# At 50 kPa and 150 C\n",
- "H_4_1 = 2780.1;\t\t\t#[kJ/kg]\n",
- "S_4_1 = 7.9401;\t\t\t#[kJ/kg-k]\n",
- "\t\t\t# Therefore at P_2 and 100 C\n",
- "H_prime_1 = H_2_1 + ((H_3_1-H_2_1)/(50-10))*(P_2-10);\t\t\t#[kJ/kg]\n",
- "S_prime_1 = S_2_1 + ((S_3_1-S_2_1)/(50-10))*(P_2-10);\t\t\t#[kJ/kg-K]\n",
- "\t\t\t# Therefore at P_2 and 150 C\n",
- "H_prime_2 = H_2_2 + ((H_4_1-H_2_2)/(50-10))*(P_2-10);\t\t\t#[kJ/kg]\n",
- "S_prime_2 = S_2_2 + ((S_4_1-S_2_2)/(50-10))*(P_2-10);\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t# Enthalpy at exit is H_2_a. So at this condition temperature can be nom be determined\n",
- "T_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(150-100) + 100;\t\t\t#[C]\n",
- "\t\t\t# The entropy at exit is\n",
- "S_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(S_prime_2 - S_prime_1) + S_prime_1;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" 2).The entropy at exit is %f kJ/kg-K\"%(S_exit);\n",
- "print \" The temperature of the exit state is %f C\"%(T_exit);\n",
- "\n",
- "print \" The irreversibility is advatageous because the exit steam is superheated and therefore\";\n",
- "print \" the blades of the turbine are not eroded by water droplets which get formed when the process is isentropic\";\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The power output is 1753.346828 kW\n",
- " 2).The entropy at exit is 8.906311 kJ/kg-K\n",
- " The temperature of the exit state is 100.002552 C\n",
- " The irreversibility is advatageous because the exit steam is superheated and therefore\n",
- " the blades of the turbine are not eroded by water droplets which get formed when the process is isentropic\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.14 Page Number : 166"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 6;\t\t\t#[MPa] - Initial pressure\n",
- "T_1 = 500 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 10;\t\t\t#[kPa] - Final pressure\n",
- "out_qlty = 0.9;\t\t\t# Output quality\n",
- "\n",
- "\t\t\t# At 6 MPa and 500 C, from steam table as reported in the book\n",
- "H_1 = 3422.2;\t\t\t#[kJ/kg]\n",
- "S_1 = 6.8803;\t\t\t#[kJ/kg-K]\n",
- "S_2 = S_1;\t\t\t# Adiabatic reversible conditions\n",
- "\t\t\t# At 10 kPa saturated\n",
- "H_liq = 191.83;\t\t\t#[kJ/kg]\n",
- "H_vap = 2584.7;\t\t\t#[kJ/kg]\n",
- "S_liq = 0.6493;\t\t\t#[kJ/kg-K]\n",
- "S_vap = 8.1502;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The dryness fraction is given by \n",
- "x = (S_1-S_liq)/(S_vap-S_liq);\n",
- "\n",
- "\t\t\t# Now the exit enthalpy is given by\n",
- "H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg]\n",
- "W = - (H_2 - H_1);\t\t\t#[kJ/kg] - Under isentropic conditions\n",
- "\n",
- "\t\t\t# We know that, delta_S = q/T_b + S_gen\n",
- "\t\t\t# Since delta_S = 0, therefore under isentropic conditions\n",
- "S_gen = 0;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t# Now for output quality 0.9\n",
- "H_2_a = H_liq*(1-out_qlty) + out_qlty*H_vap;\t\t\t#[kJ/kg]\n",
- "S_2_a = S_liq*(1-out_qlty) + out_qlty*S_vap;\t\t\t#[kJ/kg]\n",
- "W_a = - (H_2_a - H_1);\t\t\t#[kJ/kg]\n",
- "delta_S_a = S_2_a - S_1;\t\t\t#[kJ/kg-k]\n",
- "\t\t\t# Again, delta_S = q/T_b + S_gen\n",
- "\t\t\t# Since q = 0, therefore under isentropic conditions\n",
- "S_gen_a = delta_S_a;\t\t\t#[kJ/kg-K\n",
- "\t\t\t# Now efficiency is given by eff = delta_H_a/delta_H_s\n",
- "eff = W_a/W;\n",
- "\n",
- "print \" For output quality = 0.9\";\n",
- "print \" The work output per unit mass is %f kJ/kg\"%(W_a);\n",
- "print \" The entropy generation is given by S_gen = %f kJ/kg-K\"%(S_gen_a);\n",
- "print \" The efficiency with respect to reversible adiabatic case is given by eff = %f\"%(eff);\n",
- "\n",
- "\t\t\t# Now for output quality 1\n",
- "out_qlty_1 = 1;\n",
- "H_2_a_1 = H_liq*(1-out_qlty_1) + out_qlty_1*H_vap;\t\t\t#[kJ/kg]\n",
- "S_2_a_1 = S_liq*(1-out_qlty_1) + out_qlty_1*S_vap;\t\t\t#[kJ/kg]\n",
- "W_a_1 = - (H_2_a_1 - H_1);\t\t\t#[kJ/kg]\n",
- "delta_S_a_1 = S_2_a_1 - S_1;\t\t\t#[kJ/kg-k]\n",
- "\t\t\t# Again, delta_S = q/T_b + S_gen\n",
- "\t\t\t# Since q = 0, therefore under isentropic conditions\n",
- "S_gen_a_1 = delta_S_a_1;\t\t\t#[kJ/kg-K\n",
- "\t\t\t# Now efficiency is given by eff = delta_H_a/delta_H_s\n",
- "eff_1 = W_a_1/W;\n",
- "\n",
- "print \" For output quality = 1.0\";\n",
- "print \" The work output per unit mass is %f kJ/kg\"%(W_a_1);\n",
- "print \" The entropy generation is given by S_gen = %f kJ/kg-K\"%(S_gen_a_1);\n",
- "print \" The efficiency with respect to reversible adiabatic case is given by eff = %f\"%(eff_1);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " For output quality = 0.9\n",
- " The work output per unit mass is 1076.787000 kJ/kg\n",
- " The entropy generation is given by S_gen = 0.519810 kJ/kg-K\n",
- " The efficiency with respect to reversible adiabatic case is given by eff = 0.866551\n",
- " For output quality = 1.0\n",
- " The work output per unit mass is 837.500000 kJ/kg\n",
- " The entropy generation is given by S_gen = 1.269900 kJ/kg-K\n",
- " The efficiency with respect to reversible adiabatic case is given by eff = 0.673983\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.15 Page Number : 168"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 3.;\t\t\t#[bar] - Initial pressure\n",
- "T_1 = 150. + 273.15;\t\t\t#[K] - Initial temperature\n",
- "Vel_1 = 90.;\t\t\t#[m/s] - Initial velocity\n",
- "P_2 = 1.;\t\t\t#[bar] - Final pressure\n",
- "eff = 0.95;\t\t\t# Adiabatic effciciency of the nozzle\n",
- "R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
- "\n",
- "\t\t\t# At 3 bar and 150 C, from steam table\n",
- "S_1 = 7.0778;\t\t\t#[kJ/kg-K]\n",
- "H_1 = 2761.0;\t\t\t#[kJ/kg]\n",
- "S_2 = S_1;\t\t\t# \n",
- "\n",
- "\t\t\t# At 1 bar saturated\n",
- "S_liq = 1.3026;\t\t\t#[kJ/kg-K]\n",
- "S_vap = 7.3594;\t\t\t#[kJ/kg-K]\n",
- "H_liq = 417.46;\t\t\t#[kJ/kg]\n",
- "H_vap = 2675.5;\t\t\t#[kJ/kg]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The dryness factor of exit steam can be determined as\n",
- "x = (S_1-S_liq)/(S_vap-S_liq);\n",
- "\t\t\t# Enthalpy of exit steam is given by \n",
- "H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg]\n",
- "delta_H_s = H_2 - H_1;\t\t\t#[kJ/kg] - Enthalpy change\n",
- "delta_H_a = eff*delta_H_s;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# Assuming no heat exchange with surroundings and since no work is done\n",
- "\t\t\t# delta_H + (delta_V**(2))/2 = 0\n",
- "delta_Vel_square = 2*(-delta_H_a)*1000;\t\t\t#[m**(2)/s**(2)]\n",
- "Vel_2 = (delta_Vel_square + Vel_1**(2))**(1./2);\t\t\t#[m/s]\n",
- "\n",
- "print \" 1).The final velocity when fluid is steam) is %f m/s\"%(Vel_2);\n",
- "\n",
- "\t\t\t# (2)\n",
- "Y = 1.4;\t\t\t# Index of expansion\n",
- "Cp_0 = (Y*R)/(Y-1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
- "\t\t\t# The final temperature has to be determined such that entropy change is zero. Under isentropic conditions\n",
- "\t\t\t# P_1**(1-Y)*T_1**(Y) = P_2**(1-Y)*T_2**(Y)\n",
- "T_2 = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K]\n",
- "delta_H_s_2 = Cp_0*(T_2 - T_1);\t\t\t#[J/mol]\n",
- "delta_H_a_2 = eff*delta_H_s_2;\t\t\t#[J/mol]\n",
- "delta_H_a_2 = (delta_H_a_2*1000)/28.84;\t\t\t#[J/kg]\n",
- "\n",
- "delta_Vel_square_2 = 2*(-delta_H_a_2);\t\t\t#[m**(2)/s**(2)]\n",
- "Vel_2_2 = (delta_Vel_square_2 + Vel_1**(2))**(1./2);\t\t\t#[m/s]\n",
- "\n",
- "print \" 2).The final velocity when fluid is air which behaves as an ideal gas) is %f m/s\"%(Vel_2_2);\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The final velocity when fluid is steam) is 608.291583 m/s\n",
- " 2).The final velocity when fluid is air which behaves as an ideal gas) is 476.065890 m/s\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.16 Page Number : 169"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P_1 = 300.;\t\t\t#[kPa] - Initial pressure\n",
- "T_1 = 450.;\t\t\t#[K] - Initial temperature\n",
- "Vel_1 = 90.;\t\t\t#[m/s] - Initial velocity\n",
- "P_2 = 180.;\t\t\t#[kPa] - Final pressure\n",
- "eff = 0.95;\t\t\t# Adiabatic effciciency of the nozzle\n",
- "R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
- "Cp = 5.19;\t\t\t#[kJ/kg-K] - Specific heat capacity at constant pressure\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(a)\n",
- "\t\t\t# Exit velocity is highest when drop in enthalpy is highest or when isentropic conditions are maintained\n",
- "\n",
- "Mol_wt_He = 4;\t\t\t#[g/mol] - Molecular weight of helium\n",
- "R_He = R/Mol_wt_He;\t\t\t# 'R' for helium\n",
- "Y = Cp/(Cp - R_He);\n",
- "\n",
- "\t\t\t# Now temperature at exit to be determined\n",
- "T_2s = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K]\n",
- "delta_H_2s = Cp*(T_2s - T_1);\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# Since no work is done and heat exchange is zero,from first law we get\n",
- "\t\t\t# delta_H + delta_Vel**(2)/2 = 0\n",
- "delta_Vel_square = 2*(-delta_H_2s)*1000;\t\t\t#[m**(2)/s**(2)]\n",
- "Vel_2 = (delta_Vel_square)**(1./2);\t\t\t#[m/s] - ( as Vel_1 << Vel_2)\n",
- "\n",
- "print \" a).The maximum exit velocity is %f m/s\"%(Vel_2);\n",
- "\n",
- "\t\t\t#(b)\n",
- "T_2a = 373;\t\t\t#[K] - Measured temperature of helium\n",
- "delta_H_a = Cp*(T_2a - T_1);\t\t\t#[kJ/kg]\n",
- "delta_Vel_square_a = 2*(-delta_H_a)*1000;\t\t\t#[m**(2)/s**(2)]\n",
- "Vel_2a = (delta_Vel_square_a)**(1./2);\t\t\t#[m/s] - ( as Vel_1 << Vel_2a)\n",
- "\n",
- "print \" b).The actual exit velocity is %f m/s\"%(Vel_2a);\n",
- "\n",
- "\t\t\t#(c)\n",
- "delta_S_sys = Cp*math.log(T_2a/T_1) - R_He*math.log(P_2/P_1);\n",
- "\t\t\t# we know that delta_S_sys = q/T_b + S_gen and since q = 0, therfore\n",
- "S_gen = delta_S_sys;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" c).The increasse in entropy per unit mass is %f kJ/kg-K\"%(S_gen);\n",
- "\n",
- "\t\t\t# The source of irreversibility is friction in the nozzle.\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The maximum exit velocity is 929.607346 m/s\n",
- " b).The actual exit velocity is 894.013423 m/s\n",
- " c).The increasse in entropy per unit mass is 0.087748 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.17 Page Number : 170"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 1;\t\t\t#[bar] - Initial pressure\n",
- "T_1 = 150 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "V_2 = 0.28;\t\t\t#[m**(3)/kg] - Final specific volume\n",
- "T_2 = T_1;\t\t\t#[K] - Isothermal process\n",
- "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
- "\n",
- "\t\t\t# At 1 bar and 150 C, from steam table\n",
- "S_1 = 7.6134;\t\t\t#[kJ/kg-K]\n",
- "H_1 = 2776.4;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# At 150 C saturated\n",
- "V_liq = 0.001091;\t\t\t#[m**(3)/kg]\n",
- "V_vap = 0.3928;\t\t\t#[m**(3)/kg]\n",
- "H_liq = 632.2;\t\t\t#[kJ/kg]\n",
- "H_vap = 2746.5;\t\t\t#[kJ/kg]\n",
- "S_liq = 1.8418;\t\t\t#[kJ/kg-K]\n",
- "S_vap = 6.8379;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The dryness factor of exit steam can be determined as\n",
- "x = (V_2 - V_liq)/(V_vap - V_liq);\n",
- "S_2 = S_liq*(1-x) + x*S_vap;\t\t\t#[kJ/kg-K] -Entropy \n",
- "H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg] -Enthalpy \n",
- "delta_H = H_2 - H_1;\t\t\t#[kJ/kg] - Enthalpy change\n",
- "delta_S = S_2 - S_1;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# Since the compression is reversible\n",
- "q = T_1*delta_S;\t\t\t#[kJ/kg] - Heat transfer\n",
- "\t\t\t# From first law q - W = delta_H\n",
- "W = q - delta_H;\t\t\t#[kJ/kg]\n",
- "\n",
- "print \" 1).The amount of heat transfer when fluid is steam) is %f kJ/kg\"%(q)\n",
- "print \" The amount of work transfer when fluid is steam) is %f kJ/kg\"%(W)\n",
- "\n",
- "\t\t\t#(2)\n",
- "V_2 = V_2*(28.84/1000);\t\t\t#[m**(3)/mol] - Molar volume at exit\n",
- "\t\t\t# Pressure at exit is given by \n",
- "P_2 = ((R*T_2)/V_2);\t\t\t#[N/m**(2)]\n",
- "P_2 = P_2*10**(-5);\t\t\t#[bar]\n",
- "\n",
- "\t\t\t# Entropy change is given by, delta_S_2 = Cp*math.log(T_2/T_1) - R*math.log(P_2/P_1), but since T_1 = T_2, therfore\n",
- "delta_S_2 = - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
- "\n",
- "q_2 = T_1*delta_S_2;\t\t\t#[J/mol] - Heat change\n",
- "q_2 = q_2/28.84;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# Enthalpy change is given by, delta_H_2 = Cp*(T_2 - T_1) = 0 (as T_1 = T_2)\n",
- "delta_H_2 = 0;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# From first law q - W = delta_H, therefore\n",
- "W_2 = q_2 - delta_H_2;\t\t\t#[kJ/kg]\n",
- "\n",
- "print \" 2).The amount of heat transfer when fluid is ideal gas) is %f kJ/kg\"%(q_2)\n",
- "print \" The amount of work transfer when fluid is ideal gas) is %f kJ/kg\"%(W_2)\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The amount of heat transfer when fluid is steam) is -936.947741 kJ/kg\n",
- " The amount of work transfer when fluid is steam) is -298.195149 kJ/kg\n",
- " 2).The amount of heat transfer when fluid is ideal gas) is -179.526401 kJ/kg\n",
- " The amount of work transfer when fluid is ideal gas) is -179.526401 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.18 Page Number : 171"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 7*10**(5);\t\t\t#[Pa] - Initial pressure\n",
- "T_1 = 95 + 273.15;\t\t\t#[K] - Initial temperature\n",
- "P_2 = 3.5*10**(5);\t\t\t#[Pa] - Final pressure\n",
- "dia = 15*10**(-2);\t\t\t#[m] - Diameter of pipe\n",
- "m = 2;\t\t\t#[kg/s] - Mass flow rate\n",
- "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
- "Y = 1.4;\t\t\t# Index of expansion\n",
- "Cp_0 = (R*Y)/(Y-1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
- "Cp_0 = (Cp_0/28.84)*1000;\t\t\t#[J/kg-K]\n",
- "rho_1 = 6.6;\t\t\t#[kg/m**(3)] - Density\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# velocity before throttling is to be determined m = rho*Vol*Area\n",
- "V_1 = (R*T_1)/P_1;\t\t\t#[m**(3)/mol] - Specific volume\n",
- "V_1 = (V_1/28.84)*1000;\t\t\t#[m**(3)/kg]\n",
- "Vel_1 = m/(rho_1*3.14*(dia/2)**(2));\t\t\t#[m/s] - Velocity before throttling\n",
- "\n",
- "\t\t\t# Let the temperature after throttling be T_2, then\n",
- "\t\t\t# V_2 = (((R*T_2)/P_2)/28.84)*1000\n",
- "\t\t\t# Vel_2 = m/(rho_2*Area) = (m*V_2)/(3.14*(dia/2)**(2))\n",
- "\t\t\t# From first law, since q = W = 0, we get\n",
- "\t\t\t# delta_H + (delta_V**(2))/2 = 0\n",
- "\t\t\t# Cp_0*(T_2 - T_1) + ((Vel_2)**(2) - (Vel_1)**(2))/2 = 0\n",
- "\t\t\t#Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)))**(2) - (Vel_1)**(2))/2 = 0\n",
- "\t\t\t# Solving the above equation for T_2, we get\n",
- "def f1(T_2): \n",
- "\t return Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)))**(2) - (Vel_1)**(2))/2\n",
- "T_2 =fsolve(f1,100)\n",
- "\t\t\t# Therefore velocity of air downstream of restriction is given by \n",
- "Vel_2 = ((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)));\t\t\t#[m/s]\n",
- "\n",
- "print \" The velocity of air downstream of restriction is %f m/s\"%(Vel_2);\n",
- "\n",
- "delta_T = (T_2 - T_1);\n",
- "\t\t\t# Since temperature difference (delta_T) is very small, therefore enthalpy change is also very small\n",
- "\n",
- "\t\t\t# Entropy change is given by, delta_S = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1), but since T_1 and T_2 are almost equal\n",
- "delta_S = - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
- "\n",
- "print \" The change in entropy is %f kJ/mol-k\"%(delta_S);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The velocity of air downstream of restriction is 34.295216 m/s\n",
- " The change in entropy is 5.762826 kJ/mol-k\n"
- ]
- }
- ],
- "prompt_number": 18
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch5_2.ipynb b/Chemical_Engineering_Thermodynamics/ch5_2.ipynb
deleted file mode 100755
index 82489a66..00000000
--- a/Chemical_Engineering_Thermodynamics/ch5_2.ipynb
+++ /dev/null
@@ -1,747 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:beb354ab1f11a4413c580f54f984be6db9b7dd2c39bed82bc1f4874533d75759"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 5 : Exergy"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.1 Page Number : 184"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "T_1 = 500+273.15;\t\t\t#[C] - Condensation temperature\n",
- "T_2 = 250+273.15;\t\t\t#[C] - Temperature at which vaporization takes place.\n",
- "\n",
- "T_3 = 25+273.15;\t\t\t#[C] - Ambient atmospheric temperature.\n",
- "\n",
- "Q = 1;\t\t\t#We are taking a fictitious value of Q, its value is not given.But we need to initialize it wid some value,so we are taking its value as Q=1.\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#The exergy content of the vapour at 500 C,\n",
- "Ex_T_1 = Q*(1-(T_3/T_1));\n",
- "Ex_T_2 = Q*(1-(T_3/T_2));\n",
- "\t\t\t#Therefore,loss in exergy is given by\n",
- "Ex_loss = Ex_T_1 - Ex_T_2;\n",
- "\t\t\t#Fraction of exergy lost due to irreversible process is,\n",
- "Ex_fraction =(Ex_loss/Ex_T_1);\n",
- "\n",
- "# Results\n",
- "print \" The fraction of exergy lost due to irreversible process is %f\"%(Ex_fraction);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The fraction of exergy lost due to irreversible process is 0.299954\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.2 Page Number : 188"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T_1 = 300.;\t\t\t#[K] - Initial temperature.\n",
- "P_1 = 100.;\t\t\t#[kPa] - Initial pressure.\n",
- "T_2 = 500.;\t\t\t#[K] - Final temperature.\n",
- "T_0 = 300.;\t\t\t#[K] - Environment temperature.\n",
- "P_0 = 1.;\t\t\t#[atm] - Environment pressure.\n",
- "R = 8.314;\t\t\t#[J/mol*K]\n",
- "\t\t\t#(Cp_0/R)= 3.626\n",
- "Cp_0 = 3.626*R;\t\t\t#[J/mol-K] - Heat capacity at constant pressure\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1).\n",
- "\t\t\t#The availability change is given by, (phi_1 - phi_2) = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2)\n",
- "\t\t\t#Let us determine the change in internal energy\n",
- "\t\t\t#For ideal gas the molar internal energy change is given by delta_U = Cv_0*(T_2-T_1)\n",
- "\t\t\t#For ideal gas Cp_0 - Cv_0 = R, and therefore\n",
- "Cv_0 = ((Cp_0/R)- 1)*R;\t\t\t#[J/mol-K] - Heat capacity at constant volume\n",
- "delta_U = Cv_0*(T_2-T_1);\t\t\t#[J/mol]\n",
- "\t\t\t#delta_U = -w (from energy balance). Therefore, U1-U2 = -delta_U.\n",
- "\t\t\t#The entropy change of ideal gas is given by\n",
- "\t\t\t#delta_S = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1), but,(P1*V1/T1) = (P1*V1/T1) and therefore (P2/P1) = (T2/T1)\n",
- "delta_S = Cp_0*math.log(T_2/T_1) - R*math.log(T_2/T_1);\t\t\t#[J/mol-K]\n",
- "\t\t\t#The exergy change is given by, (phi_1 - phi_2) = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2)\n",
- "\t\t\t#(V_1 - V_2) = 0, because the tank is rigid and so the volume is constant\n",
- "delta_phi = (-delta_U) - T_0*(-delta_S);\t\t\t#[J/mol]\n",
- "print \" 1).The change in exergy is %f J/mol\"%(delta_phi);\n",
- "\n",
- "\t\t\t#(2).\n",
- "\t\t\t#Entropy change of the system is given by, delta_S_sys = q/T_b + S_gen\n",
- "\t\t\t#Since the system is adiabatic therefore, delta_S_sys = S_gen\n",
- "S_gen = delta_S;\n",
- "\t\t\t#Irreversibility is given by\n",
- "i = T_0*S_gen;\t\t\t#[J/mol]\n",
- "print \" 2).The value of irreversibility is %f J/mol\"%(i);\n",
- "\t\t\t#Irreversibility can also be determined using\n",
- "\t\t\t#i = (W_rev_use - W_use)\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The change in exergy is -1020.722863 J/mol\n",
- " 2).The value of irreversibility is 3345.789937 J/mol\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.3 Page Number : 190"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "# Variables\n",
- "P_1 = 15.;\t\t\t#[bar] - Initial pressure\n",
- "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
- "T_1 = 300.+273.15;\t\t\t#[K] - Initial temperature\n",
- "T_0 = 298.15;\t\t\t#[K]\n",
- "T_R = 1200.;\t\t\t#[K] - Reservoir temerature.\n",
- "P_0 = 1.;\t\t\t#[bar]\n",
- "P_0 = P_0*10**(5);\t\t\t#[Pa]\n",
- "n = 1.;\t\t\t#[mol] - No of moles\n",
- "R = 8.314;\t\t\t#[J/mol*K]\n",
- "Y = 1.4;\t\t\t# - Ratio of heat capacities.\n",
- "Cv_0 = R/(Y-1);\t\t\t#[J/mol-K] - Heat capacity at constant volume\n",
- "Cp_0 = Cv_0 + R;\t\t\t#[J/mol-K] - Heat capacity at constant pressure\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t#V_2 = 2*V_1 and since pressure is constant,we get (V_1/T_1) = (2*V_1/T_1), or, T_2 = 2*T_1.\n",
- "T_2 = 2*T_1;\t\t\t#[K]\n",
- "W = P_1*(((R*T_2)/P_1)-((R*T_1)/P_1));\t\t\t#[J/mol] - Actual work done\n",
- "delta_U = Cv_0*(T_2-T_1);\t\t\t#[J/mol] - Change in internal energy.\n",
- "q = W + delta_U;\t\t\t#[J/mol] - Heat change\n",
- "\t\t\t#Now the availability change is given by, (phi_1 - phi_2) = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2) + q*(1-(T_0/T_R))\n",
- "\t\t\t#delta_S = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1), and P_1 = P_2, Therefore\n",
- "delta_S = Cp_0*math.log(T_2/T_1);\t\t\t#[J/mol-K] - Entropy change.\n",
- "\t\t\t#Substituting expressions for delta_phi calculation. Decrease in availability is given by,\n",
- "delta_phi = (-delta_U) + P_0*(((R*T_1)/P_1)-((R*T_2)/P_1)) - T_0*(-delta_S) + q*(1-(T_0/T_R));\t\t\t#[J/mol]\n",
- "\t\t\t#Actual work done is given by, W = P_1*(V2-V1)\n",
- "\t\t\t#Work done to print lace the atmosphere is given by, W = P_0*(V_2-V_1)\n",
- "\t\t\t#Therefore, W_use = (P_1*(V2-V1) - P_0*(V2-V1))\n",
- "W_use = (P_1-P_0)*(((R*T_2)/P_1)-((R*T_1)/P_1));\t\t\t#[J/mol] - useful work done\n",
- "W_rev_use = delta_phi;\t\t\t# reversible useful work done\n",
- "\t\t\t#Irreversibility is given by,\n",
- "i = W_rev_use - W_use;\t\t\t#[J/mol]\n",
- "print \" a).When the system is confined at constant pressure by a piston and is heated until it's volume is doubled \\n the ireversibility value is %f J/mol\"%(i);\n",
- "\n",
- "\t\t\t#The irreversibility can also be calculated using \n",
- "\t\t\t# i = T_0*S_gen\n",
- "\t\t\t#S_gen = delta_S - (q/T_R)\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t#V2 = 2*V_1 and therefore T_2 = 2*T_1, as P_2 = P_1\n",
- "\t\t\t#Actual work done is same as before\n",
- "\t\t\t#Let work done on stirrer be W_stir. Thus net work done by the system is W - W_stir.Fron energy balance we get,\n",
- "W_stir = W + delta_U;\n",
- "\t\t\t#Initially the exergy is due to that of the system at state 1 and stirrer work,'W_stir' and finally we have the exergy due to system at state 2,the stirrer work is spent,thus availability is given by\n",
- "delta_phi_b = (-delta_U) + P_0*(((R*T_1)/P_1)-((R*T_2)/P_1)) - T_0*(-delta_S) + W_stir;\t\t\t#[J/mol]\n",
- "W_rev_use_b = delta_phi_b;\t\t\t# reversible useful work done\n",
- "W_use_b = W_use;\t\t\t# useful work done\n",
- "\t\t\t#Now the irreversibility is given by,\n",
- "i_b = W_rev_use_b - W_use_b;\t\t\t#[J/mol]\n",
- "print \" b).When the system is confined at constant pressure by a piston and is stirred until it's volume is doubled \\n the ireversibility value is %f J/mol\"%(i_b);\n",
- "\n",
- "\t\t\t#The irreversibility can also be calculated using \n",
- "\t\t\t# i_b = T_0*S_gen\n",
- "\t\t\t#S_gen = delta_S - (q/T_R) and here, q = 0\n",
- "\n",
- "\t\t\t#(c)\n",
- "P_2_c = 10;\t\t\t#[bar] - Final pressure, (Given)\n",
- "P_2_c = P_2_c*10**(5);\t\t\t#[Pa]\n",
- "\t\t\t#(P_1**(1-Y))*(T_1**(Y)) = (P_2**(1-Y))*(T_2**(Y))\n",
- "T_2_c = T_1*((P_1/P_2_c)**((1-Y)/Y));\t\t\t#[K]\n",
- "\t\t\t#Work done is given by, W = -delta_U = -Cv_0*(T_2_c - T_1)\n",
- "W_c = -Cv_0*(T_2_c - T_1);\t\t\t#[J/mol]\n",
- "\t\t\t#The final molar volume is calculated using P_1*V_1**(Y) = P_2*V_2**(Y)\n",
- "\t\t\t#V_2 = V_1*((P_1/P_2_c)**(1/Y))\n",
- "V_1 = (R*T_1)/P_1;\t\t\t#[cubic metre/mol] - Initial molar volume\n",
- "V_2 = V_1*((P_1/P_2_c)**(1/Y));\t\t\t#[cubic metre/mol] - Final molar volume\n",
- "\t\t\t#Now let us determine the work done to print lace the atmosphere,\n",
- "W_atm_c = P_0*(V_2 - V_1);\t\t\t#[J/mol] - work done to print lace the atmosphere\n",
- "\t\t\t#Thus useful work is given by,\n",
- "W_use_c = W - W_atm_c;\t\t\t#[J/mol] - useful work done\n",
- "\t\t\t#Here delta_S = 0,for reversible adiabatic process.Therefore,\n",
- "W_rev_use_c = W_use_c;\n",
- "\t\t\t#Now finally the irreversibility is given by,\n",
- "i_c = W_rev_use_c - W_use_c;\t\t\t#[J/mol]\n",
- "print \" c).When the system expands reversibly and adiabatically behind a piston \\n the ireversibility value is %f J/mol\"%(i_c);\n",
- "\n",
- "\t\t\t#(d)\n",
- "\t\t\t#Here temperature is constant,but V_2 = 2*V_1, therefore P_2 = P_1/2\n",
- "V_2_d = 2*V_1;\n",
- "P_2_d = P_1/2;\n",
- "\t\t\t#Under isothermal conditions work done is\n",
- "W_d = R*T_1*math.log(V_2_d/V_1);\t\t\t#[J/mol]\n",
- "\t\t\t#Work done to print lace the atmosphere is given by,\n",
- "W_atm_d = P_0*(V_2_d - V_1);\t\t\t#[J/mol] - work done to print lace the atmosphere\n",
- "\t\t\t#Thus useful work is given by,\n",
- "W_use_d = W_d - W_atm_d;\t\t\t#[J/mol] - useful work done\n",
- "delta_U_d = 0;\t\t\t#isothermal conditions\n",
- "q_d = W_d;\t\t\t# since, delta_U_d = 0\n",
- "\t\t\t#delta_S_d = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1), and T_1 = T_2, Therefore\n",
- "delta_S_d = -R*math.log(P_2_d/P_1);\t\t\t#[J/mol-K] - Entropy change\n",
- "\t\t\t#The reversible useful work is given by,\n",
- "W_rev_use_d = P_0*(V_1 - V_2_d) - T_0*(-delta_S_d) + q_d*(1-(T_0/T_R));\t\t\t#[J/mol] - Reversible useful work done.\n",
- "\t\t\t#The irreversibility is given by,\n",
- "i_d = W_rev_use_d - W_use_d;\t\t\t#[J/mol]\n",
- "print \" d).When the system expands reversibly and isothermally behind a piston until it's volume is doubled \\n the ireversibility value is %f J/mol\"%(i_d);\n",
- "\n",
- "\t\t\t#(e)\n",
- "P_2_e = 10;\t\t\t#[bar] - Final pressure, (Given)\n",
- "P_2_e = P_2_e*10**(5);\t\t\t#[Pa]\n",
- "\t\t\t#During the expansion of an ideal gas in into vacuum the temperature of the gas remains the same,\n",
- "T_2_e = T_1;\t\t\t# Final temperature\n",
- "\t\t\t#Since boundary of the system is fixed so no net work is done, W = 0 and thus\n",
- "W_use_e = 0;\t\t\t#[J/mol] - Useful work done\n",
- "\t\t\t#Here, delta_U = 0,as temperature is same and\n",
- "\t\t\t#(V_1-V_2) = 0,as for overall system there is no change in volume\n",
- "delta_S_e = - R*math.log(P_2_e/P_1);\t\t\t#[J/mol-K] - Entropy change\n",
- "\t\t\t#The reversible useful work is given by,\n",
- "W_rev_use_e = - T_0*(-delta_S_e);\t\t\t#[J/mol] - Reversible useful work done.\n",
- "\t\t\t#The irreversibility is given by,\n",
- "i_e = W_rev_use_e - W_use_e;\t\t\t#[J/mol]\n",
- "print \" e).When the system expands adiabatically into an adjacent chamber \\n the ireversibility value is %f J/mol\"%(i_e);\n",
- "\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).When the system is confined at constant pressure by a piston and is heated until it's volume is doubled \n",
- " the ireversibility value is 1869.841742 J/mol\n",
- " b).When the system is confined at constant pressure by a piston and is stirred until it's volume is doubled \n",
- " the ireversibility value is 6013.652646 J/mol\n",
- " c).When the system expands reversibly and adiabatically behind a piston \n",
- " the ireversibility value is 0.000000 J/mol\n",
- " d).When the system expands reversibly and isothermally behind a piston until it's volume is doubled \n",
- " the ireversibility value is 897.537657 J/mol\n",
- " e).When the system expands adiabatically into an adjacent chamber \n",
- " the ireversibility value is 1005.074654 J/mol\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.4 Page Number : 194"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 150+273.15;\t\t\t#[K] - Initial temperature.\n",
- "m = 4.6;\t\t\t#[kg] - mass of water\n",
- "P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
- "Q = 11000;\t\t\t#[kJ] - Heat transferred to the system.\n",
- "T_R = 600+273.15;\t\t\t#[K] - Temperature of the reservior.\n",
- "T_0 = 298;\t\t\t#[K] - Temperature of the environment\n",
- "P_0 = 100;\t\t\t#[kPa] - Pressure of the environment\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#(1)\n",
- "\t\t\t#The entropy change of an isothermal system undergoing an internally reversible process is given by,\n",
- "delta_S_t = (Q/T_1);\t\t\t#[kJ] - Entropy change\n",
- "delta_S = delta_S_t/m;\t\t\t#[kJ/kg-K] - \n",
- "\n",
- "\t\t\t#At 150 C,it has been reported in the book that, P_sat - 0.4758 kPa, V_liq = 0.001091 m**(3)/kg, U_liq = 631.68 kJ/kg, S_liq = 1.8418 kJ/kg-K, S_vap = 6.8379 kJ/kg-K\n",
- "V_1 = 0.001091;\t\t\t#[m**(3)/kg] - initial specific volume\n",
- "U_1 = 631.68;\t\t\t#[kJ/kg] - initial specific internal energy\n",
- "S_1 = 1.8418;\t\t\t#[kJ/kg-K] - initial entropy\n",
- "\t\t\t#The initial state of the water is a compressed liquid state,and S_1 is therefore equal to the entropy of the saturated liquid of the saturated liquid at the same temperature.\n",
- "S_2 = S_1 + delta_S;\t\t\t#[kJ/kg-K] - Final entropy\n",
- "\n",
- "\t\t\t#At the final state the temperature is 150 C and S = 7.499 kJ/kg-K which is more than S_vap therefore it is superheated steam.\n",
- "S_final = 7.494;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t#At 150 C, and 0.1 MPa: V = 1.9364 m**(3)/kg, U = 2582.8 kJ/kg, S = 7.6134 kJ/kg-K\n",
- "\t\t\t#At 150 C, and 0.2 MPa: V = 0.9596 m**(3)/kg, U = 2576.9 kJ/kg, S = 7.2795 kJ/kg-K\n",
- "U_t_1 = 2582.8;\t\t\t#[kJ/kg] - Internal energy\n",
- "U_t_2 = 2576.9;\t\t\t#[kJ/kg]\n",
- "V_t_1 = 1.9364;\t\t\t#[m**(3)/kg] - Specific volume\n",
- "V_t_2 = 0.9596;\t\t\t#[m**(3)/kg]\n",
- "S_t_1 = 7.6134;\t\t\t#[kJ/kg-K] - Entropy\n",
- "S_t_2 = 7.2795;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t#The pressure at exit is given by,\n",
- "P_2 = ((S_final - S_t_1)/(S_t_2 - S_t_1))*(0.2 - 0.1) + 0.1;\t\t\t#[Mpa] - Final pressure\n",
- "\t\t\t#At final state\n",
- "U_2 = U_t_1 + (U_t_2 - U_t_1)*((S_final - S_t_1)/(S_t_2 - S_t_1));\t\t\t#[kJ/kg] - Final specific internal energy\n",
- "V_2 = V_t_1 + (V_t_2 - V_t_1)*((S_final - S_t_1)/(S_t_2 - S_t_1));\t\t\t#[m**(3)/kg] - Final specific volume\n",
- "\n",
- "q = Q/m;\t\t\t#[kJ/kg] - Heat supplied per unit kg of mass.\n",
- "W_rev_use = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2) + q*(1 - (T_0/T_R));\t\t\t#[kJ/kg] - Reversible useful work done.\n",
- "\n",
- "\t\t\t#Now let us calculate the actual work done. We know q - W = delta_U, therefore\n",
- "W = q - (U_2 - U_1);\t\t\t#[kJ/kg] - Work done\n",
- "W_use = W - P_0*(V_2 - V_1);\t\t\t#[kJ/kg]\n",
- "i = W_rev_use - W_use;\t\t\t#[kJ/kg] - Irreversibility\n",
- "\t\t\t#Since the system contains 4.6 g therefore, \n",
- "W_use_new = W_use*m;\t\t\t#[kJ]\n",
- "W_rev_use_new = W_rev_use*m;\t\t\t#[kJ]\n",
- "I = W_rev_use_new - W_use_new;\t\t\t#[kJ]\n",
- "\n",
- "# Results\n",
- "print \" 1).The useful work obtained is %f kJ\"%(W_use_new);\n",
- "print \" 2).The reversible usefuk work done is %f kJ\"%(W_rev_use_new);\n",
- "print \" 3).The irreversibility is %f kJ\"%(I);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The useful work obtained is 1304.987050 kJ\n",
- " 2).The reversible usefuk work done is 5297.425775 kJ\n",
- " 3).The irreversibility is 3992.438725 kJ\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.5 Page Number : 197"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 700+273.15;\t\t\t#[K] - Initial temperature.\n",
- "P_1 = 12;\t\t\t#[MPa] - Initial pressure\n",
- "P_2 = 0.6;\t\t\t#[MPa] - Final pressure\n",
- "\t\t\t#At 12 MPa and 700 C,\n",
- "H_1 = 3858.4;\t\t\t#[kJ/kg] - initial enthalpy\n",
- "S_1 = 7.0757;\t\t\t#[kJ/kg-K] - initial entropy\n",
- "\n",
- "\t\t\t#At 0.6 MPa and 200 C,\n",
- "H_2 = 2850.1;\t\t\t#[kJ/kg]\n",
- "S_2 = 6.9673;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t#At 0.6 MPa and 250 C,\n",
- "H_3 = 2957.2;\t\t\t#[kJ/kg]\n",
- "S_3 = 7.1824;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t#At 0.6 MPa and 300 C,\n",
- "H_4 = 3061.6;\t\t\t#[kJ/kg]\n",
- "S_4 = 7.3732;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t#In the case of ideal turbine the entropy change does not take place,therefore the exit conditions are\n",
- "P_exit = P_2;\t\t\t#[MPa] - exit pressure\n",
- "T_exit = ((S_1 - S_2)/(S_3 - S_2))*(250 - 200) + 200;\t\t\t#[C] - exit temperature\n",
- "H_exit = ((S_1 - S_2)/(S_3 - S_2))*(H_3 - H_2) + H_2;\t\t\t#[kJ/kg] - exit enthalpy\n",
- "\n",
- "\t\t\t#Snce it is a flow pocess,therfore\n",
- "\t\t\t#W_rev = H_1 - H_exit - T_0*(S_1 - S_2)\n",
- "\t\t\t#As S_1 = S_2,the above equation becomes\n",
- "W_rev_1 = H_1 - H_exit;\t\t\t#[kJ/kg] - reversible work done\n",
- "\n",
- "\t\t\t#From the first law the actual work done can be calculated using, delta_H = q - W\n",
- "\t\t\t#Since the turbine does not exchange heat,therefore W = - delta_H.\n",
- "W_1 = - (H_exit - H_1);\t\t\t#[kJ/kg]\n",
- "\n",
- "print \" 1).The reversible work done is %f kJ/kg\"%(W_1);\n",
- "print \" And since the maximum work is same as the actual work ,therefore irreversibility is zero\"\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# Variables\n",
- "T_0 = 298.15;\t\t\t#[K] - Environment temperature\n",
- "P_0 = 1;\t\t\t#[atm] - Environment pressure\n",
- "adi_eff = 0.88;\t\t\t#adiabatc efficiency\n",
- "\n",
- "\t\t\t#(H_1 - H_exit_actual)/(H_1 - H_exit) = 0.88, therefore\n",
- "H_exit_actual = H_1 - 0.88*(H_1 - H_exit);\t\t\t# - Actual exit enthalpy\n",
- "\n",
- "\t\t\t#Now two properties i.e pressure = 0.6 MPa and enthalpy = H_exit_actual is fixed at the exit. The exit temperature is given by,\n",
- "T_exit_actual = ((H_exit_actual - H_3)/(H_4 - H_3))*(300 - 250) + 250;\t\t\t#[C]\n",
- "S_exit_actual = ((H_exit_actual - H_3)/(H_4 - H_3))*(S_4 - S_3) + S_3;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Now reversible work done is given by,\n",
- "W_rev_2 = H_1 - H_exit_actual - T_0*(S_1 - S_exit_actual);\t\t\t#[kJ/kg]\n",
- "print \" 2).The reversible work done is %f kJ/kg\"%(W_rev_2);\n",
- "\n",
- "\t\t\t#The actual work is given by the first law,\n",
- "W_2 = H_1 - H_exit_actual;\t\t\t#[kJ/kg] - Actual work done\n",
- "i = W_rev_2 - W_2;\t\t\t#[kJ/kg] - irreversibility\n",
- "print \" The value of irreversibility is %f kJ/kg\"%(i);\n",
- "\n",
- "\t\t\t#The irreversibility can also be determined using\n",
- "\t\t\t# i = T_0*S_gen, and S_gen is given by\n",
- "\t\t\t# S_gen = (q/T_R) - delta_S\n",
- "\n",
- "\t\t\t#The second law efficiency of the turbine is actual work done divided by reversible work,therefore\n",
- "sec_eff = W_2/W_rev_2;\n",
- "print \" The second law efficiency of the turbine is %f\"%(sec_eff);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The reversible work done is 954.326778 kJ/kg\n",
- " And since the maximum work is same as the actual work ,therefore irreversibility is zero\n",
- " 2).The reversible work done is 905.072590 kJ/kg\n",
- " The value of irreversibility is 65.265025 kJ/kg\n",
- " The second law efficiency of the turbine is 0.927890\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.6 Page Number : 198"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_1 = 8.;\t\t\t#[bar] - Initial pressure\n",
- "T_1 = 93. + 273.15;\t\t\t#[C] - Initial temperature\n",
- "V_1 = 100.;\t\t\t#[m/s] - Initial velocity\n",
- "P_2 = 1.25;\t\t\t#[bar] - Exit pressure\n",
- "T_2 = 27. + 273.15;\t\t\t#[C] - Exit temperature\n",
- "V_2 = 60.;\t\t\t#[m/s] - Exit velocity \n",
- "Y = 1.4;\t\t\t#Ratio of specific heat capacities\n",
- "T_0 = 298.15;\t\t\t#[K] - surrounding temperature\n",
- "P_0 = 1.;\t\t\t#[bar] - surrounding pressure\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Gas constant\n",
- "Cp_0 = (R*Y)/(Y-1);\t\t\t#[J/mol-K] - Heat capacity at constant pressure\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Since the amount of heat transfer is negligible,therefore from first law the actual work done is given by,\n",
- "\t\t\t#W = delta_H + (delta_V_square)/2\n",
- "delta_H = Cp_0*(T_2 - T_1);\t\t\t#[J/mol] - enthalpy change\n",
- "delta_H = (delta_H/28.84);\t\t\t#[kJ/kg] - (1 mole = 28.84 g).\n",
- "delta_V_square = V_2**(2) - V_1**(2);\n",
- "\n",
- "W = - delta_H - ((delta_V_square)/2)/1000;\t\t\t#[kJ/kg] - Actual work done\n",
- "print \" The actual work done is %f kJ/kg\"%(W);\n",
- "\n",
- "\t\t\t#Now let us calculate the maximum work that can be obtained\n",
- "\t\t\t#W_rev = (H_1 + (V_1**(2))/2) - (H_2 + (V_2**(2))/2) - T_0*(S_1 - S_2)\n",
- "delta_S = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1);\t\t\t#[J/mol-K] - Entropy change\n",
- "delta_S = delta_S/28.84;\t\t\t#kJ/kg-K]\n",
- "W_rev = -delta_H - ((delta_V_square/2)/1000) + T_0*delta_S;\t\t\t#[kJ/kg]\n",
- "print \" The maximum work obtainable per kg of air is %f kJ/kg\"%(W_rev);\n",
- "\n",
- "\t\t\t#The second law efficiency of the turbine is actual work done divided by reversible work,therefore\n",
- "sec_eff = W/W_rev;\n",
- "print \" The second law efficiency of the turbine is %f\"%(sec_eff);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The actual work done is 69.792718 kJ/kg\n",
- " The maximum work obtainable per kg of air is 169.550182 kJ/kg\n",
- " The second law efficiency of the turbine is 0.411635\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.7 Page Number : 200"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "m_cold_water = 60;\t\t\t#[kg/s] - mass flow rate of cold water\n",
- "P_1 = 50;\t\t\t#[kPa]\n",
- "T_2 = 250;\t\t\t#[C]\n",
- "T_water_1 = 1000 + 273.15;\t\t\t#[K] - Entering temperature of water\n",
- "T_water_2 = 450 +273.15;\t\t\t#[K] - Exit temperature of water\n",
- "T_0 = 298.15;\t\t\t#[K] - surrounding temperature\n",
- "P_0 = 1;\t\t\t#[atm] - surrounding pressure\n",
- "Cp_0 = 1.005;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t#For water at 50 kPa under saturated conditions,T_sat = 81.33 C, \n",
- "H_liq_1 = 340.49;\t\t\t#[kJ/kg] - Enthalpy\n",
- "S_liq_1 = 1.0910;\t\t\t#[kJ/kg-K] - Entropy\n",
- "\n",
- "\t\t\t#For steam at 50 kPa and 250 C,\n",
- "H_2 = 2976.0;\t\t\t#[kJ/kg]\n",
- "S_2 = 8.3556;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#The cold stream is water which enters as saturated liquid at 50 kPa and exits as superheated vapour at 50 kPa and 250 C,since pressure drop is neglected.\n",
- "\t\t\t#The mass flow rate of hot stream can be obtained from energy balance\n",
- "m_hot_water = (m_cold_water*(H_2 - H_liq_1))/(Cp_0*(T_water_1 - T_water_2));\t\t\t#[kg/s] - mass flow rate of hot water\n",
- "\n",
- "\t\t\t#Since there is no heat exchange with the surrounding therefore the total entropy generation is given by\n",
- "\t\t\t#S_gen = delta_S_hot + delta_S_cold\n",
- "delta_S_cold = S_2 - S_liq_1;\t\t\t#[kJ/kg-K] - change of entropy of cold water\n",
- "\t\t\t#delta_S_hot = Cp_0*math.log(T_2/T_1)-R*math.log(P_2/P_1), But pressure drop is zero,therfore\n",
- "delta_S_hot = Cp_0*math.log(T_water_2/T_water_1);\t\t\t#[kJ/kg-K] - change of entropy of hot water\n",
- "\n",
- "S_gen = m_cold_water*delta_S_cold + m_hot_water*delta_S_hot;\t\t\t#[kW/K] - Entropy generated\n",
- "print \" The entropy generation rate is %f kW/K\"%(S_gen);\n",
- "\n",
- "\t\t\t#The irreversibility rete is given by\n",
- "I = T_0*S_gen;\t\t\t#[kW]\n",
- "print \" The irreversibility rate of the heat exchanger is %f kW\"%(I);\n",
- "\n",
- "\t\t\t#The irreversibility can also be determined using the exergy approach\n",
- "\t\t\t#We know that, I = W_rev - , but since actual work done zero in heat exchangers,therefore I = W_rev = exergy change\n",
- "\t\t\t#(si_1 - si_2)_cold = H_1 - H_2 - T_0*(S_1 - S_2)\n",
- "\t\t\t#(si_1 - si_2)_hot = Cp_0*(T_1 - T_2)- T_0*(S_1 - S_2)\n",
- "\t\t\t# I = (si_1 - si_2)_cold - (si_1 - si_2)_hot.\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The entropy generation rate is 273.250824 kW/K\n",
- " The irreversibility rate of the heat exchanger is 81469.733193 kW\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.8 Page Number : 201"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "m_water = 10000.;\t\t\t#[kg/h] - Mass flow rate of cold water\n",
- "m_water = m_water/3600;\t\t\t#[kg/s]\n",
- "T_1_water = 30. + 273.15;\t\t\t#[K] - Cold water entering temperature\n",
- "m_HC = 5000.;\t\t\t#[kg/h] - mass flow rate of hot hydrocarbon\n",
- "m_HC = m_HC/3600;\t\t\t#[kg/s]\n",
- "T_1_HC = 200. + 273.15;\t\t\t#[K] - Hot hydrocarbon entering temperature\n",
- "T_2_HC = 100. + 273.15;\t\t\t#[K] - Hot hydrocarbon leaving temperature\n",
- "Cp_0_water = 1.0;\t\t\t#[kcal/kg-K] - Mean heat capacity of cooling water\n",
- "Cp_0_HC = 0.6;\t\t\t#[kcal/kg-K] - Mean heat capacity of hydrocarbon\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t#Applying energy balance to the heat exchanger,we get\n",
- "\t\t\t#m_water*Cp_0_water*(T - T_1_water) = m_HC*Cp_0_HC*(T_1_HC - T_2_HC)\n",
- "T_2_water = ((m_HC*Cp_0_HC*(T_1_HC - T_2_HC))/(m_water*Cp_0_water)) + T_1_water;\t\t\t#[K]\n",
- "T_2 = T_2_water - 273.15;\t\t\t#[C]\n",
- "print \" 1).The exit temperature of the cooling water is %f C\"%(T_2);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t#delta_S_hot_HC = Cp_0*math.log(T_2/T_1)-R*math.log(P_2/P_1), But pressure drop is zero,therfore\n",
- "delta_S_hot_HC = (Cp_0_HC*4.184)*math.log(T_2_HC/T_1_HC);\t\t\t#[kW/K] - change of entropy of hot hydrocarbon\n",
- "delta_S_HC = m_HC*delta_S_hot_HC;\t\t\t#[kW/K] - Entropy change for hudrocarbon liquid \n",
- "print \" 2).Entropy change rate of hydrocarbon liquid is %f kW/K\"%(delta_S_HC);\n",
- "\n",
- "delta_S_cold_water = (Cp_0_water*4.184)*math.log(T_2_water/T_1_water);\t\t\t#[kW/K] - change of entropy of cooling water\n",
- "delta_S_water = m_water*delta_S_cold_water;\t\t\t#[kW/K] - Entropy change for water\n",
- "print \" And entropy change rate of water is %f kW/K\"%(delta_S_water);\n",
- "\n",
- "\t\t\t#(3)\n",
- "T_0 = 298.15;\t\t\t#[K] - Surrounding temperature\n",
- "\t\t\t#S_gen = delta_S_cold_water + delta_S_hot_HC = m_water*delta_S_cold_water + m_HC*delta_S_hot_HC;\t\t\t#[kW/K] - Entropy generated\n",
- "S_gen = delta_S_water + delta_S_HC;\t\t\t#[kW/K]\n",
- "I = T_0*S_gen;\t\t\t#[kW]\n",
- "print \" 3).The irreversibility rate of the heat exchanger is %f kW\"%(I);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The exit temperature of the cooling water is 60.000000 C\n",
- " 2).Entropy change rate of hydrocarbon liquid is -0.827846 kW/K\n",
- " And entropy change rate of water is 1.096732 kW/K\n",
- " 3).The irreversibility rate of the heat exchanger is 80.168382 kW\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.9 Page Number : 202"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1_hotgas = 800.;\t\t\t#[K]\n",
- "P_1_hotgas = 1.;\t\t\t#[bar]\n",
- "T_2_hotgas = 700.;\t\t\t#[K]\n",
- "P_2_hotgas = 1.;\t\t\t#[bar]\n",
- "T_1_air = 470.;\t\t\t#[K]\n",
- "P_1_air = 1.;\t\t\t#[bar]\n",
- "P_2_air = 1.;\t\t\t#[bar]\n",
- "Cp_0_hotgas = 1.08;\t\t\t#[kJ/kg-K] - Mean heat capacity of hot gas\n",
- "Cp_0_air = 1.05;\t\t\t#[kcal/kg-K] - Mean heat capacity of air\n",
- "T_0 = 298.15;\t\t\t#[K] - surrounding temperature\n",
- "P_0 = 1.;\t\t\t#[bar] - surrounding pressure\n",
- "\t\t\t#m_air = 2*m_hotgas\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t#Assuming heat exchange only takes places in-between the streams,from energy balance we get,\n",
- "\t\t\t#m_gas*Cp_0_hotgas*(T_2_hotgas - T_1_hotgas) + 2*m_gas*Cp_0_air*(T - T_1_air), \n",
- "T_2_air = T_1_air - ((Cp_0_hotgas*(T_2_hotgas - T_1_hotgas))/(2*Cp_0_air));\t\t\t#[K] - Temp of emerging air\n",
- "print \" 1).The temperature of emerging air is %f K\"%(T_2_air);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t#Availability change of hot gas is given by,\n",
- "\t\t\t#(si_1 - si_2)_hot = H_1 - H_2 - T_0*(S_1 - S_2)\n",
- "delta_H_hotgas = (Cp_0_hotgas*(T_2_hotgas - T_1_hotgas));\t\t\t#[kJ/kg] - change in enthalpy of hotgas\n",
- "\t\t\t#delta_S_hotgas = Cp_0_hotgas*math.log(T_2_hotgas/T_1_hotgas)- R*math.log(P_2/P_1), But pressure drop is zero (P_1 = P_2),therfore\n",
- "delta_S_hotgas = Cp_0_hotgas*math.log(T_2_hotgas/T_1_hotgas);\t\t\t#[kJ/kg-K] - change of entropy of hot gas\n",
- "delta_si_hotgas = (-delta_H_hotgas) - (-T_0*delta_S_hotgas);\t\t\t#[kJ/kg]\n",
- "print \" 2).The availability change of hot gas is %f kJ/kg\"%(delta_si_hotgas);\n",
- "\n",
- "\t\t\t#(3)\n",
- "\t\t\t#Availability change of air is given by,\n",
- "\t\t\t#(si_1 - si_2)_air = H_1 - H_2 - T_0*(S_1 - S_2)\n",
- "delta_H_air = (Cp_0_air*(T_2_air - T_1_air));\t\t\t#[kJ/kg] - change in enthalpy of air\n",
- "\t\t\t#delta_S_air = Cp_0_air*math.log(T_2_air/T_1_air)- R*math.log(P_2/P_1), But pressure drop is zero (P_1 = P_2),therfore\n",
- "delta_S_air = Cp_0_air*math.log(T_2_air/T_1_air);\t\t\t#[kJ/kg-K] - change of entropy of air\n",
- "delta_si_air = (-delta_H_air) - (-T_0*delta_S_air);\t\t\t#[kJ/kg]\n",
- "print \" 3).The availability change of air is %f kJ/kg\"%(delta_si_air);\n",
- "\n",
- "\t\t\t#(4)\n",
- "\t\t\t#For the heat exchanger (Q = 0, W = 0)\n",
- "\t\t\t#Basis : 1 kg of hot gas flowing through heat exchanger\n",
- "S_gen = delta_S_hotgas + 2*delta_S_air;\t\t\t#[kJ/kg-K] - (as m_air = 2*m_hotgas)\n",
- "I = T_0*S_gen;\t\t\t#[kJ/kg]\n",
- "print \" 4).The irreversibility of thr exchanger per kg of hot gas flowing is %f kJ/kg\"%(I);\n",
- "\n",
- "\t\t\t#Irreversibility can also be obtained using\n",
- "\t\t\t#I = 2*(si_1 - si_2)_air + (si_1 - si_2)_hotgas\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The temperature of emerging air is 521.428571 K\n",
- " 2).The availability change of hot gas is 65.002625 kJ/kg\n",
- " 3).The availability change of air is -21.492234 kJ/kg\n",
- " 4).The irreversibility of thr exchanger per kg of hot gas flowing is 22.018157 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 9
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch6_2.ipynb b/Chemical_Engineering_Thermodynamics/ch6_2.ipynb
deleted file mode 100755
index 71808e15..00000000
--- a/Chemical_Engineering_Thermodynamics/ch6_2.ipynb
+++ /dev/null
@@ -1,851 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:5875fd58ba5a3eb4a34d80c6cbf01fc2219f223f8352a521a425e02950a18a26"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 6 :Chemical reactions"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.1 Page Number : 217"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\t\t\t\n",
- "\n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 880;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "a_SO2 = 6.157;\n",
- "a_SO3 = 3.918;\n",
- "a_O2 = 6.732;\n",
- "b_SO2 = 1.384*10**(-2);\n",
- "b_SO3 = 3.483*10**(-2);\n",
- "b_O2 = 0.1505*10**(-2);\n",
- "c_SO2 = -0.9103*10**(-5);\n",
- "c_SO3 = -2.675*10**(-5);\n",
- "c_O2 = -0.01791*10**(-5);\n",
- "d_SO2 = 2.057*10**(-9);\n",
- "d_SO3 = 7.744*10**(-9);\n",
- "\n",
- "delta_H_rkn_298 = -23.45*10**(3);\t\t\t#[cal] - Rkn enthalpy at 298.15 K\n",
- "delta_H_SO2_for_298 = -70.94*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of S02 at 298.15 K\n",
- "delta_H_SO3_for_298 = -94.39*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of SO3 at 298.15 K\n",
- "delta_G_SO2_for_298 = -71.68*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n",
- "delta_G_SO3_for_298 = -88.59*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of SO3 at 298.15 K\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t#Smath.tan(math.radiansard enthalpy change of reaction at temperature T is given by,\n",
- "\t\t\t#delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n",
- "delta_a = a_SO3 - a_SO2 - (a_O2/2);\n",
- "delta_b = b_SO3 - b_SO2 - (b_O2/2);\n",
- "delta_c = c_SO3 - c_SO2 - (c_O2/2);\n",
- "delta_d = d_SO3 - d_SO2;\n",
- "\n",
- "\t\t\t#Cp_0 = delta_a + (delta_b*T) + (delta_c*T**(2)) + (delta_d*T**(3));\n",
- "\t\t\t#Therefore we get,\n",
- "\n",
- "def f44(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "delta_H_rkn_880 = delta_H_rkn_298 + quad(f44,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t#On manual simplification of the above expression,we will get the expression for 'delta_H_rkn_880' as a function of T,\n",
- " \n",
- "print \" 1.The expression for smath.tan(math.radiansard enthalpy change of reaction as a function of temperature is given by\";\n",
- "print \" delta_H_rkn_880 = -22534.57 - 5.605*T + 1.012*10**-2*T**2 - 0.585*10**-5*T**3 + 1.422*10**-9*T**4\"\n",
- "\n",
- "print \" 2).Staandard enthalpy change of reaction at 880 K is %f cal\"%(delta_H_rkn_880);\n",
- "\n",
- "\t\t\t#(3)\n",
- "\t\t\t#Let us determine the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_SO2_298 = (delta_H_SO2_for_298 - delta_G_SO2_for_298)/298.15;\t\t\t#[cal/mol-K]\n",
- "delta_S_SO3_298 = (delta_H_SO3_for_298 - delta_G_SO3_for_298)/298.15;\t\t\t#[cal/mol-K]\n",
- "delta_S_O2_298 = 0;\t\t\t#[cal/mol-K]\n",
- "\n",
- "delta_S_rkn_298 = delta_S_SO3_298 - delta_S_SO2_298 - (delta_S_O2_298/2);\t\t\t#[cal/K]\n",
- "\n",
- "def f45(T): \n",
- "\t return (delta_a+delta_b*T+delta_c*T**(2)+delta_d*T**(3))/T\n",
- "\n",
- "delta_S_rkn_880 = delta_S_rkn_298 + quad(f45,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" 3).Standard entropy change of reaction at 880 K is %f cal/K\"%(delta_S_rkn_880);\n",
- "\n",
- "\t\t\t#(4)\n",
- "delta_G_rkn_880 = delta_H_rkn_880 - 880*delta_S_rkn_880;\t\t\t#[cal]\n",
- "\n",
- "print \" 4).Standard Gibbs free energy change of reaction at 880 K is %f cal\"%(delta_G_rkn_880);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1.The expression for smath.tan(math.radiansard enthalpy change of reaction as a function of temperature is given by\n",
- " delta_H_rkn_880 = -22534.57 - 5.605*T + 1.012*10**-2*T**2 - 0.585*10**-5*T**3 + 1.422*10**-9*T**4\n",
- " 2).Staandard enthalpy change of reaction at 880 K is -22766.609215 cal\n",
- " 3).Standard entropy change of reaction at 880 K is -21.002783 cal/K\n",
- " 4).Standard Gibbs free energy change of reaction at 880 K is -4284.160417 cal\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.2 Page Number : 219"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 400;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "a_CH3OH = 4.55;\n",
- "a_CO = 6.726;\n",
- "a_H2 = 6.952;\n",
- "b_CH3OH = 2.186*10**(-2);\n",
- "b_CO = 0.04001*10**(-2);\n",
- "b_H2 = -0.04576*10**(-2);\n",
- "c_CH3OH = -0.291*10**(-5);\n",
- "c_CO = 0.1283*10**(-5);\n",
- "c_H2 = 0.09563*10**(-5);\n",
- "d_CH3OH = -1.92*10**(-9);\n",
- "d_CO = -0.5307*10**(-9);\n",
- "d_H2 = -0.2079*10**(-9);\n",
- "\n",
- "delta_H_rkn_298 = -21.6643*10**(3);\t\t\t#[cal] - Reaction enthalpy at 298.15 K\n",
- "delta_H_CO_for_298 = -26.4157*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CO at 298.15 K\n",
- "delta_H_CH3OH_for_298 = -48.08*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CH3OH at 298.15 K\n",
- "delta_G_CO_for_298 = -32.8079*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n",
- "delta_G_CH3OH_for_298 = -38.69*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CH3OH at 298.15 K\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Smath.tan(math.radiansard enthalpy change of reaction at temperature T is given by,\n",
- "\t\t\t#delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n",
- "delta_a = a_CH3OH - a_CO - 2*(a_H2);\n",
- "delta_b = b_CH3OH - b_CO - 2*(b_H2);\n",
- "delta_c = c_CH3OH - c_CO - 2*(c_H2);\n",
- "delta_d = d_CH3OH - d_CO - 2*(d_H2);\n",
- "\n",
- "\t\t\t#Cp_0 = delta_a + (delta_b*T) + (delta_c*T**(2)) + (delta_d*T**(3));\n",
- "\t\t\t#Therefore we get,\n",
- "\n",
- "def f56(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "delta_H_rkn_400 = delta_H_rkn_298 + quad(f56,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" Standard enthalpy change of reaction at 400 K is %f cal\"%(delta_H_rkn_400);\n",
- "\n",
- "\t\t\t#Let us determine the smath.tan(math.radiansard Gibbs free energy change of reaction at 298.15 K\n",
- "delta_G_rkn_298 = delta_G_CH3OH_for_298 - delta_G_CO_for_298;\t\t\t#[cal]\n",
- "\n",
- "\t\t\t#Now determining the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;\t\t\t#[cal/mol-K]\n",
- "\n",
- "\n",
- "def f57(T): \n",
- "\t return (delta_a+delta_b*T+delta_c*T**(2)+delta_d*T**(3))/T\n",
- "\n",
- "delta_S_rkn_400 = delta_S_rkn_298 + quad(f57,T_1,T_2)[0]\n",
- "\n",
- "\t\t\t#Therefore,the smath.tan(math.radiansard Gibbs free energy change of the reaction is given by,\n",
- "delta_G_rkn_400 = delta_H_rkn_400 - 400*delta_S_rkn_400;\t\t\t#[cal]\n",
- "\n",
- "print \" Standard Gibbs free energy change of reaction at 400 K is %f cal\"%(delta_G_rkn_400);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Standard enthalpy change of reaction at 400 K is -22587.159576 cal\n",
- " Standard Gibbs free energy change of reaction at 400 K is -343.363287 cal\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.3 Page Number : 220"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 1200;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "\n",
- "a_CO2 = 5.316;\n",
- "a_H2 = 6.952;\n",
- "a_CO = 6.726;\n",
- "a_H2O = 7.700;\n",
- "b_CO2 = 1.4285*10**(-2);\n",
- "b_H2 = -0.04576*10**(-2);\n",
- "b_CO = 0.04001*10**(-2);\n",
- "b_H2O = 0.04594*10**(-2);\n",
- "c_CO2 = -0.8362*10**(-5);\n",
- "c_H2 = 0.09563*10**(-5);\n",
- "c_CO = 0.1283*10**(-5);\n",
- "c_H2O = 0.2521*10**(-5);\n",
- "d_CO2 = 1.784*10**(-9);\n",
- "d_H2 = -0.2079*10**(-9);\n",
- "d_CO = -0.5307*10**(-9);\n",
- "d_H2O = -0.8587*10**(-9);\n",
- "\n",
- "# Calculations and Results\n",
- "delta_H_rkn_298 = -9.8382*10**(3);\t\t\t#[cal] - Reaction enthalpy at 298.15 K\n",
- "delta_H_CO2_for_298 = -94.0518*10**(3);\t\t\t#[cal/mol-K] - Enthalpy of formation of CO2 at 298.15 K\n",
- "delta_H_CO_for_298 = -26.4157*10**(3);\t\t\t#[cal/mol-K] - Enthalpy of formation of CO at 298.15 K\n",
- "delta_H_H2O_for_298 = -57.7979*10**(3);\t\t\t#[cal/mol-K] - Enthalpy of formation of H2O at 298.15 K\n",
- "delta_G_CO2_for_298 = -94.2598*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n",
- "delta_G_CO_for_298 = -32.8079*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CH3OH at 298.15 K\n",
- "delta_G_H2O_for_298 = -54.6357*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of H2O at 298.15 K\n",
- "\n",
- "\t\t\t#Smath.tan(math.radiansard enthalpy change of reaction at temperature T is given by,\n",
- "\t\t\t#delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n",
- "delta_a = a_CO2 + a_H2 - a_CO - a_H2O;\n",
- "delta_b = b_CO2 + b_H2 - b_CO - b_H2O;\n",
- "delta_c = c_CO2 + c_H2 - c_CO - c_H2O;\n",
- "delta_d = d_CO2 + d_H2 - d_CO - d_H2O;\n",
- "\n",
- "\t\t\t#Cp_0 = delta_a + (delta_b*T) + (delta_c*T**(2)) + (delta_d*T**(3));\n",
- "\t\t\t#Therefore we get,\n",
- "\n",
- "def f11(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "delta_H_rkn_1200 = delta_H_rkn_298 + quad(f11,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" Standard enthalpy change of reaction at 1200 K is %f cal\"%(delta_H_rkn_1200);\n",
- "\n",
- "\t\t\t#Let us determine the smath.tan(math.radiansard Gibbs free energy change of reaction at 298.15 K\n",
- "delta_G_rkn_298 = delta_G_CO2_for_298 - delta_G_CO_for_298 - delta_G_H2O_for_298;\t\t\t#[cal]\n",
- "\n",
- "\t\t\t#Now determining the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;\t\t\t#[cal/mol-K]\n",
- "\n",
- "\n",
- "def f12(T): \n",
- "\t return (delta_a+delta_b*T+delta_c*T**(2)+delta_d*T**(3))/T\n",
- "\n",
- "delta_S_rkn_1200 = delta_S_rkn_298 + quad(f12,T_1,T_2)[0]\n",
- "\n",
- "\t\t\t#Therefore,the smath.tan(math.radiansard Gibbs free energy change of the reaction is given by,\n",
- "delta_G_rkn_1200 = delta_H_rkn_1200 - 1200*delta_S_rkn_1200;\t\t\t#[cal]\n",
- "\n",
- "print \" Standard Gibbs free energy change of reaction at 1200 K is %f cal\"%(delta_G_rkn_1200);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Standard enthalpy change of reaction at 1200 K is -7850.182811 cal\n",
- " Standard Gibbs free energy change of reaction at 1200 K is 953.652749 cal\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.4 Page Number : 221"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 500;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "a_NH3 = 6.5846;\n",
- "a_N2 = 6.903;\n",
- "a_H2 = 6.952;\n",
- "b_NH3 = 0.61251*10**(-2);\n",
- "b_N2 = -0.03753*10**(-2);\n",
- "b_H2 = -0.04576*10**(-2);\n",
- "c_NH3 = 0.23663*10**(-5);\n",
- "c_N2 = 0.1930*10**(-5);\n",
- "c_H2 = 0.09563*10**(-5);\n",
- "d_NH3 = -1.5981*10**(-9);\n",
- "d_N2 = -0.6861*10**(-9);\n",
- "d_H2 = -0.2079*10**(-9);\n",
- "\n",
- "delta_H_rkn_298 = -22.08*10**(3);\t\t\t#[cal] - Reaction enthalpy at 298.15 K\n",
- "delta_H_NH3_for_298 = -11.04*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of NH3 at 298.15 K\n",
- "delta_G_NH3_for_298 = -3.976*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of NH3 at 298.15 K\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Smath.tan(math.radiansard enthalpy change of reaction at temperature T is given by,\n",
- "\t\t\t#delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n",
- "delta_a = 2*a_NH3 - a_N2 - 3*a_H2;\n",
- "delta_b = 2*b_NH3 - b_N2 - 3*b_H2;\n",
- "delta_c = 2*c_NH3 - c_N2 - 3*c_H2;\n",
- "delta_d = 2*d_NH3 - d_N2 - 3*d_H2;\n",
- "\n",
- "\t\t\t#Cp_0 = delta_a + (delta_b*T) + (delta_c*T**(2)) + (delta_d*T**(3));\n",
- "\t\t\t#Therefore we get,\n",
- "\n",
- "def f5(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "delta_H_rkn_500 = delta_H_rkn_298 + quad(f5,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" Standard enthalpy change of reaction at 500 K is %f cal\"%(delta_H_rkn_500);\n",
- "\n",
- "\t\t\t#Let us determine the smath.tan(math.radiansard Gibbs free energy change of reaction at 298.15 K\n",
- "delta_G_rkn_298 = 2*delta_G_NH3_for_298;\t\t\t#[cal]\n",
- "\n",
- "\t\t\t#Now determining the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;\t\t\t#[cal/mol-K]\n",
- "\n",
- "\n",
- "def f6(T): \n",
- "\t return (delta_a+delta_b*T+delta_c*T**(2)+delta_d*T**(3))/T\n",
- "\n",
- "delta_S_rkn_500 = delta_S_rkn_298 + quad(f6,T_1,T_2)[0]\n",
- "\n",
- "\t\t\t#Therefore,the smath.tan(math.radiansard Gibbs free energy change of the reaction is given by,\n",
- "delta_G_rkn_500 = delta_H_rkn_500 - 500*delta_S_rkn_500;\t\t\t#[cal]\n",
- "\n",
- "print \" Standard Gibbs free energy change of reaction at 500 K is %f cal\"%(delta_G_rkn_500);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Standard enthalpy change of reaction at 500 K is -23925.267197 cal\n",
- " Standard Gibbs free energy change of reaction at 500 K is 2159.910425 cal\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.5 Page Number : 222"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "delta_H_rkn_298 = -57.7979*10**(3);\t\t\t#[cal/mol] - Reaction enthalpy at 298.15 K\n",
- "delta_G_rkn_298 = -54.6351*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of H2O at 298.15 K\n",
- "\n",
- "\t\t\t#Smath.tan(math.radiansard enthalpy change of reaction at temperature T is given by,\n",
- "\t\t\t#delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2_1 = 873.15;\t\t\t#[K] - Reaction temperature\n",
- "T_2_2 = 1000;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Therefore we get,\n",
- "\n",
- "def f34(T): \n",
- "\t return 7.7+0.04594*10**(-2)*T+0.2521*10**(-5)*T**(2)-0.8587*10**(-9)*T**(3)\n",
- "\n",
- "delta_H_rkn_873 = delta_H_rkn_298 + quad(f34,T_1,T_2_1)[0]\n",
- "\n",
- "\n",
- "def f35(T): \n",
- "\t return 7.7+0.04594*10**(-2)*T+0.2521*10**(-5)*T**(2)-0.8587*10**(-9)*T**(3)\n",
- "\n",
- "delta_H_rkn_1000 = delta_H_rkn_298 + quad(f35,T_1,T_2_2)[0]\n",
- "\n",
- "\n",
- "print \" Standard enthalpy change of reaction at 873 K is %f cal/mol\"%(delta_H_rkn_873);\n",
- "print \" Standard enthalpy change of reaction at 1000 K is %f cal/mol\"%(delta_H_rkn_1000);\n",
- "\n",
- "\t\t\t#Now determining the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;\t\t\t#[cal/mol-K]\n",
- "\n",
- "\n",
- "def f36(T): \n",
- "\t return (7.7+0.04594*10**(-2)*T+0.2521*10**(-5)*T**(2)-0.8587*10**(-9)*T**(3))/T\n",
- "\n",
- "delta_S_rkn_873 = delta_S_rkn_298 + quad(f36,T_1,T_2_1)[0]\n",
- "\n",
- "\n",
- "def f37(T): \n",
- "\t return (7.7+0.04594*10**(-2)*T+0.2521*10**(-5)*T**(2)-0.8587*10**(-9)*T**(3))/T\n",
- "\n",
- "delta_S_rkn_1000 = delta_S_rkn_298 + quad(f37,T_1,T_2_2)[0]\n",
- "\n",
- "\t\t\t#Therefore,the smath.tan(math.radiansard Gibbs free energy change of the reaction is given by,\n",
- "delta_G_rkn_873 = (delta_H_rkn_873 - 873.15*delta_S_rkn_873)*10**(-3);\t\t\t#[kcal/mol]\n",
- "delta_G_rkn_1000 = (delta_H_rkn_1000 - 1000*delta_S_rkn_1000)*10**(-3);\t\t\t#[kcal/mol]\n",
- "\n",
- "print \" Standard Gibbs free energy change of reaction at 873 K is %f kcal/mol\"%(delta_G_rkn_873);\n",
- "print \" Standard Gibbs free energy change of reaction at 1000 K is %f kcal/mol\"%(delta_G_rkn_1000);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Standard enthalpy change of reaction at 873 K is -52801.656303 cal/mol\n",
- " Standard enthalpy change of reaction at 1000 K is -51579.290952 cal/mol\n",
- " Standard Gibbs free energy change of reaction at 873 K is -51.575573 kcal/mol\n",
- " Standard Gibbs free energy change of reaction at 1000 K is -51.481661 kcal/mol\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.6 Page Number : 223"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 500.;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "a_C2H6 = 1.648;\n",
- "a_O2 = 6.085;\n",
- "a_CO2 = 5.316;\n",
- "a_H2O = 7.700;\n",
- "b_C2H6 = 4.124*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "b_CO2 = 1.4285*10**(-2);\n",
- "b_H2O = 0.04594*10**(-2);\n",
- "c_C2H6 = -1.530*10**(-5);\n",
- "c_O2 = -0.1709*10**(-5);\n",
- "c_CO2 = -0.8362*10**(-5);\n",
- "c_H2O = 0.2521*10**(-5);\n",
- "d_C2H6 = 1.740*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "d_CO2 = 1.784*10**(-9);\n",
- "d_H2O = -0.8587*10**(-9);\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Since excess is entering and leaving at the same temperature,therefore it does not take or give any heat to the system.\n",
- "\t\t\t#Therefore the heat exchange is only due to heat of raction at temperature T, or Q = delta_H_rkn_T\n",
- "\n",
- "delta_H_C2H6_for_298 = -20.236*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of C2H6 at 298.15 K\n",
- "delta_H_CO2_for_298 = -94.0518*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CO2 at 298.15 K\n",
- "delta_H_H2O_for_298 = -57.7979*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of H2O at 298.15 K\n",
- "\n",
- "delta_H_rkn_298 = 2*delta_H_CO2_for_298 + 3*delta_H_H2O_for_298 - delta_H_C2H6_for_298;\t\t\t#[cal] - Reaction enthalpy at 298.15 K\n",
- "\n",
- "\t\t\t#Smath.tan(math.radiansard enthalpy change of reaction at temperature T is given by,\n",
- "\t\t\t#delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n",
- "delta_a = 2*a_CO2 + 3*a_H2O - a_C2H6 - 7./2*(a_O2);\n",
- "delta_b = 2*b_CO2 + 3*b_H2O - b_C2H6 - 7./2*(b_O2);\n",
- "delta_c = 2*c_CO2 + 3*c_H2O - c_C2H6 - 7./2*(c_O2);\n",
- "delta_d = 2*d_CO2 + 3*d_H2O - d_C2H6 - 7./2*(d_O2);\n",
- "\n",
- "\t\t\t#Cp_0 = delta_a + (delta_b*T) + (delta_c*T**(2)) + (delta_d*T**(3));\n",
- "\t\t\t#Therefore we get,\n",
- "\n",
- "def f55(T): \n",
- "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
- "\n",
- "delta_H_rkn_500 = delta_H_rkn_298 + quad(f55,T_1,T_2)[0]\n",
- "\n",
- "delta_H_rkn_500 = delta_H_rkn_500*10**(-3);\t\t\t#[kcal]\n",
- "\n",
- "print \" The heat exchange of the reaction at 500 K is %f kcal\"%(delta_H_rkn_500);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The heat exchange of the reaction at 500 K is -340.644585 kcal\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.7 Page Number : 224"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 600.;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "a_C2H6 = -8.65;\n",
- "a_H2O = 7.700;\n",
- "a_CH4 = 4.750;\n",
- "a_O2 = 6.085;\n",
- "b_C2H6 = 11.578*10**(-2);\n",
- "b_H2O = 0.04594*10**(-2);\n",
- "b_CH4 = 1.200*10**(-2);\n",
- "b_O2 = 0.3631*10**(-2);\n",
- "c_C2H6 = -7.540*10**(-5);\n",
- "c_H2O = 0.2521*10**(-5);\n",
- "c_CH4 = 0.3030*10**(-5);\n",
- "c_O2 = -0.1709*10**(-5);\n",
- "d_C2H6 = 18.54*10**(-9);\n",
- "d_H2O = -0.8587*10**(-9);\n",
- "d_CH4 = -2.630*10**(-9);\n",
- "d_O2 = 0.3133*10**(-9);\n",
- "\n",
- "delta_S_CH4_for_298 = 44.50;\t\t\t#[cal/mol-K] - Entropy of formation of CH4 at 298.15 K\n",
- "delta_S_O2_for_298 = 49.00;\t\t\t#[cal/mol-K] - Entropy of formation of O2 at 298.15 K\n",
- "delta_S_C2H6_for_298 = 64.34;\t\t\t#[cal/mol-K] - Entropy of formation of C2H6 at 298.15 K\n",
- "delta_S_H2O_for_298 = 45.11;\t\t\t#[cal/mol-K] - Entropy of formation of C2H6 at 298.15 K\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Cp_0 = delta_a + (delta_b*T) + (delta_c*T**(2)) + (delta_d*T**(3));\n",
- "\n",
- "\t\t\t#Smath.tan(math.radiansard entropy change of reaction at temperature T is given by,\n",
- "\t\t\t#delta_S_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n",
- "delta_a = 1./6*(a_C2H6) + 3./2*(a_H2O) - a_CH4 - 3./4*(a_O2);\n",
- "delta_b = 1./6*(b_C2H6) + 3./2*(b_H2O) - b_CH4 - 3./4*(b_O2);\n",
- "delta_c = 1./6*(c_C2H6) + 3./2*(c_H2O) - c_CH4 - 3./4*(c_O2);\n",
- "delta_d = 1./6*(d_C2H6) + 3./2*(d_H2O) - d_CH4 - 3./4*(d_O2);\n",
- "\n",
- "delta_S_rkn_298 = 1./6*(delta_S_C2H6_for_298) + 3./2*(delta_S_H2O_for_298) - delta_S_CH4_for_298 - 3./4*(delta_S_O2_for_298);\t\t\t#[cal/K]\n",
- "\n",
- "def f27(T): \n",
- "\t return (delta_a+delta_b*T+delta_c*T**(2)+delta_d*T**(3))/T\n",
- "\n",
- "delta_S_rkn_600 = delta_S_rkn_298 + quad(f27,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" Change in entropy of the reaction at 298.15 K is %f cal/K\"%(delta_S_rkn_298);\n",
- "print \" Standard entropy change of reaction at 600 K is %f cal/K\"%(delta_S_rkn_600);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Change in entropy of the reaction at 298.15 K is -2.861667 cal/K\n",
- " Standard entropy change of reaction at 600 K is -1.880233 cal/K\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.8 Page Number : 225"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 973.15;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "\t\t\t#At 298.15 K\n",
- "delta_H_CH4_for_298 = -17.889*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CH4 at 298.15 K\n",
- "delta_H_C_for_298 = 0.00;\t\t\t#[cal/mol] - Enthalpy of formation of C (s, graphite) at 298.15 K\n",
- "delta_H_H2_for_298 = 0.00;\t\t\t#[cal/mol] - Enthalpy of formation of H2 at 298.15 K\n",
- "delta_G_CH4_for_298 = -12.140*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of H2 at 298.15 K\n",
- "delta_G_C_for_298 = 0.00;\t\t\t#[cal/mol] - Gibbs free energy change for formation of C (s, graphite) at 298.15 K\n",
- "delta_G_H2_for_298 = 0.00;\t\t\t#[cal/mol] - Gibbs free energy change for formation of H2 at 298.15 K\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#/Smath.tan(math.radiansaerd heat capacity data in cal/mol-K are given below, T is in K\n",
- "\t\t\t#Cp_0_CH4 = 4.75 + 1.2*10**(-2)*T + 0.303*10**(-5)*T**(2) - 2.63*10**(-9)*T**(3)\n",
- "\t\t\t#Cp_0_C = 3.519 + 1.532*10**(-3)*T - 1.723*10**(5)*T**(-2)\n",
- "\t\t\t#Cp_0_H2 = 6.952 - 0.04576*10**(-2)*T + 0.09563*10**(-5)*T**(2) - 0.2079*10**(-9)*T**(3)\n",
- "\n",
- "\t\t\t#Therefore smath.tan(math.radiansard heat capacity of reaction is given by,\n",
- "\t\t\t#Cp_0_rkn = 2*Cp_0_H2 + Cp_0_C - Cp_0_CH4\n",
- "\t\t\t#On simplification,we get the relation\n",
- "\t\t\t#Cp_0_rkn = 12.673 - 0.0113832*T - 1.1174*10**(-6)*T**(2) + 2.2142*10**(-9)*T**(3) - 1.723*10**(5)*T**(-2)\n",
- "\n",
- "delta_H_rkn_298 = -delta_H_CH4_for_298;\t\t\t#[cal] - Enthalpy of reaction at 298.15 K\n",
- "delta_G_rkn_298 = -delta_G_CH4_for_298;\t\t\t#[cal] - Gibbs free energy of the reaction at 298.15 K\n",
- "\n",
- "\n",
- "def f63(T): \n",
- "\t return 12.673-0.0113832*T-1.1174*10**(-6)*T**(2)+2.2142*10**(-9)*T**(3)-1.723*10**(5)*T**(-2)\n",
- "\n",
- "delta_H_rkn_973 = delta_H_rkn_298 + quad(f63,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" Standard enthalpy change of reaction at 973.15 K is %f cal\"%(delta_H_rkn_973);\n",
- "\n",
- "\t\t\t#Now determining the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;\t\t\t#[cal/K]\n",
- "\n",
- "def f64(T): \n",
- "\t return (12.673-0.0113832*T-1.1174*10**(-6)*T**(2)+2.2142*10**(-9)*T**(3)-1.723*10**(5)*T**(-2))/T\n",
- "\n",
- "delta_S_rkn_973 = delta_S_rkn_298 + quad(f64,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t#Therefore,the smath.tan(math.radiansard Gibbs free energy change of the reaction is given by,\n",
- "delta_G_rkn_973 = delta_H_rkn_973 - 973.15*delta_S_rkn_973;\t\t\t#[cal]\n",
- "\n",
- "print \" Standard Gibbs free energy change of reaction at 973 K is %f cal\"%(delta_G_rkn_973);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Standard enthalpy change of reaction at 973.15 K is 21316.998642 cal\n",
- " Standard Gibbs free energy change of reaction at 973 K is -3880.803382 cal\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.9 Page Number : 226"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 1000;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "\t\t\t#At 298.15 K\n",
- "delta_H_C_for_298 = 0.00;\t\t\t#[cal/mol] - Enthalpy of formation of C(s,graphite) at 298.15 K\n",
- "delta_H_H2O_for_298 = -57.7979*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of H2O at 298.15 K\n",
- "delta_H_CO_for_298 = -26.4157*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CO at 298.15 K\n",
- "delta_H_H2_for_298 = 0.00;\t\t\t#[cal/mol] - Enthalpy of formation of H2 at 298.15 K\n",
- "delta_G_C_for_298 = 0.00;\t\t\t#[cal/mol] - Gibbs free energy change for formation of C(s, graphite) at 298.15 K\n",
- "delta_G_H2O_for_298 = -54.6357*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of H2O at 298.15 K\n",
- "delta_G_CO_for_298 = -32.8079*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n",
- "delta_G_H2_for_298 = 0.00;\t\t\t#[cal/mol] - Gibbs free energy change for formation of H2 at 298.15 K\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#/Smath.tan(math.radiansaerd heat capacity data in cal/mol-K are given below, T is in K\n",
- "\t\t\t#Cp_0_C = 3.519 + 1.532*10**(-3)*T - 1.723*10**(5)*T**(-2)\n",
- "\t\t\t#Cp_0_H2O = 7.7 + 0.04594*10**(-2)*T + 0.2521*10**(-5)*T**(2) - 0.8587*10**(-9)*T**(3)\n",
- "\t\t\t#Cp_0_CO = 6.726 + 0.04001*10**(-2)*T + 0.1283*10**(-5)*T**(2) - 0.5307*10**(-9)*T**(3)\n",
- "\t\t\t#Cp_0_H2 = 6.952 - 0.04576*10**(-2)*T + 0.09563*10**(-5)*T**(2) - 0.2079*10**(-9)*T**(3)\n",
- "\n",
- "\t\t\t#Therefore smath.tan(math.radiansard heat capacity of reaction is given by,\n",
- "\t\t\t#Cp_0_rkn = Cp_0_H2 + Cp_0_CO - Cp_0_C - Cp_0_H2O\n",
- "\t\t\t#On simplification,we get the relation\n",
- "\t\t\t#Cp_0_rkn = 2.459 - 2.0489*10**(-3)*T - 2.817*10**(-7)*T**(2) + 1.201*10**(-10)*T**(3) + 1.723*10**(5)*T**(-2)\n",
- "\n",
- "delta_H_rkn_298 = delta_H_CO_for_298 + delta_H_H2_for_298 - delta_H_C_for_298 - delta_H_H2O_for_298;\t\t\t#[cal] - Enthalpy of reaction at 298.15 K\n",
- "delta_G_rkn_298 = delta_G_CO_for_298 + delta_G_H2_for_298 - delta_G_C_for_298 - delta_G_H2O_for_298;\t\t\t#[cal] - Gibbs free energy of the reaction at 298.15 K\n",
- "\n",
- "\n",
- "def f13(T): \n",
- "\t return 2.459-2.0489*10**(-3)*T-2.817*10**(-7)*T**(2)+1.201*10**(-10)*T**(3)+1.723*10**(5)*T**(-2)\n",
- "\n",
- "delta_H_rkn_1000 = delta_H_rkn_298 + quad(f13,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" Standard enthalpy change of reaction at 1000 K is %f cal\"%(delta_H_rkn_1000);\n",
- "\n",
- "\t\t\t#Now determining the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;\t\t\t#[cal/K]\n",
- "\n",
- "def f14(T): \n",
- "\t return (2.459-2.0489*10**(-3)*T-2.817*10**(-7)*T**(2)+1.201*10**(-10)*T**(3)+1.723*10**(5)*T**(-2))/T\n",
- "\n",
- "delta_S_rkn_1000 = delta_S_rkn_298 + quad(f14,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t#Therefore,the smath.tan(math.radiansard Gibbs free energy change of the reaction is given by,\n",
- "delta_G_rkn_1000 = delta_H_rkn_1000 - 1000*delta_S_rkn_1000;\t\t\t#[cal]\n",
- "\n",
- "print \" Standard Gibbs free energy change of reaction at 1000 K is %f cal\"%(delta_G_rkn_1000);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Standard enthalpy change of reaction at 1000 K is 32518.639475 cal\n",
- " Standard Gibbs free energy change of reaction at 1000 K is -1858.365607 cal\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 6.10 Page Number : 228"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard temperature\n",
- "T_2 = 1042;\t\t\t#[K] - Reaction temperature\n",
- "\n",
- "\t\t\t#At 298.15 K\n",
- "delta_H_CaCO3_for_298 = -289.5*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CaCO3 at 298.15 K\n",
- "delta_H_CaO_for_298 = -151.7*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CaO at 298.15 K\n",
- "delta_H_CO2_for_298 = -94.052*10**(3);\t\t\t#[cal/mol] - Enthalpy of formation of CO2 at 298.15 K\n",
- "delta_G_CaCO3_for_298 = -270.8*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CaCO3 at 298.15 K\n",
- "delta_G_CaO_for_298 = -144.3*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CaO at 298.15 K\n",
- "delta_G_CO2_for_298 = -94.260*10**(3);\t\t\t#[cal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#/Smath.tan(math.radiansaerd heat capacity data in cal/mol-K are given below, T is in K\n",
- "\t\t\t#Cp_0_CO2 = 5.316 + 1.4285*10**(-2)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3)\n",
- "\t\t\t#Cp_0_CaO = 12.129 + 0.88*10**(-3)*T + 2.08*10**(5)*T**(-2)\n",
- "\t\t\t#Cp_0_CaCO3 = 24.98 + 5.240*10**(-3)*T + 6.199*10**(5)*T**(-2)\n",
- "\n",
- "\t\t\t#Therefore smath.tan(math.radiansard heat capacity of reaction is given by,\n",
- "\t\t\t#Cp_0_rkn = Cp_0_CO2 + Cp_0_CaO - Cp_0_CaCO3\n",
- "\t\t\t#On simplification,we get the relation\n",
- "\t\t\t#Cp_0_rkn = -7.535 + 9.925*10**(-3)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3) + 4.119*10**(5)*T**(-2)\n",
- "\n",
- "delta_H_rkn_298 = delta_H_CaO_for_298 + delta_H_CO2_for_298 - delta_H_CaCO3_for_298;\t\t\t#[cal] - Enthalpy of reaction at 298.15 K\n",
- "delta_G_rkn_298 = delta_G_CaO_for_298 + delta_G_CO2_for_298 - delta_G_CaCO3_for_298;\t\t\t#[cal] - Gibbs free energy of the reaction at 298.15 K\n",
- "\n",
- "\n",
- "def f38(T): \n",
- "\t return -7.535+9.925*10**(-3)*T-0.8362*10**(-5)*T**(2)+1.784*10**(-9)*T**(3)+4.119*10**(5)*T**(-2)\n",
- "\n",
- "delta_H_rkn_1042 = delta_H_rkn_298 + quad(f38,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "print \" Standard enthalpy change of reaction at 1042 K is %f cal\"%(delta_H_rkn_1042);\n",
- "\n",
- "\t\t\t#Now determining the smath.tan(math.radiansard entropy change of reaction at 298.15 K\n",
- "delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;\t\t\t#[cal/K]\n",
- "\n",
- "def f39(T): \n",
- "\t return (-7.535+9.925*10**(-3)*T-0.8362*10**(-5)*T**(2)+1.784*10**(-9)*T**(3)+4.119*10**(5)*T**(-2))/T\n",
- "\n",
- "delta_S_rkn_1042 = delta_S_rkn_298 + quad(f39,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t#Therefore,the smath.tan(math.radiansard Gibbs free energy change of the reaction is given by,\n",
- "delta_G_rkn_1042 = delta_H_rkn_1042 - 1042*delta_S_rkn_1042;\t\t\t#[cal]\n",
- "\n",
- "print \" Standard Gibbs free energy change of reaction at 1042 K is %f cal\"%(delta_G_rkn_1042);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Standard enthalpy change of reaction at 1042 K is 41518.919956 cal\n",
- " Standard Gibbs free energy change of reaction at 1042 K is 4873.416608 cal\n"
- ]
- }
- ],
- "prompt_number": 11
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch7_2.ipynb b/Chemical_Engineering_Thermodynamics/ch7_2.ipynb
deleted file mode 100755
index dae2b7f0..00000000
--- a/Chemical_Engineering_Thermodynamics/ch7_2.ipynb
+++ /dev/null
@@ -1,1553 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:1fc4ec5605309ff88ba6d75ddff6c3046fc8a8dc45dca2d12f7651c49812921e"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 7 : Thermodynamic property relations of pure substance"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.6 Page Number : 241"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "\n",
- "\n",
- "# Variables\n",
- "P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
- "P_2 = 1.4;\t\t\t#[MPa] - Final pressure\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#We know that\n",
- "\t\t\t# dS = (Cp/T)*dT - (dV/dT)*dP\n",
- "\t\t\t# Along an isothermal path,integration of above expression between states 1 and 2 yields\n",
- "\t\t\t# S_2 - S_1 = - integral((dV/dT)*dP)_P\n",
- "\t\t\t# An estimate can be made by assuming that (dV/dT)_P remains constant over the range of pressure from P_1 to P_2 and evaluating the derivative at average pressure of 1.2 MPa\n",
- "P_avg = P_2;\n",
- "\t\t\t# S_2 - S_1 = -integral((dV/dT)*dP)_Pavg*(P_2 - P_1)\n",
- "\t\t\t# (dV/dT)_P=1.2MPa = ((V_350 - V_250)/(350 - 250))\n",
- "dV_dT = (0.2345 - 0.19234)/100;\t\t\t#[m**(3)/kg-K]\n",
- "\t\t\t#Therefore\n",
- "delta_S = -dV_dT*(P_2 - P_1)*1000;\t\t\t#[kJ/kg-K] - Entropy change\n",
- "\n",
- "# Results\n",
- "print \"The change in entropy is given by S_2-S_1 = %f kJ/kg-K\"%(delta_S);\n",
- "\n",
- "\t\t\t#Let us compare this tabulated values. At 1MPA and 300 C, S_1 = 7.1229 kJ/kg-K. At 1.4 MPa and 300 C, S_2 = 6.9534 kJ/kg-K. \n",
- "\t\t\t#Therefore S_2 - S_1 = -0.1695 kJ/kg-K\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The change in entropy is given by S_2-S_1 = -0.168640 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.7 Page Number : 241"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "from scipy.integrate import quad \n",
- "\t\t\t\n",
- "# Variables\n",
- "T = 25. + 273.15;\t\t\t#[K] - Temperature of the surrounding\n",
- "P_1 = 1.;\t\t\t#[atm] - Initial pressure\n",
- "P_2 = 1000.;\t\t\t#[atm] - Final pressure\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# V = 18.066 - 7.15*10**(-4)*P + 4.6*10**(-8)*P**(2) where, V is in 'cm**(3)/mol' and P is in 'atm\n",
- "\t\t\t# (dV/dT)_P = 0.0045 + 1.4*10**(-6)*P ;\t\t\t#cm**(3)/mol-K\n",
- "\n",
- "\t\t\t# The work done by 1 mol is given by W = integral(P*dV)\n",
- "\t\t\t# Differentiating both sides of the expression for V, we get\n",
- "\t\t\t# dV = -7.15*10**(-4)*dP + 9.2*10**(-8)*(P*dP) \n",
- "\t\t\t# P*dV = -7.15*10**(-4)*P*dP + 9.2*10**(-8)*(P**(2)*dP)\n",
- "\n",
- "\t\t\t# The work done is given by\n",
- "\n",
- "def f58(P): \n",
- "\t return -7.15*10**(-4)*P + 9.2*10**(-8)*(P**(2))\n",
- "\n",
- "W = quad(f58,P_1,P_2)[0];\t\t\t#[atm-cm**(3)[0]\n",
- "\n",
- "W = W*101325*10**(-6);\t\t\t#[J/mol]\n",
- "\n",
- "print \"The necessary work to compress water from 1 atm to 1000 atm is %f J/mol\"%(W);\n",
- "\n",
- "\t\t\t#Let us calculate the amount of heat transfer\n",
- "\t\t\t# q = integral(T*dS)\n",
- "\t\t\t# dS = ((ds/dT)_P)*dT + ((dS/dP)_T)*dP\n",
- "\t\t\t# Since the temperature is constant the first term is zero and\n",
- "\t\t\t# dS = ((dS/dP)_T)*dP = -((dV/dT)_P)*dP\n",
- "\t\t\t# Thus, q = integral(T*dS) = T*(integral(dS)) ( as temperature is constant )\n",
- "\t\t\t# or, q = -T*(integral((dV/dT)_P)*dP)\n",
- "\n",
- "\t\t\t# Thus the heat transfer is given by\n",
- "\n",
- "def f59(P): \n",
- "\t return 0.0045+1.4*10**(-6)*P\n",
- "\n",
- "q = -T* quad(f59,P_1,P_2)[0];\t\t\t#[atm-cm**(3)[0]\n",
- "\n",
- "q = q*101325*10**(-6);\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# q - W = delta_U\n",
- "\t\t\t# Thus delta_U is given by\n",
- "delta_U = q - W;\t\t\t#[J/mol]\n",
- "\n",
- "print \"The change in internal energy is %f J/mol\"%(delta_U);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The necessary work to compress water from 1 atm to 1000 atm is -33.116351 J/mol\n",
- "The change in internal energy is -123.839936 J/mol\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.12 Page Number : 247"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "\n",
- "\n",
- "# Variables\n",
- "T = 25+273.15;\t\t\t#[K] - Temperature\n",
- "P = 1;\t\t\t#[atm] - Pressure\n",
- "P = P*101325;\t\t\t#[Pa]\n",
- "Tc = 126.2;\t\t\t#[K] - Critical temperature\n",
- "Pc = 34;\t\t\t#[bar] - Critical pressure\n",
- "Pc = Pc*10**(5);\t\t\t#[Pa]\n",
- "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "a = (27*R**(2)*Tc**(2)/(64*Pc));\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# the cubic form of van der Walls equation of state is\n",
- "\t\t\t# V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P=0\n",
- "\t\t\t#Solving the cubic equation\n",
- "def f(V): \n",
- "\t return V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P\n",
- "V = fsolve(f,1)\n",
- "\t\t\t#The above equation has 1 real and 2 imaginary roots. We consider only real root.\n",
- "\n",
- "Beta = R/((P*V)-(a/V)+((2*a*b)/V**(2)));\t\t\t#[K**(-1)]\n",
- "\n",
- "K_t = (V-b)/((P*V)-(a/V)+((2*a*b)/V**(2)));\t\t\t#[Pa**(-1)]\n",
- "K_t = K_t*101325;\t\t\t#[atm**(-1)]\n",
- "\n",
- "print \" Beta\\t = \\t %f K**-1)\"%(Beta);\n",
- "print \" K_t\\t = \\t %f atm**-1)\"%(K_t);\n",
- "\n",
- "\t\t\t#For ideal gas, Beta = 1/T = 0.0033354 K**(-1) and K_t = 1/P = 1 atm**(-1)\n",
- "\t\t\t# So results obtained are convergent with those obtained assuming ideal gas.\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Beta\t = \t 0.003364 K**-1)\n",
- " K_t\t = \t 1.000672 atm**-1)\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.13 Page Number : 248"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 45+273.15;\t\t\t#[K]\n",
- "P_1 = 10;\t\t\t#[kPa] - Initial pressure\n",
- "P_2 = 8600;\t\t\t#[kPa] - Final pressure\n",
- "V = 1010;\t\t\t#[cm**(3)/kg] - Specific volume for saturated liquid water at 45 C\n",
- "V = V*10**(-6);\t\t\t#[m**(3)/kg]\n",
- "\t\t\t# Beta = (1/V)*(dV/dT)_P\n",
- "Beta = 4.25*10**(-4);\t\t\t#[k**(-1)]\n",
- "Cp = 4.178;\t\t\t#[kJ/kg-K] - Specific heat at constant pressure\n",
- "eff = 0.75;\t\t\t# Efficiency of the pump\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t#when efficiency of the pump is 100% , W = -delta_Hs\n",
- "\t\t\t# Now delta_H = T*dS + V*dP, therefore under isentropic conditions, dH = V*dP\n",
- "\t\t\t# Since the fluid is liquid, therefore the specific volume can be taken to be constant and integrating the above equaton we get\n",
- "\t\t\t# delta_Hs = V*dP\n",
- "delta_Hs = V*(P_2 - P_1);\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Actual pumps are not isentropic and therefore not 100% efficient. Therefore actual work done by the pump is given by\n",
- "W = -delta_Hs/eff;\t\t\t#[kJ/kg]\n",
- "\n",
- "print \" 1).The work done by the pump is %f kJ/kg\"%(W);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# We know that dH = Cp*dT + (1 - Beta*T)*V*dP\n",
- "\t\t\t# Beta and V are weak functions of pressure in the case of liquids.\n",
- "\t\t\t# Integrating the above equation we get\n",
- "\t\t\t# delta_H = Cp*delta_T + (1 - Beta*T)*V*(delta_P)\n",
- "\t\t\t# Now from energy balance delta_H = q - W . But q = 0. Therefore,\n",
- "delta_H = -W;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Solving for delta_T\n",
- "delta_T = (delta_H - (1 - Beta*T)*V*(P_2-P_1))/Cp;\n",
- "\n",
- "print \" 2).The temperature of water change by delta_T = %f K\"%(delta_T);\n",
- "\n",
- "\t\t\t#(3)\n",
- "T_1 = T;\t\t\t#[K]\n",
- "T_2 = T + delta_T;\t\t\t#[K]\n",
- "\t\t\t# dS = (Cp/T)*dT - Beta*V*dP\n",
- "\t\t\t# Beta and V are weak functions of pressure in the case of liquids. Integrating the above equation we get\n",
- "delta_S = Cp*math.log(T_2/T_1) - Beta*V*(P_2-P_1);\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" 3).The entropy change of water is given by delta_S = %f kJ/kg-K\"%(delta_S);"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The work done by the pump is -11.567867 kJ/kg\n",
- " 2).The temperature of water change by delta_T = 0.972970 K\n",
- " 3).The entropy change of water is given by delta_S = 0.009070 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.14 Page Number : 249"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 270;\t\t\t#[K]\n",
- "P_1 = 381;\t\t\t#[kPa] - Initial pressure\n",
- "P_2 = 1200;\t\t\t#[kPa] - Final pressure\n",
- "V_liq = 1.55*10**(-3);\t\t\t#[m**(3)/kg] - Specific volume for saturated water in liquid phase at 270 C\n",
- "Beta = 2.095*10**(-3);\t\t\t#[K**(-1)]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#dH = Cp*dT + [V - T*(dV/dT)_P]*dP\n",
- "\t\t\t# dS = (Cp/T)*dT - ((dV/dT)_P)*dP\n",
- "\t\t\t# Since isothermal conditions are maintained we get\n",
- "\t\t\t# dH = [V - T*(dV/dT)_P]*dP = V*(1 - Beta*T)*dP\n",
- "\t\t\t# For the liquid assuming V and Beta to remain constant during pressure change, and since temperature is constant we get\n",
- "delta_H = V_liq*(1 - Beta*T)*(P_2 - P_1);\t\t\t#[kJ/kg]\n",
- "\n",
- "print \"The enthalpy change is given by delta_H = %f kJ/kg\"%(delta_H);\n",
- "\n",
- "\t\t\t# Under isothermal conditions \n",
- "\t\t\t# dS = -((dV/dT)_P)*dP = -Beta*V_liq*dP\n",
- "\t\t\t# If Beta*V is assumed to remain constant during pressure change we get\n",
- "delta_S = -Beta*V_liq*(P_2-P_1);\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \"The entropy change is given by delta_S = %e kJ/kg-K\"%(delta_S);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The enthalpy change is given by delta_H = 0.551386 kJ/kg\n",
- "The entropy change is given by delta_S = -2.659498e-03 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.15 Page Number : 249"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T_1 = 0;\t\t\t#[C] - Initial tempetaure\n",
- "T_2 = 100;\t\t\t#[C] - Final temperature\n",
- "\t\t\t# Beta = 1.0414*10**(-3) + 1.5672*10**(-6)*T + 5.148*10**(-8)*T**(2), where T is in C\n",
- "\t\t\t# At constant pressure (1/V)*(dV/dT) = Beta\n",
- "\t\t\t# or, d(math.log(V)) = Beta*dT\n",
- "\t\t\t# Integrating we get math.log(V_2/V_1) = integral(Beta*dT) from limit T_1 to T_2\n",
- "\n",
- "# Calculations and Results\n",
- "def f62(T): \n",
- "\t return 1.0414*10**(-3)+1.5672*10**(-6)*T+5.148*10**(-8)*T**(2)\n",
- "\n",
- "integral = quad(f62,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t# math.log(V_2/V_1) = integral\n",
- "\t\t\t# (V_2/V_1) = exp(integral)\n",
- "\t\t\t# (V_2 - V_1)/V_1 = change = exp(integral) - 1;\n",
- "change = math.exp(integral) - 1;\n",
- "per_change = 100*change;\n",
- "\n",
- "print \"The percentage change in volume = %f %%\"%(per_change);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The percentage change in volume = 13.784486 %\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.16 Page Number : 250"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_1 = 25 + 273.15;\t\t\t#[C] - Initial tempetaure\n",
- "T_2 = 50 + 273.15;\t\t\t#[C] - Final temperature\n",
- "P_1 = 1;\t\t\t#[bar] - Initial pressure\n",
- "P_2 = 1000;\t\t\t#[bar] - Final pressure\n",
- "\n",
- "Cp_T1_P1 = 75.305;\t\t\t#[J/mol-K]\n",
- "Cp_T2_P1 = 75.314;\t\t\t#[J/mol-K]\n",
- "V_T1_P1 = 18.071;\t\t\t#[cm**(3)/mol]\n",
- "V_T1_P2 = 18.012;\t\t\t#[cm**(3)/mol]\n",
- "V_T2_P1 = 18.234;\t\t\t#[cm**(3)/mol]\n",
- "V_T2_P2 = 18.174;\t\t\t#[cm**(3)/mol]\n",
- "Beta_T1_P1 = 256*10**(-6);\t\t\t#[K**(-1)]\n",
- "Beta_T1_P2 = 366*10**(-6);\t\t\t#[K**(-1)]\n",
- "Beta_T2_P1 = 458*10**(-6);\t\t\t#[K**(-1)]\n",
- "Beta_T2_P2 = 568*10**(-6);\t\t\t#[K**(-1)]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The entropy change is given by\n",
- "\t\t\t# dS = (Cp/T)*dT - ((dV/dT)_P)*dP\n",
- "\t\t\t# The mean Cp between 25 and 50 C is \n",
- "Cp_mean = (Cp_T1_P1 + Cp_T1_P1)/2;\t\t\t#[J/mol-K]\n",
- "\n",
- "\n",
- "\t\t\t# (dV/dT)_P=1bar = (V_T2_P1 - V_T1_P1)/(50 - 25)\n",
- "dV_dT_P1 = ((V_T2_P1 - V_T1_P1)/(50 - 25))*10**(-6);\t\t\t#[m**(-3)/mol-K]\n",
- "dV_dT_P2 = ((V_T2_P2 - V_T1_P2)/(50 - 25))*10**(-6);\t\t\t#[m**(-3)/mol-K]\n",
- "\t\t\t# The mean value of (dV/dT)_P between 1 and 1000 bar is\n",
- "dV_dT_mean = (dV_dT_P1 + dV_dT_P2)/2;\t\t\t#[m**(-3)/mol-K]\n",
- "delta_S = Cp_mean*math.log(T_2/T_1) - dV_dT_mean*(P_2 - P_1)*10**(5);\t\t\t#[J/mol-K]\n",
- "\n",
- "print \" The value of entropy change is given by delta_S = %f J/mol-K\"%(delta_S);\n",
- "\n",
- "\t\t\t# Now let us determine the enthalpy change. We know that\n",
- "\t\t\t# dH = Cp*dT + [V - T*(dV/dT)_P]*dP\n",
- "\t\t\t# [V - T*(dV/dT)_P] = (V - T*V*Beta) = val (say)\n",
- "\t\t\t# At state 1\n",
- "val_1 = ((V_T1_P1)*10**(-6))*(1 - (T_1)*(Beta_T1_P1));\t\t\t#[m**(3)/mol]\n",
- "\t\t\t# At state 2\n",
- "val_2 = ((V_T2_P2)*10**(-6))*(1 - (T_2)*(Beta_T2_P2));\t\t\t#[m**(3)/mol]\n",
- "val_mean = (val_1 + val_2)/2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "delta_H = Cp_mean*(T_2 - T_1) + val_mean*(P_2-P_1)*10**(5);\t\t\t#[J/mol]\n",
- "\n",
- "print \" The value of enthalpy change is given by delta_H = %f J/mol\"%(delta_H);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of entropy change is given by delta_S = 5.414201 J/mol-K\n",
- " The value of enthalpy change is given by delta_H = 3457.542629 J/mol\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.22 Page Number : 256"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 100 + 273.15;\t\t\t#[K]\n",
- "P = 10;\t\t\t#[MPa]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The volume expansivity is defined as \n",
- "\t\t\t# Beta = (1/V)*(del V/del T)_P = (1/V)*(dV/dT)_P\n",
- "\t\t\t# From compressed liquid water tables at 100 C and 10 MPa,\n",
- "V = 0.0010385;\t\t\t#[m(3)/kg]\n",
- "Beta = (1/V)*((0.0010549 - 0.0010245)/(120 - 80));\t\t\t#[K**(-1)] \t\t\t# The values are obtained from the steam table as reported in the book.\n",
- "\n",
- "print \"The value of volume expansivity is Beta = %e K**-1)\"%(Beta);\n",
- "\n",
- "\t\t\t#Isothermal compressibility is defined as\n",
- "\t\t\t# K_t = -(1/V)*(del V/del T)_T = -(1/V)*(dV/dT)_T\n",
- "K_t = -(1/V)*((0.0010361 - 0.0010410)/(15 - 5));\t\t\t#[MPa**(-1)] \t\t\t# The values are obtained from the steam table as reported in the book.\n",
- "\n",
- "K_t = K_t*10**(-3);\t\t\t#[kPa]\n",
- "\n",
- "print \"The value of isothermal compressibility is K_t = %e kPa**-1)\"%(K_t);\n",
- "\n",
- "\t\t\t# Cp - Cv = (T*V*(Beta**(2)))/K_t\n",
- "R = (T*V*(Beta**(2)))/K_t;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \"The value of the difference between Cp and Cv is Cp-Cv = %f kJ/kg-K\"%(R);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of volume expansivity is Beta = 7.318247e-04 K**-1)\n",
- "The value of isothermal compressibility is K_t = 4.718344e-07 kPa**-1)\n",
- "The value of the difference between Cp and Cv is Cp-Cv = 0.439860 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.23 Page Number : 257"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 300 + 273.15;\t\t\t#[K]\n",
- "P = 4;\t\t\t#[MPa] \n",
- "\n",
- "# Calculations and Results\n",
- "Cp_0 = 7.7 + 0.04594*10**(-2)*T + 0.2521*10**(-5)*T**(2) - 0.8587*10**(-9)*T**(3);\t\t\t#[cal/mol-K]\n",
- "Cp_0 = (Cp_0*4.186)/18.015;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t# Cp(T,P) = Cp_0(T,P=0) - T*integral((del**2 V/del T**(2))_P)*dP from limit 0 to P\n",
- "\t\t\t# Cp = Cp_0 - T*((del**2 V/del T**2)_Pavg)*(P_2 - P_1)\n",
- "\n",
- "P_avg = (0+4)/2;\t\t\t#[MPa]\n",
- "\n",
- "\t\t\t#Using finite difference we get (del**2 V/del T**(2)) = ((V_(T+delta T) - 2*V_T + V_(T-delta T))/(delta_T**(2))\n",
- "\t\t\t#(del**2 V/del T**(2))_Pavg = (V_(350 C) + V_(250 C) - 2*V_(300 C))/(delta_T**(2)) = del_2 (say)\n",
- "del_2 = (0.13857 + 0.11144 - 2*0.12547)/(50**(2));\t\t\t#[m**(3)/kg-K**2] \t\t\t# The values are obtained from the steam table as reported in the book.\n",
- "\n",
- "\n",
- "Cp = Cp_0 - T*del_2*4000;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "print \" The value of constant pressure specific heat capacity is Cp = %f kJ/kg-K\"%(Cp);\n",
- "\n",
- "\t\t\t# At P = 4 MPa\n",
- "\t\t\t# Cp = (del H/del T)_P = (H_350 C - H_250 C)/(350 - 250.4)\n",
- "\t\t\t# Cp = (3092.5 - 2801.4)/(350 - 250.4) = 2.923 [kJ/kg-K]\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of constant pressure specific heat capacity is Cp = 2.858079 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.24 Page Number : 257"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 300 + 273.15;\t\t\t#[K]\n",
- "P = 2.0;\t\t\t#[MPa]\n",
- "\n",
- "\t\t\t# At 2 MPa and 250 C \n",
- "H_1 = 2902.5;\t\t\t#[kJ/kg]\n",
- "\t\t\t# At 2 MPa and 350 C \n",
- "H_2 = 3137.0;\t\t\t#[kJ/kg]\n",
- "\n",
- "# Calculations\n",
- "Cp = (H_2 - H_1)/(350 - 250);\t\t\t#[kJ/kg-K]\n",
- "\n",
- "# Results\n",
- "print \" The value of constant pressure specific heat capacity is Cp = %f kJ/kg-K\"%(Cp);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of constant pressure specific heat capacity is Cp = 2.345000 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.25 Page Number : 258"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T = 80 + 273.15;\t\t\t#[K]\n",
- "P = 10;\t\t\t#[MPa] \n",
- "\n",
- "V_1 = 0.0010245;\t\t\t#[m**(3)/kg]\n",
- "\t\t\t# At 60 C and 10 MPa\n",
- "V_2 = 0.0010127;\t\t\t#[m**(3)/kg]\n",
- "\t\t\t# At 100 C and 10 MPa\n",
- "V_3 = 0.0010385;\t\t\t#[m**(3)/kg]\n",
- "\n",
- "# Calculations and Results\n",
- "Beta = (1/V_1)*((V_3 - V_2)/(100 - 60));\t\t\t#[K**(-1)]\n",
- "\n",
- "print \"The value of volume expansivity is Beta = %e K**-1)\"%(Beta);\n",
- "\n",
- "\t\t\t#Isothermal compressibility is given by\n",
- "\t\t\t# K_t = -(1/V)*(del V/del P)_T\n",
- "\n",
- "\t\t\t# Temperature is kept fixed at 80 C and different pressures are taken to calculate (del V/del P)_T\n",
- "\t\t\t# At 80 C and 5 MPa\n",
- "V_4 = 0.0010268;\t\t\t#[m**(3)/kg]\n",
- "\t\t\t# At 80 C and 10 MPa\n",
- "V_5 = 0.0010245;\t\t\t#[m**(3)/kg]\n",
- "\t\t\t# At 80 C and 15 MPa\n",
- "V_6 = 0.0010222;\t\t\t#[m**(3)/kg]\n",
- "\n",
- "\t\t\t# K_t = -(1/V)*(del V/del T)_P\n",
- "K_t = -(1/V_1)*((V_4 - V_6)/(5 - 15));\t\t\t#[MPa**(-1)]\n",
- "K_t = K_t*10**(-6);\t\t\t#[Pa**(-1)]\n",
- "\n",
- "print \"The value of isothermal compressibility is K_t = %e Pa**-1)\"%(K_t);\n",
- "\n",
- "\t\t\t# Cp - Cv = (T*V*(Beta**(2)))/K_t\n",
- "R = (T*V_1*(Beta**(2)))/K_t;\t\t\t#[J/kg-K]\n",
- "\n",
- "print \"The value of the difference between Cp and Cv is Cp-Cv = %f J/kg-K\"%(R);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of volume expansivity is Beta = 6.295754e-04 K**-1)\n",
- "The value of isothermal compressibility is K_t = 4.489995e-10 Pa**-1)\n",
- "The value of the difference between Cp and Cv is Cp-Cv = 319.389628 J/kg-K\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.26 Page Number : 260"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "P_1 = 150;\t\t\t#[bar]\n",
- "P_2 = 1;\t\t\t#[bar]\n",
- "\n",
- "T_1 = 300;\t\t\t#[K]\n",
- "T_2 = 260;\t\t\t#[K]\n",
- "T_3 = 280;\t\t\t#[K]\n",
- "T_4 = 200;\t\t\t#[K]\n",
- "T_5 = 120;\t\t\t#[K]\n",
- "T_6 = 140;\t\t\t#[K]\n",
- "\n",
- "H_P1_T1 = 271.8;\t\t\t#[kJ/kg]\n",
- "H_P2_T2 = 260.0;\t\t\t#[kJ/kg] \n",
- "H_P2_T3 = 280.2;\t\t\t#[kJ/kg]\n",
- "H_P1_T4 = 129.2;\t\t\t#[kJ/kg]\n",
- "H_P2_T5 = 118.8;\t\t\t#[kJ/kg]\n",
- "H_P2_T6 = 139.1;\t\t\t#[kJ/kg]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(a)\n",
- "\t\t\t# During the Joule-Thomson expansion the enthalpy should remain constant\n",
- "\t\t\t# Therefore at 1 bar the exit temperature is such that enthalpy is 271.8 kJ/kg\n",
- "\t\t\t# The temperature at which enthalpy is 271.8 kJ/kg is given by,\n",
- "T_new = ((H_P1_T1 - H_P2_T2)/(H_P2_T3 - H_P2_T2))*(T_3 - T_2) + T_2;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# Therefore Joule-Thomson coefficient is given by,\n",
- "meu = (T_1 - T_new)/(P_1 - P_2);\t\t\t#[K/bar]\n",
- "\n",
- "print \" a).The value of Joule-Thomson coefficient for initial T = 300 K) is %f J/bar\"%(meu);\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t# During the Joule-Thomson expansion the enthalpy should remain constant\n",
- "\t\t\t# Therefore at 1 bar the exit temperature is such that enthalpy is 129.2 kJ/kg\n",
- "\t\t\t# The temperature at which enthalpy is 129.2 kJ/kg is given by,\n",
- "T_new_prime = ((H_P1_T4 - H_P2_T5)/(H_P2_T6 - H_P2_T5))*(T_6 - T_5) + T_5;\t\t\t#[K]\n",
- "\n",
- "\t\t\t# Therefore Joule-Thomson coefficient is given by,\n",
- "meu_prime = (T_4 - T_new_prime)/(P_1 - P_2);\t\t\t#[K/bar]\n",
- "\n",
- "print \" b).The value of Joule-Thomson coefficient for initial T = 200 K) is %f J/bar\"%(meu_prime);\n",
- "\n",
- "\t\t\t# Therefore the Joule-Thomson coefficient is higher for low initial temperatures and therefore the drop in temperature is more.\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The value of Joule-Thomson coefficient for initial T = 300 K) is 0.190046 J/bar\n",
- " b).The value of Joule-Thomson coefficient for initial T = 200 K) is 0.468146 J/bar\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.27 Page Number : 261"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 300;\t\t\t#[K] - Temperature\n",
- "P = 5;\t\t\t#[atm] - Pressure\n",
- "P = P*101325;\t\t\t#[Pa]\n",
- "Cp_0 = 35.78;\t\t\t#[J/mol-K] - Smath.tan(math.radiansard specific heat capacity at constant pressure\n",
- "B = -50;\t\t\t#[cm**(3)/mol]\n",
- "B = B*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# (dB/dT) = 1.0 = dB_dT (say)\n",
- "dB_dT = 1.0;\t\t\t#[cm**(3)/mol-K]\n",
- "dB_dT = dB_dT*10**(-6);\t\t\t#[m**(3)/mol-K]\n",
- "\n",
- "\t\t\t# (d**2 B/d T**2) = -0.01 = dB_dT_2 (say)\n",
- "dB_dT_2 = -0.01;\t\t\t#[cm**(3)/mol-K**(2)]\n",
- "dB_dT_2 = dB_dT_2*10**(-6);\t\t\t#[m**(3)/mol-K**(2)]\n",
- "\n",
- "Cp = Cp_0 - P*T*(dB_dT_2);\t\t\t#[[J/mol-K]] - Specific heat capacity at constant pressure\n",
- "\n",
- "\t\t\t#Therefore Joule-Thomson coefficient is given by,\n",
- "meu = (1/Cp)*(-B + T*dB_dT);\t\t\t#[K/Pa]\n",
- "meu = meu*10**(5);\t\t\t#[K/bar]\n",
- "\n",
- "# Results\n",
- "print \" c).The value of Joule-Thomson coefficient is %f K/bar\"%(meu);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " c).The value of Joule-Thomson coefficient is 0.938341 K/bar\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.30 Page Number : 267"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "den_liq = 13690.;\t\t\t#[kg/m**(3)] - Density of liquid mercury\n",
- "den_solid = 14190.;\t\t\t#[kg/m**(3)] - Density of solid mercury\n",
- "mp = -38.87;\t\t\t#[C] - Melting point of mercury at pressure of 1 bar\n",
- "mp = mp + 273.15;\t\t\t#[K]\n",
- "T_req = 0.;\t\t\t#[C] - Required temperature to which the melting point is to be raised\n",
- "T_req = T_req + 273.15;\t\t\t#[K]\n",
- "H_fus = 11.62;\t\t\t#[kJ/kg] - Latent heat of fusion of mercury\n",
- "\n",
- "# Calculations\n",
- "V_liq = (1/den_liq);\t\t\t#[m**(3)/kg] - Specific volume of liquid mercury\n",
- "\n",
- "V_solid = (1/den_solid);\t\t\t#[m**(3)/kg] - Specific volume of solid mercury\n",
- "\n",
- "\t\t\t# (delta P/delta T) = ((P - 1)*100)/(T_req - mp)\n",
- "\t\t\t# delta H/(T*delta V) = (H_liq - H_solid)/(T*(V_liq - V_solid)) = del (say)\n",
- "d = (H_fus)/(mp*(V_liq - V_solid));\t\t\t#[kPa/K] - delta H/(T*delta V)\n",
- "\n",
- "\t\t\t#Equating the two sides and then solving we get\n",
- "P = (d*(T_req - mp))/100 + 1;\t\t\t#[bar]\n",
- "\n",
- "# Results\n",
- "print \" The required pressure should be %f bar\"%(P);\n",
- "\n",
- "# answers are correct but vary from book because of rouding error. please calculate manually."
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The required pressure should be 7491.335878 bar\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.31 Page Number : 268"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Calculations and Results\n",
- "\t\t\t#(1)\n",
- "\t\t\t# At 1 bar\n",
- "\t\t\t# Considering the data given at pressure 1 and 1000 bar, we have\n",
- "delta_H_fus_1 = ((1000-1)*10**(5)*(273.15-22.6)*3.97*10**(-6))/(14.8+22.6);\t\t\t#[J/mol]\n",
- "delta_S_fus_1 = delta_H_fus_1/(273.15-22.6);\t\t\t#[J/mol-K]\n",
- "\n",
- "print \" 1).The delta_H_fus at 1 bar is %f J/mol\"%(delta_H_fus_1);\n",
- "print \" The delta_S_fus at 1 bar is %f J/mol-K\"%(delta_S_fus_1);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t# At 6000 bar\n",
- "T_mean = (128.8+173.6)/2;\t\t\t#[C] - Mean temperature\n",
- "T_mean = T_mean + 273.15;\t\t\t#[K]\n",
- "delta_V_fus_mean = (1.12+1.55)/2;\t\t\t#[cm**(3)/mol]\n",
- "\n",
- "\t\t\t# Consider the data at pressure of 5000 and 7000 bar we get,\n",
- "delta_H_fus_2 = ((7000-5000)*10**(5)*(T_mean*delta_V_fus_mean*10**(-6)))/(173.6-128.8);\t\t\t#[J/mol]\n",
- "delta_S_fus_2 = delta_H_fus_2/T_mean;\t\t\t#[J/mol-K]\n",
- "\n",
- "print \" 2).The delta_H_fus at 6000 bar is %f J/mol\"%(delta_H_fus_2);\n",
- "print \" The delta_S_fus at 6000 bar is %f J/mol-K\"%(delta_S_fus_2);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1).The delta_H_fus at 1 bar is 2656.921969 J/mol\n",
- " The delta_S_fus at 1 bar is 10.604358 J/mol-K\n",
- " 2).The delta_H_fus at 6000 bar is 2529.050223 J/mol\n",
- " The delta_S_fus at 6000 bar is 5.959821 J/mol-K\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.32 Page Number : 268"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "H_fus = 80;\t\t\t#[cal/g] - Heat of fusion at 0 C and 1 atm pressure\n",
- "T = 0+273.15;\t\t\t#[K] - Temperature\n",
- "vol_ratio = 1.091;\t\t\t# Ratio of the specific volume of ice and water.\n",
- "sp_vol = 0.001;\t\t\t#[m**(3)/kg] - Specific volume of saturated liquid water.\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# The clapeyron equation can be written as\n",
- "\t\t\t# (dP/dT)_sat = T*delta V_LS/(delta H_LS) = (T*(V_ice - V_water))/(H_ice - H_water)\n",
- "dP_dT = (T*(vol_ratio - 1)*10**(-3))/(-H_fus*4.186);\t\t\t#[K/kPa]\n",
- "\n",
- "# Results\n",
- "print \"The value of dT/dP)_sat is %e K/kPa\"%(dP_dT);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of dT/dP)_sat is -7.422554e-05 K/kPa\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.33 Page Number : 268"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "P = 2;\t\t\t#[atm] - Surrounding pressure\n",
- "bp_water = 100 + 273.15;\t\t\t#[K] - Boiling point of water at 1 atm pressure\n",
- "delta_H_vap = 2257;\t\t\t#[kJ/kg] - Enthalpy of vaporization\n",
- "delta_H_vap = delta_H_vap*18.015;\t\t\t#[J/mol]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# The clapeyron equation is given by\n",
- "\t\t\t# math.log(P_2_sat/P_1_sat) = (-delta H_vap/R)*(1/T_2 - 1/T_1)\n",
- "P_1_sat = 1;\t\t\t#[atm]\n",
- "P_2_sat = P;\n",
- "T_1 = bp_water;\n",
- "\n",
- "\t\t\t# Solving the above equation\n",
- "T_2 = 1/((math.log(P_2_sat/P_1_sat))/(-delta_H_vap/R) + (1/T_1));\t\t\t#[K]\n",
- "T_2 = T_2 - 273.15;\t\t\t#[C]\n",
- "\n",
- "# Results\n",
- "print \" The boiling point of water at a pressure of 2 atm is %f C\"%(T_2);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The boiling point of water at a pressure of 2 atm is 120.836990 C\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.34 Page Number : 269"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T_1 = 0.01 +273.15;\t\t\t#[K]\n",
- "T_2 = 1 + 273.15;\t\t\t#[K]\n",
- "P_sat_1 = 0.611;\t\t\t#[kPa] - P_sat at temperature T_1\n",
- "P_sat_2 = 0.657;\t\t\t#[kPa] - P_sat at temperature T_2\n",
- "Mol_wt = 18.015;\t\t\t#[g/mol] - Molecular weight of water\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results \n",
- " # The clapeyron equation is given by\n",
- "\t\t\t# math.log(P_sat_2/P_sat_1) = (-delta H_LV/R)*(1/T_2 - 1/T_1)\n",
- "\n",
- "\t\t\t# Solving the above equation\n",
- "delta_H = -(math.log(P_sat_2/P_sat_1)/(1/T_2 - 1/T_1))*R;\t\t\t#[J/mol]\n",
- "delta_H = delta_H/Mol_wt;\t\t\t#[kJ/kg]\n",
- "\n",
- "print \" The enthalpy of vaporization is %f kJ/kg\"%(delta_H);\n",
- "\n",
- "\t\t\t# Entropy of vaporization is given by\n",
- "S_vap = delta_H/T_2;\t\t\t#[kJ/kg-K]\n",
- "print \" The entropy of vaporization is %f kJ/kg-K\"%(S_vap);"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The enthalpy of vaporization is 2533.991278 kJ/kg\n",
- " The entropy of vaporization is 9.243083 kJ/kg-K\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.35 Page Number : 269"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 100. + 273.15;\t\t\t#[K]\n",
- "\t\t\t# (dT/dP)_sat = (1/27.12) K/mm\n",
- "dT_dP = (1/27.12);\t\t\t#[K/mm]\n",
- "dT_dP = dT_dP*(760./101325);\t\t\t#[K/Pa]\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# The clapeyron equation is given by\n",
- "\t\t\t# (dP/dT)_sat = (-delta H_LV)/(T*delta V_LV)\n",
- "\t\t\t# delta H_LV = T*delta V_LV*(dP/dT)_sat\n",
- "\n",
- "\t\t\t# (dP/dT)_sat = 1/(dT/dP)_sat\n",
- "dP_dT = 1/dT_dP;\t\t\t#[Pa/K]\n",
- "\n",
- "\t\t\t# From saturated steam table at 100 C\n",
- "V_vap = 1.6729;\t\t\t#[m**(3)/kg]\n",
- "V_liq = 0.001044;\t\t\t#[m**(3)/kg]\n",
- "delta_V = V_vap - V_liq;\t\t\t#[m**(3)/kg]\n",
- "\n",
- "\t\t\t# Therefore delta_H_LV is given by\n",
- "delta_H_LV = T*delta_V*(dP_dT);\t\t\t#[J/kg]\n",
- "delta_H_LV = delta_H_LV*10**(-3);\t\t\t#[kJ/kg]\n",
- "\n",
- "# Results\n",
- "print \" The heat of vaporization of water is %f kJ/kg\"%(delta_H_LV);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The heat of vaporization of water is 2255.667174 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.36 Page Number : 270"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T_1 = 100 + 273.15;\t\t\t#[K]\n",
- "P_1 = 1.01325;\t\t\t#[bar]\n",
- "T_2 = 98 + 273.15;\t\t\t#[K]\n",
- "P_2 = 0.943;\t\t\t#[bar]\n",
- "V_vap = 1.789;\t\t\t#[m**(3)] - Volume in vapour phase\n",
- "vessel_vol = 1.673;\t\t\t#[m**(3)] - Volume of the vessel\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# The total volume remains constant as the walls are rigid. At 98 C we get\n",
- "\t\t\t# vessel_vol = V_liq*(1 - x) + V_vap*x\n",
- "\t\t\t# Since V_liq is negligible as compared to V_vap, therefore\n",
- "x = vessel_vol/V_vap;\n",
- "\n",
- "\t\t\t# The quantity is given by x = m_vap/(m_liq + m_vap)\n",
- "\t\t\t# Since (m_liq + m_vap) = 1, therefore at 98 C saturated vapour is x and saturated liquid is (1 - x)\n",
- "m_vap = x;\t\t\t#[kg] - Mass of saturated vapour\n",
- "m_liq = (1 - x);\t\t\t#[kg] - Mass of saturated liquid\n",
- "\n",
- "print \" The amount of vapour condensed is %f kg\"%(m_liq);\n",
- "\n",
- "\t\t\t# The clapeyron equation is given by\n",
- "\t\t\t# math.log(P_2_sat/P_1_sat) = (-delta H_LV/R)*(1/T_2 - 1/T_1)\n",
- "\n",
- "\t\t\t# Solving the above equation\n",
- "delta_H = -(math.log(P_2/P_1)/(1/T_2 - 1/T_1))*R;\n",
- "delta_H = delta_H/18.015;\t\t\t#[kJ/kg]\n",
- "\n",
- "print \" The latent heat of vaporization is %f kJ/kg\"%(delta_H);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The amount of vapour condensed is 0.064841 kg\n",
- " The latent heat of vaporization is 2296.240786 kJ/kg\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.37 Page Number : 270"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.integrate import quad \n",
- "from scipy.optimize import *\n",
- "\n",
- "\n",
- "# Variables\n",
- "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
- "delta_H_gas = -52.23;\t\t\t#[kcal/mol] - Enthalpy of formation of C2H5OH(gas)\n",
- "delta_H_liq = -66.35;\t\t\t#[kcal/mol] - Enthalpy of formation of C2H5OH(liq)\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# For ethanol(g) [T is in K and Cp_0 in cal/mol-K]\n",
- "\t\t\t# Cp_0 = 4.75 + 5.006*10**(-2)*T - 2.479*10**(-5)*T**(2) + 4.79*10**(-9)*T**(3)\n",
- "\n",
- "\t\t\t# For ethanol(l) [T is in K and Cp_0 in cal/mol-K]\n",
- "\t\t\t# Cp_0 = 67.29 - 0.343*T - 6.94*10**(-4)*T**(2)\n",
- "\n",
- "\t\t\t# The vaporization of a liquid can be written as C2H5OH(liq) - C2H5OH(gas)\n",
- "\t\t\t# Since the pressure is 1 atm therefore the smath.tan(math.radiansard data can be used\n",
- "delta_H_298 = delta_H_gas - delta_H_liq;\t\t\t#[kcal/mol]\n",
- "delta_H_298 = delta_H_298*1000;\t\t\t#[cal/mol]\n",
- "delta_a = 4.75 - 67.29;\n",
- "delta_b = 5.006*10**(-2) - (-0.343);\n",
- "delta_c = -2.479*10**(-5) - 6.94*10**(-4);\n",
- "delta_d = 4.79*10**(-9);\n",
- "\n",
- "\t\t\t# The smath.tan(math.radiansard enthalpy of vaporization at a temperature T is given by\n",
- "\n",
- "def f31(T): \n",
- "\t return delta_a + delta_b*T + delta_c*T**(2) + delta_d*T**(3)\n",
- "\n",
- "\t\t\t# delta_H_T = delta_H_298 + quad(f31,T_1,T)[0]\n",
- "\n",
- "\n",
- "\t\t\t# Therefore the smath.tan(math.radiansard enthalpy of vaporization at a temperature T = 283 K is given by\n",
- "T_2 = 283;\t\t\t#[K]\n",
- "\n",
- "def f32(T): \n",
- "\t return delta_a+delta_b*T+delta_c*T**(2)+delta_d*T**(3)\n",
- "\n",
- "delta_H_283 = delta_H_298 + quad(f32,T_1,T_2)[0]\n",
- "\n",
- "\n",
- "\t\t\t# Therefore the smath.tan(math.radiansard enthalpy of vaporization at a temperature T = 348 K is given by\n",
- "T_3 = 348;\t\t\t#[K]\n",
- "\n",
- "def f33(T): \n",
- "\t return delta_a+delta_b*T+delta_c*T**(2)+delta_d*T**(3)\n",
- "\n",
- "delta_H_348 = delta_H_298 + quad(f33,T_1,T_3)[0]\n",
- "\n",
- "\n",
- "print \" The value of enthalpy of vaporization at 283 K is %f cal/mol\"%(delta_H_283);\n",
- "print \" The value of enthalpy of vaporization at 298.15 K is %f cal/mol\"%(delta_H_298);\n",
- "print \" The value of enthalpy of vaporization at 348 K is %f cal/mol\"%(delta_H_348);\n",
- "print \" Therefore Standard enthalpy of vaporization decrease with the increase in temperature\";\n",
- "\n",
- "\t\t\t# Solving the above equatio manually we get,\n",
- "\t\t\t# delta_H_vap = 1.1975*10**(-9)*T**(4) - 2.396*10**(-4)*T**(3) + 0.1965*T**(2) - 62.54*T + 21639.54 \n",
- "\t\t\t# Solving for 'T' at which 'delta_H_vap' = 0\n",
- "def f(T): \n",
- "\t return 1.1975*10**(-9)*T**(4)-2.396*10**(-4)*T**(3)+0.1965*T**(2)-62.54*T + 21639.54\n",
- "T_0 = fsolve(f,500)\n",
- "\n",
- "\t\t\t# We know that at critical point (critical temperature and critical pressure) the enthalpy of vaporization is zero.\n",
- "\t\t\t# Here we have made the smath.tan(math.radiansard enthalpy of vaporization equal to zero which is at smath.tan(math.radiansard pressure of 1 atm.\n",
- "\t\t\t# Therefore following conclusions can be drawn\n",
- "print \" The temperature obtained by equating smath.tan(math.radiansard enthalpy of vaporization equal to zero is %f K\"%(T_0);\n",
- "print \" But the critical temperature of ethanol is 513.9 K , which is far from the temperature obtained above\"\n",
- "print \" Therefore the temperature obtained by equating smath.tan(math.radiansard enthalpy of vaporization equal to zero is not the critical temperature\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of enthalpy of vaporization at 283 K is 14255.030925 cal/mol\n",
- " The value of enthalpy of vaporization at 298.15 K is 14120.000000 cal/mol\n",
- " The value of enthalpy of vaporization at 348 K is 13593.385895 cal/mol\n",
- " Therefore Standard enthalpy of vaporization decrease with the increase in temperature\n",
- " The temperature obtained by equating smath.tan(math.radiansard enthalpy of vaporization equal to zero is 635.058887 K\n",
- " But the critical temperature of ethanol is 513.9 K , which is far from the temperature obtained above\n",
- " Therefore the temperature obtained by equating smath.tan(math.radiansard enthalpy of vaporization equal to zero is not the critical temperature\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.38 Page Number : 276"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "T = 300 + 273.15;\t\t\t#[K] - Temperature\n",
- "P = 9000;\t\t\t#[kPa] - Pressure\n",
- "P_sat = 8592.7;\t\t\t#[kPa] - Vapour pressure of saturated water at 300 C\n",
- "f_sat = 6738.9;\t\t\t#[kPa] - Fugacity of saturated water at 300 C\n",
- "V_liq = 25.28;\t\t\t#[cm**(3)/mol] - Molar volume of water in liquid phase\n",
- "V_liq = V_liq*10**(-6);\t\t\t# [m**(3)/mol]\n",
- "V_vap = 391.1;\t\t\t#[cm**(3)/mol] - Molar volume of water in vapour phase\n",
- "V_vap = V_vap*10**(-6);\t\t\t# [m**(3)/mol]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations\n",
- "\t\t\t# At 300 C and 9000 kPa water is a compressed liquid and its fugacity is given by\n",
- "\t\t\t# f = f_sat*exp[V_liq*(P - P_sat)/R*T]\n",
- "fugacity = f_sat*math.exp((V_liq*(P - P_sat)*1000)/(R*T));\n",
- "\n",
- "# Results\n",
- "print \" The fugacity of water at 9000 kPa is %f kPa\"%(fugacity);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The fugacity of water at 9000 kPa is 6753.477111 kPa\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.39 Page Number : 276"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 200 + 273.15;\t\t\t#[K] - Temperature\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\t\t\t# From steam table at 200 C as reported in the book\n",
- "P_sat = 1.5538;\t\t\t#[MPa] - Vapour pressure of saturated steam\n",
- "H_vap = 2793.2;\t\t\t#[kJ/kg] - Enthalpy of saturated steam in vapour phase\n",
- "S_vap = 6.4323;\t\t\t#[kJ/kg-K] - Entropy of saturated steam in vapour phase\n",
- "\n",
- "# Calculations\n",
- "G_sat = H_vap - T*S_vap;\t\t\t#[kJ/kg] - Gibbs free energy\n",
- "G_sat = G_sat*18.015;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# Now let us calculate the Gibbs free energy at the lowest pressure available in superheated steam tables at 200 C\n",
- "\t\t\t# At 200 C and 0.01 MPa as reported in the book\n",
- "H = 2879.5;\t\t\t#[kJ/kg] - Enthalpy\n",
- "S = 8.9038;\t\t\t#[kJ/kg-K] - Entropy\n",
- "G_ig = H - T*S;\t\t\t#[kJ/kg] - Gibbs free energy\n",
- "G_ig = G_ig*18.015;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# Integrating from ideal gas state at 200 C and 0.01 MPa to saturated vapour at 200 C we get\n",
- "\t\t\t# G_sat - G_ig = R*T*math.log(f_sat/f_ig)\n",
- "\n",
- "\t\t\t# Under the ideal gas condition the pressure is small therefore f_ig = P = 0.01 MPa\n",
- "f_ig = 0.01;\t\t\t#[MPa]\n",
- "\n",
- "\t\t\t# Solving the above equation\n",
- "f_sat = f_ig*(math.exp((G_sat - G_ig)/(R*T)));\t\t\t#[MPa]\n",
- "\n",
- "# Results\n",
- "print \" The fugacity of saturated steam at 200 C is %f MPa\"%(f_sat);\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The fugacity of saturated steam at 200 C is 1.426074 MPa\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.40 Page Number : 277"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 320 + 273.15;\t\t\t#[K]\n",
- "P_1 = 70;\t\t\t#[bar]\n",
- "P_2 = 170;\t\t\t#[bar]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#(a)\n",
- "\t\t\t# dG = R*T*dmath.log(f)\n",
- "\t\t\t# G - G_ig = R*T*math.log(f/f_ig)\n",
- "\n",
- "\t\t\t# From steam table the low pressure that is available is 1 kPa.\n",
- "f_ig = 1;\t\t\t#[kPa] - Assuming ideal gas behaviour at such low pressure\n",
- "\n",
- "\t\t\t# At 1 kPa (under saturated conditions)\n",
- "P_sat = 112.891;\t\t\t#[bar]\n",
- "\t\t\t# Therefore at both 1 kPa and 70 bar the stem is superheated and byond a pressure of 112.891 bar it is compressed liquid.\n",
- "\n",
- "\t\t\t# For superheated steam table at 1 kPa and 320 C, as repoted in the book\n",
- "H_1 = 3117.08;\t\t\t#[kJ/kg] - Enthalpy\n",
- "S_1 = 10.41232;\t\t\t#[kJ/kg-K] - Entropy\n",
- "\n",
- "\t\t\t# For superheated steam table at 70 bar and 320 C, as repoted in the book\n",
- "H_2 = 2916.92;\t\t\t#[kJ/kg] - Enthalpy\n",
- "S_2 = 6.0651;\t\t\t#[kJ/kg-K] - Entropy\n",
- "\n",
- "\t\t\t# At 70 bar and 320 C,\n",
- "G = H_2 - T*S_2;\t\t\t#[kJ/kg] - Gibbs free energy\n",
- "\t\t\t# At 1 kPa and 320 C\n",
- "G_ig = H_1 - T*S_1;\t\t\t#[kJ/kg] - Gibbs free energy\n",
- "\n",
- "\t\t\t# math.log(f/f_ig) = (G - G_ig)/(R*T)\n",
- "f = f_ig*(math.exp((G - G_ig)*18/(R*T)));\t\t\t#[kPa]\n",
- "f = f*10**(-2);\t\t\t#[bar]\n",
- "\n",
- "\t\t\t# At 70 bar\n",
- "phi = f/P_1;\n",
- "\n",
- "print \" a).The fugacity of steam at 320 C and 70 bar is %f bar\"%(f);\n",
- "print \" The fugacity coefficient at 320 C and 70 bar is phi = %f\"%(phi);\n",
- "\n",
- "\t\t\t#(b)\n",
- "\t\t\t# Now consider saturated steam at 320 C. We have\n",
- "P_sat = 112.891;\t\t\t#[bar]\n",
- "V_liquid = 1.5;\t\t\t#[cm**(3)/mol] - Molar vlume of saturated liquid\n",
- "V_liquid = V_liquid*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "V_vapour = 15.48;\t\t\t#[cm**(3)/mol] - Molar vlume of saturated vapour\n",
- "U_liqid = 1445.7;\t\t\t#[Kj/kg] - Internal energy of satuarted liquid\n",
- "U_vapour = 2528.9;\t\t\t#[kJ/kg] - Internal energy of satuarted vapour\n",
- "H_liquid = 1462.6;\t\t\t#[kJ/kg] - Enthalpy of saturated liquid\n",
- "H_vapour = 2703.7;\t\t\t#[kJ/kg] - Enthalpy of saturated vapour\n",
- "S_liquid = 3.45;\t\t\t#[kJ/kg-K] - Entropy of saturated liquid\n",
- "S_vapour = 5.5423;\t\t\t#[kJ/kg-K] - Entropy of saturated vapour\n",
- "\n",
- "\t\t\t# Now let us calculate Gibbs free energy of saturated liquid and saturated vapour\n",
- "G_liquid = H_liquid - T*S_liquid;\t\t\t#[kJ/kg]\n",
- "G_vapour = H_vapour - T*S_vapour;\t\t\t#[kJ/kg]\n",
- "\t\t\t# Note that under saturated conditions\n",
- "\t\t\t# G_sat = G_liquid = G_vapour\n",
- "G_sat = G_liquid;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t# math.log(f_sat/f_ig) = (G_sat - G_ig)/(R*T)\n",
- "f_sat = f_ig*(math.exp((G_sat - G_ig)*18/(R*T)));\t\t\t#[kPa]\n",
- "f_sat = f_sat*10**(-2);\t\t\t#[bar]\n",
- "\n",
- "phi_sat = f_sat/P_sat;\n",
- "\n",
- "\t\t\t# And now the fugacity is to be determined at 320 C and P = 170 bar. We know the following relation for compressed liquid.\n",
- "\t\t\t# f_CL = f_sat*exp(V_liquid*(P-P_sat)/(R*T))\n",
- "f_CL = f_sat*math.exp(V_liquid*18*(P_2-P_sat)*10**(5)/(R*T));\t\t\t#[bar]\n",
- "\n",
- "\t\t\t# Therefore the fugacity coefficient at 170 bar and 320 C is given by\n",
- "phi_2 = f_CL/P_2;\n",
- "\n",
- "print \" b).The fugacity of steam at 320 C and 170 bar is %f bar\"%(f_CL);\n",
- "print \" The fugacity coefficient at 320 C and 170 bar is phi = %f\"%(phi_2);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " a).The fugacity of steam at 320 C and 70 bar is 58.913361 bar\n",
- " The fugacity coefficient at 320 C and 70 bar is phi = 0.841619\n",
- " b).The fugacity of steam at 320 C and 170 bar is 86.552966 bar\n",
- " The fugacity coefficient at 320 C and 170 bar is phi = 0.509135\n"
- ]
- }
- ],
- "prompt_number": 24
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.41 Page Number : 278"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "T = 300 + 273.15;\t\t\t#[K]\n",
- "P_1 = 12500*10**(3);\t\t\t#[Pa]\n",
- "P_2 = 8581*10**(3);\t\t\t#[Pa]\n",
- "P_3 = 300*10**(3);\t\t\t#[Pa]\n",
- "V_liq = 1.404;\t\t\t#[cm**(3)/g] - Specific volume of liquid\n",
- "V_liq = (V_liq/10**(6))*18.015;\t\t\t#[m**(3)/mol]\n",
- "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t# state 1: 300 C, 12500 kPa\n",
- "\t\t\t# state 2: 300 C, 8581 kPa\n",
- "\t\t\t# state 3: 300 C, 300 kPa\n",
- "\n",
- "\t\t\t# From state 1 to state 2 the system is liquid water and if the molar volume of liquid is assumed costant we can write\n",
- "\t\t\t# G_2 - G_1 = V_liq*(P_2 - P_1)\n",
- "\t\t\t# G_2 - G_1 = R*Tmath.log(f_2/f_1)\n",
- "\t\t\t# Comparing the above two equations we get\n",
- "\t\t\t# (f_2/f_1) = exp((V_liq*(P_2 - P_1)/(R*T))\n",
- "f2_f1 = math.exp((V_liq*(P_2 - P_1)/(R*T))); \t\t\t# (f_2/f_1) = f2_f1 (say)\n",
- "\n",
- "\t\t\t# In state 2 the fugacity of liquid is same as that of saturated vapour and for the vapour phase change from state 2 to 3 the fugacity ratio is calculated using \n",
- "\t\t\t# G_3 - G_2 = R*Tmath.log(f_3/f_2)\n",
- "\n",
- "\t\t\t# At 300 C, 8581 kPa \n",
- "H_liq_2 = 2749.0;\t\t\t#[kJ/kg]\n",
- "S_vap_2 = 5.7045;\t\t\t#[kJ/kg-K]\n",
- "G_vap_2 = -520.53;\t\t\t#[kJ/kg]\n",
- "G_vap_2 = G_vap_2*18.015;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# At 300 C, 300 kPa \n",
- "H_3 = 3069.3;\t\t\t#[kJ/kg]\n",
- "S_3 = 7.7022;\t\t\t#[kJ/kg-K]\n",
- "G_3 = -1345.22;\t\t\t#[kJ/kg]\n",
- "G_3 = G_3*18.015;\t\t\t#[J/mol]\n",
- "\n",
- "\t\t\t# Substituting and solving the equation G_3 - G_2 = R*Tmath.log(f_3/f_2)\n",
- "f3_f2 = math.exp((G_3 - G_vap_2)/(R*T));\t\t\t# (f_3/f_2) = f3_f2 (say)\n",
- "\n",
- "\t\t\t# (f_3/f_1) = (f_3/f_2)*(f_2/f_1)\n",
- "f3_f1 = f3_f2*f2_f1;\n",
- "\n",
- "print \" The ratio of fugacity in the final state to that in the initial state is given by f3/f2 = %f\"%(f3_f2);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The ratio of fugacity in the final state to that in the initial state is given by f3/f2 = 0.044255\n"
- ]
- }
- ],
- "prompt_number": 25
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Chemical_Engineering_Thermodynamics/ch8_2.ipynb b/Chemical_Engineering_Thermodynamics/ch8_2.ipynb
deleted file mode 100755
index 6b83d68c..00000000
--- a/Chemical_Engineering_Thermodynamics/ch8_2.ipynb
+++ /dev/null
@@ -1,752 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:8df6804e24ffba947b26128cacd98ede56f82be4a3089c7567d672249f51ebda"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "\n",
- "Chapter 8 : Thermodynamic Cycles"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.1 Page Number : 287"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math\n",
- "\n",
- "# Variables\n",
- "P_1 = 30;\t\t\t#[bar]\n",
- "P_2 = 0.04;\t\t\t#[bar]\n",
- "\n",
- "\t\t\t#(1).Carnot cycle\n",
- "\t\t\t#It has been reported in the book that at 30 bar pressure (saturated) :\n",
- "H_liq_1 = 1008.42;\t\t\t#[kJ/kg]\n",
- "H_vap_1 = 2804.2;\t\t\t#[kJ/kg]\n",
- "S_liq_1 = 2.6457;\t\t\t#[kJ/kg-K]\n",
- "S_vap_1 = 6.1869;\t\t\t#[kJ/kh-K]\n",
- "\t\t\t#Therefore, H_1 = H_liq_1, H_2 = H_vap_1, S_1 = S_liq_1 and S_2 = S_vap_1\n",
- "H_1 = H_liq_1;\n",
- "H_2 = H_vap_1;\n",
- "S_1 = S_liq_1;\n",
- "S_2 = S_vap_1;\n",
- "\n",
- "#At 0.04 bar pressure (saturated) :\n",
- "H_liq_2 = 121.46;\t\t\t#[kJ/kg]\n",
- "H_vap_2 = 2554.4;\t\t\t#[kJ/kg]\n",
- "S_liq_2 = 0.4226;\t\t\t#[kJ/kg-K]\n",
- "S_vap_2 = 8.4746;\t\t\t#[kJ/kh-K]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Dryness fraction at state 3 can be found the fact that S_3 = S_2 \n",
- "x_3 = (S_2 - S_liq_2)/(S_vap_2 - S_liq_2);\n",
- "H_3 = H_liq_2*(1 - x_3) + x_3*H_vap_2;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Dryness fraction at state 4 can be found the fact that S_4 = S_1\n",
- "x_4 = (S_1 - S_liq_2)/(S_vap_2 - S_liq_2);\n",
- "H_4 = H_liq_2*(1 - x_4) + x_4*H_vap_2;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Work done by turbine W_tur = -delta_H = -(H_3 - H_2)\n",
- "W_tur = H_2 - H_3;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Work supplied by boiler,\n",
- "q_H = H_2 - H_1;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Work transfer in compressor is given by\n",
- "W_com = -(H_1 - H_4);\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Efficiency can now be calculated as\n",
- "\t\t\t#n = (Net work done/Work supplied by boiler)\n",
- "n_carnot = (W_tur + W_com)/q_H;\n",
- "\n",
- "\t\t\t#Efficiency of the Carnot cycle can also be determined from the formula\n",
- "\t\t\t# n = 1 - (T_L/T_H), Where T_L is saturated temperature at 0.04 bar and T_H is saturated temperature at 30 bar\n",
- "\n",
- "print \"1.Carnot cycle\";\n",
- "print \"The work done by the turbine is %f kJ/kg\"%(W_tur);\n",
- "print \"The heat transfer in the boiler is %f kJ/kg\"%(q_H);\n",
- "print \"The cycle efficiency is %f\"%(n_carnot);\n",
- "\n",
- "\t\t\t#(2).Rankine cycle\n",
- "\t\t\t#The enthalpies at state 2 and 3 remain as in the Carnot cycle\n",
- "\t\t\t#Saturated liquid enthalpy at 0.04 bar is \n",
- "H_4_prime = H_liq_2;\n",
- "\n",
- "\t\t\t#Saturated liquid volume at 0.04 bar as reported in the book is\n",
- "V_liq = 0.001004;\t\t\t#[m**(3)/kg]\n",
- "\t\t\t#Work transfer in pump can be calculated as\n",
- "W_pump = -V_liq*(P_1 - P_2)*100;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Work transfer around pump gives, W_pump = -delta_H = -(H_1_prime - H_4_prime);\n",
- "H_1_prime = H_4_prime - W_pump;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Heat supplied to boiler is\n",
- "q_H_prime = H_2 - H_1_prime;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Work done by turbine is\n",
- "W_tur_prime = H_2 - H_3;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Efficiency can now be calculated as\n",
- "\t\t\t#n = (Net work done/Heat input)\n",
- "n_rankine = (W_tur_prime + W_pump)/q_H_prime;\t\t\t#\n",
- "\n",
- "print \"2.Rankine cycle\";\n",
- "print \"The work done by the turbine is %f kJ/kg\"%(W_tur_prime);\n",
- "print \"The heat transfer in the boiler is %f kJ/kg\"%(q_H_prime);\n",
- "print \"The cycle efficiency is %f\"%(n_rankine);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1.Carnot cycle\n",
- "The work done by the turbine is 941.036567 kJ/kg\n",
- "The heat transfer in the boiler is 1795.780000 kJ/kg\n",
- "The cycle efficiency is 0.404166\n",
- "2.Rankine cycle\n",
- "The work done by the turbine is 941.036567 kJ/kg\n",
- "The heat transfer in the boiler is 2679.732016 kJ/kg\n",
- "The cycle efficiency is 0.350046\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.2 Page Number : 288"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_max = 700+273.15;\t\t\t#[K] - Maximum temperature.\n",
- "P_boiler = 10*10**(6);\t\t\t#[Pa] - Constant pressure in the boiler\n",
- "P_condenser = 10*10**(3);\t\t\t#[Pa] - Constant pressure in the condenser\n",
- "\n",
- "\t\t\t#At state 2 i.e, at 700 C and 10 MPa,it has been reported in the book that from steam table\n",
- "S_2 = 7.1687;\t\t\t#[kJ/kg-K] - Entropy\n",
- "H_2 = 3870.5;\t\t\t#[kJ/kg] - Enthalpy\n",
- "\n",
- "\t\t\t#At state 3 i.e, at 700 C and 10 KPa,\n",
- "S_3 = S_2;\t\t\t#[kJ/kg-K]- Entropy \n",
- "\n",
- "\t\t\t#For sturated steam at 10 kPa, it has been reported in the book that from steam table\n",
- "S_liq = 0.6493;\t\t\t#[kJ/kg-K]- Entropy of saturated liquid\n",
- "S_vap = 8.1502;\t\t\t#[kJ/kg-K] - Enthalpy of saturated liquid\n",
- "\t\t\t#Therefore steam is saturated and its dryness factor can be calculated as\n",
- "x = (S_2 - S_liq)/(S_vap - S_liq);\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#The enthalpy at state 3 is now calculated. For steam at 10 kPa,it has been reported in the book that from steam table\n",
- "H_liq = 191.83;\t\t\t#[kJ/kg]\n",
- "H_vap = 2584.7;\t\t\t#[kJ/kg]\n",
- "\t\t\t#Therefore enthalpy at state 3 is\n",
- "H_3 = H_liq*(1-x) + H_vap*x;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Work done by the turbine \n",
- "W_tur = -(H_3 - H_2);\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Now we have to calculate work input to the pump\n",
- "\t\t\t#State 4:Saturated liquid at 10 kPa\n",
- "\t\t\t#State 4:Compressed liquid at 10 MPa\n",
- "\t\t\t#Since volume of liquid does not get affected by pressure we take volume of saturated liquid at 10 kPa,\n",
- "V_liq = 0.001010;\t\t\t#[m**(3)/kg]\n",
- "\n",
- "\t\t\t#Work transfer in the pump is\n",
- "W_pump = -V_liq*(P_boiler - P_condenser)*10**(-3);\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Energy balance around pump gives, W_pump = -delta_H = -(H_1 - H_4)\n",
- "H_4 = H_liq;\t\t\t# Enthalpy at state 4 (saturated liquid at 10 kPa)\n",
- "H_1 = H_4 - W_pump;\t\t\t#[kJ/kg]\n",
- " \n",
- "\t\t\t#Heat supplied to boiler is\n",
- "q_H = H_2 - H_1;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Efficiency can now be calculated as\n",
- "\t\t\t#n = (Net work done/Heat input)\n",
- "n_rankine = (W_tur + W_pump)/q_H;\n",
- "\n",
- "print \"The efficiency of the Rankine cycle is found to be %f\"%(n_rankine);\n",
- "\n",
- "\t\t\t#Now let us determine the efficiency of Carnot cycle. The maximun temperature is 700 C and minimum temperature is that of saturated steam at 10 kPa,\n",
- "T_min = 45.81 + 273.15;\t\t\t#[K] - From steam table as reported in the book\n",
- "n_carnot = 1-(T_min/T_max);\n",
- "\t\t\t#Note that the efficiency of Rankine cycle is less than that of carnot cycle"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The efficiency of the Rankine cycle is found to be 0.433088\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.3 Page Number : 291"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "W = 1.1;\t\t\t#[kW] - Work done per ton of refrigeration \n",
- "\t\t\t#1 ton refrigeration = 3.517 kW, therefore\n",
- "H = 3.517;\t\t\t#[kW] - Heat absorbed\n",
- "T_low = -30 + 273.15;\t\t\t#[K] - Low temperature maintained\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#COP can be calculated as\n",
- "\t\t\t#COP = (Heat absorbed/Work done)\n",
- "COP = H/W;\n",
- "\n",
- "\t\t\t#For reversed carnot cycle, COP = T_low/(T_high - T_low). Solving this we get\n",
- "T_high = (T_low/COP) + T_low;\t\t\t#[K] - Higher temperature\n",
- "\n",
- "\t\t\t#Heat rejected is\n",
- "H_rej = W + H;\t\t\t#[kW];\n",
- "\n",
- "# Results\n",
- "print \"The COP is %f\"%(COP);\n",
- "print \"The higher temperature of the cycle is %f K\"%(T_high);\n",
- "print \"The heat rejected per ton of refrigeration is %f kW\"%(H_rej);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The COP is 3.197273\n",
- "The higher temperature of the cycle is 319.199190 K\n",
- "The heat rejected per ton of refrigeration is 4.617000 kW\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.4 Page Number : 292"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_high = 20 + 273.15;\t\t\t#[K] - High temperature\n",
- "T_low = 0 + 273.15;\t\t\t#[K] - Low temperature\n",
- "Q_H = 10;\t\t\t#[kW] - Heat supplied\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#If 'Q_H' is the rate at which heat is taken from surrounding and 'W' is the rate at which work is done,then\n",
- "\t\t\t# Q_H = W + Q_L\n",
- "\t\t\t#(Q_H/Q_L) = (T_high/T_low)\n",
- "\t\t\t#Also for a reversible cycle, (Q_H/Q_L) = 1 + (W/Q_L). Solving we get,\n",
- "Q_L = (T_low/T_high)*Q_H;\t\t\t#[kW]\n",
- "W = (Q_H - Q_L) ;\t\t\t#[kW]\n",
- " \n",
- "# Results\n",
- "print \"The minimum power required is %f kW\"%(W);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The minimum power required is 0.682245 kW\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.5 Page Number : 292"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "T_high = 40 + 273.15;\t\t\t#[K] - High temperature\n",
- "T_low = -20 + 273.15;\t\t\t#[K] - Low temperature\n",
- "C = 10;\t\t\t#[tons of refrigeration] - Capacity\n",
- "\t\t\t#1 ton refrigeration = 3.517 kW, therefore\n",
- "H = C*3.517;\t\t\t#[kW] - Heat absorbed\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#For reversed carnot cycle, COP = T_low/(T_high - T_low)\n",
- "COP = T_low/(T_high - T_low);\n",
- "\n",
- "\t\t\t# COP = (Refrigerating effect)/(Work input), therefore power required is given by\n",
- "P = (H/COP);\t\t\t#[kW]\n",
- "\n",
- "# Results\n",
- "print \"The COP is %f\"%(COP);\n",
- "print \"The power required is %f kW\"%(P);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The COP is 4.219167\n",
- "The power required is 8.335769 kW\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.6 Page Number : 292"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "COP = 4;\t\t\t#Coefficient of performance\n",
- "P = 10;\t\t\t#[kW] - Work done on the cycle\n",
- "\n",
- "# Calculations\n",
- "\t\t\t#For reversed carnot cycle, COP = T_low/(T_high - T_low)\n",
- "\t\t\t#ratio = (T_high/T_low),therefore\n",
- "ratio = -1/(COP + 1);\n",
- "\n",
- "\t\t\t# Refrigerating effect = (COP)*Work input, therefore refrigeration is given by\n",
- "H = COP*P;\t\t\t#[kW]\n",
- "\n",
- "\t\t\t#Maximum refrigearation in tons is given by\n",
- "H_max = (H/3.517);\n",
- "\n",
- "# Results\n",
- "print \"The maximum refrigeration value is %f ton\"%(H_max);\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The maximum refrigeration value is 11.373330 ton\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.7 Page Number : 292"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "m = 0.6;\t\t\t#[kg/s] - mass flow rate\n",
- "T_low = -20+273.15;\t\t\t#[K] - Temperature at which vapour enters the compressor\n",
- "T_high = 30+273.15;\t\t\t#[K] - Temperature at which vapour leaves the condenser\n",
- "\n",
- "\t\t\t#From saturated refrigeration-12 tables we get,at -20 C\n",
- "H_1 = 178.74;\t\t\t#[kJ/kg] - (H_1 = H_vap)\n",
- "P_1 = 0.15093;\t\t\t#[MPa] - (P_1 = P_sat)\n",
- "P_4 = P_1;\n",
- "S_1 = 0.7087;\t\t\t#[kJ/kg-K] - (S_1 = S_vap)\n",
- "S_2 = S_1;\n",
- "\n",
- "\t\t\t#At 30 C\n",
- "P_2 = 0.7449;\t\t\t#[MPa] - (P_2 = P_sat)\n",
- "P_3 = P_2;\n",
- "H_3 = 64.59;\t\t\t#[kJ/kg] - (H_3 = H_liq)\n",
- "H_4 = H_3;\n",
- "S_3 = 0.24;\t\t\t#[kJ/kg-K] - (S_3 = S_liq)\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#It is assumed that presssure drop in the evaporator and condenser are negligible. The heat transfer rate in the evaporator is\n",
- "Q_L = m*(H_1 - H_4);\n",
- "\n",
- "print \"The heat transfer rate in the evaporator is %f kW\"%(Q_L);\n",
- "\n",
- "\t\t\t#At state 2 (P = 0.7449 MPa and S = 0.7087 kJ/kg-K) and looking in the superheated tables we have to calculate the enthalpy at state 2\n",
- "\n",
- "\t\t\t#At P = 0.7 MPa and S = 0.6917 kJ/kg-K,\n",
- "H_11 = 200.46;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#At P = 0.7 MPa and S = 0.7153 kJ/kg-K,\n",
- "H_12 = 207.73;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Thus at P = 0.7 MPa and S = 0.7087 kJ/kg-K, enthalpy is given by\n",
- "H_13 = ((S_2 -0.6917)/(0.7153 - 0.6917))*(H_12 - H_11) + H_11;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#At P = 0.8 MPa and S = 0.7021 kJ/kg-K,\n",
- "H_21 = 206.07;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#At P = 0.8 MPa and S = 0.7253 kJ/kg-K,\n",
- "H_22 = 213.45;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Thus at P = 0.8 MPa and S = 0.7087 kJ/kg-K, enthalpy is given by\n",
- "H_23 = ((S_2 -0.7021)/(0.7253 - 0.7021))*(H_22 - H_21) + H_21;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#At P = 0.7449 MPa, S = 0.7087 kJ/kg-K, the enthalpy is\n",
- "H_2 = ((0.7449 - 0.7)/(0.8 - 0.7))*(H_23 - H_13) + H_13;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#Power consumed by the compressor is\n",
- "W_comp = m*(H_2 - H_1);\t\t\t#[kW]\n",
- "\n",
- "print \"The power consumed by the compressor is %f kW\"%(W_comp);\n",
- "\n",
- "\t\t\t#Heat removed in evaporator/work done on compressor\n",
- "COP_R = Q_L/W_comp;\n",
- "\n",
- "print \"The COP the refrigerator is %f kW\"%(COP_R);\n",
- "\n",
- "\n",
- "\t\t\t#At -20 C,saturated conditions \n",
- "H_liq = 17.82;\t\t\t#[kJ/kg]\n",
- "H_vap = 178.74;\t\t\t#[kJ/kg]\n",
- "x_4 = (H_4 - H_liq)/(H_vap - H_liq);\n",
- "\n",
- "print \"The dryness factor of refrigerant after the expansion valve is %f\"%(x_4);\n",
- "\n",
- "\t\t\t#The heat transfer rate in the condenser is\n",
- "Q_H = m*(H_3 - H_2);\t\t\t#[kW]\n",
- "\n",
- "print \"The heat transfer rate in the condenser is %f kW\"%(Q_H);\n",
- "\n",
- "\t\t\t#If the cycle would have worked as a pump then,\n",
- "\t\t\t#COP_HP = (Heat supplied from condenser/Work done on compressor)\n",
- "COP_HP = (-Q_H)/W_comp;\n",
- "\n",
- "print \"The COP if cycle would work as a heat pump is %f kW\"%(COP_HP);\n",
- "\n",
- "\t\t\t#If the cycle would have been a reversed Carnot cycle then\n",
- "COP_C = T_low/(T_high - T_low);\n",
- "\n",
- "print \"The COP if cycle would run as reversed Carnot cycle is %f kW\"%(COP_C);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The heat transfer rate in the evaporator is 68.490000 kW\n",
- "The power consumed by the compressor is 16.840242 kW\n",
- "The COP the refrigerator is 4.067044 kW\n",
- "The dryness factor of refrigerant after the expansion valve is 0.290641\n",
- "The heat transfer rate in the condenser is -85.330242 kW\n",
- "The COP if cycle would work as a heat pump is 5.067044 kW\n",
- "The COP if cycle would run as reversed Carnot cycle is 5.063000 kW\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.8 Page Number : 300"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\t\t\n",
- "\n",
- "# Variables\n",
- "H_1 = 310.38;\t\t\t#[kJ/kg]\n",
- "H_2 = 277.7;\t\t\t#[kJ/kg]\n",
- "H_5 = -122.6;\t\t\t#[kJ/kg]\n",
- "H_6 = 77.8;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#The enthalpy at point 3 is same at point 4 as the expansion is isenthalpic\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#The mass condensed is 1 kg and therefore m_1 = m+6 + 1\n",
- "\n",
- "\t\t\t#Enthalpy balance around heat exchanger\n",
- "\t\t\t#m_2*H_2 + m_2*H_6 = m_3*H_3 + m_7*H_7\n",
- "\n",
- "\t\t\t#Enthalpy balance around separator\n",
- "\t\t\t#m_4*H_4 = m_5*H_5 + m_6*H_6\n",
- "\t\t\t#It can be seen that m_1 = m_2 = m_3 = m_4\n",
- "\t\t\t#and m_6 = m_7 = m_1 - 1\n",
- "\n",
- "\t\t\t#Substituting the values for enthalpy balance around heat exchanger we get,\n",
- "\t\t\t#m_1*H_2 + (m_1 - 1)*(H_6) = m_1*H_3 + (m_1 - 1)*H_1\n",
- "\t\t\t#and substituting the values for enthalpy balance around seperator we get\n",
- "\t\t\t#m_1*H_3 = (1)*(-122.6) + (m_1 - 1)*77.8\n",
- "\t\t\t#H_3 = ((1)*(-122.6) + (m_1 - 1)*77.8)/m_1\n",
- "\t\t\t#Substituting the expression for 'H_3' in the above equation and then solving for m_1, we get\n",
- "def f(m_1): \n",
- "\t return m_1*H_2+(m_1-1)*(H_6)-m_1*(((1)*(-122.6) + (m_1 - 1)*77.8)/m_1)-(m_1-1)*H_1\n",
- "m_1 = fsolve(f,4)\n",
- "\t\t\t#Thus to liquify 1 kg of air compression of m_1 kg of air is carried out.\n",
- "\n",
- "\t\t\t#Now substituting this value of m_1 to get the value of H_3,\n",
- "H_3 = ((1)*(-122.6) + (m_1 - 1)*77.8)/m_1;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#From given compressed air table we see at 200 bar and 160 K,\n",
- "H_3_1 = 40.2;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#At 200 bar and 180 K,\n",
- "H_3_2 = 79.8;\t\t\t#[kJ/kg]\n",
- "\t\t\t#By interpolation we get,\n",
- "T_3 = ((H_3 - H_3_1)*(180 - 160))/(H_3_2 - H_3_1) + 160;\t\t\t#[K]\n",
- "\n",
- "print \"Temperature before throttling is %f K\"%(T_3);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Temperature before throttling is 171.350719 K\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.9 Page Number : 304"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "# Variables\n",
- "\t\t\t#At 1 bar, 310 K \n",
- "H_1 = 310.38;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 200 bar, 310 K\n",
- "H_2 = 277.7;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 1 bar, Saturated liquid\n",
- "H_7 = -122.6;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 1 bar, Saturated vapour\n",
- "H_8 = 77.8;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 200 bar, 200 K\n",
- "H_3 = 117.6;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 1 bar, 100 K\n",
- "H_11 = 98.3;\t\t\t#[kJ/kg]\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#For 1 kg of liquid air obtained,the overall enthalpy balance is\n",
- "\t\t\t#m_2*H_2 = W - 122.6 + (m_2 - 1)*H_1\n",
- "\t\t\t#W = - 0.8*m_2*(H_11 - H_3)\n",
- "\t\t\t#Overall enthalpy balance equation becomes\n",
- "\t\t\t#H_2*m_2 = 15.44*m_2 - H_7 + (m_2 - 1)*H_1, solving\n",
- "m_2_prime = (H_7 - H_1)/(H_2 - 15.44 - H_1);\n",
- "\n",
- "print \"The number of kimath.lograms of air compressed per kg of liquid air produced is %f kg\"%(m_2_prime);\n",
- "\n",
- "\t\t\t#(2)\n",
- "\t\t\t#Enthalpy balance around separator is \n",
- "\t\t\t#0.2*m_2*H_5 = -H_7 + (0.2*m_2 - 1)*H_8, solving\n",
- "m_2 = m_2_prime;\n",
- "H_5_prime = ((0.2*m_2-1)*H_8 - H_7)/(0.2*m_2);\n",
- "\n",
- "\t\t\t#At point 5, P = 200 bar and enthalpy is\n",
- "H_5_1 = -33.53;\t\t\t#[kJ/kg]\n",
- "\t\t\t#From compressed air tables at 200 bar and 140 K,\n",
- "H_5_2 = 0.2;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 200 bar and 120 K,\n",
- "H_5_3 = -38.0;\t\t\t#[kJ/kg]\n",
- "\t\t\t#Solving by interpolation we get\n",
- "T_5 = ((H_5_1 - H_5_3)*(140 - 120))/(H_5_2 - H_5_3) + 120;\t\t\t#[K]\n",
- "\n",
- "print \"The temperature of air before throttling is %f K\"%(T_5);\n",
- "\n",
- "\t\t\t#(3)\n",
- "\t\t\t#During mixing of streams 8 and 11 to produce stream 9, the enthalpy balance is\n",
- "\t\t\t# (0.2*m_2 - 1)*H_8 + 0.8*m_2*H_11 = (m_2 - 1)*H_9,Solving for H_9\n",
- "\n",
- "H_9_prime = ((0.2*m_2-1)*H_8+0.8*m_2*H_11)/(m_2 - 1);\n",
- "\n",
- "\t\t\t#From given compressed air tables at 1 bar and 100 K,\n",
- "H_9_1 = H_11;\n",
- "\t\t\t#At 1 bar and 90 K \n",
- "H_9_2 = 87.9;\t\t\t#[kJ/kg]\n",
- "\t\t\t#Solving by interpolation we get\n",
- "T_9 = ((H_9_prime - H_9_2)*(100 - 90))/(H_9_1 - H_9_2) + 90;\t\t\t#[K]\n",
- "\n",
- "print \"The temperature of stream entering second heat exchanger is %f K\"%(T_9);\n",
- "\n",
- "\t\t\t#(4)\n",
- "\t\t\t#Enthalpy balance around first heat exchanger is\n",
- "\t\t\t#H_2*m_2 + (m_2 - 1)*H_10 = H_3*m-2 + (m-2 - 1)*H_1, solving for H_10\n",
- "\n",
- "H_10_prime = ((m_2 - 1)*H_1 + H_3*m_2 - H_2*m_2)/(m_2 - 1);\n",
- "\n",
- "\t\t\t#From given compressed air tables at 1 bar and 140 K,\n",
- "H_10_1 = 139.1;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 1 bar and 120 K \n",
- "H_10_2 = 118.8;\t\t\t#[kJ/kg]\n",
- "\t\t\t#Solving by interpolation we get\n",
- "T_10 = ((H_10_prime - H_10_2)*(140 - 120))/(H_10_1 - H_10_2) + 120;\t\t\t#[K]\n",
- "\n",
- "print \"The temperature of stream exiting second heat exchanger is %f K\"%(T_10);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The number of kimath.lograms of air compressed per kg of liquid air produced is 8.997922 kg\n",
- "The temperature of air before throttling is 122.340314 K\n",
- "The temperature of stream entering second heat exchanger is 98.029358 K\n",
- "The temperature of stream exiting second heat exchanger is 131.292906 K\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.10 Page Number : 307"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "P_high = 40;\t\t\t#[bar]\n",
- "P_low = 5;\t\t\t#[bar]\n",
- "m_1 = 0.5;\t\t\t#[kg/s] - Rate of mass moving through the expander\n",
- "m_2 = 0.1;\t\t\t#[kg/s] - Rate of mass of vapour mixing with air\n",
- "e = 0.7;\t\t\t#Efficiency\n",
- "\n",
- "\t\t\t#At state 3,(40 bar and 200 K),enthalpy and entropy is given by\n",
- "H_3 = 179.7;\t\t\t#[kJ/kg]\n",
- "S_3 = 5.330;\t\t\t#[kJ/kg-K]\n",
- "\n",
- "\t\t\t#If isentropic conditions exits in the turbine then state 11 is at 5 bar\n",
- "S_11 = 5.330;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t#From given compressed air tables at 5 bar and 120 K,\n",
- "H_11_1 = 113.6;\t\t\t#[kJ/kg]\n",
- "S_11_1 = 5.455;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t#At 5 bar and 100 K \n",
- "H_11_2 = 90.6;\t\t\t#[kJ/kg]\n",
- "S_11_2 = 5.246;\t\t\t#[kJ/kg-K]\n",
- "\t\t\t#The enthalpy has to be determined when S = S_3\n",
- "\n",
- "# Calculations and Results\n",
- "\t\t\t#Solving by interpolation we get\n",
- "H_11_s = ((H_11_1 - H_11_2)*(S_3 - S_11_2))/(S_11_1 - S_11_2) + H_11_2;\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#The adiabatic efficiency of tyrbine is given by\n",
- "\t\t\t#(H_3 - H_11_a)/(H_3 - H_11_s) = e\n",
- "H_11_a = H_3 - e*(H_3 - H_11_s);\t\t\t#[kJ/kg] - Actual enthalpy\n",
- "\n",
- " \t\t\t#At 5 bar,the saturated enthalpy is given to be\n",
- "H_8 = 88.7;\t\t\t#[kJ/kg]\n",
- "\t\t\t#From enthalpy balance during mixing we get,\n",
- "\t\t\t#0.1*H_8 + 0.5*H_11_a = 0.6*H_9\n",
- "H_9 = (m_2*H_8 + m_1*H_11_a)/(m_1 + m_2);\t\t\t#[kJ/kg]\n",
- "\n",
- "\t\t\t#From given compressed air tables at 5 bar and 140 K,\n",
- "H_9_1 = 135.3;\t\t\t#[kJ/kg]\n",
- "\t\t\t#At 5 bar and 120 K \n",
- "H_9_2 = 113.6;\t\t\t#[kJ/kg]\n",
- "\t\t\t#By interpolation we get\n",
- "T_9 = ((H_9 - H_11_1)*(140 - 120))/(H_9_1 - H_11_1) + 120;\t\t\t#[K]\n",
- "\n",
- "print \" The temperature of air entering the second heat exchanger is %f K\"%(T_9);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The temperature of air entering the second heat exchanger is 124.009841 K\n"
- ]
- }
- ],
- "prompt_number": 10
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file