summaryrefslogtreecommitdiff
path: root/260/CH15
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /260/CH15
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '260/CH15')
-rw-r--r--260/CH15/EX15.1/15_1.sce47
-rw-r--r--260/CH15/EX15.2/15_2.sce33
-rw-r--r--260/CH15/EX15.3/15_3.sce39
-rw-r--r--260/CH15/EX15.4/15_4.sce58
-rw-r--r--260/CH15/EX15.5/15_5.sce24
5 files changed, 201 insertions, 0 deletions
diff --git a/260/CH15/EX15.1/15_1.sce b/260/CH15/EX15.1/15_1.sce
new file mode 100644
index 000000000..fae9efee4
--- /dev/null
+++ b/260/CH15/EX15.1/15_1.sce
@@ -0,0 +1,47 @@
+//Eg-15.1
+//pg-605
+
+clear
+clc
+
+//using d/dx to denote the partial derivatve w.r.t x
+
+//Consider the general equation defined by the equation [2] on pg-605
+
+// A * d^2(F)/dx^2 + B * d^2(F)/dxdy + C * d^2(F)/dy^2 + D = 0;
+//for part (i)
+
+A(1) = 1;
+B(1) = 0;
+C(1) = 1;
+D(1) = 0;
+
+//for part (ii)
+
+A(2) = 1;
+B(2) = 0;
+C(2) = -1;
+D(2) = 0;
+
+//for part(iii)
+
+A(3) = 1;
+B(3) = 0;
+C(3) = 0;
+D(3) = 0;
+
+for(i = 1:3)
+ dt(i) = B(i)^2 - 4*A(i)*C(i);
+
+ if(dt(i) > 0)
+ printf('The discriminant of the PDE in part %d is %f ,so it is Hyperbolic\n',i,dt(i))
+
+ elseif(dt(i) < 0)
+ printf('The discriminant of the PDE in part %d is %f ,so it is Elliptic\n',i,dt(i)')
+
+ else(dt(i) == 0)
+ printf('The discriminant of the PDE in part %d is %f ,so it is parabolic\n',i,dt(i)')
+ end
+
+end
+
diff --git a/260/CH15/EX15.2/15_2.sce b/260/CH15/EX15.2/15_2.sce
new file mode 100644
index 000000000..88e655b83
--- /dev/null
+++ b/260/CH15/EX15.2/15_2.sce
@@ -0,0 +1,33 @@
+//Eg-15.2
+//pg-608
+
+clear
+clc
+
+// Using D in the place of greek alphabet delta
+
+// Taking square grid => Dx = Dy = 0.25
+
+// Applying central difference approximation to the second derivatives, we obtain
+
+// [T(i+1,j) - 2*T(i,j) + T(i-1,j)]/(Dx)^2 + [T(i,j+1) - 2*T(i,j) + T(i,j-1)]/(Dy)^2 = 0. i = 1,2,3; j = 1,2,3.....this can be simplified as
+
+// T(i+1,j) + T(i-1,j) + T(i,j+1) + T(i,j-1) - 4*T(i,j) = 0
+
+//Applying the above equation to the 9 points analytically leaves us with 9 equations and 9 variables T11 to T33. This can be written in the matrix equation form Ax = B.
+
+A = [4 -1 0 -1 0 0 0 0 0;-1 4 -1 0 -1 0 0 0 0;0 -1 4 0 0 -1 0 0 0;-1 0 0 4 -1 0 -1 0 0;0 -1 0 -1 4 -1 0 -1 0;0 0 -1 0 -1 4 0 0 -1;0 0 0 -1 0 0 4 -1 0;0 0 0 0 -1 0 -1 4 -1;0 0 0 0 0 -1 0 -1 4];
+
+B = [65;25;125;40;0;100;90;50;150];
+printf('Solving the Equation Ax = B will give the values of Temperatures, where A = \n')
+disp(A)
+
+printf('\nand B = ')
+
+disp(B)
+
+printf('\nTherefore the matrix representing T11 to T33 is \n')
+
+x = inv(A)*B;
+
+disp(x)
diff --git a/260/CH15/EX15.3/15_3.sce b/260/CH15/EX15.3/15_3.sce
new file mode 100644
index 000000000..48da6eae9
--- /dev/null
+++ b/260/CH15/EX15.3/15_3.sce
@@ -0,0 +1,39 @@
+//Eg-15.3
+//pg-611
+
+clear
+clc
+
+// The value of y can be computed using the equation :
+// y(i,j+1) = 0.68*y(i,j) + 0.16*y(i+1,j) + 0.16*y(i-1,j)
+y = zeros(5,5);
+y(1,1:5) = 25;
+y(1:5,1) = 100;
+y(1:5,5) = 100;
+
+//disp(y)
+
+for(j = 2:4)
+ for(i = 1:4)
+ y(i+1,j) = 0.68*y(i,j) + 0.16*y(i,j+1) + 0.16*y(i,j-1);
+ end
+
+end
+
+printf('The values of y for different t are shown in the table(Rows represents different time level and columns represent x0,x1,x2,x3,x4) below and the plot corresponding to this value is shown in the figure generated\n')
+disp(y)
+
+//There is a mistake in the textbook
+
+x = 0:0.25:1;
+
+y1 = y(1,1:5);
+y2 = y(2,1:5);
+y3 = y(3,1:5);
+y4 = y(4,1:5);
+y5 = y(5,1:5);
+
+plot(x,y1,x,y2,x,y3,x,y4,x,y5)
+legend('t0','t1','t2','t3','t4')
+xlabel('x')
+ylabel('y')
diff --git a/260/CH15/EX15.4/15_4.sce b/260/CH15/EX15.4/15_4.sce
new file mode 100644
index 000000000..2f31d7315
--- /dev/null
+++ b/260/CH15/EX15.4/15_4.sce
@@ -0,0 +1,58 @@
+//Eg-15.4
+//pg-617
+
+clear
+clc
+
+close()
+
+//Using equation [21] in this problem
+
+//Solving the equations analytically gives 3 equatinos in y11,y21,y31 which can be solved using matrix inversion.
+
+printf('Using the equation [21] we get :\n')
+x1 = inv([1.16 -0.08 0;-0.08 1.16 -0.08;0 -0.08 1.16])*[33;25;33];
+
+printf(' y11 = %f\n y21 = %f\n y31 = %f\n',x1(1,1),x1(2,1),x1(3,1))
+
+//Similarly solving for the elements in the column 2,3&4
+
+x2 = inv([1.16 -0.08 0;-0.08 1.16 -0.08;0 -0.08 1.16])*[43.442;26.4406;43.4442];
+
+printf(' y12 = %f\n y22 = %f\n y32 = %f\n',x2(1,1),x2(2,1),x2(3,1))
+
+x3 = inv([1.16 -0.08 0;-0.08 1.16 -0.08;0 -0.08 1.16])*[51.3531;30.0152;51.3531];
+
+printf(' y13 = %f\n y23 = %f\n y33 = %f\n',x3(1,1),x3(2,1),x3(3,1))
+
+x4 = inv([1.16 -0.08 0;-0.08 1.16 -0.08;0 -0.08 1.16])*[57.6403;34.5618;57.6403];
+
+printf(' y14 = %f\n y24 = %f\n y34 = %f\n',x4(1,1),x4(2,1),x4(3,1))
+
+y = zeros(4,5)
+
+y(1:4,1) = 100;
+y(1:4,5) = 100;
+
+y(1,2:4) = x1';
+y(2,2:4) = x2';
+y(3,2:4) = x3';
+y(4,2:4) = x4';
+
+printf('The values of y at the grid points are shown in the following table :\n')
+disp(y)
+
+printf('\nThe profiles of y by Crank-Nicolson method is shown in the figure\n')
+
+x = 0:0.25:1;
+
+y1 = y(1,1:5);
+y2 = y(2,1:5);
+y3 = y(3,1:5);
+y4 = y(4,1:5);
+
+
+plot(x,y1,x,y2,x,y3,x,y4)
+legend('t1','t2','t3','t4')
+xlabel('x')
+ylabel('y')
diff --git a/260/CH15/EX15.5/15_5.sce b/260/CH15/EX15.5/15_5.sce
new file mode 100644
index 000000000..f61ac0617
--- /dev/null
+++ b/260/CH15/EX15.5/15_5.sce
@@ -0,0 +1,24 @@
+//Eg-15.5
+//pg-619
+
+clear
+clc
+close()
+
+y = zeros(5,5);
+
+y(1:5,1) = 10;
+y(1:5,5) = 10;
+y(1,5:4) = 0;
+//y(1,2:4) = 10;
+
+for(i = 3:5)
+ for(j = 2:4)
+ y(i,j) = y(i-1,j+1) + y(i-1,j-1) - y(i-2,j);
+ end
+end
+
+printf('The table of the y values with different rows as different timelines :\n')
+
+Y = y(2:5,:)
+disp(Y) \ No newline at end of file