summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics_by_P_Ahuja/15-Vapour_Liquid_Equilibria.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Chemical_Engineering_Thermodynamics_by_P_Ahuja/15-Vapour_Liquid_Equilibria.ipynb')
-rw-r--r--Chemical_Engineering_Thermodynamics_by_P_Ahuja/15-Vapour_Liquid_Equilibria.ipynb1914
1 files changed, 1914 insertions, 0 deletions
diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/15-Vapour_Liquid_Equilibria.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/15-Vapour_Liquid_Equilibria.ipynb
new file mode 100644
index 0000000..cf05042
--- /dev/null
+++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/15-Vapour_Liquid_Equilibria.ipynb
@@ -0,0 +1,1914 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 15: Vapour Liquid Equilibria"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.10: Determination_of_vapour_and_liquid_phase_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.10\n",
+"//Page number - 527\n",
+"printf('Example - 15.10 and Page number - 527\n\n');\n",
+"\n",
+"//Given\n",
+"T = 50;//[C] - Temperature\n",
+"P = 64;//[kPa] - Pressure\n",
+"z_1 = 0.7;\n",
+"z_2 = 0.3;\n",
+"\n",
+"// 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",
+"// At 50 C,\n",
+"P_1_sat = exp(A_1 - B_1/(T + C_1));//[kPa]\n",
+"P_2_sat = exp(A_2 - B_2/(T + C_2));//[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",
+"deff('[y]=f(V)','y=(K_1*z_1)/(1-V+K_1*V) + (K_2*z_2)/(1-V+K_2*V) -1');\n",
+"V = fsolve(0.1,f);\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",
+"printf(' The value of V = %f\n',V);\n",
+"printf(' The value of L = %f\n\n',L);\n",
+"printf(' The liquid phase composition is, x_1 = %f and x_2 = %f\n',x_1,x_2);\n",
+"printf(' The vapour phase composition is, y_1 = %f and y_2 = %f',y_1,y_2);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.11: Calculation_of_temperature.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.11\n",
+"//Page number - 528\n",
+"printf('Example - 15.11 and Page number - 528\n\n');\n",
+"\n",
+"//Given\n",
+"P = 12.25*101325*10^(-3);//[kPa]\n",
+"z_1 = 0.8;\n",
+"z_2 = 1 - z_1;\n",
+"V = 0.4;\n",
+"// log(P_1_sat) = 13.7713 - 2892.47/(T + 248.82)\n",
+"// log(P_2_sat) = 13.7224 - 2151.63/(T + 236.91)\n",
+"\n",
+"// P_1_sat = exp(13.7713 - 21892.47/(T + 248.82));\n",
+"// P_2_sat = 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*(exp(13.7713 - 21892.47/(T + 248.82))) + x_2*(exp(13.7224 - 2151.63/(T + 236.91)));\n",
+"\n",
+"deff('[y]=f(T)','y=x_1*(exp(13.7713 - 1892.47/(T + 248.82))) + x_2*(exp(13.7224 - 2151.63/(T + 236.91))) - P');\n",
+"T_1 = fsolve(0.1,f);\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",
+"deff('[y]=f1(T)','y=1/(y_1/(exp(13.7713 - 1892.47/(T + 248.82))) + y_2/(exp(13.7224 - 2151.63/(T + 236.91)))) - P');\n",
+"T_2 = fsolve(0.1,f1);\n",
+"DPT = T_2;\n",
+"\n",
+"// Now the assumed temperature should be in the range of BPT and DPT\n",
+"// Let the assumed temperature be 47 C\n",
+"T = 47;//[C]\n",
+"error = 10;\n",
+"while(error>0.001)\n",
+" P_1_sat = exp(13.7713 - 1892.47/(T + 248.82));\n",
+" P_2_sat = 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",
+"end\n",
+"\n",
+"printf(' The temperature when 40 mol %% of mixture is in the vapour is %f C',T);\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.12: Determination_of_number_of_moles_in_liquid_and_vapour_phase.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.12\n",
+"//Page number - 529\n",
+"printf('Example - 15.12 and Page number - 529\n\n');\n",
+"\n",
+"//Given\n",
+"T = 105;//[C]\n",
+"P = 1.5;//[atm]\n",
+"P = P*101325*10^(-3);//[kPa]\n",
+"z = [0.4,0.3667,0.2333];// Feed composition\n",
+"x = [0.3,0.3,0.4];// Equilibrium liquid phase composition\n",
+"y = [0.45,0.40,0.15];// 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",
+"\n",
+"for i=1:3;\n",
+" L = (z(i) - y(i))/(x(i) - y(i));\n",
+" V = 1 - L;\n",
+" printf(' The number of moles in liquid phase (z = %f) is given by ,L = %f\n',z(i),L);\n",
+" printf(' The number of moles in vapour phase (z = %f) is given by ,V = %f\n\n',z(i),V);\n",
+"end\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.13: Determination_of_vapour_and_liquid_phase_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.13\n",
+"//Page number - 530\n",
+"printf('Example - 15.13 and Page number - 530\n\n');\n",
+"\n",
+"//Given\n",
+"T = 90;//[C]\n",
+"P = 1;//[atm]\n",
+"P = P*101325*10^(-3);//[kPa]\n",
+"z_1 = [0.1,0.5,0.8];\n",
+"\n",
+"// log(P_1_sat) = 13.8594 - 2773.78/(t + 220.07)\n",
+"// log(P_2_sat) = 14.0098 - 3103.01/(t + 219.79)\n",
+"\n",
+"//At T = 90 C\n",
+"P_1_sat = exp(13.8594 - 2773.78/(T + 220.07));\n",
+"P_2_sat = 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",
+"printf(' For two phase region to exist at 90 C and 101.325 kPa, z_1 sholud lie between %f and %f\n\n',x_1,y_1);\n",
+"printf(' For z_1 = 0.1 and z_1 = 0.5, only liquid phase exists (V = 0).\n\n');\n",
+"printf(' For z_1 = 0.8, only vapour exists (V = 1).\n')\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.14: Preparation_of_table_having_composition_and_pressure_data.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.14\n",
+"//Page number - 531\n",
+"printf('Example - 15.14 and Page number - 531\n\n');\n",
+"\n",
+"//Given\n",
+"T = 90;//[C]\n",
+"P = 1;//[atm]\n",
+"P = P*101325*10^(-3);//[kPa]\n",
+"z_1 = [0.1,0.5,0.8];\n",
+"\n",
+"// log(P_1_sat) = 13.8594 - 2773.78/(t + 220.07)\n",
+"// log(P_2_sat) = 14.0098 - 3103.01/(t + 219.79)\n",
+"\n",
+"//(a)\n",
+"//At T = 90 C\n",
+"P_1_sat = exp(13.8594 - 2773.78/(T + 220.07));\n",
+"P_2_sat = 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(1,11);\n",
+"x_2 = zeros(11);\n",
+"y_1 = zeros(11);\n",
+"\n",
+"printf(' (a).\n\n');\n",
+"printf(' x_1 \t\t P \t\t y_1 \n\n');\n",
+"\n",
+"for i=1: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",
+" printf(' %f \t %f \t %f \n',x_1(i),P_prime(i),y_1(i));\n",
+"end\n",
+"\n",
+"//(b)\n",
+"T_1_sat = 2773.78/(13.8594-log(P)) - 220.07;//[C]\n",
+"T_2_sat = 3103.01/(14.0098-log(P)) - 219.79;//[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",
+"printf(' \n\n (b).\n\n');\n",
+"printf(' T(C) \t\t P_1_sat (kPa) \t\t P_2_sat (kPa) \t\t x_1 \t\t y_1 \n\n');\n",
+"\n",
+"for j=1:11;\n",
+" P1_sat(j) = exp(13.8594 - 2773.78/(T_prime(j) + 220.07));\n",
+" P2_sat(j) = 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",
+" printf(' %f \t %f \t %f \t %f \t %f \n',T_prime(j),P1_sat(j),P2_sat(j),x_1(j),y_1(j));\n",
+"end\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.15: Calculation_of_DPT_and_BPT.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.15\n",
+"//Page number - 533\n",
+"printf('Example - 15.15 and Page number - 533\n\n');\n",
+"\n",
+"//Given\n",
+"// log(Y1) = 0.95*x_2^(2)\n",
+"// log(Y2) = 0.95*x_1^(2)\n",
+"P_1_sat = 79.80;//[kPa]\n",
+"P_2_sat = 40.45;//[kPa]\n",
+"\n",
+"//(1)\n",
+"T = 373.15;//[K]\n",
+"x_1 = 0.05;\n",
+"x_2 = 1 - x_1;\n",
+"Y1 = exp(0.95*x_2^(2));\n",
+"Y2 = exp(0.95*x_1^(2));\n",
+"\n",
+"// The total pressure of the system is given by\n",
+"P = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;//[kPa]\n",
+"y_1 = x_1*Y1*P_1_sat/P;\n",
+"y_2 = x_2*Y2*P_2_sat/P;\n",
+"\n",
+"printf(' (1).The first bubble is formed at %f kPa and the composition, y_1 = %f\n\n',P,y_1);\n",
+"\n",
+"//(2)\n",
+"T = 373.15;//[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 = exp(0.95*x_2_prime^(2));\n",
+" Y2_prime = 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",
+"end\n",
+"\n",
+"P_2 = x_1_prime*Y1_prime*P_1_sat + x_2_prime*Y2_prime*P_2_sat;\n",
+"\n",
+"printf(' (2).The first drop is formed at %f kPa and has the composition, x_1 = %f',P_2,x_1_prime);\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.16: Calculation_of_pressure.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.16\n",
+"//Page number - 534\n",
+"printf('Example - 15.16 and Page number - 534\n\n');\n",
+"\n",
+"//Given\n",
+"T = 78.15;//[C]\n",
+"P_1_sat = 755;//[mm Hg]\n",
+"P_2_sat = 329;//[mm Hg]\n",
+"\n",
+"z_1 = 0.3;\n",
+"V = 0.5;\n",
+"\n",
+"// log(Y1) = 0.845/(1 + 0.845*(x_1/x_2))^(2)\n",
+"// 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",
+"error = 10;\n",
+"while(error>0.001)\n",
+" x_2 = 1 - x_1;\n",
+" Y1 = exp(0.845/(1 + 0.845*(x_1/x_2))^(2));\n",
+" Y2 = 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",
+"end\n",
+"\n",
+"P_prime = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;//[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",
+"printf(' The required pressure is %f mm Hg\n\n',P_prime);\n",
+"printf(' and the mole fraction of component 1 in the liquid phase for this pressure is x_1 = %f\n\n',x_1);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.17: Calculation_of_van_Laar_activity_coefficient_parameters.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.17\n",
+"//Page number - 536\n",
+"printf('Example - 15.17 and Page number - 536\n\n');\n",
+"\n",
+"//Given\n",
+"T = 25;//[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];//[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;//[mm Hg]\n",
+"// Pressure value for which x_1 = y_1 = 1, corresponds to P_1_sat,therefore\n",
+"P_1_sat = 230.40;//[mm Hg]\n",
+"\n",
+"x_2 = zeros(1,15);\n",
+"y_2 = zeros(1,15);\n",
+"Y1 = zeros(1,15);\n",
+"Y2 = zeros(1,15);\n",
+"GE_RT = zeros(1,15);\n",
+"x1x2_GE_RT = zeros(1,15);\n",
+"for i=1:15;\n",
+" x_2(1,i) = 1 - x_1(i);\n",
+" y_2(1,i) = 1 - y_1(i);\n",
+" Y1(1,i) = (y_1(i)*P(i))/(x_1(i)*P_1_sat);\n",
+" Y2(1,i) = (y_2(i)*P(i))/(x_2(i)*P_2_sat);\n",
+" GE_RT(1,i) = x_1(i)*log(Y1(i)) + x_2(i)*log(Y2(i));// G_E/(R*T)\n",
+" x1x2_GE_RT(1,i) = (x_1(i)*x_2(i))/GE_RT(i);\n",
+"end\n",
+"\n",
+"[M,N,sig]=reglin(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",
+"printf(' The value of Van Laar coefficient A = %f\n\n',A);\n",
+"printf(' The value of Van Laar coefficient B = %f\n',B);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.18: Prediction_of_azeotrrope_formation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.18\n",
+"//Page number - 541\n",
+"printf('Example - 15.18 and Page number - 541\n\n');\n",
+"\n",
+"//Given\n",
+"T = 343.15;//[K] - Temperature\n",
+"// At 343.15 K\n",
+"// log(Y1) = 0.95*x_2^(2)\n",
+"// log(Y2) = 0.95*x_1^(2)\n",
+"P_1_sat = 79.80;//[kPa]\n",
+"P_2_sat = 40.50;//[kPa]\n",
+"\n",
+"// At x_1 = 0,\n",
+"Y1_infinity = exp(0.95);\n",
+"alpha_12_x0 = (Y1_infinity*P_1_sat)/(P_2_sat);\n",
+"// At x_1 = 1,\n",
+"Y2_infinity = 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 logarithm of both sides we get\n",
+"// log(Y2) - log(Y1) = log(P_1_sat/P_2_sat)\n",
+"// 0.95*x_1^(2) - 0.95*x_2^(2) = log(P_1_sat/P_2_sat)\n",
+"// Solving the above equation\n",
+"deff('[y]=f(x_1)','y=0.95*x_1^(2) - 0.95*(1-x_1)^(2) - log(P_1_sat/P_2_sat)');\n",
+"x_1 = fsolve(0.1,f);\n",
+"\n",
+"// At x_1\n",
+"x_2 = 1 - x_1;\n",
+"Y1 = exp(0.95*x_2^(2));\n",
+"Y2 = exp(0.95*x_1^(2));\n",
+"P = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;//[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",
+"printf(' Since (alpha_12_x=0) = %f and (alpha_12_x=1) = %f \n',alpha_12_x0,alpha_12_x1);\n",
+"printf(' 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\n')\n",
+"printf(' The azeotrope composition is x_1 = y_1 = %f\n\n',x_1);\n",
+"printf(' The azeotrope presssure is %f kPa\n',P);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.19: Tabulation_of_activity_coefficients_relative_volatility_and_compositions.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.19\n",
+"//Page number - 541\n",
+"printf('Example - 15.19 and Page number - 541\n\n');\n",
+"\n",
+"//Given\n",
+"T = 45;//[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",
+"// Pressure value for which x_1 = y_1 = 0, corresponds to P_2_sat,therefore\n",
+"P_2_sat = 29.819;//[kPa]\n",
+"// Pressure value for which x_1 = y_1 = 1, corresponds to P_1_sat,therefore\n",
+"P_1_sat = 27.778;//[kPa]\n",
+"\n",
+"x_2 = zeros(1,12);\n",
+"y_2 = zeros(1,12);\n",
+"Y1 = zeros(1,12);\n",
+"Y2 = zeros(1,12);\n",
+"alpha_12 = zeros(1,12);\n",
+"GE_RT = zeros(1,12);\n",
+"x1x2_GE_RT = zeros(1,12);\n",
+"\n",
+"printf(' 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');\n",
+"\n",
+"for i=1:12;\n",
+" x_2(1,i) = 1 - x_1(i);\n",
+" y_2(1,i) = 1 - y_1(i);\n",
+" Y1(1,i) = (y_1(i)*P(i))/(x_1(i)*P_1_sat);\n",
+" Y2(1,i) = (y_2(i)*P(i))/(x_2(i)*P_2_sat);\n",
+" alpha_12(1,i) = (y_1(i)/x_1(i))/(y_2(i)/x_2(i));\n",
+" GE_RT(1,i) = x_1(i)*log(Y1(i)) + x_2(i)*log(Y2(i));// G_E/(R*T)\n",
+" x1x2_GE_RT(1,i) = (x_1(i)*x_2(i))/GE_RT(i);\n",
+" printf(' %f\t %f\t %f \t %f \t %f \t %f\t %f \t%f\n\n',x_1(i),y_1(i),P(i),Y1(i),Y2(i),alpha_12(i),GE_RT(i),x1x2_GE_RT(i));\n",
+"end\n",
+"\n",
+"[M,N,sig]=reglin(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",
+"// Now let us assume the system to follow van Laar activity coefficient model. \n",
+"// 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",
+"// 1/A = N\n",
+"A = 1/N;\n",
+"// (1/B - 1/A) = M\n",
+"B = 1/(M + 1/A);\n",
+"\n",
+"printf('\n\n')\n",
+"printf(' The value of van Laar parameters are, A = %f and B = %f \n\n',A,B);\n",
+"\n",
+"Y1_infinity = exp(A);\n",
+"Y2_infinity = exp(B);\n",
+"\n",
+"\n",
+"// Azeotrope is formed when maxima ( or mainina) in pressure is observed and relative volatility becomes 1.\n",
+"// This is the case for x_1 between 0.2980 and 0.5458. \n",
+"// 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",
+"// Now let us calculate the azeotrope composition.\n",
+"// At azeotrope, Y1*P1_sat = Y2*P2_sat\n",
+"// log(Y1/Y2) = log(P_2_sat/P_1_sat)\n",
+"// From van Laar model we get\n",
+"// 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",
+"// Solving the above equation\n",
+"deff('[y]=f(x_1)','y= 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(0.1,f);\n",
+"\n",
+"printf(' The azeotrope composition is given by x_1 = y_1 = %f\n',x_1);\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.1: Calculation_of_number_of_moles_in_liquid_and_vapour_phase.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.1\n",
+"//Page number - 503\n",
+"printf('Example - 15.1 and Page number - 503\n\n');\n",
+"\n",
+"//Given\n",
+"T = 90+ 273.15;//[K] - Temperature\n",
+"P = 1;//[atm] - Pressure\n",
+"x_1 = 0.5748;// Equilibrium composition of liquid phase\n",
+"y_1 = 0.7725;// Equilibrium composition of vapour phase\n",
+"\n",
+"// We start with 1 mol of mixture of composition z_1 = 0.6, from marterial balance we get\n",
+"// (L + V)*z_1 = L*x_1 + V*y_1\n",
+"// Since total number of moles is 1, we get\n",
+"// z_1 = L*x_1 + (1-L)*y_1\n",
+"\n",
+"z_1_1 = 0.6;// - Mole fraction of benzene\n",
+"L_1 = (z_1_1 - y_1)/(x_1 - y_1);\n",
+"V_1 = 1 - L_1;\n",
+"\n",
+"printf(' For z_1 = 0.6\n');\n",
+"printf(' The moles in the liquid phase is %f mol\n',L_1);\n",
+"printf(' The moles in the vapour phase is %f mol\n\n',V_1);\n",
+"\n",
+"z_1_2 = 0.7;// - Mole fraction of benzene\n",
+"L_2 = (z_1_2 - y_1)/(x_1 - y_1);\n",
+"V_2 = 1 - L_2;\n",
+"\n",
+"printf(' For z_1 = 0.7\n');\n",
+"printf(' The moles in the liquid phase is %f mol\n',L_2);\n",
+"printf(' The moles in the vapour phase is %f mol\n\n',V_2);\n",
+"\n",
+"\n",
+"// For z = 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",
+"printf(' For z_1 = 0.8\n');\n",
+"printf(' 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",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.20: Tabulation_of_partial_pressure_and_total_pressure_data_of_components.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.20\n",
+"//Page number - 541\n",
+"printf('Example - 15.20 and Page number - 543\n\n');\n",
+"\n",
+"//Given\n",
+"T = 25;//[C] - Temperature\n",
+"P_1_sat = 230.4;//[mm Hg]\n",
+"P_2_sat = 97.45;//[mm Hg]\n",
+"Y1_infinity = 8.6;\n",
+"Y2_infinity = 6.6;\n",
+"\n",
+"// Assuming ideal vpour behaviour means that phi = 1 and since system pressure is low, therefore\n",
+"// f_i = P_i_sat \n",
+"// Assuming the activity coefficients to follow van Laar model we get\n",
+"A = log(Y1_infinity);\n",
+"B = log(Y2_infinity);\n",
+"\n",
+"//log(Y1) = A/(1+ (A*x_1)/(B*x_2))^(2)\n",
+"// 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",
+"printf(' (a).\n\n');\n",
+"printf(' x_1 \t\t Y1 \t\t Y2 \t\t y1*P \t\t y2*P \t\t P \t\t y_1 \n\n');\n",
+"\n",
+"for i=1:9;\n",
+" x_2(i) = 1 - x_1(i);\n",
+" Y1(i) = exp(A/(1+ (A*x_1(i))/(B*x_2(i)))^(2));\n",
+" Y2(i) = 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",
+" printf(' %f\t\t %f\t\t %f \t\t %f \t\t %f \t\t %f \t %f\n\n',x_1(i),Y1(i),Y2(i),y1_P(i),y2_P(i),P(i),y_1(i));\n",
+"\n",
+"end\n",
+"\n",
+"//(b)\n",
+"// The total system pressure versus x_1 shows a maxima and thus azeotrope is formed by the VLE system\n",
+"// 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",
+"// At the azeotrope point, Y1*P1_sat = Y2*P2_sat\n",
+"// log(Y1) - log(Y2) = log(P_2_sat/P_1_sat)\n",
+"// On putting the values and then solving the above equation we get\n",
+"deff('[y]=f(x_1)','y= A/(1+1.14*x_1/(1-x_1))^(2)- B/(1+0.877*(1-x_1)/x_1)^(2) - log(P_2_sat/P_1_sat)');\n",
+"x_1_prime = fsolve(0.1,f);\n",
+"\n",
+"// At x_1\n",
+"x_2_prime = 1 - x_1_prime;\n",
+"Y1_prime = exp(A/(1+ (A*x_1_prime)/(B*x_2_prime))^(2));\n",
+"Y2_prime = 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;//[kPa] - Azeotrope pressure\n",
+"y_1_prime = (x_1_prime*Y1_prime*P_1_sat)/P_prime;\n",
+"\n",
+"// Since x_1 = y_1,azeotrope formation will take place\n",
+"printf(' (b)\n\n');\n",
+"printf(' The total system pressure versus x_1 shows a maxima and thus azeotrope is formed by the VLE system\n\n');\n",
+"printf(' The azeotrope composition is x_1 = y_1 = %f\n\n',x_1_prime);\n",
+"printf(' The azeotrope presssure is %f mm Hg\n',P_prime);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.21: Determination_of_azeotrope_formation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.21\n",
+"//Page number - 544\n",
+"printf('Example - 15.21 and Page number - 544\n\n');\n",
+"\n",
+"//Given\n",
+"T = 50;//[C]\n",
+"// At 50 C\n",
+"P_1_sat = 0.67;//[atm]\n",
+"P_2_sat = 0.18;//[atm]\n",
+"Y1_infinity = 2.5;\n",
+"Y2_infinity = 7.2;\n",
+"\n",
+"//(1)\n",
+"// alpha_12 = (y_1/x_1)/(y_2/x_2) = (Y1*P_1_sat)/((Y2*P_2_sat))\n",
+"// At x_1 tending to zero,\n",
+"alpha_12_x0 = (Y1_infinity*P_1_sat)/(P_2_sat);\n",
+"// At x_1 tending to 1,\n",
+"alpha_12_x1 = (P_1_sat)/((Y2_infinity*P_2_sat));\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",
+"printf(' (1).Since (alpha_12_x=0) = %f and (alpha_12_x=1) = %f \n',alpha_12_x0,alpha_12_x1);\n",
+"printf(' 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')\n",
+"\n",
+"//(b)\n",
+"// Since the activity coefficient values are greater than 1 ,therefore the deviations from Roult's law is positive\n",
+"// and the azeotrope is maximum pressure (or minimum boiling)\n",
+"printf(' (2).Since the activity coefficient values are greater than 1 ,therefore the deviations from Roults law is positive\n');\n",
+"printf(' and the azeotrope is maximum pressure (or minimum boiling)\n\n');\n",
+"\n",
+"//(3)\n",
+"// Let us assume the system to follow van Laar activity coefficient model\n",
+"A = log(Y1_infinity);\n",
+"B = log(Y2_infinity);\n",
+"\n",
+"// log(Y1) = A/(1+ (A*x_1)/(B*x_2))^(2)\n",
+"// log(Y2) = B/(1+ (B*x_2)/(A*x_1))^(2)\n",
+"\n",
+"// At the azeotrope point, Y1*P1_sat = Y2*P2_sat\n",
+"// log(Y1) - log(Y2) = log(P_2_sat/P_2_sat)\n",
+"// On putting the values and then solving the above equation\n",
+"deff('[y]=f(x_1)','y= A/(1+ (A*x_1)/(B*(1-x_1)))^(2)- B/(1+ (B*(1-x_1))/(A*x_1))^(2) - log(P_2_sat/P_1_sat)');\n",
+"x_1 = fsolve(0.1,f);\n",
+"\n",
+"// At x_1\n",
+"x_2 = 1 - x_1;\n",
+"Y1 = exp(A/(1+ (A*x_1)/(B*x_2))^(2));\n",
+"Y2 = exp(B/(1+ (B*x_2)/(A*x_1))^(2));\n",
+"P = x_1*Y1*P_1_sat + x_2*Y2*P_2_sat;//[kPa] - Azeotrope pressure\n",
+"y_1 = (x_1*Y1*P_1_sat)/P;\n",
+"\n",
+"// Since x_1 = y_1,the azeotrope formation will take place\n",
+"\n",
+"printf(' (3).The azeotrope composition is x_1 = y_1 = %f\n',x_1);\n",
+"printf(' The azeotrope presssure is %f atm\n',P);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.22: Tabulation_of_pressure_and_composition_data.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.22\n",
+"//Page number - 545\n",
+"printf('Example - 15.22 and Page number - 545\n\n');\n",
+"\n",
+"//Given\n",
+"T = 25;//[C]\n",
+"// At 50 C\n",
+"P_1_sat = 7.866;//[kPa]\n",
+"P_2_sat = 3.140;//[kPa]\n",
+"\n",
+"// G_E/(R*T) = 1.4938*x_1*x_2/(1.54*x_1 + 0.97*x_2)\n",
+"\n",
+"// The excess Gibbs free energy expression can be written as\n",
+"// 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",
+"// Comparing with the van Laar expression\n",
+"// 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",
+"// The activity coefficients are thus given by\n",
+"// log(Y1) = A/(1+ (A*x_1)/(B*x_2))^(2)\n",
+"// 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(1,10);\n",
+"Y1 = zeros(1,10);\n",
+"Y2 = zeros(1,10);\n",
+"P = zeros(1,10);\n",
+"y_1 = zeros(1,10);\n",
+"\n",
+"printf(' x_1 \t\t Y1 \t\t Y2 \t\t P (kPa) \t\t y_1 \n\n');\n",
+"\n",
+"for i=1:10;\n",
+" x_2(1,i) = 1 - x_1(i);\n",
+" Y1(1,i) = exp(A/(1+ (A*x_1(i))/(B*x_2(i)))^(2));\n",
+" Y2(1,i) = exp(B/(1+ (B*x_2(i))/(A*x_1(i)))^(2));\n",
+" P(1,i) = x_1(i)*Y1(i)*P_1_sat + x_2(i)*Y2(i)*P_2_sat;\n",
+" y_1(1,i) = (x_1(i)*Y1(i)*P_1_sat)/P(i);\n",
+" printf(' %f\t\t %f\t\t %f \t\t %f \t\t %f \n\n',x_1(i),Y1(i),Y2(i),P(i),y_1(i));\n",
+"\n",
+"end\n",
+"\n",
+"// The azeotrope is formed near x_1 = 0.95 as in this region a maxima in pressure is obtained.\n",
+"\n",
+"// At the azeotrope point, Y1*P1_sat = Y2*P2_sat\n",
+"// log(Y1) - log(Y2) = log(P_2_sat/P_2_sat)\n",
+"// On putting the values and then solving the above equation\n",
+"deff('[y]=f(x_1)','y= A/(1+ (A*x_1)/(B*(1-x_1)))^(2)- B/(1+ (B*(1-x_1))/(A*x_1))^(2) - log(P_2_sat/P_1_sat)');\n",
+"x_1_prime = fsolve(0.1,f);\n",
+"\n",
+"// At x_1\n",
+"x_2_prime = 1 - x_1_prime;\n",
+"Y1_prime = exp(A/(1+ (A*x_1_prime)/(B*x_2_prime))^(2));\n",
+"Y2_prime = 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;//[kPa] - Azeotrope pressure\n",
+"y_1_prime = (x_1_prime*Y1_prime*P_1_sat)/P_prime;\n",
+"\n",
+"// Since x_1_prime = y_1_prime,the azeotrope formation will take place\n",
+"\n",
+"printf(' \n\nPart II \n\n');\n",
+"printf(' The azeotrope composition is x_1 = y_1 = %f\n',x_1_prime);\n",
+"printf(' The azeotrope presssure is %f kPa \n',P_prime);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.23: Determination_of_van_Laar_parameters.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.23\n",
+"//Page number - 547\n",
+"printf('Example - 15.23 and Page number - 546\n\n');\n",
+"\n",
+"//Given\n",
+"T = 58.7;//[C]\n",
+"P = 1;//[atm]\n",
+"P = P*101325*10^(-3);//[kPa]\n",
+"\n",
+"// log(P_sat) = 16.6758 - 3674.49/(t + 226.45) - For ethyl alcohol\n",
+"// log(P_sat) = 13.8216 - 2697.55/(t + 224.37) - For hexane\n",
+"\n",
+"// Let us take hexane as (1) and ethanol as (2)\n",
+"// At 58.7 C\n",
+"P_1_sat = exp(13.8216 - 2697.55/(T + 224.37));//[kPa]\n",
+"P_2_sat = exp(16.6758 - 3674.49/(T + 226.45));//[kPa]\n",
+"\n",
+"Y1 = P/P_1_sat;\n",
+"Y2 = P/P_2_sat;\n",
+"\n",
+"x_2 = 0.332;// Mol % of ethanol (given)\n",
+"x_1 = 1 - x_2;// Mol % of hehane\n",
+"\n",
+"// The van Laar parameters are given by\n",
+"A = ((1 + (x_2*log(Y2))/(x_1*log(Y1)))^(2))*log(Y1);\n",
+"B = ((1 + (x_1*log(Y1))/(x_2*log(Y2)))^(2))*log(Y2);\n",
+"\n",
+"printf(' The value of van Laar parameters are, A = %f and B = %f \n\n',A,B);\n",
+"\n",
+"// Now let us calvulate the distribution coefficient K\n",
+"x_1_prime = 0.5;//[given]\n",
+"x_2_prime = 1 - x_1_prime;\n",
+"\n",
+"// The activity coefficients are thus given by\n",
+"// log(Y1) = A/(1+ (A*x_1)/(B*x_2))^(2)\n",
+"// log(Y2) = B/(1+ (B*x_2)/(A*x_1))^(2)\n",
+"\n",
+"Y1_prime = exp(A/(1+ (A*x_1_prime)/(B*x_2_prime))^(2));\n",
+"Y2_prime = 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",
+"// 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",
+"printf(' The distribution coefficient is given by K_1 = %f\n',K_1)\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.2: Calculation_of_pressure_temperature_and_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.2\n",
+"//Page number - 515\n",
+"printf('Example - 15.2 and Page number - 515\n\n');\n",
+"\n",
+"//Given\n",
+"// log(P_1_sat) = 14.39155 - 2795.817/(t + 230.002)\n",
+"// log(P_2_sat) = 16.26205 - 3799.887/(t + 226.346)\n",
+"\n",
+"//(a)\n",
+"x_1_a =0.43;// Equilibrium composition of liquid phase\n",
+"t_a = 76;//[C] - Temperature\n",
+"x_2_a = 1 - x_1_a;\n",
+"\n",
+"// Since liquid phase composition is given we use the relation \n",
+"// P = x_1*P_1_sat + x_2*P_2_sat\n",
+"// At t = 76 C\n",
+"P_1_sat_a = exp(14.39155 - 2795.817/(t_a + 230.002));\n",
+"P_2_sat_a = exp(16.26205 - 3799.887/(t_a + 226.346));\n",
+"// Therefore total pressure is\n",
+"P_a = x_1_a*P_1_sat_a + x_2_a*P_2_sat_a;//[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",
+"printf('(a).The system pressure is, P = %f kPa\n',P_a);\n",
+"printf(' The vapour phase composition is, y_1 = %f\n\n',y_1_a);\n",
+"\n",
+"//(b)\n",
+"y_1_b = 0.43;// Equilibrium composition of vapour phase\n",
+"y_2_b = 1 - y_1_b;\n",
+"t_b = 76;//[C] - Temperature\n",
+"\n",
+"P_1_sat_b = exp(14.39155 - 2795.817/(t_b + 230.002));\n",
+"P_2_sat_b = exp(16.26205 - 3799.887/(t_b + 226.346));\n",
+"\n",
+"// Since vapour phase composition is given ,the system pressure is given by\n",
+"// 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",
+"printf('(b).The system pressure is, P = %f kPa\n',P_b);\n",
+"printf(' The liquid phase composition is, x_1 = %f\n\n',x_1_b);\n",
+"\n",
+"//(c)\n",
+"x_1_c = 0.32;// Equilibrium composition of liquid phase\n",
+"x_2_c = 1 - x_1_c;\n",
+"P_c = 101.33;//[kPa] - Pressure of the system\n",
+"\n",
+"// We have, P = x_1*P_1_sat + x_2*P_2_sat\n",
+"t_1_sat = 2795.817/(14.39155 - log(P_c)) - 230.002;\n",
+"t_2_sat = 3799.887/(16.26205 - 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 = exp(14.39155 - 2795.817/(t + 230.002));\n",
+" P_2_sat = 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",
+"end\n",
+"\n",
+"P_1_sat_c = exp(14.39155 - 2795.817/(t + 230.002));\n",
+"P_2_sat_c = 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",
+"printf('(c).The system temperature is, t = %f C\n',t);\n",
+"printf(' The vapour phase composition is, y_1 = %f\n\n',y_1_c);\n",
+"\n",
+"//(d)\n",
+"y_1_d = 0.57;// Vapour phase composition\n",
+"y_2_d = 1 - y_1_d;\n",
+"P_d = 101.33;//[kPa] - Pressure of the system\n",
+"\n",
+"// Since vapour phase composition is given, we can use the relation\n",
+"// 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
+"t_1_sat_d = 2795.817/(14.39155 - log(P_d)) - 230.002;\n",
+"t_2_sat_d = 3799.887/(16.26205 - 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 = exp(14.39155 - 2795.817/(t_d + 230.002));\n",
+" P_2_sat_prime = 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",
+"end\n",
+"\n",
+"P_1_sat_d = exp(14.39155 - 2795.817/(t_d + 230.002));\n",
+"P_2_sat_d = 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",
+"printf('(d).The system temperature is, t = %f C\n',t_d);\n",
+"printf(' The liquid phase composition is, x_1 = %f\n\n',x_1_d);\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.3: Calculation_of_pressure_temperature_and_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.3\n",
+"//Page number - 516\n",
+"printf('Example - 15.3 and Page number - 516\n\n');\n",
+"\n",
+"//Given\n",
+"// log(P_1_sat) = 14.3916 - 2795.82/(t + 230.00)\n",
+"// log(P_2_sat) = 14.2724 - 2945.47/(t + 224.00)\n",
+"// log(P_3_sat) = 14.2043 - 2972.64/(t + 209.00)\n",
+"\n",
+"//(a)\n",
+"x_1_a = 0.25;// 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;//[C] - Temperature\n",
+"\n",
+"// At t = 80 C\n",
+"P_1_sat_a = exp(14.3916 - 2795.82/(t_a + 230.00));\n",
+"P_2_sat_a = exp(14.2724 - 2945.47/(t_a + 224.00));\n",
+"P_3_sat_a = exp(14.2043 - 2972.64/(t_a + 209.00));\n",
+"\n",
+"// 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;//[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",
+"printf('(a).The system pressure is, P = %f kPa\n',P_a);\n",
+"printf(' The vapour phase composition is given by, y_1 = %f, y_2 = %f and y_3 = %f \n\n',y_1_a,y_2_a,y_3_a);\n",
+"\n",
+"//(2)\n",
+"y_1_b = 0.50;// 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;//[C] - Temperature\n",
+"\n",
+"// At t = 80 C\n",
+"P_1_sat_b = exp(14.3916 - 2795.82/(t_b + 230.00));\n",
+"P_2_sat_b = exp(14.2724 - 2945.47/(t_b + 224.00));\n",
+"P_3_sat_b = exp(14.2043 - 2972.64/(t_b + 209.00));\n",
+"\n",
+"// 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);//[kPa]\n",
+"\n",
+"// 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",
+"printf('(b).The system pressure is, P = %f kPa\n',P_b);\n",
+"printf(' The liquid phase composition is given by, x_1 = %f, x_2 = %f and x_3 = %f \n\n',x_1_b,x_2_b,x_3_b);\n",
+"\n",
+"//(c)\n",
+"x_1_c = 0.30;// 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;//[kPa] - Pressure of the system\n",
+"\n",
+"// 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 - log(P_c)) - 230.00;//[C]\n",
+"t_2_sat = 2945.47/(14.2724 - log(P_c)) - 224.00;//[C]\n",
+"t_3_sat = 2972.64/(14.2043 - log(P_c)) - 209.00;//[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 = exp(14.3916 - 2795.82/(t + 230.00));\n",
+" P_2_sat = exp(14.2724 - 2945.47/(t + 224.00));\n",
+" P_3_sat = 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",
+"end\n",
+"\n",
+"P_1_sat_c = exp(14.3916 - 2795.82/(t + 230.00));\n",
+"P_2_sat_c = exp(14.2724 - 2945.47/(t + 224.00));\n",
+"P_3_sat_c = 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",
+"printf('(c).The system temperature is, t = %f C\n',t);\n",
+"printf(' The vapour phase composition is, y_1 = %f, y_2 %f and y_3 = %f\n\n',y_1_c,y_2_c,y_3_c);\n",
+"\n",
+"//(d)\n",
+"y_1_d = 0.6;// Vapour phase composition\n",
+"y_2_d = 0.2;\n",
+"y_3_d = 1 - y_1_d - y_2_d;\n",
+"P_d = 90;//[kPa] - Pressure of the system\n",
+"\n",
+"// Since vapour phase composition is given, we can use the relation\n",
+"// 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 - log(P_d)) - 230.00;\n",
+"t_2_sat_d = 2945.47/(14.2724 - log(P_d)) - 224.00;\n",
+"t_3_sat_d = 2972.64/(14.2043 - 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 = exp(14.3916 - 2795.82/(t_d + 230.00));\n",
+" P_2_sat_prime = exp(14.2724 - 2945.47/(t_d + 224.00));\n",
+" P_3_sat_prime = 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",
+"end\n",
+"\n",
+"P_1_sat_d = exp(14.3916 - 2795.82/(t_d + 230.00));\n",
+"P_2_sat_d = exp(14.2724 - 2945.47/(t_d + 224.00));\n",
+"P_3_sat_d = 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",
+"printf('(d).The system temperature is, t = %f C\n',t_d);\n",
+"printf(' The liquid phase composition is, x_1 = %f, x_2 = %f and x_3 = %f\n\n',x_1_d,x_2_d,x_3_d);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.4: Calculation_of_pressure_and_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.4\n",
+"//Page number - 519\n",
+"printf('Example - 15.4 and Page number - 519\n\n');\n",
+"\n",
+"//Given\n",
+"T = 120;//[C] - Temperature\n",
+"P_1 = 1;//[atm] - Initial pressure\n",
+"P_1 = P_1*101.325;//[kPa]\n",
+"R = 8.314;//[J/mol*K] - Universal gas constant\n",
+"\n",
+"y_1 = 0.3;// Mole fraction of propane\n",
+"y_2 = 0.5;// Mole fraction of butane\n",
+"y_3 = 0.2;// Mole fraction of hexane\n",
+"\n",
+"// log(P_1_sat) = 13.7713 - 1892.47/(t + 248.82)\n",
+"// log(P_2_sat) = 13.7224 - 2151.63/(t + 236.91)\n",
+"// log(P_3_sat) = 13.8216 - 2697.55/(t + 224.37)\n",
+"\n",
+"//(a)\n",
+"P_1_sat = exp(13.7713 - 1892.47/(T + 248.82));\n",
+"P_2_sat = exp(13.7224 - 2151.63/(T + 236.91));\n",
+"P_3_sat = exp(13.8216 - 2697.55/(T + 224.37));\n",
+"\n",
+"// 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);//[kPa]\n",
+"\n",
+"printf(' (a).The pressure of the mixture when first drop condenses is given by, P = %f kPa\n\n',P_2);\n",
+"\n",
+"//(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",
+"printf(' (b).The liquid phase composition is given by, x_1 (propane) = %f, x_2 (butane) = %f and x_3 (hexane) = %f \n\n',x_1,x_2,x_3);\n",
+"\n",
+"// (c)\n",
+"// Work transfer per mol is given by\n",
+"// W = integral(P*dV) = integral((R*T/V)*dV) = R*T*log(V_2/V_1) = R*T*log(P_1/P_2)\n",
+"w = R*(T+273.15)*log(P_1/P_2);//[J/mol]\n",
+"// For 100 mol\n",
+"W = w*100;//[J]\n",
+"W = W*10^(-3);//[kJ]\n",
+"printf(' (c).The work required for 100 mol of mixture handeled is %f kJ',W);\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.5: Calculation_of_pressure_temperature_and_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.5\n",
+"//Page number - 520\n",
+"printf('Example - 15.5 and Page number - 520\n\n');\n",
+"\n",
+"//Given\n",
+"T = 27;//[C] - Temperature\n",
+"\n",
+"// log(P_1_sat) = 13.8216 - 2697.55/(t + 224.37)\n",
+"// log(P_2_sat) = 13.8587 - 2911.32/(t + 216.64)\n",
+"\n",
+"//(a)\n",
+"x_1_a = 0.2;\n",
+"x_2_a = 1 - x_1_a;\n",
+"\n",
+"// At t = 27 C\n",
+"P_1_sat = exp(13.8216 - 2697.55/(T + 224.37));//[kPa]\n",
+"P_2_sat = exp(13.8587 - 2911.32/(T + 216.64));//[kPa]\n",
+"P_a = x_1_a*P_1_sat + x_2_a*P_2_sat;//[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",
+"printf('(a).The total pressure is, P = %f kPa\n',P_a);\n",
+"printf(' The vapour phase composition is given by, y_1 = %f and y_2 = %f\n\n',y_1_a,y_2_a);\n",
+"\n",
+"//(b)\n",
+"y_1_b = 0.2;\n",
+"y_2_b = 1 - y_1_b;\n",
+"// 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);//[kPa]\n",
+"\n",
+"// 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",
+"printf('(b).The total pressure is, P = %f kPa\n',P_b);\n",
+"printf(' The liquid phase composition is given by, x_1 = %f and x_2 = %f\n\n',x_1_b,x_2_b);\n",
+"\n",
+"//(c)\n",
+"P_c = 30;//[kPa] - Total pressure\n",
+"x_1_c = 0.2;\n",
+"x_2_c = 1 - x_1_c;\n",
+"\n",
+"// We have, P = x_1*P_1_sat + x_2*P_2_sat\n",
+"t_1_sat = 2697.55/(13.8216 - log(P_c)) - 224.37;\n",
+"t_2_sat = 2911.32/(13.8587 - 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 = exp(13.8216 - 2697.55/(t + 224.37));\n",
+" P_2_sat = 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",
+"end\n",
+"\n",
+"P_1_sat_c = exp(13.8216 - 2697.55/(t + 224.37));\n",
+"P_2_sat_c = 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",
+"printf('(c).The system temperature is, t = %f C\n',t);\n",
+"printf(' The vapour phase composition is, y_1 = %f and y_2 = %f \n\n',y_1_c,y_2_c);\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.6: Determinatin_of_DPT_and_BPT.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.6\n",
+"//Page number - 521\n",
+"printf('Example - 15.6 and Page number - 521\n\n');\n",
+"\n",
+"//Given\n",
+"P = 90;//[kPa] - Pressure\n",
+"R = 8.314;//[J/mol*K] - Universal gas constant\n",
+"\n",
+"// log(P_sat) = A - B/(t + C)\n",
+"\n",
+"// For benzene\n",
+"A_1 = 13.8594;\n",
+"B_1 = 2773.78;\n",
+"C_1 = 220.07;\n",
+"// For ethyl benzene\n",
+"A_2 = 14.0045;\n",
+"B_2 = 3279.47;\n",
+"C_2 = 213.20;\n",
+"\n",
+"x_1 = 0.5;// Equimolar mixture\n",
+"x_2 = 0.5;\n",
+"\n",
+"// The bubble point temperature equation is\n",
+"// P = x_1*P_1_sat + x_2*P_2_sat\n",
+"\n",
+"t_1_sat = B_1/(A_1 - log(P)) - C_1;\n",
+"t_2_sat = B_2/(A_2 - 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 = exp(A_1 - B_1/(t + C_1));\n",
+" P_2_sat = 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",
+"end\n",
+"\n",
+"printf(' The bubble point temperature is %f C\n\n',t);\n",
+"\n",
+"// Now let us determine dew point temperature for y_1 = 0.5, and P = 90 kPa\n",
+"y_1 = 0.5;// Equimolar mixture\n",
+"y_2 = 0.5;\n",
+"\n",
+"// 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
+"// 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 = exp(A_1 - B_1/(t_old + C_1));\n",
+" P_2_sat_prime = 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",
+"end\n",
+"\n",
+"printf(' The dew point temperature is %f C',t_old);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.7: Determination_of_range_of_temperature_for_which_two_phase_exists.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.7\n",
+"//Page number - 522\n",
+"printf('Example - 15.7 and Page number - 522\n\n');\n",
+"\n",
+"//Given\n",
+"P = 1;//[bar] - Pressure\n",
+"P = P*10^(2);//[kPa]\n",
+"\n",
+"// log(P_1_sat) = 13.8594 - 2773.78/(t + 220.07)\n",
+"// log(P_2_sat) = 14.0098 - 3103.01/(t + 219.79)\n",
+"\n",
+"// The bubble point equation is\n",
+"// P = x_1*P_1_sat + x_2*P_2_sat;\n",
+"\n",
+"t_1_sat = 2773.78/(13.8594 - log(P)) - 220.07;\n",
+"t_2_sat = 3103.01/(14.0098 - log(P)) - 219.79;\n",
+"\n",
+"// For x_1 = 0.1\n",
+"// t = x_1_1*t_1_sat + x_2_1*t_2_sat;\n",
+"x_1 = [0.1,0.5,0.9];\n",
+"\n",
+"for i=1: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 = exp(13.8594 - 2773.78/(t + 220.07));\n",
+" P_2_sat = 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",
+"end\n",
+"\n",
+"printf(' The bubble point temperature (for x_1 = %f) is %f C\n',x_1(i),t);\n",
+"\n",
+"end\n",
+"\n",
+"printf('\n\n');\n",
+"\n",
+"// Now let us determine dew point temperature\n",
+"// 1/P = y_1/P_1_sat + y_2/P_2_sat\n",
+"\n",
+"y_1 = [0.1,0.5,0.9];\n",
+"\n",
+"for j=1: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",
+"\n",
+"error = 10;\n",
+"while(error>0.3)\n",
+" P_1_sat = exp(13.8594 - 2773.78/(t_prime + 220.07));\n",
+" P_2_sat = 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",
+"end\n",
+"\n",
+"printf(' The dew point temperature (for y_1 = %f) is %f C\n',y_1(j),t_prime);\n",
+"\n",
+"end\n",
+"\n",
+"printf('\n\n');\n",
+"\n",
+"//Therefore\n",
+"printf(' The temperature range for (z_1 = 0.1) which two phase exist is 105.61 C to 108.11 C\n');\n",
+"printf(' The temperature range for (z_1 = 0.5) which two phase exist is 91.61 C to 98.40 C\n');\n",
+"printf(' The temperature range for (z_1 = 0.9) which two phase exist is 81.71 C to 84.51 C\n');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.8: Calculation_of_DPT_and_BPT.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"//Example - 15.8\n",
+"//Page number - 524\n",
+"printf('Example - 15.8 and Page number - 524\n\n');\n",
+"\n",
+"//Given\n",
+"x_1 = 0.20;\n",
+"x_2 = 0.45;\n",
+"x_3 = 0.35;\n",
+"P = 10;//[atm]\n",
+"P = P*101325*10^(-3);//[kPa]\n",
+"\n",
+"// log(P_1_sat) = 13.7713 - 1892.47/(t + 248.82)\n",
+"// log(P_2_sat) = 13.7224 - 2151.63/(t + 236.91)\n",
+"// log(P_3_sat) = 13.8183 - 2477.07/(t + 233.21)\n",
+"\n",
+"//(a)\n",
+"// The bubble point equation is\n",
+"// P = x_1*P_1_sat + x_2*P_2_sat + x_3*P_3_sat\n",
+"\n",
+"t_1_sat = 1892.47/(13.7713 - log(P)) - 248.82;\n",
+"t_2_sat = 2151.63/(13.7224 - log(P)) - 236.91;\n",
+"t_3_sat = 2477.07/(13.8183 - 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 = exp(13.7713 - 1892.47/(t + 248.82));\n",
+" P_2_sat = exp(13.7224 - 2151.63/(t + 236.91));\n",
+" P_3_sat = 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",
+"end\n",
+"\n",
+"BPT = t;\n",
+"printf(' (a).The bubble point temperature is %f C\n\n',BPT);\n",
+"\n",
+"// (b)\n",
+"// 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",
+"// 1/P = y_1/P_1_sat + y_2/P_2_sat + y_3/P_3_sat\n",
+"\n",
+"t_old = 90;//[C]\n",
+"error = 10;\n",
+"while(error>0.1)\n",
+" P_1_sat_prime = exp(13.7713 - 1892.47/(t_old + 248.82));\n",
+" P_2_sat_prime = exp(13.7224 - 2151.63/(t_old + 236.91));\n",
+" P_3_sat_prime = 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",
+"end\n",
+"\n",
+"DPT = t_old;\n",
+"printf(' (b).The dew point temperature is %f C\n\n',DPT);\n",
+"\n",
+"// (c)\n",
+"// For the given composition and pressure the two phase region exists in the temperature range of DPT and BPT\n",
+"// Therefore at 82 C two phase exists\n",
+"// At 82 C and P = 1013.25 kPa pressure\n",
+"T_c = 82;//[C]\n",
+"P_c = 1013.25;//[kPa]\n",
+"z_1 = 0.20;\n",
+"z_2 = 0.45;\n",
+"z_3 = 0.35;\n",
+"\n",
+"P_1_sat_c = exp(13.7713 - 1892.47/(T_c + 248.82));\n",
+"P_2_sat_c = exp(13.7224 - 2151.63/(T_c + 236.91));\n",
+"P_3_sat_c = 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",
+"// We have to find such a V that the following equation is satisfied.\n",
+"// summation(y_i) = K_i*z_i/(1-V+V*K_i) = 1\n",
+"// 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",
+"deff('[y]=f1(V)','y= 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(0.4,f1);\n",
+"\n",
+"// 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",
+"printf(' (c).The proportion of vapour is given by, V = %f\n\n',V);\n",
+"printf(' The composition of vapour foemed is given by, y_1 = %f, y_2 = %f and y_3 = %f \n\n',y_1_c,y_2_c,y_3_c);\n",
+"printf(' The composition of liquid formed is given by, x_1 = %f, x_2 = %f and x_3 = %f \n\n',x_1_c,x_2_c,x_3_c);\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15.9: Calculation_of_range_of_pressure_for_which_two_phase_exists.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 15.9\n",
+"//Page number - 526\n",
+"printf('Example - 15.9 and Page number - 526\n\n');\n",
+"\n",
+"//Given\n",
+"T = 27;//[C] - Temperature\n",
+"z_1 = 0.4;\n",
+"z_2 = 0.3;\n",
+"z_3 = 0.3;\n",
+"\n",
+"// log(P_sat) = A - B/(t + C)\n",
+"\n",
+"// For propane\n",
+"A_1 = 13.7713;\n",
+"B_1 = 1892.47;\n",
+"C_1 = 248.82;\n",
+"// For i-butane\n",
+"A_2 = 13.4331;\n",
+"B_2 = 1989.35;\n",
+"C_2 = 236.84;\n",
+"// For n-butane\n",
+"A_3 = 13.7224;\n",
+"B_3 = 2151.63;\n",
+"C_3 = 236.91;\n",
+"\n",
+"//(a)\n",
+"// The pressure range for the existence of two phase region lies between dew point and bubble point pressures.\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",
+"y_3 = z_3;\n",
+"\n",
+"// At 27 C,\n",
+"P_1_sat = exp(A_1 - B_1/(T + C_1));\n",
+"P_2_sat = exp(A_2 - B_2/(T + C_2));\n",
+"P_3_sat = exp(A_3 - B_3/(T + C_3));\n",
+"\n",
+"// 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",
+"// 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",
+"// 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",
+"printf(' (a).The two phase region exists between %f and %f kPa\n\n',P_1,P_2);\n",
+"\n",
+"//(b)\n",
+"// The mean of the two-phase pressure range is given by\n",
+"P_mean = (P_1 + P_2)/2;\n",
+"\n",
+"// 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",
+"// 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) + (K_3*z_3)/(1-V-K_3*V) = 1\n",
+"// Solving we get\n",
+"deff('[y]=f(V)','y=(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(0.1,f);\n",
+"\n",
+"y_1_prime = (z_1*K_1)/(1-V+K_1*V);\n",
+"\n",
+"printf(' (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",
+""
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}