diff options
Diffstat (limited to 'Chemical_Engineering_Thermodynamics_by_P_Ahuja')
17 files changed, 19001 insertions, 0 deletions
diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/1-Introduction.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/1-Introduction.ipynb new file mode 100644 index 0000000..289674f --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/1-Introduction.ipynb @@ -0,0 +1,705 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Introduction" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.10: Calculation_of_pressure_and_temperature_at_triple_point.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.10\n", +"//Page number - 27\n", +"printf('Example - 1.10 and Page number - 27\n\n');\n", +"\n", +"//Given\n", +"// log(P)=-(1640/T)+10.56 (solid)\n", +"// log(P)=-(1159/T)+7.769 (liquid),where T is in K\n", +"// F+P=C+2, at triple point F+3=1+2 or,F=0 i.e,vapour pressure of liquid and solid at triple point are same,we get\n", +"// -(1640/T)+10.56 = -(1159/T)+7.769\n", +"\n", +"T = (1640-1159)/(10.56-7.769);//[K]\n", +"P = 10^((-1640/T)+10.56);//[torr]\n", +"\n", +"printf(' The temperature is %f K\n',T);\n", +"printf(' The pressure is %f torr (or mm Hg)',P);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.11: Determination_of_value_of_R_Cp0_and_Cv0.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.11\n", +"//Page number - 29\n", +"printf('Example - 1.11 and Page number - 29\n\n');\n", +"\n", +"//Given\n", +"M_O2 = 31.999;//molecular weight of oxygen\n", +"M_N2 = 28.014;//molecular weight of nitrogen\n", +"Y = 1.4;//molar heat capacities ratio for air\n", +"\n", +"//Molecular weight of air(21 vol% O2 and 79 vol% N2)is given by\n", +"M_air = (0.21*M_O2)+(0.79*M_N2);//(vol% = mol%)\n", +"\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"R = (R*1/M_air);//[kJ/kg*K]\n", +"\n", +"printf(' The value of universal gas constant (R) = %f kJ/kg-K \n',R);\n", +"\n", +"//Y=Cp0/Cv0 and Cp0-Cv0=R\n", +"Cv_0 = R/(Y-1);//[kJ/kg*K] \n", +"Cp_0 = Y*Cv_0;//[kJ/kg*K]\n", +"printf(' The value of Cp_0 for air is %f kJ/kg-K\n',Cp_0);\n", +"printf(' The value of Cv_0 for air is %f kJ/kg-K',Cv_0);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.12: Calculation_of_molar_heat_capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.12\n", +"//Page number - 30\n", +"printf('Example - 1.12 and Page number - 30\n\n');\n", +"\n", +"//Given\n", +"Y = 1.4;//molar heat capacities ratio for air\n", +"R = 8.314;// [J/mol*K] - Universal gas constant\n", +"Cv_0 = R/(Y-1);// [J/mol*K]\n", +"Cp_0 = Y*Cv_0;// [J/mol*K]\n", +"\n", +"printf(' The molar heat capacity at constant volume (Cv_0) is %f J/mol-K\n',Cv_0);\n", +"printf(' The molar heat capacity at constant pressure (Cp_0) is %f J/mol-K',Cp_0);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.13: Determination_of_mean_heat_capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.13\n", +"//Page number - 30\n", +"printf('Example - 1.13 and Page number - 30\n\n');\n", +"\n", +"//Given\n", +"// Cp0=7.7+(0.04594*10^(-2)*T)+(0.2521*10^(-5)*T^(2))-(0.8587*10^(-9)*T^(3))\n", +"T_1 = 400;//[K]\n", +"T_2 = 500;//[K]\n", +"\n", +"//(C)avg = q/(T_2 - T_1) = 1/(T_2 - T_1)*{(integrate('C','T',T_1,T_2))}\n", +"//(Cp0)avg = 1/(T_2 - T_1)*{(integrate('Cp0','T',T_1,T_2))}\n", +"Cp0_avg = (1/(T_2 - T_1))*integrate('7.7+(0.04594*10^(-2)*T)+(0.2521*10^(-5)*T^(2))-(0.8587*10^(-9)*T^(3))','T',T_1,T_2);\n", +"\n", +"printf(' The mean heat capacity (Cp0_avg) for temerature range of 400 to 500 K is %f cal/mol-K',Cp0_avg);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.14: Calculation_of_enthalpy_of_water.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.14\n", +"//Page number - 31\n", +"printf('Example - 1.14 and Page number - 31\n\n');\n", +"\n", +"//Given\n", +"//(a)\n", +"P_1 = 0.2;// [MPa] - pressure\n", +"x_1 = 0.59;// mole fraction\n", +"\n", +"//From saturated steam tables at 0.2 MPa\n", +"H_liq_1 = 504.7;// [kJ/kg] - Enthalpy of saturated liquid\n", +"H_vap_1 = 2706.7;// [kJ/kg]- Enthalpy of saturated vapour\n", +"H_1 = (H_liq_1*(1-x_1))+(x_1*H_vap_1);// [kJ/kg]\n", +"printf(' (a).Enthalpy of 1 kg of water in tank is %f kJ/kg\n',H_1);\n", +"\n", +"//(b)\n", +"T_2 = 120.23;// [C] - temperature\n", +"V_2 = 0.6;// [m^(3)/kg] - specific volume\n", +"\n", +"//From saturated steam tables at 120.23 C, as reported in the book\n", +"V_liq_2=0.001061;// [m^(3)/kg]\n", +"V_vap_2=0.8857;// [m^(3)/kg]\n", +"//since V_2 < Vv_2,dryness factor will be given by, V = ((1-x)*V_liq)+(x*V_vap)\n", +"x_2 = (V_2- V_liq_2)/(V_vap_2 - V_liq_2);\n", +"\n", +"//From steam table,at 120.2 C,the vapour pressure of water is 0.2 MPa.So,enthalpy is given by\n", +"H_2 = (H_liq_1*(1-x_2))+(H_vap_1*x_2);//kJ/kg]\n", +"printf(' (b).Enthalpy of saturated steam is %f kJ/kg\n',H_2);\n", +"\n", +"//(c)\n", +"P_3 = 2.5;//[MPa]\n", +"T_3 = 350;//[C]\n", +"//From steam tables at 2.5 MPa,T_sat = 223.99 C,as reported in the book\n", +"//since,T_3 > Tsat, steam is superheated\n", +"printf(' (c).As steam is superheated,from steam table,enthalpy (H) is 3126.3 kJ/kg\n');\n", +"\n", +"//(d)\n", +"T_4 = 350;//[C]\n", +"V_4 = 0.13857;//[m^(3)/kg]\n", +"//From steam table,at 350 C, V_liq = 0.001740 m^(3)/kg and V_vap = 0.008813 m^(3)/kg.Since,V > V_vap,therefore it is superheated.\n", +"//From steam table at 350 C and 1.6 MPa, V = 0.17456 m^(3)/kg\n", +"//At 350 C and 2.0 MPa, V = 0.13857 m^(3)/kg. So,\n", +"printf(' (d).The enthalpy of superheated steam (H) is 3137.0 kJ/kg\n');\n", +"\n", +"//(e)\n", +"P_4 = 2.0;//[MPa]\n", +"U_4 = 2900;// [kJ/kg] - internal energy\n", +"//From saturated table at 2.0 MPa, U_liq = 906.44kJ and U_vap = 2600.3 kJ/kg\n", +"//scince,U_4 > Uv, it is saturated.\n", +"//From superheated steam table at 2.0 MPa and 350 C, as reported in the book\n", +"U_1 = 2859.8;//[kJ/kg]\n", +"H_1 = 3137.0;//[kJ/kg]\n", +"//At 2.0 MPa and 400 C,\n", +"U_2 = 2945.2;//[kJ/kg]\n", +"H_2 = 3247.6;//[kJ/kg]\n", +"T = (((U_4 - U_1)/(U_2 - U_1))*(400 - 350)) + 350;//[C] - By interpolation\n", +"H = (((T - 350)/(400 - 350))*(H_2 - H_1)) + H_1;//[kJ/kg]\n", +"printf(' (e).The enthalpy value (of superheated steam) obtained after interpolation is %f kJ/kg\n',H);\n", +"\n", +"//(f)\n", +"P_5 = 2.5;//[MPa]\n", +"T_5 = 100;//[C]\n", +"//At 100 C,P_sat=101350 N/m^(2). Since P_5 > P_sat,it is compressed liquid\n", +"P_sat = 0.101350;//[MPa]\n", +"H_liq = 419.04;//[kJ/kg] - At 100 C and 0.10135 MPa\n", +"V_liq = 0.001044;//[m^(3)/kg] - At 100 C and 0.10135 MPa\n", +"H_0 = H_liq + (V_liq*(P_5 - P_sat))*1000;//kJ/kg]\n", +"printf(' (f).The enthalpy of compressed liquid is %f kJ/kg\n',H_0);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1: Calculation_of_pressure_and_heat_transfer_in_piston_cylinder_assembly.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.1 \n", +"//Page number - 6\n", +"printf('Example - 1.1 and Page number - 6\n\n');\n", +"\n", +"//(a)\n", +"// The pressure in the cylinder is due to the weight of the piston and due to surroundings pressure\n", +"m = 50;//[kg] - Mass of piston\n", +"A = 0.05;//[m^(2)] - Area of piston\n", +"g = 9.81;//[m/s^(2)] - Acceleration due to gravity\n", +"Po = 101325;//[N/m^(2)] - Atmospheric pressure\n", +"P = (m*g/A)+Po;//[N/m^(2)]\n", +"P = P/100000;//[bar]\n", +"printf(' (a).Pressure = %f bar\n',P);\n", +"\n", +"//(b)\n", +"printf(' (b).Since the piston weight and surroundings pressure are the same,the gas pressure in the piston-cylinder assembly remains %f bar',P);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2: Calculation_of_mass_of_air_contained_in_a_room.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.2\n", +"//Page number - 8\n", +"printf('Example - 1.2 and Page number - 8\n\n');\n", +"\n", +"// Given\n", +"P = 1;//[atm] - Atmospheric pressure\n", +"P = 101325;//[N/m^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"T = 30;//[C] - Temperature of air\n", +"T = 30+273.15;//[K]\n", +"V = 5*5*5;//[m^(3)] - Volume of the room\n", +"\n", +"//The number of moles of air is given by\n", +"n = (P*V)/(R*T);//[mol]\n", +"\n", +"//Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n", +"m = n*28.84;//[g]\n", +"m = m/1000;//[kg]\n", +"printf('The mass of air is, m = %f kg',m);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.3: Determination_of_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.3\n", +"//Page number - 13\n", +"printf('Example - 1.3 and Page number - 13\n\n');\n", +"\n", +"// Given\n", +"P1 = 3;// [bar] - initial pressure\n", +"V1 = 0.5;// [m^(3)] - initial volume\n", +"V2 = 1.0;// [m^(3)] - final volume\n", +"\n", +"//(a)\n", +"n = 1.5;\n", +"\n", +"//Let P*V^(n)=C //Given relation\n", +"//W (work done per mole)= (integrate('P','V',V1,V2))\n", +"//W = (integrate('(C/V^(n))','V',V1,V2)) = (C*((V2^*(1-n))-(V1^*(1-n))))/(1-n)\n", +"//Where C=P*V^(n)=P1*V1^(n)=P2*V2^(n)\n", +"//Thus w=((P2*V2^(n)*V2^(1-n))-(P1*V1^(n)*V1^(1-n)))/(1-n)\n", +"//w = ((P2*V2^(n))-(P1*V1^(n)))/(1-n)\n", +"//and thus W=((P2*V2)-(P1*V1))/(1-n)\n", +"//The above expression is valid for all values of n,except n=1.0\n", +"P2 = (P1*((V1/V2)^(n)));//[bar] //pressure at state 2\n", +"\n", +"//we have,(V1/V2)=(V1t/(V2t),since the number of moles are constant.Thus\n", +"W = ((P2*V2)-(P1*V1))/(1-n)*10^(5);//[J]\n", +"W = W/1000;//[kJ]\n", +"printf(' (a).The work done (for n=1.5) is %f kJ\n',W);\n", +"\n", +"//(b)\n", +"//For n=1.0,we have, PV=C.\n", +"// w(wok done per mol)= (integrate('P','V',V1,V2)) = (integrate('C/V','V',V1,V2)) = C*ln(V2/V1)=P1*V1*ln(V2/V1)\n", +"W1 = P1*V1*log(V2/V1)*10^(5);//[J]\n", +"W1 = W1/1000;//[kJ]\n", +"printf(' (b).The work done (for n=1.0) is %f kJ\n',W1);\n", +"\n", +"//(c)\n", +"//For n=0,we get P=Constant and thus\n", +"P = P1;//[bar]\n", +"// w =(integrate('P','V',V1,V2)) = P*(V2-V1)\n", +"W2 = P*(V2-V1)*10^(5);//[J]\n", +"W2 = W2/1000;//[kJ]\n", +"printf(' (c).The work done (for n=0) is %f kJ\n\n',W2);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.4: Determination_of_wind_energy_per_unit_mass_and_diameter_of_the_wind_turbine.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.4\n", +"//Page number - 17\n", +"printf('Example - 1.4 and Page number - 17\n\n');\n", +"\n", +"//(a)\n", +"//Given\n", +"V = 9;// [m/s] - velocity\n", +"d = 1;//[m] - diameter\n", +"A = 3.14*(d/2)^(2);//[m^(2)] - area\n", +"P = 1;//[atm] - pressure\n", +"P = 101325;// [N/m^(2)]\n", +"T = 300;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"E = (V^(2))/2;//[J/kg]\n", +"printf(' (a).The wind energy per unit mass of air is %f J/kg\n',E);\n", +"\n", +"//(b)\n", +"// Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n", +"M = 28.84*10^(-3);//[kg/mol]\n", +"r = (P*M)/(R*T);//[kg/m^(3)] - density\n", +"m = r*V*A;// [kg/s] - mass flow rate of air\n", +"pi = m*E;//[Watt] - power input\n", +"printf(' (b).The wind power input to the turbine is %f Watt',pi);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.5: Determination_of_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.5\n", +"//Page number - 23\n", +"printf('Example - 1.5 and Page number - 23\n\n');\n", +"\n", +"// Given\n", +"P = 1;// [bar] - atospheric pressure\n", +"P1guz = 0.75;// [bar] - gauze pressure in 1st evaporator\n", +"P2Vguz = 0.25;// [bar] - vaccum gauze pressure in 2nd evaporator\n", +"P1abs = P + P1guz;// [bar] - absolute pressure in 1st evaporator\n", +"P2abs = P - P2Vguz;// [bar] -absolute pressure in 2nd evaporator\n", +"\n", +"//From saturated steam table as reported in the book\n", +"printf(' For P1abs (absolute pressure) = %f bar\n',P1abs);\n", +"printf(' The saturation temperature in first evaporator is 116.04 C\n\n');\n", +"printf(' For P2abs (absolute pressure) = %f bar\n',P2abs);\n", +"printf(' The saturation temperature in second evaporator is 91.76 C\n');\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.6: Calculation_of_dryness_fraction_of_steam.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.6\n", +"//Page number - 23\n", +"printf('Example - 1.6 and Page number - 23\n\n');\n", +"\n", +"// Given\n", +"V = 1;// [kg] - volume of tank\n", +"P = 10;// [bar] - pressure\n", +"\n", +"//Here degree of freedom =1(C=1,P=2,threfore F=1)\n", +"//From steam table at 10 bar as reported in the book\n", +"V_liq = 0.001127;// [m^(3)/kg] - volume in liquid phase\n", +"V_vap = 0.19444;// [m^(3)/kg] - volume in vapour phase\n", +"\n", +"//x*Vv=(1-x)*Vl // since two volumes are equal\n", +"x = (V_liq/(V_liq+V_vap));// [kg]\n", +"y = (1-x);//[kg]\n", +"\n", +"printf(' Mass of saturated vapour is %f kg\n',x);\n", +"printf(' Mass of saturated liquid is %f kg',y);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.7: Determination_of_pressure_mass_and_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.7\n", +"//Page number - 23\n", +"printf('Example - 1.7 and Page number - 23\n\n');\n", +"\n", +"// Given\n", +"V = 1;// [m^(3)] - volume of tank\n", +"M = 10;// [m^(3)] - total mass\n", +"T = (90+273.15);//[K] - temperature\n", +"\n", +"//From steam table at 90 C as reported in the book\n", +"//vapour pressure(pressure of rigid tank) = 70.14[kPa] = 0.7014[bar]\n", +"printf(' Pressure of tank = 0.7014 bar\n');\n", +"\n", +"V_liq_sat=0.001036;// [m^(3)/kg] - saturated liquid specific volume\n", +"V_vap_sat=2.36056;// [m^(3)/kg] - saturated vapour specific volume\n", +"\n", +"//1=(V_liq_sat*(10-x))+(V_vap_sat*x)\n", +"x = (1-(10*V_liq_sat))/(V_vap_sat-V_liq_sat);//[kg]\n", +"y = (10-x);//[kg]\n", +"\n", +"printf(' The amount of saturated liquid is %f kg\n',y);\n", +"printf(' The amount of saturated vapour is %f kg \n',x);\n", +"\n", +"z = y*V_liq_sat;//[m^(3)] - Volume of saturated liquid \n", +"w = x*V_vap_sat;//[m^(3)] - Volume of saturated vapour\n", +"\n", +"printf(' Total volume of saturated liquid is %f m^(3)\n',z);\n", +"printf(' Total volume of saturated vapour is %f m^(3)',w);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.8: Determination_of_heat_supplied.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.8\n", +"//Page number - 24\n", +"printf('Example - 1.8 and Page number - 24\n\n');\n", +"\n", +"// Given\n", +"V = 10;// [m^(3)] - volume of vessel\n", +"P_1 = 1;// [bar] - initial pressure\n", +"V_liq_sat = 0.05;// [m^(3)] - saturated liquid volume\n", +"V_gas_sat = 9.95;// [m^(3)] - saturated vapour volume\n", +"\n", +"//At 1 bar pressure\n", +"V_liq_1 = 0.001043;// [m^(3/kg)] - specific saturated liquid volume\n", +"U_liq_1 = 417.33;// [kJ/kg] - specific internal energy\n", +"V_gas_1 = 1.69400;// [m^(3/kg)] - specific saturated vapour volume\n", +"U_gas_1 = 2506.06;// [kJ/kg]\n", +"\n", +"M_liq_1 = V_liq_sat/V_liq_1;// [kg] - mass of saturated liqid\n", +"M_gas_1 = V_gas_sat/V_gas_1;// [kg] - mass of saturated vapour\n", +"M = (M_liq_1+M_gas_1);// [kg] - total mass\n", +"U_1t = (M_liq_1*U_liq_1)+(M_gas_1*U_gas_1);// [kJ] - initial internal energy\n", +"V_gas_2 = (V/M);//[m^(3/kg)]\n", +"\n", +"//from steam table at 10 bar pressure as reported in the book\n", +"V_vap_2 = 0.19444;// [m^(3/kg)]\n", +"U_vap_2 = 2583.64;// [kJ/kg]\n", +"\n", +"//from steam table at 11 bar pressure as reported in the book\n", +"V_vap_3 = 0.17753;//[m^(3/kg)]\n", +"U_vap_3 = 2586.40;//[kJ/kg]\n", +"\n", +"//Now computing pressure when molar volume of saturated vapour=Vg_2\n", +"//By interpolation (P2-10)/(11-10)=(Vg_2-Vv_2)/(Vv_3-Vv_2)\n", +"P_2 = (((V_gas_2 - V_vap_2)/(V_vap_3 - V_vap_2)*1)+10);// [bar] - final pressure\n", +"\n", +"//By interpolation calculating internal energy at state 2\n", +"//(P2-10)/(11-10)=(U2-Uv_2)/(Uv_3-Uv_2)\n", +"U_2 = (((P_2-10)/(11-10))*(U_vap_3 - U_vap_2))+U_vap_2;//[kJ/kg]\n", +"U_2t = U_2*M;//[kJ]\n", +"H = U_2t - U_1t;//[kJ] - Heat supplied\n", +"H = H/1000;//[MJ]\n", +"\n", +"printf(' Total heat supplied is %f MJ',H);\n", +"// since volume is constant,no work is done by the system and heat supplied is used in increasing the internal energy of the system.\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.9: Calculation_of_saturation_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 1.9\n", +"//Page number - 26\n", +"printf('Example - 1.9 and Page number - 26\n\n');\n", +"\n", +"//Given\n", +"//Antoine equation for water ln(Psat)=16.262-(3799.89/(T_sat + 226.35))\n", +"P = 2;//[atm] - Pressure\n", +"P = (2*101325)/1000;//[kPa]\n", +"\n", +"P_sat = P;// Saturation pressure\n", +"T_sat = (3799.89/(16.262-log(P_sat)))-226.35;//[C] - Saturation temperature\n", +"//Thus boiling at 2 atm occurs at Tsat = 120.66 C.\n", +"\n", +"//From steam tables,at 2 bar,Tsat = 120.23 C and at 2.25 bar,Tsat = 124.0 C\n", +"//From interpolation for T_sat = 120.66 C,P = 2.0265 bar\n", +"//For P_= 2.0265 bar,T_sat, from steam table by interpolation is given by\n", +"//((2.0265-2)/(2.25-2))=((Tsat-120.23)/(124.0-120.23))\n", +"T_sat_0 = (((2.0265-2)/(2.25-2))*(124.0-120.23))+120.23;//[C]\n", +"\n", +"printf(' Saturation temperature (Tsat) = %f C which is close to %f C as determined from Antoine equation',T_sat_0,T_sat);\n", +"\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/10-Residual_Properties_by_Equations_of_State.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/10-Residual_Properties_by_Equations_of_State.ipynb new file mode 100644 index 0000000..2f969a7 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/10-Residual_Properties_by_Equations_of_State.ipynb @@ -0,0 +1,2481 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 10: Residual Properties by Equations of State" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.10: Determination_of_work_done_and_the_exit_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.10\n", +"//Page number - 345\n", +"printf('Example - 10.10 and Page number - 345\n\n');\n", +"\n", +"//Given\n", +"P_1 = 1*10^(6);//[Pa] - Initial pressure\n", +"T_1 = 200 + 273.15;//[K] - Initial temperature\n", +"P_2 = 8*10^(6);//[Pa] - Final pressure\n", +"Tc = 647.1;//[K] - Critical temperature of water\n", +"Pc = 220.55;//[bar] - Critical pressure of water\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.345;\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// For the virial gas the following are the relations for residual enthalpy and entropy\n", +"// H_R = B*P - P*T*(dB/dT) \n", +"// S_R = -P*(dB/dT)\n", +"// Where, (dB/dT) = ((R*Tc)/Pc)*((dB_0/dT) + w*(dB_1/dT))\n", +"// dB0_dT = 0.422*1.6*Tc^(1.6)*T^(-2.6);// (dB_0/dT)\n", +"// dB1_dT = 0.172*4.2*Tc^(4.2)*T^(-5.2);// (dB_1/dT)\n", +"\n", +"// (1)\n", +"Cp_0 = 29.114;//[J/mol-K] - Specific heat capacity at constant pressure\n", +"// For the isentropic process entropy change is zero, thus\n", +"// delta_S = Cp_0*log(T_2/T_1) - P_2*(dB/dT)_2 + P_1*(dB/dT)_1 = 0\n", +"\n", +"// At state 1, \n", +"Tr_1 = T_1/Tc;\n", +"B0_1 = 0.083 - 0.422/(Tr_1^(1.6));\n", +"B1_1 = 0.139 - 0.172/(Tr_1^(4.2));\n", +"// (B*Pc)/(R*Tc) = B0 + w*B1\n", +"B_1 = ((B0_1 + w*B1_1)*(R*Tc))/Pc;// [m^(3)/mol] - Second virial coefficient at state 1\n", +"dB0_dT_1 = 0.422*1.6*Tc^(1.6)*T_1^(-2.6);// (dB_0/dT)\n", +"dB1_dT_1 = 0.172*4.2*Tc^(4.2)*T_1^(-5.2);// (dB_1/dT)\n", +"dB_dT_1 = ((R*Tc)/Pc)*((dB0_dT_1) + w*(dB1_dT_1));// (dB/dT)_1\n", +"\n", +"// Now let us assume the exit temperature to be 870 K, at this temperature\n", +"// T_2 = 870;//[K] - \n", +"// At this temperature\n", +"// delta_S = Cp_0*log(T_2/T_1) - P_2*(dB/dT)_2 + P_1*(dB/dT)_1 = \n", +"\n", +"\n", +"T_2 = 860;//[K] - Exit temperature\n", +"// Therefore at state 2, we have\n", +"Tr_2 = T_2/Tc;\n", +"B0_2 = 0.083 - 0.422/(Tr_2^(1.6));\n", +"B1_2 = 0.139 - 0.172/(Tr_2^(4.2));\n", +"// (B*Pc)/(R*Tc) = B0 + w*B1\n", +"B_2 = ((B0_2 + w*B1_2)*(R*Tc))/Pc;// [m^(3)/mol] - Second virial coefficient at state 2\n", +"dB0_dT_2 = 0.422*1.6*Tc^(1.6)*T_2^(-2.6);// (dB_0/dT)\n", +"dB1_dT_2 = 0.172*4.2*Tc^(4.2)*T_2^(-5.2);// (dB_1/dT)\n", +"dB_dT_2 = ((R*Tc)/Pc)*((dB0_dT_2) + w*(dB1_dT_2));// (dB/dT)_2\n", +"\n", +"delta_H_s = Cp_0*(T_2 - T_1) + B_2*P_2 -P_2*T_2*(dB_dT_2) - B_1*P_1 + P_1*T_1*(dB_dT_1);//[J/mol] - Enthalpy change\n", +"\n", +"// As no heat exchange is assumed to take place with the surroundings,work transfer is given by\n", +"W_1 = - delta_H_s;// [J/mol]\n", +"\n", +"printf(' (1).The exit temperature is %f K\n',T_2);\n", +"printf(' The required amount of work is %f J/mol\n\n',W_1);\n", +"\n", +"\n", +"// (2)\n", +"eff = 0.8;// Adiabatic efficiency\n", +"delta_H_a = delta_H_s/0.8;// Actual enthalpy change\n", +"\n", +"// Now for calculating the value of T_exit\n", +"// delta_H_a = Cp_0*(T_exit - T_1) + B*P_2 -P_2*T_exit*(dB_dT) - B_1*P_1 + P_1*T_1*(dB_dT_1)\n", +"// On simplification we get\n", +"// 29.114*(T_2 - T_1)*B_2*8*10^(6)-8*10^(6)*T_2*(dB/dT)_2 = 12643.77 \n", +"\n", +"// Let us assume a temperature of say\n", +"T = 900;//[K]\n", +"fault=10;\n", +"\n", +"while(fault>0.3)\n", +" Tr = T/Tc;\n", +" B0 = 0.083 - 0.422/(Tr^(1.6));\n", +" B1 = 0.139 - 0.172/(Tr^(4.2));\n", +" // (B*Pc)/(R*Tc) = B0 + w*B1\n", +" B = ((B0 + w*B1)*(R*Tc))/Pc;// [m^(3)/mol] - Second virial coefficient at state 2\n", +" dB0_dT = 0.422*1.6*Tc^(1.6)*T^(-2.6);// (dB_0/dT)\n", +" dB1_dT = 0.172*4.2*Tc^(4.2)*T^(-5.2);// (dB_1/dT)\n", +" dB_dT = ((R*Tc)/Pc)*((dB0_dT) + w*(dB1_dT));// (dB/dT)_1\n", +" deff('[y]=f(T_exit)','y = delta_H_a - Cp_0*(T_exit - T_1) + B*P_2 -P_2*T_exit*(dB_dT) - B_1*P_1 + P_1*T_1*(dB_dT_1)');\n", +" T_exit = fsolve(900,f);\n", +" fault=abs(T-T_exit);\n", +" T = T + 0.2;\n", +"end\n", +"Texit = T;\n", +"\n", +"// As no heat exchange is assumed to take place with the surroundings,work transfer is given by\n", +"W_2 = - delta_H_a;// [J/mol]\n", +"\n", +"printf(' (2).The exit temperature is %f K\n',Texit);\n", +"printf(' The required amount of work is %f J/mol\n\n',W_2);\n", +"\n", +"//(3)\n", +"// Cp_0 = 7.7 + 0.04594*10^(-2)*T + 0.2521*10^(-5)*T^(2) - 0.8587*10^(-9)*T^(3)\n", +"// The entropy change for a gas following the virial equation of state is given by\n", +"// delta_S = integrate('Cp_0/T','T',T_1,T_2) - R*log(P_2/P_1) - P_2*(dB/dT)_2 + P_1*(dB/dT)_1 \n", +"// For an isentropic process the entropy change is zero and substituting the various values in the above equation we get\n", +"// 32.2168*log(T_2) + 0.1922*10^(-2)*T_2 + 0.5274*10^(-5)*T_2^(2) - 1.1976*10^(-9)*T_2^(3)-8*10^(6)*(dB/dT)_2 -216.64 = 0\n", +"\n", +"// Let us assume a temperature of say\n", +"T_prime = 700;//[K]\n", +"fault1=10;\n", +"\n", +"while(fault1>0.5)\n", +" Tr_prime = T_prime/Tc;\n", +" B0_prime = 0.083 - 0.422/(Tr_prime^(1.6));\n", +" B1_prime = 0.139 - 0.172/(Tr_prime^(4.2));\n", +" // (B*Pc)/(R*Tc) = B0 + w*B1\n", +" B_prime = ((B0_prime + w*B1_prime)*(R*Tc))/Pc;// [m^(3)/mol] - Second virial coefficient at state 2\n", +" dB0_dT_prime = 0.422*1.6*Tc^(1.6)*T_prime^(-2.6);// (dB_0/dT)\n", +" dB1_dT_prime = 0.172*4.2*Tc^(4.2)*T_prime^(-5.2);// (dB_1/dT)\n", +" dB_dT_prime = ((R*Tc)/Pc)*((dB0_dT_prime) + w*(dB1_dT_prime));// (dB/dT)_1\n", +" deff('[y]=f1(T_out)','y = 32.2168*log(T_out) + 0.1922*10^(-2)*T_out + 0.5274*10^(-5)*T_2^(2) - 1.1976*10^(-9)*T_out^(3)-8*10^(6)*dB_dT_prime -216.64');\n", +" T_out = fsolve(10,f1);\n", +" fault1=abs(T_prime-T_out);\n", +" T_prime = T_prime + 0.5;\n", +"end\n", +"T_out = T_prime;\n", +"\n", +"// Now we have to calculate enthalpy change as W = -delta_H\n", +"delta_H_3 = integrate('(7.7 + 0.04594*10^(-2)*T + 0.2521*10^(-5)*T^(2) - 0.8587*10^(-9)*T^(3))*4.184','T',T_1,T_out) + B_prime*P_2 - P_2*T_out*dB_dT_prime - B_1*P_1 + P_1*T_1*dB_dT_1;//[J/mol]\n", +"\n", +"W_3 = - delta_H_3;// [J/mol]\n", +"\n", +"printf(' (3).The exit temperature is %f K\n',T_out);\n", +"printf(' The required amount of work is %f J/mol\n\n',W_3);\n", +"\n", +"//(4)\n", +"n = 0.8;// Adiabatic efficiency\n", +"delta_H_a_4 = delta_H_3/n;//[J/mol]\n", +"W_4 = -delta_H_a_4;//[J/mol]\n", +"\n", +"// Now we have to determine the exit temperature when the enthalpy is delta_H_a_4\n", +"// 7.7*4.184*(T_2-T_1) + ((0.04594*4.184*10^(-2))/2)*(T_2^(2)-T_1^(2)) + ((0.2521*4.184*10^(-5))/3)*(T_2^(3)-T_1^(3)) - ((0.8587*4.184*10^(-9))/4)*(T_2^(4)-T_1^ (4)) + B_2*8*10^(6) - 8*10^(6)*T_2*(dB/dT)_2 + 191.7 + 496.81 = delta_H_a_4\n", +"\n", +"// Let us assume a temperature of say\n", +"T_prime1 = 700;//[K]\n", +"fault2=10;\n", +"\n", +"while(fault2>0.5)\n", +" Tr_prime1 = T_prime1/Tc;\n", +" B0_prime1 = 0.083 - 0.422/(Tr_prime1^(1.6));\n", +" B1_prime1 = 0.139 - 0.172/(Tr_prime1^(4.2));\n", +" // (B*Pc)/(R*Tc) = B0 + w*B1\n", +" B_prime1 = ((B0_prime1 + w*B1_prime1)*(R*Tc))/Pc;// [m^(3)/mol] - Second virial coefficient at state 2\n", +" dB0_dT_prime1 = 0.422*1.6*Tc^(1.6)*T_prime1^(-2.6);// (dB_0/dT)\n", +" dB1_dT_prime1 = 0.172*4.2*Tc^(4.2)*T_prime1^(-5.2);// (dB_1/dT)\n", +" dB_dT_prime1 = ((R*Tc)/Pc)*((dB0_dT_prime1) + w*(dB1_dT_prime1));// (dB/dT)_1\n", +" deff('[y]=f2(T_2)','y = 7.7*4.184*(T_2-T_1) + ((0.04594*4.184*10^(-2))/2)*(T_2^(2)-T_1^(2)) + ((0.2521*4.184*10^(-5))/3)*(T_2^(3)-T_1^(3)) - ((0.8587*4.184*10^(-9))/4)*(T_2^(4)-T_1^(4)) + B_prime1*8*10^(6) - 8*10^(6)*T_2*dB_dT_prime1 + 191.7 + 496.81 - delta_H_a_4');\n", +" T_out1 = fsolve(100,f2);\n", +" fault2=abs(T_prime1-T_out1);\n", +" T_prime1 = T_prime1 + 0.5;\n", +"end\n", +"T_out1 = T_prime1;\n", +"\n", +"printf(' (4).The exit temperature is %f K\n',T_out1);\n", +"printf(' The required amount of work is %f J/mol\n\n',W_4);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.11: Calculation_of_temperature_and_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.11\n", +"//Page number - 348\n", +"printf('Example - 10.11 and Page number - 348\n\n');\n", +"\n", +"//Given\n", +"Vol = 0.15;//[m^(3)] - Volume of the cylinder\n", +"P_1 = 100;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"T_1 = 170;//[K] - Initial temperature\n", +"n_withdrawn = 500;//[mol] - Withdrawn number of moles\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"\n", +"//(1)\n", +"Y = 1.4;// Coefficient of adiabatic expansion\n", +"n_total = (P_1*Vol)/(R*T_1);//[mol] - Total number of moles\n", +"n_2 = n_total - n_withdrawn;//[mol] - Left number of moles\n", +"V_1 = Vol/n_total;//[m^(3)/mol] - Molar volume at initial state.\n", +"// At final state\n", +"V_2 = Vol/n_2;//[m^(3)/mol] - Molar volume at final state\n", +"\n", +"// During duscharging P_1*V_1^(Y) = P_2*V_2^(Y), therefore\n", +"P_2_1 = P_1*((V_1/V_2)^(Y));//[Pa] - Final pressure\n", +"P_2_1 = P_2_1*10^(-5);//[bar]\n", +"T_2_1 = ((P_2_1*10^(5))*V_2)/R;//[K] - Final temperature\n", +"\n", +"printf(' (1).The final temperature %f K\n',T_2_1);\n", +"printf(' The final pressure %f bar\n\n',P_2_1);\n", +"\n", +"//(2)\n", +"// Cp_0 = 27.2 + 4.2*10^(-3)*T\n", +"// For a discharge process entropy per mol of the gas that remains in the cylinder is constant, delta_S = 0\n", +"// Therefore foe one mol of ideal gas integrate('Cp_0/T','T',T_1,T_2) - R*log(P_2/P_1) = 0\n", +"// Since the gas is assumed to be ideal,therefore P_2*Vol = n_2*R*T_2\n", +"// P_2 = (n_2*R*T_2)/V_2. Substituting in above equation after simplification we get\n", +"// 27.2*log(T_2/T_1) + 4.2*10^(-3)*(T_2 - T_1) - R*log(P_2/P_1)\n", +"// f(T) = 18.886*log(T) + 4.2*10^(-3)*T - 92.4\n", +"// f(T)_dash = 18.886/T + 4.2*10^(-3) // Derivative of the above function\n", +"\n", +"// Starting with a temperature of 150 K\n", +"T_prime = 150;//[K]\n", +"error = 10;\n", +"while(error>1)\n", +" f_T = 18.886*log(T_prime) + 4.2*10^(-3)*T_prime - 92.4;\n", +" f_T_dash = 18.886/T_prime + 4.2*10^(-3);\n", +" T_new = T_prime - (f_T/f_T_dash);\n", +" error=abs(T_prime - T_new);\n", +" T_prime = T_new;\n", +"end\n", +"\n", +"T_2_2 = T_prime;//[K] - Final temperature\n", +"P_2_2 = ((n_2*R*T_2_2)/Vol)*10^(-5);//[bar] - Final pressure\n", +"\n", +"printf(' (2).The final temperature %f K\n',T_2_2);\n", +"printf(' The final pressure %f bar\n\n',P_2_2);\n", +"\n", +"//(3)\n", +"Tc = 126.2;//[K] - Critical temperature of nitrogen\n", +"Pc = 34.0;//[bar] - Critical pressure of nitrogen\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.038;// Acentric factor\n", +"\n", +"// Virial equation of state, Z = 1 + (B*P)/(R*T)\n", +"// S_R = -P*(dB/dT)\n", +"\n", +"dB0_dT = 0.422*1.6*Tc^(1.6)*T_1^(-2.6);// (dB_0/dT) at state 1\n", +"dB1_dT = 0.172*4.2*Tc^(4.2)*T_1^(-5.2);// (dB_1/dT) at state 1\n", +"dB_dT = ((R*Tc)/Pc)*((dB0_dT) + w*(dB1_dT));// (dB/dT) at state 1\n", +"// The residual entropy at the initial state is given by \n", +"S_R_1 = -P_1*(dB_dT);//[J/mol-K]\n", +"\n", +"// Now let us calculate molar volume at initial state\n", +"Tr = T_1/Tc;// Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B = ((B_0+(w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]\n", +"\n", +"V_1_3 = B + (R*T_1)/P_1;//[m^(3)/mol]\n", +"// Therefore number of moles in the initial state is\n", +"n_1_3 = Vol/V_1_3;//[mol]\n", +"// Therefore final number of moles is\n", +"n_2_3 = n_1_3 - n_withdrawn;\n", +"\n", +"// Therefore molar volume at final state is\n", +"V_2_3 = Vol/n_2_3;//[m^(3)/mol]\n", +"\n", +"// Now let us determine the relation between pressure and temperature in the final state\n", +"// P_2_3 = (R*T_2_3)/(V_2_3 - B_2)\n", +"//delta_S = 0, thus delta_S_ig + delta_S_R = 0\n", +"delta_S_R = - S_R_1;\n", +"// integrate('Cp_0/T','T',T_1,T_2) - R*log(P_2/P_1) - P_2*(dB/dT)_2 + S_R_1\n", +"// On simplification,\n", +"// delta_S = 27.2*(log(T_2_prime/T_1)) + 4.2*10^(-3)*(T_2_prime - T_1) - R*(log(P_2_3/P_1)) - P_2_3*(dB_dT_3) + delta_S_R\n", +"// Starting with a temperature of 135 K\n", +"\n", +"T_2_prime = 135;//[K]\n", +"delta = 0.1;\n", +"error = 10;\n", +"while(error>0.01)\n", +" T_r = T_2_prime/Tc;// Reduced temperature\n", +" B_0_3 = 0.083-(0.422/(T_r)^(1.6));\n", +" B_1_3 = 0.139-(0.172/(T_r)^(4.2));\n", +" B_3 = ((B_0_3+(w*B_1_3))*(R*Tc))/Pc;//[m^(3)/mol]\n", +" dB0_dT_3 = 0.422*1.6*Tc^(1.6)*T_2_prime^(-2.6);// (dB_0/dT)\n", +" dB1_dT_3 = 0.172*4.2*Tc^(4.2)*T_2_prime^(-5.2);// (dB_1/dT)\n", +" dB_dT_3 = ((R*Tc)/Pc)*((dB0_dT_3) + w*(dB1_dT_3));// (dB/dT)\n", +" P_2_3 = (R*T_2_prime)/(V_2_3 - B_3);\n", +" delta_S = 27.2*(log(T_2_prime/T_1)) + 4.2*10^(-3)*(T_2_prime - T_1) - R*(log(P_2_3/P_1)) - P_2_3*(dB_dT_3) + delta_S_R;\n", +" T_new = T_2_prime + delta;\n", +" error=abs(delta_S);\n", +" T_2_prime = T_new;\n", +"end\n", +"\n", +"T_2_3 = T_2_prime;//[K] - Final temperature\n", +"// Therefore at T_2_3\n", +"P_2_3 = P_2_3*10^(-5);//[bar] - Final pressure\n", +"\n", +"printf(' (3).The final temperature %f K\n',T_2_3);\n", +"printf(' The final pressure %f bar\n\n',P_2_3);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.12: Calculation_of_change_of_internal_energy_enthalpy_entropy_and_exergy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.12\n", +"//Page number - 351\n", +"printf('Example - 10.12 and Page number - 351\n\n');\n", +"\n", +"//Given\n", +"P_1 = 80;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"T_1 = 300 + 273.15;//[T] - Initial temperature\n", +"P_2 = 40;//[bar] - Final pressure\n", +"P_2 = P_2*10^(5);//[Pa]\n", +"T_2 = 300 + 273.15;//[K] - Final temperature\n", +"T_0 = 25 + 273.15;//[K] - Surrounding temperature\n", +"P_0 = 1;//[atm] - Surrounding pressure\n", +"P_0 = P_0*101325;//[Pa]\n", +"Tc = 647.1;//[K]\n", +"Pc = 220.55;//[bar]\n", +"Pc = Pc*10^(5);//[Pa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// For van der Walls equation of state\n", +"a = (27*R^(2)*Tc^(2))/(64*Pc);//[Pa-m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3) - (b + (R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"\n", +"// Solving the cubic equation\n", +"// At 80 bar and 300 K\n", +"deff('[y]=f(V)','y=V^(3)-(b+(R*T_1)/P_1)*V^(2)+(a/P_1)*V-(a*b)/P_1');\n", +"V_1_1=fsolve(0.1,f);\n", +"V_1_2=fsolve(10,f);\n", +"V_1_2=fsolve(100,f);\n", +"// The largest root is considered because of vapour\n", +"V_1 = V_1_1;\n", +"\n", +"U_R_1 = -a/V_1;//[J/mol] - Internal energy\n", +"H_R_1 = P_1*V_1 - R*T_1 - a/V_1;//[J/mol] - Enthalpy\n", +"S_R_1 = R*log((P_1*(V_1-b))/(R*T_1));\n", +"\n", +"// Now let us calculate the residual properties at state 2\n", +"// At 40 bar and 300 K\n", +"deff('[y]=f1(V)','y=V^(3)-(b+(R*T_2)/P_2)*V^(2)+(a/P_2)*V-(a*b)/P_2');\n", +"V_2_1 = fsolve(0.1,f1);\n", +"V_2_2 = fsolve(10,f1);\n", +"V_2_3 = fsolve(100,f1);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root.\n", +"V_2 = V_2_1;\n", +"\n", +"U_R_2 = -a/V_2;//[J/mol] - Internal energy\n", +"H_R_2 = P_2*V_2 - R*T_2 - a/V_2;//[J/mol] - Enthalpy\n", +"S_R_2 = R*log((P_2*(V_2-b))/(R*T_2));\n", +"\n", +"delta_U_R = U_R_2 - U_R_1;//\n", +"delta_H_R = H_R_2 - H_R_1;//\n", +"delta_S_R = S_R_2 - S_R_1;//\n", +"\n", +"delta_U_ig = 0;//[J/mol] - As temperature is constant\n", +"delta_H_ig = 0;//[J/mol] - As temperature is constant\n", +"// delta_S_ig = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);// [J/mol-K]\n", +"// Since T_1 = T_2\n", +"// Therefore\n", +"delta_S_ig = - R*log(P_2/P_1);// [J/mol-K]\n", +"delta_U = delta_U_R + delta_U_ig;//[J/mol]\n", +"delta_H = delta_H_R + delta_H_ig;//[J/mol]\n", +"delta_S = delta_S_R + delta_S_ig;//[J/mol-K]\n", +"\n", +"// Change in exergy is given by\n", +"// delta_phi = phi_1 - phi_2 = U_1 - U_2 + P_0*(V_1 - _V_2) - T_0*(S_1 - S_2)\n", +"delta_phi = - delta_U + P_0*(V_1 - V_2) - T_0*(-delta_S);//[J/mol]\n", +"\n", +"printf(' The change in internal energy is %f J/mol\n',delta_U);\n", +"printf(' The change in enthalpy is %f J/mol\n',delta_H);\n", +"printf(' The change in entropy is %f J/mol-K\n',delta_S);\n", +"printf(' The change in exergy is %f J/mol\n',delta_phi);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.13: Calculation_of_change_in_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.13\n", +"//Page number - 353\n", +"printf('Example - 10.13 and Page number - 353\n\n');\n", +"\n", +"//Given\n", +"T_1 = 500;//[K] - Initial temperature\n", +"P_1 = 30;//[atm] - Initial pressure\n", +"P_1 = P_1*101325;//[Pa]\n", +"P_2 = 1;//[atm] - Final pressure\n", +"P_2 = P_2*101325;//[Pa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// For chlorine\n", +"Tc = 417.2;//[K] - Critical temperature\n", +"Pc = 77.10;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[Pa]\n", +"\n", +"//Redlich Kwong equation of state,\n", +"a = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;// [Pa*m^(6)*K^(1/2)/mol]\n", +"b = (0.08664*R*Tc)/Pc;// [m^(3)/mol]\n", +"\n", +"// The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3)-((R*T)/P)*V^(2)-((b_1^(2))+((b_1*R*T)/P)-(a/(T^(1/2)*P))*V-(a*b)/(T^(1/2)*P)=0\n", +"//Solving the cubic equation\n", +"// At state 1 (500 K, 30 atm)\n", +"deff('[y]=f1(V)','y=V^(3)-((R*T_1)/P_1)*V^(2)-((b^(2))+((b*R*T_1)/P_1)-(a/(T_1^(1/2)*P_1)))*V-(a*b)/(T_1^(1/2)*P_1)');\n", +"V_1=fsolve(1,f1);\n", +"V_2=fsolve(10,f1);\n", +"V_3=fsolve(100,f1);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root,\n", +"V = V_1;//[m^(3)/mol]\n", +"\n", +"// Thus compressibility factor is\n", +"Z = (P_1*V_1)/(R*T_1);//compressibility factor\n", +"\n", +"// The residual enthalpy at state 1 is given by\n", +"H_R_1 = (Z-1)*R*T_1 + ((3*a)/(2*b*T_1^(1/2)))*(log(V/(V+b)));//[J/mol]\n", +" \n", +"// Since chlorine is assumed to behave ideally under the final condition,therefore\n", +"H_R_2 = 0;// Residual enthalpy at state 2\n", +"delta_H_R = H_R_2 - H_R_1;//[J/mol] - Residual enthalpy change\n", +"// and since isothermal conditions are maintained, therfore\n", +"delta_H_ig = 0;// Enthalpy change under ideal condition\n", +"delta_H = delta_H_R + delta_H_ig;//[J/mol]\n", +"\n", +"printf(' The change in enthalpy is given by, delta_H = %f J/mol\n',delta_H);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.14: Calculation_of_final_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.14\n", +"//Page number - 353\n", +"printf('Example - 10.14 and Page number - 353\n\n');\n", +"\n", +"//(1)\n", +"//This part involves proving a relation in which no mathematical components are involved.\n", +"//For prove refer to this example 10.14 on page number 354 of the book.\n", +"printf(' (1).This part involves proving a relation in which no mathematical components are involved.\n');\n", +"printf(' For prove refer to this example 10.14 on page number 354 of the book.\n\n')\n", +"\n", +"//(2)\n", +"//Given\n", +"Vol_1 = 0.1;//[m^(3)] - Initial volume of each compartment\n", +"n_1 = 400;//[mol] - Initial number of moles in compartment 1\n", +"V_1 = Vol_1/n_1;//[m^(3)/mol] - Molar volume at state 1\n", +"T_1 = 294;//[K]\n", +"Vol_2 = 0.2;//[m^(3)] - Final volume of the compartment after removing the partition.\n", +"n_2 = n_1;//[mol] - Number of moles remains the same\n", +"V_2 = Vol_2/n_2;//[m^(3)/mol] - Molar volume at state 2\n", +"\n", +"// For argon\n", +"a = 0.1362;//[Pa-m^(6)/mol^(2)]\n", +"b = 3.215*10^(-5);//[m^(3)/mol]\n", +"Cv_0 = 12.56;//[J/mol-K] - Heat capacity in ideal gas state\n", +"\n", +"// For overall system q = 0, and no work is done, therefore delta_U = 0\n", +"// Therfore from the relation proved in part (1), we have\n", +"T_2 = T_1 + (a/Cv_0)*(1/V_2 - 1/V_1);//[K]\n", +"\n", +"printf(' (2).The final temperatutre is %f K\n',T_2)\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.15: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.15\n", +"//Page number - 354\n", +"printf('Example - 10.15 and Page number - 354\n\n');\n", +"\n", +"//This problem involves proving a relation in which no mathematical components are involved.\n", +"//For prove refer to this example 10.15 on page number 354 of the book.\n", +"printf(' This problem involves proving a relation in which no mathematical components are involved.\n\n');\n", +"printf(' For prove refer to this example 10.15 on page number 354 of the book.')\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.16: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.16\n", +"//Page number - 355\n", +"printf('Example - 10.16 and Page number - 355\n\n');\n", +"\n", +"//This problem involves proving a relation in which no mathematical components are involved.\n", +"//For prove refer to this example 10.16 on page number 355 of the book.\n", +"printf(' This problem involves proving a relation in which no mathematical components are involved.\n\n');\n", +"printf(' For prove refer to this example 10.16 on page number 355 of the book.')\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.17: Determination_of_work_done_and_the_exit_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.17\n", +"//Page number - 356\n", +"printf('Example - 10.17 and Page number - 356\n\n');\n", +"\n", +"//Given\n", +"P_1 = 1*10^(6);//[Pa] - Initial pressure\n", +"T_1 = 200 + 273.15;//[K] - Initial temperature\n", +"P_2 = 8*10^(6);//[Pa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"Y = 1.4;// Index of expansion\n", +"Cp_0 = 29.114;//[J/mol-K]\n", +"// For H20, the van der Walls constants are\n", +"a = 0.55366;//[Pa-m^(6)/mol^(2)]\n", +"b = 3.049*10^(-5);//[m^(3)/mol]\n", +"\n", +"// At state 1 (200 C, 1 MPa)\n", +"// The molar volume of steam following van der Walls equation of state (as reported in the book) is\n", +"V_1 = 3.816*10^(-3);//[m^(3)/mol]\n", +"// And the compressibility factor is \n", +"Z_1 = (P_1*V_1)/(R*T_1);\n", +"\n", +"// Assuming ideal gas behaviour the exit temperature is given by\n", +"T_2 = T_1*(P_2/P_1)^((Y-1)/Y);//[K]\n", +"\n", +"// At 8 MPa and T_2,\n", +"// The molar volume of steam following van der Walls equation of state (as reported in the book) is\n", +"V_2 = 8.41*10^(-4);//[m^(3)/mol]\n", +"// And the compressibility factor is \n", +"Z_2 = (P_2*V_2)/(R*T_2);\n", +"\n", +"// For van der Walls equation of state we know that\n", +"// delta_S_R/R = log(Z_2/Z_1) + log((V_2 - b)/V_2) - log((V_1 - b)/V_1)\n", +"delta_S_R = R*(log(Z_2/Z_1) + log((V_2 - b)/V_2) - log((V_1 - b)/V_1));//[J/mol]\n", +"\n", +"// delta_S_ig = Cp_0*log(T_2/T_1) - R*log(P_2/P_1)\n", +"// The entropy change is therefore\n", +"// delta_S = delta_S_ig + delta_S_R\n", +"// But during an isentropic process the total entropy change is zero\n", +"// Therefore we have to modify the exit temperature so that the entropy change is zero\n", +"\n", +"// Let us assume a temperature, say T = 870 K\n", +"// At 870 K the molar volume of steam following van der Walls equation of state (as reported in the book) is\n", +"// V_3 = 8.57*10^(-4);// [m^(3)/mol]\n", +"// Therefore\n", +"// Z_3 = (P_2*V_3)/(R*T_2);\n", +"// At this temperature,\n", +"// delta_S = Cp_0*log(T/T_1) - R*log(P_2/P_1) + R*(log(Z/Z_1) + R*log((V - b)/V) - R*log((V_1 - b)/V_1))\n", +"\n", +"T = 800;//[K]\n", +"fault=10;\n", +"\n", +"while(fault>0.3)\n", +" // At T and 8 MPa\n", +" deff('[y]=f1(V)','y=V^(3)-(b+(R*T)/P_2)*V^(2)+(a/P_2)*V-(a*b)/P_2');\n", +" V = fsolve(1,f1);\n", +" Z = (P_2*V)/(R*T);\n", +" \n", +" deff('[y]=f1(T)','y = Cp_0*log(T/T_1) - R*log(P_2/P_1) + R*(log(Z/Z_1) + R*(log((V - b)/V)) - R*(log((V_1 - b)/V_1)))');\n", +" T_exit = fsolve(0.1,f1);\n", +" fault=abs(T-T_exit);\n", +" T = T + 0.5;\n", +"end\n", +"Texit = T;\n", +"\n", +"// Now applying the first law to an adiabatic process we get\n", +"// W = - delta_H\n", +"\n", +"// For van der Walls gas the enthalpy change is given by\n", +"delta_H_s = Cp_0*(T_exit - T_1) + (Z - 1)*R*T_exit - a/V - (Z_1-1)*R*T_1 + a/V_1;//[J/mol]\n", +"W = - delta_H_s;//[J/mol]\n", +"\n", +"printf(' (1).The exit temperature is %f K\n',Texit);\n", +"printf(' The work required is given by, W = %f J/mol\n\n',W);\n", +"\n", +"//(2)\n", +"eff = 0.8;// Adiabatic efficiency\n", +"delta_H_a = eff*delta_H_s;//[J/mol] - Actual enthalpy change\n", +"W_2 = - delta_H_a;\n", +"\n", +"// Let us assume a temperature, say\n", +"T_prime= 900;//[K]\n", +"fault1=10;\n", +"\n", +"while(fault1>0.3)\n", +" // At T_prime and 8 MPa\n", +" deff('[y]=f2(V)','y=V^(3)-(b+(R*T_prime)/P_2)*V^(2)+(a/P_2)*V-(a*b)/P_2');\n", +" V_prime=fsolve(1,f2);\n", +" Z_prime = (P_2*V_prime)/(R*T_prime);\n", +" \n", +" deff('[y]=f3(T_prime)','y = Cp_0*(T_prime - T_1) + (Z_prime - 1)*R*T_prime - a/V_prime - 13230.49');\n", +" T_exit1 = fsolve(100,f3);\n", +" fault1=abs(T_prime-T_exit1);\n", +" T_prime = T_prime + 0.2;\n", +"end\n", +"Texit1 = T_prime;\n", +"\n", +"printf(' (2).The exit temperature is %f K\n',Texit1);\n", +"printf(' The work required is given by, W = %f J/mol\n\n',W_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.18: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.18\n", +"//Page number - 358\n", +"printf('Example - 10.18 and Page number - 358\n\n');\n", +"\n", +"//This problem involves proving a relation in which no mathematical components are involved.\n", +"//For prove refer to this example 10.18 on page number 358 of the book.\n", +"printf(' This problem involves proving a relation in which no mathematical components are involved.\n\n');\n", +"printf(' For prove refer to this example 10.18 on page number 358 of the book.')\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.19: Calculation_of_molar_volume_and_fugacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.19\n", +"//Page number - 359\n", +"printf('Example - 10.19 and Page number - 359\n\n');\n", +"\n", +"//Given\n", +"T = 100 + 273.15;//[K] - Temperature\n", +"Tc = 647.1;//[K] - Critical temperature of water\n", +"Pc = 220.55;//[bar] - Critical pressure of water\n", +"Pc = Pc*10^(5);//[Pa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// For van der Walls equation of state\n", +"a = (27*R^(2)*Tc^(2))/(64*Pc);//[Pa-m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3) - (b + (R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"\n", +"// For water vapour at 100 C under saturated conditions pressure is 1 atm, therefore\n", +"P = 1;//[atm]\n", +"P = P*101325;//[Pa]\n", +"\n", +"// At 100 C and 1 atm \n", +"deff('[y]=f(V)','y=V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P');\n", +"V_1 = fsolve(0.1,f);\n", +"V_1 = fsolve(10,f);\n", +"V_1 = fsolve(100,f);\n", +"// The largest root is considered because of molar volume of vapour phase is to determined\n", +"V = V_1;//[m^(3)/mol]\n", +"\n", +"// Now the figacity is given by\n", +"// log(f/P) = log((R*T)/(P*(V-b))) + b/(V-b) - (2*a)/(R*T*V);\n", +"f = P*(exp(log((R*T)/(P*(V-b))) + b/(V-b) - (2*a)/(R*T*V)));//[Pa]\n", +"f = f/101325;//[atm]\n", +"\n", +"printf(' The molar volume is %f m^(3)/mol\n\n',V);\n", +"printf(' The fugacity is %f atm\n\n',f);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.1: EX10_1.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.1\n", +"//Page number - 323\n", +"printf('Example - 10.1 and Page number - 323\n\n');\n", +"\n", +"//This problem involves proving a relation in which no mathematical components are involved.\n", +"//For prove refer to this example 10.1 on page number 323 of the book.\n", +"printf('This problem involves proving a relation in which no mathematical components are involved.\n\n');\n", +"printf('For prove refer to this example 10.1 on page number 323 of the book.')\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.20: Calculation_of_enthalpy_and_entropy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.20\n", +"//Page number - 359\n", +"printf('Example - 10.20 and Page number - 359\n\n');\n", +"\n", +"//Given\n", +"P_1 = 6;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"T_1 = 100 + 273.15;//[T] - Initial temperature\n", +"P_2 = 12;//[bar] - Final pressure\n", +"P_2 = P_2*10^(5);//[Pa]\n", +"T_2 = 500 + 273.15;//[K] - Final temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"Y = 1.126;// Index of expansion\n", +"Cp_0 = (R*Y)/(Y-1);//[J/mol-K]\n", +"\n", +"// For propane\n", +"Tc = 369.8;//[K]\n", +"Pc = 42.48;//[bar]\n", +"Pc = Pc*10^(5);\n", +"w = 0.152;\n", +"\n", +"//(1)\n", +"// For van der Walls equation of state\n", +"a = (27*R^(2)*Tc^(2))/(64*Pc);//[Pa-m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3) - (b + (R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"\n", +"// At state 1 (100 C and 6 bar) \n", +"deff('[y]=f(V)','y=V^(3)-(b+(R*T_1)/P_1)*V^(2)+(a/P_1)*V-(a*b)/P_1');\n", +"V_1_1 = fsolve(1,f);\n", +"V_1_2 = fsolve(10,f);\n", +"V_1_3 = fsolve(100,f);\n", +"// The largest root is considered because of molar volume of vapour phase is to determined\n", +"V_1 = V_1_1;//[m^(3)/mol]\n", +"// Thus compressibility factor is\n", +"Z_1 = (P_1*V_1)/(R*T_1);//compressibility factor\n", +"\n", +"H_R_1 = (Z_1 - 1)*R*T_1 - (a/V_1);// [J/mol]\n", +"S_R_1 = R*log((P_1*(V_1-b))/(R*T_1));// [J/mol-K]\n", +"\n", +"// At state 2 (500 C and 12 bar) \n", +"deff('[y]=f1(V)','y=V^(3)-(b+(R*T_2)/P_2)*V^(2)+(a/P_2)*V-(a*b)/P_2');\n", +"V_2_1 = fsolve(1,f1);\n", +"V_2_2 = fsolve(10,f1);\n", +"V_2_3 = fsolve(100,f1);\n", +"// The largest root is considered because of molar volume of vapour phase is to determined\n", +"V_2 = V_2_1;//[m^(3)/mol]\n", +"// Thus compressibility factor is\n", +"Z_2 = (P_2*V_2)/(R*T_2);//compressibility factor\n", +"\n", +"H_R_2 = (Z_2 - 1)*R*T_2 - (a/V_2);// [J/mol]\n", +"S_R_2 = R*log((P_2*(V_2-b))/(R*T_2));// [J/mol-K]\n", +"\n", +"// Ideal gas entropy change is given by\n", +"delta_S_ig = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);//[J/mol-K]\n", +"// Entropy change is given by\n", +"delta_S = delta_S_ig + (S_R_2 - S_R_1);//[J/mol-k]\n", +"\n", +"// Ideal gas enthalpy change is given by\n", +"delta_H_ig = Cp_0*(T_2 - T_1);//[J/mol]\n", +"// Enthalpy change is given by\n", +"delta_H = delta_H_ig + (H_R_2 - H_R_1);//[J/mol]\n", +"\n", +"printf('(1).The change in enthalpy is %f J/mol\n',delta_H);\n", +"printf(' The change in entropy is %f J/mol-K\n\n',delta_S);\n", +"\n", +"//(2)\n", +"// Virial equation of state\n", +"\n", +"// At state 1 (372.15 K, 6 bar) let us calculate B and dB/dT\n", +"Tr = T_1/Tc;// Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B = ((B_0+(w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]\n", +"dB0_dT = 0.422*1.6*Tc^(1.6)*T_1^(-2.6);// (dB_0/dT) at state 1\n", +"dB1_dT = 0.172*4.2*Tc^(4.2)*T_1^(-5.2);// (dB_1/dT) at state 1\n", +"dB_dT = ((R*Tc)/Pc)*((dB0_dT) + w*(dB1_dT));// (dB/dT) at state 1\n", +"\n", +"H_R_1_2 = B*P_1 - P_1*T_1*dB_dT;//[J/mol] - Residual enthalpy at state 1\n", +"S_R_1_2 = -P_1*(dB_dT);//[J/mol-K] - Residual entropy at state 1\n", +"\n", +"// At state 2 (773.15 K, 12 bar)\n", +"Tr_2 = T_2/Tc;// Reduced temperature\n", +"B_0_2 = 0.083-(0.422/(Tr_2)^(1.6));\n", +"B_1_2 = 0.139-(0.172/(Tr_2)^(4.2));\n", +"\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B_2 = ((B_0_2+(w*B_1_2))*(R*Tc))/Pc;//[m^(3)/mol]\n", +"dB0_dT_2 = 0.422*1.6*Tc^(1.6)*T_2^(-2.6);// (dB_0/dT) at state 1\n", +"dB1_dT_2 = 0.172*4.2*Tc^(4.2)*T_2^(-5.2);// (dB_1/dT) at state 1\n", +"dB_dT_2 = ((R*Tc)/Pc)*((dB0_dT_2) + w*(dB1_dT_2));// (dB/dT) at state 1\n", +"\n", +"H_R_2_2 = B_2*P_2 - P_2*T_2*dB_dT_2;//[J/mol] - Residual enthalpy at state 1\n", +"S_R_2_2 = -P_2*(dB_dT_2);//[J/mol-K] - Residual entropy at state 1\n", +"\n", +"delta_H_2 = delta_H_ig + (H_R_2_2 - H_R_1_2);//[J/mol]\n", +"delta_S_2 = delta_S_ig + (S_R_2_2 - S_R_1_2);//[J/mol]\n", +"\n", +"printf('(2).The change in enthalpy is %f J/mol\n',delta_H_2);\n", +"printf(' The change in entropy is %f J/mol-K\n',delta_S_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.21: Calculation_of_fugacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.21\n", +"//Page number - 362\n", +"printf('Example - 10.21 and Page number - 362\n\n');\n", +"\n", +"//Given\n", +"P = 2.76*10^(6);//[N/m^(2)] - Pressure\n", +"T = 310.93;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// For n-butane\n", +"Tc = 425.18;//[K] - Critical temperature\n", +"Pc = 37.97;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.193;\n", +"den = 0.61;//[g/cm^(3)]\n", +"mol_wt = 58;//[g/mol] - Molecular weight of butane\n", +"\n", +"// log(P_sat) = 15.7374 - 2151.63/(T-36.24)\n", +"P_sat = exp(15.7374 - 2151.63/(T-36.24));//[mm Hg]\n", +"P_sat = (P_sat/760)*101325;//[N/m^(2)]\n", +"\n", +"//(1)\n", +"// Let us determine the second virial coefficient at 310.93 K\n", +"Tr = T/Tc;// Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B = ((B_0+(w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]\n", +"\n", +"// Fugacity under saturated conditions is given by\n", +"// log(f_sat/P_sat) = (B*P_sat)/(R*T)\n", +"f_sat = P_sat*(exp((B*P_sat)/(R*T)));//[N/m^(2)]\n", +"\n", +"// The molar volume is given by\n", +"V_liq = (1/(den*1000))*(mol_wt/1000);//[m^(3)/mol]\n", +"\n", +"f = f_sat*exp(V_liq*(P-P_sat)/(R*T));\n", +"\n", +"printf(' (1).The fugacity of n-butane is %e N/m^(2)\n\n',f);\n", +"\n", +"//(2)\n", +"// For van der Walls equation of state\n", +"a = (27*R^(2)*Tc^(2))/(64*Pc);//[Pa-m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3) - (b + (R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"\n", +"// At 100 C and 1 atm \n", +"deff('[y]=f(V)','y=V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P');\n", +"V_1 = fsolve(0.1,f);\n", +"V_1 = fsolve(10,f);\n", +"V_1 = fsolve(100,f);\n", +"// The above equation has only 1 real root, other two roots are imaginary\n", +"V = V_1;//[m^(3)/mol]\n", +"\n", +"// log(f/P) = log((R*T)/(P*(V-b))) + b/(V-b) -(2*a)/(R*T*V)\n", +"f_2 = P*(exp(log((R*T)/(P*(V-b))) + b/(V-b) -(2*a)/(R*T*V)));\n", +"\n", +"printf(' (2).The fugacity of n-butane is %e N/m^(2)\n\n',f_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.22: Calculation_of_enthalpy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.22\n", +"//Page number - 363\n", +"printf('Example - 10.22 and Page number - 363\n\n');\n", +"\n", +"//Given\n", +"T = 50+273.15;//[K] - Temperature\n", +"P = 25*10^(3);//[Pa] - Pressure\n", +"y1 = 0.5;//[mol] - mole fraction of equimolar mixture\n", +"y2 = 0.5;\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"//For component 1 (methyl ethyl ketone)\n", +"Tc_1 = 535.5;//[K] - Critical temperature\n", +"Pc_1 = 41.5*10^(5);//[N/m^(2)] - Critical pressure\n", +"Vc_1 = 267;//[cm^(3)/mol] - Critical volume\n", +"Zc_1 = 0.249;// Critical compressibility factor\n", +"w_1 = 0.323;// acentric factor\n", +"\n", +"//For component 2 (toluene)\n", +"Tc_2 = 591.8;//[K]\n", +"Pc_2 = 41.06*10^(5);//[N/m^(2)]\n", +"Vc_2 = 316;//[cm^(3)/mol]\n", +"Zc_2 = 0.264;\n", +"w_2 = 0.262;\n", +"\n", +"// For equation of state Z = 1 + B/V\n", +"//For component 1, let us calculate B and dB/dT\n", +"Tr_1 = T/Tc_1;//Reduced temperature\n", +"//At reduced temperature\n", +"B1_0 = 0.083-(0.422/(Tr_1)^(1.6));\n", +"B1_1 = 0.139-(0.172/(Tr_1)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;// [m^(3)/mol-K] \n", +"dB0_dT_1 = 0.422*1.6*Tc_1^(1.6)*T^(-2.6);// [m^(3)/mol-K] - (dB_0/dT)\n", +"dB1_dT_1 = 0.172*4.2*Tc_1^(4.2)*T^(-5.2);// [m^(3)/mol-K] - (dB_1/dT)\n", +"dB_dT_1 = ((R*Tc_1)/Pc_1)*((dB0_dT_1) + w_1*(dB1_dT_1));//[m^(3)/mol-K] - (dB/dT)_\n", +"\n", +"//Similarly for component 2\n", +"Tr_2 = T/Tc_2;//Reduced temperature\n", +"//At reduced temperature Tr_2,\n", +"B2_0 = 0.083 - (0.422/(Tr_2)^(1.6));\n", +"B2_1 = 0.139 - (0.172/(Tr_2)^(4.2));\n", +"B_22 = ((B2_0+(w_2*B2_1))*(R*Tc_2))/Pc_2;//[m^(3)/mol]\n", +"dB0_dT_2 = 0.422*1.6*Tc_2^(1.6)*T^(-2.6);// [m^(3)/mol-K] - (dB_0/dT)\n", +"dB1_dT_2 = 0.172*4.2*Tc_2^(4.2)*T^(-5.2);// [m^(3)/mol-K] - (dB_1/dT)\n", +"dB_dT_2 = ((R*Tc_2)/Pc_2)*((dB0_dT_2) + w_2*(dB1_dT_2));//[m^(3)/mol-K] - (dB/dT)_\n", +"\n", +"//For cross coeffcient, let us calculate B and dB/dT\n", +"Tc_12 = (Tc_1*Tc_2)^(1/2);//[K]\n", +"w_12 = (w_1 + w_2)/2;\n", +"Zc_12 = (Zc_1 + Zc_2)/2;\n", +"Vc_12 = (((Vc_1)^(1/3) + (Vc_2)^(1/3))/2)^(3);//[cm^(3)/mol]\n", +"Vc_12 = Vc_12*10^(-6);//[m^(3)/mol]\n", +"Pc_12 = (Zc_12*R*Tc_12)/Vc_12;//[N/m^(2)]\n", +"\n", +"//Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0+(w_12*B_1)\n", +"//where B_0 and B_1 are to be evaluated at Tr_12\n", +"Tr_12 = T/Tc_12;\n", +"//At reduced temperature Tr_12\n", +"B_0 = 0.083 - (0.422/(Tr_12)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr_12)^(4.2));\n", +"B_12 = ((B_0 + (w_12*B_1))*R*Tc_12)/Pc_12;//[m^(3)/mol]\n", +"dB0_dT_12 = 0.422*1.6*Tc_12^(1.6)*T^(-2.6);// [m^(3)/mol-K] - (dB_0/dT)\n", +"dB1_dT_12 = 0.172*4.2*Tc_12^(4.2)*T^(-5.2);// [m^(3)/mol-K] - (dB_1/dT)\n", +"dB_dT_12 = ((R*Tc_12)/Pc_12)*((dB0_dT_12) + w_12*(dB1_dT_12));//[m^(3)/mol-K] - (dB/dT)_12\n", +"\n", +"//For the mixture\n", +"B = y1^(2)*B_11 + 2*y1*y2*B_12 + y2^(2)*B_22;//[m^(3)/moL]\n", +"\n", +"// The equation of state can be written as\n", +"// V^(2) - ((R*T)/P) - (B*R*T)/P = 0\n", +"// V^(2) - 0.1075*V + 1.737*10^(-4) = 0\n", +"deff('[y]=f(V)','y=V^(2) - 0.1075*V + 1.737*10^(-4)');\n", +"V1 = fsolve(0.1,f);\n", +"V2 = fsolve(1,f);\n", +"// We will consider the root which is near to R*T/P\n", +"V = V1;\n", +"// dB/dT = y_1^(2)*dB_11/dT + y_2^(2)*dB_22/dT + 2*y_1*y_2*dB_12/dT\n", +"dB_dT = y1^(2)*dB_dT_1 + y2^(2)*dB_dT_2 + 2*y1*y2*dB_dT_12;//[m^(3)/mol-K]\n", +"\n", +"// For equation of state Z = 1 + B/V\n", +"H_R = (B*R*T)/V - ((R*T^(2))/V)*dB_dT;//[J/mol]\n", +"\n", +"printf(' (1).The value of H_R for the mixture using virial equation of state is %f J/mol\n\n',H_R);\n", +"\n", +"//(2)\n", +"// For van der Walls equation of state \n", +"a_11 = (27*R^(2)*Tc_1^(2))/(64*Pc_1);//[Pa-m^(6)/mol^(2)]\n", +"a_22 = (27*R^(2)*Tc_2^(2))/(64*Pc_2);//[Pa-m^(6)/mol^(2)]\n", +"a_12 = (a_11*a_22)^(1/2);\n", +"b_1 = (R*Tc_1)/(8*Pc_1);//[m^(3)/mol]\n", +"b_2 = (R*Tc_2)/(8*Pc_2);//[m^(3)/mol]\n", +"\n", +"// For the mixture\n", +"a = y1^(2)*a_11 + y2^(2)*a_22 + 2*y1*y2*a_12;//[Pa-m^(6)/mol^(2)]\n", +"b = y1*b_1 + y2*b_2;//[m^(3)/mol]\n", +"\n", +"// From the cubic form of van der Walls equation of state\n", +"deff('[y]=f1(V)','y=V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P');\n", +"V2_1 = fsolve(0.1,f1);\n", +"V2_2 = fsolve(10,f1);\n", +"V2_3 = fsolve(100,f1);\n", +"// The largest root is considered\n", +"V_2 = V2_1;\n", +"\n", +"// The residual enthalpy is given by\n", +"H_R_2 = P*V_2 - R*T -a/V_2;//[J/mol]\n", +"\n", +"printf(' (2).The value of H_R for the mixture using van der Walls equation of state is %f J/mol\n\n',H_R_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.23: Calculation_of_fugacity_of_water_vapour.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.23\n", +"//Page number - 366\n", +"printf('Example - 10.23 and Page number - 366\n\n');\n", +"\n", +"//Given\n", +"T = 320 + 273.15;//[K]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// For water\n", +"Tc = 647.1;//[K]\n", +"Pc = 220.55;//[bar]\n", +"Pc = Pc*10^(5);//[Pa]\n", +"\n", +"// The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3) - ((R*T)/P)*V^(2) - ((b_1^(2)) + ((b_1*R*T)/P) - (a/(T^(1/2)*P))*V - (a*b)/(T^(1/2)*P) = 0\n", +"\n", +"// At 320 C and 70 bar pressure\n", +"P_1 = 70;//[bar]\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"\n", +"a = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b = (0.08664*R*Tc)/Pc;//[m^(3)/mol]\n", +"// Solving the cubic equation\n", +"deff('[y]=f1(V)','y=V^(3)-((R*T)/P_1)*V^(2)-((b^(2))+((b*R*T)/P_1)-(a/(T^(1/2)*P_1)))*V-(a*b)/(T^(1/2)*P_1)');\n", +"V1=fsolve(1,f1);\n", +"V2=fsolve(10,f1);\n", +"V3=fsolve(100,f1);\n", +"// The largest root is considered because at 320 C and 70 bar vapour phase exists.\n", +"V_1 = V1;//[m^(3)/mol]\n", +"// Thus compressibility factor is\n", +"Z_1 = (P_1*V_1)/(R*T);\n", +"\n", +"// For Redlich-Kwong equation of state\n", +"// log(f/P) = Z - 1 - log(V_1/(V_1-b)) + (a/(b*R*(T^(3/2))))*log(V/(V+b))\n", +"f_1 = P_1*(exp(Z_1-1-log(Z_1)+log(V_1/(V_1-b))+(a/(b*R*(T^(3/2))))*log(V_1/(V_1+b))));//[Pa]\n", +"f_1 = f_1*10^(-5);//[bar]\n", +"\n", +"printf(' The fugacity of water vapour at 320 C and 70 bar pressure is %f bar\n\n',f_1);\n", +"\n", +"// At 320 C and 170 bar pressure, we have\n", +"P_2 = 170;//[bar]\n", +"P_2 = P_2*10^(5);//[Pa]\n", +"\n", +"// Solving the cubic equation\n", +"deff('[y]=f2(V)','y=V^(3)-((R*T)/P_2)*V^(2)-((b^(2))+((b*R*T)/P_2)-(a/(T^(1/2)*P_2)))*V-(a*b)/(T^(1/2)*P_2)');\n", +"V4 = fsolve(1,f2);\n", +"V5 = fsolve(10,f2);\n", +"V6 = fsolve(100,f2);\n", +"// The above equation has only 1 real root,other two roots are imaginary. Therefore,\n", +"V_2 = V6;//[m^(3)/mol]\n", +"// Thus compressibility factor is\n", +"Z_2 = (P_2*V_2)/(R*T);\n", +"\n", +"// For Redlich-Kwong equation of state\n", +"// log(f/P) = Z - 1 - log(V_1/(V_1-b)) + (a/(b*R*(T^(3/2))))*log(V/(V+b))\n", +"f_2 = P_2*(exp(Z_2-1-log(Z_2)+log(V_2/(V_2-b))+(a/(b*R*(T^(3/2))))*log(V_2/(V_2+b))));//[Pa]\n", +"f_2 = f_2*10^(-5);//[bar]\n", +"\n", +"printf(' The fugacity of water vapour at 320 C and 170 bar pressure is %f bar\n\n',f_2);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.24: Determination_of_change_in_internal_energy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.24\n", +"//Page number - 367\n", +"printf('Example - 10.24 and Page number - 367\n\n');\n", +"\n", +"//Given\n", +"Vol = 0.057;//[m^(3)] - Volume of car tyre\n", +"P_1 = 300;//[kPa] - Initial pressure\n", +"P_1 = P_1*10^(3);//[Pa]\n", +"T_1 = 300;//[K] - Initial temperature\n", +"P_2 = 330;//[kPa] - Finnal pressure\n", +"P_2 = P_2*10^(3);//[Pa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"Cv_0 = 21;//[J/mol-K] - Heat capacity for air \n", +"\n", +"// For oxygen\n", +"Tc_O2 = 154.6;//[K] - Critical temperature\n", +"Pc_O2 = 50.43;//[bar] - Critical pressure\n", +"Pc_O2 = Pc_O2*10^(5);//[Pa]\n", +"y1 = 0.21;// - Mole fraction of oxygen\n", +"// For nitrogen\n", +"Tc_N2 = 126.2;//[K] - Critical temperature\n", +"Pc_N2 = 34.00;//[bar] - Critical pressure\n", +"Pc_N2 = Pc_N2*10^(5);//[Pa]\n", +"y2 = 0.79;// - Mole fraction of nitrogen\n", +"\n", +"// (1)\n", +"// Assuming ideal gas behaviour. The volume remains the same,therefore,we get\n", +"// P_1/T_1 = P_2/T_2\n", +"T_2 = P_2*(T_1/P_1);//[K]\n", +"\n", +"n = (P_1*Vol)/(R*T_1);//[mol] - Number of moles\n", +"delta_U = n*Cv_0*(T_2-T_1);//[J]\n", +"\n", +"printf(' (1).The change in internal energy (for ideal gas behaviour) is %f J\n\n',delta_U);\n", +"\n", +"//(2)\n", +"// For van der Walls equation of state \n", +"a_O2 = (27*R^(2)*Tc_O2^(2))/(64*Pc_O2);//[Pa-m^(6)/mol^(2)]\n", +"a_N2 = (27*R^(2)*Tc_N2^(2))/(64*Pc_N2);//[Pa-m^(6)/mol^(2)]\n", +"a_12 = (a_O2*a_N2)^(1/2);\n", +"b_O2 = (R*Tc_O2)/(8*Pc_O2);//[m^(3)/mol]\n", +"b_N2 = (R*Tc_N2)/(8*Pc_N2);//[m^(3)/mol]\n", +"\n", +"// For the mixture\n", +"a = y1^(2)*a_O2 + y2^(2)*a_N2 + 2*y1*y2*a_12;//[Pa-m^(6)/mol^(2)]\n", +"b = y1*b_O2 + y2*b_N2;//[m^(3)/mol]\n", +"\n", +"// From the cubic form of van der Walls equation of state\n", +"// At 300 K and 300 kPa,\n", +"deff('[y]=f1(V)','y=V^(3)-(b+(R*T_1)/P_1)*V^(2)+(a/P_1)*V-(a*b)/P_1');\n", +"V_1 = fsolve(0.1,f1);\n", +"V_2 = fsolve(10,f1);\n", +"V_3 = fsolve(100,f1);\n", +"// The above equation has only 1 real root, other two roots are imaginary\n", +"V = V_1;//[m^(3)/mol]\n", +"\n", +"// Now at P = 330 kPa and at molar volume V\n", +"// The van der Walls equation of state is\n", +"// (P + a/V^(2))*(V - b) = R*T\n", +"T_2_prime = ((P_2 + a/V^(2))*(V - b))/R;//[K]\n", +"n_prime = Vol/V;//[mol]\n", +"\n", +"// Total change in internal energy is given by\n", +"// delta_U_prime = n_prime*delta_U_ig + n_prime*(U_R_2 - U_R_1)\n", +"// delta_U_prime = n_prime*Cv_0*(T_2_prime - T_1) + n_prime*a(1/V_2 - 1/V_1);\n", +"// Since V_1 = V_2 = V, therefore\n", +"delta_U_prime = n_prime*Cv_0*(T_2_prime - T_1);\n", +"\n", +"printf(' (2).The change in internal energy (for van der Walls equation of state) is %f J\n\n',delta_U_prime);\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.25: Calculation_of_enthalpy_and_entropy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.25\n", +"//Page number - 369\n", +"printf('Example - 10.25 and Page number - 369\n\n');\n", +"\n", +"//Given\n", +"T_1 = 150 + 273.15;//[K] - Initial emperature\n", +"T_2 = T_1;// Isothermal process\n", +"P_1 = 100*10^(3);//[Pa] - Initial pressure\n", +"P_2 = 450*10^(3);//[Pa] - Final pressure\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// For water\n", +"Tc = 647.1;//[K] - Critical temperature\n", +"Pc = 220.55;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);\n", +"w = 0.345;\n", +"Mol_wt = 18.015;//[g/mol] - Molecular weight of water\n", +"Cp_0 = 4.18;//[J/mol-K] - Standard heat capacity of water\n", +"\n", +"// Both phases are superheated vapour phases because at 150 C the vapour pressure of steam is 4.67 bar and both operating pressures are below saturated pressure.\n", +"// In Peng-Robinson equation of state\n", +"m = 0.37464 + 1.54226*w - 0.26992*w^(2);\n", +"// At T_1 and P_1, we have\n", +"Tr = T_1/Tc;\n", +"alpha = (1 + m*(1 - Tr^(1/2)))^(2);\n", +"a = ((0.45724*(R*Tc)^(2))/Pc)*alpha;//[Pa*m^(6)/mol^(2)]\n", +"b = (0.07780*R*Tc)/Pc;//[m^(3)/mol]\n", +"\n", +"// Cubuc form of Peng-Robinson equation of stste is given by\n", +"// V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2))/P)-((a*b)/P)=0;\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)+(b-(R*T_1)/P_1)*V^(2)-((3*b^(2))+((2*R*T_1*b)/P_1)-(a/P_1))*V+b^(3)+((R*T_1*(b^(2)))/P_1)-((a*b)/P_1)');\n", +"V1 = fsolve(-1,f);\n", +"V2 = fsolve(0,f);\n", +"V3 = fsolve(1,f);\n", +"//The largest root is for vapour phase,\n", +"//The largest root is only considered as the systemis gas\n", +"V_1 = V3;//[m^(3)/mol]\n", +"// Thus compressibility factor is\n", +"Z_1 = (P_1*V_1)/(R*T_1);\n", +"\n", +"// At T_2 and P_2, we have\n", +"// Cubuc form of Peng-Robinson equation of stste is given by\n", +"// V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2))/P)-((a*b)/P)=0;\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)+(b-(R*T_2)/P_2)*V^(2)-((3*b^(2))+((2*R*T_2*b)/P_2)-(a/P_2))*V+b^(3)+((R*T_2*(b^(2)))/P_2)-((a*b)/P_2)');\n", +"V4 = fsolve(-1,f);\n", +"V5 = fsolve(0,f);\n", +"V6 = fsolve(1,f);\n", +"//The largest root is for vapour phase,\n", +"//The largest root is only considered as the systemis gas\n", +"V_2 = V6;//[m^(3)/mol]\n", +"// Thus compressibility factor is\n", +"Z_2 = (P_2*V_2)/(R*T_2);\n", +"\n", +"// In the Peng-Robinson equation of stste\n", +"// da/dT = -(a*m)/((alpha*T*Tc)^(1/2))\n", +"// The residual enthalpy is given by\n", +"// H_R = R*T*(Z-1) + (((T*(da_dT))-a)/(2*2^(1/2)*b))*log((Z+(1+2^(1/2)*((P*b)/(R*T))))/(Z+(1-2^(1/2)*((P*b)/(R*T)))))\n", +"\n", +"// At state 1\n", +"da_dT_1 = -(a*m)/((alpha*T_1*Tc)^(1/2));//[Pa*m^(6)/mol^(2)]\n", +"H_R_1 = R*T_1*(Z_1-1) + (((T_1*(da_dT_1))-a)/(2*(2^(1/2))*b))*log((Z_1+(1+2^(1/2))*((P_1*b)/(R*T_1)))/(Z_1+(1-2^(1/2))*((P_1*b)/(R*T_1))));\n", +"\n", +"// At state 2\n", +"da_dT_2 = -(a*m)/((alpha*T_2*Tc)^(1/2));//[Pa*m^(6)/mol^(2)]\n", +"H_R_2 = R*T_2*(Z_2-1) + (((T_2*(da_dT_2))-a)/(2*2^(1/2)*b))*log((Z_2+(1+2^(1/2))*((P_2*b)/(R*T_1)))/(Z_2+(1-2^(1/2))*((P_2*b)/(R*T_1))));\n", +"\n", +"\n", +"// Since the temperature is the same,therefore ideal gas change in enthalpy is zero and thus\n", +"delta_H = H_R_2 - H_R_1;;//[J/mol]\n", +"delta_H = delta_H/Mol_wt;//[kJ/kg]\n", +"\n", +"// The residual entropy relation for a substance following Peng - Robinson equation of state ia\n", +"// S_R = R*log(Z - (P*b)/(R*T)) + (da_dT/(2*2^(1/2)*b))*log((Z+(1+2^(1/2))*((P*b)/(R*T)))/(Z+(1-2^(1/2))*((P*b)/(R*T))))\n", +"\n", +"// The residual entropy at state 1 is\n", +"S_R_1 = R*log(Z_1 - (P_1*b)/(R*T_1)) + (da_dT_1/(2*2^(1/2)*b))*log((Z_1+(1+2^(1/2))*((P_1*b)/(R*T_1)))/(Z_1+(1-2^(1/2))*((P_1*b)/(R*T_1))));\n", +"\n", +"// The residual entropy at state 2 is\n", +"S_R_2 = R*log(Z_2 - (P_2*b)/(R*T_2)) + (da_dT_2/(2*2^(1/2)*b))*log((Z_2+(1+2^(1/2))*((P_2*b)/(R*T_2)))/(Z_2+(1-2^(1/2))*((P_2*b)/(R*T_2))));\n", +"\n", +"delta_S_R = S_R_2 - S_R_1;//[J/mol-K]\n", +"\n", +"// The ideal gas change in entropy is\n", +"delta_S_ig = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);//[J/mol-K]\n", +"\n", +"// Therefore\n", +"delta_S = delta_S_R + delta_S_ig;//[J/mol-K]\n", +"\n", +"printf(' The enthalpy change is given by, delta_H = %f kJ/mol\n\n',delta_H);\n", +"printf(' The entropy change is given by, delta_S = %f J/mol-K\n\n',delta_S);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.26: Calculation_of_final_temperature_and_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.26\n", +"//Page number - 370\n", +"printf('Example - 10.26 and Page number - 370\n\n');\n", +"\n", +"//Given\n", +"Vol = 0.15;//[m^(3)]\n", +"T_1 = 170;//[K] - Initial emperature\n", +"P_1 = 100;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// For nitrogen\n", +"Tc = 126.2;//[K] - Critical tempeature\n", +"Pc = 34;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.038;\n", +"// Cp_0 = 27.2+4.2*10^(-3)*T\n", +"\n", +"//(1)\n", +"// For van der Walls equation of state\n", +"a = (27*R^(2)*Tc^(2))/(64*Pc);//[Pa-m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3) - (b + (R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"// On simplification the equation changes to\n", +"// V^(3) - 1.799*10^(4)*V^(2) + 1.366*10^(-8)*V - 5.269*10^(-13) = 0\n", +"\n", +"// Solving the cubic equation \n", +"deff('[y]=f(V)','y=V^(3)-1.799*10^(-4)*V^(2) + 1.366*10^(-8)*V - 5.269*10^(-13)');\n", +"V1 = fsolve(1,f);\n", +"V2 = fsolve(10,f);\n", +"V3 = fsolve(100,f);\n", +"// The above equation has only 1 real root, other two roots are imagimnary\n", +"V_1 = V1;//[m^(3)/mol]\n", +"// Thus total number of moles is given by\n", +"n_1 = Vol/V_1;//[mol]\n", +"\n", +"// After 500 mol are withdrawn, the final number of moles is given by\n", +"n_2 = n_1 - 500;//[mol]\n", +"// Thus molar volume at final state is \n", +"V_2 = Vol/n_2;//[m^(3)/mol]\n", +"\n", +"// The ideal entropy change is guven by\n", +"// delta_S_ig = integrate('27.2+4.2*10^(-3)*T','T',T_1,T_2) - R*log(P_2/P_1);\n", +"// The residual entropy change is given by\n", +"// delta_S_R = R*log((P_2*(V_2-b))/(R*T_2)) - R*log((P_1*(V_1-b))/(R*T_1)) \n", +"// delta_S = delta_S_ig = delta_S_R\n", +"// delta_S = integrate('27.2+4.2*10^(-3)*T','T',T_1,T_2) + R*log((V_2-b)/(V_1-b));\n", +"// During discharging delta_S = 0, thus on simplification we get\n", +"// 18.886*log(T_2) + 4.2*10^(-3)*T_2 - 92.937 = 0\n", +"// Solving the above equation we get\n", +"deff('[y]=f1(T_2)','y=18.886*log(T_2) + 4.2*10^(-3)*T_2 - 92.937');\n", +"T_2 = fsolve(1,f1);\n", +"\n", +"// Thus at T_2, \n", +"P_2 = (R*T_2)/(V_2-b) - a/V_2^(2);//[N/m^(2)]\n", +"P_2 = P_2*10^(-5);//[bar]\n", +"\n", +"printf(' (1).The final temperature is %f K\n',T_2);\n", +"printf(' The final pressure is %f bar\n\n',P_2);\n", +"\n", +"//(2)\n", +"// In Peng-Robinson equation of state\n", +"m = 0.37464 + 1.54226*w - 0.26992*w^(2);\n", +"// At T_1 and P_1, we have\n", +"Tr = T_1/Tc;\n", +"alpha = (1 + m*(1 - Tr^(1/2)))^(2);\n", +"a_2 = ((0.45724*(R*Tc)^(2))/Pc)*alpha;//[Pa*m^(6)/mol^(2)]\n", +"b_2 = (0.07780*R*Tc)/Pc;//[m^(3)/mol]\n", +"\n", +"// Cubuc form of Peng-Robinson equation of stste is given by\n", +"// V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2))/P)-((a*b)/P)=0;\n", +"// Solving the cubic equation\n", +"deff('[y]=f2(V)','y=V^(3)+(b_2-(R*T_1)/P_1)*V^(2)-((3*b_2^(2))+((2*R*T_1*b_2)/P_1)-(a_2/P_1))*V+b_2^(3)+((R*T_1*(b_2^(2)))/P_1)-((a_2*b_2)/P_1)');\n", +"V4 = fsolve(-1,f2);\n", +"V5 = fsolve(0,f2);\n", +"V6 = fsolve(0.006,f2);\n", +"//The above equation has only 1 real root,the other two roots are imaginary\n", +"V_1_2 = V6;//[m^(3)/mol]\n", +"\n", +"// The number of moles in the initial state is given by\n", +"n_1_2 = Vol/V_1_2;//[mol]\n", +"// After 500 mol are withdrawn, the final number of moles is given by\n", +"n_2_2 = n_1_2 - 500;//[mol]\n", +"// Thus molar volume at final state is \n", +"V_2_2 = Vol/n_2_2;//[m^(3)/mol]\n", +"\n", +"// At the final state the relation between pressure and temperature is\n", +"// P_2_2 = (R*T_2_2)/(V_2_2-b_2) - a_2/V_2_2^(2)\n", +"// P_2_2 = 7.23*10^(4)*T_2 - 3.93*10^(7)*a_2\n", +"\n", +"// Now let us calculate the residual entropy at initial state\n", +"Z_1 = (P_1*V_1_2)/(R*T_1);\n", +"da_dT_1 = -(a*m)/((alpha*T_1*Tc)^(1/2));//[Pa*m^(6)/mol^(2)] - da/dT\n", +"\n", +"// The residual entropy change for Peng-Robinson equatiob of state is given by\n", +"// S_R = R*log(Z-(P*b)/(R*T)) + (da_dT/(2*2^(1/2)*b))*log((V+(1+2^(1/2))*b))/((V+(1-2^(1/2)*b))));\n", +"S_R_1 = R*(log(Z_1-(P_1*b_2)/(R*T_1))) + (da_dT_1/(2*2^(1/2)*b_2))*(log((V_1_2+(1+2^(1/2))*b_2)/(V_1_2+(1-2^(1/2))*b_2)));\n", +"\n", +"// The total entropy change is given by\n", +"// delta_S = delta_S_ig + delta_S_R\n", +"// where, delta_S_ig = integrate('27.2+4.2*10^(-3)*T','T',T_1,T_2_2) - R*log(P_2_2/P_1);\n", +"// and, P_2_2 = (R*T_2_2)/(V_2_2-b_2) - a_2/V_2_2^(2)\n", +"// On simplification we get\n", +"// delta_S = 27.2*log(T_2_2-T_1) + 4.2*10^(-3)*(T_2_2-T_1) - R*log(P_2_2/P_1) + R*log(Z_2-(P_2_2*b)/(R*T_2_2)) + 6226*(da_dT_2) + 9.22\n", +"\n", +"// Now we have the determine the value of T_2_2 such that delta_S = 0\n", +"// Starting with a temperature of 150 K\n", +"T_prime = 100;//[K]\n", +"error = 10;\n", +"while(error>0.1)\n", +" Tr_prime = T_prime/Tc;\n", +" alpha_prime = (1 + m*(1 - Tr_prime^(1/2)))^(2);\n", +" a_prime = ((0.45724*(R*Tc)^(2))/Pc)*alpha_prime;\n", +" P_prime = 7.23*10^(4)*T_prime - 3.93*10^(7)*a_prime;\n", +" Z_prime = (P_prime*V_2_2)/(R*T_prime);\n", +" da_dT_prime = -(a_prime*m)/((alpha_prime*T_prime*Tc)^(1/2));\n", +" delta_S = 27.2*log(T_prime/T_1) + 4.2*10^(-3)*(T_prime-T_1) - R*log(P_prime/P_1) + R*log(Z_prime-((P_prime*b_2)/(R*T_prime))) + 6226*(da_dT_prime) + 9.22;\n", +" error=abs(delta_S);\n", +" T_prime = T_prime + 0.3;\n", +"end\n", +"\n", +"T_2_2 = T_prime;//[K] - Final temperature\n", +"P_2_2 = P_prime*10^(-5);//[bar] - Final pressure\n", +"\n", +"printf(' (2).The final temperature is %f K\n',T_2_2);\n", +"printf(' The final pressure is %f bar\n',P_2_2);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.27: Calculation_of_vapour_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.27\n", +"//Page number - 374\n", +"printf('Example - 10.27 and Page number - 374\n\n');\n", +"\n", +"//Given\n", +"T = 373.15;//[K]\n", +"Tc = 562.16;//[K]\n", +"Pc = 48.98;//[bar]\n", +"Pc = Pc*10^(5);//[Pa]\n", +"R = 8.314;//[J/mol-K] - Universal gas constant\n", +"\n", +"// The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3) - ((R*T)/P)*V^(2) - ((b_1^(2)) + ((b_1*R*T)/P) - (a/(T^(1/2)*P))*V - (a*b)/(T^(1/2)*P) = 0\n", +"\n", +"a = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b = (0.08664*R*Tc)/Pc;//[m^(3)/mol]\n", +"\n", +"// At 373.15 K, let us assume the pressure to be 2.5 bar and under these conditions \n", +"P_1 = 2.5;//[bar]\n", +"P_1 = P_1*10^(5);//[bar]\n", +"\n", +"// Putting the values in Redlich Kwong equation of state, the equation becomes\n", +"// V^(3) - 0.0124*V^(2) + 8.326*10^(-6)*V - 7.74*10^(-10) = 0\n", +"// Solving the cubic equation\n", +"\n", +"deff('[y]=f(V)','y=V^(3) - 0.0124*V^(2) + 8.326*10^(-6)*V - 7.74*10^(-10)');\n", +"V1=fsolve(-9,f);\n", +"V2=fsolve(10,f);\n", +"V3=fsolve(0.1,f);\n", +"// The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n", +"V_liq = V1;//[m^(3)/mol] - Molar volume in liquid phase\n", +"V_vap = V3;//[m^(3)/mol] - Molar volume in vapour phase\n", +"\n", +"// Let us calculate the fugacity of vapour phase\n", +"// log(f_vap/P) = b/(V-b) + log((R*T)/(P*(V-b))) - (a/(R*T^(1.5)))*(1/(V+b) - (1/b)*log(V/(V+b)))\n", +"f_vap = P_1*exp(b/(V_vap-b) + log((R*T)/(P_1*(V_vap-b))) - (a/(R*T^(1.5)))*(1/(V_vap+b) - (1/b)*log(V_vap/(V_vap+b))));//[Pa]\n", +"\n", +"// Let us calculate the fugacity of the liquid phase\n", +"f_liq = P_1*exp(b/(V_liq-b) + log((R*T)/(P_1*(V_liq-b))) - (a/(R*T^(1.5)))*(1/(V_liq+b) - (1/b)*log(V_liq/(V_liq+b))));\n", +"\n", +"\n", +"// The two fugacities are not same; therefore another pressure is to be assumed. The new pressure is\n", +"P_new = P_1*(f_liq/f_vap);//[Pa]\n", +"\n", +"// At P_new\n", +"deff('[y]=f1(V)','y=V^(3) - ((R*T)/P_new)*V^(2) - (b^(2) + ((b*R*T)/P_new) - a/(T^(1/2)*P_new))*V - (a*b)/(T^(1/2)*P_new)');\n", +"V4=fsolve(-9,f1);\n", +"V5=fsolve(10,f1);\n", +"V6=fsolve(0.1,f1);\n", +"// The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n", +"V_liq_2 = V4;//[m^(3)/mol] - Molar volume in liquid phase\n", +"V_vap_2 = V6;//[m^(3)/mol] - Molar volume in vapour phase\n", +"\n", +"f_vap_prime = P_new*exp(b/(V_vap_2-b) + log((R*T)/(P_new*(V_vap_2-b))) - (a/(R*T^(1.5)))*(1/(V_vap_2+b) - (1/b)*log(V_vap_2/(V_vap_2+b))));//[Pa]\n", +"f_liq_prime = P_new*exp(b/(V_liq_2-b) + log((R*T)/(P_new*(V_liq_2-b))) - (a/(R*T^(1.5)))*(1/(V_liq_2+b) - (1/b)*log(V_liq_2/(V_liq_2+b))));\n", +"\n", +"// Since the fugacities of liquid and vapour phasesare almost same the assumed pressure may be taken as vapour pressure at 373.15 K\n", +"P_new = P_new*10^(-5);//[bar]\n", +"\n", +"printf(' The vapour pressure of benzene using Redlich Kwong equation of state is %f bar\n',P_new);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.28: Determination_of_vapour_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.28\n", +"//Page number - 374\n", +"printf('Example - 10.28 and Page number - 375\n\n');\n", +"\n", +"//Given\n", +"T = 150 + 273.15;//[K]\n", +"Tc = 647.1;//[K]\n", +"Pc = 220.55;//[bar]\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.345;\n", +"R = 8.314;//[J/mol-K] - Universal gas constant\n", +"\n", +"// Let us assume a pressure of 100 kPa.\n", +"P_1 = 100*10^(3);//[Pa]\n", +"\n", +"// At 100 kPa and 423.15 K, from Peng-Robinson equation of stste \n", +"m = 0.37464 + 1.54226*w - 0.26992*w^(2);\n", +"Tr = T/Tc;\n", +"alpha = (1 + m*(1 - Tr^(1/2)))^(2);\n", +"a = ((0.45724*(R*Tc)^(2))/Pc)*alpha;//[Pa*m^(6)/mol^(2)]\n", +"b = (0.07780*R*Tc)/Pc;//[m^(3)/mol]\n", +"// Cubic form of Peng-Robinson equation of stste is given by\n", +"// V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2))/P)-((a*b)/P)=0;\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)+(b-(R*T)/P_1)*V^(2)-((3*b^(2))+((2*R*T*b)/P_1)-(a/P_1))*V+b^(3)+((R*T*(b^(2)))/P_1)-((a*b)/P_1)');\n", +"V1 = fsolve(-1,f);\n", +"V2 = fsolve(0,f);\n", +"V3 = fsolve(1,f);\n", +"// The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n", +"V_liq = V1;//[m^(3)/mol] - Molar volume in liquid phase\n", +"V_vap = V3;//[m^(3)/mol] - Molar volume in vapour phase\n", +"\n", +"// The compressibility factor is given by\n", +"Z_vap = (P_1*V_vap)/(R*T);// For liquid phase\n", +"Z_liq = (P_1*V_liq)/(R*T);// For vapour phase\n", +"\n", +"// The expression for fugacity of Peng Robinson equation is\n", +"// log(f/P) = (Z-1) - log(Z-((P*b)/(R*T))) - (a/(2*2^(1/2)*b*R*T))*log((Z+(1+2^(1/2))*((P*b)/(R*T)))/((Z+(1-2^(1/2))*((P*b)/(R*T)))\n", +"// For vapour phase\n", +"f_P_vap = exp((Z_vap-1) - log(Z_vap-((P_1*b)/(R*T))) - (a/(2*2^(1/2)*b*R*T))*log((Z_vap+(1+2^(1/2))*((P_1*b)/(R*T)))/(Z_vap+(1-2^(1/2))*((P_1*b)/(R*T)))));\n", +"// For liquid phase\n", +"f_P_liq = exp((Z_liq-1) - log(Z_liq-((P_1*b)/(R*T))) - (a/(2*2^(1/2)*b*R*T))*log((Z_liq+(1+2^(1/2))*((P_1*b)/(R*T)))/(Z_liq+(1-2^(1/2))*((P_1*b)/(R*T)))));\n", +"\n", +"// Therefore f_liq/f_vap can be calculated as\n", +"fL_fV = (f_P_liq/f_P_vap);\n", +"\n", +"// The two values (f/P)_vap and (f/P)_vap are not same [ (f_P_liq/f_P_vap) >1 ]; therefore another pressure is to be assumed. The new pressure be\n", +"P_new = P_1*(f_P_liq/f_P_vap);//[Pa]\n", +"\n", +"// At P_new and 423.15 K, from Peng-Robinson equation of stste \n", +"\n", +"// V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2))/P)-((a*b)/P)=0;\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)+(b-(R*T)/P_new)*V^(2)-((3*b^(2))+((2*R*T*b)/P_new)-(a/P_new))*V+b^(3)+((R*T*(b^(2)))/P_new)-((a*b)/P_new)');\n", +"V4 = fsolve(-1,f);\n", +"V5 = fsolve(0,f);\n", +"V6 = fsolve(1,f);\n", +"// The largest root and the smallest root is considered for liquid phase and vapour phase respectively.\n", +"V_liq_2 = V4;//[m^(3)/mol] - Molar volume in liquid phase\n", +"V_vap_2 = V6;//[m^(3)/mol] - Molar volume in vapour phase\n", +"\n", +"// The compressibility factor is given by\n", +"Z_vap_2 = (P_new*V_vap_2)/(R*T);// For liquid phase\n", +"Z_liq_2 = (P_new*V_liq_2)/(R*T);// For vapour phase\n", +"\n", +"// For vapour phase\n", +"f_P_vap_2 = exp((Z_vap_2-1) - log(Z_vap_2-((P_new*b)/(R*T))) - (a/(2*2^(1/2)*b*R*T))*log((Z_vap_2+(1+2^(1/2))*((P_new*b)/(R*T)))/(Z_vap_2+(1-2^(1/2))*((P_new*b)/(R*T)))));\n", +"// For liquid phase\n", +"f_P_liq_2 = exp((Z_liq_2-1) - log(Z_liq_2-((P_new*b)/(R*T))) - (a/(2*2^(1/2)*b*R*T))*log((Z_liq_2+(1+2^(1/2))*((P_new*b)/(R*T)))/(Z_liq_2+(1-2^(1/2))*((P_new*b)/(R*T)))));\n", +"\n", +"// Therefore f_liq/f_vap can be calculated as\n", +"fL_fV_2 = (f_P_liq_2/f_P_vap_2);\n", +"\n", +"// And new pressure is given by\n", +"P_new_prime = P_new*(f_P_liq_2/f_P_vap_2);//[Pa]\n", +"P_new_prime = P_new_prime*10^(-5);\n", +"\n", +"// Since the change in pressure is small, so we can take this to be the vapour pressure at 150 C\n", +"\n", +"printf(' The vapour pressure of water using Peng-Robinson equation of stste is %f bar\n',P_new_prime);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.2: Preparation_of_fugacity_and_fugacity_coefficient.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.2\n", +"//Page number - 334\n", +"printf('Example - 10.2 and Page number - 334\n\n');\n", +"\n", +"// Given\n", +"T = 40 + 273.15;//[C] - Temperature\n", +"P_1 = 0;//[bar]\n", +"P_2 = 10;//[bar]\n", +"V_liq = 90.45;//[cm^(3)/mol]\n", +"V_liq = V_liq*10^(-6);//[m^(3)/mol]\n", +"P_sat = 4.287;//[bar] \n", +"\n", +"// For butadiene\n", +"T_c = 425.0;//[K] - Critical temperature\n", +"P_c = 43.3;//[bar] - Critical pressure\n", +"P_c = P_c*10^(5);//[N/m^(2)]\n", +"w = 0.195;// Acentric factor\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// Let us calculate second virial coefficient at 40 C\n", +"Tr = T/T_c;// Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B = ((B_0 + (w*B_1))*(R*T_c))/P_c;//[m^(3)/mol] - Second virial coefficient\n", +"\n", +"// log(f/P) = (B*P)/(R*T)\n", +"// f = P*exp((B*P)/(R*T))\n", +"\n", +"printf(' The table is as follows\n\n')\n", +"printf(' P(bar) \t\t f(bar) \t\t phi\n');\n", +"\n", +"P = [1,2,3,4,4.287,5,6,8,10];\n", +"f = zeros(9);\n", +"phi = zeros(9);\n", +"for i=1:5;\n", +" f(i)=P(i)*(exp((B*P(i)*10^(5))/(R*T)));//[bar] // Pressure inside the exponential term has to be in N/m^(2)\n", +" phi(i)= (f(i)/P(i));\n", +" printf(' %f \t %f \t\t\t %f\n',P(i),f(i),phi(i));\n", +"end\n", +"f_sat = f(5);\n", +"\n", +"// From pressure of 4.287 bar onwards the valid equation to compute fugacity of compressed liquid is given by\n", +"// f = f_sat*exp[V_liq*(P-P_sat)/(R*T)]\n", +"\n", +"for j=6:9\n", +" f(j) = f_sat*exp((V_liq*(P(j)-P_sat)*10^(5))/(R*T));//[bar] // Pressure inside the exponential term has to be in N/m^(2)\n", +" phi(j) = f(j)/P(j); \n", +" printf(' %f \t %f \t\t\t %f\n',P(j),f(j),phi(j));\n", +"end\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.3: Calculation_of_enthalpy_entropy_and_internal_energy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.3\n", +"//Page number - 334\n", +"printf('Example - 10.3 and Page number - 334\n\n');\n", +"\n", +"//Given\n", +"n = 100;//[mol] - No of moles\n", +"T_1 = 600;//[K] - Initial temperature\n", +"T_2 = 300;//[K] - Final temperature\n", +"P_1 = 10;//[atm] - Initial pressure\n", +"P_1 = P_1*101325;//[Pa]\n", +"P_2 = 5;//[atm] - Final presssure\n", +"P_2 = P_2*101325;//[Pa]\n", +"Tc = 369.8;//[K] - Critical temperature\n", +"Pc = 42.48;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.152;\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// At 600 K\n", +"Tr = T_1/Tc;// Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B = ((B_0 + (w*B_1))*(R*Tc))/Pc;//[m^(3)/mol] - Second virial coefficient\n", +"dB0_dT = 0.422*1.6*Tc^(1.6)*T_1^(-2.6);// (dB_0/dT)\n", +"dB1_dT = 0.172*4.2*Tc^(4.2)*T_1^(-5.2);// (dB_1/dT)\n", +"dB_dT = ((R*Tc)/(Pc))*(dB0_dT + w*dB1_dT);// dB/dT\n", +"\n", +"// Now let us calculate B and dB/dT at 300 K\n", +"Tr_prime = T_2/Tc;// Reduced temperature\n", +"B_0_prime = 0.083-(0.422/(Tr_prime)^(1.6));\n", +"B_1_prime = 0.139-(0.172/(Tr_prime)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B_prime = ((B_0_prime + (w*B_1_prime))*(R*Tc))/Pc;//[m^(3)/mol] - Second virial coefficient\n", +"dB0_dT_prime = 0.422*1.6*Tc^(1.6)*T_2^(-2.6);// (dB_0/dT)\n", +"dB1_dT_prime = 0.172*4.2*Tc^(4.2)*T_2^(-5.2);// (dB_1/dT)\n", +"dB_dT_prime = ((R*Tc)/(Pc))*(dB0_dT_prime + w*dB1_dT_prime);// dB/dT\n", +"\n", +"// The change in enthalpy for ideal gas is given by\n", +"delta_H_ig = integrate('-0.966+7.279*10^(-2)*T-3.755*10^(-5)*T^(2)+7.58*10^(-9)*T^(3)','T',T_1,T_2);//[cal/mol]\n", +"delta_H_ig = delta_H_ig*4.184;//[J/mol]\n", +"\n", +"// We know that delta_H_ig = delta_U_ig + R*delta_T. Therefore change in internal energy is given by \n", +"delta_U_ig = delta_H_ig - R*(T_2 - T_1);//[J/mol]\n", +"\n", +"// The change in entropy of ideal gas is given by \n", +"//delta_S_ig = integrate('Cp_0/T','T',T_1,T_2) - R*log(P_2/P_1);\n", +"delta_S_ig = integrate('(-0.966+7.279*10^(-2)*T-3.755*10^(-5)*T^(2)+7.58*10^(-9)*T^(3))/T','T',T_1,T_2)*4.184 - R*log(P_2/P_1);// [J/mol-K]\n", +"\n", +"// Now let us calculate the change in enthalpy of gas. We know that\n", +"// delta_H = delta_H_ig + delta_H_R\n", +"// delta_H_R = H_2_R - H_1_R\n", +"H_2_R = B_prime*P_2 - P_2*T_2*dB_dT_prime;// [J/mol]\n", +"H_1_R = B*P_1 - P_1*T_1*dB_dT;// [J/mol]\n", +"delta_H_R = H_2_R - H_1_R;// [J/mol]\n", +"delta_H = delta_H_ig + delta_H_R;// [J/mol]\n", +"\n", +"// Let us calculate the residual entropy of gas\n", +"S_2_R = -P_2*dB_dT_prime;//[J/mol-K]\n", +"S_1_R = -P_1*dB_dT;//[J/mol-K]\n", +"delta_S = delta_S_ig + (S_2_R - S_1_R);//[J/mol-K]\n", +"\n", +"// Let us calculate the residual internal energy of gas\n", +"U_2_R = -P_2*T_2*dB_dT_prime;//[J/mol-K]\n", +"U_1_R = -P_1*T_1*dB_dT;//[J/mol-K]\n", +"delta_U = delta_U_ig + (U_2_R - U_1_R);//[J/mol-K]\n", +"\n", +"// For 100 mol sample,\n", +"delta_H_ig = delta_H_ig*n*10^(-3);//[kJ/mol]\n", +"delta_H = delta_H*n*10^(-3);//[kJ/mol]\n", +"\n", +"delta_U_ig = delta_U_ig*n*10^(-3);//[kJ/mol]\n", +"delta_U = delta_U*n*10^(-3);//[kJ/mol]\n", +"\n", +"delta_S_ig = delta_S_ig*n*10^(-3);//[kJ/mol]\n", +"delta_S = delta_S*n*10^(-3);//[kJ/mol]\n", +"\n", +"printf(' The value of delta_H = %f kJ/mol\n',delta_H);\n", +"printf(' The value of delta_H_ig (ideal gas)= %f kJ/mol\n\n',delta_H_ig);\n", +"printf(' The value of delta_U = %f kJ/mol\n',delta_U);\n", +"printf(' The value of delta_U_ig (ideal gas) = %f kJ/mol\n\n',delta_U_ig);\n", +"printf(' The value of delta_S = %f kJ/mol\n',delta_S);\n", +"printf(' The value of delta_S_ig (ideal gas) = %f kJ/mol\n\n',delta_S_ig);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.4: Calculation_of_molar_heat_capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.4\n", +"//Page number - 337\n", +"printf('Example - 10.4 and Page number - 337\n\n');\n", +"\n", +"// Given\n", +"T = 35 + 273.15;//[K] - Temperature\n", +"P = 10;//[atm] - Pressure\n", +"P = P*101325;//[Pa]\n", +"// Methane obeys the equation of state\n", +"// Z = 1 + (P*B)/(R*T)\n", +"\n", +"// At 35 C,\n", +"B = -50;//[cm^(3)/mol]\n", +"dB_dT = 1.0;//[cm^(3)/mol-K] - dB/dT\n", +"dB_dT = dB_dT*10^(-6);//[m^(3)/mol-K]\n", +"d2B_dT2 = -0.01;//[cm^(3)/mol-K^(2)] - d^2(B)/d(T^2)\n", +"d2B_dT2 = d2B_dT2*10^(-6);//[m^(3)/mol-K^(2)]\n", +"\n", +"// Ideal gas molar heat capacity of methane is given by\n", +"// Cp_0 = 4.75 + 1.2*10^(-2)*T + 0.303*10^(-5)*T^(2) - 2.63*10^(-9)*T^(3)\n", +"\n", +"// The molar heat capacity is given by\n", +"// Cp = Cp_0 + Cp_R\n", +"// For virial gas equation of state \n", +"Cp_R = -P*T*d2B_dT2;//[J/mol-K]\n", +"\n", +"// thus heat capacity is given by \n", +"// Cp = a + b*T + c*T^(2) + d*T^(3) - P*T*d2B_dT2\n", +"// Putting the values, we get\n", +"Cp = (4.75 + 1.2*10^(-2)*T + 0.303*10^(-5)*T^(2) - 2.63*10^(-9)*T^(3))*4.184 - P*T*d2B_dT2;//[J/mol-K]\n", +"\n", +"printf(' The molar heat capacity of methane is %f J/mol-K\n',Cp);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.5: Calculation_of_final_temperature_after_expansion.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.5\n", +"//Page number - 338\n", +"printf('Example - 10.5 and Page number - 338\n\n');\n", +"\n", +"//Given\n", +"T_1 = 360;//[K] - Initial temperature\n", +"P_1 = 10;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"Tc = 408.1;//[K] - Critical temperature\n", +"Pc = 36.48;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.181;\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"Cv_0 = 106.0;//[J/mol-K]\n", +"\n", +"// At 360 K\n", +"Tr = T_1/Tc;// Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B = ((B_0 + (w*B_1))*(R*Tc))/Pc;//[m^(3)/mol] - Second virial coefficient\n", +"dB0_dT = 0.422*1.6*Tc^(1.6)*T_1^(-2.6);// (dB_0/dT)\n", +"dB1_dT = 0.172*4.2*Tc^(4.2)*T_1^(-5.2);// (dB_1/dT)\n", +"dB_dT = ((R*Tc)/(Pc))*(dB0_dT + w*dB1_dT);// dB/dT\n", +"\n", +"// Since system is adiabatic therefore no heat exchange will take place , q = 0\n", +"// and expansion takes place into vacuum,threfore W = 0\n", +"// From first law delta_U = 0. If the gas would have followed ideal gas equation of state the final temperature would have been the same as initial as delta_U = 0\n", +"// But for real gases\n", +"// delta_U = delta_U_ig + delta_U_R\n", +"// delta_U = delta_U_ig + U_2_R - U_1_R\n", +"// For equation of state Z = 1 + (B*P)/(R*T)\n", +"// V = B + (R*T)/P\n", +"// U_R = -P*T*(dB/dT)\n", +"\n", +"// delta_U_ig = Cv_0*(T_2 - T_1)\n", +"// delta_U = Cv_0*(T_2 - T_1) - P_2*T_2*(dB/dT)_2 + P_1*T_1*(dB/dT)_1\n", +"\n", +"// At state 1\n", +"V_1 = B + (R*T_1)/P_1;//[m^(3)/mol] - Molar volume\n", +"// At state 1\n", +"V_2 = 10*V_1;//[m^(3)/mol] - Molar volume\n", +"\n", +"// From the equation delta_U = 0\n", +"// Cv_0*(T_2 - T_1) - ((R*T_2)/(V_2 - B_2))*T_2*(dB/dT)_2 + P_1*T_1*(dB/dT)_1 = 0\n", +"\n", +"// Now we need to solve the above equation to get the value of T_2\n", +"// In above equation the magnitude of second term is much smaller as compared to the third term because the molar volume has become 10 times\n", +"// So neglecting second term, we have\n", +"// Cv_0*(T_2 - T_1) + P_1*T_1*(dB/dT)_1 = 0\n", +"T_2 = -(P_1*T_1*(dB_dT))/Cv_0 + T_1;//[K]\n", +"\n", +"// For exact calculation of final temperature, let us start with a temperature, say\n", +"T = 350;\n", +"\n", +"fault = 10;\n", +"while(fault>0.007)\n", +" Tr_prime = T/Tc;// Reduced temperature\n", +" B_0_prime = 0.083-(0.422/(Tr_prime)^(1.6));\n", +" B_1_prime = 0.139-(0.172/(Tr_prime)^(4.2));\n", +" //We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +" B_prime = ((B_0_prime + (w*B_1_prime))*(R*Tc))/Pc;//[m^(3)/mol] - Second virial coefficient\n", +" dB0_dT_prime = 0.422*1.6*Tc^(1.6)*T_2^(-2.6);// (dB_0/dT)\n", +" dB1_dT_prime = 0.172*4.2*Tc^(4.2)*T_2^(-5.2);// (dB_1/dT)\n", +" dB_dT_prime = ((R*Tc)/(Pc))*(dB0_dT_prime + w*dB1_dT_prime);// dB/dT\n", +" deff('[y]=f(T)','y= 106*(T-T_1)+972.72-((R*T^(2))/(V_2-B_prime))*dB_dT_prime');\n", +" T_prime = fsolve(0.15,f);\n", +" fault=abs(T-T_prime);\n", +" T = T + 0.001;\n", +"end\n", +"\n", +"printf(' The final temperature is %f K\n',T);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.6: Calculation_of_fugacity_of_liquid_benzene.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.6\n", +"//Page number - 339\n", +"printf('Example - 10.6 and Page number - 339\n\n');\n", +"\n", +"//Given\n", +"T = 220 + 273.15;//[K] - Temperature\n", +"Tc = 562.2;//[K] - Critical temperature\n", +"Pc = 48.98;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[Pa]\n", +"w = 0.210;\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"P_sat = 1912.86;//[kPa] - Saturation pressure at 220 C\n", +"P_sat = P_sat*10^(3);//[Pa]\n", +"Mol_wt = 78.114;//[g/mol] - Molecular weight of benzene\n", +"\n", +"//(1)\n", +"// Since liquid and vapour are in equilibrium the fugacity is saturated fugacity (f_sat) and can be calculated using virial gas equation of state\n", +"// At 220 C\n", +"Tr = T/Tc;// Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0 + (w*B_1)\n", +"B = ((B_0 + (w*B_1))*(R*Tc))/Pc;//[m^(3)/mol] - Second virial coefficient\n", +"\n", +"// We know that log(f/P) = (B*P)/(R*T)\n", +"// Thus at saturated conditions\n", +"// log(f_sat/P_sat) = B*P_sat/(R*T)\n", +"f_sat = P_sat*(exp((B*P_sat)/(R*T)));//[Pa]\n", +"f_sat = f_sat*10^(-3);//[kPa]\n", +"\n", +"printf(' (1).The fugacity of liquid benzene is %f kPa\n\n',f_sat);\n", +"\n", +"//(2)\n", +"P = 2014.7;// [psia] - Total gauge pressure\n", +"P = 138.94;// [bar]\n", +"P = P*10^(5);// [Pa]\n", +"den = 0.63;// [g/cm^(3)] - density of benzene\n", +"den = den*10^(3);// [kg/m^(3)]\n", +"\n", +"// Therefore specific volume is \n", +"V = 1/den;//[m/^(3)/kg]\n", +"// Molar volume is given by\n", +"V = V*Mol_wt*10^(-3);//[m^(3)/mol]\n", +"\n", +"// Thus fugacity at 220 C and pressure P is given by \n", +"f = f_sat*(exp((V*(P-P_sat))/(R*T)));\n", +"\n", +"printf(' (2).The fugacity of liquid benzene is %f kPa\n\n',f);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.7: Calculation_of_molar_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.7\n", +"//Page number - 341\n", +"printf('Example - 10.7 and Page number - 341\n\n');\n", +"\n", +"//Given\n", +"// C = -0.067 + 30.7/T\n", +"// D = 0.0012 - 0.416/T\n", +"\n", +"T = 80 + 273.15;//[K]\n", +"P = 30;//[bar]\n", +"//P = P;//[N/m^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// We have the relation derived in the book\n", +"// d(G/(R*T)) = (V/(R*T))dP - (H/(R*T^(2)))dT\n", +"// Writing the same equation for ideal gas and subtracting it from the above equation we get\n", +"// d(G_R/(R*T)) = (V_R/(R*T))dP - (H_R/(R*T^(2)))dT\n", +"// Therefore, H_R/(R*T^(2)) = -[del((G_R)/(R*T))/del(T)]_P\n", +"\n", +"// Substituting the relation G_R/(R*T) = log(f/P), we get\n", +"// H_R/(R*T^(2)) = -[del(log(f/P))/del(T)]_P = -[del(-C*P - D*P^(2))/del(T)]_P\n", +"// or, H_R/(R*T^(2)) = P*(dC/dT) + P^(2)*dD/dT\n", +"// Note that in the above equation the partial derivative is replaced by full derivative as C and D are functions of temperature. Therfore we get\n", +"// H_R/(R*T^(2)) = (30.7*P)/T^(2) + (0.416*P^(2))/T^(2)\n", +"// H_R/R = - 30.7*P + 0.416*P^(2)\n", +"\n", +"// Substituting the given conditions we get\n", +"H_R = R*(-30.7*P + 0.416*P^(2));//[J/mol]\n", +"\n", +"printf(' The molar enthalpy of the gas relative to that of the ideal gas at 80 C and 30 bar pressure is, H_R = %f J/mol\n',H_R);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.8: Determination_of_second_and_third_virial_coefficients_and_fugacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 10.8\n", +"//Page number - 341\n", +"printf('Example - 10.8 and Page number - 341\n\n');\n", +"\n", +"//Given\n", +"// (1)\n", +"T = 311;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// Pressure in 'bar' is given below\n", +"P = [0.690,1.380,2.760,5.520,8.280,11.034,13.800,16.550];\n", +"// Molar volume in 'm^(3)/mol' is given below\n", +"V = [0.0373,0.0186,0.00923,0.00455,0.00298,0.00220,0.00175,0.00144];\n", +"\n", +"// Z = 1 + (B/V) + (C/V^(2))\n", +"// (Z-1)*V = B + (C/V)\n", +"\n", +"\n", +"Z=zeros(8);\n", +"k=zeros(8);\n", +"t=zeros(8);\n", +"for i=1:8;\n", +" Z(i)=(P(i)*10^(5)*V(i))/(R*T);\n", +" k(i)=(Z(i)-1)*V(i);\n", +" t(i)=1/V(i);\n", +"end\n", +"[C,B,sig]=reglin(t',k');\n", +"\n", +"//From the regression, we get intercept = B and slope = C,and thus,\n", +"\n", +"printf(' (1).The second virial coefficient of CO2 is given by B = %e m^(3)/mol\n',B);\n", +"printf(' The thied virial coefficient of CO2 is given by C = %e m^(6)/mol^(2)\n\n',C);\n", +"\n", +"// (2)\n", +"P_final = 13.8;//[bar]\n", +"// We know that R*T*log(f/P) = integrate('V-(R*T)/P','P',0,P)\n", +"// Therefore we have to plot V - (R*T)/P versus P and calculate the area beneath the curve from 0 to 13.8 bar\n", +"// For this we need the value of the term V - (R*T)/P at P = 0. At low pressure the virial equation becomes\n", +"// Z = 1 + (B/V)\n", +"//and V - (R*T)/P = (Z*R*T)/P - (R*T)/P = (1 + (B/V))*((R*T)/P) - (R*T)/P = (B*R*T)/(P*V) = (B/Z)\n", +"// Thus lim P tending to zero (V - (R*T)/P) = B ( as P tend to zero, Z tend to 1 ) \n", +"\n", +"P_prime = [0.000,0.690,1.380,2.760,5.520,8.280,11.034,13.800];\n", +"V_prime = [0.000,0.0373,0.0186,0.00923,0.00455,0.00298,0.00220,0.00175];\n", +"summation = 0;\n", +"x=zeros(8);\n", +"y=zeros(8);\n", +"z=zeros(8);\n", +"for j=2:8;\n", +" x(j)=V_prime(j)-(R*T)/(P_prime(j)*10^(5));//[m^(3)/mol]\n", +" y(j)=(x(j) + x(j-1))/2;\n", +" z(j)=y(j)*((P_prime(j)-P_prime(j-1)))*10^(5);\n", +" summation = summation + z(j) ;//[J/mol]\n", +"end\n", +"\n", +"summation = summation + 2*z(2) - z(2);// Because in the above calculation,in order to calculate the average a summation of z(2) is not included,only half of it gets added\n", +"\n", +"// Now we have, area = integrate('V - (R*T)/P','P',0,13.8*10^(5)) = summatiom\n", +"// R*T*log(f/P) = summation\n", +"f = P_final*(exp(summation/(R*T)));//[bar]\n", +"\n", +"printf(' (2).The fugacity of steam at 311 K and 13.8 bar pressure is %f bar',f);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 10.9: Determination_of_second_and_third_virial_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 10.9\n", +"//Page number - 344\n", +"printf('Example - 10.9 and Page number - 344\n\n');\n", +"\n", +"//Given\n", +"T = 0 + 273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// Pressure in 'atm' is given below\n", +"P = [100,200,300,400,500,600,700,800,900,1000];\n", +"// The compressibility factor values are\n", +"Z = [1.069,1.138,1.209,1.283,1.356,1.431,1.504,1.577,1.649,1.720];\n", +"\n", +"// Z = 1 + (B/V) + (C/V^(2))\n", +"// (Z-1)*V = B + (C/V)\n", +"\n", +"\n", +"V = zeros(1,10);\n", +"k = zeros(1,10);\n", +"t = zeros(1,10);\n", +"for i=1:10;\n", +" V(1,i)=Z(i)*R*T/(P(i)*101325);//[m^(3)/mol]\n", +" k(1,i)=(Z(i)-1)*V(i);\n", +" t(1,i)=1/V(i);\n", +"end\n", +"[C,B,sig]=reglin(t,k);\n", +"\n", +"//From the regression, we get intercept = B and slope = C,and thus,\n", +"\n", +"printf(' (1).The second virial coefficient of H2 is given by B = %e m^(3)/mol\n',B);\n", +"printf(' The thied virial coefficient of H2 is given by C = %e m^(6)/mol^(2)\n\n',C);\n", +"\n", +"// (2)\n", +"// We know that, limit P tending to zero (V-(R*T)/P) = B, therfore P = 0, V-(R*T)/P = B\n", +"// Now let us tabulate V-(R*T)/P and determine the integral integrate('(V-(R*T)/P)','P',0,1000)\n", +"\n", +"P_prime = [0,100,200,300,400,500,600,700,800,900,1000];\n", +"Z_prime = [0,1.069,1.138,1.209,1.283,1.356,1.431,1.504,1.577,1.649,1.720];\n", +"\n", +"summation = 0;\n", +"V_prime = zeros(1,11);\n", +"x = zeros(1,11);\n", +"y = zeros(1,11);\n", +"z = zeros(1,11);\n", +"for j=2:11;\n", +" V_prime(1,j)=Z_prime(j)*R*T/(P_prime(j)*101325);//[m^(3)/mol]\n", +" x(1,j)=V_prime(j)-(R*T)/(P_prime(j)*101325);\n", +" y(1,j)=(x(j) + x(j-1))/2;\n", +" z(1,j)=y(j)*((P_prime(j)-P_prime(j-1)))*101325;\n", +" summation = summation + z(j) ;//[J/mol]\n", +"end\n", +"\n", +"summation = summation + 2*z(2) - z(2);// Because in the above calculation,in order to calculate the average a summation of z(2) is not included,only half of it gets added\n", +"\n", +"// Now we have\n", +"// R*T*log(f/P) = summation\n", +"P_dash = 1000;//[atm] - Pressure at which fugacity is to be calculated\n", +"T_dash = 273.15;//[K] - Temperature at which fugacity is to be calculated\n", +"f = P_dash*exp(summation/(R*T_dash));//[atm] \n", +"\n", +"printf(' (2).The fugacity of H2 at 0 C and 1000 atm pressure is, f = %f atm\n',f);\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/11-Properties_of_a_Component_in_a_Mixture.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/11-Properties_of_a_Component_in_a_Mixture.ipynb new file mode 100644 index 0000000..724a915 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/11-Properties_of_a_Component_in_a_Mixture.ipynb @@ -0,0 +1,546 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 11: Properties of a Component in a Mixture" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.10: Calculation_of_fugacity_0f_the_mixture.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.10\n", +"//Page number - 400\n", +"printf('Example - 11.10 and Page number - 400\n\n');\n", +"\n", +"//Given\n", +"x_A = 0.20;// Mole fraction of A\n", +"x_B = 0.35;// Mole fraction of B\n", +"x_C = 0.45;// Mole fraction of C\n", +"\n", +"phi_A = 0.7;// Fugacity coefficient of A\n", +"phi_B = 0.6;// Fugacity coefficient of B\n", +"phi_C = 0.9;// Fugacity coefficient of C\n", +"\n", +"P = 6.08;//[MPa] - Pressure\n", +"T = 384;//[K] - Temperature\n", +"\n", +"//We know that\n", +"//log(phi) = x_1*log(phi_) + x_2*log(phi_2) + x_3*log(phi_3)\n", +"log_phi = x_A*log(phi_A) + x_B*log(phi_B) + x_C*log(phi_C);// Fugacity coefficient\n", +"phi = exp(log_phi);\n", +"\n", +"//Thus fugacity is given by,\n", +"f_mixture = phi*P;//[MPa]\n", +"\n", +"printf('The fugacity of the mixture is %f MPa',f_mixture);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.11: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.11\n", +"//Page number - 400\n", +"printf('Example - 11.11 and Page number - 400\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 11.11 on page number 400 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 11.11 on page number 400 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.12: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.12\n", +"//Page number - 401\n", +"printf('Example - 11.12 and Page number - 401\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 11.12 on page number 401 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 11.12 on page number 401 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.13: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.13\n", +"//Page number - 405\n", +"printf('Example - 11.13 and Page number - 405\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 11.13 on page number 405 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 11.13 on page number 405 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.1: Determination_of_volumes_of_ethanol_and_water.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.1\n", +"//Page number - 385\n", +"printf('Example - 11.1 and Page number - 385\n\n');\n", +"\n", +"//Given\n", +"Vol_total = 3;//[m^(3)] - Total volume of solution\n", +"x_ethanol = 0.6;//Mole fraction of ethanol\n", +"x_water = 0.4;//Mole fraction of water\n", +"\n", +"//The partial molar volumes of the components in the mixture are\n", +"V_ethanol_bar = 57.5*10^(-6);//[m^(3)/mol]\n", +"V_water_bar = 16*10^(-6);//[m^(3)/mol]\n", +"\n", +"//The molar volumes of the pure components are\n", +"V_ethanol = 57.9*10^(-6);//[m^(3)/mol]\n", +"V_water = 18*10^(-6);//[m^(3)/mol]\n", +"\n", +"//The molar volume of the solution is\n", +"V_sol = x_ethanol*V_ethanol_bar + x_water*V_water_bar;//[m^(3)/mol]\n", +"//Total number of moles can be calculated as \n", +"n_total = Vol_total/V_sol;//[mol]\n", +"\n", +"//Moles of the components are\n", +"n_ethanol = n_total*x_ethanol;//[mol]\n", +"n_water = n_total*x_water;//[mol]\n", +"\n", +"//Finally the volume of the pure components required can be calculated as\n", +"Vol_ethanol = V_ethanol*n_ethanol;\n", +"Vol_water = V_water*n_water;\n", +"\n", +"printf('Required volume of ethanol is %f cubic metre\n\n',Vol_ethanol);\n", +"printf('Required volume of water is %f cubic metre',Vol_water);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.2: Developing_an_expression.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.2\n", +"//Page number - 385\n", +"printf('Example - 11.2 and Page number - 385\n\n');\n", +"\n", +"//Given\n", +"T = 25+273.15;//[K] - Temperature\n", +"P = 1;//[atm]\n", +"//Component 1 = water\n", +"//component 2 = methanol\n", +"a = -3.2;//[cm^(3)/mol] - A constant\n", +"V2 = 40.7;//[cm^(3)/mol] - Molar volume of pure component 2 (methanol)\n", +"//V1_bar = 18.1 + a*x_2^(2)\n", +"\n", +"//From Gibbs-Duhem equation at constant temperature and pressure we have\n", +"//x_1*dV1_bar + x_2*dV2_bar = 0\n", +"//dV2_bar = -(x_1/x_2)*dV1_bar = -(x_1/x_2)*a*2*x_2*dx_2 = -2*a*x_1*dx_2 = 2*a*x_1*dx_1\n", +"\n", +"//At x_1 = 0: x_2 = 1 and thus V2_bar = V2\n", +"//Integrating the above equation from x_1 = 0 to x_1 in the RHS, and from V2_bar = V2 to V2 in the LHS, we get\n", +"//V2_bar = V2 + a*x_1^(2) - Molar volume of component 2(methanol) in the mixture \n", +"\n", +"printf('The expression for the partial molar volume of methanol(2) is\nV2_bar = V2 + a*x_1^(2) [cm^(3)/mol]\n\n');\n", +"\n", +"//At infinite dilution, x_2 approach 0 and thus x_1 approach 1, therefore\n", +"x_1 = 1;// Mole fraction of component 1(water) at infinite dilution\n", +"V2_bar_infinite = V2 + a*(x_1^(2));//[cm^(3)/mol]\n", +"\n", +"printf('The partial molar volume of methanol at infinite dilution is %f cm^(3)/mol',V2_bar_infinite);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.3: Determination_of_partial_molar_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.3\n", +"//Page number - 386\n", +"printf('Example - 11.3 and Page number - 386\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 11.3 on page number 386 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 11.3 on page number 386 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.4: Calculation_of_enthalpies.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.4\n", +"//Page number - 387\n", +"printf('Example - 11.4 and Page number - 387\n\n');\n", +"\n", +"//Given\n", +"//H = a*x_1 + b*x_2 +c*x_1*x_2\n", +"\n", +"//The values of the constants are\n", +"a = 15000;//[J/mol]\n", +"b = 20000;//[J/mol]\n", +"c = -2000;//[J/mol]\n", +"\n", +"//(1)\n", +"//Enthalpy of pure component 1 = H1 is obtained at x_2 = 0, thus \n", +"x_2 = 0;\n", +"x_1 = 1;\n", +"H1 = a*x_1 + b*x_2 +c*x_1*x_2;//[J/mol]\n", +"printf('(a).The enthalpy of pure component 1 is %f J/mol\n',H1);\n", +"\n", +"//Similarly for component 2,\n", +"//Enthalpy of pure component 2 = H2 is obtained at x_1 = 0, thus \n", +"x_1_prime = 0;\n", +"x_2_prime = 1;\n", +"H2 = a*x_1_prime + b*x_2_prime +c*x_1_prime*x_2_prime;//[J/mol]\n", +"printf(' The enthalpy of pure component 2 is %f J/mol\n\n',H2);\n", +"\n", +"//(b)\n", +"//This part involves proving a relation in which no mathematics and no calculations are involved.\n", +"//For prove refer to this example 11.4 on page number 387 of the book.\n", +"\n", +"//(c)\n", +"//From part (b), we have the relation\n", +"//H1_bar = a + c*(x_2^(2))\n", +"//H2_bar = b + c*(x_1^(2))\n", +"\n", +"//For enthalpy of component 1 at infinite dilution, x_1 approach 0 and thus x_2 approach 1, therefore\n", +"x_1_c = 0;\n", +"x_2_c = 1;\n", +"H1_infinite = a + c*(x_2_c^(2));//[cm^(3)/mol]\n", +"printf('(C).The enthalpy of componenet 1 at infinite dilution (at x_1 = 0) is %f J/mol\n',H1_infinite);\n", +"\n", +"//At x_1 = 0.2\n", +"x_1_c1 = 0.2;\n", +"x_2_c1 = 0.8;\n", +"H1_bar_c1 = a + c*(x_2_c1^(2));//[J/mol]\n", +"printf(' The enthalpy of componenet 1 at (at x_1 = 0.2) is %f J/mol\n',H1_bar_c1);\n", +"\n", +"//At x_1 = 0.8\n", +"x_1_c2 = 0.8;\n", +"x_2_c2 = 0.2;\n", +"H1_bar_c2 = a + c*(x_2_c2^(2));//[J/mol]\n", +"printf(' The enthalpy of componenet 1 at (at x_1 = 0.8) is %f J/mol',H1_bar_c2);\n", +"\n", +"//As x_1 increases, 'H1_bar' approaches the value of 'H1' \n", +"\n", +"//(d)\n", +"//This part involves proving a relation in which no mathematics and no calculations are involved.\n", +"//For prove refer to this example 11.4 on page number 387 of the book.\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.5: Developing_an_expression_and_calculation_for_enthalpy_change_of_mixture.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.5\n", +"//Page number - 389\n", +"printf('Example - 11.5 and Page number - 389\n\n');\n", +"\n", +"//This problem involves proving a relation in which no mathematical components are involved.\n", +"//For prove refer to this example 11.5 on page number 389 of the book.\n", +"printf(' This problem involves proving a relation in which no mathematical components are involved.\n\n');\n", +"printf(' For prove refer to this example 11.5 on page number 389 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.6: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.6\n", +"//Page number - 390\n", +"printf('Example - 11.6 and Page number - 390\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 11.6 on page number 390 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 11.6 on page number 390 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.7: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.7\n", +"//Page number - 393\n", +"printf('Example - 11.7 and Page number - 393\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 11.7 on page number 393 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 11.7 on page number 393 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.8: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 11.8\n", +"//Page number - 394\n", +"printf('Example - 11.8 and Page number - 394\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 11.8 on page number 394 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 11.8 on page number 394 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 11.9: Calculation_of_minimum_work_required.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 11.9\n", +"//Page number - 395\n", +"printf('Example - 11.9 and Page number - 395\n\n');\n", +"//Given\n", +"n = 1*10^(3);//[mol] - No of moles\n", +"P = 0.1;//[MPa] - Pressure of the surrounding\n", +"T = 300;//[K] - Temperature of the surrounding\n", +"x_1 = 0.79;//Mole fraction of N2 in the air\n", +"x_2 = 0.21;//Mole fraction of O2 in the air\n", +"R=8.314;//[J/mol*K]\n", +"//Change in availability when x_1 moles of component 1 goes from pure state to that in the mixture is\n", +"//x_1*(si_1 - si_2) = x_1*[H1 - H1_bar - T_0*(S1 - S1_bar)]\n", +"//Similarly change in availability of x_2 moles of component 2 is\n", +"//x_2*(si_1 - si_2) = x_2*[H2 - H2_bar - T_0*(S2 - S2_bar)]\n", +"//and thus total availability change when 1 mol of mixture is formed from x_1 mol of component 1 and x_2 mol of component 2 is equal to reversible work\n", +"//W_rev = x_1*[H1 - H1_bar - T_0*(S1 - S1_bar)] + x_2*[H2 - H2_bar - T_0*(S2 - S2_bar)]\n", +"//W_rev = -[x_1*(H1_bar - H1) + x_2*(H2_bar - H2)] + T_0*[x_1*(S1_bar - S1) + x_2*(S2_bar - S2)]\n", +"//W_rev = -[delta_H_mix] +T_0*[delta_S_mix]\n", +"//If T = T_0 that is,temperature of mixing is same as that of surroundings, W_rev = -delta_G_mix.\n", +"//W_rev = -delta_G_mix = R*T*(x_1*log(x_1) + x_2*log(x_2))\n", +"W_rev = R*T*(x_1*log(x_1) + x_2*log(x_2));//[J/mol]\n", +"//Therefore total work transfer is given by\n", +"W_min = (n*W_rev)/1000;//[kJ]\n", +"printf('The minimum work required is %f kJ',W_min);" + ] + } +], +"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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/12-Partial_Molar_Volume_and_Enthalpy_from_Experimental_Data.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/12-Partial_Molar_Volume_and_Enthalpy_from_Experimental_Data.ipynb new file mode 100644 index 0000000..46ced3a --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/12-Partial_Molar_Volume_and_Enthalpy_from_Experimental_Data.ipynb @@ -0,0 +1,476 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 12: Partial Molar Volume and Enthalpy from Experimental Data" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.1: Calculation_of_partial_molar_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 12.1\n", +"//Page number - 419\n", +"printf('Example - 12.1 and Page number - 419\n\n');\n", +"\n", +"//Given\n", +"//component 1 = methanol\n", +"//component 2 = water\n", +"T = 0 + 273.15;//[K] - Temperature\n", +"P = 1;//[atm] - Pressure\n", +"x_methanol = 0.5;//Mole fraction of methanol at which molar volume is to be calculated\n", +"x_water = 0.5;//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;//[cm^(3)/mol] - Molar volume of pure component 1\n", +"V2 = 18.1;//[cm^(3)/mol] - Molar volume of pure component 2\n", +"\n", +"x1=[0.114,0.197,0.249,0.495,0.692,0.785,0.892];// Values of mole fraction of component 1\n", +"V=[20.3,21.9,23.0,28.3,32.9,35.2,37.9];// Values of molar volume\n", +"x2=zeros(1,7);// Mole fraction of component 2\n", +"x_V=zeros(1,7);// x_V = x1*V_1 + x2*V_2\n", +"V_mix=zeros(1,7);// V_mix = V - x1*V_1 - x2*V_2\n", +"del_V=zeros(1,7);//del_V = V_mix/(x1*x2)\n", +"\n", +"for i=1:7;\n", +" x2(1,i)=1-x1(i);\n", +" x_V(1,i)=x1(i)*V1 + x2(i)*V2;\n", +" V_mix(1,i)=V(i)-x1(i)*V1- x2(i)*V2;\n", +" del_V(1,i)=V_mix(i)/(x1(i)*x2(i));\n", +"end\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=[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=[sum(del_V);sum(x1.*del_V);sum((x1^2).*del_V)];\n", +"soln=a\b;\n", +"a0=soln(1);\n", +"a1=soln(2);\n", +"a2=soln(3);\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", +"// For x1 = 0.5\n", +"x1 = 0.5;\n", +"V_mix_prime = (a0+(a1*x1)+(a2*x1^2))*(x1*(1-x1));//[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;//[cm^(3)/mol] \n", +"V2_bar = V2 + V_mix_prime - x_methanol*del_V_mix_prime;//[cm^(3)/mol]\n", +"\n", +"printf('The partial molar volume of methanol (component 1) is %f cm^(3)/mol\n\n',V1_bar);\n", +"printf('The partial molar volume of water (component 2) is %f cm^(3)/mol',V2_bar);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.2: Determination_of_volume_of_the_mixture.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 12.2\n", +"//Page number - 421\n", +"printf('Example - 12.2 and Page number - 421\n\n');\n", +"\n", +"//Given\n", +"//component 1 = water\n", +"//component 2 = methanol\n", +"T = 25 + 273.15;//[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;//[cm^(3)/mol] - Molar volume of pure component 1\n", +"V2 = 40.7221;//[cm^(3)/mol] - Molar volume of pure component 2\n", +"Vol_1 = 1000;//[cm^(3)] - Volume of pure component 1\n", +"Vol_2 = 1000;//[cm^(3)] - Volume of pure component 2\n", +"\n", +"//Moles of the componenets can be calculated as \n", +"n_1 = Vol_1/V1;//[mol]\n", +"n_2 = Vol_2/V2;//[mol]\n", +"\n", +"//Mole fraction of the components \n", +"x_1 = n_1/(n_1 + n_2);\n", +"x_2 = n_2/(n_1 + n_2);\n", +"\n", +"delta_V_mix = x_1*x_2*(-3.377 - 2.945*x_1 + 3.31*x_1^(2));//[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 = (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);//[cm^(3)/mol]\n", +"\n", +"//Now calculating the partial molar volumes\n", +"V1_bar = V1 + delta_V_mix + x_1*del_delta_V_mix;//[cm^(3)/mol] \n", +"V2_bar = V2 + delta_V_mix - x_2*del_delta_V_mix;//[cm^(3)/mol]\n", +"\n", +"//Finally molar volume of the solution is given by\n", +"V_sol = x_1*V1_bar + x_2*V2_bar;//[cm^(3)/mol]\n", +"\n", +"// Total volume of the solution is given by\n", +"V_total = (n_1 + n_2)*V_sol;//[cm^(3)]\n", +"\n", +"printf('The molar volume of the solution is %f cm^(3)/mol\n\n',V_sol);\n", +"printf('The total volume of the solution is %f cm^(3)',V_total);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.3: Determination_of_volumes.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 12.3\n", +"//Page number - 422\n", +"printf('Example - 12.3 and Page number - 422\n\n');\n", +"\n", +"//Given\n", +"//component 1 = methanol\n", +"//component 2 = water\n", +"Vol = 20;//[cm^(3)] - Volume of the solution\n", +"T = 22 + 273.15;//[K] - Temperature\n", +"W_bottle = 11.5485;//[g] - Weight of density bottle\n", +"Mol_meth = 32.04;//Molecular weight of methanol\n", +"Mol_water = 18.015;// 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;//[cm^(3)/mol] - Density of pure methanol\n", +"den_water = 0.9937;//[cm^(3)/mol] - Density of pure water\n", +"\n", +"\n", +"Vol_perc=[5,10,20,30,40,50,60,70,80,90,95];// 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];// Weight of solution + weight of density bottle\n", +"\n", +"W_sol=zeros(1,11);// Weight of 20 cm^(3) of solution\n", +"den=zeros(1,11);// density of the solution\n", +"x1=zeros(1,11);// Mole fraction of methanol\n", +"x2=zeros(1,11);// Mole fraction of water\n", +"\n", +"for i=1:11;\n", +" W_sol(1,i)=W_total(i)-W_bottle;\n", +" den(1,i)=W_sol(i)/Vol;\n", +" x1(1,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(1,i)=1-x1(1,i);\n", +"end\n", +"\n", +"//Again we have,\n", +"V_kg=zeros(1,11);//[cm^(3)] - Volume of 1 kg of solution\n", +"n_mol=zeros(1,11);//[mol] - Number of moles in 1 kg of solution\n", +"V_mol=zeros(1,11);//[cm^(3)/mol] - Volume of 1 mol of solution\n", +"x_V=zeros(1,11);//[cm^(3)/mol] - x_V = x1*V_meth + x2*V_water\n", +"V_mix=zeros(1,11);//[cm^(3)/mol] - V_mix = V_mol - x1*V_meth - x2*V_water\n", +"del_V=zeros(1,11);// [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;//[cm^(3)/mol] - Molar volume of pure component 1 (methanol)\n", +"V_water = 18.1286;//[cm^(3)/mol] - Molar volume of pure component 2 (water)\n", +"\n", +"for i=1:11;\n", +" V_kg(1,i)=1000/den(i);\n", +" n_mol(1,i)=1000/(x1(i)*Mol_meth+x2(i)*Mol_water);\n", +" V_mol(1,i)=V_kg(i)/n_mol(i);\n", +" x_V(1,i)=V_meth*x1(i)+V_water*x2(i);\n", +" V_mix(1,i)=V_mol(i)-x1(i)*V_meth-x2(i)*V_water;\n", +" del_V(1,i)=V_mix(i)/(x1(i)*x2(i));\n", +"end\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=[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=[sum(del_V);sum(x1.*del_V);sum((x1^2).*del_V)];\n", +"soln=a\b;\n", +"a0=soln(1);\n", +"a1=soln(2);\n", +"a2=soln(3);\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", +"deff('[y]=f(x1)','y=(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", +"deff('[y]=f1(x1)','y=(-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(1,5);//[cm^(3)/mol] - V_mix = V - x1*V_meth - x2*V_water\n", +"del_V_prime=zeros(1,5);//[cm^(3)/mol] - del_V = V_mix/(x1*x2)\n", +"V1_bar=zeros(1,5);//[cm^(3)/mol] - Partial molar volume of component 1\n", +"V2_bar=zeros(1,5);//[cm^(3)/mol] - Partial molar volume of component 1\n", +"\n", +"for j=1: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", +" printf('For x1 = %f\n',x1_prime(j));\n", +" printf('The partial molar volume of methanol (component 1) is %f cm^(3)/mol\n',V1_bar(j));\n", +" printf('The partial molar volume of water (component 2) is %f cm^(3)/mol\n\n',V2_bar(j));\n", +"end\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.4: Determination_of_partial_molar_volumes.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 12.4\n", +"//Page number - 424\n", +"printf('Example - 12.4 and Page number - 424\n\n');\n", +"\n", +"//Given\n", +"//component 1 = formic acid\n", +"//component 2 = water\n", +"T = 20 + 273.15;//[K] - Temperature\n", +"Mol_form = 46.027;//Molecular weight of formic acid\n", +"Mol_water = 18.015;// Molecular weight of water\n", +"\n", +"Wt_perc=[10,18,30,50,72,78];//Weight percent of formic acid\n", +"den=[1.0246,1.0441,1.0729,1.1207,1.1702,1.1818];//[g/cm^(3)] - Density of solution\n", +"\n", +"V_g=zeros(1,6);//[cm^(3)/g] - Volume of 1 g of solution\n", +"x1=zeros(1,6);// Mole fraction of component 1\n", +"x2=zeros(1,6);// Mole fraction of component 2\n", +"n=zeros(1,6);// Number of moles in 1 g\n", +"V_mol=zeros(1,6);//[cm^(3)/mol] - Volume of 1 mol of solution\n", +"x_V=zeros(1,6);//[cm^(3)/mol] - x_V = x1*V_form + x2*V_water\n", +"V_mix=zeros(1,6);//[cm^(3)/mol] - V_mix = V - x1*V_form - x2*V_water\n", +"del_V=zeros(1,6);// [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;//[cm^(3)/mol] - Molar volume of pure formic acid (component 1)\n", +"V_water = 18.050;//[cm^(3)/mol] - Molar volume of pure water (component 2)\n", +"\n", +"for i=1:6;\n", +" V_g(i)=1/den(i);\n", +" x1(1,i)=(Wt_perc(i)/Mol_form)/((Wt_perc(i)/Mol_form)+((100-Wt_perc(i))/Mol_water));\n", +" x2(1,i)=1-x1(i);\n", +" n(1,i)=((Wt_perc(i)/100)/Mol_form)+(((100-Wt_perc(i))/100)/Mol_water);\n", +" V_mol(1,i)=V_g(i)/n(i);\n", +" x_V(1,i)=V_form*x1(i)+V_water*x2(i);\n", +" V_mix(1,i)=V_mol(i)-x1(i)*V_form-x2(i)*V_water;\n", +" del_V(1,i)=V_mix(i)/(x1(i)*x2(i));\n", +"end\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=[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=[sum(del_V);sum(x1.*del_V);sum((x1^2).*del_V)];\n", +"soln=a\b;\n", +"a0=soln(1);\n", +"a1=soln(2);\n", +"a2=soln(3);\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", +"deff('[y]=f(x1)','y=(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", +"deff('[y]=f1(x1)','y=(-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 = (15/Mol_form)/((15/Mol_form)+((100-15)/Mol_water)); \n", +"//Similarly at 75 Wt% of formic acid, x1 is given by\n", +"x1_prime_2 = (75/Mol_form)/((75/Mol_form)+((100-75)/Mol_water)); \n", +"\n", +"Wt_perc_prime=[15,75];\n", +"x1_prime=[x1_prime_1,x1_prime_2];\n", +"V_mix_prime=zeros(1,2);//[cm^(3)/mol] - V_mix = V - x1*V_meth - x2*V_water\n", +"del_V_prime=zeros(1,2);//[cm^(3)/mol] - del_V = V_mix/(x1*x2)\n", +"V1_bar=zeros(1,2);//[cm^(3)/mol] - Partial molar volume of component 1\n", +"V2_bar=zeros(1,2);//[cm^(3)/mol] - Partial molar volume of component 1\n", +"\n", +"for j=1: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", +" printf('For weight percent of formic acid = %f percent\n',Wt_perc_prime(j));\n", +" printf('The partial molar volume of formic acid (component 1) is %f cm^(3)/mol\n',V1_bar(j));\n", +" printf('The partial molar volume of water (component 2) is %f cm^(3)/mol\n\n',V2_bar(j));\n", +"end" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.5: Determination_of_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 12.5\n", +"//Page number - 426\n", +"printf('Example - 12.5 and Page number - 426\n\n');\n", +"\n", +"//Given\n", +"T = 40 + 273.15;//[K] - Temperature\n", +"\n", +"x1=[0.083,0.176,0.268,0.353,0.428,0.720,0.780,0.850,0.900];// Mole fraction of component 1\n", +"delta_H_mix=[0.250,0.488,0.670,0.790,0.863,0.775,0.669,0.510,0.362];//[kJ/mol] - Enthalpy of the solution\n", +"\n", +"x2=zeros(1,9);// Mole fraction of component 2\n", +"del_H=zeros(1,9);//[kJ/mol] - del_H = delta_H_mix/(x1*x2)\n", +"\n", +"for i=1:9;\n", +" x2(1,i)=1-x1(i);\n", +" del_H(1,i)=delta_H_mix(i)/(x1(i)*x2(i));\n", +"end\n", +"\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=[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=[sum(del_H);sum(x1.*del_H);sum((x1^2).*del_H)];\n", +"soln=a\b;\n", +"a0=soln(1);\n", +"a1=soln(2);\n", +"a2=soln(3);\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;//[mol]\n", +"delta_H_mix = (a0+(a1*x_1)+(a2*x_1^2))*(x_1*(1-x_1));//[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;//[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;//[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;//[kJ/mol]\n", +"k_2 = delta_H_mix - x_1_prime*del_delta_H_mix;//[kJ/mol]\n", +"\n", +"\n", +"printf('The value of (H1_bar - H1) at x1 = 0.25 is %f kJ/mol\n\n',k_1);\n", +"printf('The value of (H2_bar - H2) at x1 = 0.25 is %f kJ/mol',k_2);\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/13-Fugacity_of_a_Component_in_a_Mixture_by_Equations_of_State.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/13-Fugacity_of_a_Component_in_a_Mixture_by_Equations_of_State.ipynb new file mode 100644 index 0000000..39b1a10 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/13-Fugacity_of_a_Component_in_a_Mixture_by_Equations_of_State.ipynb @@ -0,0 +1,430 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 13: Fugacity of a Component in a Mixture by Equations of State" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.1: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 13.1\n", +"//Page number - 432\n", +"printf('Example - 13.1 and Page number - 432\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 13.1 on page number 432 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 13.1 on page number 432 of the book.')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.2: Caculation_of_fugacity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 13.2\n", +"//Page number - 433\n", +"printf('Example - 13.2 and Page number - 433\n\n');\n", +"\n", +"//Given\n", +"T = 310.93;//[K] - Temperature\n", +"P = 2.76*10^(6);//[Pa] - Pressure\n", +"y1 = 0.8942;//[mol] - mole fraction of component 1\n", +"y2 = 1 - y1;//[mol] - mole fraction of component 2\n", +"R=8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"//For component 1 (methane)\n", +"Tc_1 = 190.6;//[K] - Critical temperature\n", +"Pc_1 = 45.99*10^(5);//[N/m^(2)] - Critical pressure\n", +"Vc_1 = 98.6;//[cm^(3)/mol] - Critical molar volume\n", +"Zc_1 = 0.286;// - Critical compressibility factor\n", +"w_1 = 0.012;// - Critical acentric factor\n", +"//Similarly for component 2 (n-Butane)\n", +"Tc_2 = 425.1;//[K]\n", +"Pc_2 = 37.96*10^(5);//[N/m^(2)]\n", +"Vc_2 = 255;//[cm^(3)/mol]\n", +"Zc_2=0.274;\n", +"w_2=0.2;\n", +"\n", +"//For component 1\n", +"Tr_1 = T/Tc_1;//Reduced temperature\n", +"//At reduced temperature\n", +"B1_0 = 0.083-(0.422/(Tr_1)^(1.6));\n", +"B1_1 = 0.139-(0.172/(Tr_1)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;//[m^(3)/mol]\n", +"\n", +"//Similarly for component 2\n", +"Tr_2 = T/Tc_2;//Reduced temperature\n", +"//At reduced temperature Tr_2,\n", +"B2_0 = 0.083-(0.422/(Tr_2)^(1.6));\n", +"B2_1 = 0.139-(0.172/(Tr_2)^(4.2));\n", +"B_22 = ((B2_0+(w_2*B2_1))*(R*Tc_2))/Pc_2;//[m^(3)/mol]\n", +"\n", +"//For cross coeffcient\n", +"Tc_12 = (Tc_1*Tc_2)^(1/2);//[K]\n", +"w_12 = (w_1+w_2)/2;\n", +"Zc_12 = (Zc_1+Zc_2)/2;\n", +"Vc_12 = (((Vc_1)^(1/3)+(Vc_2)^(1/3))/2)^(3);//[cm^(3)/mol]\n", +"Vc_12 = Vc_12*10^(-6);//[m^(3)/mol]\n", +"Pc_12 = (Zc_12*R*Tc_12)/Vc_12;//[N/m^(2)]\n", +"\n", +"//Given, Z = 1 + (B*P)/(R*T)\n", +"//Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n", +"//where B_0 and B_1 are to be evaluated at Tr_12\n", +"Tr_12 = T/Tc_12;\n", +"//At reduced temperature Tr_12\n", +"B_0 = 0.083-(0.422/(Tr_12)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr_12)^(4.2));\n", +"B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;//[m^(3)/mol]\n", +"//For the mixture\n", +"B = y1^(2)*B_11+2*y1*y2*B_12+y2^(2)*B_22;//[m^(3)/mol]\n", +"\n", +"//Now del_12 can be calculated as,\n", +"del_12 = 2*B_12 - B_11 - B_22;//[m^(3)/mol]\n", +"\n", +"//We have the relation, log(phi_1) = (P/(R*T))*(B_11 + y2^(2)*del_12), therefore\n", +"phi_1 = exp((P/(R*T))*(B_11 + y2^(2)*del_12));\n", +"//Similarly for component 2\n", +"phi_2 = exp((P/(R*T))*(B_22 + y1^(2)*del_12));\n", +"\n", +"printf(' The value of fugacity coefficient of component 1 (phi_1) is %f\n\n',phi_1);\n", +"printf(' The value of fugacity coefficient of component 2 (phi_2) is %f\n\n',phi_2);\n", +"\n", +"//Finally fugacity coefficient of the mixture is given by\n", +"//log(phi) = y1*log(phi_1) + y2*log(phi_2);\n", +"phi = exp(y1*log(phi_1) + y2*log(phi_2));\n", +"\n", +"printf(' The value of fugacity coefficient of the mixture (phi) is %f ',phi);\n", +"//The fugacity coefficient of the mixture can also be obtained using\n", +"//log(phi) = (B*P)/(R*T)\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.3: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 13.3\n", +"//Page number - 435\n", +"printf('Example - 13.3 and Page number - 435\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 13.3 on page number 435 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 13.3 on page number 435 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.4: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 13.4\n", +"//Page number - 436\n", +"printf('Example - 13.4 and Page number - 436\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 13.4 on page number 436 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 13.4 on page number 436 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.5: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 13.5\n", +"//Page number - 442\n", +"printf('Example - 13.5 and Page number - 442\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 13.5 on page number 442 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 13.5 on page number 442 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.6: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 13.6\n", +"//Page number - 446\n", +"printf('Example - 13.6 and Page number - 446\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 13.6 on page number 446 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 13.6 on page number 446 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.7: Calculation_of_fugacity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"// Example - 13.7\n", +"// Page number - 447\n", +"printf('Example - 13.7 and Page number - 447\n\n');\n", +"\n", +"//Given\n", +"T = 460;//[K] - Temperature\n", +"P = 40*10^(5);//[Pa] - Pressure\n", +"R=8.314;//[J/mol*K] - Universal gas constant\n", +"// component 1 = nitrogen\n", +"// component 2 = n-Butane\n", +"y1 = 0.4974;// Mole percent of nitrogen\n", +"y2 = 0.5026;// Mole percent of n-Butane\n", +"Tc_nit = 126.2;//[K]\n", +"Pc_nit = 34.00*10^(5);//[Pa]\n", +"Tc_but = 425.1;//[K]\n", +"Pc_but = 37.96*10^(5);//[Pa]\n", +"\n", +"// (1). van der Walls equation of state\n", +"\n", +"// The fugacity coefficient of component 1 in a binary mixture following van der Walls equation of state is given by,\n", +"// log(phi_1) = b_1/(V-b) - log(Z-B) -2*(y1*a_11 + y2*a_12)/(R*T*V)\n", +"// and for component 2 is given by,\n", +"// log(phi_2) = b_2/(V-b) - log(Z-B) -2*(y1*a_12 + y2*a_22)/(R*T*V)\n", +"// Where B = (P*b)/(R*T)\n", +"\n", +"// For componenet 1 (nitrogen)\n", +"a_1 = (27*R^(2)*Tc_nit^(2))/(64*Pc_nit);//[Pa-m^(6)/mol^(2)]\n", +"b_1 = (R*Tc_nit)/(8*Pc_nit);//[m^(3)/mol]\n", +"\n", +"// Similarly for componenet 2 (n-Butane)\n", +"a_2 = (27*R^(2)*Tc_but^(2))/(64*Pc_but);//[Pa-m^(6)/mol^(2)]\n", +"b_2 = (R*Tc_but)/(8*Pc_but);//[m^(3)/mol]\n", +"\n", +"// Here\n", +"a_11 = a_1;\n", +"a_22 = a_2;\n", +"// For cross coefficient\n", +"a_12 = (a_1*a_2)^(1/2);//[Pa-m^(6)/mol^(2)]\n", +"\n", +"// For the mixture \n", +"a = y1^(2)*a_11 + y2^(2)*a_22 + 2*y1*y2*a_12;//[Pa-m^(6)/mol^(2)]\n", +"b = y1*b_1 + y2*b_2;//[m^(3)/mol]\n", +"\n", +"// The cubic form of the van der Walls equation of state is given by,\n", +"// V^(3) - (b+(R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"// Substituting the value and solving for V, we get\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P');\n", +"V_1=fsolve(-1,f);\n", +"V_2=fsolve(0,f);\n", +"V_3=fsolve(1,f);\n", +"// The molar volume V = V_3, the other two roots are imaginary\n", +"V = V_3;//[m^(3)/mol]\n", +"\n", +"// The comprssibility factor of the mixture is \n", +"Z = (P*V)/(R*T);\n", +"// And B can also be calculated as\n", +"B = (P*b)/(R*T);\n", +"\n", +"// The fugacity coefficient of component 1 in the mixture is\n", +"phi_1 = exp(b_1/(V-b) - log(Z-B) -2*(y1*a_11 + y2*a_12)/(R*T*V));\n", +"// Similarly fugacity coefficient of component 2 in the mixture is \n", +"phi_2 = exp(b_2/(V-b) - log(Z-B) -2*(y1*a_12 + y2*a_22)/(R*T*V));\n", +"\n", +"// The fugacity coefficient of the mixture is given by,\n", +"// log(phi) = y1*log(phi_1) + y2*log(phi_2)\n", +"phi = exp(y1*log(phi_1) + y2*log(phi_2));\n", +"\n", +"// Also the fugacity coefficient of the mixture following van der Walls equation of state is given by,\n", +"// log(phi) = b/(V-b) - log(Z-B) -2*a/(R*T*V)\n", +"phi_dash = exp(b/(V-b) - log(Z-B) -2*a/(R*T*V));\n", +"// The result is same as obtained above\n", +"\n", +"printf(' (1)van der Walls equation of state\n');\n", +"printf(' The value of fugacity coefficient of component 1 (nitrogen) is %f\n',phi_1);\n", +"printf(' The value of fugacity coefficient of component 2 (n-butane) is %f\n',phi_2);\n", +"printf(' The value of fugacity coefficient of the mixture is %f\n',phi);\n", +"printf(' Also the fugacity coefficient of the mixture from van der Walls equation of state is %f (which is same as above)\n\n',phi_dash);\n", +"\n", +"// (2). Redlich-Kwong equation of state\n", +"\n", +"// For component 1,\n", +"a_1_prime = (0.42748*R^(2)*Tc_nit^(2.5))/Pc_nit;//[Pa-m^(6)/mol^(2)]\n", +"b_1_prime = (0.08664*R*Tc_nit)/Pc_nit;//[m^(3)/mol]\n", +"\n", +"//similarly for component 2,\n", +"a_2_prime = (0.42748*R^(2)*Tc_but^(2.5))/Pc_but;//[Pa-m^(6)/mol^(2)]\n", +"b_2_prime = (0.08664*R*Tc_but)/Pc_but;//[m^(3)/mol]\n", +"\n", +"// For cross coefficient\n", +"a_12_prime = (a_1_prime*a_2_prime)^(1/2);//[Pa-m^(6)/mol^(2)]\n", +"// For the mixture\n", +"a_prime = y1^(2)*a_1_prime + y2^(2)*a_2_prime +2*y1*y2*a_12_prime;//[Pa-m^(6)/mol^(2)]\n", +"b_prime = y1*b_1_prime +y2*b_2_prime;//[m^(3)/mol]\n", +"\n", +"\n", +"//The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3)-((R*T)/P)*V^(2)-((b^(2))+((b*R*T)/P)-(a/(T^(1/2)*P))*V-(a*b)/(T^(1/2)*P)=0\n", +"// Solving the cubic equation\n", +"deff('[y]=f1(V)','y=V^(3)-((R*T)/P)*V^(2)-((b_prime^(2))+((b_prime*R*T)/P)-(a_prime/(T^(1/2)*P)))*V-(a_prime*b_prime)/(T^(1/2)*P)');\n", +"V_4=fsolve(1,f1);\n", +"V_5=fsolve(0,f1);\n", +"V_6=fsolve(-1,f1);\n", +"// The molar volume V = V_4, the other two roots are imaginary\n", +"V_prime = V_4;//[m^(3)/mol]\n", +"\n", +"// The compressibility factor of the mixture is\n", +"Z_prime = (P*V_prime)/(R*T);\n", +"// And B can also be calculated as\n", +"B_prime = (P*b_prime)/(R*T);\n", +"\n", +"// The fugacity coefficient of component 1 in the binary mixture is given by\n", +"// log(phi_1) = b_1/(V-b) - log(Z-B) + ((a*b_1)/((b^(2)*R*T^(3/2))))*(log((V+b)/V)-(b/(V+b)))-(2*(y1*a_1+y2*a_12)/(R*T^(3/2)b))*(log(V+b)/b)\n", +"\n", +"phi_1_prime = exp((b_1_prime/(V_prime-b_prime))-log(Z_prime-B_prime)+((a_prime*b_1_prime)/((b_prime^(2))*R*(T^(3/2))))*(log((V_prime+b_prime)/V_prime)-(b_prime/(V_prime+b_prime)))-(2*(y1*a_1_prime+y2*a_12_prime)/(R*(T^(3/2))*b_prime))*(log((V_prime+b_prime)/V_prime)));\n", +"\n", +"\n", +"// Similarly fugacity coefficient of component 2 in the mixture is \n", +"phi_2_prime = exp((b_2_prime/(V_prime-b_prime))-log(Z_prime-B_prime)+((a_prime*b_2_prime)/((b_prime^(2))*R*(T^(3/2))))*(log((V_prime+b_prime)/V_prime)-(b_prime/(V_prime+b_prime)))-(2*(y1*a_12_prime+y2*a_2_prime)/(R*(T^(3/2))*b_prime))*(log((V_prime+b_prime)/V_prime)));\n", +"\n", +"// The fugacity coefficient of the mixture is given by,\n", +"// log(phi) = y1*log(phi_1) + y2*log(phi_2)\n", +"phi_prime = exp(y1*log(phi_1_prime) + y2*log(phi_2_prime));\n", +"\n", +"// Also the fugacity coefficient for the mixture following Redlich-kwong equation of state is also given by\n", +"// log(phi) = b/(V-b) - log(Z-B) - (a/(R*T^(3/2)))*(1/(V+b)+(1/b)*log((V+b)/V))\n", +"phi_prime_dash = exp(b_prime/(V_prime-b_prime) - log(Z_prime-B_prime) - (a_prime/(R*T^(3/2)))*(1/(V_prime+b_prime)+(1/b_prime)*log((V_prime+b_prime)/ V_prime)));\n", +"\n", +"printf(' (2)Redlich-Kwong equation of state\n');\n", +"printf(' The value of fugacity coefficient of component 1 (nitrogen) is %f\n',phi_1_prime);\n", +"printf(' The value of fugacity coefficient of component 2 (n-butane) is %f\n',phi_2_prime);\n", +"printf(' The value of fugacity coefficient of the mixture is %f\n',phi_prime);\n", +"printf(' Also the fugacity coefficient for the mixture from Redlich-kwong equation of state is %f (which is same as above)\n\n',phi_prime_dash);" + ] + } +], +"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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/14-Activity_Coefficients_Models_for_Liquid_Mixtures.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/14-Activity_Coefficients_Models_for_Liquid_Mixtures.ipynb new file mode 100644 index 0000000..05bde57 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/14-Activity_Coefficients_Models_for_Liquid_Mixtures.ipynb @@ -0,0 +1,1070 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 14: Activity Coefficients Models for Liquid Mixtures" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.10: Comparision_of_Margules_and_van_Laar_eqations.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear; \n", +"clc;\n", +"\n", +"//Example - 14.10\n", +"//Page number - 466\n", +"printf('Example - 14.10 and Page number - 466\n\n')\n", +"\n", +"//Given,\n", +"T = 25 +173.15;//[K] - Temperature\n", +"x_1=[0.0115,0.0160,0.0250,0.0300,0.0575,0.1125,0.1775,0.2330,0.4235,0.5760,0.6605,0.7390,0.8605,0.9250,0.9625];\n", +"y_1=[8.0640,7.6260,7.2780,7.2370,5.9770,4.5434,3.4019,2.8023,1.7694,1.3780,1.2302,1.1372,1.0478,1.0145,1.0070];\n", +"y_2=[1.0037,1.0099,1.0102,1.0047,1.0203,1.0399,1.1051,1.1695,1.4462,1.8520,2.2334,2.6886,3.7489,4.8960,5.6040];\n", +"\n", +"x_2 = zeros(1,15);// x_2 = (1 - x_1)\n", +"G_RT = zeros(1,15);// G_RT = G_excess/(R*T)\n", +"x1x2_G_RT = zeros(1,15);// x1x2_G_RT = (x_1*x_2/(G_excess/(R*T)))\n", +"G_RTx1x2 = zeros(1,15);// G_RTx1x1 = G_excess/(R*T*x_1*x_2)\n", +"\n", +"for i=1:15;\n", +" x_2(1,i)=(1-x_1(i));\n", +" G_RT(1,i)=(x_1(i)*log(y_1(i)))+(x_2(i)*log(y_2(i)));\n", +" x1x2_G_RT(1,i)=(x_1(i)*x_2(i))/G_RT(i);\n", +" G_RTx1x2(1,i)=1/x1x2_G_RT(i);\n", +" \n", +"end\n", +"\n", +"//From Van Laar equation \n", +"// G_RTx1x2 = (x_1*x_2/(G_excess/(R*T))) = 1/A + (1/B -1/A)*x_1\n", +"//slope = (1/B -1/A) and intercept = 1/A\n", +"\n", +"//Now employing the concept of linear regression of the data ( x_1 , x1x2_G_RT ) to find the value of intercept and slope of the above equation\n", +"//Let slope = slop and intercept = intr\n", +"\n", +"[slop,intr,sig]=reglin(x_1,x1x2_G_RT);\n", +"\n", +"A = 1/intr;\n", +"B = 1/(slop+(1/A));\n", +"printf(' The value of van Laar parameters are\n A = %f and B = %f\n\n',A,B);\n", +"\n", +"// Now from Margules equation\n", +"// G_RTx1x2 = G_excess/(R*T*x_1*x_2) = B1*x_1 + A1*x_1 = A1 + (B1 - A1)*x_1\n", +"//slope = (B1 - A1) and intercept = A1\n", +"\n", +"// Again employing the concept of linear regression of the data ( x_1 , G_RTx1x2 ) to find the value of intercept and slope of the above equation\n", +"//Let slope = slop1 and intercept = intr1\n", +"\n", +"[slop1,intr1,sig1]=reglin(x_1,G_RTx1x2);\n", +"\n", +"A1 = intr1;\n", +"B1 = slop1 + A1;\n", +"printf(' The value of Margules parameters are\n A = %f and B = %f\n\n',A1,B1);\n", +"\n", +"printf(' Because of the higher value of correlation factor for Van Laar model, it fits the data better.');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.11: Calculation_of_activity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.11\n", +"//Page number - 470\n", +"printf('Example - 14.11 and Page number - 470\n\n')\n", +"\n", +"//Given,\n", +"T = 60 + 273.15;//[K] - Temperature\n", +"R = 1.987;//[cal/mol*K] - Universal gas constant\n", +"//component 1 = acetone\n", +"//component 2 = water\n", +"x_1 = 0.3;// Mole fraction of component 1\n", +"x_2 = 1 - x_1;//Mole fraction of component 2\n", +"V_mol_1 = 74.05;//[cm^(3)/mol] - Molar volume of pure component 1\n", +"V_mol_2 = 18.07;//[cm^(3)/mol] - Molar volume of pure component 2\n", +"\n", +"//for Wilson equation\n", +"a_12 = 291.27;//[cal/mol]\n", +"a_21 = 1448.01;//[cal/mol]\n", +"\n", +"//For NRTL\n", +"b_12 = 631.05;//[cal/mol]\n", +"b_21 = 1197.41;//[cal/mol]\n", +"alpha = 0.5343;\n", +"\n", +"//Froom wilson equation\n", +"A_12=(V_mol_2/V_mol_1)*(exp(-a_12/(R*T)));\n", +"A_21 = (V_mol_1/V_mol_2)*(exp(-a_21/(R*T)));\n", +"Beta = A_12/(x_1+x_2*A_12) - A_21/(x_2+x_1*A_21);\n", +"//log(Y1) = -log(x_1 + x_2*A_12) + x_2*Beta; \n", +"Y1 = exp(-log(x_1+x_2*A_12)+x_2*Beta);\n", +"//similarly for Y2\n", +"Y2 = exp(-log(x_2+x_1*A_21)-x_1*Beta);\n", +"printf('The value of activity coefficients for Wilson equation are\n Y1 = %f \t and \t Y2 = %f\n\n',Y1,Y2);\n", +"\n", +"//From NRTL equation,\n", +"t_12 = b_12/(R*T);\n", +"t_21 = b_21/(R*T);\n", +"G_12 = exp(-alpha*t_12);\n", +"G_21 = exp(-alpha*t_21);\n", +"\n", +"//log(Y1) = x_1^(2)*[t_12*(G_12/(x_1+x_2*G_12))^(2) + (G_12*t_12)/((G_12/(x_1+x_2*G_12))^(2))]\n", +"Y1_prime = exp(x_2^(2)*(t_21*(G_21/(x_1+x_2*G_21))^(2)+(G_12*t_12)/(((x_2+x_1*G_12))^(2))));\n", +"//Similarly for Y2\n", +"Y2_prime = exp(x_1^(2)*(t_12*(G_12/(x_2+x_1*G_12))^(2)+(G_21*t_21)/(((x_1+x_2*G_21))^(2))));\n", +"\n", +"printf('The value of activity coefficients for NRTL equation are\n Y1 = %f \t and \t Y2 = %f\n\n',Y1_prime,Y2_prime);\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.12: Calculation_of_the_value_of_activity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.12\n", +"//Page number - 474\n", +"printf('Example - 14.12 and Page number - 474\n\n');\n", +"\n", +"//Given \n", +"T = 307;//[K]\n", +"x_1 = 0.047;\n", +"x_2 = 1 - x_1;\n", +"\n", +"// The subgroups in the two components are\n", +"// Acetone (1) : 1 CH3, 1 CH3CO\n", +"// n-pentane (2) : 2 CH3, 3 CH2\n", +"\n", +"//Group volume (Rk) and surface area (Qk) parameters of the subgroup are\n", +"k_CH3 = 1;\n", +"k_CH2 = 2;\n", +"k_CH3CO = 19;\n", +"Rk_CH3 = 0.9011;\n", +"Rk_CH2 = 0.6744;\n", +"Rk_CH3CO = 1.6724;\n", +"Qk_CH3 = 0.848;\n", +"Qk_CH2 = 0.540;\n", +"Qk_CH3CO = 1.4880;\n", +"\n", +"// Interaction parameters of the subgroups in kelvin (K) are\n", +"a_1_1 = 0;\n", +"a_1_2 = 0;\n", +"a_1_19 = 476.40;\n", +"a_2_1 = 0;\n", +"a_2_2 = 0;\n", +"a_2_19 = 476.40;\n", +"a_19_1 = 26.76;\n", +"a_19_2 = 26.76;\n", +"a_19_19 = 0;\n", +"\n", +"r_1 = 1*Rk_CH3 + 1*Rk_CH3CO;\n", +"r_2 = 2*Rk_CH3 + 3*Rk_CH2;\n", +"q_1 = 1*Qk_CH3 + 1*Qk_CH3CO;\n", +"q_2 = 2*Qk_CH3 + 3*Qk_CH2;\n", +"\n", +"J_1 = r_1/(r_1*x_1+r_2*x_2);\n", +"J_2 = r_2/(r_1*x_1+r_2*x_2);\n", +"L_1 = q_1/(q_1*x_1+q_2*x_2);\n", +"L_2 = q_2/(q_1*x_1+q_2*x_2);\n", +"t_1_1 = exp(-a_1_1/T);\n", +"t_1_2 = exp(-a_1_2/T);\n", +"t_1_19 = exp(-a_1_19/T);\n", +"t_2_1 = exp(-a_2_1/T);\n", +"t_2_2 = exp(-a_2_2/T);\n", +"t_2_19 = exp(-a_2_19/T);\n", +"t_19_1 = exp(-a_19_1/T);\n", +"t_19_2 = exp(-a_19_2/T);\n", +"t_19_19 = exp(-a_19_19/T);\n", +"\n", +"e_1_1 = 1*Qk_CH3/q_1;\n", +"e_2_1 = 0;\n", +"e_19_1 = (1*Qk_CH3CO/q_1);\n", +"e_1_2 = 2*Qk_CH3/q_2;\n", +"e_2_2 = 3*Qk_CH2/q_2;\n", +"e_19_2 = 0;\n", +"\n", +"B_1_1 = e_1_1*t_1_1 + e_2_1*t_2_1 + e_19_1*t_19_1;\n", +"B_1_2 = e_1_1*t_1_2 + e_2_1*t_2_2 + e_19_1*t_19_2;\n", +"B_1_19 = e_1_1*t_1_19 + e_2_1*t_2_19 + e_19_1*t_19_19;\n", +"B_2_1 = e_1_2*t_1_1 + e_2_2*t_2_1 + e_19_2*t_19_1;\n", +"B_2_2 = e_1_2*t_1_2 + e_2_2*t_2_2 + e_19_2*t_19_2;\n", +"B_2_19 = e_1_2*t_1_19 + e_2_2*t_2_19 + e_19_2*t_19_19;\n", +"\n", +"theta_1 = (x_1*q_1*e_1_1 + x_2*q_2*e_1_2)/(x_1*q_1 + x_2*q_2);\n", +"theta_2 = (x_1*q_1*e_2_1 + x_2*q_2*e_2_2)/(x_1*q_1 + x_2*q_2);\n", +"theta_19 = (x_1*q_1*e_19_1 + x_2*q_2*e_19_2)/(x_1*q_1 + x_2*q_2);\n", +"\n", +"s_1 = theta_1*t_1_1 + theta_2*t_2_1 + theta_19*t_19_1;\n", +"s_2 = theta_1*t_1_2 + theta_2*t_2_2 + theta_19*t_19_2;\n", +"s_19 = theta_1*t_1_19 + theta_2*t_2_19 + theta_19*t_19_19;\n", +"\n", +"// log(Y1_C) = 1 - J_1 + log(J_1) - 5*q_1*(1- (J_1/L_1) + log(J_1/L_1))\n", +"// log(Y2_C) = 1 - J_2 + log(J_2) - 5*q_2*(1- (J_2/L_2) + log(J_2/L_2))\n", +"Y1_C = exp(1 - J_1 + log(J_1) - 5*q_1*(1- (J_1/L_1) + log(J_1/L_1)));\n", +"Y2_C = exp(1 - J_2 + log(J_2) - 5*q_2*(1- (J_2/L_2) + log(J_2/L_2)));\n", +"\n", +"// For species 1\n", +"summation_theta_k_1 = theta_1*(B_1_1/s_1) + theta_2*(B_1_2/s_2) + theta_19*(B_1_19/s_19);\n", +"summation_e_ki_1 = e_1_1*log(B_1_1/s_1) + e_2_1*log(B_1_2/s_2) + e_19_1*log(B_1_19/s_19);\n", +"\n", +"// For species 2\n", +"summation_theta_k_2 = theta_1*(B_2_1/s_1) + theta_2*(B_2_2/s_2) + theta_19*(B_2_19/s_19);\n", +"summation_e_ki_2 = e_1_2*log(B_2_1/s_1) + e_2_2*log(B_2_2/s_2) + e_19_2*log(B_2_19/s_19);\n", +"\n", +"// log(Y1_R) = q_1(1 - summation_theta_k_1 + summation_e_ki_1)\n", +"// log(Y2_R) = q_2(1 - summation_theta_k_2 + summation_e_ki_2)\n", +"Y1_R = exp(q_1*(1 - summation_theta_k_1 + summation_e_ki_1));\n", +"Y2_R = exp(q_2*(1 - summation_theta_k_2 + summation_e_ki_2));\n", +"\n", +"// log(Y1) = log(Y1_C) + log(Y1_R)\n", +"// log(Y2) = log(Y2_C) + log(Y2_R)\n", +"Y1 = exp(log(Y1_C) + log(Y1_R));\n", +"Y2 = exp(log(Y2_C) + log(Y2_R));\n", +" \n", +"printf(' The activity coefficients are Y1 = %f and Y2 = %f\n',Y1,Y2);\n", +" \n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.13: Calculation_of_the_value_of_activity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.15\n", +"//Page number - 481\n", +"printf('Example - 14.15 and Page number - 481\n\n')\n", +"\n", +"//Given,\n", +"T = 25 + 273.15;//[K] - Temperature\n", +"R = 1.987;//[cal/mol*K] - Universal gas constant\n", +"//component 1 = chloroform\n", +"//component 2 = carbon tetrachloride\n", +"x_1 = 0.5;//Mole fraction of component 1 //Equimolar mixture\n", +"x_2 = 0.5;//Mole fraction of component 2\n", +"V_mol_1 = 81;//[cm^(3)/mol] - Molar volume of pure component 1\n", +"V_mol_2 = 97;//[cm^(3)/mol] - Molar volume of pure component 2\n", +"del_1 = 9.2;//[(cal/cm^(3))^(1/2)] - Mole fraction of component 1\n", +"del_2 = 8.6;//[(cal/cm^(3))^(1/2)] - Mole fraction of component 2\n", +"\n", +"//Scatchard - Hilderbrand model\n", +"phi_1 = (x_1*V_mol_1)/(x_1*V_mol_1+x_2*V_mol_2);\n", +"phi_2 = (x_2*V_mol_2)/(x_1*V_mol_1+x_2*V_mol_2);\n", +"\n", +"//log(Y1) = (V_mol_1/(R*T))*phi_1^(2)*(del_1-del_2)^(2)\n", +"Y1 = exp((V_mol_1/(R*T))*(phi_1^(2))*((del_1-del_2)^(2)));\n", +"\n", +"//Similarly, for Y2\n", +"Y2 = exp((V_mol_2/(R*T))*(phi_2^(2))*((del_1-del_2)^(2)));\n", +"\n", +"printf('The value of activity coefficients for Scatchard-Hilderbrand model are\n Y1 = %f \t and \t Y2 = %f\n\n',Y1,Y2);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.14: Calculation_of_the_value_of_activity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 14.14\n", +"//Page number - 485\n", +"printf('Example - 14.14 and Page number - 485\n\n')\n", +"//Given,\n", +"T = 25 + 273.15;//[K] - Temperature\n", +"mol_HCl = 0.001;//[mol/kg] - Molality of HCl\n", +"A = 0.510;//[(kg/mol)^(1/2)]\n", +"Z_positive = 1;//Stoichiometric coefficient of 'H' ion\n", +"Z_negative = -1;//Stoichiometric coefficient of 'Cl' ion\n", +"m_H_positive = mol_HCl;//\n", +"m_Cl_negative = mol_HCl;\n", +"// I = 1/2*[((Z_positive)^(2))*m_H_positive + ((Z_negative)^(2))*m_Cl_negative]\n", +"I = 1/2*(((Z_positive)^(2))*m_H_positive + ((Z_negative)^(2))*m_Cl_negative);\n", +"//Using Debye-Huckel limiting law wee get,\n", +"// log(Y1) = -A*(abs(Z_positive*Z_negative))*(I^(1/2)))\n", +"Y = 10^(-A*(abs(Z_positive*Z_negative))*(I^(1/2)));\n", +"printf('The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = %f\n\n',Y);\n", +"//Using Debye-Huckel extended model we get\n", +"//log(Y_prime) = (-A*(abs(Z_positive*Z_negative))*(I^(1/2)))/(1 + (I^(1/2)));\n", +"Y_prime = 10^((-A*(abs(Z_positive*Z_negative))*(I^(1/2)))/(1 + (I^(1/2))));\n", +"printf('The mean activity coefficient at 25 C using Debye-Huckel extended model is Y = %f\n\n',Y_prime);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.15: Calculation_of_the_value_of_activity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.15\n", +"//Page number - 485\n", +"printf('Example - 14.15 and Page number - 485\n\n')\n", +"\n", +"//Given,\n", +"T = 25 + 273.15;//[K] - Temperature\n", +"mol_CaCl2 = 0.001;//[mol/kg] - Molality of HCl\n", +"A = 0.510;//[(kg/mol)^(1/2)]\n", +"Z_positive = 2;//Stoichiometric coefficient of 'Ca' ion\n", +"Z_negative = -1;//Stoichiometric coefficient of 'Cl' ion\n", +"m_Ca_positive = mol_CaCl2;\n", +"m_Cl_negative = 2*mol_CaCl2;\n", +"\n", +"// I = 1/2*[((Z_positive)^(2))*m_Ca_positive + ((Z_negative)^(2))*m_Cl_negative]\n", +"I = 1/2*(((Z_positive)^(2))*m_Ca_positive + ((Z_negative)^(2))*m_Cl_negative);\n", +"\n", +"//Using Debye-Huckel limiting law wee get,\n", +"// log(Y1) = -A*(abs(Z_positive*Z_negative))*(I^(1/2)))\n", +"Y = 10^(-A*(abs(Z_positive*Z_negative))*(I^(1/2)));\n", +"printf('The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = %f\n\n',Y);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.16: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.16\n", +"//Page number - 486\n", +"printf('Example - 14.16 and Page number - 486\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 14.16 on page number 486 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 14.16 on page number 486 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.17: Calculation_of_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.17\n", +"//Page number - 488\n", +"printf('Example - 14.17 and Page number - 488\n\n');\n", +"\n", +"//Given,\n", +"T = 50 + 273.15;//[K] - Temperature\n", +"R=8.314;//[J/mol*K] - Universal gas constant\n", +"x_1 = 0.3;// Mole fraction of component 1\n", +"x_2 = (1-x_1);// Mole fraction of component 2\n", +"//Increment of 1% means Y2 = 1.01*Y1\n", +"\n", +"//Excess volume of the mixture is given by,\n", +"V_excess = 4*x_1*x_2;//[cm^(3)/mol]\n", +"//Amd threfore\n", +"V_1_excess = 4*x_2*x_2*10^(-6);//[m^(3)/mol] - Exces volume of component 1\n", +"V_2_excess = 4*x_1*x_1*10^(-6);//[m^(3)/mol] - Exces volume of component 2\n", +"\n", +"//We have from equation 14.89 of the book,\n", +"//V_i_excess/(R*T) = (del_log(Y_i)/del_P)_T,x\n", +"\n", +"//Rearranging above equation\n", +"//d(log(Y1)) = (V1_excess/(R*T))dP\n", +"//Integrating the above equation at constant 'T' and 'x' in the limit from 'Y1' to '1.01*Y1' in the LHS and from 'P' to 'P+delta_P' in the RHS\n", +"//On simplification we get\n", +"//log(1.01*Y1/Y1) = (V_1_exces/(R*T))*delta_P\n", +"delta_P = log(1.01)/(V_1_excess/(R*T));//[N/m^(2)]\n", +"delta_P = delta_P*10^(-6);//[MPa]\n", +"\n", +"printf('The required pressure to increase the activity coefficient by 1%% is %f MPa',delta_P);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.18: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.18\n", +"//Page number - 488\n", +"printf('Example - 14.18 and Page number - 488\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 14.18 on page number 488 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 14.18 on page number 488 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.19: Determination_of_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.19\n", +"//Page number - 489\n", +"printf('Example - 14.19 and Page number - 489\n\n');\n", +"\n", +"//given\n", +"P = 2;//[bar] - Pressure\n", +"T = 310;//[K] - Temperature\n", +"R=8.314;//[J/mol*K] - Universal gas constant\n", +"A = (0.1665 + 233.74/T);// Margules parameter\n", +"B = (0.5908 + 197.55/T);// Margules parameter\n", +"\n", +"//two parameter Margules equation is given by\n", +"//G_excess/(R*T*x_1*x_2) = B*x_1 + A*x_2\n", +"//On simplification and putting the values we get\n", +"//G_excess = ((0.5908 + 197.55/T)*x_1^(2)*x_2 + (0.1665 + 233.74/T)*x_2^(2)*x_1)\n", +"\n", +"\n", +"//H_excess/(R*T^(2)) = -[d/dT(G_excess/(R*T*x_1*x_2))]_P,x\n", +"//On simplification and putting the values we get\n", +"//H_excess/(R*T^(2)) = (197.55/T^(2))*x_1^(2)*x_2 + (233.74/T^(2))*x_1*x_2^(2)\n", +"\n", +"//We know that enthalpy change of mixing is given by\n", +"// delta_H_mix = H - x_1*H_1 - x_2*H_2 = delta_H_id_mix + H_excess\n", +"\n", +"//But, delta_H_id_mix = 0 and H_excess is positive , therefore enthalpy of muxture\n", +"// H > (x_1*H_1 + x_2*H_2)\n", +"//Therefore heat is required during the formation of mixture\n", +"\n", +"printf('Since enthalpy of mixture formation (H) comes out to be positive, threfore steam is required to maintain the constant temperature.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.1: Determination_of_expression_for_activity_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.1\n", +"//Page number - 455\n", +"printf('Example - 14.1 and Page number - 455\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 14.1 on page number 455 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 14.1 on page number 455 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.20: Determination_of_an_expression.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.20\n", +"//Page number - 490\n", +"printf('Example - 14.20 and Page number - 490\n\n');\n", +"\n", +"T = 40 + 273.15;//[K]\n", +"P = 101.3;//[kPa]\n", +"\n", +"// G_E/(R*T) = A*x_1*x_2\n", +"\n", +"// The parameter A at 101.3 kPa and various temperatures are\n", +"A_35 = 0.479;// A at 35 C\n", +"A_40 = 0.458;// A at 40 C\n", +"A_45 = 0.439;// A at 45 C\n", +"\n", +"// At 40 C, G_E/(R*T) is given by\n", +"// G_E/(R*T) = A_40*x1*x2\n", +"// Therefore log(Y1) = A_40*x2^(2) and log(Y2) = A_40*x1^(2)\n", +"\n", +"dA_dT = (A_45-A_35)/(45-35);//[K^(-1)] - dA/dT\n", +"// H_E/(R*T^(2)) = -[del(G_E/(R*T))/del(T)]_P,x = (dA/dT)*x1*x2\n", +"// H_E/(R*T) = -T*(dA/dT)*x1*x2 = 1.25*x1*x2\n", +"\n", +"// S_E = (H_E - G_E)/T = (-R*T^(2)*(dA/dT)*x1*x2 - A*R*T*x1*x2)/T = -(R*T*(dA/dT) + A*R)*x1*x2\n", +"// Thus S_E/R = -(T*(dA/dT) + A)*x1*x2 = 0.795*x1*x2\n", +"\n", +"printf(' The expressions are H_E/(R*T) = 1.25*x1*x2 \n\t\t S_E/R = 0.795*x1*x2');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.21: Calculation_of_enthalpy_entropy_and_Gibbs_free_energy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.21\n", +"//Page number - 490\n", +"printf('Example - 14.21 and Page number - 490\n\n');\n", +"\n", +"//given\n", +"T = 293.15;//[K] - Temperature\n", +"R=8.314;//[J/mol*K] - Universal gas constant\n", +"A = 1280;//[J/mol]\n", +"\n", +"//(dA/dT)_P,x = del_A (say)\n", +"dA_dT = -7.0;//[J/mol-K]\n", +"\n", +"//For equilomar mixture,\n", +"x_1 = 0.5;// Mole fraction of component 1\n", +"x_2 = 0.5;// Mole fraction of component 2\n", +"\n", +"//log(Y1) = (A/(R*T))*x_2^(2)\n", +"//log(Y2) = (A/(R*T))*x_1^(2)\n", +"Y1 = exp((A/(R*T))*x_2^(2));\n", +"Y2 = exp((A/(R*T))*x_1^(2));\n", +"\n", +"//G_excess/(R*T*) = x_1*log(Y1) + x_2*log(Y2) = (A/(R*T))*x_1*x_2\n", +"G_excess = A*x_1*x_2;//[J/mol] - Excess Gibbs free energy\n", +"\n", +"//H_excess/(R*T^(2)) = -[d/dT(G_excess/(R*T))]_P,x\n", +"//H_excess/(R*T^(2)) = -((x_1*x_2)/R)*[d/dT(A/T)]_P,x\n", +"//On simplification and putting the values we get\n", +"H_excess = A*x_1*x_2 - T*dA_dT*x_1*x_2;//[J/mol] - Excess enthalpy\n", +"\n", +"//Now excess entropy is given by\n", +"S_excess = (H_excess - G_excess)/T;//[J/mol-K] - Excess entropy\n", +"\n", +"printf('For equimolar mixture\n\n');\n", +"printf('Excess Gibbs free energy (G_excess) is %f J/mol\n\n',G_excess);\n", +"printf('Excess enthalpy (H_excess) is %f J/mol\n\n',H_excess);\n", +"printf('Excess entropy (S_excess) is %f J/mol\n\n',S_excess);\n", +"printf('The value of activity coefficient Y1 is %f\n\n',Y1);\n", +"printf('The value of activity coefficient Y2 is %f\n\n',Y2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.22: Determination_of_Gibbs_free_energy_and_enthalpy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"// Example - 14.22\n", +"// Page number - 491\n", +"printf('Example - 14.22 and Page number - 491\n\n');\n", +"\n", +"// Given\n", +"T = 60 + 273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// log(Y1_inf) = log(Y2_inf) = 0.15 + 10/T\n", +"\n", +"// Since the two liquids are slightly dissimilar , we assume the activity coeffiecients to follow van Laar equation \n", +"// From van Laaar equation \n", +"// A = log(Y1_inf) and B = log(Y2_inf) and since it is given that log(Y1_inf) = log(Y2_inf), therefore A = B\n", +"//(x_1*x_2)/(G_excess/R*T) = x_1/B + x_2/A = X_1/A + x_2/A = 1/A\n", +"// G_excess/(R*T) = A*x_1*x_2\n", +"\n", +"// For equilomar mixture,\n", +"x_1 = 0.5;// Mole fraction of component 1\n", +"x_2 = 0.5;// Mole fraction of component 2\n", +"\n", +"// Expression for A can be written as\n", +"// A = 0.15 + 10/T, where T is in C. Therefore\n", +"A = 0.15 + 10/(T - 273.15);\n", +"// Differentiating it with respect to temprature we get\n", +"dA_dT = - 10/((T-273.15)^(2));\n", +"\n", +"// The excess Gibbs free energy can be calculated as\n", +"G_excess = A*x_1*x_2*(R*T);//[J/mol]\n", +"\n", +"// The ideal Gibbs free energy change can be calculated as\n", +"delta_G_id_mix = R*T*(x_1*log(x_1) + x_2*log(x_2));//[J/mol]\n", +"\n", +"// Finally we have,\n", +"delta_G_mix = G_excess + delta_G_id_mix;//[J/mol]\n", +"\n", +"printf('The Gibbs free energy change of mixing for equimolar mixture is %f J/mol\n\n',delta_G_mix);\n", +"\n", +"\n", +"// Now let us determine the excess enthalpy. We know that\n", +"// H_excess/(R*T^(2)) = -[d/dT(G_excess/R*T)]_P,x = - x_1*x_2*[d/dT(A)]_P,x\n", +"// Therefore at 'T' = 60 C the excess enthalpy is given by\n", +"H_excess = -R*(T^(2))*x_1*x_2*dA_dT;//[J/mol]\n", +"\n", +"delta_H_id_mix = 0;//[J/mol] - Enthalpy change of mixing for ideal solution is zero.\n", +"\n", +"//Thus enthalpy change of mixing for an equimolar mixture at 333.15 K is given by\n", +"delta_H_mix = delta_H_id_mix + H_excess;//[J/mol]\n", +"\n", +"\n", +"printf('The enthalpy change of mixing for equimolar mixture is %f J/mol',delta_H_mix);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.2: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.2\n", +"//Page number - 456\n", +"printf('Example - 14.2 and Page number - 456\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 14.2 on page number 456 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 14.2 on page number 456 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.3: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.3\n", +"//Page number - 458\n", +"printf('Example - 14.3 and Page number - 458\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 14.3 on page number 458 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 14.3 on page number 458 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.4: Determination_of_value_of_Gibbs_free_energy_change_and_enthalpy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.4\n", +"//Page number - 461\n", +"printf('Example - 14.4 and Page number - 461\n\n');\n", +"\n", +"//Given,\n", +"T = 300;//[K] - Temperature\n", +"b = 100;//[cal/mol]\n", +"R = 1.987;//[cal/mol*K] - Universal gas constant\n", +"// R*T*log(Y_1) = b*x_2^(2)\n", +"// R*T*log(Y_2) = b*x_1^(2)\n", +"\n", +"//For equimolar mixture\n", +"x_1 = 0.5;//Mole fraction of component 1\n", +"x_2 = 0.5;//Mole fraction of component 2\n", +"\n", +"//The excess Gibbs free energy is given by\n", +"// G_excess = R*T*(x_1*log(Y_1) + x_2*log(Y_2)) = b*x_1*x_2^(2) + b*x_2*x_1^(2) = b*x_1*(x_1 + x_2) = b*x_1*x_2\n", +"G_excess = b*x_1*x_2;//[cal/mol]\n", +"\n", +"//The ideal Gibbs free energy change of mixing is given by,\n", +"delta_G_id_mix = R*T*(x_1*log(x_1)+x_2*log(x_2));//[cal/mol]\n", +"\n", +"//The Gibbs free energy of mixing is given by\n", +"delta_G_mix = delta_G_id_mix + G_excess;//[cal/mol]\n", +"\n", +"//It is given that entropy change of mixing is that of ideal mixture,therefore\n", +"// delta_S_mix = delta_S_id_mix = - R*sum(x_i*log(x_i))\n", +"\n", +"//delta_G_mix = delta_H_mix - T*delta_S_mix = delta_H_mix + R*T*(x_1*log(x_1)+x_2*log(x_2))\n", +"delta_H_mix = b*x_1*x_2;//[cal/mol]\n", +"\n", +"printf('The value of Gibbs free energy change for equimolar mixture formation is %f cal/mol\n\n',delta_G_mix);\n", +"printf('The value of enthalpy change for equimolar mixture formation is %f cal/mol\n\n',delta_H_mix);\n", +"\n", +"//Work required for separation of mixture into pure components is\n", +"W = delta_G_mix;\n", +"printf('The least amount of work required for separation at 300 K is %f cal/mol\n\n',W);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.5: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.5\n", +"//Page number - 461\n", +"printf('Example - 14.5 and Page number - 461\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 14.5 on page number 461 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 14.5 on page number 461 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.6: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.6\n", +"//Page number - 463\n", +"printf('Example - 14.6 and Page number - 463\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 14.6 on page number 463 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 14.6 on page number 463 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.7: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.7\n", +"//Page number - 464\n", +"printf('Example - 14.7 and Page number - 464\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 14.7 on page number 464 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 14.7 on page number 464 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.8: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.8\n", +"//Page number - 465\n", +"printf('Example - 14.8 and Page number - 465\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 14.8 on page number 465 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 14.8 on page number 465 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 14.9: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 14.9\n", +"//Page number - 465\n", +"printf('Example - 14.9 and Page number - 465\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 14.9 on page number 465 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 14.9 on page number 465 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 +} 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 +} 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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/17-Chemical_Reactions_Equilibria.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/17-Chemical_Reactions_Equilibria.ipynb new file mode 100644 index 0000000..15764a5 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/17-Chemical_Reactions_Equilibria.ipynb @@ -0,0 +1,2047 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 17: Chemical Reactions Equilibria" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.10: Tabulation_of_equilibrium_constant_values.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.10\n", +"//Page number - 609\n", +"printf('Example - 17.10 and Page number - 606\n\n');\n", +"\n", +"// Given\n", +"// (1/2)*N2 + (1/2)*O2 - NO\n", +"\n", +"R = 1.987;//[cal/mol-K]\n", +"\n", +"delta_H_NO_298 = 21.600;//[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n", +"delta_G_NO_298 = 20.719;//[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n", +"\n", +"// Cp_0 = a + b*T + c*T^(2) + d*T^(3)\n", +"\n", +"a_N2 = 6.157;\n", +"a_O2 = 6.085;\n", +"a_NO = 6.461;\n", +"b_N2 = -0.03753*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"b_NO = 0.2358*10^(-2);\n", +"c_N2 = 0.1930*10^(-5);\n", +"c_O2 = -0.1709*10^(-5);\n", +"c_NO = -0.07705*10^(-5);\n", +"d_N2 = -0.6861*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"d_NO = 0.08729*10^(-9);\n", +"\n", +"//(1)\n", +"T_1 = 298.15;//[K]\n", +"\n", +"delta_H_rkn_298 = delta_H_NO_298;//[kcal]\n", +"delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", +"delta_G_rkn_298 = delta_G_NO_298;//[kcal]\n", +"delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", +"\n", +"delta_a = a_NO - (a_N2/2) - (a_O2/2);\n", +"delta_b = b_NO - (b_N2/2) - (b_O2/2);\n", +"delta_c = c_NO - (c_N2/2) - (c_O2/2);\n", +"delta_d = d_NO - (d_N2/2) - (d_O2/2);\n", +"\n", +"// delta_H_rkn_T = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T);\n", +"// On simplification we get\n", +"// delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10^(-2)*T^(2) - 0.0293*10^(-5)*T^(3) + 0.0685*10^(-9)*T^(4)\n", +"\n", +"printf(' The expression for delta_H_rkn_T as a function of T is given by\n');\n", +"printf(' delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10^(-2)*T^(2) - 0.0293*10^(-5)*T^(3) + 0.0685*10^(-9)*T^(4)\n\n');\n", +"\n", +"// Now let us calculate K_298 (at 298 K)\n", +"// We know delta_G_rkn_298 = -R*T*log(K_298) \n", +"K_298 = exp(-delta_G_rkn_298/(R*T_1));// Equilibrium constant at 298.15 K\n", +"\n", +"// log(K_2/K_1) = integrate('delta_H_rkn_298/(R*T^(2))','T',T_1,T)\n", +"// On substituting the values and simplifying we get the expression\n", +"// log(K) = 1.5103 - 10862.92/T - 0.0166*log(T) + 1.84*10^(-4)*T - 7.35*10^(-8)*T^(2) + 1.15*10^(-11)*T^(3)\n", +"\n", +"printf(' The expression for log(K) as a function of T is given by\n');\n", +"printf(' log(K) = 1.5103 - 10862.92/T - 0.0166*log(T) + 1.84*10^(-4)*T - 7.35*10^(-8)*T^(2) + 1.15*10^(-11)*T^(3)\n\n\n\n')\n", +"\n", +"T = [500,1000,1500,2000,2500];\n", +"K = zeros(5);\n", +"\n", +"printf(' T (K) \t\t\t K \n\n');\n", +"\n", +"for i=1:5;\n", +" K(i) = exp(1.5103-10862.92/T(i) - 0.0166*log(T(i)) + 1.84*10^(-4)*T(i) - 7.35*10^(-8)*T(i)^(2) + 1.15*10^(-11)*T(i)^(3));\n", +" \n", +" printf(' %f \t\t %e \n\n',T(i),K(i));\n", +"end\n", +"\n", +"printf('\n\n');\n", +"\n", +"// It can be seen that for endothermic reactions equilibrium constant increases with temperature.\n", +"printf(' It can be seen that for endothermic reactions equilibrium constant increases with temperature\n');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.11: Determination_of_mean_standard_enthalpy_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.11\n", +"//Page number - 611\n", +"printf('Example - 17.11 and Page number - 611\n\n');\n", +"\n", +"// Given\n", +"// SO2 + (1/2)*O2 - SO3\n", +"R = 8.314;//[J/mol-K]\n", +"\n", +"K_800 = 0.0319;// Equilibrium constant at 800 K\n", +"K_900 = 0.153;// Equilibrium constant at 900 K\n", +"T_1 = 800;//[K]\n", +"T_2 = 900;//[K]\n", +"\n", +"// We have the relation \n", +"// log(K_2/K_1) = -(delta_H_rkn/R)*(1/T_2 - 1/T_1)\n", +"// log(K_900/K_800) = -(delta_H_rkn_850/R)*(1/T_2 - 1/T_1)\n", +"delta_H_rkn_850 = -R*log(K_900/K_800)/(1/T_2 - 1/T_1);//[J]\n", +"delta_H_rkn_850 = delta_H_rkn_850*10^(-3);//[kJ]\n", +"\n", +"printf(' The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = %f \n',delta_H_rkn_850);\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.12: Derivation_of_expression_for_enthalpy_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.12\n", +"//Page number - 611\n", +"printf('Example - 17.12 and Page number - 611\n\n');\n", +"\n", +"// Given\n", +"// log(K) = -2.61 + 23672.62/T - 7.17*log(T) + 1.24*10^(-2)*T - 0.148*10^(-5)*T^(2) + 0.039*10^(-9)*T^(3)\n", +"\n", +"// We know that\n", +"// dlog(K)/dT = delta_H_rkn/(R*T^(2))\n", +"\n", +"// Differentiating the above expression of log(K),we get\n", +"// dlog(K)/dT = -23672.62/T^(2) - 7.17/T + 1.24*10^(-2) - 2*0.148*10^(-5)*T + 3*0.039*10^(-9)*T^(2)\n", +"\n", +"// On further simplification we get \n", +"// delta_H_rkn = -47037.5 - 14.24*T + 2.46*10^(-2)*T^(2) - 0.59*10^(-5)*T^(3) + 0.23*10^(-9)*T^(4)\n", +"printf(' delta_H_rkn = -47037.5 - 14.24*T + 2.46*10^(-2)*T^(2) - 0.59*10^(-5)*T^(3) + 0.23*10^(-9)*T^(4)\n');\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.13: Determination_of_equilibrium_composition.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.13\n", +"//Page number - 611\n", +"printf('Example - 17.13 and Page number - 611\n\n');\n", +"\n", +"// Given\n", +"T_1 = 298.15;//[K]\n", +"T = 2600;//[K]\n", +"R = 1.987;//[cal/mol-K] - Universal gas constant\n", +"\n", +"// Cp_0 = a + b*T + c*T^(2) + d*T^(3)\n", +"delta_H_CO_298 = -26.416;//[kcal/mol] - Enthalpy of formation of CO at 298.15 K\n", +"delta_G_CO_298 = -32.808;//[kcal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n", +"delta_H_CO2_298 = -94.052;//[kcal/mol] - Enthalpy of formation of C02 at 298.15 K\n", +"delta_G_CO2_298 = -94.260;//[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n", +"\n", +"// CO + (1/2)*O2 - CO2\n", +"\n", +"a_CO = 6.726;\n", +"a_O2 = 6.0685;\n", +"a_CO2 = 5.316;\n", +"b_CO = 0.04001*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"b_CO2 = 1.4285*10^(-2);\n", +"c_CO = 0.1283*10^(-5);\n", +"c_O2 = -0.1709*10^(-5);\n", +"c_CO2 = -0.8362*10^(-5);\n", +"d_CO = -0.5307*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"d_CO2 = 1.784*10^(-9);\n", +"\n", +"\n", +"delta_H_rkn_298 = delta_H_CO2_298 - delta_H_CO_298;//[kcal]\n", +"delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", +"delta_G_rkn_298 = delta_G_CO2_298 - delta_G_CO_298;//[kcal]\n", +"delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", +"\n", +"delta_a = a_CO2 - (a_CO) - (a_O2/2);\n", +"delta_b = b_CO2 - (b_CO) - (b_O2/2);\n", +"delta_c = c_CO2 - (c_CO) - (c_O2/2);\n", +"delta_d = d_CO2 - (d_CO) - (d_O2/2);\n", +"\n", +"// delta_H_rkn_T = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T);\n", +"// On simplification we get\n", +"delta_H_rkn_T = -66773.56 - 4.45*T + 0.605*10^(-2)*T^(2) - 0.29*10^(-5)*T^(3) + 0.54*10^(-9)*T^(4);\n", +"\n", +"// log(K/K_298) = integrate('delta_H_rkn_T/(R*T^(2))','T',T_1,T)\n", +"\n", +"// We know that delta_G_rkn_T = -R*T*log(K)\n", +"// At 298.15 K\n", +"K_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", +"\n", +"// Therfore on simplification we get\n", +"//log(K) = 2.94 + 33605.2/T - 2.24*log(T) + 0.304*10(-2)*T - 0.073*10^(-5)*T^(2) + 0.09*10^(-9)*T^(3)\n", +"K = exp(2.94 + 33605.2/T - 2.24*log(T) + 0.304*10^(-2)*T - 0.073*10^(-5)*T^(2) + 0.09*10^(-9)*T^(3));\n", +"\n", +"printf(' The value of equilibrium constant at 2600 K is given by, K_298 = %f\n\n',K);\n", +"\n", +"\n", +"//(a)\n", +"P_1 = 1;//[atm]\n", +"Kp_1 = P_1^(-1/2);\n", +"Ky_1 = K/Kp_1;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_CO_1_eq = 1 - X\n", +"// n_02_1_eq = 0.5- 0.5X\n", +"// n_CO2_1_eq = X\n", +"// Total moles = 1.5 - 0.5*X\n", +"\n", +"// Ky = y_CO2/(y_CO^(1/2)*y_CO)\n", +"//ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", +"\n", +"deff('[y]=f(X)','y= Ky_1-(X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", +"X_1 = fsolve(0.9,f);\n", +"\n", +"y_CO2_1 = X_1/(1.5-0.5*X_1);\n", +"y_CO_1 = (1-X_1)/(1.5-0.5*X_1);\n", +"y_O2_1 = (0.5-0.5*X_1)/(1.5-0.5*X_1);\n", +"\n", +"printf(' (a).The equilibrium composition (at 1 atm) is given by, y_CO2 = %f, y_CO = %f and y_O2 = %f\n\n',y_CO2_1,y_CO_1,y_O2_1);\n", +"\n", +"//(b)\n", +"P_2 = 10;//[atm]\n", +"Kp_2 = P_2^(-1/2);\n", +"Ky_2 = K/Kp_2;\n", +"\n", +"// Ky = y_CO2/(y_CO^(1/2)*y_CO)\n", +"//ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", +"\n", +"deff('[y]=f1(X)','y= Ky_2-(X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", +"X_2 = fsolve(0.9,f1);\n", +"\n", +"y_CO2_2 = X_2/(1.5-0.5*X_2);\n", +"y_CO_2 = (1-X_2)/(1.5-0.5*X_2);\n", +"y_O2_2 = (0.5-0.5*X_2)/(1.5-0.5*X_2);\n", +"\n", +"printf(' (b).The equilibrium composition (at 10 atm) is given by, y_CO2 = %f, y_CO = %f and y_O2 = %f\n\n',y_CO2_2,y_CO_2,y_O2_2);\n", +"\n", +"//(c)\n", +"P_3 = 1;//[atm]\n", +"Kp_3 = P_3^(-1/2);\n", +"Ky_3 = K/Kp_3;\n", +"\n", +"// Ky = y_CO2/(y_CO^(1/2)*y_CO)\n", +"//ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", +"\n", +"// At equilibrium, the moles of the components be\n", +"// n_CO_3_eq = 1 - X\n", +"// n_02_3_eq = 0.5- 0.5X\n", +"// n_CO2_3_eq = X\n", +"// n_N2_eq = 1;\n", +"// Total moles = 2.5 - 0.5*X\n", +"\n", +"deff('[y]=f2(X)','y= Ky_3-(X*(2.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", +"X_3 = fsolve(0.9,f2);\n", +"\n", +"y_CO2_3 = X_3/(2.5-0.5*X_3);\n", +"y_CO_3 = (1-X_3)/(2.5-0.5*X_3);\n", +"y_O2_3 = (0.5-0.5*X_3)/(2.5-0.5*X_3);\n", +"y_N2 = 1/(2.5-0.5*X_3);\n", +"\n", +"printf(' (c).The equilibrium composition (at 1 atm and 1 mol N2) is given by, y_CO2 = %f, y_CO = %f , y_O2 = %f and y_N2 = %f\n\n',y_CO2_3,y_CO_3,y_O2_3,y_N2);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.14: Determination_of_equilibrium_composition.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.14\n", +"//Page number - 614\n", +"printf('Example - 17.14 and Page number - 614\n\n');\n", +"\n", +"// Given\n", +"T = 25 + 298.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol-K]\n", +"delta_G_298 = -1000;//[J] - Gibbs free energy change at 298 K\n", +"\n", +"// G_E/(R*T) = x_1*x_2\n", +"\n", +"// We know that delta_G_rkn = - R*T*log(K), therefore\n", +"K = exp(-delta_G_298/(R*T));\n", +"\n", +"//(1)\n", +"// Let x_1 is the mole fraction of A and x_2 be the mole fraction of B\n", +"// If A and B form an ideal mixture then,\n", +"Ky = 1;\n", +"// and K = Kx = x_2/x_1\n", +"// and at equilibrium x_2/x_1 = K\n", +"// (1-x_1)/x_1 = K\n", +"x_1 = 1/(1+K);\n", +"\n", +"printf(' (1).The equilibrium composition (for ideal behaviour) is given by x_1 = %f\n\n',x_1);\n", +"\n", +"//(2)\n", +"// The activity coefficients are given by\n", +"// log(Y1) = [del(n*G_E/(R*T))/del(n_1)]_T,P,n_2 = x_2^(2)\n", +"// similarly, log(Y2) = x_1^(2)\n", +"\n", +"// The equilibrium constant for the liquid phase reaction is given by\n", +"// K = Kx*Ky = (x_2*Y2)/(x_1*Y1) = (x_2*exp(x_1^(2)))/(x_1*exp(x_2^(2)))\n", +"// Solving the above equation we get\n", +"\n", +"deff('[y]=f2(x_1)','y= K -((1-x_1)*exp(x_1^(2)))/(x_1*exp((1-x_1)^(2)))');\n", +"x_1_prime = fsolve(0.9,f2);\n", +"\n", +"printf(' (2).The equilibrium composition (for non-ideal behaviour) is given by x_1 = %f\n\n',x_1_prime);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.15: Determination_of_the.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.15\n", +"//Page number - 615\n", +"printf('Example - 17.15 and Page number - 615\n\n');\n", +"\n", +"// Given\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"T_2 = 373;//[K] - Reaction temperature\n", +"P = 1;//[atm]\n", +"R = 1.987;//[cal/mol-K] - Universal gas constant\n", +"\n", +"// CH3COOH (l) + C2H5OH (l) - CH3COOC2H5 (l) + H2O (l)\n", +"\n", +"delta_H_CH3COOH_298 = -116.2*10^(3);// [cal/mol]\n", +"delta_H_C2H5OH_298 = -66.35*10^(3);// [cal/mol]\n", +"delta_H_CH3COOC2H5_298 = -110.72*10^(3);// [cal/mol]\n", +"delta_H_H2O_298 = -68.3174*10^(3);// [cal/mol]\n", +"\n", +"delta_G_CH3COOH_298 = -93.56*10^(3);// [cal/mol]\n", +"delta_G_C2H5OH_298 = -41.76*10^(3);// [cal/mol]\n", +"delta_G_CH3COOC2H5_298 = -76.11*10^(3);// [cal/mol]\n", +"delta_G_H2O_298 = -56.6899*10^(3);// [cal/mol]\n", +"\n", +"delta_H_rkn_298 = delta_H_CH3COOC2H5_298 + delta_H_H2O_298 - delta_H_CH3COOH_298 - delta_H_C2H5OH_298;//[cal/mol]\n", +"delta_G_rkn_298 = delta_G_CH3COOC2H5_298 + delta_G_H2O_298 - delta_G_CH3COOH_298 - delta_G_C2H5OH_298;//[cal/mol]\n", +"\n", +"// We know that delta_G_rkn_T = -R*T*log(K)\n", +"// At 298.15 K\n", +"K_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", +"\n", +"// We know that dlog(K)/dT = delta_H_rkn/(R*T^(2))\n", +"// If delta_H_rkn is assumed constant we get\n", +"// log(K_2/K_1) = (-delta_H_rkn/R)*(1/T_2 - 1/T_1)\n", +"// log(K_373/K_298) = (-delta_H_rkn_298/R)*(1/T_2 - 1/T_1)\n", +"\n", +"K_373 = exp(log(K_298) + (-delta_H_rkn_298/R)*(1/T_2 - 1/T_1));\n", +"// Note that the equilibrium constant value rises becauses the reaction is endothermic\n", +"\n", +"printf(' The value of equilibrium constant at 373 K is , K_373 = %f\n\n',K_373);\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_CH3COOH = 1 - X\n", +"// n_C2H5OH = 1 - X\n", +"// n_CH3COOC2H5 = X\n", +"// n_H20 = X\n", +"// Total moles = 2\n", +"\n", +"// Kx = (x_CH3COOH*x_C2H5OH)/(x_CH3COOC2H5*x_H2O)\n", +"// Assuming the liquid mixture to be ideal,that is Ky = 1, therefore K_x = K\n", +"K_x = K_373;\n", +"// X^(2)/(1-X)^(2) = K_x\n", +"X = (K_x)^(1/2)/(1+(K_x)^(1/2));\n", +"\n", +"// The mole fraction of ethyl acetate is given by\n", +"x_CH3COOC2H5 = X/2;\n", +"\n", +"printf(' The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by, x_CH3COOC2H5 = %f\n',x_CH3COOC2H5);\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.16: Calculation_of_the_value_of_Gibbs_free_energy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.16\n", +"//Page number - 617\n", +"printf('Example - 17.16 and Page number - 617\n\n');\n", +"\n", +"// Given\n", +"// CaCO3 (s1) - CaO (s2) + CO2 (g)\n", +"T_1 = 898 + 273.15;//[K]\n", +"T_2 = 700 + 273.15;//[K]\n", +"R = 8.314;//[J/mol-K] - Universal gas constant\n", +"\n", +"P_CO2_T_1 = 1;//[atm] - Decomposition pressure of CO2 over CaCO3 at 898 C\n", +"P_CO2_T_2 = 0.0333;//[atm] - Decomposition pressure of CO2 over CaCO3 at 700 C\n", +"\n", +"// The equilibrium constant of the reaction is given by\n", +"// K = (a_CO2*a_CaO)/a_CaCO3\n", +"\n", +"// Since the pressure is small therefore carbon dioxide can be assumed to behave as ideal gas and thus\n", +"// a_CO2 = y_CO2*P/1 = P_CO2\n", +"\n", +"// The activity of CaO is (CaO is pure)\n", +"// a_CaO = f_CaO/f_0_CaO = exp[V_CaO*(P - P_0)/(R*T)] = 1 (since pressure is low)\n", +"\n", +"// The activity of CaCO3 is (CaCO3 is pure)\n", +"// a_CaCO3 = f_CaCO3/f_0_CaCO3 = exp[V_CaCO3*(P - P_0)/(R*T)] = 1 (since pressure is low)\n", +"\n", +"//Since pressures are around 1 atm,therefore Poynting factors are also near 1, and thus activity of CaO and CaCO3 is unity and equilibrium constant is given by\n", +"//K = P_CO2 , therefore\n", +" \n", +"// At 898 C\n", +"K_T_1 = P_CO2_T_1;\n", +"delta_G_T_1 = -R*T_1*log(K_T_1);\n", +"\n", +"// At 700 C\n", +"K_T_2 = P_CO2_T_2;\n", +"delta_G_T_2 = -R*T_2*log(K_T_2);\n", +"\n", +"printf(' The value of delta_G_rkn at 700 C is %f J\n\n',delta_G_T_1);\n", +"printf(' The value of delta_G_rkn at 898 C is %f J\n\n',delta_G_T_2);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.17: Calculation_of_nu.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.17\n", +"//Page number - 618\n", +"printf('Example - 17.17 and Page number - 618\n\n');\n", +"\n", +"// Given\n", +"T = 700 + 273.15;//[K]\n", +"K = 7.403;// Equilibrium constant for the reaction at 700 C\n", +"\n", +"// CH4 - C (s) + 2*H2 \n", +"\n", +"// The equilibrium constant of the reaction is given by\n", +"// K = (a_C*a_H2^(2))/a_CH4\n", +"\n", +"// Since carbon is pure therefore its activity is given by\n", +"// a_C = f/f_0 = 1 as pressure is 1 atm.\n", +"// Since the pressure is low,therefore the gas phase can be taken to be ideal,therefore\n", +"// K = (y_H2^(2)*P^(2))/(y_CH4*P) = y_H2^(2)/y_CH4 (as P = 1 atm)\n", +"Ky = K;// (Kp = 1 atm)\n", +"\n", +"// Initial moles of the species are\n", +"n_CH4 = 1;\n", +"n_H2 = 0;\n", +"n_C = 0;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// Moles at equilibrium be\n", +"// n_CH4_eq = 1 -X\n", +"// n_H2_eq = 2*x\n", +"// n_C_eq = X\n", +"\n", +"// Moles present in gas phase\n", +"// n_CH4_gas = 1 -X\n", +"// n_H2_gas = 2*x\n", +"// Total moles = 1 + X\n", +"\n", +"// gas phase mole fraction \n", +"// y_CH4_gas = (1 -X)/(1+X)\n", +"// y_H2_gas = 2*x/(1+X)\n", +"\n", +"// Ky = y_H2_gas^(2)/y_CH4_gaS\n", +"X = (K/(4+K))^(1/2);\n", +"\n", +"printf(' The number of moles of carbon black formed from one mole of methane is %f mol\n\n',X);\n", +"\n", +"// Therefore mole fraction of components in the gas phase at equilibrium is \n", +"y_CH4 = (1-X)/(1+X);\n", +"y_H2 = 2*X/(1+X);\n", +"\n", +"printf(' The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = %f and y_H2 = %f \n',y_CH4,y_H2);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.18: Determination_of_value_of_the_equilibrium_constant.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.18\n", +"//Page number - 619\n", +"printf('Example - 17.18 and Page number - 619\n\n');\n", +"\n", +"// Given\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"T_2 = 1042;//[K] - Reaction temperature\n", +"R = 1.987;//[cal/mol-K] - Universal gas constant\n", +"\n", +"// CaCO3 (s1) - CaO (s2) + CO2 (g)\n", +"\n", +"delta_H_CaCO3_298 = -289.5;//[kcal/mol] - Enthalpy of formation of CaCO3 at 298.15 K\n", +"delta_H_CaO_298 = -151.7;//[kcal/mol] - Enthalpy of formation of CaO at 298.15 K\n", +"delta_H_CO2_298 = -94.052;//[kcal/mol] - Enthalpy of formation of CO2 at 298.15 K\n", +"delta_G_CaCO3_298 = -270.8;//[kcal/mol] - Gibbs free energy change for formation of CaCO3 at 298.15 K\n", +"delta_G_CaO_298 = -144.3;//[kcal/mol] - Gibbs free energy change for formation of CaO at 298.15 K\n", +"delta_G_CO2_298 = -94.260;//[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n", +"\n", +"// The standard heat capacity data as a function of temperature are given below\n", +"// Cp_CO2 = 5.316 + 1.4285*10^(2)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3)\n", +"// Cp_CaO = 12.129 + 0.88*10^(-3)*T - 2.08*10^(5)*T^(-2)\n", +"// Cp_CaCO3 = 24.98 + 5.240*10^(-3)*T - 6.199*10^(5)*T^(-2)\n", +"// Therefore Cp_0 is given by\n", +"// Cp_0 = Cp_CO2 + Cp_CaO - Cp_CaCO3\n", +"// Cp_0 = -7.535 + 9.925*10^(-3)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3) + 4.119*10^(5)*T^(-2)\n", +"\n", +"// The standard enthalpy change of the reaction at 298.15 K is given by\n", +"delta_H_rkn_298 = delta_H_CO2_298 + delta_H_CaO_298 - delta_H_CaCO3_298;//[kcal]\n", +"delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", +"delta_G_rkn_298 = delta_G_CO2_298 + delta_G_CaO_298 - delta_G_CaCO3_298;//[kcal]\n", +"delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", +"\n", +"// The standard enthalpy change of the reaction at temperature T is given by\n", +"// delta_H_rkn_T = delta_H_rkn_298 + integrate('-7.535 + 9.925*10^(-3)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3) + 4.119*10^(5)*T^(-2)','T',T_1,T);\n", +"// On simplification we get\n", +"// delta_H_rkn_T = 47005.3 - 7.535*T + 4.9625*10^(-3)*T^(2) - 0.2787*10^(-5)*T^(3) + 0.446*10^(-9)*T^(4) - 4.119*10^(5)*T^(-1)\n", +"\n", +"\n", +"// log(K_2/K_1) = integrate('delta_H_rkn_T/(R*T^(2))','T',T_1,T)\n", +"log_K2_K1 = integrate('(47005.3-7.535*T+4.9625*10^(-3)*T^(2)-0.2787*10^(-5)*T^(3)+0.446*10^(-9)*T^(4) - 4.119*10^(5)*T^(-1))/T^(2)','T',T_1,T_2);// log(K_2/K_1)\n", +"\n", +"// We know that delta_G_rkn_T = -R*T*log(K)\n", +"// At 298.15 K\n", +"K_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", +"\n", +"// Putting the values in the above expression we get\n", +"// log(K_1042/K_298) = log_K2_K1/R\n", +"K_1042 = K_298*exp(log_K2_K1/R);\n", +"\n", +"printf(' The value of equilibrium constant at 1042 K is, K_1042 = %f\n\n',K_1042);\n", +"\n", +"// Since for the given reaction K = P_CO2,where P is in atm, therefore,\n", +"P_CO2 = K_1042;\n", +"// and thus decomposition takes place till the partial pressure of CO2 reaches 0.095 atm\n", +"// After that the decomposition in the closed vessel stops as equilibrium is achieved.\n", +"\n", +"printf(' The equilibrium pressure of CO2 is, P_CO2 = %f atm \n',P_CO2);\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.19: Determination_of_the_value_of_equilibrium_constant.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.19\n", +"//Page number - 620\n", +"printf('Example - 17.19 and Page number - 620\n\n');\n", +"\n", +"// Given\n", +"T_1 = 298.15;//[k] - Standard reaction temperature\n", +"T_2 = 1200;//[K] - Reaction temperature\n", +"R = 1.987;//[cal/mol-K] - Universal gas consatnt\n", +"\n", +"// C (s) + CO2 (g) - 2*CO2 (g) // Reaction 1\n", +"// CO2 + H2 - CO + H2O // Reacction 2\n", +"\n", +"K_1 = 63;// Equilibrium constant for the first reaction\n", +"K_2 = 1.4;// Equilibrium constant for the secind reaction\n", +"\n", +"delta_G_H2O_298 = -54640;//[cal/mol] - Standard Gibbs free energy of formation of water vapour\n", +"delta_H_H2O_298 = -57800;//[cal/mol] - Standard enthalpy change of formation of water vapour\n", +"delta_G_rkn_298 = delta_G_H2O_298;\n", +"\n", +"// The standard heat capacity data of the components in cal/mol-K are given below\n", +"// Cp_H2 = 6.947 - 0.2*10^(-3)*T + 4.8*10^(-7)*T^(2)\n", +"// Cp_O2 = 6.148 + 3.1*10^(-3)*T - 9.2*10^(-7)*T^(2)\n", +"// Cp_H2O = 7.256 + 2.3*10^(-3)*T + 2.8*10^(-7)*T^(2)\n", +"\n", +"// Let us consider two more reactions\n", +"// C (s) + (1/2)*O2 - CO // Reaction 3\n", +"// H2 + (1/2)*O2 - H2O // Reaction 4\n", +"\n", +"// Considering the above 4 reactions, it can be shown that reaction (3) = reaction (1) + reaction (4) - reaction (2)\n", +"// Thus, delta_G_rkn_3 = delta_G_rkn_1 + delta_G_rkn_4 - delta_G_rkn_2\n", +"// or, -R*T*log(K_3) = -R*T*log(K_1) + -R*T*log(K_4) - -R*T*log(K_2)\n", +"// K_3 = (K_1*K_4/K_2)\n", +"\n", +"// Now we have to determine K_4 at 1200 K.\n", +"// The standard enthalpy change of reaction (4) as a fuction of temperature is given by\n", +"// delta_H_rkn_T = -57020 - 2.765*T + 0.475*10^(-3)*T^(2) + 8.67*10^(-8)*T^(3);\n", +"\n", +"// log(K_4_2/K_4_1) = integrate('delta_H_rkn_T/(R*T^(2))','T',T_1,T)\n", +"log_K2_K1_4 = integrate('(-57020-2.765*T+0.475*10^(-3)*T^(2)+8.67*10^(-8)*T^(3))/T^(2)','T',T_1,T_2);\n", +"\n", +"// We know that delta_G_rkn_T = -R*T*log(K)\n", +"// At 298.15 K\n", +"K_4_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", +"\n", +"// Putting the values in the above expression we get\n", +"// log(K_4_1200/K_4_298) = log_K2_K1_R/R\n", +"K_4_1200 = K_4_298*exp(log_K2_K1_4/R);\n", +"K_4 = K_4_1200;\n", +"\n", +"// Therefore the equilibrium constant for reaction (3) at 1200 K is given by\n", +"K_3 = (K_1*K_4)/K_2;\n", +"\n", +"printf(' The equilibrium constant at 1200 K for the given reaction is, K = %e\n',K_3);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.1: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.1\n", +"//Page number - 595\n", +"printf('Example - 17.1 and Page number - 595\n\n');\n", +"\n", +"//This problem involves proving a relation in which no mathematical components are involved.\n", +"//For prove refer to this example 17.1 on page number 595 of the book.\n", +"printf('This problem involves proving a relation in which no mathematical components are involved.\n\n');\n", +"printf('For prove refer to this example 17.1 on page number 595 of the book.')\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.20: Calculation_of_standard_equilibrium_cell_voltage.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.20\n", +"//Page number - 622\n", +"printf('Example - 17.20 and Page number - 622\n\n');\n", +"\n", +"// Given\n", +"delta_G_H2O_298 = -237.034;//[kJ/mol] - Standard Gibbs free energy of formation of H2O (l) at 298 K\n", +"F = 96485;//[C/mol] - Faraday constant\n", +"\n", +"//(1)\n", +"// For the reaction\n", +"// H2 (g) + (1/2)*O2 (g) - H2O (l)\n", +"n = 2;// Number of electrons transferred in the reaction\n", +"\n", +"// The standard Gibbs free energy change of the reaction is given by\n", +"// delta_G_rkn = delta_G_for_H2O(l) - delta_G_for_H2(g) - (1/2/)*delta_G_for_O2(g)\n", +"// Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n", +"delta_G_rkn = delta_G_H2O_298;//[kJ]\n", +"delta_G_rkn = delta_G_rkn*10^(3);//[J]\n", +"\n", +"// delta_G_rkn = -n*F*E_0\n", +"// Thus standard equilibrium cell voltage is given by\n", +"E_0 = - delta_G_rkn/(n*F);///[V]\n", +"\n", +"printf(' (1).The standard equilibrium cell voltage is %f V\n\n',E_0);\n", +"\n", +"//(2)\n", +"// For the reaction\n", +"// 2*H2 (g) + O2 (g) - 2*H2O (l)\n", +"n_prime = 4;// Number of electrons transferred in the reaction\n", +"\n", +"// The standard Gibbs free energy change of the reaction is given by\n", +"// delta_G_rkn = 2*delta_G_for_H2O(l) - 2*delta_G_for_H2(g) - delta_G_for_O2(g)\n", +"// Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n", +"delta_G_rkn_prime = 2*delta_G_H2O_298;//[kJ]\n", +"delta_G_rkn_prime = delta_G_rkn_prime*10^(3);//[J]\n", +"\n", +"// delta_G_rkn = -n*F*E_0\n", +"// Thus standard equilibrium cell voltage is given by\n", +"E_0_prime = - delta_G_rkn_prime/(n_prime*F);///[V]\n", +"\n", +"printf(' (2).The standard equilibrium cell voltage is %f V\n\n',E_0_prime);\n", +"\n", +"// Thus the result obtained is same for both the reactions\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.21: Calculation_of_number_of_chemical_reactions.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.21\n", +"//Page number - 624\n", +"printf('Example - 17.21 and Page number - 624\n\n');\n", +"\n", +"// Given\n", +"P = 2;// Number of phases\n", +"C = 5;// Number of components\n", +"\n", +"// First we write chemical equations for formation of each component from basic elements\n", +"// C + 2*H2 = CH4 // (reaction 1) \n", +"// H2 + (1/2)*O2 = H20 // (reaction 2)\n", +"// C + (1/2)*O2 = CO // (reaction 3)\n", +"// C + O2 = CO2 // (reaction 4)\n", +"\n", +"// We do not have C in the equilibrium reaction mixture, therefore we have to eliminate it.\n", +"// Substituting for C from reaction (1) into reactions (3) and (4) we get the following set of reactions\n", +"// H2 + (1/2)*O2 = H20\n", +"// CH4 - 2*H2 + (1/2)*O2 = CO\n", +"// CH4 - 2*H2 + O2 = CO2\n", +"\n", +"// or,\n", +"// H2 + (1/2)*O2 = H2O\n", +"// CH4 + (1/2)*O2 = CO + 2*H2\n", +"// CH4 + O2 = CO2 + 2*H2\n", +"\n", +"// We do not have O2 in the equilibrium reaction mixture,therefore we have to eliminateit\n", +"// Substituting for O2 from the first reaction of the above set into seecond and third reactions of the above set we get the following set of reactions.\n", +"// CH4 + H2O - H2 = CO + 2*H2\n", +"// CH4 + 2*H20 - 2*H2 = CO2 + 2*H2 \n", +"\n", +"// Therefore one set of independent reactions is\n", +"// CH4 + H20 = CO + 3*H2\n", +"// CH4 + 2*H2O = CO2 + 4*H2\n", +"\n", +"// Another set of independent reactions can be obtained by substituting for CH4 from the first reaction into second and we get\n", +"// CH4 + H2O = CO + 3*H2\n", +"// CO + 3*H2 - H2O + 2*H2O = CO2 4*H2\n", +"\n", +"// Or, \n", +"// CH4 + H2O = CO + 3*H2\n", +"// CO + H2O = CO2 + H2\n", +"// This is another set of independent reactions. Thus whatever be the set of independent reactions, the number of independent reactions are two\n", +"// If different set of reactions are considered, then we get different equilibrium constants,different reaction coordinates but the final composition will be same\n", +"// Thus only 2 independent reactions occur,therefore \n", +"r = 2;\n", +"\n", +"// and the number of degree of freedom becomes,\n", +"F = r - P + C;\n", +"\n", +"printf(' The number of independent chemical reactions are %f \n\n',r);\n", +"\n", +"printf(' The first set of independent reactions are given below\n');\n", +"printf(' CH4 + H20 = CO + 3*H2\n');\n", +"printf(' CH4 + 2*H2O = CO2 + 4*H2\n\n');\n", +"\n", +"printf(' The second set of independent reactions are given below\n');\n", +"printf(' CH4 + H20 = CO + 3*H2\n');\n", +"printf(' CO + H2O = CO2 + H2');\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.22: Calculation_of_number_of_chemical_reactions.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.22\n", +"//Page number - 626\n", +"printf('Example - 17.22 and Page number - 626\n\n');\n", +"\n", +"// Given\n", +"T = 400;//[K] - Temperature\n", +"P = 1;//[atm] - Pressure\n", +"R = 1.987;//[cal/mol-K] - Universal gas consatnt\n", +"\n", +"delta_G_n_pentane_400 = 9600;//[cal/mol] - Standard Gibbs free energy of formation of n-pentane at 400 K\n", +"delta_G_iso_pentane_400 = 8200;//[cal/mol] - Standard Gibbs free energy of formation of iso-pentane at 400 K\n", +"delta_G_neo_pentane_400 = 9000;//[cal/mol] - Standard Gibbs free energy of formation of neo-pentane at 400 K\n", +"\n", +"// The three reactions for the formation of these isomers can be written as follows\n", +"// 5*C + 6*H2 = n-pentane\n", +"// 5*C + 6*H2 = iso-pentane\n", +"// 5*C + 6*H2 = neo-pentane\n", +"\n", +"// We can eliminate elemental carbon and hydrogen as they are not present in equilibrium reaction mixture and get the following two sets of independent reactions\n", +"// n-pentane = iso-pentane \n", +"// n-pentane = neo-pentane \n", +"\n", +"// or,\n", +"// iso-pentane = n-pentane \n", +"// iso-pentane = neo-pentane \n", +"\n", +"// or,\n", +"// noe-pentane = iso-pentane \n", +"// neo-pentane = n-pentane \n", +"\n", +"// Let us take the following set of independent reactions\n", +"// iso-pentane = n-pentane // (reaction 1)\n", +"delta_G_rkn_1 = delta_G_n_pentane_400 - delta_G_iso_pentane_400;//[cal]\n", +"K_1 = exp(-delta_G_rkn_1/(R*T));\n", +"// iso-pentane = neo-pentane // (reaction 2)\n", +"delta_G_rkn_2 = delta_G_neo_pentane_400 - delta_G_iso_pentane_400;//[cal]\n", +"K_2 = exp(-delta_G_rkn_2/(R*T));\n", +"\n", +"// Let the initial number of moles be\n", +"// n_iso_pentane = 1\n", +"// n_n_pentane = 0\n", +"// n_neo_pentane = 0\n", +"\n", +"// Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n", +"// At equilibrium, the moles of the components be\n", +"// n_iso_pentane_eq = 1 - X_1 - X_2\n", +"// n_n_pentane_eq = X_1\n", +"// n_neo_pentane_eq = X_2\n", +"// Total moles = 1 \n", +"\n", +"// Pressure has no effect on these reactions ( P = 1 atm) and therefore\n", +"Ky_1 = K_1;\n", +"Ky_2 = K_2;\n", +"\n", +"// From reaction (1), we get\n", +"// Ky_1 = X_1/(1-X_1-X_2)\n", +"\n", +"// From reaction (2), we get\n", +"// Ky_2 = X_2/(1-X_1-X_2)\n", +"\n", +"// Putting the value of X_1 from first equation into the second we get\n", +"// X_1 = (Ky_1*(1-X_2))/(1+Ky_1)\n", +"// Now putting it into the second equation we grt\n", +"// Ky_2 = X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n", +"// Now solving for X_2\n", +"deff('[y]=f(X_2)','y= Ky_2 - X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)');\n", +"X_2 = fsolve(0.8,f);\n", +"\n", +"// Therefore X_1 can be calculated as\n", +"X_1 = (Ky_1*(1-X_2))/(1+Ky_1);\n", +"\n", +"// Finally the mole fractions of the components at equilibrium\n", +"y_n_pentane = X_1;\n", +"y_neo_pentane = X_2;\n", +"y_iso_pentane = 1 -X_1 - X_2;\n", +"\n", +"printf(' The equilibrium composition is given by, y_n_pentane = %f, y_neo_pentane = %f and y_iso_pentane = %f\n\n\n',y_n_pentane,y_neo_pentane,y_iso_pentane);\n", +"\n", +"// Let us consider another set of independent reactions\n", +"\n", +"// n-pentane = iso-pentane // (reaction 3)\n", +"delta_G_rkn_3 = delta_G_iso_pentane_400 - delta_G_n_pentane_400;//[cal]\n", +"K_3 = exp(-delta_G_rkn_3/(R*T));\n", +"// n-pentane = neo-pentane // (reaction 4)\n", +"delta_G_rkn_4 = delta_G_neo_pentane_400 - delta_G_n_pentane_400;//[cal]\n", +"K_4 = exp(-delta_G_rkn_4/(R*T));\n", +"\n", +"// Let the initial number of moles be\n", +"// n_n_pentane = 1\n", +"// n_iso_pentane = 0\n", +"// n_neo_pentane = 0\n", +"\n", +"// Let the reaction coordinate at equilibrium for the two reaction be X_3 and X_4 respectively\n", +"// At equilibrium, the moles of the components be\n", +"// n_n_pentane_eq = 1 - X_3 - X_4\n", +"// n_iso_pentane_eq = X_4\n", +"// n_neo_pentane_eq = X_4\n", +"// Total moles = 1 \n", +"\n", +"// Pressure has no effect on these reactions (P = 1 atm) and therefore\n", +"Ky_3 = K_3;\n", +"Ky_4 = K_4;\n", +"\n", +"// From reaction (3), we get\n", +"// Ky_3 = X_3/(1-X_3-X_4)\n", +"\n", +"// From reaction (4), we get\n", +"// Ky_4 = X_4/(1-X_3-X_4)\n", +"\n", +"// Putting the value of X_3 from first equation into the second we get\n", +"// X_3 = (Ky_3*(1-X_4))/(1+Ky_3)\n", +"// Now putting it into the second equation we grt\n", +"// Ky_4 = X_4/(1-((Ky_1*(1-X_4))/(1+Ky_3))-X_4)\n", +"// Now solving for X_4\n", +"deff('[y]=f1(X_4)','y= Ky_4 - X_4/(1-((Ky_3*(1-X_4))/(1+Ky_3))-X_4)');\n", +"X_4 = fsolve(0.8,f1);\n", +"\n", +"// Therefore X_3 can be calculated as\n", +"X_3 = (Ky_3*(1-X_4))/(1+Ky_3);\n", +"\n", +"// Finally the mole fractions of the components at equilibrium\n", +"y_n_pentane1 = 1 - X_3 - X_4;\n", +"y_neo_pentane1 = X_4;\n", +"y_iso_pentane1 = X_3;\n", +"\n", +"// The final composition does not depend on the set of reactions considered. \n", +"\n", +"printf(' For another set of independent reactions considered\n');\n", +"printf(' The equilibrium composition is given by, y_n_pentane = %f, y_neo_pentane = %f and y_iso_pentane = %f\n\n\n',y_n_pentane1,y_neo_pentane1,y_iso_pentane1);\n", +"printf(' Thus the final composition does not depend on the set of reactions considered\n\n\n');\n", +"printf(' The number of independent reactions taking place is two');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.23: Calculation_of_equilibrium_composition.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.23\n", +"//Page number - 628\n", +"printf('Example - 17.23 and Page number - 628\n\n');\n", +"\n", +"// Given\n", +"T = 600;//[K] - Temperature\n", +"P = 1;//[atm] - Pressure\n", +"R = 1.987;//[cal/mol-K] - Universal gas consatnt\n", +"\n", +"// CH4 + H2O = CO + 3*H2 // (Reaction 1)\n", +"// CO + H2O = CO2 + H2 // (Reaction 2)\n", +"\n", +"K_1 = 0.574;// Equilibrium constant of first reaction\n", +"K_2 = 2.21;// Equilibrium constant of second reaction\n", +"\n", +"// Initial number of moles of the components are\n", +"// n_CH4 = 1\n", +"// n_H2O = 5\n", +"// n_CO = 0\n", +"// n_H2 = O\n", +"// n_CO2 = 0\n", +"\n", +"// Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n", +"// At equilibrium, the moles of the components be\n", +"// n_CH4_eq = 1 - X_1\n", +"// n_H20_eq = 5 - X_1 - X_2\n", +"// n_CO_eq = X_1 - X_2\n", +"// n_H2_eq = 3*X_1 + X_2\n", +"// n_CO2_eq = X_2\n", +"// Total moles = 6 + 2*X_1\n", +"\n", +"// Since the pressure is 1 atm, K = Kp, Ky = K\n", +"Ky_1 = K_1;\n", +"Ky_2 = K_2;\n", +"\n", +"// From reaction (1), we get\n", +"// Ky_1 = ((X_1-X_2)*(3*X_1+X_2)^(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)^(2))\n", +"\n", +"// From reaction (2), we get\n", +"// Ky_2 = (X_2*(3*X_1+X_2))/((X_1-X_2)*(5-X_1-X_2))\n", +"\n", +"// Let us assume a value of X_1\n", +"X_1 = 0.1;\n", +"\n", +"fault = 10;\n", +"while(fault>0.05)\n", +" deff('[y]=f(X_2)','y= Ky_1-((X_1-X_2)*(3*X_1+X_2)^(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)^(2))');\n", +" X_2 = fsolve(0.8,f);\n", +" X_2_prime = X_2;\n", +" deff('[y]=f1(X_1_prime)','y= Ky_2-(X_2_prime*(3*X_1_prime+X_2_prime))/((X_1_prime-X_2_prime)*(5-X_1_prime-X_2_prime))');\n", +" X_1_prime = fsolve(0.8,f1);\n", +" fault=abs(X_1 - X_1_prime);\n", +" X_1 = X_1 + 0.001;\n", +"end\n", +"\n", +"n_CH4 = 1 - X_1;\n", +"n_H20 = 5 - X_1 - X_2;\n", +"n_CO = X_1 - X_2;\n", +"n_H2 = 3*X_1 + X_2;\n", +"n_CO2 = X_2;\n", +"Total_moles = 6 + 2*X_1;\n", +"\n", +"printf(' The equilibrium composition of the resulting mixture is given by\n');\n", +"printf(' n_CH4 = % f mol\n n_H2O = %f mol\n n_CO = %f mol\n n_H2 = %f mol and\n n_CO2 = %f mol\n\n',n_CH4,n_H20,n_CO,n_H2,n_CO2);\n", +"printf(' The total number of moles is %f mol\n',Total_moles);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.24: Determination_of_number_of_moles.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.24\n", +"//Page number - 631\n", +"printf('Example - 17.24 and Page number - 631\n\n');\n", +"\n", +"// Given\n", +"T = 600 + 273.15;//[K] - Reaction temperature\n", +"P = 1;//[atm] - Reaction pressure\n", +"\n", +"// The Gibbs free energy of formation of various species at 873.15 K are\n", +"delta_G_CH4_RT = -2.82;// delta_G_CH4/(R*T)\n", +"delta_G_H2O_RT = -29.73;// delta_G_CH4/(R*T)\n", +"delta_G_CO_RT = -27.51;// delta_G_CH4/(R*T)\n", +"delta_G_H2_RT = -1.46;// delta_G_CH4/(R*T)\n", +"delta_G_CO2_RT = -56.68;// delta_G_CH4/(R*T)\n", +"\n", +"// Initial number of moles of the components are\n", +"// n_CH4 = 1\n", +"// n_H2O = 5\n", +"// n_CO = 0\n", +"// n_H2 = O\n", +"// n_CO2 = 0\n", +"\n", +"// The del(F)/del(n_i) = 0 equations for CH4 (1), H2O (2), CO (3), H2 (4) and CO2 (5) becomes\n", +"// delta_G_1_T + R*T*log((n_1*P)/n) + lambda_C + 4*lambda_H = 0\n", +"// delta_G_2_T + R*T*log((n_2*P)/n) + 2*lambda_C + lambda_O = 0\n", +"// delta_G_3_T + R*T*log((n_3*P)/n) + lambda_c + lambda_O = 0\n", +"// delta_G_4_T + R*T*log((n_4*P)/n) + 2*lambda_H = 0\n", +"// delta_G_5_T + R*T*log((n_5*P)/n) + lambda_C + 2*lambda_O = 0\n", +"\n", +"// Where n is the total number of moles in the equilibrium reaction mixture. Dividing the above equations by R*T we get\n", +"// delta_G_1_T/(R*T) + log((n_1*P)/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n", +"// delta_G_2_T/(R*T) + log((n_2*P)/n) + 2*lambda_C/(R*T) + lambda_O/(R*T) = 0\n", +"// delta_G_3_T/(R*T) + log((n_3*P)/n) + lambda_c/(R*T) + lambda_O/(R*T) = 0\n", +"// delta_G_4_T/(R*T) + log((n_4*P)/n) + 2*lambda_H/(R*T) = 0\n", +"// delta_G_5_T/(R*T) + log((n_5*P)/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n", +"\n", +"// Substituting the values of delta_G_i_T/(R*T) in the above equations,the full set of equations (including elemental balance) becomes\n", +"// -2.82 + log(n_1/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n", +"// -29.73 + log(n_2/n) + 2*lambda_H/(R*T) + lambda_O/(R*T) = 0\n", +"// -27.51 + log(n_3/n) + lambda_C/(R*T) + lambda_O/(R*T) = 0\n", +"// -1.46 + log(n_4/n) + 2*lambda_H/(R*T) = 0\n", +"// -56.68 + log(n_5/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n", +"\n", +"// The constraint equations are\n", +"// n_1 + n_3 + n_5 = 1 // (moles of C in the reaction mixture = 1)\n", +"// 4*n_1 + 2*n_2 + 2*n_4 = 14 // (moles of H in the reaction mixture = 14)\n", +"// n_2 + n_3 + 2*n_5 = 5 // (moles of O in the raection mixture = 5)\n", +"\n", +"// The total moles are given by\n", +"// n = n_1 + n_2 + n_3 + n_4 + n_5\n", +"\n", +"function[f]=solution(x)\n", +"f(1) = -2.82 + log(x(1)/x(6)) + x(7) + 4*x(8);\n", +"f(2) = -29.73 + log(x(2)/x(6)) + 2*x(8) + x(9);\n", +"f(3) = -27.51 + log(x(3)/x(6)) + x(7) + x(9);\n", +"f(4) = -1.46 + log(x(4)/x(6)) + 2*x(8);\n", +"f(5) = -56.68 + log(x(5)/x(6)) + x(7) + 2*x(9);\n", +"f(6) = x(1) + x(3) +x(5) - 1;\n", +"f(7) = 4*x(1) + 2*x(2) + 2*x(4) - 14;\n", +"f(8) = x(2) + x(3) +2*x(5) - 5;\n", +"f(9) = x(1)+ x(2) + x(3) + x(4) + x(5) - x(6); \n", +"\n", +"funcprot(0);\n", +"endfunction\n", +"x = [0.01,3.5,0.2,3.0,0.5,5.0,2.0,1.0,25.0];\n", +"y = fsolve(x,solution);\n", +"\n", +"printf(' n_1 = %f mol\n',y(1));\n", +"printf(' n_2 = %f mol\n',y(2));\n", +"printf(' n_3 = %f mol\n',y(3));\n", +"printf(' n_4 = %f mol\n',y(4));\n", +"printf(' n_5 = %f mol\n',y(5));\n", +"printf(' n = %f mol\n',y(6));\n", +"printf(' lambda_C/RT = %f\n',y(7));\n", +"printf(' lambda_H/RT = %f\n',y(8));\n", +"printf(' lambda_O/RT = %f\n\n',y(9));\n", +"\n", +"printf(' The Lagrange multiplier values do not have any physical significance\n');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.2: Determination_of_number_of_moles.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.2\n", +"//Page number - 598\n", +"printf('Example - 17.2 and Page number - 598\n\n');\n", +"\n", +"// Given\n", +"P = 1;//[atm] - Reactor pressure\n", +"T = 749;//[K] - Reactor temperature\n", +"K = 74;// Equlibrium constant\n", +"\n", +"// SO2 + (1/2)*O2 - SO3\n", +"\n", +"Kp = P^(1);\n", +"Ky = K/Kp;\n", +"\n", +"//(1)\n", +"// Initial number of moles of the components are\n", +"n_SO2_1_in = 12;\n", +"n_O2_1_in = 9;\n", +"n_SO3_1_in = 0;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_SO2_1_eq = 12 - X\n", +"// n_O2_1_eq = 9 - 0.5*X\n", +"// n_SO3_1_eq = X\n", +"// Total moles = 21 - 0.5*X\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"// y_SO3 = X/(21-0.5*X)\n", +"// y_SO2 = (12-X)/(21-0.5*X)\n", +"// y_O2 = (9-0.5*X)/(21-0.5*X)\n", +"\n", +"// Ky = y_SO3/(y_SO2*y_O2^(2))\n", +"// Ky = (X*(21-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))\n", +"deff('[y]=f(X)','y= Ky-(X*(21-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))');\n", +"X_1 = fsolve(11,f);\n", +"\n", +"y_SO3_1 = X_1/(21-0.5*X_1);\n", +"y_SO2_1 = (12-X_1)/(21-0.5*X_1);\n", +"y_O2_1 = (9-0.5*X_1)/(21-0.5*X_1);\n", +"\n", +"printf(' (1).The moles of SO3 formed = %f mol\n',X_1);\n", +"printf(' The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\n\n',y_SO3_1,y_SO2_1,y_O2_1);\n", +"\n", +"//(2)\n", +"// Initial number of moles of the components are\n", +"n_SO2_2_in = 24;\n", +"n_O2_2_in = 18;\n", +"n_SO3_2_in = 0;\n", +"\n", +"// At equilibrium, the moles of the components be\n", +"// n_SO2_1_eq = 24 - X\n", +"// n_O2_1_eq = 18 - 0.5*X\n", +"// n_SO3_1_eq = X\n", +"// Total moles = 42 - 0.5*X\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"// y_SO3 = X/(42-0.5*X)\n", +"// y_SO2 = (24-X)/(42-0.5*X)\n", +"// y_O2 = (18-0.5*X)/(42-0.5*X)\n", +"\n", +"// Ky = y_SO3/(y_SO2*y_O2^(2))\n", +"// Ky = (X*(42-0.5*X)^(1/2))/((24-X)*(18-0.5*X)^(1/2))\n", +"deff('[y]=f1(X)','y= Ky-(X*(42-0.5*X)^(1/2))/((24-X)*(18-0.5*X)^(1/2))');\n", +"X_2 = fsolve(22,f1);\n", +"\n", +"y_SO3_2 = X_2/(42-0.5*X_2);\n", +"y_SO2_2 = (24-X_2)/(42-0.5*X_2);\n", +"y_O2_2 = (18-0.5*X_2)/(42-0.5*X_2);\n", +"printf(' (2).The moles of SO3 formed = %f mol\n',X_2);\n", +"printf(' The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\n\n',y_SO3_2,y_SO2_2,y_O2_2);\n", +"\n", +"//(3)\n", +"// Initial number of moles of the components are\n", +"n_SO2_3_in = 12;\n", +"n_O2_3_in = 9;\n", +"n_SO3_3_in = 0;\n", +"n_N2 = 79;\n", +"\n", +"// At equilibrium, the moles of the components be\n", +"// n_SO2_1_eq = 12 - X\n", +"// n_O2_1_eq = 9 - 0.5*X\n", +"// n_SO3_1_eq = X\n", +"// Total moles = 100 - 0.5*X\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"// y_SO3 = X/(100-0.5*X)\n", +"// y_SO2 = (12-X)/(100-0.5*X)\n", +"// y_O2 = (9-0.5*X)/(100-0.5*X)\n", +"\n", +"// Ky = y_SO3/(y_SO2*y_O2^(2))\n", +"// Ky = (X*(100-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))\n", +"deff('[y]=f2(X)','y= Ky-(X*(100-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))');\n", +"X_3 = fsolve(10,f2);\n", +"\n", +"y_SO3_3 = X_3/(100-0.5*X_3);\n", +"y_SO2_3 = (12-X_3)/(100-0.5*X_3);\n", +"y_O2_3 = (9-0.5*X_3)/(100-0.5*X_3);\n", +"\n", +"printf(' (3).The moles of SO3 formed = %f mol\n',X_3);\n", +"printf(' The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\n\n',y_SO3_3,y_SO2_3,y_O2_3);\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.3: Determination_of_equilibrium_composition.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.3\n", +"//Page number - 599\n", +"printf('Example - 17.3 and Page number - 599\n\n');\n", +"\n", +"// Given\n", +"T = 600;//[K] - Reactor temperature\n", +"P = 300;//[atm] - Reactor pressure\n", +"K = 0.91*10^(-4);// Equilibrium constant\n", +"\n", +"// The fugacity coefficients of the components are\n", +"phi_CO = 1.0;\n", +"phi_H2 = 1.2;\n", +"phi_CH3OH = 0.47;\n", +"\n", +"// CO + 2*H2 - CH3OH \n", +"\n", +"// For gas phase reactions the standard state is pure ideal gas and thus fi_0 = 1 atm and thus\n", +"// ai_cap = fi_cap/fi_0 = yi*P*phi_i_cap/1\n", +"// Thus K = Ky*Kp*K_phi\n", +"Kp = P^(1-3);\n", +"K_phi = phi_CH3OH/(phi_CO*phi_H2^(2));\n", +"Ky = K/(Kp*K_phi);\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium ,the moles of the components be \n", +"// n_CO = 1 - X\n", +"// n_H2 = 3 - 2*X\n", +"// n_CH3OH = X\n", +"// Total moles = 4 - 2*X\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"// y_CO = (1-X)/(4-2*X)\n", +"// y_H2 = (3-2*X)/(4-2*X)\n", +"// y_CH3OH = (X)/(4-2*X)\n", +"\n", +"// Ky = y_CH3OH/(y_CO*y_H2^(2)) = (X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))^(2))\n", +"deff('[y]=f(X)','y=Ky-(X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))^(2))');\n", +"X = fsolve(0.1,f);\n", +"\n", +"// Therefore at equilibrium \n", +"y_CO = (1-X)/(4-2*X);\n", +"y_H2 = (3-2*X)/(4-2*X);\n", +"y_CH3OH = (X)/(4-2*X);\n", +"\n", +"printf(' The mole fractions at equilibrium are y_CO = %f, y_H2 = %f and y_CH3OH = %f',y_CO,y_H2,y_CH3OH);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.4: Determination_of_the_value_of_equilibrium_constant.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.4\n", +"//Page number - 600\n", +"printf('Example - 17.4 and Page number - 600\n\n');\n", +"\n", +"// Given\n", +"T = 600;//[K] - Reactor temperature\n", +"P = 4;//[atm] - Reactor pressure\n", +"K = 1.175;// Equilibrium constant\n", +"\n", +"// (1/2)*N2 + (3/2)*H_2 - NH3\n", +"\n", +"// Initial number of moles of the components are\n", +"n_N2 = 1;\n", +"n_H2 = 3;\n", +"n_HN3 = 0;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X.\n", +"// At equilibrium ,the moles of the components be \n", +"// n_N2 = 1 - 0.5*X\n", +"// n_H2 = 3 - 1.5*X\n", +"// n_NH3 = X\n", +"// Total moles = 4 - X\n", +"\n", +"// We have, K = Ky*Kp\n", +"Kp = P^(1-2);//[atm^(-1)]\n", +"Ky = K/(Kp);\n", +"\n", +"// Ky = y_NH3/(y_N2^(1/2)*y_H2^(3/2)) = (X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2))\n", +"// Solving the above equation we get\n", +"deff('[y]=f(X)','y=Ky - (X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2))');\n", +"X = fsolve(0.1,f);\n", +"\n", +"y_NH3 = X/(4-X);// Mole fraction of NH3 at equilibrium\n", +"\n", +"printf(' The value of Kp = %f and Ky = %f \n',Kp,Ky);\n", +"printf(' The mole fractions of NH3 at equilibrium is %f\n\n',y_NH3);\n", +"\n", +"// If reaction carried out at constant temperature and volume\n", +"\n", +"// We know that for ideal gas, P*V = n*R*T and thus P is directly proportional to n at constant V and T.\n", +"// Let P = k*n\n", +"// Initially P = 4 atm and n = 4 moles, thus K = 1 and we get p = n, where P is in atm. \n", +"// Thus at equilibrium P = 4 - X\n", +"\n", +"// Ky = K/Kp = 1.175*P = 1.175*(4 - X)\n", +"// (X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2)) = 1.175*(4 - X)\n", +"// Solving the above equation we get\n", +"deff('[y]=f1(X)','y=(X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2))-1.175*(4-X)');\n", +"X_prime = fsolve(1,f1);\n", +"\n", +"// Therefore at equilibrium \n", +"P_prime = 4 - X_prime;\n", +"y_NH3_prime = X_prime/(4-X_prime);\n", +"\n", +"printf(' If reaction is carried out at constant temperature and volume,then\n');\n", +"printf(' The equilibrium pressure is %f atm\n',P_prime);\n", +"printf(' The equilibrium mole fractions of NH3 in the reactor is %f\n\n',y_NH3_prime);\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.5: Determination_of_mole_fraction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.5\n", +"//Page number - 601\n", +"printf('Example - 17.5 and Page number - 601\n\n');\n", +"\n", +"// Given\n", +"T = 400;//[K] - Reactor temperature\n", +"P = 1;//[atm] - Reactor pressure\n", +"K = 1.52;// Equilibrium constant\n", +"y_H2 = 0.4;// Equilibrium mole fraction of hydrogen\n", +"\n", +"// CO(g) + 2*H_2(g) - CH3OH(g)\n", +"\n", +"// K = y_CH3OH/(y_CO*y_H2^(2)*P^(2))\n", +"// Let total number of moles at equilibrium be 1\n", +"// y_CH3OH = 0.6 - y_CO;\n", +"// (0.6 - y_CO)/y_CO = K*P^(2)*y_H2^(2)\n", +"\n", +"y_CO = 0.6/(1 + K*P^(2)*y_H2^(2));\n", +"y_CH3OH = 0.6 - y_CO;\n", +"\n", +"printf(' The mole fractions are, y_CO = %f and y_CH3OH = %f \n',y_CO,y_CH3OH);\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.6: Determination_of_number_of_moles.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.6\n", +"//Page number - 602\n", +"printf('Example - 17.6 and Page number - 602\n\n');\n", +"\n", +"// Given\n", +"T = 749;//[K] - Reactor temperature\n", +"P = 1;//[atm] - Reactor pressure\n", +"K = 74;\n", +"\n", +"Kp = P^(-1/2);//[atm^(-1/2)]\n", +"Ky = K/Kp;\n", +"\n", +"// SO2 + (1/2)*O2 - SO3\n", +"\n", +"// Initial number of moles of the components are\n", +"n_SO2_1_in = 10;\n", +"n_O2_1_in = 8;\n", +"n_SO3_1_in = 0;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_SO2_1_eq = 10 - X\n", +"// n_O2_1_eq = 8 - 0.5*X\n", +"// SO3_1_eq = X\n", +"// Total moles = 18 - 0.5*X\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"// y_SO3 = X/(18-0.5*X)\n", +"// y_SO2 = (10-X)/(18-0.5*X)\n", +"// y_O2 = (8-0.5*X)/(18-0.5*X)\n", +"\n", +"// Ky = y_SO3/(y_SO2*y_O2^(2))\n", +"// Ky = (X*(18-0.5*X)^(1/2))/((10-X)*(8-0.5*X)^(1/2))\n", +"deff('[y]=f(X)','y= Ky-(X*(18-0.5*X)^(1/2))/((10-X)*(8-0.5*X)^(1/2))');\n", +"X_1 = fsolve(11,f);\n", +"\n", +"n_SO3 = X_1;\n", +"n_SO2 = 10 - X_1;\n", +"n_O2 = 8 - 0.5*X_1;\n", +"\n", +"printf(' (1).The moles of the components at equilibrium are, n_SO3 = %f mol, n_SO2 = %f mol and n_O2 = %f mol\n\n',n_SO3,n_SO2,n_O2);\n", +"\n", +"// Now for the reaction\n", +"// 2*SO2 + O2 - 2*SO3\n", +"\n", +"// The equilibrium constant for this reaction is KP^(2)\n", +"Ky_prime = Ky^(2);\n", +"\n", +"// At equilibrium, the moles of the components be\n", +"// n_SO2_1_eq = 10 - 2*X\n", +"// n_O2_1_eq = 8 - X\n", +"// SO3_1_eq = 2*X\n", +"// Total moles = 18 - X\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"// y_SO3 = 2*X/(18-X)\n", +"// y_SO2 = (10-2*X)/(18-X)\n", +"// y_O2 = (8- X)/(18-X)\n", +"\n", +"// Ky_prime = y_SO3^(2)/(y_SO2^(2)*y_O2)\n", +"// Ky_prime = ((2*X)^(2)*(18-X))/((10-2*X)^(2)*(8-X))\n", +"deff('[y]=f1(X)','y= Ky_prime-((2*X)^(2)*(18-X))/(((10-2*X)^(2))*(8-X))');\n", +"X_2 = fsolve(6,f1);\n", +"\n", +"n_SO3_prime = 2*X_2;\n", +"n_SO2_prime = 10 - 2*X_2;\n", +"n_O2_prime = 8 - X_2;\n", +"\n", +"printf(' (2).The moles of the components at equilibrium are, n_SO3 = %f mol, n_SO2 = %f mol and n_O2 = %f mol\n\n',n_SO3_prime,n_SO2_prime,n_O2_prime);\n", +"printf(' Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.7: Calculation_of_mole_fraction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.7\n", +"//Page number - 603\n", +"printf('Example - 17.7 and Page number - 603\n\n');\n", +"\n", +"// Given\n", +"T = 500;//[K]\n", +"// For the reaction, 0.5*A2 + 0.5*B2 - AB\n", +"delta_G = -4200;//[J/mol]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"//(1)\n", +"// A2 + B2 - 2*AB\n", +"\n", +"// We know delta_G_rkn_0 = -R*T*log(K) \n", +"delta_G_1 = 2*delta_G;\n", +"K_1 = exp(-delta_G_1/(R*T));// Equilibrium constant at 500 K for the above reaction\n", +"// As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n", +"Ky = K_1;\n", +"\n", +"// Initial number of moles of the components are\n", +"n_A2_1_in = 0.5;\n", +"n_B2_1_in = 0.5;\n", +"n_AB_1_in = 0;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_A2_1_eq = 0.5 - X\n", +"// n_B2_1_eq = 0.5- X\n", +"// n_AB_1_eq = 2*X\n", +"// Total moles = 1\n", +"\n", +"// Ky = (2*X)^(2)/(0.5-X)^(2)\n", +"deff('[y]=f(X)','y= Ky-(2*X)^(2)/(0.5-X)^(2)');\n", +"X_1 = fsolve(0.2,f);\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"y_A2_1 = 0.5 - X_1;\n", +"y_B2_1 = 0.5- X_1;\n", +"y_AB_1 = 2*X_1;\n", +"\n", +"printf(' (1).The mole fractions at equilibrium are y_A2 = %f, y_B2 = %f and y_AB = %f\n\n',y_A2_1,y_B2_1,y_AB_1);\n", +"\n", +"//(2)\n", +"// 0.5*A2 + 0.5*B2 - AB\n", +"\n", +"// We know delta_G_rkn_0 = -R*T*log(K) \n", +"delta_G_2 = delta_G;\n", +"K_2 = exp(-delta_G_2/(R*T));// Equilibrium constant at 500 K for the above reaction\n", +"\n", +"// As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n", +"Ky_2 = K_2;\n", +"\n", +"// Initial number of moles of the components are\n", +"n_A2_2_in = 0.5;\n", +"n_B2_2_in = 0.5;\n", +"n_AB_2_in = 0;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_A2_2_eq = 0.5 - 0.5*X\n", +"// n_B2_2_eq = 0.5- 0.5*X\n", +"// n_AB_2_eq = X\n", +"// Total moles = 1\n", +"\n", +"// Ky = y_AB/(y_A2^(1/2)*y_B2^(1/2))\n", +"// Ky = X/(0.5 - 0.5*X)\n", +"X_2 = 0.5*Ky_2/(1+0.5*Ky_2);\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"y_A2_2 = 0.5 - 0.5*X_2;\n", +"y_B2_2 = 0.5- 0.5*X_2;\n", +"y_AB_2 = X_2;\n", +"\n", +"printf(' (2).The mole fractions at equilibrium are y_A2 = %f, y_B2 = %f and y_AB = %f\n\n',y_A2_2,y_B2_2,y_AB_2);\n", +"\n", +"//(3)\n", +"// 2*AB - A2 + B2\n", +"\n", +"K_3 = 1/K_1;// Equilibrium constant at 500 K for the above reaction\n", +"// As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n", +"Ky_3 = K_3;\n", +"\n", +"// Initial number of moles of the components are\n", +"n_AB_3_in = 1;\n", +"n_A2_3_in = 0;\n", +"n_B2_3_in = 0;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_AB_3_eq = 1 - X\n", +"// n_A2_3_eq = X/2\n", +"// n_B2_3_eq = X/2\n", +"// Total moles = 1\n", +"\n", +"// Ky = (X/2)^(2)/(1-X)^(2)\n", +"deff('[y]=f1(X)','y= Ky_3-(X/2)^(2)/(1-X)^(2)');\n", +"X_3 = fsolve(0.4,f1);\n", +"\n", +"// The mole fractions of the components at equilibrium are\n", +"y_A2_3 = X_3/2;\n", +"y_B2_3 = X_3/2;\n", +"y_AB_3 = 1-X_3;\n", +"\n", +"printf(' (3).The mole fractions at equilibrium are y_A2 = %f, y_B2 = %f and y_AB = %f\n\n',y_A2_3,y_B2_3,y_AB_3);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.8: Calculation_of_heat_exchange.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.8\n", +"//Page number - 606\n", +"printf('Example - 17.8 and Page number - 606\n\n');\n", +"\n", +"// Given\n", +"// P*P +q*Q - r*R + s*S\n", +"// Let Cp_P = p, Cp_Q = Q, Cp_R = R and Cp_S = S\n", +"\n", +"//(1)\n", +"// When reactants are heated from 10 to 25 C,reaction takes place at 25 C and products are raised from 25 C to 1500 K the heat exchange is given by\n", +"T_1 = 10 + 273.15;//[K]\n", +"T_2 = 25 + 273.15;//[K]\n", +"T_3 = 1500;//[K]\n", +"// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_2) + delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S)*dT','T'T_2,T_3);\n", +"printf(' (1).The expression for the heat exchange with the surrounding by the first path is given below\n');\n", +"printf(' Q = integrate((p*Cp_P + q*Cp_q)*dT,T,T_1,T_2) + delta_H_rkn_298 + integrate((r*Cp_R + s*Cp_S)*dT,TT_2,T_3);\n\n')\n", +"\n", +"//(2)\n", +"// When reactants are heated from 10 C to 1500 K,reaction take place at 1500 K the heat exchange is given by\n", +"// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_3) + delta_H_rkn_1500\n", +"// where, delta_H_rkn_1500 = delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S - p*Cp_P - q*Cp_q)*dT','T'T_2,T_3);\n", +"// Therefore\n", +"// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_3) + delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S - p*Cp_P - q*Cp_q)*dT','T'T_2,T_3);\n", +"// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_2) + delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S)*dT','T'T_2,T_3);\n", +"\n", +"// which is same as in method (1). The total enthalpy change between two fixed ponts is a function only of state and not the path taken.\n", +"\n", +"printf(' (2).The expression for the heat exchange with the surrounding by the second path is given below\n');\n", +"printf(' Q = integrate((p*Cp_P + q*Cp_q)*dT,T,T_1,T_2) + delta_H_rkn_298 + integrate((r*Cp_R + s*Cp_S)*dT,TT_2,T_3);\n\n')\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.9: Dtermination_of_heat_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 17.9\n", +"//Page number - 606\n", +"printf('Example - 17.9 and Page number - 606\n\n');\n", +"\n", +"// Given\n", +"// SO2 + (1/2)*O2 - SO3\n", +"R = 1.987;//[cal/mol-K]\n", +"\n", +"delta_H_SO2_298 = -70.96;//[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n", +"delta_H_SO3_298 = -94.45;//[kcal/mol] - Enthalpy of formation of S03 at 298.15 K\n", +"delta_G_SO2_298 = -71.79;//[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n", +"delta_G_SO3_298 = -88.52;//[kcal/mol] - Gibbs free energy change for formation of SO3 at 298.15 K\n", +"\n", +"// Cp_0 = a + b*T + c*T^(2) + d*T^(3)\n", +"\n", +"a_SO2 = 6.157;\n", +"a_SO3 = 3.918;\n", +"a_O2 = 6.085;\n", +"b_SO2 = 1.384*10^(-2);\n", +"b_SO3 = 3.483*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"c_SO2 = -0.9103*10^(-5);\n", +"c_SO3 = -2.675*10^(-5);\n", +"c_O2 = -0.1709*10^(-5);\n", +"d_SO2 = 2.057*10^(-9);\n", +"d_SO3 = 7.744*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"\n", +"//(1)\n", +"T_1 = 298.15;//[K]\n", +"\n", +"delta_H_rkn_298 = delta_H_SO3_298 - delta_H_SO2_298;//[kcal]\n", +"delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", +"delta_G_rkn_298 = delta_G_SO3_298 - delta_G_SO2_298;//[kcal]\n", +"delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", +"\n", +"delta_a = a_SO3 - a_SO2 - (a_O2/2);\n", +"delta_b = b_SO3 - b_SO2 - (b_O2/2);\n", +"delta_c = c_SO3 - c_SO2 - (c_O2/2);\n", +"delta_d = d_SO3 - d_SO2 - (d_O2/2);\n", +"\n", +"// delta_H_rkn_T = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T);\n", +"// On simplification we get\n", +"// delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10^(-2)*T^(2) - 0.5598*10^(-5)*T^(3) + 1.3826*10^(-9)*T^(4)\n", +"\n", +"printf(' (1).The expression for delta_H_rkn_T as a function of T is given by\n');\n", +"printf(' delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10^(-2)*T^(2) - 0.5598*10^(-5)*T^(3) + 1.3826*10^(-9)*T^(4)\n\n');\n", +"\n", +"//(2)\n", +"// R*log(K_T/K_298) = integrate('delta_H_rkn_T/T^(2)',T,T_1,T)\n", +"// First let us calculate K_298.\n", +"// delta_G_rkn_T = - R*T*log(K)\n", +"K_298 = exp(-delta_G_rkn_298/(R*T_1));\n", +"\n", +"// On substituting the values and simplifying we get the expression\n", +"// log(K) = 3.87 + 11380.10/T - 2.6580*log(T) + 0.4825*10^(-2)*T - 0.1409*10^(-5)*T^(2) + 0.2320*10^(-9)*T^(3)\n", +"\n", +"printf(' (2).The expression for log(K) as a function of T is given by\n');\n", +"printf(' log(K) = 3.87 + 11380.10/T - 2.6580*log(T) + 0.4825*10^(-2)*T - 0.1409*10^(-5)*T^(2) + 0.2320*10^(-9)*T^(3)\n\n');\n", +"\n", +"//(3)\n", +"P = 1;//[atm]\n", +"T = 880;//[K]\n", +"K = exp(3.87 + 11380.10/T - 2.6580*log(T) + 0.4825*10^(-2)*T - 0.1409*10^(-5)*T^(2) + 0.2320*10^(-9)*T^(3));\n", +"Kp = P^(-1/2);//[atm^(-1/2)]\n", +"Ky = K/Kp;\n", +"\n", +"// Let the reaction coordinate at equilibrium for the reaction be X\n", +"// At equilibrium, the moles of the components be\n", +"// n_SO2_eq = 1 - X\n", +"// n_O2_eq = 0.5- 0.5*X\n", +"// n_SO3_1_eq = X\n", +"// Total moles = 1.5-0.5*X\n", +"\n", +"// Ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", +"deff('[y]=f(X)','y= Ky - (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", +"X = fsolve(0.8,f);\n", +"\n", +"// The mole fraction of SO3 at equilibrium is given by\n", +"y_SO3 = X/(1.5-0.5*X);\n", +"\n", +"printf(' (3).The mole fraction of SO3 at equilibrium is given by, y_SO3 = %f\n',y_SO3);\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/18-Adiabatic_Reaction_Temperature.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/18-Adiabatic_Reaction_Temperature.ipynb new file mode 100644 index 0000000..3900022 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/18-Adiabatic_Reaction_Temperature.ipynb @@ -0,0 +1,531 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 18: Adiabatic Reaction Temperature" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 18.1: Calculation_of_heat_transfer.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 18.1\n", +"//Page number - 650\n", +"printf('Example - 18.1 and Page number - 648\n\n');\n", +"\n", +"// Given\n", +"\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"T_2 = 500;//[K] - Reaction temperature\n", +"P = 1;//[atm] - Pressure \n", +"\n", +"a_CO2 = 5.316;\n", +"a_O2 = 6.085;\n", +"a_N2 = 6.903;\n", +"a_H2O = 7.700;\n", +"a_C3H8 = -0.966;\n", +"b_CO2 = 1.4285*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"b_N2 = -0.03753*10^(-2);\n", +"b_H2O = 0.04594*10^(-2);\n", +"b_C3H8 = 7.279*10^(-2);\n", +"c_CO2 = -0.8362*10^(-5);\n", +"c_O2 = -0.1709*10^(-5);\n", +"c_N2 = 0.1930*10^(-5);\n", +"c_H2O = 0.2521*10^(-5);\n", +"c_C3H8 = -3.755*10^(-5);\n", +"d_CO2 = 1.784*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"d_N2 = -0.6861*10^(-9);\n", +"d_H2O = -0.8587*10^(-9);\n", +"d_C3H8 = 7.580*10^(-9);\n", +"\n", +"// The standard enthalpy of formation at 298.15 K is given by\n", +"delta_H_for_CO2 = -94.052;//[kcal/mol]\n", +"delta_H_for_C3H8 = -24.820;//[kcal/mol]\n", +"delta_H_for_H2O = -57.7979;//[kcal/mol]\n", +"\n", +"// The reaction with stoichiometric amount of air is\n", +"// C3H8 + 5(O2 + 3.7N2) - 3CO2 + 4H2O + 18.8N2\n", +"\n", +"// The reaction with 100% excess air is\n", +"// C3H8 + 10(O2 + 3.7N2) - 3CO2 + 4H2O + 5O2 + 37.6N2\n", +"\n", +"// The standard enthalpy change of reaction at 298.15 K\n", +"delta_H_rkn_298 = 3*delta_H_for_CO2 + 4*delta_H_for_H2O - delta_H_for_C3H8;\n", +"\n", +"// For exit stream\n", +"sum_ai_ni = 3*a_CO2 + 4*a_H2O + 5*a_O2 + 37.6*a_N2;\n", +"sum_bi_ni = 3*b_CO2 + 4*b_H2O + 5*b_O2 + 37.6*b_N2;\n", +"sum_ci_ni = 3*c_CO2 + 4*c_H2O + 5*c_O2 + 37.6*c_N2;\n", +"sum_di_ni = 3*d_CO2 + 4*d_H2O + 5*d_O2 + 37.6*d_N2;\n", +"\n", +"\n", +"// To raise the exit species from 298.15 to 500 K the enthalpy change is\n", +"delta_H_rkn = integrate('sum_ai_ni+sum_bi_ni*T+sum_ci_ni*T^(2)+sum_di_ni*T^(3)','T',T_1,T_2);//[cal]\n", +"delta_H_rkn = delta_H_rkn*10^(-3);//[kcal]\n", +"\n", +"// Therefore per mole of fuel the heat exchange is\n", +"// Q = Heat exchange in step 1 + Heat exchange in step 2\n", +"Q = delta_H_rkn_298 + delta_H_rkn;\n", +"\n", +"printf(' The heat transfer from the combustion chamber per mole of fuel is %f kcal (per mol of C3H8)',Q);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 18.2: Calculation_of_adiabatic_flame_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 18.2\n", +"//Page number - 650\n", +"printf('Example - 18.2 and Page number - 650\n\n');\n", +"\n", +"// Given\n", +"\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"\n", +"a_CO2 = 5.316;\n", +"a_H2O = 7.700;\n", +"a_O2 = 6.085;\n", +"a_C2H6 = 1.648;\n", +"b_CO2 = 1.4285*10^(-2);\n", +"b_H2O = 0.04595*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"b_C2H6 = 4.124*10^(-2);\n", +"c_CO2 = -0.8362*10^(-5);\n", +"c_H2O = 0.2521*10^(-5);\n", +"c_O2 = -0.1709*10^(-5);\n", +"c_C2H6 = -1.530*10^(-5);\n", +"d_CO2 = 1.784*10^(-9);\n", +"d_H2O = -0.8587*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"d_C2H6 = 1.740*10^(-9);\n", +"\n", +"// The standard enthalpy of formation at 298.15 K is given by\n", +"delta_H_for_CO2 = -94.052;//[kcal/mol]\n", +"delta_H_for_C2H6 = -20.236;//[kcal/mol]\n", +"delta_H_for_H2O = -57.7979;//[kcal/mol]\n", +"\n", +"// The reaction with stoichiometric amount of air is\n", +"// C2H6 + (7/2)O2 - 2CO2 + 3H2O\n", +"\n", +"// The reaction with 4 mol of O2 and 10 mol CO2 is\n", +"// C2H6 + 4O2 + 10CO2 - 12H2O + 3H2O + 0.5O2\n", +"// The product consists of 12 mol of CO2, 3 mol of water vapour and 0.5 mol of oxygen\n", +"delta_H_rkn_298 = 2*delta_H_for_CO2 + 3*delta_H_for_H2O - delta_H_for_C2H6;//[kcal]\n", +"delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", +"\n", +"// For exit stream\n", +"sum_ai_ni = 12*a_CO2 + 3*a_H2O + 0.5*a_O2;\n", +"sum_bi_ni = 12*b_CO2 + 3*b_H2O + 0.5*b_O2;\n", +"sum_ci_ni = 12*c_CO2 + 3*c_H2O + 0.5*c_O2;\n", +"sum_di_ni = 12*d_CO2 + 3*d_H2O + 0.5*d_O2;\n", +"\n", +"// From energy balance equation we get\n", +"// delta_H_rkn_298 + sum_ai_ni*(T_2 - T_1) + (sum_bi_ni/2)*(T_2^(2) - T_1^(2)) + (sum_ci_ni/3)*(T_2^(3) - T_1^(3)) + (sum_di_ni/4)*(T_2^(4) - T_1^(4))\n", +"// Solving above equation for T_2\n", +"deff('[y]=f(T_2)','y=delta_H_rkn_298 +sum_ai_ni*(T_2-T_1)+(sum_bi_ni/2)*(T_2^(2)-T_1^(2))+(sum_ci_ni/3)*(T_2^(3)-T_1^(3))+(sum_di_ni/4)*(T_2^(4)-T_1^(4))');\n", +"T_2 = fsolve(-1,f);\n", +"\n", +"printf(' The adiabatic flame temperature is %f K',T_2);\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 18.3: Calculation_of_mole_fraction_and_average_heat_capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 18.3\n", +"//Page number - 651\n", +"printf('Example - 18.3 and Page number - 651\n\n');\n", +"\n", +"// Given\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"\n", +"// The reaction with theoritical air is\n", +"// CH4 + 2(O2 + 3.76N2) - CO2 + 2H20 + 7.52N2\n", +"\n", +"//(1)\n", +"n_product = (1 + 2 + 7.52);// Total number of moles of product\n", +"// The mole fraction of water vapour is\n", +"y_H2O = 2/(n_product);\n", +"printf(' (1).The mole fraction of water vapour is %f\n\n',y_H2O);\n", +"\n", +"//(2)\n", +"delta_H_rkn_298 = -730*10^(3);//[J/mol]\n", +"C = 40;//[J/mol-K] - Average molar heat capacity\n", +"\n", +"// From energy balance we have\n", +"// delta_H_rkn_298 + n_product*C(T_2 - T_1) = 0\n", +"T_2 = - delta_H_rkn_298/(n_product*C) + T_1;//[K]\n", +"T_max = T_2 - T_1;\n", +"\n", +"printf(' (2).The maximum temperature rise of the exhaust gases is %f K\n',T_max);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 18.4: Determination_of_adiabatic_flame_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 18.4\n", +"//Page number - 651\n", +"printf('Example - 18.4 and Page number - 651\n\n');\n", +"\n", +"// Given\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"\n", +"// The standard enthalpy of formation at 298.15 K is given by\n", +"delta_H_for_CO2 = -94.052;//[kcal/mol]\n", +"delta_H_for_C8H18 = -59.780;//[kcal/mol]\n", +"delta_H_for_H2O = -57.7979;//[kcal/mol]\n", +"\n", +"a_CO2 = 5.316;\n", +"a_H2O = 7.700;\n", +"a_N2 = 6.903;\n", +"b_CO2 = 1.4285*10^(-2);\n", +"b_H2O = 0.04595*10^(-2);\n", +"b_N2 = -0.03753*10^(-2);\n", +"c_CO2 = -0.8362*10^(-5);\n", +"c_H2O = 0.2521*10^(-5);\n", +"c_N2 = 0.1930*10^(-5);\n", +"d_CO2 = 1.784*10^(-9);\n", +"d_H2O = -0.8587*10^(-9);\n", +"d_N2 = -0.6861*10^(-9);\n", +"\n", +"//(a)\n", +"// The reaction with stoichiometric amount of air is\n", +"// C3H18 + 12.5(O2 + 3.76N2) - 8CO2 + 9H2O + 47N2\n", +"\n", +"// The standard enthalpy change of reaction at 298.15 K is\n", +"delta_H_rkn_298 = 8*delta_H_for_CO2 + 9*delta_H_for_H2O - delta_H_for_C8H18;//[kcal]\n", +"delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", +"\n", +"// For exit stream\n", +"sum_ai_ni = 8*a_CO2 + 9*a_H2O + 47*a_N2;\n", +"sum_bi_ni = 8*b_CO2 + 9*b_H2O + 47*b_N2;\n", +"sum_ci_ni = 8*c_CO2 + 9*c_H2O + 47*c_N2;\n", +"sum_di_ni = 8*d_CO2 + 9*d_H2O + 47*d_N2;\n", +"\n", +"// From energy balance equation we get\n", +"// delta_H_rkn_298 + sum_ai_ni*(T_2 - T_1) + (sum_bi_ni/2)*(T_2^(2) - T_1^(2)) + (sum_ci_ni/3)*(T_2^(3) - T_1^(3)) + (sum_di_ni/4)*(T_2^(4) - T_1^(4))\n", +"// Solving above equation for T_2\n", +"deff('[y]=f(T_2)','y=delta_H_rkn_298 +sum_ai_ni*(T_2-T_1)+(sum_bi_ni/2)*(T_2^(2)-T_1^(2))+(sum_ci_ni/3)*(T_2^(3)-T_1^(3))+(sum_di_ni/4)*(T_2^(4)-T_1^(4))');\n", +"T_2 = fsolve(-1,f);\n", +"\n", +"printf(' (1).The adiabatic flame temperature is %f K\n\n',T_2);\n", +"\n", +"//(2)\n", +"// The mean standard heat capacity of various components over the temperature range from 25 to 3000 C is \n", +"Cp_CO2 = 13.91;//[cal/mol-K]\n", +"Cp_H2O = 10.16;//[cal/mol-K]\n", +"Cp_O2 = 7.88;//[cal/mol-K]\n", +"Cp_N2 = 7.45;//[cal/mol-K]\n", +"\n", +"// From energy balance equation we get\n", +"// delta_H_rkn_298 + (8*Cp_CO2 + 9*Cp_H2O + 47*Cp_N2)*(T_2_prime)\n", +"T_2_prime = - delta_H_rkn_298/(8*Cp_CO2 + 9*Cp_H2O + 47*Cp_N2);//[K]\n", +"\n", +"printf(' (2).The adiabatic flame temperature is %f K',T_2_prime);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 18.5: Calculation_of_conversion.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 18.5\n", +"//Page number - 652\n", +"printf('Example - 18.5 and Page number - 652\n\n');\n", +"\n", +"// Given\n", +"// N2 + 3H2 - 2NH3\n", +"T_1 = 700;//[K] - Reaction temperature\n", +"Max_adia_rise = 100;///[K] - Maximum adiabatic rise in temperature\n", +"T_2 = T_1 + Max_adia_rise;//[K] - \n", +"\n", +"delta_H_rkn_700 = -94.2;//[kJ] - Standard enthalpy of reaction at 700 K\n", +"delta_H_rkn_700 = delta_H_rkn_700*10^(3);//[J]\n", +"\n", +"// The mean standard heat capacity of various components over the temperature range from 700 to 800 K is \n", +"Cp_N2 = 30.0;//[cal/mol-K]\n", +"Cp_H2 = 28.9;//[cal/mol-K]\n", +"Cp_NH3 = 49.2;//[cal/mol-K]\n", +"\n", +"// The energy balance equation is\n", +"// X*delta_H_rkn_700 + integrate('(sum_ni_Cpi_exit)*dT','T',T_1,T_2)\n", +"\n", +"//At exit, let moles of NH3 = (1-X), moles of H2 = (3-3X), moles of NH3 = 2X . Therefore we have,\n", +"// delta_H_rkn_700*X + {(1-X)*Cp_N2 + (3-3X)*Cp_H2 + (2X)*Cp_NH3}*(T_2 - T_1)\n", +"// On simplification we get, 960.3*X = 116.7\n", +"X = 116.7/960.3;\n", +"\n", +"printf(' The maximum allowable conversion fraction in the reactor is given by, X = %f \n',X);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 18.6: Calculation_of_maximum_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 18.6\n", +"//Page number - 653\n", +"printf('Example - 18.6 and Page number - 653\n\n');\n", +"\n", +"// Given\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"V = 2.0*10^(-3);//[m^(3)] - Volume of calorimeter\n", +"m = 10;//[g] - Mass of liquid octane\n", +"Mol_wt = 114;//[g/mol] - Molecular weight of octane\n", +"n = m/Mol_wt;//[mol] - No of moles of octane\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// The standard enthalpy of formation at 298.15 K is given by\n", +"delta_H_for_CO2 = -94.052;//[kcal/mol]\n", +"delta_H_for_C8H18 = -59.780;//[kcal/mol]\n", +"delta_H_for_H2O = -57.7979;//[kcal/mol]\n", +"\n", +"// The standard molar heat capacity of various components in high temperature range from is given by \n", +"// Cp_H2O = 6.970 + 0.3464*10^(-2)*T - 0.04833*10^(-5)*T^(2);\n", +"// Cp_O2 = 6.732 + 0.1505*10^(-2)*T - 0.01791*10^(-5)*T^(2);\n", +"// Cp_CO2 = 18.036 - 4.474*10^(-5)*T - 158.08/(T^(1/2));\n", +"// Therefore we have\n", +"// Sum_ni_Cpi_exit = 249.09 + 0.04*T - 0.547*10^(-5)*T^(2) - 1264.64/(T^(1/2))\n", +"\n", +"// The reaction with stoichiometric amount of oxygen is\n", +"// C8H18 + 12.5O2 - 8CO2 + 9H2O\n", +"\n", +"// The reaction with 50% excess oxygen is\n", +"// C8H18 + 18.75O2 - 8CO2 +9H2O + 6.25O2\n", +"\n", +"// The standard enthalpy change of reaction at 298.15 K is\n", +"delta_H_rkn_298 = 8*delta_H_for_CO2 + 9*delta_H_for_H2O - delta_H_for_C8H18;//[kcal]\n", +"delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", +"\n", +"// From the energy balance equation we get\n", +"// delta_H_rkn_298 + integrate('(sum_ni_Cpi_exit)*dT','T',T_1,T_2)\n", +"// delta_H_rkn_298 + 249.09*(T_2 - T_1) + (0.04/2)*(T_2^(2) - T_1^(2)) - ((0.547*10^(-5))/3)*(T_2^(3)-T_1^(3)) - (1264.64*2)*(T_2^(1/2)-T_1^(1/2))\n", +"// Solving above equation for T_2\n", +"deff('[y]=f(T_2)','y=delta_H_rkn_298 + 249.09*(T_2 - T_1) + (0.04/2)*(T_2^(2)-T_1^(2)) - ((0.547*10^(-5))/3)*(T_2^(3)-T_1^(3)) - (1264.64*2)*(T_2^(1/2)-T_1^(1/2))');\n", +"T_2 = fsolve(1000,f);\n", +"\n", +"// When 1 mol of octane reacts the final number of moles in the calorimeter is 23.25\n", +"// When n mol of octane reacts the final number of moles in the calorimeter is\n", +"n_total = n*23.25;//[mol]\n", +"\n", +"// The maximum explosion pressure is calculated when no heat is dissipated to the surroundings and thus bomb calorimeter attains the adiabatic flame temperature\n", +"// Thus maximum explosion pressure is given by\n", +"P = (n_total*R*T_2)/V;//[N/m^(2)]\n", +"P = P*10^(-5);//[bar]\n", +"\n", +"printf(' The maximum explosion pressure inside the bomb calorimeter is %f bar',P);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 18.7: Calculation_of_number_of_moles.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 18.7\n", +"//Page number - 656\n", +"printf('Example - 18.7 and Page number - 656\n\n');\n", +"\n", +"// Given\n", +"T_1 = 400 + 273.15;//[K]\n", +"// SO2(g) + 1/2*(O2) (g) - SO3 (g)\n", +"\n", +"a_SO2 = 6.157;\n", +"a_SO3 = 3.918;\n", +"a_O2 = 6.085;\n", +"a_N2 = 6.903;\n", +"b_SO2 = 1.384*10^(-2);\n", +"b_SO3 = 3.483*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"b_N2 = -0.03753*10^(-2);\n", +"c_SO2 = -0.9103*10^(-5);\n", +"c_SO3 = -2.675*10^(-5);\n", +"c_O2 = -0.01709*10^(-5);\n", +"c_N2 = 0.1930;\n", +"d_SO2 = 2.057*10^(-9);\n", +"d_SO3 = 7.744*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"d_N2 = -0.6861*10^(-9);\n", +"\n", +"// At 400 C, from the given expressions\n", +"delta_H_rkn_T_1 = -22630.14 - 5.2815*T_1 + 0.9587*10^(-2)*T_1^(2) - 0.5598*10^(-5)*T_1^(3) + 1.3826*10^(-9)*T_1^(4);//[cal]\n", +"// This is the standard enthalpy change of reaction for 1 mol of SO2 reacted. Since X moles of SO2 are reactants therefore \n", +"// delta_H_rkn_T_X (for X moles of SO2 reacted) = delta_H_rkn_T_1*X\n", +"\n", +"// Let the number of moles at equilibrium be\n", +"// n_O2 = 9-0.5*X\n", +"// n_SO2 = 12-X\n", +"// n_SO3 = X\n", +"// n_N2 = 79\n", +"// Total moles at equilibrium = 100-0.5X\n", +"// Ky = y_SO3/(y_SO2*y_O2^(1/2))\n", +"// Ky = (X*(100-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))\n", +"// We know that K = Ky*Kp. Since P = 1 atm, therefore Ky = K\n", +"\n", +"// Now we have to account for the heat required to raise 9-0.5*X mol of O2, 12-X mol of SO2, X mol of SO3 and 79 mol of N2 from T to ART\n", +"// sum_ni_Cp_i = (12-X)*(a + b*T + c*T^(2) + d*T^(3)) + (9-0.5*X)*(a + b*T + c*T^(2) + d*T^(3)) + X*(a + b*T + c*T^(2) + d*T^(3)) + 79*(a + b*T + c*T^ (2) + d*T^(3))\n", +"\n", +"// From energy balance equation we get\n", +"// delta_H_rkn_T_1 + integrate('sum_ni_Cp_i','T',T_1,T)\n", +"// The above equation on simplification becomes\n", +"// (673.99-5.2815*X)*(T-T_1) + (16.91+1.9175*X)*(10^(-2)/2)*(T^(2)-T_1^(2)) + (2.79-1.6793*X)*(10^(-5)/3)*(T^(3)-T_1^(3)) + (-26.70+5.5304*X)*(10^(-9) /4)*(T^(4)-T_1^(4)) = delta_H_rkn_T_1*X\n", +"\n", +"// Let us assume a temperature, say\n", +"T = 800;//[K]\n", +"fault = 10;\n", +"\n", +"while(fault>0.01)\n", +" K = exp(3.87 + (11389.10/T) - 2.6580*log(T) + 0.4825*10^(-2)*T - 0.1409*10^(-5)*T^(2) + 0.2320*10^(-9)*T^(3));\n", +" deff('[y]=f(X)','y= K - (X*(100-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))');\n", +" X1 = fsolve(0.1,f);// X from equilibrium equation\n", +" deff('[y]=f1(X)','y= (673.99-5.2815*X)*(T-T_1)+(16.91+1.9175*X)*(10^(-2)/2)*(T^(2)-T_1^(2))+(2.79-1.6793*X)*(10^(-5)/3)*(T^(3)-T_1^(3))+(-26.70+5.5304*X)*(10^(-9)/4)*(T^(4)-T_1^(4))+delta_H_rkn_T_1*X');\n", +" X2 = fsolve(1,f1);// X from energy balance equation\n", +" fault = abs(X1-X2);\n", +" T = T + 0.01;\n", +"end\n", +"\n", +"printf(' The moles of SO2 reacted are %f mol\n\n',X1);\n", +"printf(' The adiabatic reaction temperature is %f K\n',T);\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/2-Equations_of_state.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/2-Equations_of_state.ipynb new file mode 100644 index 0000000..72a9295 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/2-Equations_of_state.ipynb @@ -0,0 +1,1168 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2: Equations of state" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.10: Estimation_of_molar_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 2.10\n", +"//Page number - 52\n", +"printf('Example - 2.10 and Page number - 52\n\n');\n", +"\n", +"//Given\n", +"T = 71+273.15;//[K] - Temperature\n", +"P = 69*10^(5);//[N/m^(2)] - Pressure\n", +"y1 = 0.5;//[mol] - mole fraction of equimolar mixture\n", +"y2 = 0.5;\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"//For component 1 (methane)\n", +"Tc_1 =190.6;//[K] - Critical temperature\n", +"Pc_1 = 45.99*10^(5);//[N/m^(2)] - Critical pressure\n", +"Vc_1 = 98.6;//[cm^(3)/mol] - Critical volume\n", +"Zc_1 = 0.286;// Critical compressibility factor\n", +"w_1 = 0.012;// acentric factor\n", +"\n", +"//For component 2 (hydrogen sulphide)\n", +"Tc_2 = 373.5;//[K]\n", +"Pc_2 = 89.63*10^(5);//[N/m^(2)]\n", +"Vc_2 = 98.5;//[cm^(3)/mol]\n", +"Zc_2 = 0.284;\n", +"w_2 = 0.094;\n", +"\n", +"//For component 1\n", +"Tr_1 = T/Tc_1;//Reduced temperature\n", +"//At reduced temperature\n", +"B1_0 = 0.083-(0.422/(Tr_1)^(1.6));\n", +"B1_1 = 0.139-(0.172/(Tr_1)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;//[m^(3)/mol]\n", +"\n", +"//Similarly for component 2\n", +"Tr_2 = T/Tc_2;//Reduced temperature\n", +"//At reduced temperature Tr_2,\n", +"B2_0 = 0.083 - (0.422/(Tr_2)^(1.6));\n", +"B2_1 = 0.139 - (0.172/(Tr_2)^(4.2));\n", +"B_22 = ((B2_0+(w_2*B2_1))*(R*Tc_2))/Pc_2;//[m^(3)/mol]\n", +"\n", +"//For cross coeffcient\n", +"Tc_12 = (Tc_1*Tc_2)^(1/2);//[K]\n", +"w_12 = (w_1 + w_2)/2;\n", +"Zc_12 = (Zc_1 + Zc_2)/2;\n", +"Vc_12 = (((Vc_1)^(1/3) + (Vc_2)^(1/3))/2)^(3);//[cm^(3)/mol]\n", +"Vc_12 = Vc_12*10^(-6);//[m^(3)/mol]\n", +"Pc_12 = (Zc_12*R*Tc_12)/Vc_12;//[N/m^(2)]\n", +"\n", +"//Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0+(w_12*B_1)\n", +"//where B_0 and B_1 are to be evaluated at Tr_12\n", +"Tr_12 = T/Tc_12;\n", +"//At reduced temperature Tr_12\n", +"B_0 = 0.083 - (0.422/(Tr_12)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr_12)^(4.2));\n", +"B_12=((B_0 + (w_12*B_1))*R*Tc_12)/Pc_12;//[m^(3)/mol]\n", +"\n", +"//For the mixture\n", +"B = y1^(2)*B_11+2*y1*y2*B_12 + y2^(2)*B_22;//[m^(3)/mol]\n", +"\n", +"//Now given virial equation is, Z=1+(B*P)/(R*T)\n", +"Z = 1 + (B*P)/(R*T);\n", +"\n", +"//Also Z = (P*V)/(R*T).Therefore,\n", +"V = (Z*R*T)/P;//[m^(3)/mol]\n", +"\n", +"printf(' The molar volume of the mixture is %e m^(3)/mol',V);\n", +"//The value obtained is near the experimental value of V_exp = 3.38*10^(-4) m^(3)/mol\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.11: Calculation_of_maximum_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"// Example - 2.11\n", +"// Page number - 53\n", +"printf('Example - 2.11 and Page number - 53\n\n');\n", +"// Given\n", +"P = 6*10^(6);// [Pa] - Pressure\n", +"P_max = 12*10^(6);// [Pa] - Max pressure to which cylinder may be exposed\n", +"T = 280;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"//(1).Assuming ideal gas behaviour,\n", +"V_ideal = (R*T)/P;//[m^(3)/mol]\n", +"//Now when temperature and pressure are increased,the molar volume remains same,as total volume and number of moles are same.\n", +"//For max pressure of 12 MPa,temperature is\n", +"T_max_ideal = (P_max*V_ideal)/R;\n", +"printf(' (1).The maximum temperature assuming ideal behaviour is %f K\n',T_max_ideal);\n", +"// (2).Assuming virial equation of state\n", +"// For component 1 (methane),at 280 K\n", +"Tc_1 = 190.6;//[K]\n", +"Pc_1 = 45.99*10^(5);//[N/m^(2)]\n", +"Vc_1 = 98.6;//[cm^(3)/mol]\n", +"Zc_1 = 0.286;\n", +"w_1 = 0.012;\n", +"Tr_1 = T/Tc_1;//Reduced temperature\n", +"B1_0 = 0.083 - (0.422/(Tr_1)^(1.6));\n", +"B1_1 = 0.139 - (0.172/(Tr_1)^(4.2));\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B_11 = ((B1_0 + (w_1*B1_1))*(R*Tc_1))/Pc_1;//[m^(3)/mol]\n", +"//For component 2 (Propane)\n", +"Tc_2 = 369.8;//[K]\n", +"Pc_2 = 42.48*10^(5);//[N/m^(2)]\n", +"Vc_2 = 200;//[cm^(3)/mol]\n", +"Zc_2 = 0.276;\n", +"w_2 = 0.152;\n", +"Tr_2 = T/Tc_2;// Reduced temperature\n", +"B2_0 = 0.083 - (0.422/(Tr_2)^(1.6));\n", +"B2_1 = 0.139 - (0.172/(Tr_2)^(4.2));\n", +"B_22 = ((B2_0 + (w_2*B2_1))*(R*Tc_2))/Pc_2;//[m^(3)/mol]\n", +"//For cross coeffcient\n", +"y1 = 0.8;//mole fraction of component 1\n", +"y2 = 0.2;//mole fraction of component 2\n", +"Tc_12 = (Tc_1*Tc_2)^(1/2);//[K]\n", +"w_12 = (w_1 + w_2)/2;\n", +"Zc_12 = (Zc_1 + Zc_2)/2;\n", +"Vc_12 = (((Vc_1)^(1/3) + (Vc_2)^(1/3))/2)^(3);//[cm^(3)/mol]\n", +"Vc_12 = Vc_12*10^(-6);//[m^(3)/mol]\n", +"Pc_12 = (Zc_12*R*Tc_12)/Vc_12;//[N/m^(2)]\n", +"Tr_12 = T/Tc_12;\n", +"//At reduced temperature,Tr_12,\n", +"B_0 = 0.083 - (0.422/(Tr_12)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr_12)^(4.2));\n", +"B_12 = ((B_0 + (w_12*B_1))*R*Tc_12)/Pc_12;//[m^(3)/mol]\n", +"//For the mixture\n", +"B = y1^(2)*B_11+2*y1*y2*B_12 + y2^(2)*B_22;//[m^(3)/mol]\n", +"//Now given virial equation is, Z=1+(B*P)/(R*T)\n", +"Z = 1 + (B*P)/(R*T);\n", +"//Also Z = (P*V)/(R*T).Therefore,\n", +"V_real = (Z*R*T)/P;//[m^(3)/mol]\n", +"// This molar volume remains the same as the volume and number of moles remains fixed.\n", +"// Sice Z is a function of presure and temperature,we shall assume a temperature,calculate Z and again calculate temperature,till convergence is obtained.\n", +"// We will use the concept of iteration to compute the convergent value of temperature\n", +"// Let us start with the temperature at ideal conditions i.e T = 560 K,\n", +"T_prime = 560;//[K]\n", +"fault = 10;\n", +"while(fault > 1)\n", +"T_prime_r1 = T_prime/Tc_1;\n", +"B_prime1_0 = 7.7674*10^(-3);\n", +"B_prime1_1 = 0.13714;\n", +"B_prime_11 = ((B_prime1_0 + (w_1*B_prime1_1))*(R*Tc_1))/Pc_1;//[m^(3)/mol]\n", +"//Similarly for component 2,\n", +"T_prime_r2 = T_prime/Tc_2;\n", +"B_prime2_0 = -0.1343;\n", +"B_prime2_1 = 0.10887;\n", +"B_prime_22 = ((B_prime2_0 + (w_2*B_prime2_1))*(R*Tc_2))/Pc_2;//[m^(3)/mol]\n", +"//For cross coefficient (assuming k12=0)\n", +"//Tc_12 , w_12 , Zc_12 , Vc_12 and Pc_12 have already been calculated above,now\n", +"T_prime_r12 = T_prime/Tc_12;//\n", +"//At reduced temperature,T_prime_r12,\n", +"B_prime_0 = 0.083 - (0.422/(T_prime_r12)^(1.6));\n", +"B_prime_1 = 0.139 - (0.172/(T_prime_r12)^(4.2));\n", +"B_prime_12 = ((B_prime_0+(w_12*B_prime_1))*R*Tc_12)/Pc_12;//[m^(3)/mol]\n", +"//For the mixture\n", +"B_prime = y1^(2)*B_prime_11 + 2*y1*y2*B_prime_12 + y2^(2)*B_prime_22;//[m^(3)/mol]\n", +"Z_prime = 1 + (B_prime*P_max)/(R*T_prime);\n", +"T_new = (P_max*V_real)/(Z_prime*R);\n", +"fault = abs(T_prime - T_new);\n", +"T_prime = T_new;\n", +"end\n", +"printf(' (2).The maximum temperature assuming the gas to follow virial equation of stste is %f K\n',T_new);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.12: Calculation_of_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"// Example - 2.12\n", +"// Page number - 64\n", +"printf('Example - 2.12 and Page number - 64\n\n');\n", +"\n", +"//Given\n", +"\n", +"V_vessel = 0.1;//[m^(3)]// Volume of vessel\n", +"T = 25 + 273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"m = 25*1000;//[g]// Mass of ethylene\n", +"Tc = 282.3;//[K] - Critical temperature\n", +"Pc = 50.40;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[N/m^(2)]\n", +"Zc = 0.281;// Critical compressibility factor\n", +"Vc = 131;//[cm^(3)/mol] - Critical volume\n", +"Vc = Vc*10^(-6);//[m^(3)/mol]\n", +"w = 0.087;// Acentric factor\n", +"M = 28.054;// Molecular weight of ethylene\n", +"\n", +"n = m/M;//[mole] - No. of moles of ethylene\n", +"V = V_vessel/n;//[m^(3)/mol] - Molar volume\n", +"\n", +"//Under Redlich Kwong equation of state, we have\n", +"a = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b = (0.08664*R*Tc)/Pc;//[m^(3)/mol]\n", +"P = ((R*T)/(V-b))-(a/(T^(1/2)*V*(V+b)));//[N/m^(2)]\n", +"printf(' The required pressure using Redlich Kwong equation of state is %e N/m^(2)\n',P);\n", +"\n", +"//For ideal gas equation of state,\n", +"P_ideal = (R*T)/V;//[N/m^(2)]\n", +"printf(' For ideal gas equation of state,the required pressure is %e N/m^(2)\n',P_ideal);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.13: Calculation_of_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"// Example - 2.13\n", +"// Page number - 65\n", +"printf('Example - 2.13 and Page number - 65\n\n');\n", +"\n", +"//Given\n", +"\n", +"V_vessel = 360*10^(-3);//[m^(3)] - volume of vessel\n", +"T = 62+273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"m = 70*1000;//[g]/ - Mass of carbon dioxide\n", +"\n", +"//For carbon dioxide\n", +"Tc = 304.2;//[K] - Cricitical temperature\n", +"Pc = 73.83;//[bar] - Cricitical pressure\n", +"Pc = Pc*10^(5);// [N/m^(2)]\n", +"Zc = 0.274;// Critical compressibility factor\n", +"Vc = 94.0;//[cm^(3)/mol]\n", +"Vc = Vc*10^(-6);//[m^(3)/mol]\n", +"w = 0.224;// Acentric factor\n", +"M = 44.01;// Molecular weight of carbon dioxide\n", +"\n", +"n = m/M;//[mol] - No. of moles\n", +"V = V_vessel/n;//[m^(3)/mol]//molar volume\n", +"\n", +"// (1)\n", +"// Ideal gas behaviour\n", +"P_1 = (R*T)/V;//[N/m^(2)]\n", +"printf(' (1).The required pressure using ideal equation of state is %e N/m^(2)\n',P_1);\n", +"\n", +"// (2)\n", +"// Virial equation of state, Z = 1 + (B*P)/(R*T)\n", +"// (P*V)/(R*T) = 1 + (B*P)/(R*T), and thus P = (R*T)/(V - B). Now\n", +"Tr = T/Tc;//Reduced temperature\n", +"// At reduced temperature Tr,\n", +"B_0 = 0.083 - (0.422/(Tr)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr)^(4.2));\n", +"B = ((B_0 + (w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]\n", +"P_2 = (R*T)/(V - B);//[N/m^(2)]\n", +"printf(' (2).The required pressure using given virial equation of state is %e N/m^(2)\n',P_2);\n", +"\n", +"// (3)\n", +"// Virial equation of state, Z = 1 + (B/V)\n", +"// (P*V)/(R*T) = 1 + (B/V)\n", +"P_3 = ((R*T)/V) + (B*R*T)/(V^(2));//[N/m^(2)]\n", +"printf(' (3).The required pressure using given virial equation of state is %e N/m^(2)\n',P_3);\n", +"\n", +"// (4)\n", +"// Van der Walls equation of state,P = ((R*T)/(V-b)) - a/(V^(2))\n", +"a = (27*(R^(2))*(Tc^(2)))/(64*Pc);//[Pa*m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"P_4 = ((R*T)/(V-b)) - a/(V^(2));//[N/m^(2)]\n", +"printf(' (4).The required pressure using van der Walls equation of state is %e N/m^(2)\n',P_4);\n", +"\n", +"//(5)\n", +"// Redlich Kwong equation of state,\n", +"a_1 = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b_1 = (0.08664*R*Tc)/Pc;//[m^(3)/mol]\n", +"P_5 = ((R*T)/(V - b_1)) - (a_1/(T^(1/2)*V*(V + b_1)));//[N/m^(2)]\n", +"printf(' (5).The required pressure using Redlich Kwong equation of state is %e N/m^(2)\n',P_5);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.14: Determination_of_compressibility_factor.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"// Example - 2.14\n", +"// Page number - 66\n", +"printf('Example - 2.14 and Page number - 66\n\n');\n", +"//Given\n", +"T = 500+273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"P = 325*1000;//[Pa] - Pressure\n", +"Tc = 647.1;//[K] - Cricitical temperature\n", +"Pc = 220.55;//[bar] - Cricitical pressure\n", +"Pc = Pc*10^(5);//[N/m^(2)]\n", +"//(1)\n", +"// Van der Walls equation of state,\n", +"a = (27*(R^(2))*(Tc^(2)))/(64*Pc);//[Pa*m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P=0\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P');\n", +"V_1 = fsolve(1,f);\n", +"V_2 = fsolve(10,f);\n", +"V_3 = fsolve(100,f);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root,\n", +"Z_1 = (P*V_1)/(R*T);//compressibility factor\n", +"printf(' (1).The compressibility factor of steam using van der Walls equation of state is %f\n',Z_1);\n", +"//(2)\n", +"//Redlich Kwong equation of state,\n", +"a_1 = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b_1 = (0.08664*R*Tc)/Pc;//[m^(3)/mol]\n", +"// The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3)-((R*T)/P)*V^(2)-((b_1^(2))+((b_1*R*T)/P)-(a/(T^(1/2)*P))*V-(a*b)/(T^(1/2)*P)=0\n", +"//Solving the cubic equation\n", +"deff('[y]=f1(V)','y=V^(3)-((R*T)/P)*V^(2)-((b_1^(2))+((b_1*R*T)/P)-(a_1/(T^(1/2)*P)))*V-(a_1*b_1)/(T^(1/2)*P)');\n", +"V_4=fsolve(1,f1);\n", +"V_5=fsolve(10,f1);\n", +"V_6=fsolve(100,f1);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root,\n", +"// Thus compressibility factor is\n", +"Z_2 = (P*V_4)/(R*T);//compressibility factor\n", +"printf(' (2).The compressibility factor of steam using Redlich Kwong equation of state is %f\n',Z_2);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.15: Determination_of_molar_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"// Example - 2.15\n", +"// Page number - 67\n", +"printf('Example - 2.15 and Page number - 67\n\n');\n", +"\n", +"//Given\n", +"T = 250+273.15;//[K]\n", +"R = 8.314;//[J/mol*K]\n", +"P = 39.76;//[bar] Vapour pressure of water at T\n", +"P = P*10^(5);//[N/m^(2)]\n", +"Tc = 647.1;//[K] - Cricitical temperature\n", +"Pc = 220.55*10^(5);//[N/m^(2)] - Cricitical pressure\n", +"w = 0.345;//Acentric factor\n", +"M = 18.015;// Molecular weight of water\n", +"\n", +"// Using peng-Robinson equation of stste \n", +"m = 0.37464 + 1.54226*w - 0.26992*w^(2);\n", +"Tr = T/Tc;\n", +"alpha = (1 + m*(1 - Tr^(1/2)))^(2);\n", +"a = ((0.45724*(R*Tc)^(2))/Pc)*alpha;//[Pa*m^(6)/mol^(2)]\n", +"b = (0.07780*R*Tc)/Pc;//[m^(3)/mol]\n", +"// Cubuc form of Peng-Robinson equation of stste is given by\n", +"// V^(3) + (b-(R*T)/P)*V^(2) - ((3*b^(2)) + ((2*R*T*b)/P) - (a/P))*V+b^(3) + ((R*T*(b^(2))/P) - ((a*b)/P) = 0;\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2)))/P)-((a*b)/P)');\n", +"V_1 = fsolve(-1,f);\n", +"V_2 = fsolve(0,f);\n", +"V_3 = fsolve(1,f);\n", +"//The largest root is for vapour phase,\n", +"V_vap = V_3;//[m^(3)/mol] - Molar volume (saturated vapour)\n", +"V_vap = V_vap*10^(6)/M;//[cm^(3)/g]\n", +"\n", +"printf(' The moar volume of saturated water in the vapour phase (V_vap) is %f cm^(3)/g\n',V_vap);\n", +"\n", +"//The smallest root is for liquid phase,\n", +"V_liq = V_1;//[m^(3)/mol] - molar volume (saturated liquid)\n", +"V_liq = V_liq*10^(6)/M;//[cm^(3)/g]\n", +"printf(' The moar volume of saturated water in the liquid phase (V_liq) is %f cm^(3)/g\n',V_liq);\n", +"\n", +"//From steam table at 250 C, V_vap = 50.13 [cm^(3)/g] and V_liq = 1.251 [cm^(3)/g].\n", +"printf(' From steam table at 250 C, V_vap = 50.13 [cm^(3)/g] and V_liq = 1.251 [cm^(3)/g]');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.16: Calculation_of_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"// Example - 2.16\n", +"// Page number - 68\n", +"printf('Example - 2.16 and Page number - 68\n\n');\n", +"\n", +"//Given\n", +"T = 500+273.15;//[K] - Temperature\n", +"P = 15;//[atm] - Pressure\n", +"P = P*101325;//[N/m^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"Tc = 190.6;//[K] - Cricitical temperature\n", +"Pc = 45.99*10^(5);//[N/m^(2)] - Cricitical pressure\n", +"Vc = 98.6;//[cm^(3)/mol] - Cricitical molar volume\n", +"Zc = 0.286;// Critical compressibility factor\n", +"w = 0.012;// Acentric factor\n", +"\n", +"//(1)\n", +"//Virial equation of state,Z = 1 + (B*P)/(R*T)\n", +"Tr_1 = T/Tc;//Reduced temperature\n", +"B_0 = 0.083-(0.422/(Tr_1)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr_1)^(4.2));\n", +"// We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B = ((B_0+(w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]//second virial coefficient\n", +"Z = 1 + (B*P)/(R*T);//compressibility factor\n", +"//(P*V)/(R*T)=1+(B*P)/(R*T),and thus,\n", +"V_1 = (Z*R*T)/P;//[m^(3)/mol]\n", +"printf(' (1).The molar volume of methane using given virial equation is %e m^(3)/mol\n',V_1);\n", +"\n", +"//(2).\n", +"//Virial equation of state,Z = 1 + (B/V)\n", +"//Also,Z = (P*V)/(R*T). Substituting the value of Z,we get\n", +"// V^(2) - ((R*T)/P)*V - ((B*R*T)/P) = 0.Solving the quadratic equation\n", +"deff('[y]=f(V)','y=V^(2)-((R*T)/P)*V-((B*R*T)/P)');\n", +"V2_1=fsolve(0,f);\n", +"V2_2=fsolve(1,f);\n", +"// Out of two roots,we will consider only positive root\n", +"printf(' (2).The molar volume of methane using given virial equation is %e m^(3)/mol\n',V2_2);\n", +"\n", +"// (3)\n", +"// Van der Walls equation of state,\n", +"// (P + (a/V^(2)))*(V - b) = R*T\n", +"a_3 = (27*(R^(2))*(Tc^(2)))/(64*Pc);//[Pa*m^(6)/mol^(2)]\n", +"b_3 = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3) - (b + (R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"// Solving the cubic equation\n", +"deff('[y]=f1(V)','y=V^(3)-(b_3+(R*T)/P)*V^(2)+(a_3/P)*V-(a_3*b_3)/P');\n", +"V3_1=fsolve(1,f1);\n", +"V3_2=fsolve(10,f1);\n", +"V3_3=fsolve(100,f1);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root.\n", +"printf(' (3).The molar volume of methane using van der Walls equation of state is %e m^(3)/mol\n',V3_1);\n", +"\n", +"// (4)\n", +"// Redlich Kwong equation of state\n", +"a_4 = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b_4 = (0.08664*R*Tc)/Pc;//[m^(3)/mol]\n", +"// The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3) - ((R*T)/P)*V^(2) - ((b_1^(2)) + ((b_1*R*T)/P) - (a/(T^(1/2)*P))*V - (a*b)/(T^(1/2)*P) = 0\n", +"// Solving the cubic equation\n", +"deff('[y]=f2(V)','y=V^(3)-((R*T)/P)*V^(2)-((b_4^(2))+((b_4*R*T)/P)-(a_4/(T^(1/2)*P)))*V-(a_4*b_4)/(T^(1/2)*P)');\n", +"V4_1=fsolve(1,f2);\n", +"V4_2=fsolve(10,f2);\n", +"V4_3=fsolve(100,f2);\n", +"//The above equation has 1 real and 2 imaginary roots. We consider only real root.\n", +"printf(' (4).The molar volume of methane using Redlich Kwong equation of state is %e m^(3)/mol\n',V4_1);\n", +"\n", +"// (5)\n", +"// Using Peng-Robinson equation of state \n", +"m = 0.37464 + 1.54226*w - 0.26992*w^(2);\n", +"Tr_5 = T/Tc;\n", +"alpha = (1 + m*(1 - Tr_5^(1/2)))^(2);\n", +"a = ((0.45724*(R*Tc)^(2))/Pc)*alpha;//[Pa*m^(6)/mol^(2)]\n", +"b = (0.07780*R*Tc)/Pc;//[m^(3)/mol]\n", +"// Cubic form of Peng-Robinson equation of stste is given by\n", +"// V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2))/P)-((a*b)/P)=0;\n", +"// Solving the cubic equation\n", +"deff('[y]=f3(V)','y=V^(3)+(b-(R*T)/P)*V^(2)-((3*b^(2))+((2*R*T*b)/P)-(a/P))*V+b^(3)+((R*T*(b^(2)))/P)-((a*b)/P)');\n", +"V5_1=fsolve(-1,f3);\n", +"V5_2=fsolve(0,f3);\n", +"V5_3=fsolve(1,f3);\n", +"//The largest root is for vapour phase,\n", +"//The largest root is only considered as the systemis gas\n", +"printf(' (5).The molar volume of methane using Peng-Robinson equation of state is %e m^(3)/mol\n',V5_3);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.17: Estimation_of_compressibility_factor.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"// Example - 2.17\n", +"// Page number - 70\n", +"printf('Example - 2.17 and Page number - 70\n\n');\n", +"\n", +"//Given\n", +"T = 310.93;//[K] - Temperature\n", +"P = 2.76*10^(6);//[N/m^(2)] - Pressure\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"y1 = 0.8942;// Mole fraction of component 1 (methane)\n", +"y2 = 1-y1;// Mole fraction of component 2 (n-butane)\n", +"\n", +"//For component 1 (methane)\n", +"Tc_1 = 190.58;//[K] - Cricitical temperature\n", +"Pc_1 = 46.05;//[bar] - Cricitical pressure\n", +"Pc_1 = Pc_1*10^(5);//[N/m^(2)]\n", +"Zc_1 = 0.288;// Critical compressibility factor\n", +"Vc_1 = 99.1;//[cm^(3)/mol]\n", +"Vc_1 = Vc_1*10^(-6);//[m^(3)/mol]\n", +"w_1 = 0.011;// Acentric factor\n", +"\n", +"//For component 2 (n-butane)\n", +"Tc_2 = 425.18;//[K] - Cricitical temperature\n", +"Pc_2 = 37.97;//[bar] - Cricitical pressure\n", +"Pc_2 = Pc_2*10^(5);// [N/m^(2)]\n", +"Zc_2 = 0.274;// Critical compressibility factor\n", +"Vc_2 = 255.1;// [cm^(3)/mol]\n", +"Vc_2 = Vc_2*10^(-6);// [m^(3)/mol]\n", +"w_2 = 0.193;// Acentric factor\n", +"\n", +"// (1)\n", +"// Virial equation of state, Z = 1 + (B*P)/(R*T)\n", +"// For component 1 (methane)\n", +"Tr_1 = T/Tc_1;//Reduced temperature\n", +"// At reduced temperature\n", +"B1_0 = 0.083 - (0.422/(Tr_1)^(1.6));\n", +"B1_1 = 0.139 - (0.172/(Tr_1)^(4.2));\n", +"// We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;//[m^(3)/mol]\n", +"\n", +"//Similarly for component 2\n", +"Tr_2 = T/Tc_2;//Reduced temperature\n", +"//At reduced temperature Tr_2,\n", +"B2_0 = 0.083 - (0.422/(Tr_2)^(1.6));\n", +"B2_1 = 0.139 - (0.172/(Tr_2)^(4.2));\n", +"B_22 = ((B2_0 + (w_2*B2_1))*(R*Tc_2))/Pc_2;//[m^(3)/mol]\n", +"\n", +"//For cross coeffcient\n", +"Tc_12 = (Tc_1*Tc_2)^(1/2);//[K]\n", +"w_12 = (w_1 + w_2)/2;\n", +"Zc_12 = (Zc_1 + Zc_2)/2;\n", +"Vc_12 = (((Vc_1)^(1/3)+(Vc_2)^(1/3))/2)^(3);//[m^(3)/mol]\n", +"Pc_12 =(Zc_12*R*Tc_12)/Vc_12;//[N/m^(2)]\n", +"\n", +"//Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0+(w_12*B_1)\n", +"//where B_0 and B_1 are to be evaluated at Tr_12\n", +"Tr_12 = T/Tc_12;\n", +"//At reduced temperature Tr_12\n", +"B_0 = 0.083 - (0.422/(Tr_12)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr_12)^(4.2));\n", +"B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;//[m^(3)/mol]\n", +"\n", +"//For the mixture\n", +"B = y1^(2)*B_11+2*y1*y2*B_12+y2^(2)*B_22;//[m^(3)/mol]\n", +"Z_1 = 1+(B*P)/(R*T);//compressibility factor\n", +"printf(' (1).The compressibility factor of mixture using Virial equation of state is %f\n',Z_1);\n", +"\n", +"// (2)\n", +"// Pseudo reduced method.\n", +"T_pc = (y1*Tc_1)+(y2*Tc_2);//[K] - Cricitical temperature\n", +"P_pc = (y1*Pc_1)+(y2*Pc_2);//[N/m^(2)] - Cricitical pressure\n", +"w = (y1*w_1)+(y2*w_2);// Acentric factor\n", +"T_pr = T/T_pc;// Reduced temperature\n", +"P_pr = P/P_pc;// Reduced pressure\n", +"//At this value of Tpr,\n", +"B0 = 0.083 - (0.422/(T_pr)^(1.6));\n", +"B1 = 0.139 - (0.172/(T_pr)^(4.2));\n", +"Z0 = 1 + B0*(P_pr/T_pr);\n", +"Z1 = B1*(P_pr/T_pr);\n", +"Z = Z0 + w*Z1;\n", +"printf(' (2).The compressibility factor of mixture using pseudo reduced method is %f\n',Z);\n", +"\n", +"// (3)\n", +"// Redlich Kwong equation of state is given by\n", +"// P = ((R*T)/(V-b)) - (a/(T^(1/2)*V*(V+b)))\n", +"// For methane,component 1\n", +"a_1 = (0.42748*(R^(2))*(Tc_1^(2.5)))/Pc_1;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b_1 = (0.08664*R*Tc_1)/Pc_1;//[m^(3)/mol]\n", +"//For n-butane,component 2\n", +"a_2 = (0.42748*(R^(2))*(Tc_2^(2.5)))/Pc_2;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b_2 = (0.08664*R*Tc_2)/Pc_2;//[m^(3)/mol]\n", +"//For the mixture\n", +"a_12 = (a_1*a_2)^(1/2);//[Pa*m^(6)*K^(1/2)/mol]\n", +"a = y1^(2)*a_1 + 2*y1*y2*a_12 + y2^(2)*a_2;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b = (y1*b_1) + (y2*b_2);//[m^(3)/mol]\n", +"// The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3) - ((R*T)/P)*V^(2) - ((b_1^(2)) + ((b_1*R*T)/P) - (a/(T^(1/2)*P))*V - (a*b)/(T^(1/2)*P) = 0\n", +"// Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)-((R*T)/P)*V^(2)-((b^(2))+((b*R*T)/P)-(a/(T^(1/2)*P)))*V-(a*b)/(T^(1/2)*P)');\n", +"V_1=fsolve(1,f);\n", +"V_2=fsolve(10,f);\n", +"V_3=fsolve(100,f);\n", +"// Thus compressibility factor is\n", +"Z_3 = (P*V_1)/(R*T);//compressibility factor\n", +"printf(' (3).The compressibility factor of mixture using Redlich Kwong equation of state is %f\n',Z_3);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1: Relations_in_virial_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 2.1\n", +"//Page number - 40\n", +"printf('Example - 2.1 and Page number - 40\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 2.1 on page number 40 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 2.1 on page number 40 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2: Determination_of_acentric_factor.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 2.2\n", +"//Page number - 42\n", +"printf('Example - 2.2 and Page number - 42\n\n');\n", +"\n", +"//Given\n", +"Tc = 647.1;//[K] - Critical temperature\n", +"Pc = 220.55;//[bar] - Critical pressure\n", +"Tr = 0.7;// Reduced temperature\n", +"\n", +"T = Tr*Tc;//[K]\n", +"//From steam table,vapour pressure of H2O at T is 10.02 [bar], as reported in the book\n", +"P = 10.02;//[bar]\n", +"w = -1-log10((P/Pc));\n", +"printf(' The acentric factor (w) of water at given condition is %f ',w);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3: Calculation_of_acentric_factor.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 2.3\n", +"//Page number - 42\n", +"printf('Example - 2.3 and Page number - 42\n\n');\n", +"\n", +"//Given\n", +"//log10(Psat)=8.1122-(1592.864/(t+226.184))// 'Psat' in [mm Hg] and 't' in [c]\n", +"Tc = 513.9;//[K] - Critical temperature\n", +"Pc = 61.48;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[N/m^(2)]\n", +"Tr = 0.7;// Reduced temperature\n", +"\n", +"T = Tr*Tc;//[K] - Temperature\n", +"T = T - 273.15;//[C]\n", +"P_sat = 10^(8.1122 - (1592.864/(T + 226.184)));//[mm Hg]\n", +"P_sat = (P_sat/760)*101325;//[N/m^(2)]\n", +"Pr_sat = P_sat/Pc;\n", +"w = -1-log10(Pr_sat);// Acentric factor\n", +"printf(' The acentric factor (w) for ethanol at given condition is %f',w);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.4: Calculation_of_virial_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 2.4\n", +"//Page number - 45\n", +"printf('Example - 2.4 and Page number - 45\n\n');\n", +"\n", +"//Given\n", +"T = 380;//[K] - Temperature\n", +"Tc = 562.1;//[K] - Critical temperature\n", +"P = 7;//[atm] - Pressure\n", +"P = P*101325;//[N/m^(2)]\n", +"Pc = 48.3;//[atm] - Critical pressure\n", +"Pc = Pc*101325;//[N/m^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"w = 0.212;// acentric factor\n", +"Tr = T/Tc;// Reduced temperature\n", +"\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B = ((B_0+(w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]\n", +"printf(' The second virial coefficient for benzene is %e m^(3)/mol\n',B);\n", +"\n", +"//Compressibility factor is given by\n", +"Z = 1 + ((B*P)/(R*T));\n", +"printf(' The compressibility factor at 380 K is %f\n',Z);\n", +"\n", +"//We know thar Z=(P*V)/(R/*T),therfore\n", +"V = (Z*R*T)/P;//[m^(3)/mol]\n", +"printf(' The molar volume is %e m^(3)/mol\n',V);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5: Calculation_of_mass_using_virial_equation_of_state.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 2.5\n", +"//Page number - 46\n", +"printf('Example - 2.5 and Page number - 46\n\n');\n", +"\n", +"//Given\n", +"V_1 = 0.3;//[m^(3)]//volume of cylinder\n", +"T = 60+273.15;//[K] - Temperature\n", +"P = 130*10^(5);//[N/m^(2)] - Pressure\n", +"Tc = 305.3;//[K] - Critical temperature\n", +"Pc = 48.72*10^(5);//[N/m^(2)] - Critical pressure\n", +"w = 0.100;//acentric factor\n", +"M = 30.07;//molecular weight of ethane\n", +"Tr = T/Tc;// Reduced temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B = ((B_0 + (w*B_1))*(R*Tc))/Pc;//[m^(3)/mol] - Second virial coefficient\n", +"Z = 1 + ((B*P)/(R*T));//Compressibility factor\n", +"V = (Z*R*T)/P;//[m^(3)/mol] - Molar volume\n", +"\n", +"//No.of moles in 0.3 m^(3) cylinder is given by\n", +"n1 = V_1/V;//[mol]\n", +"\n", +"//Mass of gas in cylinder is given by \n", +"m1 = (n1*M)/1000;//[kg]\n", +"printf(' Under actual conditions,the mass of ethane is, %f kg\n',m1);\n", +"\n", +"//Under ideal condition, taking Z = 1,\n", +"V_ideal = (R*T)/P;//[m^(3)/mol]\n", +"n2 = V_1/V_ideal;//[mol]\n", +"m2 = (n2*M)/1000;//[kg]\n", +"printf(' Under ideal conditions,the mass of ethane is, %f kg\n',m2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.6: Calculation_of_molar_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 2.6\n", +"//Page number - 47\n", +"printf('Example - 2.6 and Page number - 47\n\n');\n", +"\n", +"//Given\n", +"T = 373.15;//[K] - Temperature\n", +"P = 101325;//[N/m^(2)] - Pressure\n", +"Tc = 647.1;//[K] - Critical temperature\n", +"Pc = 220.55*10^(5);//[N/m^(2)] - Critical pressure\n", +"w = 0.345;//acentric factor\n", +"Tr = T/Tc;// Reduced temperature\n", +"R = 8.314;//[J/mol*K] - UNiversal gas constant\n", +"\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"\n", +"//We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B = ((B_0+(w*B_1))*(R*Tc))/Pc;//[m^(3)/mol] - Second virial coefficient\n", +"\n", +"//We have, Z = 1+(B/V) and Z = (P*V)/(R*T). Substituting the value of Z,we get\n", +"// V^(2)-((R*T)/P)*V-((B*R*T)/P)=0 .Solving the quadratic equation by shreedharcharya rule\n", +"V1 = (((R*T)/P) + (((R*T)/P)^(2) + 4*1*((B*R*T)/P))^(1/2))/2*1;\n", +"\n", +"printf(' The molar volume of water vapour is %f m^(3)/mol',V1);\n", +"\n", +"//The roots are,V1 = 0.0003670 [m^(3)/mol] and V2 = 0.0302510 [m^(3)/mol].\n", +"//As 'V2' is near to ideal volume (0.030618 [m^(3)/mol]),it is taken as the molar volume\n", +"//The other root 'V1' hss no physical significance" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.7: Calculation_of_molar_volume_and_virial_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"//Example - 2.7\n", +"// Page number - 47\n", +"printf('Example - 2.7 and Page number - 47\n\n');\n", +"// Given\n", +"T = 50+273.15;//[K] - Temperature\n", +"P = 15*10^(5);//[N/m^(2)] - Pressure\n", +"Tc = 305.3;//[K] - Critical temperature\n", +"Pc = 48.72*10^(5);//[N/m^(2)] - Critical pressure\n", +"w = 0.100;// Acentric factor\n", +"B = -157.31;//[cm^(3)/mol] - second virial coefficient\n", +"B = B*10^(-6);//[m^(3)/mol]\n", +"C = 9650;//[cm^(6)/mol^(2)] - third virial coefficient\n", +"C = C*10^(-12);//[cm^(6)/mol^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// (1)\n", +"V_1 = (R*T)/P;//[m^(3)/mol] - Molar volume\n", +"printf(' (1).The molar volume for ideal equation of state is %e m^(3)/mol\n',V_1);\n", +"// (2)\n", +"Tr = T/Tc;// Reduced temperature\n", +"// At this temperature\n", +"B_0 = 0.083-(0.422/(Tr)^(1.6));\n", +"B_1 = 0.139-(0.172/(Tr)^(4.2));\n", +"// We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B_2 = ((B_0 + (w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]//second virial coefficient\n", +"printf(' (2).The second virial coefficent using Pitzer correlation is found to be %e m^(3)/mol which is same as given value\n',B_2);\n", +"// (3)\n", +"// Given (virial equation),Z=1+(B/V)\n", +"V_3 = B + (R*T)/P;//[m^(3)/mol] - Molar volume\n", +"printf(' (3).The molar volume using virial equation of state is %e m^(3)/mol\n',V_3);\n", +"// (4)\n", +"// Given (virial equation),Z = 1 + ((B*P)/(R*T)) + ((C - B^(2))/(R*T)^(2))*P^(2)\n", +"V_4 = B + (R*T)/P + ((C - B^(2))/(R*T))*P;// [m^(3)/mol]\n", +"printf(' (4).The molar volume using given virial equation of state is %e m^(3)/mol\n',V_4);\n", +"// (5)\n", +"// Given,Z = 1 + (B/V)\n", +"// Also,Z = (P*V)/(R*T). Substituting the value of Z,we get\n", +"// V^(2)-((R*T)/P)*V-((B*R*T)/P)=0.Solving the quadratic equation\n", +"deff('[y]=f(V)','y=V^(2)-((R*T)/P)*V-((B*R*T)/P)');\n", +"V_5_1 = fsolve(0,f);\n", +"V_5_2 = fsolve(1,f);\n", +"printf(' (5).The molar volume using given virial equation of state is %e m^(3)/mol\n',V_5_2);\n", +"// The roots are,V_5_1=0.0001743 [m^(3)/mol] and V_5_2=0.0016168 [m^(3)/mol].\n", +"// As 'V_2' is near to ideal volume (0.0017911 [m^(3)/mol]),it is taken as the molar volume\n", +"// (6)\n", +"// Given,Z = 1 + (B/V) + (C/V^(2))\n", +"// Also,Z = (P*V)/(R*T). Substituting the value of Z,we get\n", +"// V^(3)-((R*T)/P)*V^(2)-((B*R*T)/P)*V-((C*R*T)/P)=0. Solving the cubic equation\n", +"deff('[y]=f1(V)','y=V^(3)-((R*T)/P)*V^(2)-((B*R*T)/P)*V-((C*R*T)/P)');\n", +"V_6_3=fsolve(-1,f1);\n", +"V_6_4=fsolve(0,f1);\n", +"V_6_5=fsolve(1,f1);\n", +"//The above equation has 1 real and 2 imaginary roots. We consider only real root.\n", +"printf(' (6).The molar volume using given virial equation of state is %e m^(3)/mol\n',V_6_5);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.8: Determination_of_second_and_third_virial_coefficients.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 2.8\n", +"// Page number - 49\n", +"printf('Example - 2.8 and Page number - 49\n\n');\n", +"\n", +"//Given\n", +"T = 0 + 273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"//Virial equation of state, Z=1+(B/V)+(C/V^(2))\n", +"//From above equation we get (Z-1)*V=B+(C/V)\n", +"\n", +"P=[50,100,200,400,600,1000];\n", +"Z=[0.9846,1.0000,1.0365,1.2557,1.7559,2.0645];\n", +"V=zeros(6);\n", +"k=zeros(6);\n", +"t=zeros(6);\n", +"for i=1:6;\n", +" V(i)=(Z(i)*R*T)/(P(i)*101325);//[m^(3)/mol]\n", +" k(i)=(Z(i)-1)*V(i);\n", +" t(i)=1/V(i);\n", +"end\n", +"[C,B,sig]=reglin(t',k');\n", +"\n", +"//From the regression, we get intercept=B and slope=C,and thus,\n", +"printf(' The value of second virial coefficient (B) is %e m^(3)/mol\n',B);\n", +"printf(' The value of third virial coefficient (C) is %e m^(6)/mol^(2)',C);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.9: Estimation_of_second_virial_coefficient.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 2.9\n", +"//Page number - 51\n", +"printf('Example - 2.9 and Page number - 51\n\n');\n", +"\n", +"//Given\n", +"T = 444.3;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"B_11 = -8.1;//[cm^(3)/mol]\n", +"B_11 = -8.1*10^(-6);//[m^(3)/mol]\n", +"B_22 = -293.4*10^(-6);//[m^(3)/mol]\n", +"y1 = 0.5;// mole fraction // equimolar mixture\n", +"y2 = 0.5;\n", +"\n", +"// For component 1 (methane)\n", +"Tc_1 = 190.6;//[K] - cricitical temperature\n", +"Vc_1 = 99.2;//[cm^(3)/mol] - cricitical molar volume\n", +"Zc_1 = 0.288;// critical compressibility factor\n", +"w_1 = 0.012;// acentric factor\n", +"\n", +"// For component 2 (n-butane)\n", +"Tc_2 = 425.2;//[K]\n", +"Vc_2 = 255.0;//[cm^(3)/mol]\n", +"Zc_2 = 0.274;\n", +"w_2 = 0.199;\n", +"\n", +"//Using virial mixing rule,we get\n", +"Tc_12 = (Tc_1*Tc_2)^(1/2);//[K]\n", +"w_12 = (w_1 + w_2)/2;\n", +"Zc_12 = (Zc_1+Zc_2)/2;\n", +"Vc_12 = (((Vc_1)^(1/3) + (Vc_2)^(1/3))/2)^(3);//[cm^(3)/mol]\n", +"Vc_12 = Vc_12*10^(-6);//[cm^(3)/mol]\n", +"Pc_12 = (Zc_12*R*Tc_12)/Vc_12;//[N/m^(2)]\n", +"Tr_12 = T/Tc_12;//Reduced temperature\n", +"B_0 = 0.083 - (0.422/(Tr_12)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr_12)^(4.2));\n", +"\n", +"//We know,(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n", +"B_12 = ((B_0+(w_12*B_1))*(R*Tc_12))/Pc_12;//[m^(3)/mol] - Cross coefficient\n", +"B = y1^(2)*B_11+2*y1*y2*B_12+y2^(2)*B_22;//[m^(3)/mol] - Second virial coefficient for mixture\n", +"B = B*10^(6);//[cm^(3)/mol]\n", +"printf(' The second virial coefficient,(B) for the mixture of gas is %f cm^(3)/mol',B);\n", +"\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/3-The_First_Law_and_Its_Applications.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/3-The_First_Law_and_Its_Applications.ipynb new file mode 100644 index 0000000..7e1cf38 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/3-The_First_Law_and_Its_Applications.ipynb @@ -0,0 +1,1419 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3: The First Law and Its Applications" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.10: Finding_expressions_for_temperature_and_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.10\n", +"//Page number - 95\n", +"printf('Example - 3.10 and Page number - 95\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 3.10 on page number 95 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 3.10 on page number 95 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.11: Calculation_of_final_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.11\n", +"//Page number - 97\n", +"printf('Example - 3.11 and Page number - 97\n\n');\n", +"\n", +"//Given\n", +"n = 1.5;// - ratio of heat capacities\n", +"T_1 = 500;//[K] - Initial temperature\n", +"T_2 = 1000;//[K] - Final temperature\n", +"P_1 = 1;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// The compression path is given by, P*V^(1.5) = constant\n", +"// P*(R*T/P)^(1.5) = constant\n", +"// P1^(-0.5)*T1^(1.5) = P2^(-0.5)*T2^(1.5)\n", +"P_2 = P_1*(T_1/T_2)^(-3);//[Pa]\n", +"P_2_final = P_2*10^(-5);//[bar] - Final pressure in bar\n", +"printf(' The final pressure is %f bar\n',P_2_final);\n", +"\n", +"// From first law q - w = delta(U). \n", +"// First w and delta(U) are calculated and thereafter heat exchange is determined.\n", +"V_1 = R*T_1/P_1;//[m^(3)/mol] - Initial volume\n", +"V_2 = R*T_2/P_2;//[m^(3)/mol] - Final volume\n", +"w = ((P_1*V_1)/(n - 1))*(1 - (P_2/P_1)^(1 - 1/n));//[J/mol] - work done\n", +"\n", +"// Mean temperature is given by,\n", +"T_mean = (T_1 + T_2)/2;//[K]\n", +"\n", +"//Now, heat capacity at T_mean is given by,\n", +"Cp_0 = R*(3.3 + 0.63*10^(-3)*T_mean);//[J/mol*K]\n", +"Cv_0 = Cp_0 - R;//[J/mol*K]\n", +"//Therefore delta(U) is given by\n", +"del_U = Cv_0*(T_2 - T_1);//[J/mol] - Change in internal energy\n", +"q = w + del_U;//[J/mol] - heat change\n", +"printf(' The amount of heat supplied to the system is %f J/mol\n',q);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.12: Calculation_of_slope_and_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.12\n", +"//Page number - 99\n", +"printf('Example - 3.12 and Page number - 99\n\n');\n", +"\n", +"//Given\n", +"P_1 = 150*10^(3);//[Pa] - Initial pressure\n", +"V_1 = 0.001;//[m^(3)] - Initial volume\n", +"P_2 = 1000*10^(3);//[Pa] - Final pressure\n", +"V_2 = 0.003;//[m^(3)] - Final volume\n", +"\n", +"// At x = 0, Vt(total volume) = 0.001 m^(3), therefore x = (V_t - V_1)/A; where A is area of cross section and x is length\n", +"// Force exerted b sprig is given by, F = Ps*A = k*x = k*(V_t - V_1)/A\n", +"// Ps = (k/A^(2))*(V_t - V_1)\n", +"// Total pressure = Initial pressre + Pressre due to spring\n", +"// P = P_1 + (k/A^(2))*(V_t - V_1)\n", +"// Let (k/A^(2)) = t (say)\n", +"// At state 2, i.e at P2 and V_t = V_2.\n", +"deff('[y]=f(t)','y=P_2-P_1 - t*(V_2-V_1)');\n", +"t = fsolve(1000,f);\n", +"// Therefore,pressure is related to total volume as P = P_1-t*(V_t - V_1)\n", +"\n", +"// (a)\n", +"//slope = (k/A^(2))\n", +"printf(' (a).The slope of the line on P-Vt diagram is %e N/m^(5)\n',t);\n", +"\n", +"// (b)\n", +"// Work done by the gas is given by w=integral(PdVt)\n", +"w = integrate('P_1+t*(V_t-V_1)','V_t',V_1,V_2);//[J]\n", +"w = w*10^(-3);//[kJ]\n", +"printf(' (b).The work done by gas is %f kJ\n',w);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.13: Calculation_of_work_done_and_final_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 3.13\n", +"//Page number - 99\n", +"printf('Example - 3.13 and Page number - 99\n\n');\n", +"//Given\n", +"V = 36;//[L] - Vol of gas on each side\n", +"P_1 = 1;//[atm] - pressure on left side of the piston\n", +"P_1 = P_1*101325;//[Pa]\n", +"T = 273.15;//[K]\n", +"P_2 = 3.375;//[atm] - Pressure on right side of the piston\n", +"P_2 = P_2*101325;//[Pa]\n", +"Y = 1.44;// Ratio of heat capacities\n", +"R = 8.314;//[J/mol*K] - Universal gas constnt\n", +"// (a)\n", +"// For total system, del(U_total) = Q. \n", +"// Onto gas on right hand side no heat is supplied,as the piston is non conducting. Therefore,for gas on the right hand side, del(U) = -W.\n", +"// As heat is slowly supplied to the left hand side,expansion on right hand side is slow and process is adiabatic.\n", +"// For gas on right hand side, PV^(Y) = constant.\n", +"// T_2/T_1 = (P_2/P_1)^((Y - 1)/Y)\n", +"T_right = T*(P_2/P_1)^((Y - 1)/Y);//[K]\n", +"Cv_0 = R/(Y-1);//[J/mol*K] - Heat capacity at constant volume.\n", +"// Now work done on the gas on right hand side is given by\n", +"// W = (P_1*V_1 - P_2*V_2)/(Y - 1) = R*(T_2 - T_1)/(Y - 1) = Cv_0*(T_1 - T_2)\n", +"W_left = Cv_0*(T - T_right);//[J/mol]\n", +"// Negative sign for the work done on LHS gas implies work is done on the gas\n", +"// For right hand side of the gas\n", +"// P*Vt = n*R*T\n", +"n = P_1*(V*10^(-3))/(R*T);// number of moles\n", +"W_right = (-W_left)*n;//[J] - We used negative sign for 'W_left' because it is negative in magnitude.\n", +"W_right = W_right/1000;//[kJ]\n", +"printf(' (a).Total work done on gas on the right hand side is %f kJ\n',W_right);\n", +"//(b)\n", +"printf(' (b).The final temperature of the gas on right side is %f K\n',T_right);\n", +"// (c)\n", +"// Pressure is same on both sides as piston is frictionless.\n", +"// The number of moles on both sides are also same as they have same temperature,presure and volume.\n", +"// We have (P_left*V_left)/T_left = (P_right*V_right)/T_right.\n", +"// Since P_left = P_right, (V_left/T_left) = (V_right/T-right) and also P*V^(Y) = constant.\n", +"V_right = V*(P_1/P_2)^(1/Y);//[L] - The total volume on right side \n", +"// The total volume on right side can also be calculated using P2*V2 = n*R*T2.\n", +"// Since total volume = 72 [L], therefore volume of left side is\n", +"V_left = 2*V - V_right;//[L]\n", +"T_left = T_right*(V_left/V_right);\n", +"printf(' (c).Final temperature of the gas on the left side is %f K\n',T_left);\n", +"//(d)\n", +"//The first law applied to the total system (left side and right side) gives.\n", +"//Q - W = del(U_left) + del(U_right)\n", +"//There is no net work done by the total system as the cylinder is closed at both ends.\n", +"Q = n*Cv_0*(T_left-T) + n*Cv_0*(T_right-T);//[J]\n", +"Q = Q/1000;//[kJ]\n", +"printf(' (d).Amount of heat added to the gas on the left side is %f kJ',Q);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.14: Calculation_of_powerand_discharge_head.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.14\n", +"//Page number - 105\n", +"printf('Example - 3.14 and Page number - 105\n\n');\n", +"\n", +"\n", +"//Given\n", +"P_2 = 0.2;//[bar]\n", +"P_2 = P_2*10^(5);//[Pa]\n", +"int_dia_2 = 2.4*10^(-2);//[m] - internal diameter at state 2.\n", +"Q = 5*10^(-3);//[cubic metre/s] - Flow rate at point 2.\n", +"den = 1000;//[kg/cubic metre] - density\n", +"delta_z = 1;//[m] - Difference in height\n", +"g = 9.81;//[m/s^(2)] - Acceleration due to gravity\n", +"\n", +"// (1)\n", +"// Pressure at state 1 is atmospheric pressure and at state 2 is gauze pressure at state 2 + atmospheric pressure,thus\n", +"// (delta(P)/den) = (P2-P1)/den = P2/den\n", +"Vel_2 = Q/(3.14*(int_dia_2/2)^(2));//[m/s] - Velocity of water at state 2.\n", +"// Velocity at state 1 i negligible as compared to velocity at state 2,because the diameter of reservoir is very large as compared to diameter of pipe at state 2\n", +"\n", +"// From bernaulli equation we get,\n", +"// -w = (delta(P)/den) + delta(v^(2))/2 + g*delta_z\n", +"w = -((P_2/den )+ (Vel_2^(2)/2) + (g*delta_z));//[J/kg]\n", +"// w multiplied by m = (den*Q), will give the fluid power.\n", +"m = den*Q;//[kg/s]\n", +"W_net = m*w;//[Watt]\n", +"printf(' (1).The fluid power is %f Watt\n',W_net);\n", +"\n", +"//(2)\n", +"// Total discharge head developed by the pump is given by\n", +"// h = (delta(P)/den*g) + (Vel_2^(2)/2*g) + delta_z\n", +"h = (P_2/(den*g)) + (Vel_2^(2)/(2*g)) + delta_z;//[m]\n", +"printf(' (2).Total discharge head developed by the pump is given by h = %f m',h);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.15: Calculation_of_discharge_velocity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.15\n", +"//Page number - 106\n", +"printf('Example - 3.15 and Page number - 106\n\n');\n", +"\n", +"//Given\n", +"T_1 = 1000;//[K] - Temperature at entry\n", +"P_1 = 0.6;//[MPa] - Pressure at entry\n", +"P_2 = 0.2;//[MPa] - Exit pressure\n", +"Vel_1 = 50;//[m/s] - Entry velocity \n", +"Y = 1.4;// Ratio of heat capacities\n", +"Mol_wt = 28;//[g/mol] - Molecular weight of air\n", +"Cp = 29.099;//[J/mol-K] - Specific heat capacity at constant pressure\n", +"Cp = (Cp/Mol_wt)*1000;//[J/kg-K]\n", +"\n", +"// We know that for a flow process \n", +"// delta_H + delta_V^(2)/2 + delta_(g*z) = q - w\n", +"// Since process is adiabatic,therefore q = 0 and since no work is done by the gas, therefore w = 0\n", +"// Assuming there is no change in the potenial energy between entry and exit, we have\n", +"// delta_H + delta_V^(2)/2 = 0\n", +"\n", +"// For a reversible process P*V^(Y) = constant and thus (T_2/T_1) = (P_2/P_1)^((Y-1)/Y)\n", +"T_2 = T_1*(P_2/P_1)^((Y-1)/Y);//[K] - Exit temperature\n", +"\n", +"// delta_H + delta_V^(2)/2 = 0\n", +"// Vel_2^(2)/2 - Vel_1^(2)/2 - (H_1 - H_2)= 0\n", +"// Vel_2^(2)/2 - Vel_1^(2)/2 - Cp*(T_1 - T_2) = 0\n", +"Vel_2_square = 2*(Vel_1^(2)/2 + Cp*(T_1 - T_2));//[m^(2)/s^(2)]\n", +"Vel_2 = (Vel_2_square)^(1/2);//[m/s]\n", +"\n", +"printf(' The discharge velocity is %f m/s\n',Vel_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.16: Calculation_of_change_in_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.16\n", +"//Page number - 107\n", +"printf('Example - 3.16 and Page number - 107\n\n');\n", +"\n", +"//Given\n", +"P_entry = 10;//[bar] - Pressure at entry\n", +"V_entry = 200;//[m/s] - Velocity at entry\n", +"P_exit = 1;//[bar] - Vressure at exit\n", +"V_exit = 800;//[m/s] - Velocity at exit\n", +"g = 9.81;//[m/s^(2)] - Acceleration due to gravity\n", +"\n", +"//Heat balance gives\n", +"// delta_H + (delta_V^(2))/2 + g*delta_z = q - w\n", +"//delta_H = q - w - (delta_V^(2))/2 \n", +"//From nozzle no work is extracted,therefore\n", +"delta_H = -(V_exit^(2)- V_entry^(2))/2;//[J/kg]\n", +"delta_H = delta_H*10^(-3);//[kJ/kg]\n", +"\n", +"printf(' The change in enthalpy per kg of steam is %f kJ/kg',delta_H);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.17: Calculation_of_work_done_and_change_in_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 3.17\n", +"//Page number - 111\n", +"printf('Example - 3.17 and Page number - 111\n\n');\n", +"//Given\n", +"T_1 = 280;//[K] - Temperature at entry\n", +"P_1 = 100;//[kPa] - Pressure at entry\n", +"T_2 = 400;//[K] - Temperature at exit\n", +"P_2 = 600;//[kPa] - Pressure at exit\n", +"m = 0.02;//[kg/s] - Mass flow rate\n", +"m = m*10^(3);//[g/s]\n", +"heat_loss = 16;//[kJ/kg]\n", +"//Cp_0 = 28.11 + 0.1967*10^(-2)*T + 0.4802*10^(-5)*T^(2) - 1.966*10^(-9)*T^(3)\n", +"//delta_H = q - w (neglecting kinetic and potential changes)\n", +"//delta_H = integral(Cp_0*dT)\n", +"delta_H = integrate('28.11 + 0.1967*10^(-2)*T + 0.4802*10^(-5)*T^(2) - 1.966*10^(-9)*T^(3)','T',T_1,T_2);//[J/mol - Enthalpy change\n", +"printf(' Change in enthalpy is %f J/mol\n',delta_H);\n", +"//Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n", +"Mol_wt = 28.84;//[g/mol]\n", +"q = - (heat_loss*Mol_wt);//[J/mol]\n", +"w = q - delta_H;//[J/mol]\n", +"printf(' The work done per mole of air is %f J/mol\n',w);\n", +"//the negative sign implies that work is done on the compressor.\n", +"n = m/Mol_wt;//[mol/s] - Mole flow rate\n", +"W_net = delta_H*n;//[W]\n", +"W_net = -W_net*10^(-3);//[kW]\n", +"printf(' And the necessary power input to the compressor is %f kW\n',W_net);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.18: Calculation_of_work_done_per_unit_mass.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.18\n", +"//Page number - 112\n", +"printf('Example - 3.18 and Page number - 112\n\n');\n", +"\n", +"\n", +"//Given\n", +"T_1 = 300;//[K] - Temperature at entry\n", +"P_1 = 100;//[kPa] - Pressure at entry\n", +"P_2 = 900;//[kPa] - Pressure at exit\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// (a)\n", +"// Reversible adiabatic compression\n", +"Y = 1.4;//Ratio of specific heat capacities\n", +"// For ideal gas, P*V^(Y)= constant and it takes the form of (T_2/T_1) = (P_2/P_1)^((Y-1)/Y)\n", +"T_2 = T_1*(P_2/P_1)^((Y - 1)/Y);//[K]\n", +"// The work exchange for adiabatic process is given by\n", +"// W_adia = -delta_H = -Cp*(T2-T1) = Cp*(T1-T2) = ((Y*R)/(Y-1))*(T1-T2)\n", +"W_adia = ((Y*R)/(Y - 1))*(T_1 - T_2);//[J/mol] -work done\n", +"// Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n", +"Mol_wt = 28.84;//[g/mol]\n", +"W_adia = W_adia/Mol_wt;//[J/g]\n", +"printf(' (a).The compressor work done for reversible adiabatic compession is %f J/g\n',W_adia);\n", +"\n", +"//(b)\n", +"//Isothermal compression\n", +"//W_iso = -integral(V*dP) = -integral((R*T/P)*dP) = R*T*ln(P_2/P_1)\n", +"W_iso = -R*T_1*log(P_2/P_1);//[J/mol]\n", +"W_iso = W_iso/Mol_wt;//[J/g]\n", +"printf(' (b).The compressor work done for isothermal compession is %f J/g\n',W_iso);\n", +"//Note that in isothermal compression between the same states work done is less as compared to reversible adiabatic compression.\n", +"\n", +"//(c)\n", +"//Ideal two-stage compression \n", +"n = 1.3;//Polytropic exponent.\n", +"//Minimum work done in two stage compression is given by\n", +"//W_comp = ((2*n*R*T_1)/(n-1))*[1-(P_x/P_1)^(n-1)/n]\n", +"//where for minimum work, (P_x/P_1) = (P_x/P_2), and thus\n", +"P_x = (P_1*P_2)^(1/2);//[kPa]\n", +"//therefore, work done is given by,\n", +"W_comp = ((2*n*R*T_1)/(n-1))*[1-(P_x/P_1)^((n-1)/n)];//[J/mol]\n", +"W_comp = W_comp/Mol_wt;//[J/g]\n", +"printf(' (c).The compressor work done for ideal two-stage compession is %f J/g\n',W_comp);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.19: Calculation_of_inlet_and_outlet_velocity_and_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.19\n", +"//Page number - 113\n", +"printf('Example - 3.19 and Page number - 113\n\n');\n", +"\n", +"\n", +"//Given\n", +"T_1 = 600;//[C] - Temperature at entry\n", +"P_1 = 15;//[MPa] - Pressure at entry\n", +"T_2 = 400;//[K] - Temperature at exit\n", +"P_2 = 100;//[kPa] - Pressure at exit\n", +"A_in = 0.045;//[metre square] - flow in area\n", +"A_out = 0.31;//[metre square] - flow out area\n", +"m = 30;//[kg/s] - mass flow rate.\n", +"\n", +"//At 15 MPa and 600 C,it has been reported in the book that the properties of steam are,\n", +"Vol_1 = 0.02491;//[m^(3)/kg] - Specific volume\n", +"H_1 = 3582.3;//[kJ/kg] - Enthalpy\n", +"// m = den*vel*A = (Vel*A)/Vol, substituting the values\n", +"vel_1 = (m*Vol_1)/A_in;//[m/s] - Velocity at point 1.\n", +"printf(' The inlet velocity is %f m/s\n',vel_1);\n", +"\n", +"//At 100 MPa (saturated vapour),it has been reported in the book that the properties of steam are, T_sat = 99.63 C, and\n", +"Vol_vap_2 = 1.6940;//[m^(3)/kg] - specific volume of saturated vapour.\n", +"H_vap_2 = 2675.5;//[kJ/kg] - Enthalpy os saturated vapour.\n", +"vel_2 = (m*Vol_vap_2)/A_out;//[m/s] - Velocity at point 2.\n", +"printf(' The exit velocity is %f m/s\n',vel_2);\n", +"\n", +"//From first law we get, q - w =delta_H + delta_V^(2)/2\n", +"//q = 0, therefore, -w = delta_H + delta_V^(2)/2\n", +"delta_H = H_vap_2 - H_1;//[kJ/kg] - change in enthalpy.\n", +"delta_V_square = (vel_2^(2) - vel_1^(2))/2;//[J/kg]\n", +"delta_V_square = delta_V_square*10^(-3);//[kJ/kg]\n", +"w = -(delta_H + delta_V_square);//[J/kg] \n", +"W_net = w*m;//[kW]\n", +"W_net = W_net*10^(-3);//[MW] - power produced.\n", +"printf(' The power that can be produced by the turbine is %f MW',W_net);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.1: Calculation_of_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 3.1\n", +"//Page number - 80\n", +"printf('Example - 3.1 and Page number - 80\n\n');\n", +"\n", +"// Given\n", +"V_vessel = 4*10^(-3);//[m^(-3)] - Volume of vessel\n", +"T = 200+273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal fas constant\n", +"P = 1.5*10^(6);//[Pa] - Pressure\n", +"Q = 40*1000;//[J] - Heat input\n", +"// From steam table at 200 C,Psat=1.55549 MPa,therefore the steam is superheated.\n", +"\n", +"// (1)\n", +"// Using steam table,at 1.5 MPa and 200 C,\n", +"V_1 = 0.1325;//[m^(3)/mol] - Specific volume\n", +"U_1 = 2598.1;//[kJ/kg] - Specific internal energy\n", +"// From first law under constant pressure,\n", +"// Q - m*P*(V2 - V1) = m*(U2 - U1)\n", +"m = V_vessel/V_1;//[kg] - Mass of system\n", +"// Putting the values,the above equation becomes\n", +"// 45283*(V2 - 0.1325) + 30.1887*(U2 - 2598.1) = 40000\n", +"// From steam table at 700 C LHS is 33917.0 and at 800 C,it is 40925.3.\n", +"// Therefore the final temperature lies between 700 and 800 C\n", +"printf(' (1).From steam table the final temperature lies between 700 and 800 C\n');\n", +"\n", +"// Alternate method\n", +"// Here we use first law at constant pressure,\n", +"// Q = m*(H_2 - H_1)\n", +"H_1 = 2796.8;//[kJ/kg]\n", +"// Substituting the values,\n", +"// 40 = 0.0301887*(H_2 - 2796.8)\n", +"H_2 = (40/0.0301887) + 2796.9;//[kJ/kg]\n", +"// Threfore,final enthalpy is (H2) 4121.8 [kJ/kg] and pressure is 1.5 [MPa].\n", +"// From steam table at 1.5 [MPa]and 700 C,enthalpy is 3920.3 [kj/kg] and at 1.5 [MPa]and 800 C,enthalpy is 4152.6 [kj/kg]\n", +"printf('\tAlternate method\n');\n", +"printf('\tBy linear interpolation we get the temperature at which enthlpy is 4121.8 kJ/kg to be 786.74 C\n\n');\n", +"\n", +"// (2)\n", +"// Assuming ideal behaviour.\n", +"n = (P*V_vessel)/(R*T);//[mol] - No of moles\n", +"M = 18.015;// Molecular weight of water\n", +"m_2 = n*M;//[g] - mass of moles\n", +"Cp_1 = 7.7 + 0.04594*10^(-2)*T + 0.2521*10^(-5)*T^(2) - 0.8587*10^(-9)*T^(3);//[cal/mol*K] - Heat capacity at constant presure\n", +"R0 = 1.987;//[cal/mol*K] - universal gas constant\n", +"Cv_1 = Cp_1 - R0;//[cal/mol*K] - Heat capacity at constant volume\n", +"Cv_1 = Cv_1*4.184/M;//[J/g*K]\n", +"T1 = T;\n", +"// From 1st law energy balance for constant pressure, we have Q-W= m*(delta_U)\n", +"// Q = P*(V2 - V1)*m = m*Cv*(T2 - T1)\n", +"// Q = P*((T2/T1)-1)*V1*m = m*Cv*(T2-T1)\n", +"// But, (V1*Cv)=initial total volume of system = V_vessel\n", +"// Q-P((T2/T1)-1)*V_vessel = m_2*Cv_0*(T2-T1);\n", +"deff('[y]=f(T2)','y=Q-P*((T2/T1)-1)*V_vessel-m_2*Cv_1*(T2-T1)');\n", +"T2_1 = fsolve(1,f);\n", +"//The heat capacity should be evaluted at mean temperature\n", +"T_mean = (T1 + T2_1)/2;\n", +"Cp_2 = 7.7 + 0.04594*10^(-2)*T_mean+0.2521*10^(-5)*T_mean^(2) - 0.8587*10^(-9)*T_mean^(3);//[cal/mol*K] - Heat capacity at constant presure\n", +"Cv_2 = Cp_2-R0;//[cal/mol*K] - Heat capacity at constant volume\n", +"Cv_2 = Cv_2*4.184/M;//[J/g*K]\n", +"//Now again solving the equation Q=P*((T2/T1)-1)*V1*m = m*Cv*(T2-T1),for Cv=Cv_2\n", +"deff('[y]=f1(T2)','y=Q-P*((T2/T1)-1)*V_vessel-m_2*Cv_2*(T2-T1)');\n", +"T2_2 = fsolve(1,f1);\n", +"printf(' (2).The temperature assuming ideal behaviour is %f K\n',T2_2);\n", +"\n", +"// Alternate method\n", +"// From 1st law at constant pressure, we have Q = m*Cp(T2-T1)\n", +"T2_3 = Q/(m_2*(Cp_1*4.184/M))+T1;\n", +"//We can calculate the mean temperature as done above\n", +"T_mean1 = (T1 + T2_3)/2;//[J/g*K]\n", +"//The heat capacity should be evaluted at mean temperature\n", +"Cp_3 = 7.7 + 0.04594*10^(-2)*T_mean1 + 0.2521*10^(-5)*T_mean1^(2)-0.8587*10^(-9)*T_mean1^(3);//[cal/mol*K] - Heat capacity at constant presure\n", +"Cp_3 = Cp_3*4.184/M;//[J/g*K]\n", +"// Again solving the equation Q = m*Cp(T2-T1), for Cp=Cp_3\n", +"T2_4 = Q/(m_2*Cp_3) + T1;\n", +"printf('\tAlternate method\n');\n", +"printf('\tThe temperature assuming ideal behaviour (alternate method) is %f K\n',T2_4);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.20: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.20\n", +"//Page number - 117\n", +"printf('Example - 3.20 and Page number - 117\n\n');\n", +"\n", +"//(1)\n", +"//This part involves no numerical components\n", +"//For prove refer to this example 3.20 on page number 117 of the book.\n", +"\n", +"//(2)\n", +"//Given,\n", +"R = 8.314;//[J/mol-K] - Universal gas constant\n", +"Cp_0 = 2.5*R;//[J/mol-K] - Specific heat capacity at constant pressure\n", +"Cv_0 = 1.5*R;//[J/mol-K] - Specific heat capacity at constant volume\n", +"T_L = 300;//[K] - Temperature at which port properties are constant.\n", +"\n", +"Y = Cp_0/Cv_0;// Ratio of heat capacities.\n", +"//From part(1) we obtained the relation,\n", +"// T_2 = 1/(((P_2-P_1)/(Y*T_L*P_2))+(P_1/(P_2*T_1)))\n", +"// Not that when P_2 >> P_1 ,T_2 approaches Y*T_L and thus\n", +"T_2 = Y*T_L;//[K]\n", +"printf(' (b).The final temperature is %f K',T_2);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.21: Determination_of_equilibrium_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.21\n", +"//Page number - 119\n", +"printf('Example - 3.21 and Page number - 119\n\n');\n", +"\n", +"//Given\n", +"T_1 = 40 + 273.15;//[K] - Initial temperature.\n", +"P_1 = 1;//[bar] - Initial pressure.\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"Vol_1 = 0.01;//[cubic metre] - Initial volume of the cylinder.\n", +"T_2 = 100 + 273.15;//[K] - Final temperature.\n", +"P_2 = 100;//[kPa] - Final pressure.\n", +"P_2 = P_2*10^(5);//[Pa]\n", +"Vol_2 = 0.02;//[cubic metre] - Final volume of the cylinder.\n", +"Cp = 1.005;//[J/g-K] - Specific heat capacity at constant pressure.\n", +"Cv = 0.718;//[J/g-K] - Specific heat capacity at constant volume.\n", +"Mol_wt = 28.84;//[g/mol] - Molecular weight of air.\n", +"R = 8.314;//[J/mol-K] - universal gas constant\n", +"\n", +"delta_Vol = Vol_2 - Vol_1;// [cubic metre] - Change in volume.\n", +"// Assuming ideal gas P*V = R*T\n", +"V_1 = (R*T_1)/P_1;// [m^(3)/mol] - Initial specific volume.\n", +"// Therefore,the total number of moles initially in the system is,\n", +"n_1 = (Vol_1/V_1);// [mol]\n", +"m_1 = n_1*Mol_wt;// [g] - Initial mass of the system.\n", +"Y = Cp/Cv;//Ratio of heat capacities\n", +"\n", +"// The energy balance equation is given by\n", +"// -P*delta_Vol + H_liq*(m_2 - m_1) = m_2*Cv*(P*V2)/R - m_1*Cv*T_1\n", +"// m_2*Cv*(P*V2)/R = (Cv*P_1*Vol_2)/R\n", +"// Cv/R = 1/(Y-1)\n", +"// Since pressure of the gas in system is assumed constant,therefore it remains at 1 bar and thus P = P_1,\n", +"H_liq = Cp*T_2;// [J/g] - Enthalpy of liquid\n", +"m_2 = (P_1*delta_Vol + ((P_1*Vol_2)/(Y-1)) + H_liq*m_1 - m_1*Cv*T_1)/H_liq;//[g]\n", +"\n", +"//The mass entering the assembly during the filling process is given by\n", +"m = m_2 - m_1;//[g]\n", +"n_2 = m_2/Mol_wt;//[mol] - Number of moles in the final state.\n", +"V_2 = Vol_2/n_2;//[m^(3)/mol] - Final specific volume.\n", +"// Therfore,final temperature is given by,\n", +"T_2 = (P_1*V_2)/R;//[K] - Final temperature.\n", +"\n", +"printf(' The final equilibrium temperature is %f K\n',T_2);\n", +"printf(' The mass entering through the valve is %f g\n',m);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.22: Determination_of_mass.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.22\n", +"//Page number - 122\n", +"printf('Example - 3.22 and Page number - 122\n\n');\n", +"\n", +"//Given\n", +"V_total = 5;//[L] - Volume of pressure cooker.\n", +"V_total = V_total*10^(-3);//m^(3)\n", +"P_gauze = 15;//[psi] - Operating pressure (gauze)of pressure cooker.\n", +"P_gauze = (P_gauze/14.5)*10^(5);//[N/m^(2)]\n", +"P_atm = 0.966*10^(5);//[N/m^(2)] - Atmospheric pressure.\n", +"m_1 = 1;//[kg] - Initial mass.\n", +"t = 30*60;//[s] - Total time.\n", +"J = 500;//[W] - Rate of heat supply\n", +"\n", +"P_abs = P_gauze + P_atm;//[N/m^(2)] - Absolute pressure.\n", +"//The energy balance equqtion gives,\n", +"// Q = m_e*H_e +(m_2*U_2 - m_1*U_1), where 'm_e' is the mass exit from the system and 'H_e' is enthalpy at exit conditions.\n", +"\n", +"//It has been reported in the book that from steam table at P_abs,\n", +"T_sat = 120.23;//[K]- Saturated temperature\n", +"V_liq = 0.001061;//[m^(3)/kg] - specific volume of liquid.\n", +"V_vap = 0.8857;//[m^(3)/kg] - specific volume of vapour.\n", +"U_liq = 504.49;//[kJ/kg] - specific internal energy of liquid.\n", +"U_vap = 2529.5;//[kJ/kg] - specific internal energy of vapour.\n", +"H_liq = 504.70;//[kJ/kg] - specific enthalpy of liquid.\n", +"H_vap = 2706.7;//[kJ/kg] - specific internal energy of vapour.\n", +"\n", +"//We know that total volume occupied by 1 kg of fluid is \n", +"//V_total = (1-x)*V_liq + x*V_vap\n", +"x1 = (V_liq - V_total)/(V_liq - V_vap);//[g]\n", +"\n", +"//Internal energy at this state is\n", +"U_1 = (1-x1)*U_liq + x1*U_vap;//[kJ/kg] - specific internal energy\n", +"U_1_net = m_1*U_1;//[kJ] - Internal energy\n", +"\n", +"//The amount of heat suplied is given by,\n", +"J_net = J*t;//[J] - Net heat supplied.\n", +"J_net = J_net*10^(-3);//[kJ]\n", +"\n", +"//Let the dryness factor at the end of the process be x\n", +"//The specific properties of the liquid and vapour remain same as P and T_sat are the same in the cooker.\n", +"//Let the total mass of H2O (liquid + vapour) at the end of the process be 'm' kg.\n", +"// V_total/m = (1-x)*(V_liq) + x*V_vap ......equqtion(1)\n", +"\n", +"//the specific internal energy at the end of process is\n", +"//U = (1-x)*U_liq + x*U_vap\n", +"//The total internal energy at the end of the process is\n", +"//U_net = m*U = x*[(1-x)*U_liq + x*U_vap]\n", +"\n", +"//The energy balance equqtion gives,\n", +"// Q = m_e*H_e +(m_2*U_2 - m_1*U_1), where 'm_e' is the mass exit from the system and 'H_e' is enthalpy at exit conditions.\n", +"//Since the vapour which exits out have enthalpy equal to that of saturated vapour,we get on simplification\n", +"// 900 = (1-m)*(2706.7) + m*((1-x)*504.49 + x*2529.5) - 513.5..........equation(2)\n", +"// The second equation on simplification becomes\n", +"// x = ((0.005/m) - 0.001061)/0.884639\n", +"\n", +"// Putting the expression of x in first equation and then simplifying, we get\n", +"// - 1293.2 = -2202.21*m + 11.445 - 2.429*m\n", +"m = (11.445+1293.2)/(2202.21+2.429);//[kg]\n", +"\n", +"// Therefore x can be calculated as\n", +"x = ((0.005/m) - 0.001061)/0.884639;\n", +"\n", +"// Therfore total water (liquid + vapour) present in the pressure cooker at the end of the process is m kg.\n", +"m_vapour = x*m;//[kg] - Mass of vapour\n", +"m_liquid = (1-x)*m;//[kg] - Mass of vapour\n", +"\n", +"printf(' Total water (liquid + vapour) present in the pressure cooker at the end of the process is %f kg\n',m);\n", +"printf(' The mass of vapour is %f kg\n',m_vapour);\n", +"printf(' The mass of liquid is %f kg\n',m_liquid);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.2: Calculation_of_heat_required.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.2\n", +"//Page number - 83\n", +"printf('Example - 3.2 and Page number - 83\n\n');\n", +"\n", +"//Given\n", +"V_tank = 1;//[m^(3)] - Volume of the tank\n", +"V_liq = 0.05;//[m^(3)] - Volume of saturated water\n", +"V_vap = 0.95;//[m^(3)] - Volume of saturated vapour\n", +"P = 1;//[bar] - Pressure\n", +"V_liq_sat = 0.001043;//[m^(3)/kg] - Specific volume of saturated water\n", +"V_vap_sat = 1.6940;//[m^(3)/kg] - Specific volume of saturated vapour\n", +"U_liq_sat = 417.4;//[kJ/kg] - Saturated liquid internal energy\n", +"U_vap_sat = 2506.1;//[kJ/kg] - Saturated vapour internal energy\n", +"m = (V_liq/V_liq_sat) + (V_vap/V_vap_sat);//[kg] - Total mass of water\n", +"U_1 = (V_liq/V_liq_sat)*U_liq_sat + (V_vap/V_vap_sat)*U_vap_sat;//[kJ] - Total internal energy\n", +"\n", +"// At final state,which is saturated vapour\n", +"V = V_tank/m;//[m^(3)/kg] - Molar volume\n", +"// From saturated steam table at 8 MPa,as reported in the book V_vap = 0.02352[m^(3)/kg] and U_vap = 2569.8[kJ/kg]\n", +"// At 9 MPa, Vv = 0.02048[m^(3)/kg] and Uv = 2557.8[kJ/kg]\n", +"// Therefore final state pressure of the system (from interpolation) is 8.954 [MPa] and internal energy of saturated vapour is 2558.35 [kJ/kg]\n", +"U_2 = m*2558.35;//[kJ] - Final total internal energy\n", +"del_Ut = U_2 - U_1;//[kJ] \n", +"//we have, del_U = Q - W\n", +"//Here work done is zero because volume is rigid.\n", +"Q = del_Ut;//[kJ]\n", +"Q = del_Ut*10^(-3);//[MJ]\n", +"printf(' The amount of heat to be added is %f MJ', Q);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.3: Calculation_of_temperature_internal_energy_and_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.3\n", +"//Page number - 83\n", +"printf('Example - 3.3 and Page number - 83\n\n');\n", +"\n", +"//Given\n", +"M_vap_sat = 0.22;//[kg] - mass of saturated vapour\n", +"M_liq_sat = 1.78;//[kg] - mass of saturated liquid\n", +"P = 700;//[kPa] - Pressure\n", +"\n", +"//At P=700 kPa,the systen is saturated,from steam table as reported in the book\n", +"T_sat1 = 164.97;//[C]\n", +"V_liq_1 = 0.001108;//[m^(3)/kg] \n", +"V_vap_1 = 0.2729;//[m^(3)/kg]\n", +"Vt_1 = V_liq_1*M_liq_sat + V_vap_1*M_vap_sat;//[m^(3)] - total volume\n", +"\n", +"//At final state,P = 8 MPa\n", +"T_sat2 = 295.06;//[C]\n", +"V_liq_2 = 0.001384;//[m^(3)/kg] \n", +"V_vap_2=0.02352;//[m^(3)/kg]\n", +"Vt_2 = Vt_1;// Since the volume is rigid.\n", +"// Since the volume of 2 kg of vapour is 0.062 [m^(3)]\n", +"V = Vt_2/2;//[m^(3)/kg] - specific volume\n", +"\n", +"// (a)\n", +"// From steam table at 8 [MPa]and 350 [C],V=0.02995[m^(3)/kg]; \n", +"V_1 = 0.02995;//[m^(3)/kg]\n", +"// And at 8 [MPa]and 400 [C],\n", +"V_2 = 0.03432;//[m^(3)/kg]\n", +"// By interpolation,\n", +"T = ((V-V_1)/(V_2 - V_1))*(400-350)+350;\n", +"printf(' (a).The final temperature is %f c\n',T);\n", +"\n", +"// (b)\n", +"// From steam table \n", +"U_1 = 2747.7;//[kJ/kg]\n", +"H_1 = 2987.3;//[kJ/kg]\n", +"// And at 8 [MPa]and 400 C,\n", +"U_2 = 2863.8;//[kJ/kg]\n", +"H_2 = 3138.3;//[kJ/kg]\n", +"// Therefore at T = 362.01 C\n", +"U = U_1+((U_2 - U_1)/(400 - 350))*(T - 350);\n", +"printf(' (b).The internal energy is %f kJ/kg\n',U);\n", +"\n", +"//(c)\n", +"H = H_1+((H_2 - H_1)/(400 - 350))*(T - 350);\n", +"printf(' (b).The enthalpy is %f kJ/kg\n',H);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.4: Calculation_of_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.4\n", +"//Page number - 85\n", +"printf('Example - 3.4 and Page number - 85\n\n');\n", +"\n", +"// Given\n", +"T = 300;//[K] - Temperature\n", +"P1 = 1;//[bar] - Initial pressure\n", +"P1 = P1*10^(5);//[N/m^(2)]\n", +"P2 = 8;//[bar] - Final pressure\n", +"P2 = P2*10^(5);//[N/m^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"Tc = 126.2;//[K] - Critical temperature\n", +"Pc = 34;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[N/m^(2)]\n", +"w = 0.038;// Acentric factor\n", +"\n", +"// w = integral(Pdv)\n", +"// Z = 1 + (B/V)\n", +"// (P*V)/(R*T) = 1 + (B/V)\n", +"// P = (R*T)/V + (B*R*T)/V^(2)\n", +"// w = integrate('(R*T/V) + (B*R*T)/V^(2)','V',V1,V2)\n", +"// Under isothermal conditions,\n", +"// w = R*T*log(V2/V1) - B*R*T*((1/V2) - (1/V1));\n", +"// The second virial coefficient at state 1 is same as at state 2,as the temperature is the same i.e, T=300 [K]\n", +"Tr = T/Tc;\n", +"B_0 = 0.083 - (0.422/(Tr)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr)^(4.2));\n", +"B = ((B_0+(w*B_1))*(R*Tc))/Pc;//[m^(3)/mol]\n", +"\n", +"// Now we have to calculate molar volume i.e V1 and V2 at given conditions\n", +"// At state 1,\n", +"deff('[y]=f(V)','y=V^(2)-(R*T/P1)*V-(B*R*T)/P1');\n", +"V_1 = fsolve(-1,f);\n", +"V_2 = fsolve(1,f);\n", +"// We will take root near to (R*T)/P, i.e V_2\n", +"V1 = V_2;\n", +"\n", +"// At state 2,\n", +"deff('[y]=f1(V)','y=V^(2)-(R*T/P2)*V-(B*R*T)/P2');\n", +"V_3=fsolve(-1,f1);\n", +"V_4=fsolve(1,f1);\n", +"V2 = V_4;\n", +"// The work done is thus,\n", +"w = R*T*log(V2/V1) - B*R*T*((1/V2) - (1/V1));//[J]\n", +"w = w*10^(-3);//[kJ]\n", +"\n", +"printf(' The work done is %f kJ/mol\n',w);\n", +"printf(' Negative sign indicates that work is done on the gas');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.5: Calculation_of_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.5\n", +"//Page number - 86\n", +"printf('Example - 3.5 and Page number - 86\n\n');\n", +"\n", +"//Given\n", +"\n", +"T = 300;//[K] - Temperature\n", +"P1 = 1;//[bar] - Initial pressure\n", +"P1 = P1*10^(5);//[N/m^(2)]\n", +"P2 = 8;//[bar] - Final pressure\n", +"P2 = P2*10^(5);//[N/m^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"y1 = 0.21;// Mole fraction of component 1 (oxygen)\n", +"y2 = 0.79;// Mole fraction of component 1 (nitroen)\n", +"\n", +"// For component 1 (Oxygen)\n", +"Tc_1 = 154.6;//[K]\n", +"Pc_1 = 50.43*10^(5);//[N/m^(2)]\n", +"Vc_1 = 73.4;//[cm^(3)/mol]\n", +"Zc_1 = 0.288;\n", +"w_1 = 0.022;\n", +"\n", +"//For component 2 (Nitrogen)\n", +"Tc_2 = 126.2;//[K]\n", +"Pc_2 = 34*10^(5);//[N/m^(2)]\n", +"Vc_2 = 89.2;//[cm^(3)/mol]\n", +"Zc_2 = 0.289;\n", +"w_2 = 0.038;\n", +"\n", +"//For component 1\n", +"Tr_1 = T/Tc_1;//Reduced temperature\n", +"//At reduced temperature\n", +"B1_0 = 0.083 - (0.422/(Tr_1)^(1.6));\n", +"B1_1 = 0.139 - (0.172/(Tr_1)^(4.2));\n", +"// We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", +"B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;//[m^(3)/mol]\n", +"\n", +"// Similarly for component 2\n", +"Tr_2 = T/Tc_2;//Reduced temperature\n", +"// At reduced temperature Tr_2,\n", +"B2_0 = 0.083 - (0.422/(Tr_2)^(1.6));\n", +"B2_1 = 0.139 - (0.172/(Tr_2)^(4.2));\n", +"B_22 = ((B2_0 + (w_2*B2_1))*(R*Tc_2))/Pc_2;//[m^(3)/mol]\n", +"\n", +"//For cross coeffcient\n", +"Tc_12 = (Tc_1*Tc_2)^(1/2);//[K]\n", +"w_12 = (w_1 + w_2)/2;\n", +"Zc_12 = (Zc_1+Zc_2)/2;\n", +"Vc_12 = (((Vc_1)^(1/3)+(Vc_2)^(1/3))/2)^(3);//[cm^(3)/mol]\n", +"Vc_12 = Vc_12*10^(-6);//[m^(3)/mol]\n", +"Pc_12 = (Zc_12*R*Tc_12)/Vc_12;//[N/m^(2)]\n", +"\n", +"// Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n", +"// where B_0 and B_1 are to be evaluated at Tr_12\n", +"Tr_12 = T/Tc_12;\n", +"// At reduced temperature Tr_12\n", +"B_0 = 0.083 - (0.422/(Tr_12)^(1.6));\n", +"B_1 = 0.139 - (0.172/(Tr_12)^(4.2));\n", +"B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;//[m^(3)/mol]\n", +"\n", +"// For the mixture\n", +"B = y1^(2)*B_11 + 2*y1*y2*B_12+y2^(2)*B_22;//[m^(3)/mol]\n", +"// Now we have to calculate molar volume i.eV1 and V2 at given conditions\n", +"\n", +"// At state 1,\n", +"deff('[y]=f(V)','y=V^(2)-(R*T/P1)*V-(B*R*T)/P1');\n", +"V_1=fsolve(-1,f);\n", +"V_2=fsolve(1,f);\n", +"// We will take root near to (R*T)/P, i.e V_2\n", +"V1 = V_2;//[m^(3)/mol]\n", +"\n", +"// At state 2,\n", +"deff('[y]=f1(V)','y=V^(2)-(R*T/P2)*V-(B*R*T)/P2');\n", +"V_3=fsolve(-1,f1);\n", +"V_4=fsolve(1,f1);\n", +"V2 = V_4;//[m^(3)/mol]\n", +"\n", +"// Work done per mole of air is given by, w=integral(Pdv)\n", +"// Z = 1 + (B/V)\n", +"// (P*V)/(R*T) = 1 +( B/V)\n", +"// P = (R*T)/V+(B*R*T)/V^(2)\n", +"// w = integrate('(R*T/V)+(B*R*T)/V^(2)','V',V1,V2)\n", +"// Under isothermal conditions,\n", +"w = R*T*log(V2/V1)-B*R*T*((1/V2)-(1/V1));\n", +"w = w*10^(-3);//[kJ/mol]\n", +"printf(' The work done is %f kJ/mol',w);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.6: Calculation_of_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"//Example - 3.6\n", +"//Page number - 88\n", +"printf('Example - 3.6 and Page number - 88\n\n');\n", +"//Given\n", +"T = 125+273.15;//[K] - Temperature\n", +"P1 = 1;//[bar] - Initial pressure\n", +"P1 = P1*10^(5);//[N/m^(2)]\n", +"P2 = 60;//[bar] - Final pressure\n", +"P2 = P2*10^(5);//[N/m^(2)]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"Tc = 416.3;//[K] - Critical temperature\n", +"Pc = 66.80*10^(5);//[N/m^(2)] - Critical pressure\n", +"// (1)\n", +"// Virial equation of state, Z = 1 + (B/V)+(C/V^(2))\n", +"// (P*V)/(R*T) = 1 + (B/V)+(C/V^(2))\n", +"// P = (R*T)/V+(B*R*T)/V^(2)+(C*R*T)/V^(3)\n", +"// w = integral(PdV)=R*T*log(V2/V1)-(B*R*T)*(1/V2-1/V1)-(C*R*T/2)*(1/V2^(2)-1/V1^(2))\n", +"B = -207.5;//[cm^(3)/mol] - Second virial coefficient\n", +"B = -207.5*10^(-6);//[m^(3)/mol]\n", +"C = 18200;//[cm^(6)/mol^(2)] - Third virial coefficient\n", +"C = 18200*10^(-12);//[m^(6)/mol^(2)]\n", +"// We need to calculate molar volume at state 1 and 2,\n", +"// At state 1,P = P1,\n", +"// V^(3)-(R*T/P)*V^(2)-(B*R*T/P)*V-(C*R*T/P)=0\n", +"// Solving the cubic equation\n", +"deff('[y]=f1(V)','y=V^(3)-(R*T/P1)*V^(2)-(B*R*T/P1)*V-(C*R*T/P1)');\n", +"V_1=fsolve(-1,f1);\n", +"V_2=fsolve(0,f1);\n", +"V_3=fsolve(10,f1);\n", +"// The cubic equation has only 1 real root,other two roots are imaginary.\n", +"V1 = V_3;\n", +"// Similarly at state 2,P=P2\n", +"// V^(3) - (R*T/P)*V^(2) - (B*R*T/P)*V - (C*R*T/P) = 0\n", +"// Solving the cubic equation\n", +"deff('[y]=f2(V)','y=V^(3)-(R*T/P2)*V^(2)-(B*R*T/P2)*V-(C*R*T/P2)');\n", +"V_4=fsolve(-1,f2);\n", +"V_5=fsolve(0,f2);\n", +"V_6=fsolve(1,f2);\n", +"V2 = V_6;\n", +"// Finally work done is given by,\n", +"w1 = R*T*log(V2/V1)-(B*R*T)*(1/V2-1/V1)-(C*R*T/2)*(1/V2^(2)-1/V1^(2));//[J/mol]\n", +"w1 = w1*10^(-3);//[kJ/mol]\n", +"printf(' (1).The work done using given virial equation of state is %f kJ/mol\n',w1);\n", +"// (2)\n", +"// Virial equation of state, Z = 1+(B*P)/(R*T)+((C-B^(2))/(R*T)^(2))*P^(2)\n", +"// (P*V)/(R*T)= 1+(B*P)/(R*T)+((C-B^(2))/(R*T)^(2))*P^(2)\n", +"// V = (R*T)/P+B+((C-B^(2))/(R*T))*P\n", +"// Differentiating both sides by P and integrating we get,\n", +"// w = integral(PdV)=-(R*T)*log(P2/P1)+((C-B^(2))/(2*R*T))*(P2^(2)-P1^(2))\n", +"w2 = -(R*T)*log(P2/P1) + ((C-B^(2))/(2*R*T))*(P2^(2)-P1^(2));//[J/mol]\n", +"w2 = w2*10^(-3);//[kJ/mol]\n", +"printf(' (2).The work done using given virial equation of state is %f kJ/mol\n',w2);\n", +"// (3)\n", +"// Van der Walls equation of state is given by,\n", +"a = (27*(R^(2))*(Tc^(2)))/(64*Pc);//[Pa*m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"// P = ((R*T)/(V-b))-a/(V^(2));//[N/m^(2)]\n", +"// w = integral(PdV)=R*T*log((V2-b)/(V1-a))+a*(1/V2-1/V1)\n", +"// The cubic form of van der Walls equation of state is given by,\n", +"// V^(3) - (b+(R*T)/P)*V^(2) + (a/P)*V - (a*b)/P = 0\n", +"// Solving the cubic equation for P=P1\n", +"deff('[y]=f3(V)','y=V^(3)-(b+(R*T)/P1)*V^(2)+(a/P1)*V-(a*b)/P1');\n", +"V2_1=fsolve(1,f3);\n", +"V2_2=fsolve(10,f3);\n", +"V2_3=fsolve(100,f3);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root (V2_3).\n", +"// Similarly at state 2,for P=P2,\n", +"deff('[y]=f4(V)','y=V^(3)-(b+(R*T)/P2)*V^(2)+(a/P2)*V-(a*b)/P2');\n", +"V2_4=fsolve(1,f4);\n", +"V2_5=fsolve(10,f4);\n", +"V2_6=fsolve(100,f4);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root (V2_6).\n", +"// Finally work done is given by\n", +"w3 = R*T*log((V2_6-b)/(V2_3-b))+a*(1/V2_6-1/V2_3);//[J/mol]\n", +"w3 = w3*10^(-3);//[kJ/mol]\n", +"printf(' (3).The work done using van der Walls equation of state is %f kJ/mol\n',w3);\n", +"// (4)\n", +"// Redlich Kwong equation of state,\n", +"a_1 = (0.42748*(R^(2))*(Tc^(2.5)))/Pc;//[Pa*m^(6)*K^(1/2)/mol]\n", +"b_1 = (0.08664*R*Tc)/Pc;//[m^(3)/mol]\n", +"// P = ((R*T)/(V-b_1))-(a_1/(T^(1/2)*V*(V+b_1)));//[N/m^(2)]\n", +"// Work done is given by\n", +"// w = R*T*log((V2-b)/(V1-b))-a/T^(1/2)*integrate('1/V*(V+b)',V',V1,V2)\n", +"// Using the factorization 1/(V*(V+b))=(1/b)*((1/V)-(1/V+b)),we get\n", +"// w = R*T*log((V2-b)/(V1-b))-(a/(b*T^(1/2)))*(log(V2/V1)-log((V2+b)/(V1+b))\n", +"// Now we have calculate V1 and V2,\n", +"// The cubic form of Redlich Kwong equation of state is given by,\n", +"// V^(3) - ((R*T)/P)*V^(2) - ((b_1^(2)) + ((b_1*R*T)/P) - (a/(T^(1/2)*P))*V - (a*b)/(T^(1/2)*P) = 0\n", +"// Solving the cubic equation at state 1,\n", +"deff('[y]=f5(V)','y=V^(3)-((R*T)/P1)*V^(2)-((b_1^(2))+((b_1*R*T)/P1)-(a_1/(T^(1/2)*P1)))*V-(a_1*b_1)/(T^(1/2)*P1)');\n", +"V3_1=fsolve(1,f5);\n", +"V3_2=fsolve(10,f5);\n", +"V3_3=fsolve(100,f5);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root (V3_3).\n", +"// Similarly at state 2,for P = P2,\n", +"deff('[y]=f6(V)','y=V^(3)-((R*T)/P2)*V^(2)-((b_1^(2))+((b_1*R*T)/P2)-(a_1/(T^(1/2)*P2)))*V-(a_1*b_1)/(T^(1/2)*P2)');\n", +"V3_4=fsolve(1,f6);\n", +"V3_5=fsolve(10,f6);\n", +"V3_6=fsolve(100,f6);\n", +"// The above equation has 1 real and 2 imaginary roots. We consider only real root (V3_6).\n", +"// Finally work done is given by\n", +"w4 = R*T*log((V3_6-b_1)/(V3_3-b_1))-(a_1/(b_1*T^(1/2)))*(log(V3_6/V3_3)-log((V3_6+b_1)/(V3_3+b_1)));//[J/mol]\n", +"w4 = w4*10^(-3);//[kJ/mol]\n", +"printf(' (3).The work done using Redlich Kwong equation of state is %f kJ/mol\n',w4);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.7: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.7\n", +"//Page number - 92\n", +"printf('Example - 3.7 and Page number - 92\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 3.7 on page number 92 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 3.7 on page number 92 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.8: Calculation_of_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"//Example - 3.8\n", +"//Page number - 93\n", +"printf('Example - 3.8 and Page number - 93\n\n');\n", +"//Given\n", +"T = 20 + 273.15;//[K] - Temperature\n", +"P_1 = 140;//[kPa] - Initial pressure\n", +"P_1 = P_1*10^(3);//[Pa]\n", +"P_2 = 560;//[kPa] - Final pressure\n", +"P_2 = P_2*10^(3);//[Pa]\n", +"R = 1.987;//[cal/mol*K] - Universal gas constant\n", +"// Cp_0 = 1.648+4.124*10^(-2)*T - 1.53*10^(-5)*T^(2) + 1.74*10^(-9)*T^(3)\n", +"// Using adiabatic compression, P*V^(Y)=constant. For ideal gases\n", +"// P*(R*T/P)^(Y) = constant\n", +"// P^(1-Y)*T^(Y) = constant or,P1^(1-Y)*T1^(Y)=P2^(1-Y)*T2^(Y)\n", +"// Now,at state 1, i.e at T=20[C]\n", +"Cp_1 = 1.648+4.124*10^(-2)*T-1.53*10^(-5)*T^(2)+1.74*10^(-9)*T^(3);//[cal/mol*K] - Heat capacity at constant pressure\n", +"Cv_1 = Cp_1 - R;//[cal/mol*K] - Heat capacity at constant volume\n", +"Y1 = Cp_1/Cv_1;// Ratio of heat capacities\n", +"// Now calculatung the temperature at state 2 (T2)\n", +"// (T2/T1)=(P1/P2)^((1-Y1)/Y1)\n", +"T_1 = T;\n", +"T_2 = ((P_1/P_2)^((1-Y1)/Y1))*T_1;//[K]\n", +"// Now calculating the mean temperature\n", +"T_mean = (T_1 + T_2)/2;//[K]\n", +"// At mean temperature\n", +"Cp_2 = 1.648+4.124*10^(-2)*T_mean - 1.53*10^(-5)*T_mean^(2) + 1.74*10^(-9)*T_mean^(3);//[cal/mol*K] - Heat capacity at constant pressure\n", +"Cv_2 = Cp_2 - R;//[cal/mol*K] - Heat capacity at constant volume\n", +"Y2 = Cp_2/Cv_2;\n", +"// Calculating exit temperature\n", +"// Again using the realation,(T2/T1)=(P1/P2)^((1-Y1)/Y1)\n", +"T_exit = ((P_1/P_2)^((1-Y2)/Y2))*T_1;//[K]\n", +"// Since value of mean temperature has not changed much the molar heat capacity ratio can be assumed to be same.Therefore\n", +"// w = -delta(U)=Cv_0*(T2-T1)\n", +"w = Cv_2*(T_1 - T_exit);//[cal/mol]\n", +"w = w*4.184;//[J/mol]\n", +"printf(' The work done for adiabatic compression is %f J/mol\n',w);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.9: Calculation_of_final_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 3.9\n", +"//Page number - 93\n", +"printf('Example - 3.9 and Page number - 93\n\n');\n", +"\n", +"//Given\n", +"m_ice = 1000;//[g] - Mass of ice\n", +"m_water = 1000;//[g] - Mass of water\n", +"T_ice = 273.15;//[K] - Temperature of ice\n", +"T_water = 373.15;//[K] - Temperature of water\n", +"L = 79.71;//[cal/g] - Latent heat of melting of ice.\n", +"\n", +"//(1)\n", +"Cp_1 = 1;//[cal/g-K] - Heat capacity at constant pressure\n", +"// Let the final temperature be T\n", +"// We assume that all of the ice melts.Energy taken up by ice is\n", +"// E1 = L*m_ice + m_ice*Cp_1*(T - T_ice)\n", +"// Energy given by hot water is,\n", +"// E2 = m_water*Cp_1*(T_water - T)\n", +"// No heat exchange with surrounding.Solving for T\n", +"T_1 = (m_ice*Cp_1*T_ice + m_water*Cp_1*T_water - L*m_ice)/(m_ice*Cp_1 + m_water*Cp_1);//[K]\n", +"T_1 = T_1 - 273.15;//[C]\n", +"\n", +"printf(' (1).The final temperature (taking Cp_water = 1 cal/g-K) is %f C\n',T_1);\n", +"//Since the final temperature is greater than 273.15 K,so our assumption that all of ice melts is correct\n", +"\n", +"// (2)\n", +"// Cp_2 = 1.00874-0.7067*10^(-3)*T+15.93*10^(-6)*T^(2)-83.8*10^(-9)*T^(3);\n", +"// From energy balance,we get L*m_ice + m_ice*integrate('Cp_2','T',0,T) + m_water*integrate('Cp_2','T',100,T) = 0; (where T is in C)\n", +"// On putting the values and then simplifying we get\n", +"// 2.01748*T - 0.0007067*T^(2) + 1.062*10^(-5)*T^(3) - 4.19*10^(-8)*T^(4) - 20.8455 = 0\n", +"// Solving the above equation we get\n", +"deff('[y]=f1(T)','y = 2.01748*T - 0.0007067*T^(2) + 1.062*10^(-5)*T^(3) - 4.19*10^(-8)*T^(4) - 20.8455');\n", +"T_0 = fsolve(1,f1);//[C]\n", +"printf(' (2).The final temperature using specific heat capacity equation is %f C\n',T_0);\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/4-The_Secomd_Law_and_Its_Applications.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/4-The_Secomd_Law_and_Its_Applications.ipynb new file mode 100644 index 0000000..6e8b087 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/4-The_Secomd_Law_and_Its_Applications.ipynb @@ -0,0 +1,1387 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4: The Secomd Law and Its Applications" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.10: Determination_of_work_required_and_exit_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.10\n", +"//Page number - 161\n", +"printf('Example - 4.10 and Page number - 161\n\n');\n", +"\n", +"//Given\n", +"P_1 = 1;//[MPa] - Initial pressure\n", +"T_1 = 200 + 273.15;//[K] - Initial temperature\n", +"P_2 = 8;//[MPa] - Final pressure\n", +"Y = 1.4;// Index of expansion of gas\n", +"R = 1.987;//[cal/mol*K] - Universal gas constant\n", +"// Cp_0 = 7.7 + 0.04594*10^(-2)*T + 0.2521*10^(-5)*T^(2) - 0.8587*10^(-9)*T^(3), here T is in K and Cp_0 is in cal/mol-K\n", +"a = 7.7;\n", +"b = 0.04594*10^(-2);\n", +"c = 0.2521*10^(-5);\n", +"d = - 0.8587*10^(-9);\n", +"\n", +"// delta_S = integral((Cp_0/T)*dT) - R*log(P_2/P_1) = 0\n", +"// delta_S = integral(((a + b*T + c*T^(2) + d*T^(3))/T)*dT) - R*log(P_2/P_1) = 0\n", +"// delta_S = a*log(T_2/T_1) + b*(T_2 - T_1) + (c/2)*(T_2^(2) - T_1^(2)) + (d/3)*(T_2^(3) - T_1^(3)) - R*log(P_2/P_1) = 0\n", +"// Solving for T_2 in the above equation we get\n", +"deff('[y]=f(T_2)','y=a*log(T_2/T_1)+b*(T_2-T_1)+(c/2)*(T_2^(2)-T_1^(2))+(d/3)*(T_2^(3)-T_1^(3))-R*log(P_2/P_1)');\n", +"T_2 = fsolve(100,f);\n", +"\n", +"// Now let us calculate the enthalpy change under these conditions \n", +"delta_H_s = integrate('7.7+0.04594*10^(-2)*T+0.2521*10^(-5)*T^(2)-0.8587*10^(-9)*T^(3)','T',T_1,T_2);//[cal/mol]\n", +"delta_H_s = delta_H_s*4.184;//[J/mol]\n", +"// Therefore isentropic work done is\n", +"W = - delta_H_s;\n", +"\n", +"printf(' (1).The exit temperature of steam is %f K\n',T_2);\n", +"printf(' The required work is %f J/mol\n\n',W);\n", +"\n", +"//(2)\n", +"eff = 0.8;\n", +"delta_H_a = delta_H_s/eff;//[J/mol] - Actual enthalpy change\n", +"// Therefore actual work done is given by \n", +"W_a = - delta_H_a;//[J/mol]\n", +"\n", +"// Now we have to determine the exit temperature under actual conditions\n", +"// delta_H_a = integral(Cp_0*dT) from limit T_1 = 473.15 K to T_2\n", +"// On putting the values and simplifying we get\n", +"// 7.7*T_2 + 0.02297*10^(-2)*T_2^(2) + 0.084*10^(-5)*T_2^(3) - 0.214675*10^(-9)*T_2^(4) - 6907.106 = 0\n", +"\n", +"deff('[y]=f1(T_2_prime)','y=a*(T_2_prime-T_1)+(b/2)*(T_2_prime^(2)-T_1^(2))+(c/3)*(T_2_prime^(3)-T_1^(3))+(d/4)*(T_2_prime^(4)-T_1^(4))-(delta_H_a/4.184)');\n", +"T_2_prime = fsolve(100,f1);\n", +"\n", +"printf(' (2).The exit temperature of steam is %f K\n',T_2_prime);\n", +"printf(' The required work is %f J/mol\n\n',W_a);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.11: Determination_of_work_required_and_exit_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.11\n", +"//Page number - 162\n", +"printf('Example - 4.11 and Page number - 162\n\n');\n", +"\n", +"//Given\n", +"P_1 = 1;//[MPa] - Initial pressure\n", +"T_1 = 200 + 273.15;//[K] - Initial temperature\n", +"P_2 = 8;//[MPa] - Final pressure\n", +"Y = 1.4;// Index of expansion of gas\n", +"\n", +"// At state 1 (1 MPa and 200 C) from steam table as reported in the book\n", +"H_1 = 2827.9;//[kJ/kg]\n", +"S_1 = 6.694;//[kJ/kg]\n", +"// At state 2 (8 MPa)\n", +"S_2 = S_1;// Isentropic process\n", +"// From steam table at 8 MPa and 450 C\n", +"S_21 = 6.5551;//[kJ/kg-K]\n", +"// From steam table at 8 MPa and 500 C\n", +"S_22 = 6.7240;//[kJ/kg-K]\n", +"// Therefore temperature at which entropy of steam is 6.694 kJ/kg-K is given by\n", +"T_2 = 450 + (500-450)/(S_22-S_21)*(S_2-S_21);//[C]\n", +"T_2 = T_2 + 273.15;//[K]\n", +"\n", +"// Enthalpy of steam at 8 MPa and 450 C from steam table as reported in the book \n", +"H_21 = 3272.0;//[kJ/kg]\n", +"// And at 8 MPA and 500 C\n", +"H_22 = 3398.3;//[kJ/kg]\n", +"// Therefore enthalpy of steam at 8 MPa and T_2 \n", +"H_2 = H_21 + ((H_22-H_21)/(500-450))*((T_2-273.15) - 450); \n", +"// Work done is given by \n", +"// W = - delta_H_s\n", +"W = - (H_2 - H_1);//[J/g]\n", +"W = W*18.015;//[J/mol]\n", +"delta_H_s = - W;\n", +"\n", +"printf(' (1).The exit temperature of steam is %f K\n',T_2);\n", +"printf(' The required work is %f J/mol\n\n',W);\n", +"\n", +"//(2)\n", +"eff = 0.8;// Adiabatic efficiency\n", +"// delta_H_s/delta_H_a = 0.8\n", +"delta_H_a = delta_H_s/eff;//[J/mol] - Actual enthalpy change\n", +"// Therefore actual work done \n", +"W_a = - delta_H_a;//[J/mol]\n", +"// Enthalpy at actual exit conditions is \n", +"H_2_a = H_1 + delta_H_a/18.015;//[kJ/kg]\n", +"\n", +"// Enthalpy of steam at 8 MPa and 500 C from steam table as reported in the book \n", +"H_21_a = 3398.3;//[kJ/kg]\n", +"// And at 8 MPA and 550 C\n", +"H_22_a = 3521.0;//[kJ/kg]\n", +"// Therefore temperature at H_22_a is given by\n", +"T_2_a = 500 + ((550-500)*(H_2_a - H_21_a))/(H_22_a - H_21_a);//[C]\n", +"T_2_a = T_2_a + 273.15;//[K]\n", +"\n", +"printf(' (2).The exit temperature of steam is %f K\n',T_2_a);\n", +"printf(' The required work is %f J/mol\n\n',W_a);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.12: Determination_of_work_required_and_discharge_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.12\n", +"//Page number - 163\n", +"printf('Example - 4.12 and Page number - 163\n\n');\n", +"\n", +"//Given\n", +"P_1 = 140;//[kPa] - Initial pressure\n", +"T_1 = 20 + 273.15;//[K] - Initial temperature\n", +"P_2 = 560;//[kPa] - Final pressure\n", +"eff = 0.75;// Compressor efficiency\n", +"R = 1.987;//[cal/mol*K] - Universal gas constant\n", +"// Cp_0 = 4.750 + 1.200*10^(-2)*T + 0.3030*10^(-5)*T^(2) - 2.630*10^(-9)*T^(3), here T is in K and Cp_0 is in cal/mol-K\n", +"a = 7.7;\n", +"b = 0.04594*10^(-2);\n", +"c = 0.2521*10^(-5);\n", +"d = - 0.8587*10^(-9);\n", +"\n", +"// At 20 C,as reported in the book\n", +"Cp_0 = 8.46;//[cal/mol-K] - Specific heat capacity at constant pressure\n", +"Cv_0 = Cp_0 - R;//[cal/mol-K] - Specific heat capacity at constant volume\n", +"Y = Cp_0/Cv_0;// Index of expansion\n", +"\n", +"// Assuming 100 % efficiency,for reversible and adiabatic process the final temperature is given by\n", +"// P*V^(Y) = constant or, P*((R*T)/P)^(Y) = constant\n", +"T_2 = ((P_1/P_2)^((1-Y)/Y))*T_1;//[K]\n", +"\n", +"// Since at final temperature the value of heat capacity ratio would have changed \n", +"// So let us determine Y at mean temperature and then calculating final temperature\n", +"T_mean = (T_1 + T_2)/2;//[K]\n", +"\n", +"// At T_mean,as reported in the book\n", +"Cp_0_new = 9.153;//[cal/mol-K]\n", +"Cv_0_new = Cp_0_new - R;//[cal/mol-K]\n", +"Y_new = Cp_0_new/Cv_0_new;\n", +"T_2_new = T_1*((P_1/P_2)^((1-Y_new)/Y_new));//[K]\n", +"\n", +"// The enthalpy change is given by \n", +"delta_H = integrate('4.750+1.200*10^(-2)*T+0.3030*10^(-5)*T^(2)-2.630*10^(-9)*T^(3)','T',T_1,T_2_new);//[cal/mol]\n", +"\n", +"//For adiabatic process\n", +"W = - delta_H;//[cal/mol]\n", +"// Now actual work done on the system is given by \n", +"W_a = W/eff;//[cal/mol]\n", +"\n", +"// Since the actual process is adiabatic the work done is change in negative of enthalpy\n", +"// Therefore actual change in enthalpy is - W_a, or\n", +"// - W_a = 4.750*(T_2-T_1) + (1.2*10^(-2)/2)*(T_2^(2)-T_1^(2)) + (0.3030*10^(-5)/3)*(T_2^(3)-T_1^(3)) - (2.63*10^(-9)/4)*(T_2^*(4)-T_1^(4));\n", +"// Solving for T_2 in the above equation\n", +"deff('[y]=f1(T_2_prime)','y=4.750*(T_2_prime-T_1)+((1.2*10^(-2))/2)*(T_2_prime^(2)-T_1^(2))+((0.3030*10^(-5))/3)*(T_2_prime^(3)-T_1^(3))-((2.63*10^(-9))/4)*(T_2_prime^(4)-T_1^(4))+W_a');\n", +"T_2_prime=fsolve(100,f1);\n", +"\n", +"printf(' The required work is %f cal/mol\n',W_a);\n", +"printf(' The discharge temperature of methane is %f K\n',T_2_prime);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.13: Dtermination_of_power_output_entropy_and_exit_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.13\n", +"//Page number - 164\n", +"printf('Example - 4.13 and Page number - 164\n\n');\n", +"\n", +"//Given\n", +"P_1 = 10;//[bar] - Initial pressure\n", +"T_1 = 500 + 273.15;//[K] - Initial temperature\n", +"P_2 = 2;//[psia] - Final pressure\n", +"P_2 = P_2/14.5;//[bar]\n", +"P_2 = P_2*10^(2);//[kPa]\n", +"m = 1.8;//[kg/s] - Mass flux\n", +"eff = 0.8;// Efficiency\n", +"\n", +"// At state 1, from steam table\n", +"H_1 = 3478.5;//[kJ/kg]\n", +"S_1 = 7.7622;//[kJ/kg-K]\n", +"S_2 = S_1;// Adiabatic process\n", +"\n", +"// From saturated steam table at 10 kPa\n", +"S_liq_1 = 0.6493;//[kJ/kg-K]\n", +"S_vap_1 = 8.1502;//[kJ/kg-K]\n", +"// From saturated steam table at 15 kPa\n", +"S_liq_2 = 0.7549;//[kJ/kg-K]\n", +"S_vap_2 = 8.0085;//[kJ/kg-K]\n", +"// Threfore at P_2 \n", +"S_liq = S_liq_1 + ((S_liq_2-S_liq_1)/(15-10))*(P_2-10);\n", +"S_vap = S_vap_1 + ((S_vap_2-S_vap_1)/(15-10))*(P_2-10);\n", +"\n", +"// The dryness fraction at exit state is\n", +"x_2 = (S_1-S_liq)/(S_vap-S_liq);\n", +"// The enthalpy at exit to be determined. At 10 kPa\n", +"H_liq_1 = 191.83;//[kJ/kg]\n", +"H_vap_1 = 2584.7;//[kJ/kg]\n", +"// At 15 kPa\n", +"H_liq_2 = 225.94;//[kJ/kg]\n", +"H_vap_2 = 2599.1;//[kJ/kg]\n", +"// Therfore at P_2\n", +"H_liq = H_liq_1 + ((H_liq_2-H_liq_1)/(15-10))*(P_2-10);\n", +"H_vap = H_vap_1 + ((H_vap_2-H_vap_1)/(15-10))*(P_2-10);\n", +"\n", +"// Enthalpy at state 2\n", +"H_2_s = H_liq*(1-x_2) + x_2*H_vap;//[kJ/kg]\n", +"W = m*(H_1 - H_2_s);//[kW]\n", +"\n", +"printf(' (1).The power output is %f kW\n\n',W);\n", +"\n", +"//(2)\n", +"// If the process is 80 % efficient the enthalpy change is\n", +"// H_1 - H_2_a = eff*(H_1 - H_2_s)\n", +"H_2_a = H_1 - (0.8*(H_1 - H_2_s));\n", +"\n", +"// Now under these conditions temperature and entropy have to be determined. From superheated steam tables,as reported in the book\n", +"// At 10 kPa and 100 C\n", +"H_2_1 = 2687.5;//[kJ/kg]\n", +"S_2_1 = 8.4479;//[kJ/kg-k]\n", +"// At 10 kPa and 150 C\n", +"H_2_2 = 2783.0;//[kJ/kg]\n", +"S_2_2 = 8.6882;//[kJ/kg-k]\n", +"// At 50 kPa and 100 C\n", +"H_3_1 = 2682.5;//[kJ/kg]\n", +"S_3_1 = 7.6947;//[kJ/kg-k]\n", +"// At 50 kPa and 150 C\n", +"H_4_1 = 2780.1;//[kJ/kg]\n", +"S_4_1 = 7.9401;//[kJ/kg-k]\n", +"// Therefore at P_2 and 100 C\n", +"H_prime_1 = H_2_1 + ((H_3_1-H_2_1)/(50-10))*(P_2-10);//[kJ/kg]\n", +"S_prime_1 = S_2_1 + ((S_3_1-S_2_1)/(50-10))*(P_2-10);//[kJ/kg-K]\n", +"// Therefore at P_2 and 150 C\n", +"H_prime_2 = H_2_2 + ((H_4_1-H_2_2)/(50-10))*(P_2-10);//[kJ/kg]\n", +"S_prime_2 = S_2_2 + ((S_4_1-S_2_2)/(50-10))*(P_2-10);//[kJ/kg-K]\n", +"\n", +"// Enthalpy at exit is H_2_a. So at this condition temperature can be nom be determined\n", +"T_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(150-100) + 100;//[C]\n", +"// The entropy at exit is\n", +"S_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(S_prime_2 - S_prime_1) + S_prime_1;//[kJ/kg-K]\n", +"\n", +"printf(' (2).The entropy at exit is %f kJ/kg-K\n',S_exit);\n", +"printf(' The temperature of the exit state is %f C\n\n',T_exit);\n", +"\n", +"printf(' The irreversibility is advatageous because the exit steam is superheated and therefore,\n');\n", +"printf(' the blades of the turbine are not eroded by water droplets which get formed when the process is isentropic');\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.14: Calculation_of_work_output_per_unit_mass.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.14\n", +"//Page number - 166\n", +"printf('Example - 4.14 and Page number - 166\n\n');\n", +"\n", +"//Given\n", +"P_1 = 6;//[MPa] - Initial pressure\n", +"T_1 = 500 + 273.15;//[K] - Initial temperature\n", +"P_2 = 10;//[kPa] - Final pressure\n", +"out_qlty = 0.9;// Output quality\n", +"\n", +"// At 6 MPa and 500 C, from steam table as reported in the book\n", +"H_1 = 3422.2;//[kJ/kg]\n", +"S_1 = 6.8803;//[kJ/kg-K]\n", +"S_2 = S_1;// Adiabatic reversible conditions\n", +"// At 10 kPa saturated\n", +"H_liq = 191.83;//[kJ/kg]\n", +"H_vap = 2584.7;//[kJ/kg]\n", +"S_liq = 0.6493;//[kJ/kg-K]\n", +"S_vap = 8.1502;//[kJ/kg-K]\n", +"\n", +"// The dryness fraction is given by \n", +"x = (S_1-S_liq)/(S_vap-S_liq);\n", +"\n", +"// Now the exit enthalpy is given by\n", +"H_2 = H_liq*(1-x) + x*H_vap;//[kJ/kg]\n", +"W = - (H_2 - H_1);//[kJ/kg] - Under isentropic conditions\n", +"\n", +"// We know that, delta_S = q/T_b + S_gen\n", +"// Since delta_S = 0, therefore under isentropic conditions\n", +"S_gen = 0;//[kJ/kg-K]\n", +"\n", +"// Now for output quality 0.9\n", +"H_2_a = H_liq*(1-out_qlty) + out_qlty*H_vap;//[kJ/kg]\n", +"S_2_a = S_liq*(1-out_qlty) + out_qlty*S_vap;//[kJ/kg]\n", +"W_a = - (H_2_a - H_1);//[kJ/kg]\n", +"delta_S_a = S_2_a - S_1;//[kJ/kg-k]\n", +"// Again, delta_S = q/T_b + S_gen\n", +"// Since q = 0, therefore under isentropic conditions\n", +"S_gen_a = delta_S_a;//[kJ/kg-K\n", +"// Now efficiency is given by eff = delta_H_a/delta_H_s\n", +"eff = W_a/W;\n", +"\n", +"printf(' For output quality = 0.9\n');\n", +"printf(' The work output per unit mass is %f kJ/kg\n',W_a);\n", +"printf(' The entropy generation is given by S_gen = %f kJ/kg-K\n',S_gen_a);\n", +"printf(' The efficiency with respect to reversible adiabatic case is given by eff = %f\n\n',eff);\n", +"\n", +"// Now for output quality 1\n", +"out_qlty_1 = 1;\n", +"H_2_a_1 = H_liq*(1-out_qlty_1) + out_qlty_1*H_vap;//[kJ/kg]\n", +"S_2_a_1 = S_liq*(1-out_qlty_1) + out_qlty_1*S_vap;//[kJ/kg]\n", +"W_a_1 = - (H_2_a_1 - H_1);//[kJ/kg]\n", +"delta_S_a_1 = S_2_a_1 - S_1;//[kJ/kg-k]\n", +"// Again, delta_S = q/T_b + S_gen\n", +"// Since q = 0, therefore under isentropic conditions\n", +"S_gen_a_1 = delta_S_a_1;//[kJ/kg-K\n", +"// Now efficiency is given by eff = delta_H_a/delta_H_s\n", +"eff_1 = W_a_1/W;\n", +"\n", +"printf(' For output quality = 1.0\n');\n", +"printf(' The work output per unit mass is %f kJ/kg\n',W_a_1);\n", +"printf(' The entropy generation is given by S_gen = %f kJ/kg-K\n',S_gen_a_1);\n", +"printf(' The efficiency with respect to reversible adiabatic case is given by eff = %f\n',eff_1);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.15: Estimation_of_final_velocity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.15\n", +"//Page number - 168\n", +"printf('Example - 4.15 and Page number - 168\n\n');\n", +"\n", +"//Given\n", +"P_1 = 3;//[bar] - Initial pressure\n", +"T_1 = 150 + 273.15;//[K] - Initial temperature\n", +"Vel_1 = 90;//[m/s] - Initial velocity\n", +"P_2 = 1;//[bar] - Final pressure\n", +"eff = 0.95;// Adiabatic effciciency of the nozzle\n", +"R = 8.314;//[J/mol*-] - Universal gas constant\n", +"\n", +"// At 3 bar and 150 C, from steam table\n", +"S_1 = 7.0778;//[kJ/kg-K]\n", +"H_1 = 2761.0;//[kJ/kg]\n", +"S_2 = S_1;// \n", +"\n", +"// At 1 bar saturated\n", +"S_liq = 1.3026;//[kJ/kg-K]\n", +"S_vap = 7.3594;//[kJ/kg-K]\n", +"H_liq = 417.46;//[kJ/kg]\n", +"H_vap = 2675.5;//[kJ/kg]\n", +"// The dryness factor of exit steam can be determined as\n", +"x = (S_1-S_liq)/(S_vap-S_liq);\n", +"// Enthalpy of exit steam is given by \n", +"H_2 = H_liq*(1-x) + x*H_vap;//[kJ/kg]\n", +"delta_H_s = H_2 - H_1;//[kJ/kg] - Enthalpy change\n", +"delta_H_a = eff*delta_H_s;//[kJ/kg]\n", +"\n", +"// Assuming no heat exchange with surroundings and since no work is done\n", +"// delta_H + (delta_V^(2))/2 = 0\n", +"delta_Vel_square = 2*(-delta_H_a)*1000;//[m^(2)/s^(2)]\n", +"Vel_2 = (delta_Vel_square + Vel_1^(2))^(1/2);//[m/s]\n", +"\n", +"printf(' (1).The final velocity (when fluid is steam) is %f m/s\n\n',Vel_2);\n", +"\n", +"// (2)\n", +"Y = 1.4;// Index of expansion\n", +"Cp_0 = (Y*R)/(Y-1);//[J/mol-K] - Specific heat capacity at constant pressure\n", +"// The final temperature has to be determined such that entropy change is zero. Under isentropic conditions\n", +"// P_1^(1-Y)*T_1^(Y) = P_2^(1-Y)*T_2^(Y)\n", +"T_2 = T_1*(P_1/P_2)^((1-Y)/Y);//[K]\n", +"delta_H_s_2 = Cp_0*(T_2 - T_1);//[J/mol]\n", +"delta_H_a_2 = eff*delta_H_s_2;//[J/mol]\n", +"delta_H_a_2 = (delta_H_a_2*1000)/28.84;//[J/kg]\n", +"\n", +"delta_Vel_square_2 = 2*(-delta_H_a_2);//[m^(2)/s^(2)]\n", +"Vel_2_2 = (delta_Vel_square_2 + Vel_1^(2))^(1/2);//[m/s]\n", +"\n", +"printf(' (2).The final velocity (when fluid is air which behaves as an ideal gas) is %f m/s\n\n',Vel_2_2);\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.16: Calculation_of_final_velocity_and_increase_in_entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.16\n", +"//Page number - 169\n", +"printf('Example - 4.16 and Page number - 169\n\n');\n", +"\n", +"//Given\n", +"P_1 = 300;//[kPa] - Initial pressure\n", +"T_1 = 450;//[K] - Initial temperature\n", +"Vel_1 = 90;//[m/s] - Initial velocity\n", +"P_2 = 180;//[kPa] - Final pressure\n", +"eff = 0.95;// Adiabatic effciciency of the nozzle\n", +"R = 8.314;//[J/mol*-] - Universal gas constant\n", +"Cp = 5.19;//[kJ/kg-K] - Specific heat capacity at constant pressure\n", +"\n", +"//(a)\n", +"// Exit velocity is highest when drop in enthalpy is highest or when isentropic conditions are maintained\n", +"\n", +"Mol_wt_He = 4;//[g/mol] - Molecular weight of helium\n", +"R_He = R/Mol_wt_He;// 'R' for helium\n", +"Y = Cp/(Cp - R_He);\n", +"\n", +"// Now temperature at exit to be determined\n", +"T_2s = T_1*(P_1/P_2)^((1-Y)/Y);//[K]\n", +"delta_H_2s = Cp*(T_2s - T_1);//[kJ/kg]\n", +"\n", +"// Since no work is done and heat exchange is zero,from first law we get\n", +"// delta_H + delta_Vel^(2)/2 = 0\n", +"delta_Vel_square = 2*(-delta_H_2s)*1000;//[m^(2)/s^(2)]\n", +"Vel_2 = (delta_Vel_square)^(1/2);//[m/s] - ( as Vel_1 << Vel_2)\n", +"\n", +"printf(' (a).The maximum exit velocity is %f m/s\n\n',Vel_2);\n", +"\n", +"//(b)\n", +"T_2a = 373;//[K] - Measured temperature of helium\n", +"delta_H_a = Cp*(T_2a - T_1);//[kJ/kg]\n", +"delta_Vel_square_a = 2*(-delta_H_a)*1000;//[m^(2)/s^(2)]\n", +"Vel_2a = (delta_Vel_square_a)^(1/2);//[m/s] - ( as Vel_1 << Vel_2a)\n", +"\n", +"printf(' (b).The actual exit velocity is %f m/s\n\n',Vel_2a);\n", +"\n", +"//(c)\n", +"delta_S_sys = Cp*log(T_2a/T_1) - R_He*log(P_2/P_1);\n", +"// we know that delta_S_sys = q/T_b + S_gen and since q = 0, therfore\n", +"S_gen = delta_S_sys;//[kJ/kg-K]\n", +"\n", +"printf(' (c).The increasse in entropy per unit mass is %f kJ/kg-K',S_gen);\n", +"\n", +"// The source of irreversibility is friction in the nozzle.\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.17: Calculation_of_work_done_and_heat_transfer.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.17\n", +"//Page number - 170\n", +"printf('Example - 4.17 and Page number - 170\n\n');\n", +"\n", +"//Given\n", +"P_1 = 1;//[bar] - Initial pressure\n", +"T_1 = 150 + 273.15;//[K] - Initial temperature\n", +"V_2 = 0.28;//[m^(3)/kg] - Final specific volume\n", +"T_2 = T_1;//[K] - Isothermal process\n", +"R = 8.314;//[J/mol-K] - Universal gas constant\n", +"\n", +"// At 1 bar and 150 C, from steam table\n", +"S_1 = 7.6134;//[kJ/kg-K]\n", +"H_1 = 2776.4;//[kJ/kg]\n", +"\n", +"// At 150 C saturated\n", +"V_liq = 0.001091;//[m^(3)/kg]\n", +"V_vap = 0.3928;//[m^(3)/kg]\n", +"H_liq = 632.2;//[kJ/kg]\n", +"H_vap = 2746.5;//[kJ/kg]\n", +"S_liq = 1.8418;//[kJ/kg-K]\n", +"S_vap = 6.8379;//[kJ/kg-K]\n", +"\n", +"// The dryness factor of exit steam can be determined as\n", +"x = (V_2 - V_liq)/(V_vap - V_liq);\n", +"S_2 = S_liq*(1-x) + x*S_vap;//[kJ/kg-K] -Entropy \n", +"H_2 = H_liq*(1-x) + x*H_vap;//[kJ/kg] -Enthalpy \n", +"delta_H = H_2 - H_1;//[kJ/kg] - Enthalpy change\n", +"delta_S = S_2 - S_1;//[kJ/kg]\n", +"\n", +"// Since the compression is reversible\n", +"q = T_1*delta_S;//[kJ/kg] - Heat transfer\n", +"// From first law q - W = delta_H\n", +"W = q - delta_H;//[kJ/kg]\n", +"\n", +"printf(' (1).The amount of heat transfer (when fluid is steam) is %f kJ/kg\n',q)\n", +"printf(' The amount of work transfer (when fluid is steam) is %f kJ/kg\n\n',W)\n", +"\n", +"//(2)\n", +"V_2 = V_2*(28.84/1000);//[m^(3)/mol] - Molar volume at exit\n", +"// Pressure at exit is given by \n", +"P_2 = ((R*T_2)/V_2);//[N/m^(2)]\n", +"P_2 = P_2*10^(-5);//[bar]\n", +"\n", +"// Entropy change is given by, delta_S_2 = Cp*log(T_2/T_1) - R*log(P_2/P_1), but since T_1 = T_2, therfore\n", +"delta_S_2 = - R*log(P_2/P_1);//[J/mol-K]\n", +"\n", +"q_2 = T_1*delta_S_2;//[J/mol] - Heat change\n", +"q_2 = q_2/28.84;//[kJ/kg]\n", +"\n", +"// Enthalpy change is given by, delta_H_2 = Cp*(T_2 - T_1) = 0 (as T_1 = T_2)\n", +"delta_H_2 = 0;//[kJ/kg]\n", +"\n", +"// From first law q - W = delta_H, therefore\n", +"W_2 = q_2 - delta_H_2;//[kJ/kg]\n", +"\n", +"printf(' (2).The amount of heat transfer (when fluid is ideal gas) is %f kJ/kg\n',q_2)\n", +"printf(' The amount of work transfer (when fluid is ideal gas) is %f kJ/kg\n',W_2)\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.18: Calculation_of_air_velocity_and_change_in_entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.18\n", +"//Page number - 171\n", +"printf('Example - 4.18 and Page number - 171\n\n');\n", +"\n", +"//Given\n", +"P_1 = 7*10^(5);//[Pa] - Initial pressure\n", +"T_1 = 95 + 273.15;//[K] - Initial temperature\n", +"P_2 = 3.5*10^(5);//[Pa] - Final pressure\n", +"dia = 15*10^(-2);//[m] - Diameter of pipe\n", +"m = 2;//[kg/s] - Mass flow rate\n", +"R = 8.314;//[J/mol-K] - Universal gas constant\n", +"Y = 1.4;// Index of expansion\n", +"Cp_0 = (R*Y)/(Y-1);//[J/mol-K] - Specific heat capacity at constant pressure\n", +"Cp_0 = (Cp_0/28.84)*1000;//[J/kg-K]\n", +"rho_1 = 6.6;//[kg/m^(3)] - Density\n", +"\n", +"// velocity before throttling is to be determined m = rho*Vol*Area\n", +"V_1 = (R*T_1)/P_1;//[m^(3)/mol] - Specific volume\n", +"V_1 = (V_1/28.84)*1000;//[m^(3)/kg]\n", +"Vel_1 = m/(rho_1*3.14*(dia/2)^(2));//[m/s] - Velocity before throttling\n", +"\n", +"// Let the temperature after throttling be T_2, then\n", +"// V_2 = (((R*T_2)/P_2)/28.84)*1000\n", +"// Vel_2 = m/(rho_2*Area) = (m*V_2)/(3.14*(dia/2)^(2))\n", +"// From first law, since q = W = 0, we get\n", +"// delta_H + (delta_V^(2))/2 = 0\n", +"// Cp_0*(T_2 - T_1) + ((Vel_2)^(2) - (Vel_1)^(2))/2 = 0\n", +"//Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)^(2)))^(2) - (Vel_1)^(2))/2 = 0\n", +"// Solving the above equation for T_2, we get\n", +"deff('[y]=f1(T_2)','y=Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)^(2)))^(2) - (Vel_1)^(2))/2');\n", +"T_2 =fsolve(100,f1);//[K] - Temperature after throttling \n", +"// Therefore velocity of air downstream of restriction is given by \n", +"Vel_2 = ((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)^(2)));//[m/s]\n", +"\n", +"printf(' The velocity of air downstream of restriction is %f m/s\n',Vel_2);\n", +"\n", +"delta_T = (T_2 - T_1);\n", +"// Since temperature difference (delta_T) is very small, therefore enthalpy change is also very small\n", +"\n", +"// Entropy change is given by, delta_S = Cp_0*log(T_2/T_1) - R*log(P_2/P_1), but since T_1 and T_2 are almost equal\n", +"delta_S = - R*log(P_2/P_1);//[J/mol-K]\n", +"\n", +"printf(' The change in entropy is %f kJ/mol-k',delta_S);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.1: Calculation_of_entropy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.1 \n", +"//Page number - 148\n", +"printf('Example - 4.1 and Page number - 148\n\n');\n", +"\n", +"//Given\n", +"n = 1000;//[mol]\n", +"T = 400;//[K]\n", +"P_1 = 100;//[kPa]\n", +"P_2 = 1000;//[kPa]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"//(a)\n", +"T_surr = 400;//[K] - surrounding temperature\n", +"// Total change in entropy of the system is given by\n", +"// delta_S_sys = n*(Cp_0*log(T_2/T_1) - R*log(P_2/P_1))\n", +"// The process being isothermal the first term is zero and the total entropy change of the system is\n", +"delta_S_sys_a = - n*R*log(P_2/P_1);//[J/K]\n", +"delta_S_sys_a = delta_S_sys_a*10^(-3);//[kJ/K]\n", +"\n", +"// Since the process is reversible therefore\n", +"Q_sys = T_surr*delta_S_sys_a;//[kJ] - Heat change in the system\n", +"// Negative sign in the value of Q_sys implies that heat is released from the system and is released to the surroundings,therefore\n", +"Q_surr = - Q_sys;//[kJ] - Heat change in the surrounding\n", +"delta_S_surr_a = Q_surr/T_surr;//[kJ/K]\n", +"\n", +"delta_S_univ_a = delta_S_sys_a + delta_S_surr_a;//[kJ/K]\n", +"// We get delta_S_univ = 0, which is true for a reversible process\n", +"\n", +"printf(' (a).The entropy change of the gas is given by delta_S_sys = %f kJ/K \n',delta_S_sys_a);\n", +"printf(' The entropy change of the surrounding is, delta_S_surr = %f kJ/K \n',delta_S_surr_a);\n", +"printf(' The total entropy change of the gas is, delta_S_univ = %f kJ/K \n\n',delta_S_univ_a);\n", +"\n", +"//(b)\n", +"T_surr_b = 300;//[K] - surrounding temperature\n", +"// Since the initial and final states are fixed therefore the entropy change of the system is same whether the process is carried out reversibly or irreversibly.\n", +"delta_S_sys_b = delta_S_sys_a;\n", +"\n", +"// Work done under reversible condition is given by\n", +"// W = integral(P*dV) = integral(((R*T)/V)*dV) = R*T*log(V_2/V_1)\n", +"// For ideal gas we have, P1*V1/T1 = P2*V2/T2 or, V2/V1 = P1/P2 (for isothermal conditions)\n", +"W = R*T*log(P_1/P_2);//[J/mol]\n", +"W = W*10^(-3);//[kJ/mol]\n", +"// 20% extra work has to be done for the system to reach the same final state as under reversible conditions. Therefore\n", +"W = W*(120/100);//[kJ/mol]\n", +"W = W*n;//[kJ] - Total work done for n moles\n", +"\n", +"// Using the first law we have delta_U = Q - W. Now under isothermal conditions for ideal gas, delta_U = 0. Therefore,\n", +"Q = -W;\n", +"// It implies that whatever work is done on the system is lost as heat to the surroundings.\n", +"// Since heat is gained by the surroundings therefore\n", +"delta_S_surr_b = Q/T_surr_b;//[kJ/K]\n", +"\n", +"delta_S_univ_b = delta_S_sys_b + delta_S_surr_b;//[kJ/K]\n", +"\n", +"printf(' (b).The entropy change of the gas is given by delta_S_sys = %f kJ/K \n',delta_S_sys_b);\n", +"printf(' The entropy change of the surrounding is, delta_S_surr = %f kJ/K \n',delta_S_surr_b);\n", +"printf(' The total entropy change of the gas is, delta_S_univ = %f kJ/K \n\n',delta_S_univ_b);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2: Determination_of_whether_the_process_is_reversible_or_not.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 4.1 \n", +"//Page number - 148\n", +"printf('Example - 4.1 and Page number - 148\n\n');\n", +"// Given\n", +"T = 400;//[K] - Temperature\n", +"P_1 = 500*10^(3);//[Pa] - Initial pressure\n", +"P_2 = 100*10^(3);//[Pa] - Final pressure\n", +"V_1 = 750*10^(-6);//[m^(3)] - Initial volume\n", +"W_actual = 0.55*10^(3);//[J] - Actual work done\n", +"R = 8.314;//[J/mol*K] - Universal fas constant\n", +"// Suppose that the surroundings are at 400 K.\n", +"// Therefore the process is externally reversible as temperature of the surroundings is same as system temperature.\n", +"// The number of moles is given by\n", +"n = (P_1*V_1)/(R*T);//[mol]\n", +"// The entropy change of ideal gas under isothermal condition is given by\n", +"delta_S_sys = - n*R*log(P_2/P_1);//[J/mol]\n", +"// The heat supplied to the system in the internally reversible process is\n", +"Q_theot = T*delta_S_sys;//[J]\n", +"// Since the process is isothermal therefore, workdone is given by\n", +"W_theot = Q_theot;//[J] - Theoritical work done\n", +"// Since actual work done by the gas is 0.55 kJ therefore actual heat supplied is also 0.55 kJ because under isothermal conditions delta_U = 0\n", +"Q_actual = W_actual;\n", +"// Since Q_theot > Q_actual, so the process is irreversible\n", +"printf(' Since, Q_theot = %f J is greater than Q_actual = %f J\n',Q_theot,Q_actual);\n", +"printf(' Therefore,the process is internally irreversible');\n", +"// Moreover delta_S_sys is same whether the process is reversible or irreversible as the initial and final states is the same.\n", +"// In the reversible process higher amount of heat is supplied (as compared to irreversible) due to which delta_S_sys take place.\n", +"// In the irreversible process the entropy of system increases due two reasons : heat supplied and entropy generation\n", +"// So in the irreversible case amount of heat supplied is less as compared to reversible case as entropy generation term also adds to the entropy change of system\n", +"// delta_S_sys = Q/T_b + S_gen\n", +"S_gen = delta_S_sys - (Q_theot/T);//[J/K]\n", +"// The entropy generated may be due to friction and other dissipayive effects or due to non-quasi-static expansion" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.3: Calculation_of_final_pressure_temperature_and_increase_in_entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.3\n", +"//Page number - 150\n", +"printf('Example - 4.3 and Page number - 150\n\n');\n", +"\n", +"// Given\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// For side A\n", +"V_A = 1;//[L] - Volume\n", +"V_A = V_A*10^(-3);//[m^(3)]\n", +"T_A = 300;//[K] - Temperature\n", +"P_A = 2;//[atm] - Pressure\n", +"P_A = P_A*101325;//[Pa]\n", +"\n", +"// For side B\n", +"V_B = 1;//[L] - volume\n", +"V_B = V_B*10^(-3);//[m^(3)]\n", +"T_B = 300;//[K] - Temperature\n", +"P_B = 1;//[atm] - Pressure\n", +"P_B = P_B*101325;//[Pa]\n", +"\n", +"// From first law final temperature and pressure are given by (example 3.30)\n", +"// T = ((n_A*T_A) + (n_B*T_B))/(n_A + n_B)\n", +"// P = ((P_A*V_A) + (P_A*V_B))/(V_A + V_B)\n", +"\n", +"// Since in this case T_A = T_B, therefore final pressure is given by\n", +"P = ((P_A*V_A) + (P_B*V_B))/(V_A + V_B);//[Pa]\n", +"P = P/101325;//[atm]\n", +"\n", +"printf(' The final temperature is %f K\n',T_A);\n", +"printf(' The final pressure is %f atm\n',P);\n", +"\n", +"// The number of moles of air on each side are\n", +"n_A = (P_A*V_A)/(R*T_A);//[mol]\n", +"n_B = (P_B*V_B)/(R*T_B);//[mol]\n", +"\n", +"delta_S_A = -n_A*R*log((P*101325)/P_A);//[J/K] - Entropy change on side A\n", +"delta_S_B = -n_B*R*log((P*101325)/P_B);//[J/K] - Entropy change on side B\n", +"delta_S_sys = delta_S_A + delta_S_B;//[J/K] - Total entropy change of system\n", +"\n", +"// Since the system is insulated there is no heat exchange with the surroundings, therefore entropy change of surrounding is zero\n", +"delta_S_surr = 0;//[J/K]\n", +"delta_S_univ = delta_S_sys + delta_S_surr;//[J/K]\n", +"printf(' The total increase in entropy is %f J/K',delta_S_univ);\n", +"\n", +"// The entropy change of the system can also be writtten as\n", +"// delta_s_sys = Q/T_b + S_gen\n", +"// Since there is no heat transfer, therefore\n", +"S_gen = delta_S_univ;//[J/K]\n", +"// The process is reversible because of entropy generation due to spontaneous release of piston.\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.4: CAlculation_of_final_temperature_heat_transfer_and_change_of_entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.4\n", +"//Page number - 151\n", +"printf('Example - 4.4 and Page number - 151\n\n');\n", +"\n", +"// Given\n", +"V_vessel = 0.2;//[m^(3)] - Volume of the vessel\n", +"P_1 = 10;//[bar] - Initial pressure inside the vessel\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"P_2 = 3.5;//[bar] - Final pressure inside the vessel\n", +"P_2 = P_2*10^(5);//Pa\n", +"T_1 = 250 + 273.15;//[K] - Initial temperature of the vesssel\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// (a)\n", +"// At 10 bar and 250 C the steam is superheated. From steam table as reported in book we have\n", +"V_1 = 0.2327;//[m^(3)/kg] - specific volume\n", +"U_1 = 2709.9;//[kJ/kg] - specific internal energy\n", +"H_1 = 2942.6;//[kj/kg] - Specific enthalpy\n", +"S_1 = 6.9247;//[kJ/kg-K] - Specific entropy\n", +"// the quantity of steam is given by\n", +"m = V_vessel/V_1;//[kg]\n", +"\n", +"// At final state \n", +"V_2 = 0.2327;//[m^(3)/kg] - Molar volume\n", +"V_liq_2 = 0.001079;// [m^(3)/kg]\n", +"V_vap_2 = 0.5243;// [m^(3)/kg]\n", +"// Since overall volume lies between saturated liquid and saturated vapour therefore the steam is saturated and its dryness fraction at final state is given by\n", +"x = (V_2 - V_liq_2)/(V_vap_2 - V_liq_2);\n", +"// Final temperature = T_sat (at 3 bar) from steam table\n", +"T_final = 138.88;//[C]\n", +"\n", +"// At 3.5 bar saturated conditions \n", +"S_liq = 1.7275;//[kJ/kg-K] - Entropy of saturated liquid\n", +"S_vap = 6.9405;//[kJ/kg-K] - Entropy of saturated vapour\n", +"U_liq = 583.95;//[kJ/kg] - Internal energy of saturated liquid\n", +"U_vap = 2548.9;//[kJ/kg] - Internal energy of saturated vapour\n", +"// Therefore at final state \n", +"U_2 = U_liq*(1 - x) + x*U_vap;//[kJ/kg]\n", +"S_2 = S_liq*(1 - x) + x*S_vap;//[kJ/kg-K]\n", +"Q_1 = m*(U_2 - U_1);//[kJ]\n", +"delta_S_1 = m*(S_2 - S_1);//[kJ/kg-K]\n", +"\n", +"printf(' (a).The final temperature is %f C\n',T_final);\n", +"printf(' The amount of heat transfer is %f kJ\n',Q_1);\n", +"printf(' The change of entropy is %f kJ/kg-K\n\n',delta_S_1);\n", +"\n", +"// (b)\n", +"Y = 1.4;// Ratio of heat capacities for air\n", +"// (P_1*V_1)/T_1 = (P_2*V_2)/T_2 and since V_1 = V_2\n", +"T_2 = (P_2/P_1)*T_1;//[K]\n", +"\n", +"// Since the volume is fixed therefore work done (W) = 0 and from first law we get\n", +"// Q = delta_U = n*Cv_0*(T_2 - T_1)\n", +"Cv_0 = R/(Y - 1);//[J/mol-K] - Heat capacity at constant volume\n", +"Cp_0 = (Y*R)/(Y - 1);//[J/mol-K] - Heat capacity at constant pressure\n", +"n = (P_1*V_vessel)/(R*T_1);//[mol] - No. of moles\n", +"Q_2 = n*Cv_0*(T_2 - T_1);//[J] - Heat change\n", +"Q_2 = Q_2*10^(-3);//[kJ]\n", +"\n", +"delta_S_2 = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);//[J/mol-K]\n", +"delta_S_2 = n*delta_S_2*10^(-3);//[kJ/K]\n", +"\n", +"printf(' (b).The final temperature is %f C\n',T_2);\n", +"printf(' The amount of heat transfer is %f kJ\n',Q_2);\n", +"printf(' The change of entropy is %f kJ/K\n',delta_S_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.5: Calculation_of_final_temperature_work_and_heat_transfer.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.5\n", +"//Page number - 153\n", +"printf(' Example - 4.5 and Page number - 153\n\n');\n", +"\n", +"// Given\n", +"m = 1000;//[g] - Mass of fluid\n", +"P_1 = 20;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"P_2 = 2;//[bar] - Final pressure\n", +"P_2 = P_2*10^(5);//Pa\n", +"T_1 = 250 + 273.15;//[K] - Initial temperature\n", +"n = 1.25;\n", +"R = 8.314;//[J/mol*-] - Universal gas constant\n", +"Y = 1.4;// Index of expansion\n", +"Cv_0 = R/(Y- 1);//[J/mol-K]\n", +"Cp_0 = R + Cv_0;//[J/mol-K]\n", +"\n", +"//(a)\n", +"// For steam at 20 bar and 250 C, from steam table as reported in the book\n", +"V_1 = 0.11144;//[m^(3)/kg]\n", +"U_1 = 2679.6;//[kJ/kg]\n", +"S_1 = 6.5453;//[kJ/kg-K]\n", +"// P_1*V_1^(n) = P_2*V_2^(n)\n", +"V_2 = ((P_1*V_1^(n))/P_2)^(1/n);//[m^(3)/kg]\n", +"\n", +"// At 2 bar under saturated conditions,from steam table as reported in the book\n", +"V_liq = 0.001061;//[m^(3)/kg]\n", +"V_vap = 0.8857;//[m^(3)/kg]\n", +"x = (V_2 - V_liq)/(V_vap - V_liq);// Dryness fraction\n", +"T_sat = 120.23;//[C] - The final temperature\n", +"U_liq = 504.49;//[kJ/kg] - Internal energy of saturate liquid\n", +"U_vap = 2529.5;//[kJ/kg] - Internal energy of saturate vapour\n", +"// Therefore, internal energy at state 2 is given by\n", +"U_2 = U_liq*(1 - x) + x*U_vap;//[kJ/kg]\n", +"\n", +"// Work transfer is given by\n", +"W = (P_1*V_1 - P_2*V_2)/(n - 1);//[J/kg]\n", +"W = W*10^(-3);//[kJ/kg]\n", +"delta_U = U_2 - U_1;//[kJ/kg]\n", +"\n", +"// From first law, q - W = delta_U\n", +"q = W + delta_U;//[kJ/kg]\n", +"\n", +"// At final state (2 bar saturated), as reported in the book\n", +"S_liq = 1.5301;//[kJ/kg-K] - Entropy of saturated liquid\n", +"S_vap = 7.1271;//[kJ/kg-K] - Entropy of saturated vapour\n", +"// Therefore, entropy at state 2 is given by\n", +"S_2 = S_liq*(1 - x) + x*S_vap;//[kJ/kg-K]\n", +"delta_S = S_2 - S_1;//[kJ/kg-K]\n", +"\n", +"printf(' (a).The final temperature is %f C\n',T_sat);\n", +"printf(' The work done is equal to %f kJ/kg\n',W);\n", +"printf(' The heat change is equal to %f kJ/kg\n',q);\n", +"printf(' The entropy change is equal to %f kJ/kg-K\n\n',delta_S);\n", +"\n", +"//(b)\n", +"// P*V^(n) = constant\n", +"// Since the gas behaves as ideal we can write\n", +"// P_1^(1-n)*T_1^(n) = P_2^(1-n)*T_2^(n)\n", +"T_2 = T_1*(P_1/P_2)^((1-n)/n);//[K]\n", +"\n", +"// Molar volume is given by\n", +"V_2_1 = (R*T_1)/P_1;//[m^(3)/mol] - At state 1\n", +"V_2_2 = (R*T_2)/P_2;//[m^(3)/mol] - At state 2\n", +"\n", +"// Work transfer is given by\n", +"w_2 = ((P_1*V_2_1) - (P_2*V_2_2))/(n-1);//[J/mol]\n", +"Mol_wt_air = 0.21*32 + 0.79*28;//[g/mol] - Molecular weight of air\n", +"n_mole = m/Mol_wt_air;\n", +"// Total work transfer is given by\n", +"W_2 = w_2*n_mole*10^(-3);//[kJ]\n", +"// Internal energy change is given by\n", +"delta_U = n_mole*Cv_0*(T_2 - T_1)*10^(-3);//[kJ]\n", +"\n", +"// Heat transfer is given by\n", +"Q = W_2 + delta_U;//[kJ]\n", +"\n", +"// Entropy change is given by\n", +"delta_S_2 = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);//[J/mol-K]\n", +"delta_S_2 = delta_S_2*n_mole;//[J/mol]\n", +"\n", +"printf(' (b).The final temperature is %f C\n',T_2);\n", +"printf(' The work done is equal to %f kJ/kg\n',W_2);\n", +"printf(' The total heat change is equal to %f kJ\n',Q);\n", +"printf(' The entropy change is equal to %f kJ/kg-K\n\n',delta_S_2);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.6: Calculation_of_final_temperature_and_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.6\n", +"//Page number - 154\n", +"printf('Example - 4.6 and Page number - 154\n\n');\n", +"\n", +"//Given\n", +"m = 1000;//[g] - Mass of fluid\n", +"P_1 = 20;//[bar] - Initial pressure\n", +"P_2 = 2;//[bar] - Final ressure\n", +"T_1 = 250 + 273.15;//[K] - Initial tempearture\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// (a).\n", +"// At 20 bar and 250 C as reported in the book\n", +"V_1 = 0.11144;//[m^(3)/kg] - Specific volume\n", +"U_1 = 2679.6;//[kJ/kg] - Specific internal energy\n", +"S_1 = 6.5453;//[kJ/kg-K] - Specific entropy\n", +"S_2 = S_1;// Isentropic expansion\n", +"\n", +"// At 2 bar under saturated conditions \n", +"S_liq = 1.5301;//[kJ/kg-K]\n", +"S_vap = 7.1271;//[kJ/kg-K]\n", +"U_liq = 504.49;//[kJ/kg-K]\n", +"U_vap = 2529.5;//[kJ/kg-K]\n", +"// Therefore dryness factor can be determined as\n", +"x = (S_1 - S_liq)/(S_vap - S_liq);\n", +"U_2 = U_liq*(1 - x) + x*U_vap;//[kJ/kg] - Specific internal energy at final state\n", +"delta_U = U_2 - U_1;//[kJ/kg] - change in internal energy\n", +"W = - delta_U;// - Work done\n", +"\n", +"// The final saturated temperature at 2 bar from steam table is\n", +"T_2 = 120.23;//[C]\n", +"\n", +"printf(' (a).The final temperature is %f C\n',T_2);\n", +"printf(' The work done is equal to %f kJ/kg\n\n',W);\n", +"\n", +"// (b).\n", +"Y = 1.4;// Index of expansion for air\n", +"Cv_0 = R/(Y-1);//[J/mol*K] - Specific heat capacity at constant volume\n", +"// Ideal gas under isentropic expansion P_1^(1-Y)*T_1^(Y) =P_2^(1-Y)*T_2^(Y)\n", +"T_2_prime = T_1*(P_1/P_2)^((1-Y)/Y);//[K] - Final temperature\n", +"delta_U_prime = Cv_0*(T_2_prime - T_1);//[J/mol] - change in internal energy\n", +"\n", +"// Number of moles is given by\n", +"n = m/28.84;//[mol]\n", +"delta_U_prime = delta_U_prime*n*10^(-3);//[kJ]\n", +"W_prime = - delta_U_prime;// Work done\n", +"\n", +"printf(' (b).The final temperature is %f C\n',T_2_prime);\n", +"printf(' The work done is equal to %f kJ/kg\n',W_prime);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.7: Determination_of_index_of_isentropic_expansion.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.7\n", +"//Page number - 155\n", +"printf('Example - 4.7 and Page number - 155\n\n');\n", +"\n", +"//Given\n", +"P_1 = 15;//[bar] - Initial pressure\n", +"P_2 = 0.15;//[bar] - Final pressure\n", +"\n", +"// We know that during isentropic expansion\n", +"// W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n", +"\n", +"// At 15 bar (saturated vapour), from steam table as reported in the book\n", +"V_1 = 0.13177;//[m^(3)/kg]\n", +"U_1 = 2594.5;//[kJ/kg]\n", +"S_1 = 6.4448;//[kJ/kg-K]\n", +"\n", +"// Now at state 2 (P_2 = 0.15 bar),from steam table as reported in the book\n", +"S_2 = S_1;// Isentropic expansion\n", +"S_liq = 0.7549;//[kJ/kg-K]\n", +"S_vap = 8.0085;//[kJ/kg-K]\n", +"U_liq = 225.92;//[kJ/kg]\n", +"U_vap = 2448.7;//[kJ/kg]\n", +"V_liq = 0.001014;//[m^(3)/kg]\n", +"V_vap = 10.02;//[m^(3)/kg]\n", +"\n", +"// Therefore dryness factor can be calculated as\n", +"x = (S_1 - S_liq)/(S_vap - S_liq);\n", +"U_2 = U_liq*(1 - x) + x*U_vap;//[kJ/kg] - Specific internal energy at final state\n", +"delta_U = U_2 - U_1;//[kJ/kg] - change in internal energy\n", +"W = - delta_U;// - Work done\n", +"\n", +"// The specific volume at the final state is\n", +"V_2 = V_liq*(1 - x) + x*V_vap;//[m^(3)/kg]\n", +"\n", +"// From work done under adiabatic conditions we get\n", +"// W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n", +"Y = (((P_1*V_1) - (P_2*V_2))/W) + 1;\n", +"\n", +"printf(' The index of expansion is given by Y = %f\n',Y);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.8: Determination_of_entropy_production.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.8\n", +"//Page number - 157\n", +"printf('Example - 4.8 and Page number - 157\n\n');\n", +"\n", +"//Given\n", +"P_1 = 40;//[bar] - Initial pressure\n", +"T_1 = 500;//[C] - Initial temperature\n", +"Vel_1 = 140;//[m/s] - Initial velocity\n", +"T_2 = 100;//[C] - Final temperature\n", +"Vel_2 = 80;//[m/s] - Final velocity\n", +"W = 746.0;//[kJ/kg] - Work output\n", +"\n", +"// (a).\n", +"// From steam table as reported in the book\n", +"H_1 = 3445.3;//[kJ/kg]\n", +"H_2 = 2676.1;//[kJ/kg]\n", +"S_1 = 7.0901;//[kJ/kh-K]\n", +"S_2 = 7.3549;//[kJ/kg-K]\n", +"\n", +"// The temperature at which heat exchange take place is given by \n", +"T_b =(T_1 + T_2)/2 + 273.15;//[K]\n", +"\n", +"// From first law in a control volume \n", +"// q - W = delta_H + (delta_V^(2))/2 , therefore\n", +"q = W*10^(3) + (H_2 - H_1)*10^(3) + (Vel_2^(2) - Vel_1^(2))/2;//[J/kg]\n", +"q = q*10^(-3);//[kJ/kg]\n", +"\n", +"S_gen = (S_2 - S_1) - (q/T_b);//[kJ/kg-K]\n", +"\n", +"printf(' (a).The specific entropy production within turbine is %f kJ/kg-K\n',S_gen);\n", +"\n", +"//(b)\n", +"// If control volume is too large to include the turbine and the environment then T_b becomes equal to 289 K. In this case\n", +"T_b_prime = 298;//[K]\n", +"\n", +"// The entropy change of the sysytem is given by \n", +"//delta_S = q/T_b + S_gen\n", +"S_gen = (S_2 - S_1) - (q/T_b_prime);//[kJ/kg-K]\n", +"\n", +"printf(' (b).The specific entropy production within turbine is %f kJ/kg-K',S_gen);\n", +"\n", +"// In the first part only irreversibilities within the turbine are evaluated\n", +"// whereas in part (2) irreversible heat transfer between the turbine cover and environment are also included.\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.9: Determination_of_work_required_and_exit_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 4.9\n", +"//Page number - 160\n", +"printf('Example - 4.9 and Page number - 160\n\n');\n", +"\n", +"//Given\n", +"P_1 = 1;//[MPa] - Initial pressure\n", +"T_1 = 200 + 273.15;//[K] - Initial temperature\n", +"P_2 = 8;//[MPa] - Final pressure\n", +"Y = 1.4;// Index of expansion of gas\n", +"R = 8.314;//[J/mol-K] - Universal gas constant\n", +"\n", +"//(1)\n", +"// The exit temperature for ideal gas under isentropic conditions is given by \n", +"T_2 = T_1*((P_2/P_1)^((Y-1)/Y));//[K] - Exit temperature\n", +"Cp_0 = Y*R/(Y-1);//[J/mol-K] - Specific heat capacity at constant pressure\n", +"// For isentropic conditions the enthalpy change for ideal gas is given by\n", +"delta_H_s = Cp_0*(T_2 - T_1);//[J/mol]\n", +"// Therefore work is given by\n", +"W = - delta_H_s;//[J/mol]\n", +"\n", +"printf(' (1).The exit temperature of steam is %f K\n',T_2);\n", +"printf(' The required work is %f J/mol\n\n',W);\n", +"\n", +"//(2)\n", +"eff = 0.8;// Adiabatic efficiency\n", +"// delta_H_s/delta_H_a = 0.8\n", +"delta_H_a = delta_H_s/eff;//[J/mol] - Actual enthalpy change\n", +"W_a = - delta_H_a;//[J/mol]\n", +"\n", +"// The ideal gas enthalpy is a function only of temperature,therefore actual exit temperature T_2a is given by \n", +"// delta_H_a = Cp_0*(T_2a - T_1)\n", +"T_2a = (delta_H_a/Cp_0) + T_1;\n", +"\n", +"printf(' (2).The exit temperature of steam is %f K\n',T_2a);\n", +"printf(' The required work is %f J/mol\n\n',W_a);\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/5-Exergy.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/5-Exergy.ipynb new file mode 100644 index 0000000..5ecb5d3 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/5-Exergy.ipynb @@ -0,0 +1,704 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5: Exergy" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.1: Determination_of_fraction_of_the_availability_loss.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.1\n", +"//Page number - 184\n", +"printf('Example - 5.1 and Page number - 184\n\n');\n", +"\n", +"\n", +"//Given\n", +"T_1 = 500+273.15;//[C] - Condensation temperature\n", +"T_2 = 250+273.15;//[C] - Temperature at which vaporization takes place.\n", +"\n", +"T_3 = 25+273.15;//[C] - Ambient atmospheric temperature.\n", +"\n", +"Q = 1;//We are taking a fictitious value of Q, its value is not given.But we need to initialize it wid some value,so we are taking its value as Q=1.\n", +"\n", +"//The exergy content of the vapour at 500 C,\n", +"Ex_T_1 = Q*(1-(T_3/T_1));\n", +"Ex_T_2 = Q*(1-(T_3/T_2));\n", +"//Therefore,loss in exergy is given by\n", +"Ex_loss = Ex_T_1 - Ex_T_2;\n", +"//Fraction of exergy lost due to irreversible process is,\n", +"Ex_fraction =(Ex_loss/Ex_T_1);\n", +"printf(' The fraction of exergy lost due to irreversible process is %f',Ex_fraction);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.2: Determination_of_availability_change_and_irreversibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.2\n", +"//Page number - 188\n", +"printf('Example - 5.2 and Page number - 188\n\n');\n", +"\n", +"//Given\n", +"T_1 = 300;//[K] - Initial temperature.\n", +"P_1 = 100;//[kPa] - Initial pressure.\n", +"T_2 = 500;//[K] - Final temperature.\n", +"T_0 = 300;//[K] - Environment temperature.\n", +"P_0 = 1;//[atm] - Environment pressure.\n", +"R = 8.314;//[J/mol*K]\n", +"//(Cp_0/R)= 3.626\n", +"Cp_0 = 3.626*R;//[J/mol-K] - Heat capacity at constant pressure\n", +"\n", +"\n", +"//(1).\n", +"//The availability change is given by, (phi_1 - phi_2) = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2)\n", +"//Let us determine the change in internal energy\n", +"//For ideal gas the molar internal energy change is given by delta_U = Cv_0*(T_2-T_1)\n", +"//For ideal gas Cp_0 - Cv_0 = R, and therefore\n", +"Cv_0 = ((Cp_0/R)- 1)*R;//[J/mol-K] - Heat capacity at constant volume\n", +"delta_U = Cv_0*(T_2-T_1);//[J/mol]\n", +"//delta_U = -w (from energy balance). Therefore, U1-U2 = -delta_U.\n", +"//The entropy change of ideal gas is given by\n", +"//delta_S = Cp_0*log(T_2/T_1) - R*log(P_2/P_1), but,(P1*V1/T1) = (P1*V1/T1) and therefore (P2/P1) = (T2/T1)\n", +"delta_S = Cp_0*log(T_2/T_1) - R*log(T_2/T_1);//[J/mol-K]\n", +"//The exergy change is given by, (phi_1 - phi_2) = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2)\n", +"//(V_1 - V_2) = 0, because the tank is rigid and so the volume is constant\n", +"delta_phi = (-delta_U) - T_0*(-delta_S);//[J/mol]\n", +"printf(' (1).The change in exergy is %f J/mol\n\n',delta_phi);\n", +"\n", +"//(2).\n", +"//Entropy change of the system is given by, delta_S_sys = q/T_b + S_gen\n", +"//Since the system is adiabatic therefore, delta_S_sys = S_gen\n", +"S_gen = delta_S;\n", +"//Irreversibility is given by\n", +"i = T_0*S_gen;//[J/mol]\n", +"printf(' (2).The value of irreversibility is %f J/mol',i);\n", +"//Irreversibility can also be determined using\n", +"//i = (W_rev_use - W_use)\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.3: Determination_of_availability_change_and_irreversibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.3\n", +"//Page number - 190\n", +"printf('Example - 5.3 and Page number - 190\n\n')\n", +"\n", +"//Given\n", +"P_1 = 15;//[bar] - Initial pressure\n", +"P_1 = P_1*10^(5);//[Pa]\n", +"T_1 = 300+273.15;//[K] - Initial temperature\n", +"T_0 = 298.15;//[K]\n", +"T_R = 1200;//[K] - Reservoir temerature.\n", +"P_0 = 1;//[bar]\n", +"P_0 = P_0*10^(5);//[Pa]\n", +"n = 1;//[mol] - No of moles\n", +"R = 8.314;//[J/mol*K]\n", +"Y = 1.4;// - Ratio of heat capacities.\n", +"Cv_0 = R/(Y-1);//[J/mol-K] - Heat capacity at constant volume\n", +"Cp_0 = Cv_0 + R;//[J/mol-K] - Heat capacity at constant pressure\n", +"\n", +"//(1)\n", +"//V_2 = 2*V_1 and since pressure is constant,we get (V_1/T_1) = (2*V_1/T_1), or, T_2 = 2*T_1.\n", +"T_2 = 2*T_1;//[K]\n", +"W = P_1*(((R*T_2)/P_1)-((R*T_1)/P_1));//[J/mol] - Actual work done\n", +"delta_U = Cv_0*(T_2-T_1);//[J/mol] - Change in internal energy.\n", +"q = W + delta_U;//[J/mol] - Heat change\n", +"//Now the availability change is given by, (phi_1 - phi_2) = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2) + q*(1-(T_0/T_R))\n", +"//delta_S = Cp_0*log(T_2/T_1) - R*log(P_2/P_1), and P_1 = P_2, Therefore\n", +"delta_S = Cp_0*log(T_2/T_1);;//[J/mol-K] - Entropy change.\n", +"//Substituting expressions for delta_phi calculation. Decrease in availability is given by,\n", +"delta_phi = (-delta_U) + P_0*(((R*T_1)/P_1)-((R*T_2)/P_1)) - T_0*(-delta_S) + q*(1-(T_0/T_R));//[J/mol]\n", +"//Actual work done is given by, W = P_1*(V2-V1)\n", +"//Work done to displace the atmosphere is given by, W = P_0*(V_2-V_1)\n", +"//Therefore, W_use = (P_1*(V2-V1) - P_0*(V2-V1))\n", +"W_use = (P_1-P_0)*(((R*T_2)/P_1)-((R*T_1)/P_1));//[J/mol] - useful work done\n", +"W_rev_use = delta_phi;// reversible useful work done\n", +"//Irreversibility is given by,\n", +"i = W_rev_use - W_use;//[J/mol]\n", +"printf(' (a).The ireversibility value is %f J/mol\n\n',i);\n", +"\n", +"//The irreversibility can also be calculated using \n", +"// i = T_0*S_gen\n", +"//S_gen = delta_S - (q/T_R)\n", +"\n", +"//(b)\n", +"//V2 = 2*V_1 and therefore T_2 = 2*T_1, as P_2 = P_1\n", +"//Actual work done is same as before\n", +"//Let work done on stirrer be W_stir. Thus net work done by the system is W - W_stir.Fron energy balance we get,\n", +"W_stir = W + delta_U;\n", +"//Initially the exergy is due to that of the system at state 1 and stirrer work,'W_stir' and finally we have the exergy due to system at state 2,the stirrer work is spent,thus availability is given by\n", +"delta_phi_b = (-delta_U) + P_0*(((R*T_1)/P_1)-((R*T_2)/P_1)) - T_0*(-delta_S) + W_stir;//[J/mol]\n", +"W_rev_use_b = delta_phi_b;// reversible useful work done\n", +"W_use_b = W_use;// useful work done\n", +"//Now the irreversibility is given by,\n", +"i_b = W_rev_use_b - W_use_b;//[J/mol]\n", +"printf(' (b).The ireversibility value is %f J/mol\n\n',i_b);\n", +"\n", +"//The irreversibility can also be calculated using \n", +"// i_b = T_0*S_gen\n", +"//S_gen = delta_S - (q/T_R) and here, q = 0\n", +"\n", +"//(c)\n", +"P_2_c = 10;//[bar] - Final pressure, (Given)\n", +"P_2_c = P_2_c*10^(5);//[Pa]\n", +"//(P_1^(1-Y))*(T_1^(Y)) = (P_2^(1-Y))*(T_2^(Y))\n", +"T_2_c = T_1*((P_1/P_2_c)^((1-Y)/Y));//[K]\n", +"//Work done is given by, W = -delta_U = -Cv_0*(T_2_c - T_1)\n", +"W_c = -Cv_0*(T_2_c - T_1);//[J/mol]\n", +"//The final molar volume is calculated using P_1*V_1^(Y) = P_2*V_2^(Y)\n", +"//V_2 = V_1*((P_1/P_2_c)^(1/Y))\n", +"V_1 = (R*T_1)/P_1;//[cubic metre/mol] - Initial molar volume\n", +"V_2 = V_1*((P_1/P_2_c)^(1/Y));//[cubic metre/mol] - Final molar volume\n", +"//Now let us determine the work done to displace the atmosphere,\n", +"W_atm_c = P_0*(V_2 - V_1);//[J/mol] - work done to displace the atmosphere\n", +"//Thus useful work is given by,\n", +"W_use_c = W - W_atm_c;//[J/mol] - useful work done\n", +"//Here delta_S = 0,for reversible adiabatic process.Therefore,\n", +"W_rev_use_c = W_use_c;\n", +"//Now finally the irreversibility is given by,\n", +"i_c = W_rev_use_c - W_use_c;//[J/mol]\n", +"printf(' (c).The ireversibility value is %f J/mol\n\n',i_c);\n", +"\n", +"//(d)\n", +"//Here temperature is constant,but V_2 = 2*V_1, therefore P_2 = P_1/2\n", +"V_2_d = 2*V_1;\n", +"P_2_d = P_1/2;\n", +"//Under isothermal conditions work done is\n", +"W_d = R*T_1*log(V_2_d/V_1);//[J/mol]\n", +"//Work done to displace the atmosphere is given by,\n", +"W_atm_d = P_0*(V_2_d - V_1);//[J/mol] - work done to displace the atmosphere\n", +"//Thus useful work is given by,\n", +"W_use_d = W_d - W_atm_d;//[J/mol] - useful work done\n", +"delta_U_d = 0;//isothermal conditions\n", +"q_d = W_d;// since, delta_U_d = 0\n", +"//delta_S_d = Cp_0*log(T_2/T_1) - R*log(P_2/P_1), and T_1 = T_2, Therefore\n", +"delta_S_d = -R*log(P_2_d/P_1);//[J/mol-K] - Entropy change\n", +"//The reversible useful work is given by,\n", +"W_rev_use_d = P_0*(V_1 - V_2_d) - T_0*(-delta_S_d) + q_d*(1-(T_0/T_R));//[J/mol] - Reversible useful work done.\n", +"//The irreversibility is given by,\n", +"i_d = W_rev_use_d - W_use_d;//[J/mol]\n", +"printf(' (d).The ireversibility value is %f J/mol\n\n',i_d);\n", +"\n", +"//(e)\n", +"P_2_e = 10;//[bar] - Final pressure, (Given)\n", +"P_2_e = P_2_e*10^(5);//[Pa]\n", +"//During the expansion of an ideal gas in into vacuum the temperature of the gas remains the same,\n", +"T_2_e = T_1;// Final temperature\n", +"//Since boundary of the system is fixed so no net work is done, W = 0 and thus\n", +"W_use_e = 0;//[J/mol] - Useful work done\n", +"//Here, delta_U = 0,as temperature is same and\n", +"//(V_1-V_2) = 0,as for overall system there is no change in volume\n", +"delta_S_e = - R*log(P_2_e/P_1);//[J/mol-K] - Entropy change\n", +"//The reversible useful work is given by,\n", +"W_rev_use_e = - T_0*(-delta_S_e);//[J/mol] - Reversible useful work done.\n", +"//The irreversibility is given by,\n", +"i_e = W_rev_use_e - W_use_e;//[J/mol]\n", +"printf(' (e).The ireversibility value is %f J/mol\n\n',i_e);\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.4: Determination_of_useful_work_and_irreversibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.4\n", +"//Page number - 194\n", +"printf('Example - 5.4 and Page number - 194\n\n')\n", +"\n", +"\n", +"//Given\n", +"T_1 = 150+273.15;//[K] - Initial temperature.\n", +"m = 4.6;//[kg] - mass of water\n", +"P_1 = 1;//[MPa] - Initial pressure\n", +"Q = 11000;//[kJ] - Heat transferred to the system.\n", +"T_R = 600+273.15;//[K] - Temperature of the reservior.\n", +"T_0 = 298;//[K] - Temperature of the environment\n", +"P_0 = 100;//[kPa] - Pressure of the environment\n", +"\n", +"//(1)\n", +"//The entropy change of an isothermal system undergoing an internally reversible process is given by,\n", +"delta_S_t = (Q/T_1);//[kJ] - Entropy change\n", +"delta_S = delta_S_t/m;//[kJ/kg-K] - \n", +"\n", +"//At 150 C,it has been reported in the book that, P_sat - 0.4758 kPa, V_liq = 0.001091 m^(3)/kg, U_liq = 631.68 kJ/kg, S_liq = 1.8418 kJ/kg-K, S_vap = 6.8379 kJ/kg-K\n", +"V_1 = 0.001091;//[m^(3)/kg] - initial specific volume\n", +"U_1 = 631.68;//[kJ/kg] - initial specific internal energy\n", +"S_1 = 1.8418;//[kJ/kg-K] - initial entropy\n", +"//The initial state of the water is a compressed liquid state,and S_1 is therefore equal to the entropy of the saturated liquid of the saturated liquid at the same temperature.\n", +"S_2 = S_1 + delta_S;//[kJ/kg-K] - Final entropy\n", +"\n", +"//At the final state the temperature is 150 C and S = 7.499 kJ/kg-K which is more than S_vap therefore it is superheated steam.\n", +"S_final = 7.494;//[kJ/kg-K]\n", +"//At 150 C, and 0.1 MPa: V = 1.9364 m^(3)/kg, U = 2582.8 kJ/kg, S = 7.6134 kJ/kg-K\n", +"//At 150 C, and 0.2 MPa: V = 0.9596 m^(3)/kg, U = 2576.9 kJ/kg, S = 7.2795 kJ/kg-K\n", +"U_t_1 = 2582.8;//[kJ/kg] - Internal energy\n", +"U_t_2 = 2576.9;//[kJ/kg]\n", +"V_t_1 = 1.9364;//[m^(3)/kg] - Specific volume\n", +"V_t_2 = 0.9596;//[m^(3)/kg]\n", +"S_t_1 = 7.6134;//[kJ/kg-K] - Entropy\n", +"S_t_2 = 7.2795;//[kJ/kg-K]\n", +"//The pressure at exit is given by,\n", +"P_2 = ((S_final - S_t_1)/(S_t_2 - S_t_1))*(0.2 - 0.1) + 0.1;//[Mpa] - Final pressure\n", +"//At final state\n", +"U_2 = U_t_1 + (U_t_2 - U_t_1)*((S_final - S_t_1)/(S_t_2 - S_t_1));//[kJ/kg] - Final specific internal energy\n", +"V_2 = V_t_1 + (V_t_2 - V_t_1)*((S_final - S_t_1)/(S_t_2 - S_t_1));//[m^(3)/kg] - Final specific volume\n", +"\n", +"q = Q/m;//[kJ/kg] - Heat supplied per unit kg of mass.\n", +"W_rev_use = U_1 - U_2 + P_0*(V_1 - V_2) - T_0*(S_1 - S_2) + q*(1 - (T_0/T_R));//[kJ/kg] - Reversible useful work done.\n", +"\n", +"//Now let us calculate the actual work done. We know q - W = delta_U, therefore\n", +"W = q - (U_2 - U_1);//[kJ/kg] - Work done\n", +"W_use = W - P_0*(V_2 - V_1);//[kJ/kg]\n", +"i = W_rev_use - W_use;//[kJ/kg] - Irreversibility\n", +"//Since the system contains 4.6 g therefore, \n", +"W_use_new = W_use*m;//[kJ]\n", +"W_rev_use_new = W_rev_use*m;//[kJ]\n", +"I = W_rev_use_new - W_use_new;//[kJ]\n", +"\n", +"printf(' (1).The useful work obtained is %f kJ\n\n',W_use_new);\n", +"printf(' (2).The reversible usefuk work done is %f kJ\n\n',W_rev_use_new);\n", +"printf(' (3).The irreversibility is %f kJ\n\n',I);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.5: Determination_of_reversible_work_and_irreversibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.5\n", +"//Page number - 197\n", +"printf('Example - 5.5 and Page number - 197\n\n')\n", +"\n", +"//Given\n", +"T_1 = 700+273.15;//[K] - Initial temperature.\n", +"P_1 = 12;//[MPa] - Initial pressure\n", +"P_2 = 0.6;//[MPa] - Final pressure\n", +"//At 12 MPa and 700 C,\n", +"H_1 = 3858.4;//[kJ/kg] - initial enthalpy\n", +"S_1 = 7.0757;//[kJ/kg-K] - initial entropy\n", +"\n", +"//At 0.6 MPa and 200 C,\n", +"H_2 = 2850.1;//[kJ/kg]\n", +"S_2 = 6.9673;//[kJ/kg-K]\n", +"\n", +"//At 0.6 MPa and 250 C,\n", +"H_3 = 2957.2;//[kJ/kg]\n", +"S_3 = 7.1824;//[kJ/kg-K]\n", +"\n", +"//At 0.6 MPa and 300 C,\n", +"H_4 = 3061.6;//[kJ/kg]\n", +"S_4 = 7.3732;//[kJ/kg-K]\n", +"\n", +"//(1)\n", +"//In the case of ideal turbine the entropy change does not take place,therefore the exit conditions are\n", +"P_exit = P_2;//[MPa] - exit pressure\n", +"T_exit = ((S_1 - S_2)/(S_3 - S_2))*(250 - 200) + 200;//[C] - exit temperature\n", +"H_exit = ((S_1 - S_2)/(S_3 - S_2))*(H_3 - H_2) + H_2;//[kJ/kg] - exit enthalpy\n", +"\n", +"//Snce it is a flow pocess,therfore\n", +"//W_rev = H_1 - H_exit - T_0*(S_1 - S_2)\n", +"//As S_1 = S_2,the above equation becomes\n", +"W_rev_1 = H_1 - H_exit;//[kJ/kg] - reversible work done\n", +"\n", +"//From the first law the actual work done can be calculated using, delta_H = q - W\n", +"//Since the turbine does not exchange heat,therefore W = - delta_H.\n", +"W_1 = - (H_exit - H_1);//[kJ/kg]\n", +"\n", +"printf(' (1).The reversible work done is %f kJ/kg\n',W_1);\n", +"printf(' And since the maximum work is same as the actual work,therefore irreversibility is zero\n\n');\n", +"\n", +"//(2)\n", +"//Given\n", +"T_0 = 298.15;//[K] - Environment temperature\n", +"P_0 = 1;//[atm] - Environment pressure\n", +"adi_eff = 0.88;//adiabatc efficiency\n", +"\n", +"//(H_1 - H_exit_actual)/(H_1 - H_exit) = 0.88, therefore\n", +"H_exit_actual = H_1 - 0.88*(H_1 - H_exit);// - Actual exit enthalpy\n", +"\n", +"//Now two properties i.e pressure = 0.6 MPa and enthalpy = H_exit_actual is fixed at the exit. The exit temperature is given by,\n", +"T_exit_actual = ((H_exit_actual - H_3)/(H_4 - H_3))*(300 - 250) + 250;//[C]\n", +"S_exit_actual = ((H_exit_actual - H_3)/(H_4 - H_3))*(S_4 - S_3) + S_3;//[kJ/kg]\n", +"\n", +"//Now reversible work done is given by,\n", +"W_rev_2 = H_1 - H_exit_actual - T_0*(S_1 - S_exit_actual);//[kJ/kg]\n", +"printf(' (2).The reversible work done is %f kJ/kg\n',W_rev_2);\n", +"\n", +"//The actual work is given by the first law,\n", +"W_2 = H_1 - H_exit_actual;//[kJ/kg] - Actual work done\n", +"i = W_rev_2 - W_2;//[kJ/kg] - irreversibility\n", +"printf(' The value of irreversibility is %f kJ/kg\n',i);\n", +"\n", +"//The irreversibility can also be determined using\n", +"// i = T_0*S_gen, and S_gen is given by\n", +"// S_gen = (q/T_R) - delta_S\n", +"\n", +"//The second law efficiency of the turbine is actual work done divided by reversible work,therefore\n", +"sec_eff = W_2/W_rev_2;\n", +"printf(' The second law efficiency of the turbine is %f\n',sec_eff);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.6: Determination_of_maximum_obtainable_work_and_efficiency.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.6\n", +"//Page number - 198\n", +"printf('Example - 5.6 and Page number - 198\n\n')\n", +"\n", +"//Given\n", +"P_1 = 8;//[bar] - Initial pressure\n", +"T_1 = 93 + 273.15;//[C] - Initial temperature\n", +"V_1 = 100;//[m/s] - Initial velocity\n", +"P_2 = 1.25;//[bar] - Exit pressure\n", +"T_2 = 27 + 273.15;//[C] - Exit temperature\n", +"V_2 = 60;//[m/s] - Exit velocity \n", +"Y = 1.4;//Ratio of specific heat capacities\n", +"T_0 = 298.15;//[K] - surrounding temperature\n", +"P_0 = 1;//[bar] - surrounding pressure\n", +"R = 8.314;//[J/mol*K] - Gas constant\n", +"Cp_0 = (R*Y)/(Y-1);//[J/mol-K] - Heat capacity at constant pressure\n", +"\n", +"//Since the amount of heat transfer is negligible,therefore from first law the actual work done is given by,\n", +"//W = delta_H + (delta_V_square)/2\n", +"delta_H = Cp_0*(T_2 - T_1);//[J/mol] - enthalpy change\n", +"delta_H = (delta_H/28.84);//[kJ/kg] - (1 mole = 28.84 g).\n", +"delta_V_square = V_2^(2) - V_1^(2);\n", +"\n", +"W = - delta_H - ((delta_V_square)/2)/1000;//[kJ/kg] - Actual work done\n", +"printf(' The actual work done is %f kJ/kg\n\n',W);\n", +"\n", +"//Now let us calculate the maximum work that can be obtained\n", +"//W_rev = (H_1 + (V_1^(2))/2) - (H_2 + (V_2^(2))/2) - T_0*(S_1 - S_2)\n", +"delta_S = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);//[J/mol-K] - Entropy change\n", +"delta_S = delta_S/28.84;//kJ/kg-K]\n", +"W_rev = -delta_H - ((delta_V_square/2)/1000) + T_0*delta_S;//[kJ/kg]\n", +"printf(' The maximum work obtainable per kg of air is %f kJ/kg\n\n',W_rev);\n", +"\n", +"//The second law efficiency of the turbine is actual work done divided by reversible work,therefore\n", +"sec_eff = W/W_rev;\n", +"printf(' The second law efficiency of the turbine is %f\n\n',sec_eff);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.7: Determination_of_entropy_generation_rate_and_irreversibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.7\n", +"//Page number - 200\n", +"printf('Example - 5.7 and Page number - 200\n\n')\n", +"\n", +"//Given\n", +"m_cold_water = 60;//[kg/s] - mass flow rate of cold water\n", +"P_1 = 50;//[kPa]\n", +"T_2 = 250;//[C]\n", +"T_water_1 = 1000 + 273.15;//[K] - Entering temperature of water\n", +"T_water_2 = 450 +273.15;//[K] - Exit temperature of water\n", +"T_0 = 298.15;//[K] - surrounding temperature\n", +"P_0 = 1;//[atm] - surrounding pressure\n", +"Cp_0 = 1.005;//[kJ/kg-K]\n", +"\n", +"//For water at 50 kPa under saturated conditions,T_sat = 81.33 C, \n", +"H_liq_1 = 340.49;//[kJ/kg] - Enthalpy\n", +"S_liq_1 = 1.0910;//[kJ/kg-K] - Entropy\n", +"\n", +"//For steam at 50 kPa and 250 C,\n", +"H_2 = 2976.0;//[kJ/kg]\n", +"S_2 = 8.3556;//[kJ/kg-K]\n", +"\n", +"//The cold stream is water which enters as saturated liquid at 50 kPa and exits as superheated vapour at 50 kPa and 250 C,since pressure drop is neglected.\n", +"//The mass flow rate of hot stream can be obtained from energy balance\n", +"m_hot_water = (m_cold_water*(H_2 - H_liq_1))/(Cp_0*(T_water_1 - T_water_2));//[kg/s] - mass flow rate of hot water\n", +"\n", +"//Since there is no heat exchange with the surrounding therefore the total entropy generation is given by\n", +"//S_gen = delta_S_hot + delta_S_cold\n", +"delta_S_cold = S_2 - S_liq_1;//[kJ/kg-K] - change of entropy of cold water\n", +"//delta_S_hot = Cp_0*log(T_2/T_1)-R*log(P_2/P_1), But pressure drop is zero,therfore\n", +"delta_S_hot = Cp_0*log(T_water_2/T_water_1);//[kJ/kg-K] - change of entropy of hot water\n", +"\n", +"S_gen = m_cold_water*delta_S_cold + m_hot_water*delta_S_hot;//[kW/K] - Entropy generated\n", +"printf(' The entropy generation rate is %f kW/K\n\n',S_gen);\n", +"\n", +"//The irreversibility rete is given by\n", +"I = T_0*S_gen;//[kW]\n", +"printf(' The irreversibility rate of the heat exchanger is %f kW\n',I);\n", +"\n", +"//The irreversibility can also be determined using the exergy approach\n", +"//We know that, I = W_rev - , but since actual work done zero in heat exchangers,therefore I = W_rev = exergy change\n", +"//(si_1 - si_2)_cold = H_1 - H_2 - T_0*(S_1 - S_2)\n", +"//(si_1 - si_2)_hot = Cp_0*(T_1 - T_2)- T_0*(S_1 - S_2)\n", +"// I = (si_1 - si_2)_cold - (si_1 - si_2)_hot.\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.8: Calculation_of_exit_temperature_entropy_and_irreversibility_rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.8\n", +"//Page number - 201\n", +"printf('Example - 5.8 and Page number - 201\n\n')\n", +"\n", +"//Given\n", +"m_water = 10000;//[kg/h] - Mass flow rate of cold water\n", +"m_water = m_water/3600;//[kg/s]\n", +"T_1_water = 30 + 273.15;//[K] - Cold water entering temperature\n", +"m_HC = 5000;//[kg/h] - mass flow rate of hot hydrocarbon\n", +"m_HC = m_HC/3600;//[kg/s]\n", +"T_1_HC = 200 + 273.15;//[K] - Hot hydrocarbon entering temperature\n", +"T_2_HC = 100 + 273.15;//[K] - Hot hydrocarbon leaving temperature\n", +"Cp_0_water = 1.0;//[kcal/kg-K] - Mean heat capacity of cooling water\n", +"Cp_0_HC = 0.6;//[kcal/kg-K] - Mean heat capacity of hydrocarbon\n", +"\n", +"//(1)\n", +"//Applying energy balance to the heat exchanger,we get\n", +"//m_water*Cp_0_water*(T - T_1_water) = m_HC*Cp_0_HC*(T_1_HC - T_2_HC)\n", +"T_2_water = ((m_HC*Cp_0_HC*(T_1_HC - T_2_HC))/(m_water*Cp_0_water)) + T_1_water;//[K]\n", +"T_2 = T_2_water - 273.15;//[C]\n", +"printf(' (1).The exit temperature of the cooling water is %f C\n\n',T_2);\n", +"\n", +"//(2)\n", +"//delta_S_hot_HC = Cp_0*log(T_2/T_1)-R*log(P_2/P_1), But pressure drop is zero,therfore\n", +"delta_S_hot_HC = (Cp_0_HC*4.184)*log(T_2_HC/T_1_HC);//[kW/K] - change of entropy of hot hydrocarbon\n", +"delta_S_HC = m_HC*delta_S_hot_HC;//[kW/K] - Entropy change for hudrocarbon liquid \n", +"printf(' (2).Entropy change rate of hydrocarbon liquid is %f kW/K\n',delta_S_HC);\n", +"\n", +"delta_S_cold_water = (Cp_0_water*4.184)*log(T_2_water/T_1_water);//[kW/K] - change of entropy of cooling water\n", +"delta_S_water = m_water*delta_S_cold_water;//[kW/K] - Entropy change for water\n", +"printf(' And entropy change rate of water is %f kW/K\n\n',delta_S_water);\n", +"\n", +"//(3)\n", +"T_0 = 298.15;//[K] - Surrounding temperature\n", +"//S_gen = delta_S_cold_water + delta_S_hot_HC = m_water*delta_S_cold_water + m_HC*delta_S_hot_HC;//[kW/K] - Entropy generated\n", +"S_gen = delta_S_water + delta_S_HC;//[kW/K]\n", +"I = T_0*S_gen;//[kW]\n", +"printf(' (3).The irreversibility rate of the heat exchanger is %f kW\n',I);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.9: Determinatio_of_exit_temperature_availability_change_and_irreversibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 5.9\n", +"//Page number - 202\n", +"printf('Example - 5.9 and Page number - 202\n\n');\n", +"\n", +"//Given\n", +"T_1_hotgas = 800;//[K]\n", +"P_1_hotgas = 1;//[bar]\n", +"T_2_hotgas = 700;//[K]\n", +"P_2_hotgas = 1;//[bar]\n", +"T_1_air = 470;//[K]\n", +"P_1_air = 1;//[bar]\n", +"P_2_air = 1;//[bar]\n", +"Cp_0_hotgas = 1.08;//[kJ/kg-K] - Mean heat capacity of hot gas\n", +"Cp_0_air = 1.05;//[kcal/kg-K] - Mean heat capacity of air\n", +"T_0 = 298.15;//[K] - surrounding temperature\n", +"P_0 = 1;//[bar] - surrounding pressure\n", +"//m_air = 2*m_hotgas\n", +"\n", +"//(1)\n", +"//Assuming heat exchange only takes places in-between the streams,from energy balance we get,\n", +"//m_gas*Cp_0_hotgas*(T_2_hotgas - T_1_hotgas) + 2*m_gas*Cp_0_air*(T - T_1_air), \n", +"T_2_air = T_1_air - ((Cp_0_hotgas*(T_2_hotgas - T_1_hotgas))/(2*Cp_0_air));//[K] - Temp of emerging air\n", +"printf(' (1).The temperature of emerging air is %f K\n\n',T_2_air);\n", +"\n", +"//(2)\n", +"//Availability change of hot gas is given by,\n", +"//(si_1 - si_2)_hot = H_1 - H_2 - T_0*(S_1 - S_2)\n", +"delta_H_hotgas = (Cp_0_hotgas*(T_2_hotgas - T_1_hotgas));//[kJ/kg] - change in enthalpy of hotgas\n", +"//delta_S_hotgas = Cp_0_hotgas*log(T_2_hotgas/T_1_hotgas)- R*log(P_2/P_1), But pressure drop is zero (P_1 = P_2),therfore\n", +"delta_S_hotgas = Cp_0_hotgas*log(T_2_hotgas/T_1_hotgas);//[kJ/kg-K] - change of entropy of hot gas\n", +"delta_si_hotgas = (-delta_H_hotgas) - (-T_0*delta_S_hotgas);//[kJ/kg]\n", +"printf(' (2).The availability change of hot gas is %f kJ/kg\n\n',delta_si_hotgas);\n", +"\n", +"//(3)\n", +"//Availability change of air is given by,\n", +"//(si_1 - si_2)_air = H_1 - H_2 - T_0*(S_1 - S_2)\n", +"delta_H_air = (Cp_0_air*(T_2_air - T_1_air));//[kJ/kg] - change in enthalpy of air\n", +"//delta_S_air = Cp_0_air*log(T_2_air/T_1_air)- R*log(P_2/P_1), But pressure drop is zero (P_1 = P_2),therfore\n", +"delta_S_air = Cp_0_air*log(T_2_air/T_1_air);//[kJ/kg-K] - change of entropy of air\n", +"delta_si_air = (-delta_H_air) - (-T_0*delta_S_air);//[kJ/kg]\n", +"printf(' (3).The availability change of air is %f kJ/kg\n\n',delta_si_air);\n", +"\n", +"//(4)\n", +"//For the heat exchanger (Q = 0, W = 0)\n", +"//Basis : 1 kg of hot gas flowing through heat exchanger\n", +"S_gen = delta_S_hotgas + 2*delta_S_air;//[kJ/kg-K] - (as m_air = 2*m_hotgas)\n", +"I = T_0*S_gen;//[kJ/kg]\n", +"printf(' (4).The irreversibility of thr exchanger per kg of hot gas flowing is %f kJ/kg\n',I);\n", +"\n", +"//Irreversibility can also be obtained using\n", +"//I = 2*(si_1 - si_2)_air + (si_1 - si_2)_hotgas\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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/6-Chemical_reactions.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/6-Chemical_reactions.ipynb new file mode 100644 index 0000000..f452ee9 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/6-Chemical_reactions.ipynb @@ -0,0 +1,720 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 6: Chemical reactions" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.10: Determination_of_standard_enthalpy_change_and_Gibbs_free_energy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.10\n", +"//Page number - 228\n", +"printf('Example - 6.10 and Page number - 228\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 1042;//[K] - Reaction temperature\n", +"\n", +"//At 298.15 K\n", +"delta_H_CaCO3_for_298 = -289.5*10^(3);//[cal/mol] - Enthalpy of formation of CaCO3 at 298.15 K\n", +"delta_H_CaO_for_298 = -151.7*10^(3);//[cal/mol] - Enthalpy of formation of CaO at 298.15 K\n", +"delta_H_CO2_for_298 = -94.052*10^(3);//[cal/mol] - Enthalpy of formation of CO2 at 298.15 K\n", +"delta_G_CaCO3_for_298 = -270.8*10^(3);//[cal/mol] - Gibbs free energy change for formation of CaCO3 at 298.15 K\n", +"delta_G_CaO_for_298 = -144.3*10^(3);//[cal/mol] - Gibbs free energy change for formation of CaO at 298.15 K\n", +"delta_G_CO2_for_298 = -94.260*10^(3);//[cal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n", +"\n", +"///Standaerd heat capacity data in cal/mol-K are given below, T is in K\n", +"//Cp_0_CO2 = 5.316 + 1.4285*10^(-2)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3)\n", +"//Cp_0_CaO = 12.129 + 0.88*10^(-3)*T + 2.08*10^(5)*T^(-2)\n", +"//Cp_0_CaCO3 = 24.98 + 5.240*10^(-3)*T + 6.199*10^(5)*T^(-2)\n", +"\n", +"//Therefore standard heat capacity of reaction is given by,\n", +"//Cp_0_rkn = Cp_0_CO2 + Cp_0_CaO - Cp_0_CaCO3\n", +"//On simplification,we get the relation\n", +"//Cp_0_rkn = -7.535 + 9.925*10^(-3)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3) + 4.119*10^(5)*T^(-2)\n", +"\n", +"delta_H_rkn_298 = delta_H_CaO_for_298 + delta_H_CO2_for_298 - delta_H_CaCO3_for_298;//[cal] - Enthalpy of reaction at 298.15 K\n", +"delta_G_rkn_298 = delta_G_CaO_for_298 + delta_G_CO2_for_298 - delta_G_CaCO3_for_298;//[cal] - Gibbs free energy of the reaction at 298.15 K\n", +"\n", +"delta_H_rkn_1042 = delta_H_rkn_298 + integrate('-7.535+9.925*10^(-3)*T-0.8362*10^(-5)*T^(2)+1.784*10^(-9)*T^(3)+4.119*10^(5)*T^(-2)','T',T_1,T_2);//[cal]\n", +"\n", +"printf(' Standard enthalpy change of reaction at 1042 K is %f cal\n\n',delta_H_rkn_1042);\n", +"\n", +"//Now determining the standard entropy change of reaction at 298.15 K\n", +"delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;//[cal/K]\n", +"delta_S_rkn_1042 = delta_S_rkn_298 + integrate('(-7.535+9.925*10^(-3)*T-0.8362*10^(-5)*T^(2)+1.784*10^(-9)*T^(3)+4.119*10^(5)*T^(-2))/T','T',T_1,T_2);//[cal/K]\n", +"\n", +"//Therefore,the standard Gibbs free energy change of the reaction is given by,\n", +"delta_G_rkn_1042 = delta_H_rkn_1042 - 1042*delta_S_rkn_1042;//[cal]\n", +"\n", +"printf(' Standard Gibbs free energy change of reaction at 1042 K is %f cal',delta_G_rkn_1042);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.1: Determination_of_enthalpy_entropy_and_Gibbs_free_energy_change_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.1\n", +"//Page number - 217\n", +"printf('Example - 6.1 and Page number - 217\n\n');\n", +"\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 880;//[K] - Reaction temperature\n", +"\n", +"a_SO2 = 6.157;\n", +"a_SO3 = 3.918;\n", +"a_O2 = 6.732;\n", +"b_SO2 = 1.384*10^(-2);\n", +"b_SO3 = 3.483*10^(-2);\n", +"b_O2 = 0.1505*10^(-2);\n", +"c_SO2 = -0.9103*10^(-5);\n", +"c_SO3 = -2.675*10^(-5);\n", +"c_O2 = -0.01791*10^(-5);\n", +"d_SO2 = 2.057*10^(-9);\n", +"d_SO3 = 7.744*10^(-9);\n", +"\n", +"delta_H_rkn_298 = -23.45*10^(3);//[cal] - Rkn enthalpy at 298.15 K\n", +"delta_H_SO2_for_298 = -70.94*10^(3);//[cal/mol] - Enthalpy of formation of S02 at 298.15 K\n", +"delta_H_SO3_for_298 = -94.39*10^(3);//[cal/mol] - Enthalpy of formation of SO3 at 298.15 K\n", +"delta_G_SO2_for_298 = -71.68*10^(3);//[cal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n", +"delta_G_SO3_for_298 = -88.59*10^(3);//[cal/mol] - Gibbs free energy change for formation of SO3 at 298.15 K\n", +"\n", +"//(1)\n", +"//Standard enthalpy change of reaction at temperature T is given by,\n", +"//delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n", +"delta_a = a_SO3 - a_SO2 - (a_O2/2);\n", +"delta_b = b_SO3 - b_SO2 - (b_O2/2);\n", +"delta_c = c_SO3 - c_SO2 - (c_O2/2);\n", +"delta_d = d_SO3 - d_SO2;\n", +"\n", +"//Cp_0 = delta_a + (delta_b*T) + (delta_c*T^(2)) + (delta_d*T^(3));\n", +"//Therefore we get,\n", +"delta_H_rkn_880 = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T_2);\n", +"\n", +"//On manual simplification of the above expression,we will get the expression for 'delta_H_rkn_880' as a function of T,\n", +" \n", +"printf(' (1).The expression for standard enthalpy change of reaction as a function of temperature is given by\n');\n", +"printf(' delta_H_rkn_880 = -22534.57 - 5.605*T + 1.012*10^(-2)*T^(2) - 0.585*10^(-5)*T^(3) + 1.422*10^(-9)*T^(4)\n\n')\n", +"\n", +"printf(' (2).Standard enthalpy change of reaction at 880 K is %f cal\n\n',delta_H_rkn_880);\n", +"\n", +"//(3)\n", +"//Let us determine the standard entropy change of reaction at 298.15 K\n", +"delta_S_SO2_298 = (delta_H_SO2_for_298 - delta_G_SO2_for_298)/298.15;//[cal/mol-K]\n", +"delta_S_SO3_298 = (delta_H_SO3_for_298 - delta_G_SO3_for_298)/298.15;//[cal/mol-K]\n", +"delta_S_O2_298 = 0;//[cal/mol-K]\n", +"\n", +"delta_S_rkn_298 = delta_S_SO3_298 - delta_S_SO2_298 - (delta_S_O2_298/2);//[cal/K]\n", +"delta_S_rkn_880 = delta_S_rkn_298 + integrate('(delta_a+delta_b*T+delta_c*T^(2)+delta_d*T^(3))/T','T',T_1,T_2);//[cal/K]\n", +"\n", +"printf(' (3).Standard entropy change of reaction at 880 K is %f cal/K\n\n',delta_S_rkn_880);\n", +"\n", +"//(4)\n", +"delta_G_rkn_880 = delta_H_rkn_880 - 880*delta_S_rkn_880;//[cal]\n", +"\n", +"printf(' (4).Standard Gibbs free energy change of reaction at 880 K is %f cal\n\n',delta_G_rkn_880);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.2: Determination_of_standard_enthalpy_and_Gibbs_free_energy_change_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.2\n", +"//Page number - 219\n", +"printf('Example - 6.2 and Page number - 219\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 400;//[K] - Reaction temperature\n", +"\n", +"a_CH3OH = 4.55;\n", +"a_CO = 6.726;\n", +"a_H2 = 6.952;\n", +"b_CH3OH = 2.186*10^(-2);\n", +"b_CO = 0.04001*10^(-2);\n", +"b_H2 = -0.04576*10^(-2);\n", +"c_CH3OH = -0.291*10^(-5);\n", +"c_CO = 0.1283*10^(-5);\n", +"c_H2 = 0.09563*10^(-5);\n", +"d_CH3OH = -1.92*10^(-9);\n", +"d_CO = -0.5307*10^(-9);\n", +"d_H2 = -0.2079*10^(-9);\n", +"\n", +"delta_H_rkn_298 = -21.6643*10^(3);//[cal] - Reaction enthalpy at 298.15 K\n", +"delta_H_CO_for_298 = -26.4157*10^(3);//[cal/mol] - Enthalpy of formation of CO at 298.15 K\n", +"delta_H_CH3OH_for_298 = -48.08*10^(3);//[cal/mol] - Enthalpy of formation of CH3OH at 298.15 K\n", +"delta_G_CO_for_298 = -32.8079*10^(3);//[cal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n", +"delta_G_CH3OH_for_298 = -38.69*10^(3);//[cal/mol] - Gibbs free energy change for formation of CH3OH at 298.15 K\n", +"\n", +"//Standard enthalpy change of reaction at temperature T is given by,\n", +"//delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n", +"delta_a = a_CH3OH - a_CO - 2*(a_H2);\n", +"delta_b = b_CH3OH - b_CO - 2*(b_H2);\n", +"delta_c = c_CH3OH - c_CO - 2*(c_H2);\n", +"delta_d = d_CH3OH - d_CO - 2*(d_H2);\n", +"\n", +"//Cp_0 = delta_a + (delta_b*T) + (delta_c*T^(2)) + (delta_d*T^(3));\n", +"//Therefore we get,\n", +"delta_H_rkn_400 = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T_2);\n", +"\n", +"printf(' Standard enthalpy change of reaction at 400 K is %f cal\n\n',delta_H_rkn_400);\n", +"\n", +"//Let us determine the standard Gibbs free energy change of reaction at 298.15 K\n", +"delta_G_rkn_298 = delta_G_CH3OH_for_298 - delta_G_CO_for_298;//[cal]\n", +"\n", +"//Now determining the standard entropy change of reaction at 298.15 K\n", +"delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;//[cal/mol-K]\n", +"\n", +"delta_S_rkn_400 = delta_S_rkn_298 + integrate('(delta_a+delta_b*T+delta_c*T^(2)+delta_d*T^(3))/T','T',T_1,T_2);//[cal/K]\n", +"//Therefore,the standard Gibbs free energy change of the reaction is given by,\n", +"delta_G_rkn_400 = delta_H_rkn_400 - 400*delta_S_rkn_400;//[cal]\n", +"\n", +"printf(' Standard Gibbs free energy change of reaction at 400 K is %f cal\n',delta_G_rkn_400);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.3: Determination_of_standard_enthalpy_and_Gibbs_free_energy_change_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.3\n", +"//Page number - 220\n", +"printf('Example - 6.3 and Page number - 220\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 1200;//[K] - Reaction temperature\n", +"\n", +"\n", +"a_CO2 = 5.316;\n", +"a_H2 = 6.952;\n", +"a_CO = 6.726;\n", +"a_H2O = 7.700;\n", +"b_CO2 = 1.4285*10^(-2);\n", +"b_H2 = -0.04576*10^(-2);\n", +"b_CO = 0.04001*10^(-2);\n", +"b_H2O = 0.04594*10^(-2);\n", +"c_CO2 = -0.8362*10^(-5);\n", +"c_H2 = 0.09563*10^(-5);\n", +"c_CO = 0.1283*10^(-5);\n", +"c_H2O = 0.2521*10^(-5);\n", +"d_CO2 = 1.784*10^(-9);\n", +"d_H2 = -0.2079*10^(-9);\n", +"d_CO = -0.5307*10^(-9);\n", +"d_H2O = -0.8587*10^(-9);\n", +"\n", +"delta_H_rkn_298 = -9.8382*10^(3);//[cal] - Reaction enthalpy at 298.15 K\n", +"delta_H_CO2_for_298 = -94.0518*10^(3);//[cal/mol-K] - Enthalpy of formation of CO2 at 298.15 K\n", +"delta_H_CO_for_298 = -26.4157*10^(3);//[cal/mol-K] - Enthalpy of formation of CO at 298.15 K\n", +"delta_H_H2O_for_298 = -57.7979*10^(3);//[cal/mol-K] - Enthalpy of formation of H2O at 298.15 K\n", +"delta_G_CO2_for_298 = -94.2598*10^(3);//[cal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n", +"delta_G_CO_for_298 = -32.8079*10^(3);//[cal/mol] - Gibbs free energy change for formation of CH3OH at 298.15 K\n", +"delta_G_H2O_for_298 = -54.6357*10^(3);//[cal/mol] - Gibbs free energy change for formation of H2O at 298.15 K\n", +"\n", +"//Standard enthalpy change of reaction at temperature T is given by,\n", +"//delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n", +"delta_a = a_CO2 + a_H2 - a_CO - a_H2O;\n", +"delta_b = b_CO2 + b_H2 - b_CO - b_H2O;\n", +"delta_c = c_CO2 + c_H2 - c_CO - c_H2O;\n", +"delta_d = d_CO2 + d_H2 - d_CO - d_H2O;\n", +"\n", +"//Cp_0 = delta_a + (delta_b*T) + (delta_c*T^(2)) + (delta_d*T^(3));\n", +"//Therefore we get,\n", +"delta_H_rkn_1200 = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T_2);\n", +"\n", +"printf(' Standard enthalpy change of reaction at 1200 K is %f cal\n\n',delta_H_rkn_1200);\n", +"\n", +"//Let us determine the standard Gibbs free energy change of reaction at 298.15 K\n", +"delta_G_rkn_298 = delta_G_CO2_for_298 - delta_G_CO_for_298 - delta_G_H2O_for_298;//[cal]\n", +"\n", +"//Now determining the standard entropy change of reaction at 298.15 K\n", +"delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;//[cal/mol-K]\n", +"\n", +"delta_S_rkn_1200 = delta_S_rkn_298 + integrate('(delta_a+delta_b*T+delta_c*T^(2)+delta_d*T^(3))/T','T',T_1,T_2);//[cal/K]\n", +"//Therefore,the standard Gibbs free energy change of the reaction is given by,\n", +"delta_G_rkn_1200 = delta_H_rkn_1200 - 1200*delta_S_rkn_1200;//[cal]\n", +"\n", +"printf(' Standard Gibbs free energy change of reaction at 1200 K is %f cal',delta_G_rkn_1200);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.4: Determination_of_standard_enthalpy_and_Gibbs_free_energy_change_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.4\n", +"//Page number - 221\n", +"printf('Example - 6.4 and Page number - 221\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 500;//[K] - Reaction temperature\n", +"\n", +"a_NH3 = 6.5846;\n", +"a_N2 = 6.903;\n", +"a_H2 = 6.952;\n", +"b_NH3 = 0.61251*10^(-2);\n", +"b_N2 = -0.03753*10^(-2);\n", +"b_H2 = -0.04576*10^(-2);\n", +"c_NH3 = 0.23663*10^(-5);\n", +"c_N2 = 0.1930*10^(-5);\n", +"c_H2 = 0.09563*10^(-5);\n", +"d_NH3 = -1.5981*10^(-9);\n", +"d_N2 = -0.6861*10^(-9);\n", +"d_H2 = -0.2079*10^(-9);\n", +"\n", +"delta_H_rkn_298 = -22.08*10^(3);//[cal] - Reaction enthalpy at 298.15 K\n", +"delta_H_NH3_for_298 = -11.04*10^(3);//[cal/mol] - Enthalpy of formation of NH3 at 298.15 K\n", +"delta_G_NH3_for_298 = -3.976*10^(3);//[cal/mol] - Gibbs free energy change for formation of NH3 at 298.15 K\n", +"\n", +"//Standard enthalpy change of reaction at temperature T is given by,\n", +"//delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n", +"delta_a = 2*a_NH3 - a_N2 - 3*a_H2;\n", +"delta_b = 2*b_NH3 - b_N2 - 3*b_H2;\n", +"delta_c = 2*c_NH3 - c_N2 - 3*c_H2;\n", +"delta_d = 2*d_NH3 - d_N2 - 3*d_H2;\n", +"\n", +"//Cp_0 = delta_a + (delta_b*T) + (delta_c*T^(2)) + (delta_d*T^(3));\n", +"//Therefore we get,\n", +"delta_H_rkn_500 = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T_2);\n", +"\n", +"printf(' Standard enthalpy change of reaction at 500 K is %f cal\n\n',delta_H_rkn_500);\n", +"\n", +"//Let us determine the standard Gibbs free energy change of reaction at 298.15 K\n", +"delta_G_rkn_298 = 2*delta_G_NH3_for_298;//[cal]\n", +"\n", +"//Now determining the standard entropy change of reaction at 298.15 K\n", +"delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;//[cal/mol-K]\n", +"\n", +"delta_S_rkn_500 = delta_S_rkn_298 + integrate('(delta_a+delta_b*T+delta_c*T^(2)+delta_d*T^(3))/T','T',T_1,T_2);//[cal/K]\n", +"//Therefore,the standard Gibbs free energy change of the reaction is given by,\n", +"delta_G_rkn_500 = delta_H_rkn_500 - 500*delta_S_rkn_500;//[cal]\n", +"\n", +"printf(' Standard Gibbs free energy change of reaction at 500 K is %f cal',delta_G_rkn_500);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.5: Determination_of_standard_enthalpy_and_Gibbs_free_energy_change_of_reaction.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.5\n", +"//Page number - 222\n", +"printf('Example - 6.5 and Page number - 222\n\n');\n", +"\n", +"//Given\n", +"//Cp_0 = 7.7 + 0.04594*10^(-2)*T + 0.2521*10^(-5)*T^(2) - 0.8587*10^(-9)*T^(3)\n", +"\n", +"delta_H_rkn_298 = -57.7979*10^(3);//[cal/mol] - Reaction enthalpy at 298.15 K\n", +"delta_G_rkn_298 = -54.6351*10^(3);//[cal/mol] - Gibbs free energy change for formation of H2O at 298.15 K\n", +"\n", +"//Standard enthalpy change of reaction at temperature T is given by,\n", +"//delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2_1 = 873.15;//[K] - Reaction temperature\n", +"T_2_2 = 1000;//[K] - Reaction temperature\n", +"\n", +"//Therefore we get,\n", +"delta_H_rkn_873 = delta_H_rkn_298 + integrate('7.7+0.04594*10^(-2)*T+0.2521*10^(-5)*T^(2)-0.8587*10^(-9)*T^(3)','T',T_1,T_2_1);;//[cal/mol]\n", +"delta_H_rkn_1000 = delta_H_rkn_298 + integrate('7.7+0.04594*10^(-2)*T+0.2521*10^(-5)*T^(2)-0.8587*10^(-9)*T^(3)','T',T_1,T_2_2);//[cal/mol]\n", +"\n", +"printf(' Standard enthalpy change of reaction at 873 K is %f cal/mol\n\n',delta_H_rkn_873);\n", +"printf(' Standard enthalpy change of reaction at 1000 K is %f cal/mol\n\n',delta_H_rkn_1000);\n", +"\n", +"//Now determining the standard entropy change of reaction at 298.15 K\n", +"delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;//[cal/mol-K]\n", +"\n", +"delta_S_rkn_873 = delta_S_rkn_298 + integrate('(7.7+0.04594*10^(-2)*T+0.2521*10^(-5)*T^(2)-0.8587*10^(-9)*T^(3))/T','T',T_1,T_2_1);//[cal/mol-K]\n", +"delta_S_rkn_1000 = delta_S_rkn_298 + integrate('(7.7+0.04594*10^(-2)*T+0.2521*10^(-5)*T^(2)-0.8587*10^(-9)*T^(3))/T','T',T_1,T_2_2);//[cal/mol-K]\n", +"//Therefore,the standard Gibbs free energy change of the reaction is given by,\n", +"delta_G_rkn_873 = (delta_H_rkn_873 - 873.15*delta_S_rkn_873)*10^(-3);//[kcal/mol]\n", +"delta_G_rkn_1000 = (delta_H_rkn_1000 - 1000*delta_S_rkn_1000)*10^(-3);//[kcal/mol]\n", +"\n", +"printf(' Standard Gibbs free energy change of reaction at 873 K is %f kcal/mol\n\n',delta_G_rkn_873);\n", +"printf(' Standard Gibbs free energy change of reaction at 1000 K is %f kcal/mol\n',delta_G_rkn_1000);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.6: Calculation_of_heat_exchange.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.6\n", +"//Page number - 223\n", +"printf('Example - 6.6 and Page number - 223\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 500;//[K] - Reaction temperature\n", +"\n", +"a_C2H6 = 1.648;\n", +"a_O2 = 6.085;\n", +"a_CO2 = 5.316;\n", +"a_H2O = 7.700;\n", +"b_C2H6 = 4.124*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"b_CO2 = 1.4285*10^(-2);\n", +"b_H2O = 0.04594*10^(-2);\n", +"c_C2H6 = -1.530*10^(-5);\n", +"c_O2 = -0.1709*10^(-5);\n", +"c_CO2 = -0.8362*10^(-5);\n", +"c_H2O = 0.2521*10^(-5);\n", +"d_C2H6 = 1.740*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"d_CO2 = 1.784*10^(-9);\n", +"d_H2O = -0.8587*10^(-9);\n", +"\n", +"//Since excess is entering and leaving at the same temperature,therefore it does not take or give any heat to the system.\n", +"//Therefore the heat exchange is only due to heat of raction at temperature T, or Q = delta_H_rkn_T\n", +"\n", +"delta_H_C2H6_for_298 = -20.236*10^(3);//[cal/mol] - Enthalpy of formation of C2H6 at 298.15 K\n", +"delta_H_CO2_for_298 = -94.0518*10^(3);//[cal/mol] - Enthalpy of formation of CO2 at 298.15 K\n", +"delta_H_H2O_for_298 = -57.7979*10^(3);//[cal/mol] - Enthalpy of formation of H2O at 298.15 K\n", +"\n", +"delta_H_rkn_298 = 2*delta_H_CO2_for_298 + 3*delta_H_H2O_for_298 - delta_H_C2H6_for_298;//[cal] - Reaction enthalpy at 298.15 K\n", +"\n", +"//Standard enthalpy change of reaction at temperature T is given by,\n", +"//delta_H_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n", +"delta_a = 2*a_CO2 + 3*a_H2O - a_C2H6 - 7/2*(a_O2);\n", +"delta_b = 2*b_CO2 + 3*b_H2O - b_C2H6 - 7/2*(b_O2);\n", +"delta_c = 2*c_CO2 + 3*c_H2O - c_C2H6 - 7/2*(c_O2);\n", +"delta_d = 2*d_CO2 + 3*d_H2O - d_C2H6 - 7/2*(d_O2);\n", +"\n", +"//Cp_0 = delta_a + (delta_b*T) + (delta_c*T^(2)) + (delta_d*T^(3));\n", +"//Therefore we get,\n", +"delta_H_rkn_500 = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T_2);//[cal]\n", +"delta_H_rkn_500 = delta_H_rkn_500*10^(-3);//[kcal]\n", +"\n", +"printf(' The heat exchange of the reaction at 500 K is %f kcal',delta_H_rkn_500);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.7: Calculation_of_change_in_entropy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.7\n", +"//Page number - 224\n", +"printf('Example - 6.7 and Page number - 224\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 600;//[K] - Reaction temperature\n", +"\n", +"a_C2H6 = -8.65;\n", +"a_H2O = 7.700;\n", +"a_CH4 = 4.750;\n", +"a_O2 = 6.085;\n", +"b_C2H6 = 11.578*10^(-2);\n", +"b_H2O = 0.04594*10^(-2);\n", +"b_CH4 = 1.200*10^(-2);\n", +"b_O2 = 0.3631*10^(-2);\n", +"c_C2H6 = -7.540*10^(-5);\n", +"c_H2O = 0.2521*10^(-5);\n", +"c_CH4 = 0.3030*10^(-5);\n", +"c_O2 = -0.1709*10^(-5);\n", +"d_C2H6 = 18.54*10^(-9);\n", +"d_H2O = -0.8587*10^(-9);\n", +"d_CH4 = -2.630*10^(-9);\n", +"d_O2 = 0.3133*10^(-9);\n", +"\n", +"delta_S_CH4_for_298 = 44.50;//[cal/mol-K] - Entropy of formation of CH4 at 298.15 K\n", +"delta_S_O2_for_298 = 49.00;//[cal/mol-K] - Entropy of formation of O2 at 298.15 K\n", +"delta_S_C2H6_for_298 = 64.34;//[cal/mol-K] - Entropy of formation of C2H6 at 298.15 K\n", +"delta_S_H2O_for_298 = 45.11;//[cal/mol-K] - Entropy of formation of C2H6 at 298.15 K\n", +"\n", +"//Cp_0 = delta_a + (delta_b*T) + (delta_c*T^(2)) + (delta_d*T^(3));\n", +"\n", +"//Standard entropy change of reaction at temperature T is given by,\n", +"//delta_S_rkn_T = delta_rkn_298 + delta_Cp_0*delta_T\n", +"delta_a = 1/6*(a_C2H6) + 3/2*(a_H2O) - a_CH4 - 3/4*(a_O2);\n", +"delta_b = 1/6*(b_C2H6) + 3/2*(b_H2O) - b_CH4 - 3/4*(b_O2);\n", +"delta_c = 1/6*(c_C2H6) + 3/2*(c_H2O) - c_CH4 - 3/4*(c_O2);\n", +"delta_d = 1/6*(d_C2H6) + 3/2*(d_H2O) - d_CH4 - 3/4*(d_O2);\n", +"\n", +"delta_S_rkn_298 = 1/6*(delta_S_C2H6_for_298) + 3/2*(delta_S_H2O_for_298) - delta_S_CH4_for_298 - 3/4*(delta_S_O2_for_298);//[cal/K]\n", +"delta_S_rkn_600 = delta_S_rkn_298 + integrate('(delta_a+delta_b*T+delta_c*T^(2)+delta_d*T^(3))/T','T',T_1,T_2);//[cal/K]\n", +"\n", +"printf(' Change in entropy of the reaction at 298.15 K is %f cal/K\n\n',delta_S_rkn_298);\n", +"printf(' Standard entropy change of reaction at 600 K is %f cal/K',delta_S_rkn_600);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.8: Calculation_of_standard_enthalpy_change_and_Gibbs_free_energy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.8\n", +"//Page number - 225\n", +"printf('Example - 6.8 and Page number - 225\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 973.15;//[K] - Reaction temperature\n", +"\n", +"//At 298.15 K\n", +"delta_H_CH4_for_298 = -17.889*10^(3);//[cal/mol] - Enthalpy of formation of CH4 at 298.15 K\n", +"delta_H_C_for_298 = 0.00;//[cal/mol] - Enthalpy of formation of C (s, graphite) at 298.15 K\n", +"delta_H_H2_for_298 = 0.00;//[cal/mol] - Enthalpy of formation of H2 at 298.15 K\n", +"delta_G_CH4_for_298 = -12.140*10^(3);//[cal/mol] - Gibbs free energy change for formation of H2 at 298.15 K\n", +"delta_G_C_for_298 = 0.00;//[cal/mol] - Gibbs free energy change for formation of C (s, graphite) at 298.15 K\n", +"delta_G_H2_for_298 = 0.00;//[cal/mol] - Gibbs free energy change for formation of H2 at 298.15 K\n", +"\n", +"///Standaerd heat capacity data in cal/mol-K are given below, T is in K\n", +"//Cp_0_CH4 = 4.75 + 1.2*10^(-2)*T + 0.303*10^(-5)*T^(2) - 2.63*10^(-9)*T^(3)\n", +"//Cp_0_C = 3.519 + 1.532*10^(-3)*T - 1.723*10^(5)*T^(-2)\n", +"//Cp_0_H2 = 6.952 - 0.04576*10^(-2)*T + 0.09563*10^(-5)*T^(2) - 0.2079*10^(-9)*T^(3)\n", +"\n", +"//Therefore standard heat capacity of reaction is given by,\n", +"//Cp_0_rkn = 2*Cp_0_H2 + Cp_0_C - Cp_0_CH4\n", +"//On simplification,we get the relation\n", +"//Cp_0_rkn = 12.673 - 0.0113832*T - 1.1174*10^(-6)*T^(2) + 2.2142*10^(-9)*T^(3) - 1.723*10^(5)*T^(-2)\n", +"\n", +"delta_H_rkn_298 = -delta_H_CH4_for_298;//[cal] - Enthalpy of reaction at 298.15 K\n", +"delta_G_rkn_298 = -delta_G_CH4_for_298;//[cal] - Gibbs free energy of the reaction at 298.15 K\n", +"\n", +"delta_H_rkn_973 = delta_H_rkn_298 + integrate('12.673-0.0113832*T-1.1174*10^(-6)*T^(2)+2.2142*10^(-9)*T^(3)-1.723*10^(5)*T^(-2)','T',T_1,T_2);//[cal]\n", +"\n", +"printf(' Standard enthalpy change of reaction at 973.15 K is %f cal\n\n',delta_H_rkn_973);\n", +"\n", +"//Now determining the standard entropy change of reaction at 298.15 K\n", +"delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;//[cal/K]\n", +"delta_S_rkn_973 = delta_S_rkn_298 + integrate('(12.673-0.0113832*T-1.1174*10^(-6)*T^(2)+2.2142*10^(-9)*T^(3)-1.723*10^(5)*T^(-2))/T','T',T_1,T_2);//[cal/K]\n", +"\n", +"//Therefore,the standard Gibbs free energy change of the reaction is given by,\n", +"delta_G_rkn_973 = delta_H_rkn_973 - 973.15*delta_S_rkn_973;//[cal]\n", +"\n", +"printf(' Standard Gibbs free energy change of reaction at 973 K is %f cal\n',delta_G_rkn_973);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.9: Calculation_of_standard_enthalpy_change_and_Gibbs_free_energy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 6.9\n", +"//Page number - 226\n", +"printf('Example - 6.9 and Page number - 226\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard temperature\n", +"T_2 = 1000;//[K] - Reaction temperature\n", +"\n", +"//At 298.15 K\n", +"delta_H_C_for_298 = 0.00;//[cal/mol] - Enthalpy of formation of C(s,graphite) at 298.15 K\n", +"delta_H_H2O_for_298 = -57.7979*10^(3);//[cal/mol] - Enthalpy of formation of H2O at 298.15 K\n", +"delta_H_CO_for_298 = -26.4157*10^(3);//[cal/mol] - Enthalpy of formation of CO at 298.15 K\n", +"delta_H_H2_for_298 = 0.00;//[cal/mol] - Enthalpy of formation of H2 at 298.15 K\n", +"delta_G_C_for_298 = 0.00;//[cal/mol] - Gibbs free energy change for formation of C(s, graphite) at 298.15 K\n", +"delta_G_H2O_for_298 = -54.6357*10^(3);//[cal/mol] - Gibbs free energy change for formation of H2O at 298.15 K\n", +"delta_G_CO_for_298 = -32.8079*10^(3);//[cal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n", +"delta_G_H2_for_298 = 0.00;//[cal/mol] - Gibbs free energy change for formation of H2 at 298.15 K\n", +"\n", +"///Standaerd heat capacity data in cal/mol-K are given below, T is in K\n", +"//Cp_0_C = 3.519 + 1.532*10^(-3)*T - 1.723*10^(5)*T^(-2)\n", +"//Cp_0_H2O = 7.7 + 0.04594*10^(-2)*T + 0.2521*10^(-5)*T^(2) - 0.8587*10^(-9)*T^(3)\n", +"//Cp_0_CO = 6.726 + 0.04001*10^(-2)*T + 0.1283*10^(-5)*T^(2) - 0.5307*10^(-9)*T^(3)\n", +"//Cp_0_H2 = 6.952 - 0.04576*10^(-2)*T + 0.09563*10^(-5)*T^(2) - 0.2079*10^(-9)*T^(3)\n", +"\n", +"//Therefore standard heat capacity of reaction is given by,\n", +"//Cp_0_rkn = Cp_0_H2 + Cp_0_CO - Cp_0_C - Cp_0_H2O\n", +"//On simplification,we get the relation\n", +"//Cp_0_rkn = 2.459 - 2.0489*10^(-3)*T - 2.817*10^(-7)*T^(2) + 1.201*10^(-10)*T^(3) + 1.723*10^(5)*T^(-2)\n", +"\n", +"delta_H_rkn_298 = delta_H_CO_for_298 + delta_H_H2_for_298 - delta_H_C_for_298 - delta_H_H2O_for_298;//[cal] - Enthalpy of reaction at 298.15 K\n", +"delta_G_rkn_298 = delta_G_CO_for_298 + delta_G_H2_for_298 - delta_G_C_for_298 - delta_G_H2O_for_298;//[cal] - Gibbs free energy of the reaction at 298.15 K\n", +"\n", +"delta_H_rkn_1000 = delta_H_rkn_298 + integrate('2.459-2.0489*10^(-3)*T-2.817*10^(-7)*T^(2)+1.201*10^(-10)*T^(3)+1.723*10^(5)*T^(-2)','T',T_1,T_2);//[cal]\n", +"\n", +"printf(' Standard enthalpy change of reaction at 1000 K is %f cal\n\n',delta_H_rkn_1000);\n", +"\n", +"//Now determining the standard entropy change of reaction at 298.15 K\n", +"delta_S_rkn_298 = (delta_H_rkn_298 - delta_G_rkn_298)/298.15;//[cal/K]\n", +"delta_S_rkn_1000 = delta_S_rkn_298 + integrate('(2.459-2.0489*10^(-3)*T-2.817*10^(-7)*T^(2)+1.201*10^(-10)*T^(3)+1.723*10^(5)*T^(-2))/T','T',T_1,T_2);//[cal/K]\n", +"\n", +"//Therefore,the standard Gibbs free energy change of the reaction is given by,\n", +"delta_G_rkn_1000 = delta_H_rkn_1000 - 1000*delta_S_rkn_1000;//[cal]\n", +"\n", +"printf(' Standard Gibbs free energy change of reaction at 1000 K is %f cal\n',delta_G_rkn_1000);" + ] + } +], +"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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/7-Thermodynamic_property_relations_of_pure_substance.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/7-Thermodynamic_property_relations_of_pure_substance.ipynb new file mode 100644 index 0000000..ec4303f --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/7-Thermodynamic_property_relations_of_pure_substance.ipynb @@ -0,0 +1,1897 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7: Thermodynamic property relations of pure substance" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.10: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.10\n", +"//Page number - 245\n", +"printf('Example - 7.10 and Page number - 245\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.10 on page number 245 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.10 on page number 245 of the book.');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.11: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.11\n", +"//Page number - 246\n", +"printf('Example - 7.11 and Page number - 246\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.11 on page number 246 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.11 on page number 246 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.12: Evaluation_of_beta_and_K_for_nitrogen_gas.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.12\n", +"//Page number - 247\n", +"printf('Example - 7.9 and Page number - 244\n\n');\n", +"\n", +"//given\n", +"T = 25+273.15;//[K] - Temperature\n", +"P = 1;//[atm] - Pressure\n", +"P = P*101325;//[Pa]\n", +"Tc = 126.2;//[K] - Critical temperature\n", +"Pc = 34;//[bar] - Critical pressure\n", +"Pc = Pc*10^(5);//[Pa]\n", +"R=8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"a = (27*R^(2)*Tc^(2)/(64*Pc));//[Pa-m^(6)/mol^(2)]\n", +"b = (R*Tc)/(8*Pc);//[m^(3)/mol]\n", +"\n", +"\n", +"// the cubic form of van der Walls equation of state is\n", +"// V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P=0\n", +"//Solving the cubic equation\n", +"deff('[y]=f(V)','y=V^(3)-(b+(R*T)/P)*V^(2)+(a/P)*V-(a*b)/P');\n", +"V = fsolve(1,f);\n", +"//The above equation has 1 real and 2 imaginary roots. We consider only real root.\n", +"\n", +"Beta = R/((P*V)-(a/V)+((2*a*b)/V^(2)));//[K^(-1)]\n", +"\n", +"K_t = (V-b)/((P*V)-(a/V)+((2*a*b)/V^(2)));//[Pa^(-1)]\n", +"K_t = K_t*101325;//[atm^(-1)]\n", +"\n", +"printf(' Beta\t = \t %f K^(-1)\n',Beta);\n", +"printf(' K_t\t = \t %f atm^(-1)',K_t);\n", +"\n", +"//For ideal gas, Beta = 1/T = 0.0033354 K^(-1) and K_t = 1/P = 1 atm^(-1)\n", +"// So results obtained are convergent with those obtained assuming ideal gas.\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.13: Calculation_of_temperature_change_and_entropy_change_of_water.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.13\n", +"//Page number - 248\n", +"printf('Example - 7.13 and Page number - 248\n\n');\n", +"\n", +"//Given\n", +"T = 45+273.15;//[K]\n", +"P_1 = 10;//[kPa] - Initial pressure\n", +"P_2 = 8600;//[kPa] - Final pressure\n", +"V = 1010;//[cm^(3)/kg] - Specific volume for saturated liquid water at 45 C\n", +"V = V*10^(-6);//[m^(3)/kg]\n", +"// Beta = (1/V)*(dV/dT)_P\n", +"Beta = 4.25*10^(-4);//[k^(-1)]\n", +"Cp = 4.178;//[kJ/kg-K] - Specific heat at constant pressure\n", +"eff = 0.75;// Efficiency of the pump\n", +"\n", +"//(1)\n", +"//when efficiency of the pump is 100% , W = -delta_Hs\n", +"// Now delta_H = T*dS + V*dP, therefore under isentropic conditions, dH = V*dP\n", +"// Since the fluid is liquid, therefore the specific volume can be taken to be constant and integrating the above equaton we get\n", +"// delta_Hs = V*dP\n", +"delta_Hs = V*(P_2 - P_1);//[kJ/kg]\n", +"\n", +"//Actual pumps are not isentropic and therefore not 100% efficient. Therefore actual work done by the pump is given by\n", +"W = -delta_Hs/eff;//[kJ/kg]\n", +"\n", +"printf(' (1).The work done by the pump is %f kJ/kg\n',W);\n", +"\n", +"//(2)\n", +"// We know that dH = Cp*dT + (1 - Beta*T)*V*dP\n", +"// Beta and V are weak functions of pressure in the case of liquids.\n", +"// Integrating the above equation we get\n", +"// delta_H = Cp*delta_T + (1 - Beta*T)*V*(delta_P)\n", +"// Now from energy balance delta_H = q - W . But q = 0. Therefore,\n", +"delta_H = -W;//[kJ/kg]\n", +"// Solving for delta_T\n", +"delta_T = (delta_H - (1 - Beta*T)*V*(P_2-P_1))/Cp;\n", +"\n", +"printf(' (2).The temperature of water change by, delta_T = %f K\n',delta_T);\n", +"\n", +"//(3)\n", +"T_1 = T;//[K]\n", +"T_2 = T + delta_T;//[K]\n", +"// dS = (Cp/T)*dT - Beta*V*dP\n", +"// Beta and V are weak functions of pressure in the case of liquids. Integrating the above equation we get\n", +"delta_S = Cp*log(T_2/T_1) - Beta*V*(P_2-P_1);//[kJ/kg-K]\n", +"\n", +"printf(' (3).The entropy change of water is given by delta_S = %f kJ/kg-K',delta_S);\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.14: Estimation_of_change_in_entropy_and_enthalpy.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.14\n", +"//Page number - 249\n", +"printf('Example - 7.14 and Page number - 249\n\n');\n", +"\n", +"//Given\n", +"T = 270;//[K]\n", +"P_1 = 381;//[kPa] - Initial pressure\n", +"P_2 = 1200;//[kPa] - Final pressure\n", +"V_liq = 1.55*10^(-3);//[m^(3)/kg] - Specific volume for saturated water in liquid phase at 270 C\n", +"Beta = 2.095*10^(-3);//[K^(-1)]\n", +"\n", +"//dH = Cp*dT + [V - T*(dV/dT)_P]*dP\n", +"// dS = (Cp/T)*dT - ((dV/dT)_P)*dP\n", +"// Since isothermal conditions are maintained we get\n", +"// dH = [V - T*(dV/dT)_P]*dP = V*(1 - Beta*T)*dP\n", +"// For the liquid assuming V and Beta to remain constant during pressure change, and since temperature is constant we get\n", +"delta_H = V_liq*(1 - Beta*T)*(P_2 - P_1);//[kJ/kg]\n", +"\n", +"printf('The enthalpy change is given by delta_H = %f kJ/kg\n',delta_H);\n", +"\n", +"// Under isothermal conditions \n", +"// dS = -((dV/dT)_P)*dP = -Beta*V_liq*dP\n", +"// If Beta*V is assumed to remain constant during pressure change we get\n", +"delta_S = -Beta*V_liq*(P_2-P_1);//[kJ/kg-K]\n", +"\n", +"printf('The entropy change is given by delta_S = %e kJ/kg-K',delta_S);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.15: Calculation_of_percentage_change_in_volume.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.15\n", +"//Page number - 249\n", +"printf('Example - 7.15 and Page number - 249\n\n');\n", +"\n", +"//Given\n", +"T_1 = 0;//[C] - Initial tempetaure\n", +"T_2 = 100;//[C] - Final temperature\n", +"// Beta = 1.0414*10^(-3) + 1.5672*10^(-6)*T + 5.148*10^(-8)*T^(2), where T is in C\n", +"// At constant pressure (1/V)*(dV/dT) = Beta\n", +"// or, d(log(V)) = Beta*dT\n", +"// Integrating we get log(V_2/V_1) = integral(Beta*dT) from limit T_1 to T_2\n", +"integral = integrate('1.0414*10^(-3)+1.5672*10^(-6)*T+5.148*10^(-8)*T^(2)','T',T_1,T_2);\n", +"\n", +"// log(V_2/V_1) = integral\n", +"// (V_2/V_1) = exp(integral)\n", +"// (V_2 - V_1)/V_1 = change = exp(integral) - 1;\n", +"change = exp(integral) - 1;\n", +"per_change = 100*change;\n", +"\n", +"printf('The percentage change in volume = %f %%',per_change);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.16: Determination_of_enthalpy_and_entropy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.16\n", +"//Page number - 250\n", +"printf('Example - 7.16 and Page number - 250\n\n');\n", +"\n", +"//Given\n", +"T_1 = 25 + 273.15;//[C] - Initial tempetaure\n", +"T_2 = 50 + 273.15;//[C] - Final temperature\n", +"P_1 = 1;//[bar] - Initial pressure\n", +"P_2 = 1000;//[bar] - Final pressure\n", +"\n", +"Cp_T1_P1 = 75.305;//[J/mol-K]\n", +"Cp_T2_P1 = 75.314;//[J/mol-K]\n", +"V_T1_P1 = 18.071;//[cm^(3)/mol]\n", +"V_T1_P2 = 18.012;//[cm^(3)/mol]\n", +"V_T2_P1 = 18.234;//[cm^(3)/mol]\n", +"V_T2_P2 = 18.174;//[cm^(3)/mol]\n", +"Beta_T1_P1 = 256*10^(-6);//[K^(-1)]\n", +"Beta_T1_P2 = 366*10^(-6);//[K^(-1)]\n", +"Beta_T2_P1 = 458*10^(-6);//[K^(-1)]\n", +"Beta_T2_P2 = 568*10^(-6);//[K^(-1)]\n", +"\n", +"// The entropy change is given by\n", +"// dS = (Cp/T)*dT - ((dV/dT)_P)*dP\n", +"// The mean Cp between 25 and 50 C is \n", +"Cp_mean = (Cp_T1_P1 + Cp_T1_P1)/2;//[J/mol-K]\n", +"\n", +"\n", +"// (dV/dT)_P=1bar = (V_T2_P1 - V_T1_P1)/(50 - 25)\n", +"dV_dT_P1 = ((V_T2_P1 - V_T1_P1)/(50 - 25))*10^(-6);//[m^(-3)/mol-K]\n", +"dV_dT_P2 = ((V_T2_P2 - V_T1_P2)/(50 - 25))*10^(-6);//[m^(-3)/mol-K]\n", +"// The mean value of (dV/dT)_P between 1 and 1000 bar is\n", +"dV_dT_mean = (dV_dT_P1 + dV_dT_P2)/2;//[m^(-3)/mol-K]\n", +"delta_S = Cp_mean*log(T_2/T_1) - dV_dT_mean*(P_2 - P_1)*10^(5);//[J/mol-K]\n", +"\n", +"printf(' The value of entropy change is given by, delta_S = %f J/mol-K\n',delta_S);\n", +"\n", +"// Now let us determine the enthalpy change. We know that\n", +"// dH = Cp*dT + [V - T*(dV/dT)_P]*dP\n", +"// [V - T*(dV/dT)_P] = (V - T*V*Beta) = val (say)\n", +"// At state 1\n", +"val_1 = ((V_T1_P1)*10^(-6))*(1 - (T_1)*(Beta_T1_P1));//[m^(3)/mol]\n", +"// At state 2\n", +"val_2 = ((V_T2_P2)*10^(-6))*(1 - (T_2)*(Beta_T2_P2));//[m^(3)/mol]\n", +"val_mean = (val_1 + val_2)/2;//[m^(3)/mol]\n", +"\n", +"delta_H = Cp_mean*(T_2 - T_1) + val_mean*(P_2-P_1)*10^(5);//[J/mol]\n", +"\n", +"printf(' The value of enthalpy change is given by, delta_H = %f J/mol',delta_H);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.17: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.17\n", +"//Page number - 253\n", +"printf('Example - 7.17 and Page number - 253\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.17 on page number 253 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.17 on page number 253 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.18: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.18\n", +"//Page number - 253\n", +"printf('Example - 7.18 and Page number - 253\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.18 on page number 253 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.18 on page number 253 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.19: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.19\n", +"//Page number - 254\n", +"printf('Example - 7.19 and Page number - 254\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.19 on page number 254 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.19 on page number 254 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.1: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.1\n", +"//Page number - 235\n", +"printf('Example - 7.1 and Page number - 235\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.1 on page number 235 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.1 on page number 235 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.20: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.20\n", +"//Page number - 254\n", +"printf('Example - 7.20 and Page number - 254\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.20 on page number 254 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.20 on page number 254 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.21: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.21\n", +"//Page number - 255\n", +"printf('Example - 7.21 and Page number - 255\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.21 on page number 255 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.21 on page number 255 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.22: Calculation_of_volume_expansivity_and_isothermal_compressibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.22\n", +"//Page number - 256\n", +"printf('Example - 7.22 and Page number - 256\n\n');\n", +"\n", +"// Given\n", +"T = 100 + 273.15;//[K]\n", +"P = 10;//[MPa]\n", +"\n", +"// The volume expansivity is defined as \n", +"// Beta = (1/V)*(del V/del T)_P = (1/V)*(dV/dT)_P\n", +"// From compressed liquid water tables at 100 C and 10 MPa,\n", +"V = 0.0010385;//[m(3)/kg]\n", +"Beta = (1/V)*((0.0010549 - 0.0010245)/(120 - 80));//[K^(-1)] // The values are obtained from the steam table as reported in the book.\n", +"\n", +"printf('The value of volume expansivity is Beta = %e K^(-1)\n',Beta);\n", +"\n", +"//Isothermal compressibility is defined as\n", +"// K_t = -(1/V)*(del V/del T)_T = -(1/V)*(dV/dT)_T\n", +"K_t = -(1/V)*((0.0010361 - 0.0010410)/(15 - 5));//[MPa^(-1)] // The values are obtained from the steam table as reported in the book.\n", +"\n", +"K_t = K_t*10^(-3);//[kPa]\n", +"\n", +"printf('The value of isothermal compressibility is K_t = %e kPa^(-1)\n',K_t);\n", +"\n", +"// Cp - Cv = (T*V*(Beta^(2)))/K_t\n", +"R = (T*V*(Beta^(2)))/K_t;//[kJ/kg-K]\n", +"\n", +"printf('The value of the difference between Cp and Cv is Cp-Cv = %f kJ/kg-K',R);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.23: Estimation_of_specific_heat_capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.23\n", +"//Page number - 257\n", +"printf('Example - 7.23 and Page number - 257\n\n');\n", +"\n", +"// Given\n", +"T = 300 + 273.15;//[K]\n", +"P = 4;//[MPa] \n", +"\n", +"Cp_0 = 7.7 + 0.04594*10^(-2)*T + 0.2521*10^(-5)*T^(2) - 0.8587*10^(-9)*T^(3);//[cal/mol-K]\n", +"Cp_0 = (Cp_0*4.186)/18.015;//[kJ/kg-K]\n", +"\n", +"// Cp(T,P) = Cp_0(T,P=0) - T*integral((del^2 V/del T^(2))_P)*dP from limit 0 to P\n", +"// Cp = Cp_0 - T*((del^2 V/del T^2)_Pavg)*(P_2 - P_1)\n", +"\n", +"P_avg = (0+4)/2;//[MPa]\n", +"\n", +"//Using finite difference we get (del^2 V/del T^(2)) = ((V_(T+delta T) - 2*V_T + V_(T-delta T))/(delta_T^(2))\n", +"//(del^2 V/del T^(2))_Pavg = (V_(350 C) + V_(250 C) - 2*V_(300 C))/(delta_T^(2)) = del_2 (say)\n", +"del_2 = (0.13857 + 0.11144 - 2*0.12547)/(50^(2));//[m^(3)/kg-K^2] // The values are obtained from the steam table as reported in the book.\n", +"\n", +"\n", +"Cp = Cp_0 - T*del_2*4000;//[kJ/kg-K]\n", +"\n", +"printf(' The value of constant pressure specific heat capacity is, Cp = %f kJ/kg-K',Cp);\n", +"\n", +"// At P = 4 MPa\n", +"// Cp = (del H/del T)_P = (H_350 C - H_250 C)/(350 - 250.4)\n", +"// Cp = (3092.5 - 2801.4)/(350 - 250.4) = 2.923 [kJ/kg-K]\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.24: Estimation_of_specific_heat_capacity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.24\n", +"//Page number - 257\n", +"printf('Example - 7.24 and Page number - 257\n\n');\n", +"\n", +"// Given\n", +"T = 300 + 273.15;//[K]\n", +"P = 2.0;//[MPa]\n", +"\n", +"// At 2 MPa and 250 C \n", +"H_1 = 2902.5;//[kJ/kg]\n", +"// At 2 MPa and 350 C \n", +"H_2 = 3137.0;//[kJ/kg]\n", +"\n", +"Cp = (H_2 - H_1)/(350 - 250);//[kJ/kg-K]\n", +"\n", +"printf(' The value of constant pressure specific heat capacity is, Cp = %f kJ/kg-K',Cp);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.25: Calculation_of_volume_expansivity_and_isothermal_compressibility.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.25\n", +"//Page number - 258\n", +"printf('Example - 7.25 and Page number - 258\n\n');\n", +"\n", +"// Given\n", +"T = 80 + 273.15;//[K]\n", +"P = 10;//[MPa] \n", +"\n", +"// Beta = (1/V)*(del V/del T)_P\n", +"\n", +"// Pressure is kept fixed at 10 MPa and (del V/del T)_P is evaluated. Looking in the compressed liquid water tables,at\n", +"// At 80 C and 10 MPa\n", +"V_1 = 0.0010245;//[m^(3)/kg]\n", +"// At 60 C and 10 MPa\n", +"V_2 = 0.0010127;//[m^(3)/kg]\n", +"// At 100 C and 10 MPa\n", +"V_3 = 0.0010385;//[m^(3)/kg]\n", +"\n", +"Beta = (1/V_1)*((V_3 - V_2)/(100 - 60));//[K^(-1)]\n", +"\n", +"printf('The value of volume expansivity is Beta = %e K^(-1)\n',Beta);\n", +"\n", +"//Isothermal compressibility is given by\n", +"// K_t = -(1/V)*(del V/del P)_T\n", +"\n", +"// Temperature is kept fixed at 80 C and different pressures are taken to calculate (del V/del P)_T\n", +"// At 80 C and 5 MPa\n", +"V_4 = 0.0010268;//[m^(3)/kg]\n", +"// At 80 C and 10 MPa\n", +"V_5 = 0.0010245;//[m^(3)/kg]\n", +"// At 80 C and 15 MPa\n", +"V_6 = 0.0010222;//[m^(3)/kg]\n", +"\n", +"// K_t = -(1/V)*(del V/del T)_P\n", +"K_t = -(1/V_1)*((V_4 - V_6)/(5 - 15));//[MPa^(-1)]\n", +"K_t = K_t*10^(-6);//[Pa^(-1)]\n", +"\n", +"printf('The value of isothermal compressibility is K_t = %e Pa^(-1)\n',K_t);\n", +"\n", +"// Cp - Cv = (T*V*(Beta^(2)))/K_t\n", +"R = (T*V_1*(Beta^(2)))/K_t;//[J/kg-K]\n", +"R = R*10^(-3);//[kJ/kg-K]\n", +"\n", +"printf('The value of the difference between Cp and Cv is Cp-Cv = %f kJ/kg-K',R);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.26: Calculation_of_mean_Joule_Thomson_coefficient.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 7.26\n", +"//Page number - 260\n", +"printf('Example - 7.26 and Page number - 260\n\n');\n", +"// Given\n", +"P_1 = 150;//[bar]\n", +"P_2 = 1;//[bar]\n", +"T_1 = 300;//[K]\n", +"T_2 = 260;//[K]\n", +"T_3 = 280;//[K]\n", +"T_4 = 200;//[K]\n", +"T_5 = 120;//[K]\n", +"T_6 = 140;//[K]\n", +"H_P1_T1 = 271.8;//[kJ/kg]\n", +"H_P2_T2 = 260.0;//[kJ/kg] \n", +"H_P2_T3 = 280.2;//[kJ/kg]\n", +"H_P1_T4 = 129.2;//[kJ/kg]\n", +"H_P2_T5 = 118.8;//[kJ/kg]\n", +"H_P2_T6 = 139.1;//[kJ/kg]\n", +"//(a)\n", +"// During the Joule-Thomson expansion the enthalpy should remain constant\n", +"// Therefore at 1 bar the exit temperature is such that enthalpy is 271.8 kJ/kg\n", +"// The temperature at which enthalpy is 271.8 kJ/kg is given by,\n", +"T_new = ((H_P1_T1 - H_P2_T2)/(H_P2_T3 - H_P2_T2))*(T_3 - T_2) + T_2;//[K]\n", +"// Therefore Joule-Thomson coefficient is given by,\n", +"meu = (T_1 - T_new)/(P_1 - P_2);//[K/bar]\n", +"printf(' (a).The value of Joule-Thomson coefficient (for initial T = 300 K) is %f J/bar\n',meu);\n", +"//(b)\n", +"// During the Joule-Thomson expansion the enthalpy should remain constant\n", +"// Therefore at 1 bar the exit temperature is such that enthalpy is 129.2 kJ/kg\n", +"// The temperature at which enthalpy is 129.2 kJ/kg is given by,\n", +"T_new_prime = ((H_P1_T4 - H_P2_T5)/(H_P2_T6 - H_P2_T5))*(T_6 - T_5) + T_5;//[K]\n", +"// Therefore Joule-Thomson coefficient is given by,\n", +"meu_prime = (T_4 - T_new_prime)/(P_1 - P_2);//[K/bar]\n", +"printf(' (b).The value of Joule-Thomson coefficient (for initial T = 200 K) is %f J/bar',meu_prime);\n", +"// Therefore the Joule-Thomson coefficient is higher for low initial temperatures and therefore the drop in temperature is more." + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.27: Estimation_of_Joule_Thomson_coefficient.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.27\n", +"//Page number - 261\n", +"printf('Example - 7.27 and Page number - 261\n\n');\n", +"\n", +"//(a)\n", +"//This part involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.27 on page number 261 of the book.\n", +"\n", +"//(b)\n", +"//This part involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.27 on page number 261 of the book.\n", +"\n", +"//(c)\n", +"T = 300;//[K] - Temperature\n", +"P = 5;//[atm] - Pressure\n", +"P = P*101325;//[Pa]\n", +"Cp_0 = 35.78;//[J/mol-K] - Standard specific heat capacity at constant pressure\n", +"B = -50;//[cm^(3)/mol]\n", +"B = B*10^(-6);//[m^(3)/mol]\n", +"\n", +"// (dB/dT) = 1.0 = dB_dT (say)\n", +"dB_dT = 1.0;//[cm^(3)/mol-K]\n", +"dB_dT = dB_dT*10^(-6);//[m^(3)/mol-K]\n", +"\n", +"// (d^2 B/d T^2) = -0.01 = dB_dT_2 (say)\n", +"dB_dT_2 = -0.01;//[cm^(3)/mol-K^(2)]\n", +"dB_dT_2 = dB_dT_2*10^(-6);//[m^(3)/mol-K^(2)]\n", +"\n", +"Cp = Cp_0 - P*T*(dB_dT_2);//[[J/mol-K]] - Specific heat capacity at constant pressure\n", +"\n", +"//Therefore Joule-Thomson coefficient is given by,\n", +"meu = (1/Cp)*(-B + T*dB_dT);//[K/Pa]\n", +"meu = meu*10^(5);//[K/bar]\n", +"\n", +"printf(' (c).The value of Joule-Thomson coefficient is %f J/bar',meu);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.28: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.28\n", +"//Page number - 262\n", +"printf('Example - 7.28 and Page number - 262\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.28 on page number 262 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.28 on page number 262 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.29: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.29\n", +"//Page number - 263\n", +"printf('Example - 7.29 and Page number - 263\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.29 on page number 263 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.29 on page number 263 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.2: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.2\n", +"//Page number - 236\n", +"printf('Example - 7.2 and Page number - 236\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.2 on page number 236 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.2 on page number 236 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.30: Calculation_of_pressure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.30\n", +"//Page number - 267\n", +"printf('Example - 7.30 and Page number - 267\n\n');\n", +"\n", +"//Given\n", +"den_liq = 13690;//[kg/m^(3)] - Density of liquid mercury\n", +"den_solid = 14190;//[kg/m^(3)] - Density of solid mercury\n", +"mp = -38.87;//[C] - Melting point of mercury at pressure of 1 bar\n", +"mp = mp + 273.15;//[K]\n", +"T_req = 0;//[C] - Required temperature to which the melting point is to be raised\n", +"T_req = T_req + 273.15;//[K]\n", +"H_fus = 11.62;//[kJ/kg] - Latent heat of fusion of mercury\n", +"\n", +"V_liq = (1/den_liq);//[m^(3)/kg] - Specific volume of liquid mercury\n", +"V_solid = (1/den_solid);//[m^(3)/kg] - Specific volume of solid mercury\n", +"\n", +"// (delta P/delta T) = ((P - 1)*100)/(T_req - mp)\n", +"// delta H/(T*delta V) = (H_liq - H_solid)/(T*(V_liq - V_solid)) = del (say)\n", +"del = (H_fus)/(mp*(V_liq - V_solid));//[kPa/K] - delta H/(T*delta V)\n", +"\n", +"//Equating the two sides and then solving we get\n", +"P = (del*(T_req - mp))/100 + 1;//[bar]\n", +"\n", +"printf(' The required pressure should be %f bar',P);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.31: Calculation_of_enthalpy_change_and_entropy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.31\n", +"//Page number - 268\n", +"printf('Example - 7.31 and Page number - 268\n\n');\n", +"\n", +"// The clapeyron equation is\n", +"// (dP/dT)_sat = delta_H_fus/(T*delta_V_fus)\n", +"\n", +"//(1)\n", +"// At 1 bar\n", +"// Considering the data given at pressure 1 and 1000 bar, we have\n", +"delta_H_fus_1 = ((1000-1)*10^(5)*(273.15-22.6)*3.97*10^(-6))/(14.8+22.6);//[J/mol]\n", +"delta_S_fus_1 = delta_H_fus_1/(273.15-22.6);//[J/mol-K]\n", +"\n", +"printf(' (1).The delta_H_fus at 1 bar is %f J/mol\n',delta_H_fus_1);\n", +"printf(' The delta_S_fus at 1 bar is %f J/mol-K\n\n',delta_S_fus_1);\n", +"\n", +"//(2)\n", +"// At 6000 bar\n", +"T_mean = (128.8+173.6)/2;//[C] - Mean temperature\n", +"T_mean = T_mean + 273.15;//[K]\n", +"delta_V_fus_mean = (1.12+1.55)/2;//[cm^(3)/mol]\n", +"\n", +"// Consider the data at pressure of 5000 and 7000 bar we get,\n", +"delta_H_fus_2 = ((7000-5000)*10^(5)*(T_mean*delta_V_fus_mean*10^(-6)))/(173.6-128.8);//[J/mol]\n", +"delta_S_fus_2 = delta_H_fus_2/T_mean;//[J/mol-K]\n", +"\n", +"printf(' (2).The delta_H_fus at 6000 bar is %f J/mol\n',delta_H_fus_2);\n", +"printf(' The delta_S_fus at 6000 bar is %f J/mol-K\n\n',delta_S_fus_2);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.32: Estimation_of_ratio_of_temperature_change_and_pressure_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.32\n", +"//Page number - 268\n", +"printf('Example - 7.32 and Page number - 268\n\n');\n", +"\n", +"//Given\n", +"H_fus = 80;//[cal/g] - Heat of fusion at 0 C and 1 atm pressure\n", +"T = 0+273.15;//[K] - Temperature\n", +"vol_ratio = 1.091;// Ratio of the specific volume of ice and water.\n", +"sp_vol = 0.001;//[m^(3)/kg] - Specific volume of saturated liquid water.\n", +"\n", +"// The clapeyron equation can be written as\n", +"// (dP/dT)_sat = T*delta V_LS/(delta H_LS) = (T*(V_ice - V_water))/(H_ice - H_water)\n", +"dP_dT = (T*(vol_ratio - 1)*10^(-3))/(-H_fus*4.186);//[K/kPa]\n", +"\n", +"printf('The value of (dT/dP)_sat is %e K/kPa',dP_dT);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.33: Determination_of_boiling_point_of_water.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.33\n", +"//Page number - 268\n", +"printf('Example - 7.33 and Page number - 268\n\n');\n", +"\n", +"//Given\n", +"P = 2;//[atm] - Surrounding pressure\n", +"bp_water = 100 + 273.15;//[K] - Boiling point of water at 1 atm pressure\n", +"delta_H_vap = 2257;//[kJ/kg] - Enthalpy of vaporization\n", +"delta_H_vap = delta_H_vap*18.015;//[J/mol]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// The clapeyron equation is given by\n", +"// log(P_2_sat/P_1_sat) = (-delta H_vap/R)*(1/T_2 - 1/T_1)\n", +"P_1_sat = 1;//[atm]\n", +"P_2_sat = P;\n", +"T_1 = bp_water;\n", +"\n", +"// Solving the above equation\n", +"T_2 = 1/((log(P_2_sat/P_1_sat))/(-delta_H_vap/R) + (1/T_1));//[K]\n", +"T_2 = T_2 - 273.15;//[C]\n", +"\n", +"printf(' The boiling point of water at a pressure of 2 atm is %f C',T_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.34: Calculation_of_enthalpy_and_entropy_of_vaporization_of_water.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 7.34\n", +"//Page number - 269\n", +"printf('Example - 7.34 and Page number - 269\n\n');\n", +"//Given\n", +"T_1 = 0.01 +273.15;//[K]\n", +"T_2 = 1 + 273.15;//[K]\n", +"P_sat_1 = 0.611;//[kPa] - P_sat at temperature T_1\n", +"P_sat_2 = 0.657;//[kPa] - P_sat at temperature T_2\n", +"Mol_wt = 18.015;//[g/mol] - Molecular weight of water\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"// The clapeyron equation is given by\n", +"// log(P_sat_2/P_sat_1) = (-delta H_LV/R)*(1/T_2 - 1/T_1)\n", +"// Solving the above equation\n", +"delta_H = -(log(P_sat_2/P_sat_1)/(1/T_2 - 1/T_1))*R;//[J/mol]\n", +"delta_H = delta_H/Mol_wt;//[kJ/kg]\n", +"printf(' The enthalpy of vaporization is %f kJ/kg\n',delta_H);\n", +"// Entropy of vaporization is given by\n", +"S_vap = delta_H/T_2;//[kJ/kg-K]\n", +"printf(' The entropy of vaporization is %f kJ/kg-K',S_vap);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.35: Estimation_of_heat_of_vaporization_of_water.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.35\n", +"//Page number - 269\n", +"printf('Example - 7.35 and Page number - 269\n\n');\n", +"\n", +"//Given\n", +"T = 100 + 273.15;//[K]\n", +"// (dT/dP)_sat = (1/27.12) K/mm\n", +"dT_dP = (1/27.12);//[K/mm]\n", +"dT_dP = dT_dP*(760/101325);//[K/Pa]\n", +"\n", +"// The clapeyron equation is given by\n", +"// (dP/dT)_sat = (-delta H_LV)/(T*delta V_LV)\n", +"// delta H_LV = T*delta V_LV*(dP/dT)_sat\n", +"\n", +"// (dP/dT)_sat = 1/(dT/dP)_sat\n", +"dP_dT = 1/dT_dP;//[Pa/K]\n", +"\n", +"// From saturated steam table at 100 C\n", +"V_vap = 1.6729;//[m^(3)/kg]\n", +"V_liq = 0.001044;//[m^(3)/kg]\n", +"delta_V = V_vap - V_liq;//[m^(3)/kg]\n", +"\n", +"// Therefore delta_H_LV is given by\n", +"delta_H_LV = T*delta_V*(dP_dT);//[J/kg]\n", +"delta_H_LV = delta_H_LV*10^(-3);//[kJ/kg]\n", +"\n", +"printf(' The heat of vaporization of water is %f kJ/kg\n',delta_H_LV);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.36: Calculation_of_latent_heat_of_vaporization.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.36\n", +"//Page number - 270\n", +"printf('Example - 7.36 and Page number - 270\n\n');\n", +"\n", +"//Given\n", +"T_1 = 100 + 273.15;//[K]\n", +"P_1 = 1.01325;//[bar]\n", +"T_2 = 98 + 273.15;//[K]\n", +"P_2 = 0.943;//[bar]\n", +"V_vap = 1.789;//[m^(3)] - Volume in vapour phase\n", +"vessel_vol = 1.673;//[m^(3)] - Volume of the vessel\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// The total volume remains constant as the walls are rigid. At 98 C we get\n", +"// vessel_vol = V_liq*(1 - x) + V_vap*x\n", +"// Since V_liq is negligible as compared to V_vap, therefore\n", +"x = vessel_vol/V_vap;\n", +"\n", +"// The quantity is given by x = m_vap/(m_liq + m_vap)\n", +"// Since (m_liq + m_vap) = 1, therefore at 98 C saturated vapour is x and saturated liquid is (1 - x)\n", +"m_vap = x;//[kg] - Mass of saturated vapour\n", +"m_liq = (1 - x);//[kg] - Mass of saturated liquid\n", +"\n", +"printf(' The amount of vapour condensed is %f kg\n',m_liq);\n", +"\n", +"// The clapeyron equation is given by\n", +"// log(P_2_sat/P_1_sat) = (-delta H_LV/R)*(1/T_2 - 1/T_1)\n", +"\n", +"// Solving the above equation\n", +"delta_H = -(log(P_2/P_1)/(1/T_2 - 1/T_1))*R;\n", +"delta_H = delta_H/18.015;//[kJ/kg]\n", +"\n", +"printf(' The latent heat of vaporization is %f kJ/kg\n',delta_H);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.37: Determination_of_temperature_dependence.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.37\n", +"//Page number - 270\n", +"printf('Example - 7.37 and Page number - 270\n\n');\n", +"\n", +"//Given\n", +"T_1 = 298.15;//[K] - Standard reaction temperature\n", +"delta_H_gas = -52.23;//[kcal/mol] - Enthalpy of formation of C2H5OH(gas)\n", +"delta_H_liq = -66.35;//[kcal/mol] - Enthalpy of formation of C2H5OH(liq)\n", +"\n", +"// For ethanol(g) [T is in K and Cp_0 in cal/mol-K]\n", +"// Cp_0 = 4.75 + 5.006*10^(-2)*T - 2.479*10^(-5)*T^(2) + 4.79*10^(-9)*T^(3)\n", +"\n", +"// For ethanol(l) [T is in K and Cp_0 in cal/mol-K]\n", +"// Cp_0 = 67.29 - 0.343*T - 6.94*10^(-4)*T^(2)\n", +"\n", +"// The vaporization of a liquid can be written as C2H5OH(liq) - C2H5OH(gas)\n", +"// Since the pressure is 1 atm therefore the standard data can be used\n", +"delta_H_298 = delta_H_gas - delta_H_liq;//[kcal/mol]\n", +"delta_H_298 = delta_H_298*1000;//[cal/mol]\n", +"delta_a = 4.75 - 67.29;\n", +"delta_b = 5.006*10^(-2) - (-0.343);\n", +"delta_c = -2.479*10^(-5) - 6.94*10^(-4);\n", +"delta_d = 4.79*10^(-9);\n", +"\n", +"// The standard enthalpy of vaporization at a temperature T is given by\n", +"// delta_H_T = delta_H_298 + integrate('delta_a + delta_b*T + delta_c*T^(2) + delta_d*T^(3)','T',T_1,T);//[cal/mol]\n", +"\n", +"// Therefore the standard enthalpy of vaporization at a temperature T = 283 K is given by\n", +"T_2 = 283;//[K]\n", +"delta_H_283 = delta_H_298 + integrate('delta_a+delta_b*T+delta_c*T^(2)+delta_d*T^(3)','T',T_1,T_2);//[cal/mol]\n", +"\n", +"// Therefore the standard enthalpy of vaporization at a temperature T = 348 K is given by\n", +"T_3 = 348;//[K]\n", +"delta_H_348 = delta_H_298 + integrate('delta_a+delta_b*T+delta_c*T^(2)+delta_d*T^(3)','T',T_1,T_3);//[cal/mol]\n", +"\n", +"// From the values of standard enthalpy of vaporization obtained above at 283, 298, and 348 K, it is clear that enthalpy decreases with increase in temperature\n", +"printf(' The value of enthalpy of vaporization at 283 K is %f cal/mol\n',delta_H_283);\n", +"printf(' The value of enthalpy of vaporization at 298.15 K is %f cal/mol\n',delta_H_298);\n", +"printf(' The value of enthalpy of vaporization at 348 K is %f cal/mol\n',delta_H_348);\n", +"printf(' Therefore standard enthalpy of vaporization decrease with the increase in temperature\n\n');\n", +"\n", +"// Solving the above equatio manually we get,\n", +"// delta_H_vap = 1.1975*10^(-9)*T^(4) - 2.396*10^(-4)*T^(3) + 0.1965*T^(2) - 62.54*T + 21639.54 \n", +"// Solving for 'T' at which 'delta_H_vap' = 0\n", +"deff('[y]=f(T)','y=1.1975*10^(-9)*T^(4)-2.396*10^(-4)*T^(3)+0.1965*T^(2)-62.54*T + 21639.54');\n", +"T_0 = fsolve(500,f);//[J/mol]\n", +"\n", +"// We know that at critical point (critical temperature and critical pressure) the enthalpy of vaporization is zero.\n", +"// Here we have made the standard enthalpy of vaporization equal to zero which is at standard pressure of 1 atm.\n", +"// Therefore following conclusions can be drawn\n", +"printf(' The temperature obtained by equating standard enthalpy of vaporization equal to zero is %f K\n',T_0);\n", +"printf(' But the critical temperature of ethanol is 513.9 K, which is far from the temperature obtained above\n')\n", +"printf(' Therefore the temperature obtained by equating standard enthalpy of vaporization equal to zero is not the critical temperature')\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.38: Calculation_of_fugacity_of_water.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.38\n", +"//Page number - 276\n", +"printf('Example - 7.38 and Page number - 276\n\n');\n", +"\n", +"//Given\n", +"T = 300 + 273.15;//[K] - Temperature\n", +"P = 9000;//[kPa] - Pressure\n", +"P_sat = 8592.7;//[kPa] - Vapour pressure of saturated water at 300 C\n", +"f_sat = 6738.9;//[kPa] - Fugacity of saturated water at 300 C\n", +"V_liq = 25.28;//[cm^(3)/mol] - Molar volume of water in liquid phase\n", +"V_liq = V_liq*10^(-6);// [m^(3)/mol]\n", +"V_vap = 391.1;//[cm^(3)/mol] - Molar volume of water in vapour phase\n", +"V_vap = V_vap*10^(-6);// [m^(3)/mol]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// At 300 C and 9000 kPa water is a compressed liquid and its fugacity is given by\n", +"// f = f_sat*exp[V_liq*(P - P_sat)/R*T]\n", +"fugacity = f_sat*exp((V_liq*(P - P_sat)*1000)/(R*T));\n", +"\n", +"printf(' The fugacity of water at 9000 kPa is %f kPa',fugacity);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.39: Estimation_of_fugacity_of_saturated_steam.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.39\n", +"//Page number - 276\n", +"printf('Example - 7.39 and Page number - 276\n\n');\n", +"\n", +"//Given\n", +"T = 200 + 273.15;//[K] - Temperature\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// From steam table at 200 C as reported in the book\n", +"P_sat = 1.5538;//[MPa] - Vapour pressure of saturated steam\n", +"H_vap = 2793.2;//[kJ/kg] - Enthalpy of saturated steam in vapour phase\n", +"S_vap = 6.4323;//[kJ/kg-K] - Entropy of saturated steam in vapour phase\n", +"G_sat = H_vap - T*S_vap;//[kJ/kg] - Gibbs free energy\n", +"G_sat = G_sat*18.015;//[J/mol]\n", +"\n", +"// Now let us calculate the Gibbs free energy at the lowest pressure available in superheated steam tables at 200 C\n", +"// At 200 C and 0.01 MPa as reported in the book\n", +"H = 2879.5;//[kJ/kg] - Enthalpy\n", +"S = 8.9038;//[kJ/kg-K] - Entropy\n", +"G_ig = H - T*S;//[kJ/kg] - Gibbs free energy\n", +"G_ig = G_ig*18.015;//[J/mol]\n", +"\n", +"// Integrating from ideal gas state at 200 C and 0.01 MPa to saturated vapour at 200 C we get\n", +"// G_sat - G_ig = R*T*log(f_sat/f_ig)\n", +"\n", +"// Under the ideal gas condition the pressure is small therefore f_ig = P = 0.01 MPa\n", +"f_ig = 0.01;//[MPa]\n", +"\n", +"// Solving the above equation\n", +"f_sat = f_ig*(exp((G_sat - G_ig)/(R*T)));//[MPa]\n", +"\n", +"printf(' The fugacity of saturated steam at 200 C is %f MPa',f_sat);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.3: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.3\n", +"//Page number - 236\n", +"printf('Example - 7.2 and Page number - 236\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.3 on page number 236 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.3 on page number 236 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.40: Estimation_of_fugacity_of_steam.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.40\n", +"//Page number - 277\n", +"printf('Example - 7.40 and Page number - 277\n\n');\n", +"\n", +"// Given\n", +"T = 320 + 273.15;//[K]\n", +"P_1 = 70;//[bar]\n", +"P_2 = 170;//[bar]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"//(a)\n", +"// dG = R*T*dlog(f)\n", +"// G - G_ig = R*T*log(f/f_ig)\n", +"\n", +"// From steam table the low pressure that is available is 1 kPa.\n", +"f_ig = 1;//[kPa] - Assuming ideal gas behaviour at such low pressure\n", +"\n", +"// At 1 kPa (under saturated conditions)\n", +"P_sat = 112.891;//[bar]\n", +"// Therefore at both 1 kPa and 70 bar the stem is superheated and byond a pressure of 112.891 bar it is compressed liquid.\n", +"\n", +"// For superheated steam table at 1 kPa and 320 C, as repoted in the book\n", +"H_1 = 3117.08;//[kJ/kg] - Enthalpy\n", +"S_1 = 10.41232;//[kJ/kg-K] - Entropy\n", +"\n", +"// For superheated steam table at 70 bar and 320 C, as repoted in the book\n", +"H_2 = 2916.92;//[kJ/kg] - Enthalpy\n", +"S_2 = 6.0651;//[kJ/kg-K] - Entropy\n", +"\n", +"// At 70 bar and 320 C,\n", +"G = H_2 - T*S_2;//[kJ/kg] - Gibbs free energy\n", +"// At 1 kPa and 320 C\n", +"G_ig = H_1 - T*S_1;//[kJ/kg] - Gibbs free energy\n", +"\n", +"// log(f/f_ig) = (G - G_ig)/(R*T)\n", +"f = f_ig*(exp((G - G_ig)*18/(R*T)));//[kPa]\n", +"f = f*10^(-2);//[bar]\n", +"\n", +"// At 70 bar\n", +"phi = f/P_1;\n", +"\n", +"printf(' (a).The fugacity of steam at 320 C and 70 bar is %f bar\n',f);\n", +"printf(' The fugacity coefficient at 320 C and 70 bar is, phi = %f\n\n',phi);\n", +"\n", +"//(b)\n", +"// Now consider saturated steam at 320 C. We have\n", +"P_sat = 112.891;//[bar]\n", +"V_liquid = 1.5;//[cm^(3)/mol] - Molar vlume of saturated liquid\n", +"V_liquid = V_liquid*10^(-6);//[m^(3)/mol]\n", +"V_vapour = 15.48;//[cm^(3)/mol] - Molar vlume of saturated vapour\n", +"U_liqid = 1445.7;//[Kj/kg] - Internal energy of satuarted liquid\n", +"U_vapour = 2528.9;//[kJ/kg] - Internal energy of satuarted vapour\n", +"H_liquid = 1462.6;//[kJ/kg] - Enthalpy of saturated liquid\n", +"H_vapour = 2703.7;//[kJ/kg] - Enthalpy of saturated vapour\n", +"S_liquid = 3.45;//[kJ/kg-K] - Entropy of saturated liquid\n", +"S_vapour = 5.5423;//[kJ/kg-K] - Entropy of saturated vapour\n", +"\n", +"// Now let us calculate Gibbs free energy of saturated liquid and saturated vapour\n", +"G_liquid = H_liquid - T*S_liquid;//[kJ/kg]\n", +"G_vapour = H_vapour - T*S_vapour;//[kJ/kg]\n", +"// Note that under saturated conditions\n", +"// G_sat = G_liquid = G_vapour\n", +"G_sat = G_liquid;//[kJ/kg]\n", +"\n", +"// log(f_sat/f_ig) = (G_sat - G_ig)/(R*T)\n", +"f_sat = f_ig*(exp((G_sat - G_ig)*18/(R*T)));//[kPa]\n", +"f_sat = f_sat*10^(-2);//[bar]\n", +"\n", +"phi_sat = f_sat/P_sat;\n", +"\n", +"// And now the fugacity is to be determined at 320 C and P = 170 bar. We know the following relation for compressed liquid.\n", +"// f_CL = f_sat*exp(V_liquid*(P-P_sat)/(R*T))\n", +"f_CL = f_sat*exp(V_liquid*18*(P_2-P_sat)*10^(5)/(R*T));//[bar]\n", +"\n", +"// Therefore the fugacity coefficient at 170 bar and 320 C is given by\n", +"phi_2 = f_CL/P_2;\n", +"\n", +"printf(' (b).The fugacity of steam at 320 C and 170 bar is %f bar\n',f_CL);\n", +"printf(' The fugacity coefficient at 320 C and 170 bar is, phi = %f\n\n',phi_2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.41: Determination_of_fugacities_at_two_states.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.41\n", +"//Page number - 278\n", +"printf('Example - 7.41 and Page number - 278\n\n');\n", +"\n", +"//Given\n", +"T = 300 + 273.15;//[K]\n", +"P_1 = 12500*10^(3);//[Pa]\n", +"P_2 = 8581*10^(3);//[Pa]\n", +"P_3 = 300*10^(3);//[Pa]\n", +"V_liq = 1.404;//[cm^(3)/g] - Specific volume of liquid\n", +"V_liq = (V_liq/10^(6))*18.015;//[m^(3)/mol]\n", +"R = 8.314;//[J/mol*K] - Universal gas constant\n", +"\n", +"// state 1: 300 C, 12500 kPa\n", +"// state 2: 300 C, 8581 kPa\n", +"// state 3: 300 C, 300 kPa\n", +"\n", +"// From state 1 to state 2 the system is liquid water and if the molar volume of liquid is assumed costant we can write\n", +"// G_2 - G_1 = V_liq*(P_2 - P_1)\n", +"// G_2 - G_1 = R*Tlog(f_2/f_1)\n", +"// Comparing the above two equations we get\n", +"// (f_2/f_1) = exp((V_liq*(P_2 - P_1)/(R*T))\n", +"f2_f1 = exp((V_liq*(P_2 - P_1)/(R*T))); // (f_2/f_1) = f2_f1 (say)\n", +"\n", +"// In state 2 the fugacity of liquid is same as that of saturated vapour and for the vapour phase change from state 2 to 3 the fugacity ratio is calculated using \n", +"// G_3 - G_2 = R*Tlog(f_3/f_2)\n", +"\n", +"// At 300 C, 8581 kPa \n", +"H_liq_2 = 2749.0;//[kJ/kg]\n", +"S_vap_2 = 5.7045;//[kJ/kg-K]\n", +"G_vap_2 = -520.53;//[kJ/kg]\n", +"G_vap_2 = G_vap_2*18.015;//[J/mol]\n", +"\n", +"// At 300 C, 300 kPa \n", +"H_3 = 3069.3;//[kJ/kg]\n", +"S_3 = 7.7022;//[kJ/kg-K]\n", +"G_3 = -1345.22;//[kJ/kg]\n", +"G_3 = G_3*18.015;//[J/mol]\n", +"\n", +"// Substituting and solving the equation G_3 - G_2 = R*Tlog(f_3/f_2)\n", +"f3_f2 = exp((G_3 - G_vap_2)/(R*T));// (f_3/f_2) = f3_f2 (say)\n", +"\n", +"// (f_3/f_1) = (f_3/f_2)*(f_2/f_1)\n", +"f3_f1 = f3_f2*f2_f1;\n", +"\n", +"printf(' The ratio of fugacity in the final state to that in the initial state is given by f3/f2 = %f',f3_f2);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.4: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.4\n", +"//Page number - 240\n", +"printf('Example - 7.4 and Page number - 240\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.4 on page number 240 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.4 on page number 240 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.5: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.5\n", +"//Page number - 240\n", +"printf('Example - 7.5 and Page number - 240\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.5 on page number 240 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.5 on page number 240 of the book.');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.6: Estimation_of_entropy_change.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.6\n", +"//Page number - 241\n", +"printf('Example - 7.6 and Page number - 241\n\n');\n", +"\n", +"//Given\n", +"P_1 = 1;//[MPa] - Initial pressure\n", +"P_2 = 1.4;//[MPa] - Final pressure\n", +"\n", +"//We know that\n", +"// dS = (Cp/T)*dT - (dV/dT)*dP\n", +"// Along an isothermal path,integration of above expression between states 1 and 2 yields\n", +"// S_2 - S_1 = - integral((dV/dT)*dP)_P\n", +"// An estimate can be made by assuming that (dV/dT)_P remains constant over the range of pressure from P_1 to P_2 and evaluating the derivative at average pressure of 1.2 MPa\n", +"P_avg = P_2;\n", +"// S_2 - S_1 = -integral((dV/dT)*dP)_Pavg*(P_2 - P_1)\n", +"// (dV/dT)_P=1.2MPa = ((V_350 - V_250)/(350 - 250))\n", +"dV_dT = (0.2345 - 0.19234)/100;//[m^(3)/kg-K]\n", +"//Therefore\n", +"delta_S = -dV_dT*(P_2 - P_1)*1000;//[kJ/kg-K] - Entropy change\n", +"\n", +"printf('The change in entropy is given by\n S_2-S_1 = %f kJ/kg-K',delta_S);\n", +"\n", +"//Let us compare this tabulated values. At 1MPA and 300 C, S_1 = 7.1229 kJ/kg-K. At 1.4 MPa and 300 C, S_2 = 6.9534 kJ/kg-K. \n", +"//Therefore S_2 - S_1 = -0.1695 kJ/kg-K\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.7: Determination_of_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.7\n", +"//Page number - 241\n", +"printf('Example - 7.7 and Page number - 241\n\n');\n", +"\n", +"//Given\n", +"T = 25 + 273.15;//[K] - Temperature of the surrounding\n", +"P_1 = 1;//[atm] - Initial pressure\n", +"P_2 = 1000;//[atm] - Final pressure\n", +"\n", +"// V = 18.066 - 7.15*10^(-4)*P + 4.6*10^(-8)*P^(2) where, V is in 'cm^(3)/mol' and P is in 'atm\n", +"// (dV/dT)_P = 0.0045 + 1.4*10^(-6)*P ;//cm^(3)/mol-K\n", +"\n", +"// The work done by 1 mol is given by W = integral(P*dV)\n", +"// Differentiating both sides of the expression for V, we get\n", +"// dV = -7.15*10^(-4)*dP + 9.2*10^(-8)*(P*dP) \n", +"// P*dV = -7.15*10^(-4)*P*dP + 9.2*10^(-8)*(P^(2)*dP)\n", +"\n", +"// The work done is given by\n", +"W = integrate('-7.15*10^(-4)*P + 9.2*10^(-8)*(P^(2))','P',P_1,P_2);//[atm-cm^(3)/mol]\n", +"W = W*101325*10^(-6);//[J/mol]\n", +"\n", +"printf('The necessary work to compress water from 1 atm to 1000 atm is %f J/mol\n\n',W);\n", +"\n", +"//Let us calculate the amount of heat transfer\n", +"// q = integral(T*dS)\n", +"// dS = ((ds/dT)_P)*dT + ((dS/dP)_T)*dP\n", +"// Since the temperature is constant the first term is zero and\n", +"// dS = ((dS/dP)_T)*dP = -((dV/dT)_P)*dP\n", +"// Thus, q = integral(T*dS) = T*(integral(dS)) ( as temperature is constant )\n", +"// or, q = -T*(integral((dV/dT)_P)*dP)\n", +"\n", +"// Thus the heat transfer is given by\n", +"q = -T*integrate('0.0045+1.4*10^(-6)*P','P',P_1,P_2);//[atm-cm^(3)/mol]\n", +"q = q*101325*10^(-6);//[J/mol]\n", +"\n", +"// q - W = delta_U\n", +"// Thus delta_U is given by\n", +"delta_U = q - W;//[J/mol]\n", +"\n", +"printf('The change in internal energy is %f J/mol',delta_U);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.8: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.8\n", +"//Page number - 243\n", +"printf('Example - 7.8 and Page number - 243\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.8 on page number 243 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.8 on page number 243 of the book.')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.9: Proving_a_mathematical_relation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 7.9\n", +"//Page number - 244\n", +"printf('Example - 7.9 and Page number - 244\n\n');\n", +"\n", +"//This problem involves proving a relation in which no numerical components are involved.\n", +"//For prove refer to this example 7.9 on page number 244 of the book.\n", +"printf(' This problem involves proving a relation in which no numerical components are involved.\n\n');\n", +"printf(' For prove refer to this example 7.9 on page number 244 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 +} diff --git a/Chemical_Engineering_Thermodynamics_by_P_Ahuja/8-Thermodynamic_Cycles.ipynb b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/8-Thermodynamic_Cycles.ipynb new file mode 100644 index 0000000..636576d --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_P_Ahuja/8-Thermodynamic_Cycles.ipynb @@ -0,0 +1,704 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 8: Thermodynamic Cycles" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.10: Determination_of_temperature_of_air.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 8.10\n", +"//Page number - 307\n", +"printf('Example - 8.10 and Page number - 307\n\n');\n", +"\n", +"//Given\n", +"P_high = 40;//[bar]\n", +"P_low = 5;//[bar]\n", +"m_1 = 0.5;//[kg/s] - Rate of mass moving through the expander\n", +"m_2 = 0.1;//[kg/s] - Rate of mass of vapour mixing with air\n", +"e = 0.7;//Efficiency\n", +"\n", +"//At state 3,(40 bar and 200 K),enthalpy and entropy is given by\n", +"H_3 = 179.7;//[kJ/kg]\n", +"S_3 = 5.330;//[kJ/kg-K]\n", +"\n", +"//If isentropic conditions exits in the turbine then state 11 is at 5 bar\n", +"S_11 = 5.330;//[kJ/kg-K]\n", +"//From given compressed air tables at 5 bar and 120 K,\n", +"H_11_1 = 113.6;//[kJ/kg]\n", +"S_11_1 = 5.455;//[kJ/kg-K]\n", +"//At 5 bar and 100 K \n", +"H_11_2 = 90.6;//[kJ/kg]\n", +"S_11_2 = 5.246;//[kJ/kg-K]\n", +"//The enthalpy has to be determined when S = S_3\n", +"//Solving by interpolation we get\n", +"H_11_s = ((H_11_1 - H_11_2)*(S_3 - S_11_2))/(S_11_1 - S_11_2) + H_11_2;//[kJ/kg]\n", +"\n", +"//The adiabatic efficiency of tyrbine is given by\n", +"//(H_3 - H_11_a)/(H_3 - H_11_s) = e\n", +"H_11_a = H_3 - e*(H_3 - H_11_s);//[kJ/kg] - Actual enthalpy\n", +"\n", +" //At 5 bar,the saturated enthalpy is given to be\n", +"H_8 = 88.7;//[kJ/kg]\n", +"//From enthalpy balance during mixing we get,\n", +"//0.1*H_8 + 0.5*H_11_a = 0.6*H_9\n", +"H_9 = (m_2*H_8 + m_1*H_11_a)/(m_1 + m_2);//[kJ/kg]\n", +"\n", +"//From given compressed air tables at 5 bar and 140 K,\n", +"H_9_1 = 135.3;//[kJ/kg]\n", +"//At 5 bar and 120 K \n", +"H_9_2 = 113.6;//[kJ/kg]\n", +"//By interpolation we get\n", +"T_9 = ((H_9 - H_11_1)*(140 - 120))/(H_9_1 - H_11_1) + 120;//[K]\n", +"\n", +"printf(' The temperature of air entering the second heat exchanger is %f K\n\n',T_9);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.1: Calculation_of_work_done.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//Example - 8.1\n", +"//Page number - 287\n", +"printf('Example - 8.1 and Page number - 287\n\n');\n", +"//Given\n", +"P_1 = 30;//[bar]\n", +"P_2 = 0.04;//[bar]\n", +"//(1).Carnot cycle\n", +"//It has been reported in the book that at 30 bar pressure (saturated) :\n", +"H_liq_1 = 1008.42;//[kJ/kg]\n", +"H_vap_1 = 2804.2;//[kJ/kg]\n", +"S_liq_1 = 2.6457;//[kJ/kg-K]\n", +"S_vap_1 = 6.1869;//[kJ/kh-K]\n", +"//Therefore, H_1 = H_liq_1, H_2 = H_vap_1, S_1 = S_liq_1 and S_2 = S_vap_1\n", +"H_1 = H_liq_1;\n", +"H_2 = H_vap_1;\n", +"S_1 = S_liq_1;\n", +"S_2 = S_vap_1;\n", +"//At 0.04 bar pressure (saturated) :\n", +"H_liq_2 = 121.46;//[kJ/kg]\n", +"H_vap_2 = 2554.4;//[kJ/kg]\n", +"S_liq_2 = 0.4226;//[kJ/kg-K]\n", +"S_vap_2 = 8.4746;//[kJ/kh-K]\n", +"//Dryness fraction at state 3 can be found the fact that S_3 = S_2 \n", +"x_3 = (S_2 - S_liq_2)/(S_vap_2 - S_liq_2);\n", +"H_3 = H_liq_2*(1 - x_3) + x_3*H_vap_2;//[kJ/kg]\n", +"//Dryness fraction at state 4 can be found the fact that S_4 = S_1\n", +"x_4 = (S_1 - S_liq_2)/(S_vap_2 - S_liq_2);\n", +"H_4 = H_liq_2*(1 - x_4) + x_4*H_vap_2;//[kJ/kg]\n", +"//Work done by turbine W_tur = -delta_H = -(H_3 - H_2)\n", +"W_tur = H_2 - H_3;//[kJ/kg]\n", +"//Work supplied by boiler,\n", +"q_H = H_2 - H_1;//[kJ/kg]\n", +"//Work transfer in compressor is given by\n", +"W_com = -(H_1 - H_4);//[kJ/kg]\n", +"//Efficiency can now be calculated as\n", +"//n = (Net work done/Work supplied by boiler)\n", +"n_carnot = (W_tur + W_com)/q_H;\n", +"//Efficiency of the Carnot cycle can also be determined from the formula\n", +"// n = 1 - (T_L/T_H), Where T_L is saturated temperature at 0.04 bar and T_H is saturated temperature at 30 bar\n", +"printf('(1).Carnot cycle\n\n');\n", +"printf('The work done by the turbine is %f kJ/kg\n\n',W_tur);\n", +"printf('The heat transfer in the boiler is %f kJ/kg\n\n',q_H);\n", +"printf('The cycle efficiency is %f\n\n\n',n_carnot);\n", +"//(2).Rankine cycle\n", +"//The enthalpies at state 2 and 3 remain as in the Carnot cycle\n", +"//Saturated liquid enthalpy at 0.04 bar is \n", +"H_4_prime = H_liq_2;\n", +"//Saturated liquid volume at 0.04 bar as reported in the book is\n", +"V_liq = 0.001004;//[m^(3)/kg]\n", +"//Work transfer in pump can be calculated as\n", +"W_pump = -V_liq*(P_1 - P_2)*100;//[kJ/kg]\n", +"//Work transfer around pump gives, W_pump = -delta_H = -(H_1_prime - H_4_prime);\n", +"H_1_prime = H_4_prime - W_pump;//[kJ/kg]\n", +"//Heat supplied to boiler is\n", +"q_H_prime = H_2 - H_1_prime;//[kJ/kg]\n", +"//Work done by turbine is\n", +"W_tur_prime = H_2 - H_3;//[kJ/kg]\n", +"//Efficiency can now be calculated as\n", +"//n = (Net work done/Heat input)\n", +"n_rankine = (W_tur_prime + W_pump)/q_H_prime;//\n", +"printf('(2).Rankine cycle\n\n');\n", +"printf('The work done by the turbine is %f kJ/kg\n\n',W_tur_prime);\n", +"printf('The heat transfer in the boiler is %f kJ/kg\n\n',q_H_prime);\n", +"printf('The cycle efficiency is %f',n_rankine);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.2: Calculation_of_efficiency_of_Rankine_cycle.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 8.2\n", +"//Page number - 288\n", +"printf('Example - 8.2 and Page number - 288\n\n');\n", +"\n", +"//Given\n", +"T_max = 700+273.15;//[K] - Maximum temperature.\n", +"P_boiler = 10*10^(6);//[Pa] - Constant pressure in the boiler\n", +"P_condenser = 10*10^(3);//[Pa] - Constant pressure in the condenser\n", +"\n", +"//At state 2 i.e, at 700 C and 10 MPa,it has been reported in the book that from steam table\n", +"S_2 = 7.1687;//[kJ/kg-K] - Entropy\n", +"H_2 = 3870.5;//[kJ/kg] - Enthalpy\n", +"\n", +"//At state 3 i.e, at 700 C and 10 KPa,\n", +"S_3 = S_2;//[kJ/kg-K]- Entropy \n", +"\n", +"//For sturated steam at 10 kPa, it has been reported in the book that from steam table\n", +"S_liq = 0.6493;//[kJ/kg-K]- Entropy of saturated liquid\n", +"S_vap = 8.1502;//[kJ/kg-K] - Enthalpy of saturated liquid\n", +"//Therefore steam is saturated and its dryness factor can be calculated as\n", +"x = (S_2 - S_liq)/(S_vap - S_liq);\n", +"\n", +"//The enthalpy at state 3 is now calculated. For steam at 10 kPa,it has been reported in the book that from steam table\n", +"H_liq = 191.83;//[kJ/kg]\n", +"H_vap = 2584.7;//[kJ/kg]\n", +"//Therefore enthalpy at state 3 is\n", +"H_3 = H_liq*(1-x) + H_vap*x;//[kJ/kg]\n", +"\n", +"//Work done by the turbine \n", +"W_tur = -(H_3 - H_2);//[kJ/kg]\n", +"\n", +"//Now we have to calculate work input to the pump\n", +"//State 4:Saturated liquid at 10 kPa\n", +"//State 4:Compressed liquid at 10 MPa\n", +"//Since volume of liquid does not get affected by pressure we take volume of saturated liquid at 10 kPa,\n", +"V_liq = 0.001010;//[m^(3)/kg]\n", +"\n", +"//Work transfer in the pump is\n", +"W_pump = -V_liq*(P_boiler - P_condenser)*10^(-3);//[kJ/kg]\n", +"\n", +"//Energy balance around pump gives, W_pump = -delta_H = -(H_1 - H_4)\n", +"H_4 = H_liq;// Enthalpy at state 4 (saturated liquid at 10 kPa)\n", +"H_1 = H_4 - W_pump;//[kJ/kg]\n", +" \n", +"//Heat supplied to boiler is\n", +"q_H = H_2 - H_1;//[kJ/kg]\n", +"\n", +"//Efficiency can now be calculated as\n", +"//n = (Net work done/Heat input)\n", +"n_rankine = (W_tur + W_pump)/q_H;\n", +"\n", +"printf('The efficiency of the Rankine cycle is found to be %f',n_rankine);\n", +"\n", +"//Now let us determine the efficiency of Carnot cycle. The maximun temperature is 700 C and minimum temperature is that of saturated steam at 10 kPa,\n", +"T_min = 45.81 + 273.15;//[K] - From steam table as reported in the book\n", +"n_carnot = 1-(T_min/T_max);\n", +"//Note that the efficiency of Rankine cycle is less than that of carnot cycle.\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.3: Calculatrion_of_COP_of_carnot_refrigerator_and_heat_rejected.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 8.3\n", +"//Page number - 291\n", +"printf('Example - 8.3 and Page number - 291\n\n');\n", +"\n", +"//Given\n", +"W = 1.1;//[kW] - Work done per ton of refrigeration \n", +"//1 ton refrigeration = 3.517 kW, therefore\n", +"H = 3.517;//[kW] - Heat absorbed\n", +"T_low = -30 + 273.15;//[K] - Low temperature maintained\n", +"\n", +"//COP can be calculated as\n", +"//COP = (Heat absorbed/Work done)\n", +"COP = H/W;\n", +"\n", +"//For reversed carnot cycle, COP = T_low/(T_high - T_low). Solving this we get\n", +"T_high = (T_low/COP) + T_low;//[K] - Higher temperature\n", +"\n", +"//Heat rejected is\n", +"H_rej = W + H;//[kW];\n", +"\n", +"printf('The COP is %f\n\n',COP);\n", +"printf('The higher temperature of the cycle is %f K\n\n',T_high);\n", +"printf('The heat rejected per ton of refrigeration is %f kW\n\n',H_rej);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.4: Calculation_of_minimum_power_required.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 8.4\n", +"//Page number - 292\n", +"printf('Example - 8.4 and Page number - 292\n\n');\n", +"\n", +"//Given\n", +"T_high = 20 + 273.15;//[K] - High temperature\n", +"T_low = 0 + 273.15;//[K] - Low temperature\n", +"Q_H = 10;//[kW] - Heat supplied\n", +"\n", +"//If 'Q_H' is the rate at which heat is taken from surrounding and 'W' is the rate at which work is done,then\n", +"// Q_H = W + Q_L\n", +"//(Q_H/Q_L) = (T_high/T_low)\n", +"//Also for a reversible cycle, (Q_H/Q_L) = 1 + (W/Q_L). Solving we get,\n", +"Q_L = (T_low/T_high)*Q_H;//[kW]\n", +"W = (Q_H - Q_L) ;//[kW]\n", +" \n", +"printf('The minimum power required is %f kW',W);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.5: Determination_of_COP_and_power_required.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 8.5\n", +"//Page number - 292\n", +"printf('Example - 8.5 and Page number - 292\n\n');\n", +"\n", +"//Given\n", +"T_high = 40 + 273.15;//[K] - High temperature\n", +"T_low = -20 + 273.15;//[K] - Low temperature\n", +"C = 10;//[tons of refrigeration] - Capacity\n", +"//1 ton refrigeration = 3.517 kW, therefore\n", +"H = C*3.517;//[kW] - Heat absorbed\n", +"\n", +"//For reversed carnot cycle, COP = T_low/(T_high - T_low)\n", +"COP = T_low/(T_high - T_low);\n", +"\n", +"// COP = (Refrigerating effect)/(Work input), therefore power required is given by\n", +"P = (H/COP);//[kW]\n", +"\n", +"printf('The COP is %f\n\n',COP);\n", +"printf('The power required is %f kW',P);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.6: Determination_of_maximum_refrigeration_effect.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 8.6\n", +"//Page number - 292\n", +"printf('Example - 8.6 and Page number - 292\n\n');\n", +"\n", +"//Given\n", +"COP = 4;//Coefficient of performance\n", +"P = 10;//[kW] - Work done on the cycle\n", +"\n", +"//For reversed carnot cycle, COP = T_low/(T_high - T_low)\n", +"//ratio = (T_high/T_low),therefore\n", +"ratio = -1/(COP + 1);\n", +"\n", +"// Refrigerating effect = (COP)*Work input, therefore refrigeration is given by\n", +"H = COP*P;//[kW]\n", +"\n", +"//Maximum refrigearation in tons is given by\n", +"H_max = (H/3.517);\n", +"\n", +"printf('The maximum refrigeration value is %f ton',H_max);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.7: Determination_of_refrigeration_effect_power_consumed_and_COP_of_refrigerator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 8.7\n", +"//Page number - 292\n", +"printf('Example - 8.7 and Page number - 292\n\n');\n", +"\n", +"//Given\n", +"m = 0.6;//[kg/s] - mass flow rate\n", +"T_low = -20+273.15;//[K] - Temperature at which vapour enters the compressor\n", +"T_high = 30+273.15;//[K] - Temperature at which vapour leaves the condenser\n", +"\n", +"//From saturated refrigeration-12 tables we get,at -20 C\n", +"H_1 = 178.74;//[kJ/kg] - (H_1 = H_vap)\n", +"P_1 = 0.15093;//[MPa] - (P_1 = P_sat)\n", +"P_4 = P_1;\n", +"S_1 = 0.7087;//[kJ/kg-K] - (S_1 = S_vap)\n", +"S_2 = S_1;\n", +"\n", +"//At 30 C\n", +"P_2 = 0.7449;//[MPa] - (P_2 = P_sat)\n", +"P_3 = P_2;\n", +"H_3 = 64.59;//[kJ/kg] - (H_3 = H_liq)\n", +"H_4 = H_3;\n", +"S_3 = 0.24;//[kJ/kg-K] - (S_3 = S_liq)\n", +"\n", +"//It is assumed that presssure drop in the evaporator and condenser are negligible. The heat transfer rate in the evaporator is\n", +"Q_L = m*(H_1 - H_4);\n", +"\n", +"printf('The heat transfer rate in the evaporator is %f kW\n\n',Q_L);\n", +"\n", +"//At state 2 (P = 0.7449 MPa and S = 0.7087 kJ/kg-K) and looking in the superheated tables we have to calculate the enthalpy at state 2\n", +"\n", +"//At P = 0.7 MPa and S = 0.6917 kJ/kg-K,\n", +"H_11 = 200.46;//[kJ/kg]\n", +"\n", +"//At P = 0.7 MPa and S = 0.7153 kJ/kg-K,\n", +"H_12 = 207.73;//[kJ/kg]\n", +"\n", +"//Thus at P = 0.7 MPa and S = 0.7087 kJ/kg-K, enthalpy is given by\n", +"H_13 = ((S_2 -0.6917)/(0.7153 - 0.6917))*(H_12 - H_11) + H_11;//[kJ/kg]\n", +"\n", +"//At P = 0.8 MPa and S = 0.7021 kJ/kg-K,\n", +"H_21 = 206.07;//[kJ/kg]\n", +"\n", +"//At P = 0.8 MPa and S = 0.7253 kJ/kg-K,\n", +"H_22 = 213.45;//[kJ/kg]\n", +"\n", +"//Thus at P = 0.8 MPa and S = 0.7087 kJ/kg-K, enthalpy is given by\n", +"H_23 = ((S_2 -0.7021)/(0.7253 - 0.7021))*(H_22 - H_21) + H_21;//[kJ/kg]\n", +"\n", +"//At P = 0.7449 MPa, S = 0.7087 kJ/kg-K, the enthalpy is\n", +"H_2 = ((0.7449 - 0.7)/(0.8 - 0.7))*(H_23 - H_13) + H_13;//[kJ/kg]\n", +"\n", +"//Power consumed by the compressor is\n", +"W_comp = m*(H_2 - H_1);//[kW]\n", +"\n", +"printf('The power consumed by the compressor is %f kW\n\n',W_comp);\n", +"\n", +"//Heat removed in evaporator/work done on compressor\n", +"COP_R = Q_L/W_comp;\n", +"\n", +"printf('The COP the refrigerator is %f kW\n\n',COP_R);\n", +"\n", +"\n", +"//At -20 C,saturated conditions \n", +"H_liq = 17.82;//[kJ/kg]\n", +"H_vap = 178.74;//[kJ/kg]\n", +"x_4 = (H_4 - H_liq)/(H_vap - H_liq);\n", +"\n", +"printf('The dryness factor of refrigerant after the expansion valve is %f\n\n',x_4);\n", +"\n", +"//The heat transfer rate in the condenser is\n", +"Q_H = m*(H_3 - H_2);//[kW]\n", +"\n", +"printf('The heat transfer rate in the condenser is %f kW\n\n',Q_H);\n", +"\n", +"//If the cycle would have worked as a pump then,\n", +"//COP_HP = (Heat supplied from condenser/Work done on compressor)\n", +"COP_HP = (-Q_H)/W_comp;\n", +"\n", +"printf('The COP if cycle would work as a heat pump is %f kW\n\n',COP_HP);\n", +"\n", +"//If the cycle would have been a reversed Carnot cycle then\n", +"COP_C = T_low/(T_high - T_low);\n", +"\n", +"printf('The COP if cycle would run as reversed Carnot cycle is %f kW\n\n',COP_C);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.8: Calculation_of_amount_of_air.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"//Example - 8.8\n", +"//Page number - 300\n", +"printf('Example - 8.8 and Page number - 300\n\n');\n", +"\n", +"//Given\n", +"//From compressor to the expansion valve the pressure is 200 bar and from expansion valve to the inlet of compressor the pressure is 1 bar.\n", +"//Point 5 is saturated liquid at 1 bar and point 6 is saturated vapour at 1 bar\n", +"\n", +"//It has been reported in the book that at state 1 (310 K, 1 bar)\n", +"H_1 = 310.38;//[kJ/kg]\n", +"//At state 2 (310 K, 200 bar)\n", +"H_2 = 277.7;//[kJ/kg]\n", +"//At state 5 (1 bar,saturated liquid)\n", +"H_5 = -122.6;//[kJ/kg]\n", +"//At state 6 (1 bar,saturated vapur)\n", +"H_6 = 77.8;//[kJ/kg]\n", +"\n", +"//The enthalpy at point 3 is same at point 4 as the expansion is isenthalpic\n", +"\n", +"//The mass condensed is 1 kg and therefore m_1 = m+6 + 1\n", +"\n", +"//Enthalpy balance around heat exchanger\n", +"//m_2*H_2 + m_2*H_6 = m_3*H_3 + m_7*H_7\n", +"\n", +"//Enthalpy balance around separator\n", +"//m_4*H_4 = m_5*H_5 + m_6*H_6\n", +"//It can be seen that m_1 = m_2 = m_3 = m_4\n", +"//and m_6 = m_7 = m_1 - 1\n", +"\n", +"//Substituting the values for enthalpy balance around heat exchanger we get,\n", +"//m_1*H_2 + (m_1 - 1)*(H_6) = m_1*H_3 + (m_1 - 1)*H_1\n", +"//and substituting the values for enthalpy balance around seperator we get\n", +"//m_1*H_3 = (1)*(-122.6) + (m_1 - 1)*77.8\n", +"//H_3 = ((1)*(-122.6) + (m_1 - 1)*77.8)/m_1\n", +"//Substituting the expression for 'H_3' in the above equation and then solving for m_1, we get\n", +"deff('[y]=f(m_1)','y=m_1*H_2+(m_1-1)*(H_6)-m_1*(((1)*(-122.6) + (m_1 - 1)*77.8)/m_1)-(m_1-1)*H_1');\n", +"m_1 = fsolve(4,f);//[kg]\n", +"//Thus to liquify 1 kg of air compression of m_1 kg of air is carried out.\n", +"\n", +"//Now substituting this value of m_1 to get the value of H_3,\n", +"H_3 = ((1)*(-122.6) + (m_1 - 1)*77.8)/m_1;//[kJ/kg]\n", +"\n", +"//From given compressed air table we see at 200 bar and 160 K,\n", +"H_3_1 = 40.2;//[kJ/kg]\n", +"\n", +"//At 200 bar and 180 K,\n", +"H_3_2 = 79.8;//[kJ/kg]\n", +"//By interpolation we get,\n", +"T_3 = ((H_3 - H_3_1)*(180 - 160))/(H_3_2 - H_3_1) + 160;//[K]\n", +"\n", +"printf('Temperature before throttling is %f',T_3);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.9: Calculation_of_amount_of_air_and_temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"funcprot(0);\n", +"\n", +"//Example - 8.9\n", +"//Page number - 304\n", +"printf('Example - 8.9 and Page number - 304\n\n');\n", +"\n", +"//Given\n", +"//At 1 bar, 310 K \n", +"H_1 = 310.38;//[kJ/kg]\n", +"//At 200 bar, 310 K\n", +"H_2 = 277.7;//[kJ/kg]\n", +"//At 1 bar, Saturated liquid\n", +"H_7 = -122.6;//[kJ/kg]\n", +"//At 1 bar, Saturated vapour\n", +"H_8 = 77.8;//[kJ/kg]\n", +"//At 200 bar, 200 K\n", +"H_3 = 117.6;//[kJ/kg]\n", +"//At 1 bar, 100 K\n", +"H_11 = 98.3;//[kJ/kg]\n", +"\n", +"//(1)\n", +"//For 1 kg of liquid air obtained,the overall enthalpy balance is\n", +"//m_2*H_2 = W - 122.6 + (m_2 - 1)*H_1\n", +"//W = - 0.8*m_2*(H_11 - H_3)\n", +"//Overall enthalpy balance equation becomes\n", +"//H_2*m_2 = 15.44*m_2 - H_7 + (m_2 - 1)*H_1, solving\n", +"m_2_prime = (H_7 - H_1)/(H_2 - 15.44 - H_1);\n", +"\n", +"printf('The number of kilograms of air compressed per kg of liquid air produced is %f kg\n\n',m_2_prime);\n", +"\n", +"//(2)\n", +"//Enthalpy balance around separator is \n", +"//0.2*m_2*H_5 = -H_7 + (0.2*m_2 - 1)*H_8, solving\n", +"m_2 = m_2_prime;\n", +"H_5_prime = ((0.2*m_2-1)*H_8 - H_7)/(0.2*m_2);\n", +"\n", +"//At point 5, P = 200 bar and enthalpy is\n", +"H_5_1 = -33.53;//[kJ/kg]\n", +"//From compressed air tables at 200 bar and 140 K,\n", +"H_5_2 = 0.2;//[kJ/kg]\n", +"//At 200 bar and 120 K,\n", +"H_5_3 = -38.0;//[kJ/kg]\n", +"//Solving by interpolation we get\n", +"T_5 = ((H_5_1 - H_5_3)*(140 - 120))/(H_5_2 - H_5_3) + 120;//[K]\n", +"\n", +"printf('The temperature of air before throttling is %f K\n\n',T_5);\n", +"\n", +"//(3)\n", +"//During mixing of streams 8 and 11 to produce stream 9, the enthalpy balance is\n", +"// (0.2*m_2 - 1)*H_8 + 0.8*m_2*H_11 = (m_2 - 1)*H_9,Solving for H_9\n", +"\n", +"H_9_prime = ((0.2*m_2-1)*H_8+0.8*m_2*H_11)/(m_2 - 1);\n", +"\n", +"//From given compressed air tables at 1 bar and 100 K,\n", +"H_9_1 = H_11;\n", +"//At 1 bar and 90 K \n", +"H_9_2 = 87.9;//[kJ/kg]\n", +"//Solving by interpolation we get\n", +"T_9 = ((H_9_prime - H_9_2)*(100 - 90))/(H_9_1 - H_9_2) + 90;//[K]\n", +"\n", +"printf('The temperature of stream entering second heat exchanger is %f K\n\n',T_9);\n", +"\n", +"//(4)\n", +"//Enthalpy balance around first heat exchanger is\n", +"//H_2*m_2 + (m_2 - 1)*H_10 = H_3*m-2 + (m-2 - 1)*H_1, solving for H_10\n", +"\n", +"H_10_prime = ((m_2 - 1)*H_1 + H_3*m_2 - H_2*m_2)/(m_2 - 1);\n", +"\n", +"//From given compressed air tables at 1 bar and 140 K,\n", +"H_10_1 = 139.1;//[kJ/kg]\n", +"//At 1 bar and 120 K \n", +"H_10_2 = 118.8;//[kJ/kg]\n", +"//Solving by interpolation we get\n", +"T_10 = ((H_10_prime - H_10_2)*(140 - 120))/(H_10_1 - H_10_2) + 120;//[K]\n", +"\n", +"printf('The temperature of stream exiting second heat exchanger is %f K\n\n',T_10);" + ] + } +], +"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 +} |