-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAllenCahn.m
46 lines (45 loc) · 813 Bytes
/
AllenCahn.m
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
%
% Copyright (c) 2018, Vishal_S
% All rights reserved. Please read the "license.txt" for license terms.
%
% Project Title: Phase field modelling
%
% Developer: Vishal S
%
% Contact Info: [email protected]
%
clear
clf
t = cputime;
delt = 0.5;
dx = 1.0;
N = 128;
L = 1.0;
A = 1.0;
kappa = 1.0;
phi = zeros(N,1);
for i = (N/4) + 1 : 3*(N/4)
phi(i) = 1.0;
endfor
plot(phi,'r-;Initial;');
hold on;
halfN = N/2;
delk = 2*pi/N;
for m= 1:400
g = 2*A.*phi.*(1-phi).*(1-2.*phi);
ghat = fft(g);
phihat = fft(phi ) ;
for i = 1:N
if((i-1)<=halfN)
k = (i-1)*delk;
endif
if((i-1)>halfN)
k = (i-1-N)*delk;
endif
k2 = k*k;
phihat(i) = (phihat(i) - L*delt*ghat(i))/(1+ 2*kappa*L*delt*k2);
endfor
phi = real(ifft(phihat));
endfor
plot(phi,'g');
print -depsc AC1DFT.eps