-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_analysis_script3D.m
121 lines (118 loc) · 6.27 KB
/
data_analysis_script3D.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
116
117
118
119
120
121
function data_analysis_script3D(n,seeds,choice)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% data_analysis_script3D(n,seeds,choice)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colects the different grain statistics 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dims = [n n n];
clearvars -except n seeds choice dims;
max_epoch = 2; % number of intermediate steps stored
file_save = ['data3d-',num2str(choice)];
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));
volumes_grains = cell(length(seeds),max_epoch+1);
volumes_convhull = cell(length(seeds),max_epoch+1);
volumes_grains_alt = cell(length(seeds),max_epoch+1);
volumes_convhull_alt = cell(length(seeds),max_epoch+1);
surface_areas_grains = cell(length(seeds),max_epoch+1);
mdf = cell(length(seeds),max_epoch+1);
nNeighbors = cell(length(seeds),max_epoch+1);
volumes_grains_original = cell(length(seeds),max_epoch+1);
volumes_convhull_original = cell(length(seeds),max_epoch+1);
volumes_grains_alt_original = cell(length(seeds),max_epoch+1);
volumes_convhull_alt_original = cell(length(seeds),max_epoch+1);
surface_areas_grains_original = cell(length(seeds),max_epoch+1);
mdf_original = cell(length(seeds),max_epoch+1);
nNeighbors_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);
[volumes_grains{l,epoch+1}, volumes_convhull{l,epoch+1},...
volumes_grains_alt{l,epoch+1}, volumes_convhull_alt{l,epoch+1},...
surface_areas_grains{l,epoch+1},mdf{l,epoch+1}, nNeighbors{l,epoch+1}]...
= compute_statistics3D(grains_component,dims,ori_component,dt);
save_variable(file_save,volumes_grains,'volumes_grains')
save_variable(file_save,volumes_convhull,'volumes_convhull')
save_variable(file_save,volumes_grains_alt,'volumes_grains_alt')
save_variable(file_save,volumes_convhull,'volumes_convhull_alt')
save_variable(file_save,surface_areas_grains,'surface_areas_grains')
save_variable(file_save,mdf,'mdf')
save_variable(file_save,nNeighbors,'nNeighbors')
if epoch == 0
volumes_grains_original{l,epoch+1} = volumes_grains{l,epoch+1};
volumes_convhull_original{l,epoch+1} = volumes_convhull{l,epoch+1};
volumes_grains_alt_original{l,epoch+1} = volumes_grains_alt{l,epoch+1};
volumes_convhull_alt_original{l,epoch+1} = volumes_convhull_alt{l,epoch+1};
surface_areas_grains_original{l,epoch+1} = surface_areas_grains{l,epoch+1};
mdf_original{l,epoch+1} = mdf{l,epoch+1};
nNeighbors_original{l,epoch+1} = nNeighbors{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);
[volumes_grains_original{l,epoch+1}, volumes_convhull_original{l,epoch+1},...
volumes_grains_alt_original{l,epoch+1}, volumes_convhull_alt_original{l,epoch+1},...
surface_areas_grains_original{l,epoch+1},mdf_original{l,epoch+1}, nNeighbors_original{l,epoch+1}]...
= compute_statistics3D(grains_component,dims,ori_component,dt);
end
save_variable(file_save,volumes_grains_original,'volumes_grains_original')
save_variable(file_save,volumes_convhull_original,'volumes_convhull_original')
save_variable(file_save,volumes_grains_alt_original,'volumes_grains_alt_original')
save_variable(file_save,volumes_convhull_original,'volumes_convhull_alt_original')
save_variable(file_save,surface_areas_grains_original,'surface_areas_grains_original')
save_variable(file_save,mdf_original,'mdf_original')
save_variable(file_save,nNeighbors_original,'nNeighbors_original')
end
end
end
end