summaryrefslogtreecommitdiff
path: root/260/CH14/EX14.3/14_3.sce
blob: e1c2464fcbd79a055f362a65e73a5c7c988283a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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')