summaryrefslogtreecommitdiff
path: root/260/CH14/EX14.3/14_3.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /260/CH14/EX14.3/14_3.sce
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/CH14/EX14.3/14_3.sce')
-rw-r--r--260/CH14/EX14.3/14_3.sce41
1 files changed, 41 insertions, 0 deletions
diff --git a/260/CH14/EX14.3/14_3.sce b/260/CH14/EX14.3/14_3.sce
new file mode 100644
index 000000000..e1c2464fc
--- /dev/null
+++ b/260/CH14/EX14.3/14_3.sce
@@ -0,0 +1,41 @@
+//Eg-14.3
+//pg-583
+
+clear
+clc
+close()
+
+//Analytically solving the given equation using central difference formula we get 3 equations at 3 internal points
+
+// At point 1 T0 - 2*T1 + T2 = -3.125 (1)
+// At point 2 T1 - 2*T2 + T3 = -3.125 (2)
+// At point 3 T2 - 2*T3 + T4 = -3.125 (3)
+
+// Using BC 1 T-1 = T1
+// Using BC 2 T5 = T3 - 0.25*T4 + 75;
+
+// using BC 1 in (1), we get T1 - T0 = -1.5625 (4)
+// using the value of T5 in the BC gives 2*T3 - 2.25*T4 = -78.125 (5)
+
+//Solving these equations gives the values of T at different points
+
+A = [1 -2 1 0 0;0 1 -2 1 0;0 0 1 -2 1;1 -1 0 0 0;0 0 0 2 -2.25];
+B = [-3.125;-3.125;-3.125;1.5625;-78.125];
+
+X = inv(A)*B;
+
+x = 0:0.25:1;
+
+plot(x,X,'ks')
+
+//Analytically
+
+L = 1;
+x1 = 0:0.01:1;
+T = 300 + 50*L^2/(2)*(1-(x1/L)^2 + 2*2);
+
+plot(x1,T)
+
+xlabel('x(m)')
+ylabel('T(K)')
+legend('FD solution','Analytical Solution') \ No newline at end of file