-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_temperature.txt
68 lines (57 loc) · 1.69 KB
/
test_temperature.txt
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% test for temperature discrete
% set R=10
% set phase field parameter equals to zero
% range temperature from 0.9 to 1.2
% test if the discrete euqation makes sense
clear;clc;clf;tic
nx=9;
ny=nx;
dx=0.03;
xnode=dx:dx:nx;
r=length(xnode);
dy=dx;
ynode=dy:dy:ny;
s=length(ynode);
dt=0.0001;
R=10;
K=2.0;
P=zeros(r,s);
Pn=zeros(r,s);
T=zeros(r,s);
Tn=zeros(r,s);
Te=zeros(r,s);
for n=0.9:0.05:1.2
n
for i=1:r
for j=1:s
T(i,j)=0; % T=Treal/Tm
Te(i,j)=n;
if (i-r/2)^2+(j-s/2)^2<R^2
T(i,j)=1;
end
end
end
end
for i=1:r
for j=1:s
if i==1 && j==1
Tn(i,j)=K*(Pn(i,j)-P(i,j))+T(i,j);
elseif i==r && j==1
Tn(i,j)=K*(Pn(i,j)-P(i,j))+T(i,j);
elseif i==1 && j==s
Tn(i,j)=K*(Pn(i,j)-P(i,j))+T(i,j);
elseif i==r && j==s
Tn(i,j)=K*(Pn(i,j)-P(i,j))+T(i,j);
elseif i<r && i>1 && j==1
Tn(i,j)=dt/(dx)^2*(T(i+1,j)+T(i-1,j)-2*T(i,j))+K*(Pn(i,j)-P(i,j))+T(i,j);
elseif i<r && i>1 && j==s
Tn(i,j)=dt/(dx)^2*(T(i+1,j)+T(i-1,j)-2*T(i,j))+K*(Pn(i,j)-P(i,j))+T(i,j);
elseif j<r && j>1 && i==1
Tn(i,j)=dt/(dy)^2*(T(i,j+1)+T(i,j-1)-2*T(i,j))+K*(Pn(i,j)-P(i,j))+T(i,j);
elseif j<r && j>1 && i==r
Tn(i,j)=dt/(dy)^2*(T(i,j+1)+T(i,j-1)-2*T(i,j))+K*(Pn(i,j)-P(i,j))+T(i,j);
else
Tn(i,j)=dt*(T(i,j+1)+T(i,j-1)+T(i+1,j)+T(i-1,j)+0.5*(T(i+1,j+1)+T(i+1,j-1)+T(i-1,j+1)+T(i-1,j-1))-6*T(i,j))/(dx)^2+K*(Pn(i,j)-P(i,j))+T(i,j);
end
end
end