summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics_by_P_Ahuja/16-Other_Phase_Equilibria.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Chemical_Engineering_Thermodynamics_by_P_Ahuja/16-Other_Phase_Equilibria.ipynb')
-rw-r--r--Chemical_Engineering_Thermodynamics_by_P_Ahuja/16-Other_Phase_Equilibria.ipynb802
1 files changed, 802 insertions, 0 deletions
diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/16-Other_Phase_Equilibria.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/16-Other_Phase_Equilibria.ipynb
new file mode 100644
index 0000000..07414a2
--- /dev/null
+++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/16-Other_Phase_Equilibria.ipynb
@@ -0,0 +1,802 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 16: Other Phase Equilibria"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.10: Determination_of_boiling_point_elevation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.10\n",
+"//Page number - 583\n",
+"printf('Example - 16.10 and Page number - 583\n\n');\n",
+"\n",
+"//Given\n",
+"R = 8.314;//[J/mol*K] - universal gas constant\n",
+"T_b = 373.15;//[K] - Boiling point of water\n",
+"m_water = 100;//[g] - Mass of water\n",
+"m_C12H22 = 5;//[g] - Mass of glucise (C12H22)\n",
+"M_wt_water = 18.015;// Molecular weight of water \n",
+"M_wt_C12H22 = 342.30;// Molecular weight of C12H22\n",
+"mol_water = m_water/M_wt_water;//[mol] - Moles of water\n",
+"mol_C12H22 = m_C12H22/M_wt_C12H22;//[mol] - Moles of C12H22\n",
+"\n",
+"H_vap = 540;//[cal/g] - Enthalpy change of vaporisation\n",
+"H_vap = H_vap*4.186*M_wt_water;//[J/mol]\n",
+"\n",
+"//Mole fraction of the solute (C12H22) is given by\n",
+"x_2 = mol_C12H22/(mol_C12H22+mol_water);\n",
+"\n",
+"//The boiling point elevation is given by\n",
+"// 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",
+"printf('The elevation in boiling point is given by \n delta_T = %f C',delta_T_b);\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.11: Determination_of_osmotic_pressure.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.11\n",
+"//Page number - 584\n",
+"printf('Example - 16.11 and Page number - 584\n\n');\n",
+"\n",
+"//Given\n",
+"R = 8.314;//[J/mol*K] - Universal gas constant\n",
+"T = 25 + 273.15;//[K] - Surrounding temperature \n",
+"den_water = 1000;//[kg/m^(3)] - Density of water\n",
+"m_water = 100;//[g] - Mass of water\n",
+"m_C12H22 = 5;//[g] - Mass of glucise (C12H22)\n",
+"M_wt_water = 18.015;// Molecular weight of water \n",
+"M_wt_C12H22 = 342.30;// Molecular weight of C12H22\n",
+"mol_water = m_water/M_wt_water;//[mol] - Moles of water\n",
+"mol_C12H22 = m_C12H22/M_wt_C12H22;//[mol] - Moles of C12H22\n",
+"\n",
+"//Mole fraction of the water is given by\n",
+"x_1 = mol_water/(mol_C12H22+mol_water);\n",
+"\n",
+"//Molar volume of water can be calculated as\n",
+"V_l_water = (1/den_water)*M_wt_water*10^(-3);//[m^(3)/mol]\n",
+"\n",
+"//The osmotic pressure is given by\n",
+"pi = -(R*T*log(x_1))/V_l_water;//[N/m^(2)]\n",
+"pi = pi*10^(-5);//[bar]\n",
+"\n",
+"printf('The osmotic pressure of the mixture is %f bar',pi);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.12: Determination_of_pressure.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.12\n",
+"//Page number - 585\n",
+"printf('Example - 16.12 and Page number - 585\n\n');\n",
+"\n",
+"//Given\n",
+"R = 8.314;//[J/mol*K] - universal gas constant\n",
+"T = 25 + 273.15;//[K] - Surrounding temperature\n",
+"den_water = 1000;//[kg/m^(3)] - Density of water\n",
+"m_water = 100;//[g] - Mass of water\n",
+"m_NaCl = 3.5;//[g] - Mass of NaCl\n",
+"M_wt_water = 18.015;// Molecular weight of water \n",
+"M_wt_NaCl = 58.5;// Molecular weight of NaCl\n",
+"mol_water = m_water/M_wt_water;//[mol] - Moles of water\n",
+"mol_NaCl = m_NaCl/M_wt_NaCl;//[mol] - Moles of NaCl\n",
+"\n",
+"H_fus = -80;//[cal/g] - Enthalpy change of fusion at 0 C\n",
+"H_fus = H_fus*4.186*M_wt_water;//[J/mol]\n",
+"\n",
+"//Mole fraction of the solute (NaCl) is given by\n",
+"x_2 = mol_NaCl/(mol_NaCl+mol_water);\n",
+"\n",
+"//But NaCl is compietely ionized and thus each ion acts independently to lower the water mole fraction.\n",
+"x_2_act = 2*x_2;// Actual mole fraction\n",
+"\n",
+"x_1 = 1 - x_2_act;\n",
+"\n",
+"//Molar volume of water can be calculated as\n",
+"V_l_water = (1/den_water)*M_wt_water*10^(-3);//[m^(3)/mol]\n",
+"\n",
+"//The osmotic pressure is given by\n",
+"pi = -(R*T*log(x_1))/V_l_water;//[N/m^(2)]\n",
+"pi = pi*10^(-5);//[bar]\n",
+"//The minimum pressure to desalinate sea water is nothing but the osmotic pressure\n",
+"\n",
+"printf('The minimum pressure to desalinate sea water is %f bar',pi);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.13: Determination_of_amount_of_precipitate.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.13\n",
+"//Page number - 586\n",
+"printf('Example - 16.13 and Page number - 586\n\n');\n",
+"\n",
+"//Given\n",
+"R = 8.314;//[J/mol*K] - universal gas constant\n",
+"T = 173.15;//[K] - Surrounding temperature\n",
+"P = 60;//[bar]\n",
+"P = P*10^(5);//[Pa] \n",
+"\n",
+"//componenet 1 : CO2 (1)\n",
+"//componenet 2 : H2 (2)\n",
+"P_1_sat = 0.1392;//[bar] - Vapour pressre of pure solid CO2\n",
+"P_1_sat = P_1_sat*10^(5);//[bar]\n",
+"V_s_1 = 27.6;//[cm^(3)/mol] - Molar volume of solid CO2\n",
+"V_s_1 = V_s_1*10^(-6);//[m^(3)/mol]\n",
+"n_1 = 0.01;//[mol] - Initial number of moles of CO2\n",
+"n_2 = 0.99;//[mol] - Initial number of moles of H2\n",
+"\n",
+"//Let us determine the fugacity of solid CO2 (1) at 60 C and 173.15 K\n",
+"// f_1 = f_1_sat*exp(V_s_1*(P-P_1_sat)/(R*T))\n",
+"\n",
+"//Since vapour pressure of pure solid CO2 is very small, therefore\n",
+"f_1_sat = P_1_sat;\n",
+"f_1 = f_1_sat*exp(V_s_1*(P-P_1_sat)/(R*T));\n",
+"\n",
+"//Since gas phase is ideal therefore\n",
+"// y1*P = f_1\n",
+"y1 = f_1/P;\n",
+"\n",
+"//Number of moles of H2 in vapour phase at equilibrium remains the same as initial number of moles.\n",
+"//Number of moles of CO2 in vapour phase at equilibrium can be calculated as\n",
+"//y1 = (n_1_eq/(n_1_eq + n_2)). Therefore\n",
+"n_1_eq = n_2*y1/(1-y1);\n",
+"\n",
+"//Therefore moles of CO2 precipitated is\n",
+"n_ppt = n_1 - n_1_eq;//[mol]\n",
+"\n",
+"printf('The moles of CO2 precipitated is %f mol',n_ppt);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.14: Calculation_of_pressure.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.14\n",
+"//Page number - 586\n",
+"printf('Example - 16.14 and Page number - 586\n\n');\n",
+"\n",
+"//Given\n",
+"R = 8.314;//[J/mol*K] - universal gas constant\n",
+"T = 350;//[K] - Surrounding temperature\n",
+"\n",
+"//componenet 1 : organic solid (1)\n",
+"//componenet 2 : CO2 (2)\n",
+"\n",
+"P_1_sat = 133.3;//[N/m^(2)] - Vapour pressre of organic solid\n",
+"V_s_1 = 200;//[cm^(3)/mol] - Molar volume of organic solid\n",
+"V_s_1 = V_s_1*10^(-6);//[m^(3)/mol]\n",
+"\n",
+"///At 350 K, the values of the coefficients \n",
+"B_11 = -500;//[cm^(3)/mol]\n",
+"B_22 = -85;//[cm^^(3)/mol]\n",
+"B_12 = -430;//[cm^(3)/mol]\n",
+"\n",
+"//From phase equilibrium equation of component 1, we get\n",
+"// y1*P*phi_1 = f_1\n",
+"// f_1 = f_1_sat*exp(V_s_1*(P-P_1_sat)/(R*T))\n",
+"\n",
+"//Since vapour pressure of organic solid is very small, therefore\n",
+"f_1_sat = P_1_sat;\n",
+"\n",
+"// Now let us determine the fugacity coefficient of organic solid in the vapour mixture.\n",
+"// log(phi_1) = (P/(R*T))*(B_11 + y2^(2)*del_12) \n",
+"del_12 = (2*B_12 - B_11 - B_22)*10^(-6);//[m^(3)/mol]\n",
+"\n",
+"//It is given that the partial pressure of component 1 in the vapour mixture is 1333 N?m^(2)\n",
+"// y1*P = 1333 N/m^(2) or, y1 = 1333/P\n",
+"// y2 = 1- 1333/P\n",
+"// log(phi_1) = (P/(R*T))*(B_11 + (1- 1333/P)^(2)*del_12)\n",
+"\n",
+"//The phase equilibrium equation becomes\n",
+"// y1*P*phi_1 = f_1_sat*exp(V_s_1*(P-P_1_sat)/(R*T))\n",
+"//Taking log on both side we have\n",
+"// log(y1*P) + log(phi_1) = log(f_1_sat) + (V_s_1*(P-P_1_sat)/(R*T))\n",
+"// (V_s_1*(P-P_1_sat)/(R*T)) - log(phi_1) = log(1333/133.3) = log(10)\n",
+"\n",
+"//substituting for log(phi_1) from previous into the above equation we get\n",
+"// (V_s_1*(P-P_1_sat)/(R*T)) - (P/(R*T))*(B_11 + (1- 1333/P)^(2)*del_12) - log(10) = 0\n",
+"// On simplification we get,\n",
+"// 975*P^(2) - 6.7*10^(9)*P + 4.89*10^(8) = 0\n",
+"// 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);//[Pa]\n",
+"P4 = (6.7*10^(9) - ((-6.7*10^(9))^(2)-4*975*4.98*10^(8))^(1/2))/(2*975);//[Pa]\n",
+"// The second value is not possible, therefore pressure of the system is P3\n",
+"P3 = P3*10^(-5);//[bar]\n",
+"\n",
+"printf(' The total pressure of the system is %f bar',P3);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.1: Determination_of_solubility.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"funcprot(0);\n",
+"\n",
+"// Example - 16.1\n",
+"// Page number - 564\n",
+"printf('Example - 16.1 and Page number - 564\n\n');\n",
+"\n",
+"// Given\n",
+"T = 0 + 273.15;//[K] - Temperature\n",
+"P = 20*10^(5);//[Pa] - Pressure\n",
+"R = 8.314;//[J/mol*K] - Universal gas constant\n",
+"\n",
+"//componenet 1 : methane (1)\n",
+"//componenet 2 : methanol (2)\n",
+"\n",
+"H_constant = 1022;//[bar] - Henry's law constant\n",
+"H_constant = H_constant*10^(5);//[Pa]\n",
+"\n",
+"// The second virial coefficients are\n",
+"B_11 = -53.9;//[cm^(3)/mol]\n",
+"B_11 = B_11*10^(-6);//[m^(3)/mol]\n",
+"B_12 = -166;//[cm^(3)/mol]\n",
+"B_12 = B_12*10^(-6);//[m^(3)/mol]\n",
+"B_22 = -4068;//[cm^(3)/mol]\n",
+"B_22 = B_22*10^(-6);//[m^(3)/mol]\n",
+"\n",
+"den_meth = 0.8102;//[g/cm^(3)] - Density of methanol at 0 C\n",
+"Mol_wt_meth = 32.04;// Molecular weight of methanol\n",
+"P_2_sat = 0.0401;//[bar] - Vapour pressure of methanol at 0 C\n",
+"\n",
+"//The molar volume of methanol can be calculated as\n",
+"V_2_liq = (1/(den_meth/Mol_wt_meth))*10^(-6);//[m^(3)/mol]\n",
+"\n",
+"//The phase equilibrium equation of the components at high pressure\n",
+"//y1*phi_1*P = x_1*H_1\n",
+"//y2*phi_2*P = x_2*H_2\n",
+"\n",
+"//Since methane follows Henry's law therefore methanol follows the lewis-Rnadall rule\n",
+"//f_2 is the fugacity of the compressed liquid which is calculated using\n",
+"//f_2 = f_2_sat*exp[V_2_liq*(P - P_sat_2)/(R*T)]\n",
+"//where f_2_sat can be calculated using virial equation \n",
+"// log(phi_2_sat) = log(f_2_sat/P_2_sat) = (B_22*P_2_sat)/(R*T)\n",
+"\n",
+"f_2_sat = P_2_sat*exp((B_22*P_2_sat*10^(5))/(R*T));//[bar]\n",
+"\n",
+"//Putting the value of 'f_2_sat' in the expression of f_2 , we get\n",
+"f_2 = f_2_sat*exp(V_2_liq*(P - P_2_sat*10^(5))/(R*T));//[bar]\n",
+"\n",
+"//Now let us calculate the fugacity coefficients of the species in the vapour mixture\n",
+"del_12 = 2*B_12 - B_11 - B_22;//[m^(3)/mol]\n",
+"\n",
+"//log(phi_1) = (P/(R*T))*(B_11 + y2^(2)*del_12)\n",
+"//log(phi_2) = (P/(R*T))*(B_22 + y1^(2)*del_12)\n",
+"\n",
+"\n",
+"//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 = exp((P/(R*T))*((B_11 + y2^(2)*del_12)));\n",
+" phi_2 = 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",
+"end\n",
+"\n",
+"printf(' The solubility of methane in methanol is given by x1 = %f\n',x_1);\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.2: Determination_of_solubility.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"// Example - 16.2\n",
+"// Page number - 566\n",
+"printf('Example - 16.2 and Page number - 566\n\n');\n",
+"\n",
+"// Given\n",
+"x_C2H6_1 = 0.33*10^(-4);// Solubility of ethane in water at 25 C and 1 bar\n",
+"\n",
+"//componenet 1 : ethane (1)\n",
+"//componenet 2 : water (2)\n",
+"\n",
+"// Z = 1 - 7.63*10^(3)*P - 7.22*10^(-5)*P^(2)\n",
+"\n",
+"//The phase equilibrium equation of ethane is\n",
+"//f_1_V = x_1*H_1\n",
+"//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",
+"// log(phi) = integral('Z-1)/P) from limit '0' to 'P'\n",
+"\n",
+"P1 = 0;\n",
+"P2 = 1;\n",
+"P3 = 35;\n",
+"intgral = integrate('(1-7.63*10^(-3)*P-7.22*10^(-5)*P^(2)-1)/P','P',P1,P2);\n",
+"phi_1_1 = exp(intgral);// - Fugacity coefficient of ethane at 1 bar\n",
+"f_1_1 = phi_1_1*P2;//[bar] - Fugacity of ethane at 1 bar\n",
+"\n",
+"//Similarly\n",
+"intgral_1 = integrate('(1-7.63*10^(-3)*P-7.22*10^(-5)*P^(2)-1)/P','P',P1,P3);\n",
+"phi_1_35 = exp(intgral_1);// Fugacity coefficient of ethane at 35 bar\n",
+"f_1_35 = phi_1_35*P3;//[bar] - Fugacity of ethane at 35 bar\n",
+"\n",
+"// At ethane pressure of 1 bar , x_C2H6_1*H_1 = phi_1_1\n",
+"H_1 = phi_1_1/x_C2H6_1;//[bar] - Henry's constant\n",
+"\n",
+"// At ethane pressure of 35 bar , x_C2H6_35*H_1 = phi_1_35\n",
+"x_C2H6_35 = f_1_35/H_1;// Solubility of ethane at 35 bar pressure\n",
+"\n",
+"printf('The solubility of ethane at 35 bar is given by x_C2H6 = %e',x_C2H6_35);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.3: Proving_a_mathematical_relation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.3\n",
+"//Page number - 567\n",
+"printf('Example - 16.3 and Page number - 567\n\n');\n",
+"\n",
+"//This problem involves proving a relation in which no mathematics and no calculations are involved.\n",
+"//For prove refer to this example 16.3 on page number 567 of the book.\n",
+"printf(' This problem involves proving a relation in which no mathematics and no calculations are involved.\n\n');\n",
+"printf(' For prove refer to this example 16.3 on page number 567 of the book.')\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.4: Determination_of_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.4\n",
+"//Page number - 571\n",
+"printf('Example - 16.4 and Page number - 571\n\n');\n",
+"\n",
+"//Given\n",
+"T = 200;//[K]\n",
+"R = 8.314;//[J/mol*K] - universal gas constant\n",
+"// G_E = A*x_1*x_2\n",
+"A = 4000;//[J/mol]\n",
+"x_1 = 0.6;// Mle fraction of feed composition\n",
+"\n",
+"// Since A is given to be independent of temperature\n",
+"UCST = A/(2*R);//[K] - Upper critical solution temperature\n",
+"printf(' The UCST of the system is %f K\n\n',UCST);\n",
+"\n",
+"// Since the given temperature is less than UCST therefore two phase can get formed at the given temperature.\n",
+"\n",
+"// x1_alpha = 1 - x1_beta\n",
+"// We know that, x1_alpha*Y_1_alpha = x2_alpha*Y_2_alpha\n",
+"// x1_alpha*exp[(A/(R*T))*(x2_alpha)^(2)] = (1 - x1_alpha)*exp[(A/(R*T))*(x1_alpha)^(2)]\n",
+"// where use has beeen made of the fact that x1_alpha = 1 - x1_beta and x2_beta = 1 - x1_beta = x1_alpha .Taking logarithm of both side we get\n",
+"// log(x1_alpha) + (A/(R*T))*(1 - x1_alpha)^(2) = log(1 - x1_alpha) + (A/(R*T))*x1_alpha^(2)\n",
+"// log(x1_alpha/(1-x1_alpha)) = (A/(R*T))*(2*x1_alpha - 1)\n",
+"\n",
+"deff('[y]=f(x1_alpha)','y= log(x1_alpha/(1-x1_alpha)) - (A/(R*T))*(2*x1_alpha - 1)');\n",
+"x1_alpha = fsolve(0.1,f);\n",
+"x1_beta = fsolve(0.9,f);\n",
+"// Because of symmetry 1 - x1_beta = x1_alpha\n",
+"\n",
+"// It can be seen that the equation, log(x1/(1-x1)) = (A/(R*T))*(2*x1 - 1) has two roots.\n",
+"// The two roots acn be determined by taking different values \n",
+"// 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",
+"// Thus x1 = 0.169 is the composition of phase alpha and x1 = 0.831 is of phase beta\n",
+"printf(' The composition of two liquid phases in equilibrium is given by, x1_alpha = %f and x1_beta = %f\n\n',x1_alpha,x1_beta);\n",
+"\n",
+"// 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",
+"// whereas if the overall (feed) composition is between 0.169 and 0.831 two phases shall be formed.\n",
+"// The amounts of phases can also be calculated. The feed composition is given to be z1 = 0.6\n",
+"z1 = 0.6;\n",
+"// z1 = x1_alpha*alpha + x1_beta*beta\n",
+"// beta = 1 - alpha\n",
+"alpha = (z1-x1_beta)/(x1_alpha-x1_beta);//[mol]\n",
+"Beta = 1 - alpha;//[mol]\n",
+"printf(' The relative amount of phases is given by, alpha = %f mol and beta = %f mol\n\n\n',alpha,Beta);\n",
+"\n",
+"// the relative amounts of the phases changes with the feed composition \n",
+"\n",
+"//log(x1/(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 mixtures is obtained.\n",
+"\n",
+"printf(' log(x1/(1-x1)) = (A/(R*T))*(2*x1 - 1)\n');\n",
+"printf(' 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');\n",
+"printf(' and if it has no real roots then a homogeneous liquid mixture is obtained\n');\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.5: Determination_of_equilibrium_composition.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.5\n",
+"//Page number - 573\n",
+"printf('Example - 16.5 and Page number - 573\n\n');\n",
+"\n",
+"//Given\n",
+"T = 300;//[K]\n",
+"R = 8.314;//[J/mol*K] - universal gas constant\n",
+"A = 7000;//[J/mol]\n",
+"\n",
+"// log(x_1/(1-x_1)) = (A/(R*T))*(2*x_1-1)\n",
+"\n",
+"deff('[y]=f(x_1)','y=log(x_1/(1-x_1))-((A/(R*T))*(2*x_1-1))');\n",
+"\n",
+"x1_alpha=fsolve(0.1,f);\n",
+"\n",
+"x1_beta=1-x1_alpha;\n",
+"\n",
+"printf('The equilibrium compositin of the two liquid phase system is given by\n x1_alpha \t = %f \n x1_beta \t = %f',x1_alpha,x1_beta);\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.6: Proving_a_mathematical_relation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.6\n",
+"//Page number - 577\n",
+"printf('Example - 16.6 and Page number - 577\n\n');\n",
+"\n",
+"//This problem involves proving a relation in which no mathematics and no calculations are involved.\n",
+"//For prove refer to this example 16.6 on page number 577 of the book.\n",
+"printf(' This problem involves proving a relation in which no mathematics and no calculations are involved.\n\n');\n",
+"printf(' For prove refer to this example 16.6 on page number 577 of the book.')\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.7: Determination_of_freezing_point_depression.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.7\n",
+"//Page number - 579\n",
+"printf('Example - 16.7 and Page number - 579\n\n');\n",
+"\n",
+"//Given\n",
+"R = 8.314;//[J/mol*K] - Universal gas constant\n",
+"M_wt_meth = 32;// Molecular weight of methanol \n",
+"M_wt_water = 18;// Molecular weight of water \n",
+"m_meth = 0.01;//[g] - Mass of methanol added per cm^(3) of solution\n",
+"\n",
+"//Since the concentration of methanol is very small therefore we can assume that the density of solution = pure water\n",
+"den_sol = 1;//[g/cm^(3)]\n",
+"\n",
+"//The mole fraction of solute is given by\n",
+"//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",
+"//We know that heat of fusion of water is\n",
+"H_fus = -80;//[cal/g] - Enthalpy change of fusion at 0 C\n",
+"H_fus = H_fus*4.186*M_wt_water;//[J/mol]\n",
+"\n",
+"//Therefore freezing point depression is given by\n",
+"// T - T_m = (R*(T^(2))*x_2)/H_fus\n",
+"T_f = 273.15;//[K] - Freezing point of water\n",
+"delta_T_f = (R*(T_f^(2))*x_2)/H_fus;//[K]\n",
+"\n",
+"printf('The depression in freezing point is given by \n delta_T = %f K',delta_T_f);"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.8: Determination_of_freezing_point.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"//Example - 16.8\n",
+"//Page number - 580\n",
+"printf('Example - 16.8 and Page number - 580\n\n');\n",
+"//Given\n",
+"R = 8.314;//[J/mol*K] - universal gas constant\n",
+"T_f = 273.15;//[K] - Freezing point of water\n",
+"m_water = 100;//[g] - Mass of water\n",
+"m_NaCl = 3.5;//[g] - Mass of NaCl\n",
+"M_wt_water = 18.015;// Molecular weight of water \n",
+"M_wt_NaCl = 58.5;// Molecular weight of NaCl\n",
+"mol_water = m_water/M_wt_water;//[mol] - Moles of water\n",
+"mol_NaCl = m_NaCl/M_wt_NaCl;//[mol] - Moles of NaCl\n",
+"H_fus = -80;//[cal/g] - Enthalpy change of fusion at 0 C\n",
+"H_fus = H_fus*4.186*M_wt_water;//[J/mol]\n",
+"//Mole fraction of the solute (NaCl) is given by\n",
+"x_2 = mol_NaCl/(mol_NaCl+mol_water);\n",
+"//But NaCl is compietely ionized and thus each ion acts independently to lower the water mole fraction.\n",
+"x_2_act = 2*x_2;// Actual mole fraction\n",
+"//Now depression in freezing point is given by\n",
+"// T - T_m = (R*(T^(2))*x_2_act)/H_fus\n",
+"delta_T_f = (R*(T_f^(2))*x_2_act)/H_fus;//[C]\n",
+"//Thus freezing point of seawater = depression in freezing point\n",
+"printf('The freezing point of seawater is %f C',delta_T_f);"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 16.9: Proving_a_mathematical_relation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"clear;\n",
+"clc;\n",
+"\n",
+"//Example - 16.9\n",
+"//Page number - 580\n",
+"printf('Example - 16.9 and Page number - 580\n\n');\n",
+"\n",
+"//This problem involves proving a relation in which no mathematics and no calculations are involved.\n",
+"//For prove refer to this example 16.9 on page number 580 of the book.\n",
+"printf(' This problem involves proving a relation in which no mathematics and no calculations are involved.\n\n');\n",
+"printf(' For prove refer to this example 16.9 on page number 580 of the book.')\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
+}