-
Notifications
You must be signed in to change notification settings - Fork 2
/
texeval2mtex.m
241 lines (201 loc) · 7.64 KB
/
texeval2mtex.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
%% TexEval to MTEX
% Created on Jul 31 2018 by Håkon Wiik Ånes (hakon.w.anes@ntnu.no)
% Updated on October 30 2019
%
% Create a MTEX PoleFigure object from four pole figures by using
% loadPoleFigure_generic, and
% 1. calculate the ODF
% 2. plot intensities along fibres (beta, Cube-Goss)
% 3. calculate volume fractions
%
% Working with:
% MATLAB > R2018a
% MTEX 5.2.beta2
%% Import pole figure data and create PoleFigure object
cs = crystalSymmetry('m-3m', [4.04 4.04 4.04], 'mineral', 'Al');
path = 'path/to/files/';
fnamesPrefix = 'my_sample_R';
fnames = {
fullfile(path, [fnamesPrefix '_pf111_uncorr.dat']),...
fullfile(path, [fnamesPrefix '_pf200_uncorr.dat']),...
fullfile(path, [fnamesPrefix '_pf220_uncorr.dat']),...
fullfile(path, [fnamesPrefix '_pf311_uncorr.dat'])};
% Specimen symmetry
ss = specimenSymmetry('1'); % Triclinic
ssO = specimenSymmetry('orthorhombic');
% Plotting convention
setMTEXpref('xAxisDirection', 'north');
setMTEXpref('zAxisDirection', 'outOfPlane');
% Set annotations to highlight spatial reference frame
pfAnnotations = @(varargin) text([vector3d.X, vector3d.Y],...
{'RD', 'TD'}, 'BackgroundColor', 'w', 'tag', 'axesLabels', varargin{:});
setMTEXpref('pfAnnotations', pfAnnotations);
h = {
Miller(1, 1, 1, cs),...
Miller(2, 0, 0, cs),...
Miller(2, 2, 0, cs),...
Miller(3, 1, 1, cs)};
% Load pole figures separately
columnNames = {'Polar Angle', 'Azimuth Angle', 'Intensity'};
pf1 = loadPoleFigure_generic(fnames{1}, 'ColumnNames', columnNames);
pf2 = loadPoleFigure_generic(fnames{2}, 'ColumnNames', columnNames);
pf3 = loadPoleFigure_generic(fnames{3}, 'ColumnNames', columnNames);
pf4 = loadPoleFigure_generic(fnames{4}, 'ColumnNames', columnNames);
% Construct pole figure object of the four pole figures
intensities = {
pf1.intensities,...
pf2.intensities,...
pf3.intensities,...
pf4.intensities};
pfs = PoleFigure(h, pf1.r, intensities, cs, ss);
%% Plot pole figures of raw, corrected data
figure
plot(pfs, 'upper', 'projection', 'eangle', 'minmax')
mtexColorbar('location', 'southOutside')
%% Calculate the ODF using default settings
odf = calcODF(pfs)
% Set correct specimen symmetry for calculation of texture strength
odf.SS = ssO;
% Calculate texture strength
textureIndex = odf.textureindex
entropy = odf.entropy
odfMax = odf.max
%% ODF in {111} PF with specified contour levels
levelsPF = [0, 1, 2, 3, 4, 5];
odf.SS = ss;
figure
plotPDF(odf, h, 'upper', 'projection', 'eangle', 'contourf', levelsPF)
mtexColorbar
%% Define ideal texture components and spread acceptance angle
br = orientation.byEuler(35*degree, 45*degree, 90*degree, cs, ssO);
cu = orientation.byEuler(90*degree, 35*degree, 45*degree, cs, ssO);
cube = orientation.byEuler(0, 0, 0, cs, ssO);
cubeND = orientation.byMiller([0 0 1], [3 1 0], cs, ssO);
cubeND45 = orientation.byEuler(45*degree, 0, 0, cs, ssO);
goss = orientation.byEuler(0, 45*degree, 0, cs, ssO);
p = orientation.byMiller([0 1 1], [1 2 2], cs, ssO);
q = orientation.byMiller([0 1 3], [2 3 1], cs, ssO);
s = orientation.byEuler(59*degree, 37*degree, 63*degree, cs, ssO);
%% Plot ODF in Euler space phi2 sections
levelsODF = [0, 1, 2, 3, 4, 8, 12];
odf.SS = ssO;
figure
plot(odf, 'phi2', [0 45 65]*degree, 'contourf', levelsODF, 'minmax')
mtexColorbar
hold on
annotate(br.symmetrise, 'marker', 'd', 'markerfacecolor', 'g')
annotate(cu.symmetrise, 'marker', '^', 'markerfacecolor', 'b')
annotate(cube.symmetrise, 'marker', 's', 'markerfacecolor', 'r')
annotate(cubeND.symmetrise, 'marker', 's', 'markerfacecolor', 'r')
annotate(goss.symmetrise, 'marker', 'o', 'markerfacecolor', 'y')
annotate(q.symmetrise, 'marker', '>', 'markerfacecolor', 'c')
annotate(s.symmetrise, 'marker', 'p', 'markerfacecolor', 'm')
hold off
figure
plot(odf, 'sections', 18, 'contourf', levelsODF)
mtexColorbar
hold on
annotate(br.symmetrise, 'marker', 'd', 'markerfacecolor', 'g')
annotate(cu.symmetrise, 'marker', '^', 'markerfacecolor', 'b')
annotate(cube.symmetrise, 'marker', 's', 'markerfacecolor', 'r')
annotate(cubeND.symmetrise, 'marker', 's', 'markerfacecolor', 'r')
annotate(goss.symmetrise, 'marker', 'o', 'markerfacecolor', 'y')
annotate(q.symmetrise, 'marker', '>', 'markerfacecolor', 'c')
annotate(s.symmetrise, 'marker', 'p', 'markerfacecolor', 'm')
hold off
%% Plot inverse pole figure
figure
plotIPDF(odf, [xvector, yvector, zvector], 'contourf', 'minmax') % contoured
%plotIPDF(odf, [xvector, yvector, zvector]) % continuous
mtexColorMap WhiteJet % or e.g. white2black
mtexColorbar
%% Calculate volume fractions Mi
spread = 10*degree;
Mbr = volume(odf, br, spread)
Mcu = volume(odf, cu, spread)
Mcube = volume(odf, cube, spread)
McubeND = volume(odf, cubeND, spread)
McubeND45 = volume(odf, cubeND45, spread)
Mgoss = volume(odf, goss, spread)
Mp = volume(odf, p, spread)
Mq = volume(odf, q, spread)
Ms = volume(odf, s, spread)
%% Plot intensity along beta fibre from Cu to Brass and write results to file
odf.SS = ssO;
f = fibre(cu, br, cs, ssO);
% generate list from fibres and evalute ODF at specific orientations
fibreOris = f.orientation;
evalOris = [];
evalIndex = [1 84 167 254 346 446 556 680 824 1000];
evalValues = zeros(1, 10);
for i=1:10
ori = fibreOris(evalIndex(i));
evalOris = [evalOris ori];
evalValues(i) = eval(odf, ori);
end
figure
plot(evalOris.phi2/degree, evalValues, '-o')
xlabel('\phi_2 \rightarrow', 'interpreter', 'tex')
ylabel('Orientation density f(g)', 'interpreter', 'tex')
xlim([45 90])
% Write fibre data to a csv file for further analysis
datafname = fullfile(path, 'data_fibre_beta.csv');
% Write header to file
fid = fopen(datafname, 'w');
fprintf(fid, '%s\r\n', 'phi1,Phi,phi2,fibreValue');
fclose(fid);
% Write Euler angles and intensities to file
dlmwrite(datafname, [(evalOris.phi1/degree)' (evalOris.Phi/degree)'...
(evalOris.phi2/degree)' evalValues'], '-append')
%% Plot intensity along fibre from Cube to Goss and write results to file
odf.SS = ssO;
f = fibre(cube, goss, cs, ssO);
% Generate list from fibres and evalute ODF at specific orientations
fibreOris = f.orientation;
evalOris = [];
evalIndex = [1 111 222 333 444 555 666 777 888 1000];
evalValues = zeros(1, 10);
for i=1:10
ori = fibreOris(evalIndex(i));
evalOris = [evalOris ori];
evalValues(i) = eval(odf, ori);
end
figure
plot(evalOris.Phi/degree, evalValues, '-o')
xlabel('\Phi \rightarrow', 'interpreter', 'tex')
ylabel('Orientation density f(g)', 'interpreter', 'tex')
xlim([0 45])
% Write fibre data to a csv file for further analysis
datafname = fullfile(path, 'data_fibre_cube_goss.csv');
% Write header to file
fid = fopen(datafname, 'w');
fprintf(fid, '%s\r\n', 'phi1,Phi,phi2,fibreValue');
fclose(fid);
% Write Euler angles and intensities to file
dlmwrite(datafname, [(evalOris.phi1/degree)' (evalOris.Phi/degree)'...
(evalOris.phi2/degree)' evalValues'], '-append')
%% Plot intensity along fibre from Cube to ND-rotated Cube
odf.SS = ssO;
f = fibre(cube, cubeND45, cs, ssO);
% Generate list from fibres and evalute ODF at specific orientations
fibreOris = f.orientation;
evalOris = [];
evalIndex = [1 111 222 333 444 555 666 777 888 1000];
evalValues = zeros(1,10);
for i=1:10
ori = fibreOris(evalIndex(i));
evalOris = [evalOris ori];
evalValues(i) = eval(odf, ori);
end
figure
plot(evalOris.phi1/degree, evalValues, '-o')
xlabel('\phi_1 \rightarrow', 'interpreter', 'tex')
ylabel('Orientation density f(g)', 'interpreter', 'tex')
xlim([0 45])
% Write fibre data to csv file for further analysis in Python
datafname = fullfile(path, 'data_fibre_cube_cubeND45.csv');
fid = fopen(datafname, 'w');
fprintf(fid, '%s\r\n', 'phi1,Phi,phi2,fibreValue');
fclose(fid);
dlmwrite(datafname, [(evalOris.phi1/degree)' (evalOris.Phi/degree)'...
(evalOris.phi2/degree)' evalValues'], '-append')