summaryrefslogtreecommitdiff
path: root/249
diff options
context:
space:
mode:
Diffstat (limited to '249')
-rwxr-xr-x249/CH18/EX18.2/18_02.sce17
-rwxr-xr-x249/CH18/EX18.3/18_03.sce77
-rwxr-xr-x249/CH21/EX21.1/21_01.sce87
-rwxr-xr-x249/CH3/EX3.1/3_01.sce91
-rwxr-xr-x249/CH3/EX3.2/3_02.sce63
-rwxr-xr-x249/CH5/EX5.2/5_02.sce85
6 files changed, 244 insertions, 176 deletions
diff --git a/249/CH18/EX18.2/18_02.sce b/249/CH18/EX18.2/18_02.sce
index 2725ac3f5..83fd045d7 100755
--- a/249/CH18/EX18.2/18_02.sce
+++ b/249/CH18/EX18.2/18_02.sce
@@ -1,5 +1,18 @@
clear
clc
+function [coefs]=regress(x,y)
+coefs=[]
+ if (type(x) <> 1)|(type(y)<>1) then error(msprintf(gettext("%s: Wrong type for input arguments: Numerical expected.\n"),"regress")), end
+ lx=length(x)
+ if lx<>length(y) then error(msprintf(gettext("%s: Wrong size for both input arguments: same size expected.\n"),"regress")), end
+ if lx==0 then error(msprintf(gettext("%s: Wrong size for input argument #%d: Must be > %d.\n"),"regress", 1, 0)), end
+ x=matrix(x,lx,1)
+ y=matrix(y,lx,1)
+ xbar=sum(x)/lx
+ ybar=sum(y)/lx
+ coefs(2)=sum((x-xbar).*(y-ybar))/sum((x-xbar).^2)
+ coefs(1)=ybar-coefs(2)*xbar
+endfunction
//Pressure(atm)
PAo=3.2;
R=0.082;//litre.atm/mol.k
@@ -25,6 +38,4 @@ coeff1=regress(CA_avg,rA)
k=coeff1(2)
printf("\n The rate of reaction(mol/hr.kg) is %f",k)
printf("CA")
-disp('The answer slightly differs from those given in book as regress fn is used for calculating slope and intercept')
-
-
+disp('The answer slightly differs from those given in book as regress fn is used for calculating slope and intercept') \ No newline at end of file
diff --git a/249/CH18/EX18.3/18_03.sce b/249/CH18/EX18.3/18_03.sce
index a281ee41e..6080fb0bd 100755
--- a/249/CH18/EX18.3/18_03.sce
+++ b/249/CH18/EX18.3/18_03.sce
@@ -1,33 +1,44 @@
-clear
-clc
-CAo=0.1;//mol/litre
-FAo=2;//mol/hr
-eA=3;
-CA=[0.074;0.06;0.044;0.029];//mol/litre
-W=[0.02;0.04;0.08;0.16];//kg
-//Gussing 1st order,plug flow rxn
-//(1+eA)*log(1/(1-XA))-eA*XA=k*(CAo*W/FAo)
-for i=1:4
-XA(i)=(CAo-CA(i))/(CAo+eA*CA(i));
-y(i)=(1+eA)*log(1/(1-XA(i)))-eA*XA(i);
-x(i)=CAo*W(i)/FAo;
-W_by_FAo(i)=W(i)/FAo;
-CAout_by_CAo(i)=CA(i)/CAo;
-XA1(i)=(1-CAout_by_CAo(i))/(1+eA*CAout_by_CAo(i));
-end
-plot(x,y)
-coeff3=regress(x,y);
-xlabel('CAoW/FAo'),ylabel('4ln(1/1-XA)-3XA')
-k=coeff3(2);
-printf("\n Part a,using integral method of analysis")
-printf("\n The rate of reaction(mol/litre) is %f",k)
-printf("CA")
-//Part b
-//plotting W_by_FAo vs XA1,the calculating rA=dXA/d(W/FAo) for last 3 points,we get
-rA=[5.62;4.13;2.715];
-coeff2=regress(CA(2:4),rA);
-printf("\n Part b,using differential method of analysis")
-printf("\n The rate of reaction(mol/litre) is %f",coeff2(2))
-printf("CA")
-
-
+clear
+clc
+function [coefs]=regress(x,y)
+coefs=[]
+ if (type(x) <> 1)|(type(y)<>1) then error(msprintf(gettext("%s: Wrong type for input arguments: Numerical expected.\n"),"regress")), end
+ lx=length(x)
+ if lx<>length(y) then error(msprintf(gettext("%s: Wrong size for both input arguments: same size expected.\n"),"regress")), end
+ if lx==0 then error(msprintf(gettext("%s: Wrong size for input argument #%d: Must be > %d.\n"),"regress", 1, 0)), end
+ x=matrix(x,lx,1)
+ y=matrix(y,lx,1)
+ xbar=sum(x)/lx
+ ybar=sum(y)/lx
+ coefs(2)=sum((x-xbar).*(y-ybar))/sum((x-xbar).^2)
+ coefs(1)=ybar-coefs(2)*xbar
+endfunction
+CAo=0.1;//mol/litre
+FAo=2;//mol/hr
+eA=3;
+CA=[0.074;0.06;0.044;0.029];//mol/litre
+W=[0.02;0.04;0.08;0.16];//kg
+//Gussing 1st order,plug flow rxn
+//(1+eA)*log(1/(1-XA))-eA*XA=k*(CAo*W/FAo)
+for i=1:4
+XA(i)=(CAo-CA(i))/(CAo+eA*CA(i));
+y(i)=(1+eA)*log(1/(1-XA(i)))-eA*XA(i);
+x(i)=CAo*W(i)/FAo;
+W_by_FAo(i)=W(i)/FAo;
+CAout_by_CAo(i)=CA(i)/CAo;
+XA1(i)=(1-CAout_by_CAo(i))/(1+eA*CAout_by_CAo(i));
+end
+plot(x,y)
+coeff3=regress(x,y);
+xlabel('CAoW/FAo'),ylabel('4ln(1/1-XA)-3XA')
+k=coeff3(2);
+printf("\n Part a,using integral method of analysis")
+printf("\n The rate of reaction(mol/litre) is %f",k)
+printf("CA")
+//Part b
+//plotting W_by_FAo vs XA1,the calculating rA=dXA/d(W/FAo) for last 3 points,we get
+rA=[5.62;4.13;2.715];
+coeff2=regress(CA(2:4),rA);
+printf("\n Part b,using differential method of analysis")
+printf("\n The rate of reaction(mol/litre) is %f",coeff2(2))
+printf("CA") \ No newline at end of file
diff --git a/249/CH21/EX21.1/21_01.sce b/249/CH21/EX21.1/21_01.sce
index 71fe097be..d477a76e6 100755
--- a/249/CH21/EX21.1/21_01.sce
+++ b/249/CH21/EX21.1/21_01.sce
@@ -1,39 +1,48 @@
-clear
-clc
-t=[0;2;4;6];
-XA=[0.75;0.64;0.52;0.39];
-t1=4000;//kg.s/m3
-density_s=1500;//kg/m3
-De=5*10^-10;
-d=2.4*10^-3;
-//Assuming -rA=kCA*a,-da/dt=kd*a
-//For this rate a plot of ln(CAo/CA-1)vs t should give a straight line
-for i=1:4
- y(i)=log((1/(1-XA(i)))-1);
-end
-plot(y,t)
-xlabel('t')
-ylabel('ln(CAo/CA-1)')
-//Guessing No Intrusion of Diffusional Resistance
-//ln(CAo/CA-1)=ln(k*t1)-kd*t
-coeff =regress(t,y);
-kd=coeff(2);
-k=exp(coeff(1))/t1;
-L=d/6;
-Mt=L*sqrt(k*density_s/De);
-//Assuming Runs were made in regime of strong resistance to pore diffusion
-k1=((exp(coeff(1)))^2)*(L^2)*density_s/(t1*t1*De);
-kd1=-2*coeff(2);
-Mt=L*sqrt(k1*density_s/De);
-printf("\n Rate equation(mol/kg.s) in diffusion free regime with deactivation is %f ",k1)
-printf("CA*a with \n -da/dt(hr-1) is %f",kd1)
-printf("a")
-//In strong pore diffusion
-k2=k1*sqrt(De/(k1*density_s));
-printf("\n Rate equation(mol/kg.s) in strong pore diffusion resistance regime with deactivation is %f ",k2)
-printf("CA*a^0.5/L with \n -da/dt(hr-1) is %f",kd1)
-printf("a")
-
-
-
-
+clear
+clc
+function [coefs]=regress(x,y)
+coefs=[]
+ if (type(x) <> 1)|(type(y)<>1) then error(msprintf(gettext("%s: Wrong type for input arguments: Numerical expected.\n"),"regress")), end
+ lx=length(x)
+ if lx<>length(y) then error(msprintf(gettext("%s: Wrong size for both input arguments: same size expected.\n"),"regress")), end
+ if lx==0 then error(msprintf(gettext("%s: Wrong size for input argument #%d: Must be > %d.\n"),"regress", 1, 0)), end
+ x=matrix(x,lx,1)
+ y=matrix(y,lx,1)
+ xbar=sum(x)/lx
+ ybar=sum(y)/lx
+ coefs(2)=sum((x-xbar).*(y-ybar))/sum((x-xbar).^2)
+ coefs(1)=ybar-coefs(2)*xbar
+endfunction
+t=[0;2;4;6];
+XA=[0.75;0.64;0.52;0.39];
+t1=4000;//kg.s/m3
+density_s=1500;//kg/m3
+De=5*10^-10;
+d=2.4*10^-3;
+//Assuming -rA=kCA*a,-da/dt=kd*a
+//For this rate a plot of ln(CAo/CA-1)vs t should give a straight line
+for i=1:4
+ y(i)=log((1/(1-XA(i)))-1);
+end
+plot(y,t)
+xlabel('t')
+ylabel('ln(CAo/CA-1)')
+//Guessing No Intrusion of Diffusional Resistance
+//ln(CAo/CA-1)=ln(k*t1)-kd*t
+coeff =regress(t,y);
+kd=coeff(2);
+k=exp(coeff(1))/t1;
+L=d/6;
+Mt=L*sqrt(k*density_s/De);
+//Assuming Runs were made in regime of strong resistance to pore diffusion
+k1=((exp(coeff(1)))^2)*(L^2)*density_s/(t1*t1*De);
+kd1=-2*coeff(2);
+Mt=L*sqrt(k1*density_s/De);
+printf("\n Rate equation(mol/kg.s) in diffusion free regime with deactivation is %f ",k1)
+printf("CA*a with \n -da/dt(hr-1) is %f",kd1)
+printf("a")
+//In strong pore diffusion
+k2=k1*sqrt(De/(k1*density_s));
+printf("\n Rate equation(mol/kg.s) in strong pore diffusion resistance regime with deactivation is %f ",k2)
+printf("CA*a^0.5/L with \n -da/dt(hr-1) is %f",kd1)
+printf("a") \ No newline at end of file
diff --git a/249/CH3/EX3.1/3_01.sce b/249/CH3/EX3.1/3_01.sce
index 1bbf163bd..4897377b9 100755
--- a/249/CH3/EX3.1/3_01.sce
+++ b/249/CH3/EX3.1/3_01.sce
@@ -1,39 +1,52 @@
-clear
-clc
-//Given
-t=[0 20 40 60 120 180 300];
-C_A=[10 8 6 5 3 2 1];
-CAo=10;
-//Guessing 1st order kinetics
-//This means log(CAo/C_A) vs t should give a straight line
-for i=1:7
- k(i)=log(CAo/C_A(i));
- CA_inv(i)=1/C_A(i);
-end
-//plot(t,k)
-//This doesn't give straight line.
-//Guessing 2nd Order Kinetics so
-//1/C_A vs t should give a straight line
-//plot(t,CA_inv)
-//Again this doesn't give a straight line
-//Guessing nth order kinetics and using fractional life method with F=80%
-//log Tf=log(0.8^(1-n)-1/(k(n-1)))+(1-n)logCAo
-//plot(t,C_A)
-
-//Picking different values of CAo
-//Time needed for 3 runs,,from graph
-T=[18.5;23;35];
-CAo=[10;5;2];
-for i=1:3
- CA(i)=0.8*CAo(i);
- log_Tf(i)=log10(T(i));
- log_CAo(i)=log10(CAo(i));
-end
-plot(log_CAo,log_Tf)
-xlabel('log CAo');ylabel('log t');
-coeff1=regress(log_CAo,log_Tf);
-n=1-coeff1(2);
-printf("From graph we get slope and intercept for calculating rate eqn")
-k1=((0.8^(1-n))-1)*(10^(1-n))/(18.5*(n-1));
-printf("\n The rate equation is given by %f",k1)
-printf("CA^1.4 mol/litre.sec")
+clear
+clc
+function [coefs]=regress(x,y)
+coefs=[]
+ if (type(x) <> 1)|(type(y)<>1) then error(msprintf(gettext("%s: Wrong type for input arguments: Numerical expected.\n"),"regress")), end
+ lx=length(x)
+ if lx<>length(y) then error(msprintf(gettext("%s: Wrong size for both input arguments: same size expected.\n"),"regress")), end
+ if lx==0 then error(msprintf(gettext("%s: Wrong size for input argument #%d: Must be > %d.\n"),"regress", 1, 0)), end
+ x=matrix(x,lx,1)
+ y=matrix(y,lx,1)
+ xbar=sum(x)/lx
+ ybar=sum(y)/lx
+ coefs(2)=sum((x-xbar).*(y-ybar))/sum((x-xbar).^2)
+ coefs(1)=ybar-coefs(2)*xbar
+endfunction
+//Given
+t=[0 20 40 60 120 180 300];
+C_A=[10 8 6 5 3 2 1];
+CAo=10;
+//Guessing 1st order kinetics
+//This means log(CAo/C_A) vs t should give a straight line
+for i=1:7
+ k(i)=log(CAo/C_A(i));
+ CA_inv(i)=1/C_A(i);
+end
+//plot(t,k)
+//This doesn't give straight line.
+//Guessing 2nd Order Kinetics so
+//1/C_A vs t should give a straight line
+//plot(t,CA_inv)
+//Again this doesn't give a straight line
+//Guessing nth order kinetics and using fractional life method with F=80%
+//log Tf=log(0.8^(1-n)-1/(k(n-1)))+(1-n)logCAo
+//plot(t,C_A)
+
+//Picking different values of CAo
+//Time needed for 3 runs,,from graph
+T=[18.5;23;35];
+CAo=[10;5;2];
+for i=1:3
+ CA(i)=0.8*CAo(i);
+ log_Tf(i)=log10(T(i));
+ log_CAo(i)=log10(CAo(i));
+end
+plot(log_CAo,log_Tf)
+xlabel('log CAo');ylabel('log t');
+coeff1=regress(log_CAo,log_Tf);
+n=1-coeff1(2);
+printf("From graph we get slope and intercept for calculating rate eqn")
+k1=((0.8^(1-n))-1)*(10^(1-n))/(18.5*(n-1));
+printf("\n The rate equation is given by %f",k1)
+printf("CA^1.4 mol/litre.sec") \ No newline at end of file
diff --git a/249/CH3/EX3.2/3_02.sce b/249/CH3/EX3.2/3_02.sce
index a2a1ef1b6..bb129725c 100755
--- a/249/CH3/EX3.2/3_02.sce
+++ b/249/CH3/EX3.2/3_02.sce
@@ -1,26 +1,37 @@
-clear
-clc
-CA=[10;8;6;5;3;2;1];//mol/litre
-T=[0;20;40;60;120;180;300];//sec
-//plot(T,CA)
-//xlabel('Time(sec)');ylabel('CA(mol/litre)');
-//From graph y=-dCA/dt at different points are
-y=[-0.1333;-0.1031;-0.0658;-0.0410;-0.0238;-0.0108;-0.0065];
-//Guessing nth rate order
-//rA=kCA^n
-//log(-dCA/dt)=logk+nlogCA
-for i=1:7
-log_y(i)=log10(y(i));
-log_CA(i)=log10(CA(i));
-end
-plot(log_CA,log_y)
-xlabel('logCA');ylabel('log(-dCA/dt)')
-coeff1=regress(log_CA,log_y);
-n=coeff1(2);
-k=-10^(coeff1(1));
-printf("\n After doing linear regression,the slope and intercept of the graph is %f , %f",coeff(2),coeff(1))
-printf("\n The rate equation is therefore given by %f",k)
-printf("CA^1.375 mol/litre.sec")
-disp('The answer slightly differs from those given in book as regress fn is used for calculating slope and intercept')
-
-
+clear
+clc
+function [coefs]=regress(x,y)
+coefs=[]
+ if (type(x) <> 1)|(type(y)<>1) then error(msprintf(gettext("%s: Wrong type for input arguments: Numerical expected.\n"),"regress")), end
+ lx=length(x)
+ if lx<>length(y) then error(msprintf(gettext("%s: Wrong size for both input arguments: same size expected.\n"),"regress")), end
+ if lx==0 then error(msprintf(gettext("%s: Wrong size for input argument #%d: Must be > %d.\n"),"regress", 1, 0)), end
+ x=matrix(x,lx,1)
+ y=matrix(y,lx,1)
+ xbar=sum(x)/lx
+ ybar=sum(y)/lx
+ coefs(2)=sum((x-xbar).*(y-ybar))/sum((x-xbar).^2)
+ coefs(1)=ybar-coefs(2)*xbar
+endfunction
+CA=[10;8;6;5;3;2;1];//mol/litre
+T=[0;20;40;60;120;180;300];//sec
+//plot(T,CA)
+//xlabel('Time(sec)');ylabel('CA(mol/litre)');
+//From graph y=-dCA/dt at different points are
+y=[-0.1333;-0.1031;-0.0658;-0.0410;-0.0238;-0.0108;-0.0065];
+//Guessing nth rate order
+//rA=kCA^n
+//log(-dCA/dt)=logk+nlogCA
+for i=1:7
+log_y(i)=log10(y(i));
+log_CA(i)=log10(CA(i));
+end
+plot(log_CA,log_y)
+xlabel('logCA');ylabel('log(-dCA/dt)')
+coeff1=regress(log_CA,log_y);
+n=coeff1(2);
+k=-10^(coeff1(1));
+printf("\n After doing linear regression,the slope and intercept of the graph is %f , %f",coeff(2),coeff(1))
+printf("\n The rate equation is therefore given by %f",k)
+printf("CA^1.375 mol/litre.sec")
+disp('The answer slightly differs from those given in book as regress fn is used for calculating slope and intercept') \ No newline at end of file
diff --git a/249/CH5/EX5.2/5_02.sce b/249/CH5/EX5.2/5_02.sce
index 0f9eb6da2..be0f4e030 100755
--- a/249/CH5/EX5.2/5_02.sce
+++ b/249/CH5/EX5.2/5_02.sce
@@ -1,37 +1,50 @@
-clear
-clc
-//Given
-//Volumetric flow rates(litre/hr)
-vo=[10;3;1.2;0.5];
-//Concentrations (millimol/litre)
-CA=[85.7;66.7;50;33.4];
-CAo=100;
-//Volume(litre)
-V=0.1;
-//For the stoichiometry 2A-->R
-//Expansion factor is
-e=(1-2)/2;
-//Initialization
-XA=zeros(4,1);
-rA=zeros(4,1);
-//Relation between concentration and conversion
-for i=1:4
-XA(i)=(1-CA(i)/CAo)/(1+e*CA(i)/CAo);
-//Rate of reaction is given by
-rA(i)=vo(i)*CAo*XA(i)/V;
-//Testing nth order kinetics
-//-rA=k*CA^n
-//log(-rA)=logk+nlog(CA)
-m(i)=log10(CA(i));
-n(i)=log10(rA(i));
-end
-//For nth order plot between n & m should give a straight line
-plot(m,n)
-coefs=regress(m,n);
-printf("Intercept of the graph is %f\n",coefs(1))
-printf("Slope of the graph is %f\n",coefs(2))
-k=10^coefs(1)
-n=coefs(2)
-printf("\n Taking n=2,rate of equation(millimol/litre.hr) is %f",k)
-printf("CA^2 \n")
+clear
+clc
+function [coefs]=regress(x,y)
+coefs=[]
+ if (type(x) <> 1)|(type(y)<>1) then error(msprintf(gettext("%s: Wrong type for input arguments: Numerical expected.\n"),"regress")), end
+ lx=length(x)
+ if lx<>length(y) then error(msprintf(gettext("%s: Wrong size for both input arguments: same size expected.\n"),"regress")), end
+ if lx==0 then error(msprintf(gettext("%s: Wrong size for input argument #%d: Must be > %d.\n"),"regress", 1, 0)), end
+ x=matrix(x,lx,1)
+ y=matrix(y,lx,1)
+ xbar=sum(x)/lx
+ ybar=sum(y)/lx
+ coefs(2)=sum((x-xbar).*(y-ybar))/sum((x-xbar).^2)
+ coefs(1)=ybar-coefs(2)*xbar
+endfunction
+//Given
+//Volumetric flow rates(litre/hr)
+vo=[10;3;1.2;0.5];
+//Concentrations (millimol/litre)
+CA=[85.7;66.7;50;33.4];
+CAo=100;
+//Volume(litre)
+V=0.1;
+//For the stoichiometry 2A--&gt;R
+//Expansion factor is
+e=(1-2)/2;
+//Initialization
+XA=zeros(4,1);
+rA=zeros(4,1);
+//Relation between concentration and conversion
+for i=1:4
+XA(i)=(1-CA(i)/CAo)/(1+e*CA(i)/CAo);
+//Rate of reaction is given by
+rA(i)=vo(i)*CAo*XA(i)/V;
+//Testing nth order kinetics
+//-rA=k*CA^n
+//log(-rA)=logk+nlog(CA)
+m(i)=log10(CA(i));
+n(i)=log10(rA(i));
+end
+//For nth order plot between n &amp; m should give a straight line
+plot(m,n)
+coefs=regress(m,n);
+printf("Intercept of the graph is %f\n",coefs(1))
+printf("Slope of the graph is %f\n",coefs(2))
+k=10^coefs(1)
+n=coefs(2)
+printf("\n Taking n=2,rate of equation(millimol/litre.hr) is %f",k)
+printf("CA^2 \n")
disp('The sol slightly differ from that given in book because regress fn is used to calculate the slope') \ No newline at end of file