-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_analysis_script3D_slices.m
115 lines (109 loc) · 5.8 KB
/
data_analysis_script3D_slices.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
function data_analysis_script3D_slices(n,seeds,choice,spacing)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% data_analysis_script3D_slices(n,seeds,choice,spacing)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colects the different grain statistics on the 2D slices from 3D
% grain boundary motion. Data files must be stored in the folder
% 'Simulations 3D' as generated by the 'run_simulations3D' function.
%
% INPUT:
% n = Grid dimension of the simulations
% seeds = Seeds used to detect the correct file
% choice = Type of initial data to detect the correct file
% spacing = number of grids in between the 2D slices collected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
max_epoch = 2; % number of intermediate steps stored
dims = [n n n];
clearvars -except n seeds choice spacing max_epoch dims;
file_save = ['data3d-',num2str(choice),'-slices'];
save(file_save,'-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_slices = cell(length(seeds),max_epoch+1);
areas_convhull_slices = cell(length(seeds),max_epoch+1);
mdf_slices = cell(length(seeds),max_epoch+1);
nNeighbors_slices = cell(length(seeds),max_epoch+1);
isopratio_slices = cell(length(seeds),max_epoch+1);
areas_grains_slices_original = cell(length(seeds),max_epoch+1);
areas_convhull_slices_original = cell(length(seeds),max_epoch+1);
mdf_slices_original = cell(length(seeds),max_epoch+1);
nNeighbors_slices_original = cell(length(seeds),max_epoch+1);
isopratio_slices_original = cell(length(seeds),max_epoch+1);
for l = seeds
filename = ['./Simulations 3D/','simulation3d-',num2str(choice),'-',num2str(dims(1)),'x',num2str(dims(2)),'x',num2str(dims(3)),'-',num2str(l),'.mat']
if exist(filename, 'file') == 2
disp(l)
load(filename,'alpha','beta')
list_alpha(l) = alpha;
list_beta(l) = beta;
save_variable(file_save,list_alpha,'list_alpha')
save_variable(file_save,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(file_save,list_t1,'list_t1')
save_variable(file_save,list_t2,'list_t2')
save_variable(file_save,list_t1_original,'list_t1_original')
save_variable(file_save,list_t2_original,'list_t2_original')
load(filename,'ori_t0')
for epoch = 0:max_epoch
disp(['Compute statistics epoch = ',num2str(epoch)])
load(filename,['grains_t',num2str(epoch)]);
grains = eval(['grains_t',num2str(epoch)]);
dt = 2/n^2;
load(filename,'Rfamilies');
if epoch == 0
ID = (1:1:size(grains,1))';
else
load(filename,['ID_t',num2str(epoch)]);
ID = eval(['ID_t',num2str(epoch)]);
end
[grains_component, ori_component] = compute_grains_component3d(grains,ori_t0,ID,dims,Rfamilies);
[areas_grains_slices{l,epoch+1}, areas_convhull_slices{l,epoch+1},...
nNeighbors_slices{l,epoch+1},mdf_slices{l,epoch+1},...
isopratio_slices{l,epoch+1}] =...
compute_statistics_slices3D(grains_component,dims,ori_component,Rfamilies,dt,spacing);
save_variable(file_save,areas_grains_slices,'areas_grains_slices')
save_variable(file_save,areas_convhull_slices,'areas_convhull_slices')
save_variable(file_save,mdf_slices,'mdf_slices')
save_variable(file_save,nNeighbors_slices,'nNeighbors_slices')
save_variable(file_save,isopratio_slices,'isopratio_slices')
if epoch == 0
areas_grains_slices_original{l,epoch+1} = areas_grains_slices{l,epoch+1};
areas_convhull_slices_original{l,epoch+1} = areas_convhull_slices{l,epoch+1};
mdf_slices_original{l,epoch+1} = mdf_slices{l,epoch+1};
nNeighbors_slices_original{l,epoch+1} = nNeighbors_slices{l,epoch+1};
isopratio_slices_original{l,epoch+1} = isopratio_slices{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']);
dt = 2/n^2;
if epoch == 0
ID = (1:1:size(grains,1))';
else
load(filename,['ID_t',num2str(epoch),'_original']);
ID = eval(['ID_t',num2str(epoch),'_original']);
end
[grains_component, ori_component] = compute_grains_component3d(grains,ori_t0,ID,dims,Rfamilies);
[areas_grains_slices_original{l,epoch+1}, areas_convhull_slices_original{l,epoch+1},...
nNeighbors_slices_original{l,epoch+1},mdf_slices_original{l,epoch+1},...
isopratio_slices_original{l,epoch+1}] =...
compute_statistics_slices3D(grains_component,dims,ori_component,Rfamilies,dt,spacing);
end
save_variable(file_save,areas_grains_slices_original,'areas_grains_slices_original')
save_variable(file_save,areas_convhull_slices_original,'areas_convhull_slices_original')
save_variable(file_save,mdf_slices_original,'mdf_slices_original')
save_variable(file_save,nNeighbors_slices_original,'nNeighbors_slices_original')
save_variable(file_save,isopratio_slices_original,'isopratio_slices_original')
end
end
end
end