-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_analysis_script2D.m
98 lines (96 loc) · 4.78 KB
/
data_analysis_script2D.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
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
function data_analysis_script2D(n,seeds)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% data_analysis_script2D(n,seeds)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colects the different grain statistics from 2D grain boundary
% motion. Data files must be stored in the folder 'Simulations 2D'
% as generated by the 'run_simulations2D' function.
%
% INPUT:
% n = Grid dimension of the simulations
% seeds = Seeds used to detect the correct file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
max_epoch = 2; % number of intermediate steps stored
dims = [n n];
clearvars -except n seeds max_epoch dims;
mkdir Data
save('./Data/data2d','-v7.3')
list_alpha = zeros(1,length(seeds));
list_beta = zeros(1,length(seeds));
list_t1 = zeros(1,length(seeds));
list_t2 = zeros(1,length(seeds));
list_t1_original = zeros(1,length(seeds));
list_t2_original = zeros(1,length(seeds));
areas_grains = cell(length(seeds),max_epoch+1);
areas_convhull = cell(length(seeds),max_epoch+1);
mdf = cell(length(seeds),max_epoch+1);
nNeighbors = cell(length(seeds),max_epoch+1);
isopratio = cell(length(seeds),max_epoch+1);
areas_grains_original = cell(length(seeds),max_epoch+1);
areas_convhull_original = cell(length(seeds),max_epoch+1);
mdf_original = cell(length(seeds),max_epoch+1);
nNeighbors_original = cell(length(seeds),max_epoch+1);
isopratio_original = cell(length(seeds),max_epoch+1);
for l = seeds
filename = ['./Simulations 2D/','simulation2d-',num2str(dims(1)),'x',num2str(dims(2)),'-',num2str(l),'.mat']
if exist(filename, 'file') == 2
disp(l)
load(filename,'alpha','beta')
list_alpha(l) = alpha;
list_beta(l) = beta;
save_variable('data2d',list_alpha,'list_alpha')
save_variable('data2d',list_beta,'list_beta')
load(filename,'t1','t2')
list_t1(l) = t1;
list_t2(l) = t2;
load(filename,'t1_original','t2_original')
list_t1_original(l) = t1_original;
list_t2_original(l) = t2_original;
save_variable('data2d',list_t1,'list_t1')
save_variable('data2d',list_t2,'list_t2')
save_variable('data2d',list_t1_original,'list_t1_original')
save_variable('data2d',list_t2_original,'list_t2_original')
for epoch = 0:max_epoch
disp(['Compute statistics epoch = ',num2str(epoch)])
load(filename,['grains_t',num2str(epoch)]);
grains = eval(['grains_t',num2str(epoch)]);
load(filename,['ori_t',num2str(epoch)]);
ori = eval(['ori_t',num2str(epoch)]);
dt = 2/n^2;
load(filename,'Rfamilies');
[grains_component, ori_component] = compute_grains_component2d(grains,ori,dims,Rfamilies);
[areas_grains{l,epoch+1}, areas_convhull{l,epoch+1},...
mdf{l,epoch+1},nNeighbors{l,epoch+1}, isopratio{l,epoch+1}]...
= compute_statistics2D(grains_component,dims,ori_component,dt);
save_variable('data2d',areas_grains,'areas_grains')
save_variable('data2d',areas_convhull,'areas_convhull')
save_variable('data2d',mdf,'mdf')
save_variable('data2d',nNeighbors,'nNeighbors')
save_variable('data2d',isopratio,'isopratio')
if epoch == 0
areas_grains_original{l,epoch+1} = areas_grains{l,epoch+1};
areas_convhull_original{l,epoch+1} = areas_convhull{l,epoch+1};
mdf_original{l,epoch+1} = mdf{l,epoch+1};
nNeighbors_original{l,epoch+1} = nNeighbors{l,epoch+1};
isopratio_original{l,epoch+1} = isopratio{l,epoch+1};
else
disp(['Compute statistics (original) epoch = ',num2str(epoch)])
load(filename,['grains_t',num2str(epoch),'_original']);
grains = eval(['grains_t',num2str(epoch),'_original']);
load(filename,['ori_t',num2str(epoch),'_original']);
ori = eval(['ori_t',num2str(epoch),'_original']);
dt = 2/n^2;
[grains_component, ori_component] = compute_grains_component2d(grains,ori,dims,Rfamilies);
[areas_grains_original{l,epoch+1}, areas_convhull_original{l,epoch+1},...
mdf_original{l,epoch+1},nNeighbors_original{l,epoch+1}, isopratio_original{l,epoch+1}]...
= compute_statistics2D(grains_component,dims,ori_component,dt);
end
save_variable('data2d',areas_grains_original,'areas_grains_original')
save_variable('data2d',areas_convhull_original,'areas_convhull_original')
save_variable('data2d',mdf_original,'mdf_original')
save_variable('data2d',nNeighbors_original,'nNeighbors_original')
save_variable('data2d',isopratio_original,'isopratio_original')
end
end
end
end