summaryrefslogtreecommitdiff
path: root/545
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:38:01 +0530
committerprashantsinalkar2017-10-10 12:38:01 +0530
commitf35ea80659b6a49d1bb2ce1d7d002583f3f40947 (patch)
treeeb72842d800ac1233e9d890e020eac5fd41b0b1b /545
parent7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (diff)
downloadScilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.gz
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.bz2
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.zip
updated the code
Diffstat (limited to '545')
-rwxr-xr-x545/CH5/EX5.8/ch_5_eg_8.sce64
-rwxr-xr-x545/CH7/EX7.2/ch_7_eg_2.sce86
-rwxr-xr-x545/CH8/EX8.2/ch_8_eg_2.sce54
3 files changed, 102 insertions, 102 deletions
diff --git a/545/CH5/EX5.8/ch_5_eg_8.sce b/545/CH5/EX5.8/ch_5_eg_8.sce
index 812c04d91..d04093eba 100755
--- a/545/CH5/EX5.8/ch_5_eg_8.sce
+++ b/545/CH5/EX5.8/ch_5_eg_8.sce
@@ -1,33 +1,33 @@
-clc
-disp("the soln of eg 5.8-->Chemical Reaction and Diffusion in Pore");
-lnght=.001
-k_const=.001
-D=10^-9
-delta_x=l/100
-C=1 //in mol/m3
-//B.C. are C=1 at x=0
-// dC/dx=0 at x=10^-3 since at the end point conc. is const.
-//using central difference method we get the following eqns which can be solved using TDMA method
-for i=2:99, a(i)=1 //sub diagonal assignment
-end
-a(100)=2 //since C99=C100 using B.C.
-for j=1:100, b(j)=-2.0001, //main diagonal assignment
-end
-for k=1:99, c(k)=1; //super diagonal assignment
-end
-d(1)=-1
-for l=2:100, d(l)=0;
-end //given values assignment
-i=1;
-n=100;
-beta1(i)=b(i); //initial b is equal to beta since a1=0
-gamma1(i)=d(i)/beta1(i); //since c7=0
-m=i+1;
-for j=m:n, beta1(j)=b(j)-a(j)*c(j-1)/beta1(j-1);
-gamma1(j)=(d(j)-a(j)*gamma1(j-1))/beta1(j);
-end
-x(n)=gamma1(n); //since c7=0
-n1=n-i;
-for k=1:n1, j=n-k; x(j)=gamma1(j)-c(j)*x(j+1)/beta1(j);
-end
+clc
+disp("the soln of eg 5.8-->Chemical Reaction and Diffusion in Pore");
+lnght=.001
+k_const=.001
+D=10^-9
+delta_x=lnght/100
+C=1 //in mol/m3
+//B.C. are C=1 at x=0
+// dC/dx=0 at x=10^-3 since at the end point conc. is const.
+//using central difference method we get the following eqns which can be solved using TDMA method
+for i=2:99, a(i)=1 //sub diagonal assignment
+end
+a(100)=2 //since C99=C100 using B.C.
+for j=1:100, b(j)=-2.0001, //main diagonal assignment
+end
+for k=1:99, c(k)=1; //super diagonal assignment
+end
+d(1)=-1
+for l=2:100, d(l)=0;
+end //given values assignment
+i=1;
+n=100;
+beta1(i)=b(i); //initial b is equal to beta since a1=0
+gamma1(i)=d(i)/beta1(i); //since c7=0
+m=i+1;
+for j=m:n, beta1(j)=b(j)-a(j)*c(j-1)/beta1(j-1);
+gamma1(j)=(d(j)-a(j)*gamma1(j-1))/beta1(j);
+end
+x(n)=gamma1(n); //since c7=0
+n1=n-i;
+for k=1:n1, j=n-k; x(j)=gamma1(j)-c(j)*x(j+1)/beta1(j);
+end
disp(x(50),"the values of conc. at x=.5mm or at the 50th node is"); \ No newline at end of file
diff --git a/545/CH7/EX7.2/ch_7_eg_2.sce b/545/CH7/EX7.2/ch_7_eg_2.sce
index 81a5e14c7..b629b408d 100755
--- a/545/CH7/EX7.2/ch_7_eg_2.sce
+++ b/545/CH7/EX7.2/ch_7_eg_2.sce
@@ -1,44 +1,44 @@
-clc
-disp("soln of eg 7.2-->Second Order Reaction-20 parts")
-e1=1,e2=1
-u=1,D=10^-4,k=1,C_a_in=1,delta_x=10/20
-cff_ca2_n1=2*D/delta_x^2+u/delta_x //co-efficient of C-A2 at node 1
-cff_da1_n1=-(2*u^2/D+2*u/delta_x)*C_a_in //right hand side co-efficient
-cff_ca1_n2=D/delta_x^2+u/delta_x
-cff_ca3_n2=D/delta_x^2 //co-efficient of C-A3 at node 2
-cff_da1_n2=0
-cff_ca2_n3=cf_ca1_n2
-cff_ca4_n3=cf_ca3_n2
-cff_da1_n3=0
-cff_ca20_n21=2*D/delta_x^2+u/delta_x //co-efficient of C-A20 at node 21
-cff_da21_n21=0
-for i=2:20, a(i)=cff_ca1_n2,
-end
-a(21)=cff_ca2_n1,c(1)=cff_ca2_n1
-for i=2:20,c(i)=cff_ca3_n2,
-end
-d(1)=cff_da1_n1
-for i=2:21,d(i)=cff_da1_n2
-end
-for i=1:21,x(i)=0,
-end
-while e1>1e-6 & e2>1e-6 do for i=1:21,x1(i)=x(i),end,
- cff_ca1_n1=-2*D/delta_x^2-3*u/delta_x-x1(1)-2*u^2/D //main diagonal elements dependence on conc.
- b(1)=cff_ca1_n1,
- for i=2:21,b(i)=-2*D/delta_x^2-u/delta_x-x(i),end
-
-//solving by TDMA method
- i=1, n=21, Beta(i)=b(i),
- Gamma(i)=d(i)/Beta(i)
- i1=i+1,
- for j=i1:n, Beta(j)=b(j)-a(j)*c(j-1)/Beta(j-1),
- Gamma(j)=(d(j)-a(j)*Gamma(j-1))/Beta(j),
- end
- x(n)=Gamma(n)
- n1=n-i,
- for k=1:n1, j=n-k,x(j)=Gamma(j)-c(j)*x(j+1)/Beta(j)
- end
-e1=abs(x(1)-x1(1)), e2=abs(x(21)-x1(21))
-end
-for i=1:21,disp(x(i))
+clc
+disp("soln of eg 7.2-->Second Order Reaction-20 parts")
+e1=1,e2=1
+u=1,D=10^-4,k=1,C_a_in=1,delta_x=10/20
+cff_ca2_n1=2*D/delta_x^2+u/delta_x //co-efficient of C-A2 at node 1
+cff_da1_n1=-(2*u^2/D+2*u/delta_x)*C_a_in //right hand side co-efficient
+cff_ca1_n2=D/delta_x^2+u/delta_x
+cff_ca3_n2=D/delta_x^2 //co-efficient of C-A3 at node 2
+cff_da1_n2=0
+cff_ca2_n3=cff_ca2_n1
+cff_ca4_n3=cff_ca3_n2
+cff_da1_n3=0
+cff_ca20_n21=2*D/delta_x^2+u/delta_x //co-efficient of C-A20 at node 21
+cff_da21_n21=0
+for i=2:20, a(i)=cff_ca1_n2,
+end
+a(21)=cff_ca2_n1,c(1)=cff_ca2_n1
+for i=2:20,c(i)=cff_ca3_n2,
+end
+d(1)=cff_da1_n1
+for i=2:21,d(i)=cff_da1_n2
+end
+for i=1:21,x(i)=0,
+end
+while e1>1e-6 & e2>1e-6 do for i=1:21,x1(i)=x(i),end,
+ cff_ca1_n1=-2*D/delta_x^2-3*u/delta_x-x1(1)-2*u^2/D //main diagonal elements dependence on conc.
+ b(1)=cff_ca1_n1,
+ for i=2:21,b(i)=-2*D/delta_x^2-u/delta_x-x(i),end
+
+//solving by TDMA method
+ i=1, n=21, Beta(i)=b(i),
+ Gamma(i)=d(i)/Beta(i)
+ i1=i+1,
+ for j=i1:n, Beta(j)=b(j)-a(j)*c(j-1)/Beta(j-1),
+ Gamma(j)=(d(j)-a(j)*Gamma(j-1))/Beta(j),
+ end
+ x(n)=Gamma(n)
+ n1=n-i,
+ for k=1:n1, j=n-k,x(j)=Gamma(j)-c(j)*x(j+1)/Beta(j)
+ end
+e1=abs(x(1)-x1(1)), e2=abs(x(21)-x1(21))
+end
+for i=1:21,disp(x(i))
end \ No newline at end of file
diff --git a/545/CH8/EX8.2/ch_8_eg_2.sce b/545/CH8/EX8.2/ch_8_eg_2.sce
index 501b7d1df..8adab9a0b 100755
--- a/545/CH8/EX8.2/ch_8_eg_2.sce
+++ b/545/CH8/EX8.2/ch_8_eg_2.sce
@@ -1,28 +1,28 @@
-clc
-disp("the soln of eg 8.2-->");
-for i=1:100, x(i)=0
-end
-iter=0, e1=1, f=1
-k=.1,D=10^-9,r=.01,delta_r=r/10,t1=k*delta_r^2/D
-while e1>1e-6 & f>1e-6 do iter=iter+1,for i=1:100, x1(i)=x(i),
- end, for i=2:100, a(i)=1-(1/(i-1))
- end, b(1)=-6-.t1*x1(1), for i=2:100, b(i)=-2-t1*x1(i)
- end, c(1)=6, for i=2:99,c(i)=1+(1/(i-1))
- end, for i=1:99,d(i)=0, end, d(100)=-100/99,
- i=1, n=100, Beta(i)=b(i),
- Gamma(i)=d(i)/Beta(i)
- i1=i+1,
- for j=i1:n, Beta(j)=b(j)-a(j)*c(j-1)/Beta(j-1),
- Gamma(j)=(d(j)-a(j)*Gamma(j-1))/Beta(j),
- end
- x(n)=Gamma(n)
- n1=n-i,
- for k=1:n1, j=n-k,x(j)=Gamma(j)-c(j)*x(j+1)/Beta(j)
- end
- e1=abs(x(1)-x1(1)),
- f=abs(x(100)-x1(100)),
-end
-disp("the solution by TDMA of node 77 to 99 by 2nd order rxn. is");
-for i=77:100,
- disp(x(i));
+clc
+disp("the soln of eg 8.2-->");
+for i=1:100, x(i)=0
+end
+iter=0, e1=1, f=1
+k=.1,D=10^-9,r=.01,delta_r=r/10,t1=k*delta_r^2/D
+while e1>1e-6 & f>1e-6 do iter=iter+1,for i=1:100, x1(i)=x(i),
+ end, for i=2:100, a(i)=1-(1/(i-1))
+ end, b=-6-t1*x1(1); , for i=2:100, b(i)=-2-t1*x1(i)
+ end, c(1)=6, for i=2:99,c(i)=1+(1/(i-1))
+ end, for i=1:99,d(i)=0, end, d(100)=-100/99,
+ i=1, n=100, Beta(i)=b(i),
+ Gamma(i)=d(i)/Beta(i)
+ i1=i+1,
+ for j=i1:n, Beta(j)=b(j)-a(j)*c(j-1)/Beta(j-1),
+ Gamma(j)=(d(j)-a(j)*Gamma(j-1))/Beta(j),
+ end
+ x(n)=Gamma(n)
+ n1=n-i,
+ for k=1:n1, j=n-k,x(j)=Gamma(j)-c(j)*x(j+1)/Beta(j)
+ end
+ e1=abs(x(1)-x1(1)),
+ f=abs(x(100)-x1(100)),
+end
+disp("the solution by TDMA of node 77 to 99 by 2nd order rxn. is");
+for i=77:100,
+ disp(x(i));
end \ No newline at end of file