-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInterfaceEnergyCH.m
72 lines (67 loc) · 1.19 KB
/
InterfaceEnergyCH.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
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
%
% 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: vishalsubbu97@gmail.com
%
clear
clf
t = cputime;
delt = 0.5;
N = 128;
D = 1;
c = zeros(N,1);
ctilde = zeros(N,1);
for i = (N/4) + 1: 3*N/4
c(i) = 1.0
endfor
#plot the initial profile
plot (c , 'r-');
hold on;
halfN = N/2;
delk = 2*pi/N;
for j= 1:4000
g = 2.*c.*(1-c).*(1-2.*c);
ghat = fft(g);
chat = fft(c) ;
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;
k4 = k2*k2;
chat(i) = (chat(i) - (k2*delt*ghat(i)))/(1+(2*k4*delt));
endfor
c = real(ifft(chat));
endfor
plot(c,'g');
chat = fft(c);
for i = 1:N
if((i-1)<=halfN)
k = (i-1)*delk;
endif
if((i-1)>halfN)
k = (i-1-N)*delk;
endif
chat (i) = complex(0,1) *k*chat(i);
endfor
cprime = real(ifft(chat));
energy1 -0.0;
energy2 = 0.0;
kappa = 1.0;
A = 1.0;
for i = 1:N
energy1 = energy1 + A*c(i)*c(i)*(1-c(i))*(1-c(i));
energy2 = energy2 + kappa*cprime(i)*cprime(i);
endfor
energy1
energy2
0.5*(energy1 + energy2)
print -depsc CH1DFT.eps