summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics_by_P_Ahuja/ch12_1.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Chemical_Engineering_Thermodynamics_by_P_Ahuja/ch12_1.ipynb')
-rwxr-xr-xChemical_Engineering_Thermodynamics_by_P_Ahuja/ch12_1.ipynb503
1 files changed, 503 insertions, 0 deletions
diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/ch12_1.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/ch12_1.ipynb
new file mode 100755
index 00000000..2d5ee204
--- /dev/null
+++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/ch12_1.ipynb
@@ -0,0 +1,503 @@
+{
+ "metadata": {
+ "name": "ch12_1",
+ "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": [
+ "from numpy import *\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