-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_anisotropy.txt
126 lines (102 loc) · 3.38 KB
/
test_anisotropy.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
% test for anisotropy
% R=10
% range phase field parameter, to see anisotropy result
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);
delta=0.02;
jq=6;
R=10;
theta=zeros(r,s);
theta_x=zeros(r,s);
theta_y=zeros(r,s);
eta2dthe=zeros(r,s);
etathe=zeros(r,s);
etaprimethe=zeros(r,s);
eta=zeros(r,s);
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
for i=1:r
for j=1:s
theta(i,j)=atan(P_y(i,j)/(P_x(i,j)+1e-80)); % add one small constance for preventing denominator equals to zero
eta2dthe(i,j)=-delta*jq*(2*sin(jq*theta(i,j))+delta*sin(2*jq*theta(i,j))); % d eta^2/d theta
etathe(i,j)=-delta*jq*sin(jq*theta(i,j)); % d eta/d theta
etaprimethe(i,j)=-delta*jq^2*cos(jq*theta(i,j)); % d etaprime/d theta
eta(i,j)=1+delta*cos(jq*theta(i,j)); % eta
theta_x(i,j)=(P_x(i,j)*P_xy(i,j)-P_y(i,j)*P_xx(i,j))/(P_x(i,j)^2+P_y(i,j)^2+1e-40); % d theta/dx
theta_y(i,j)=(P_x(i,j)*P_yy(i,j)-P_y(i,j)*P_xy(i,j))/(P_x(i,j)^2+P_y(i,j)^2+1e-40); % d theta/dy
%epsilon_d(i,j)=-epsilonbar*delta*j*sin(jq*(theta(i,j)-theta0(i,j)));
end
end