-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExplicit1DNoFlux.m
53 lines (46 loc) · 1010 Bytes
/
Explicit1DNoFlux.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
%
% 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
%
clf
clear
t = cputime ;
%not dimensionalised numbers
delt = 0.1;
delx = 0.5;
D = 1.0;
alpha = D*delt/(delx*delx);
%initial conditions
% c(1) = C_0 and the remoining is 0.0
c = zeros(101,1);
c_t = zeros(101,1);
c(1) = 1;
c_t(1) = 1;
%plot the initial profile
plot (c, 'r-;Initial profile;');
%get handle
ax = gca ;
set(ax, "linewidth",2.0);
axis("square");
%hold the plot
hold on
% Compostion evolution
for k = 1:20 %this is for plotting
for j = 1:500
for i = 2:100
c_t(i) = c(i)*(1 - 2*alpha) + alpha*(c(i-1) + c(i+1) );
endfor # ending i loop
c_t(101) = c(101)*(1-2*alpha) + 2*alpha*(c(100));
c = c_t;
endfor # ending j loop
plot (c )
endfor # ending k loop
% Save figure
print -depsc Explicit1D.eps
printf('Total cpu time: %f seconds\n', cputime-t);