-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_phase_field.txt
100 lines (82 loc) · 2.43 KB
/
test_phase_field.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
% test for phase field discrete
% to set R=10, larger than setup radius
% let phase field parameter range from 0 to 1
% 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);
R=10;
P=ones(r,s);
P_x=zeros(r,s);
P_y=zeros(r,s);
P_xx=zeros(r,s);
P_yy=zeros(r,s);
P_xy=zeros(r,s);
for n=0.1:0.1:1
n
for i=1:r
for j=1:s
P(i,j)=0;
if (i-r/2)^2+(j-s/2)^2<R^2
P(i,j)=n;
end
end
end
end
for i=1:r
for j=1:s
if i==1 && j==1
P_x(i,j)=0;
P_y(i,j)=0;
P_xx(i,j)=0;
P_yy(i,j)=0;
elseif i==r && j==1
P_x(i,j)=0;
P_y(i,j)=0;
P_xx(i,j)=0;
P_yy(i,j)=0;
elseif i==1 && j==s
P_x(i,j)=0;
P_y(i,j)=0;
P_xx(i,j)=0;
P_yy(i,j)=0;
elseif i==r && j==s
P_x(i,j)=0;
P_y(i,j)=0;
P_xx(i,j)=0;
P_yy(i,j)=0;
elseif i<r && i>1 && j==1
P_x(i,j)=0.5*(P(i+1,j)-P(i-1,j))/dx;
P_y(i,j)=0;
P_xx(i,j)=(P(i+1,j)+P(i-1,j)-2*P(i,j))/(dx)^2;
P_yy(i,j)=0;
elseif i<r && i>1 && j==s
P_x(i,j)=0.5*(P(i+1,j)-P(i-1,j))/dx;
P_y(i,j)=0;
P_xx(i,j)=(P(i+1,j)+P(i-1,j)-2*P(i,j))/(dx)^2;
P_yy(i,j)=0;
elseif j<r && j>1 && i==1
P_x(i,j)=0;
P_y(i,j)=0.5*(P(i,j+1)-P(i,j-1))/dy;
P_xx(i,j)=0;
P_yy(i,j)=(P(i,j+1)+P(i,j-1)-2*P(i,j))/(dy)^2;
elseif j<r && j>1 && i==r
P_x(i,j)=0;
P_y(i,j)=0.5*(P(i,j+1)-P(i,j-1))/dy;
P_xx(i,j)=0;
P_yy(i,j)=(P(i,j+1)+P(i,j-1)-2*P(i,j))/(dy)^2;
else
P_x(i,j)=0.5*(P(i+1,j)-P(i-1,j))/dx;
P_y(i,j)=0.5*(P(i,j+1)-P(i,j-1))/dy;
P_xx(i,j)=(P(i+1,j)+P(i-1,j)-2*P(i,j))/(dx)^2;
P_yy(i,j)=(P(i,j+1)+P(i,j-1)-2*P(i,j))/(dy)^2;
P_xy(i,j)=(P(i+1,j+1)-P(i-1,j+1)-P(i+1,j-1)+P(i-1,j-1))/(4*dx^2);
end
end
end