grain average GND map and Grain average GND density plotted against grain area #639
Unanswered
LuqingCui
asked this question in
Ask Anything
Replies: 3 comments 1 reply
-
Hi Luqing,
If you have a variable for GND at every EBSD pixel, and you have computed grains, you can use accumarray() to compute a mean GND value for each grain:
grainGND = accumarray(ebsd.grainId, GND, size(grains), @nanmean);
Does that work for you?
Cheers,
Zach
… On Dec 19, 2020, at 9:24 AM, LuqingCui ***@***.***> wrote:
Hi all,
Does anyone know how to calculate the grain average GND map? I have obtained the GND map on each pixel for FCC metal based on the code on MTEX website: https://mtex-toolbox.github.io/GND.html <https://mtex-toolbox.github.io/GND.html>.
But how to get the grain average GND map (Fig. 3h) and ### Grain average GND density plotted against grain area (Fig. 3i) as follows:
<https://user-images.githubusercontent.com/72967420/102692807-1bea8480-4216-11eb-8964-98a9f64dded7.png>
Thank you very much in advance!
Best regards,
Luqing Cui
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#639>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACC5AU7AFN54NJQ43UFZC33SVTAUTANCNFSM4VCLT43Q>.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Yes. You need to have existing grains for each existing ebsd.grainId. But after you get rid of some grains, you then have a different number of grain ids than those stores in ebsd.grainId.
*After* removing grains and recomputing (“redo”) grains, try adding a line of:
ebsd = ebsd(grains)
Then proceed with the rest of your code and see if that works.
Cheers,
Zach
… On Dec 20, 2020, at 9:11 AM, LuqingCui ***@***.***> wrote:
Hi Cheers,
Thanks for your reply. I type the code as you suggested, and when the code run to the line of "grainGND = accumarray(ebsd.grainId, gnd_tot, size(grains), @nanmean);"
The error comesout as follows:
The code I used is as follows:
import_wizard
ebsd=ebsd('fe')
% define the color key
ipfKey = ipfHSVKey(ebsd);
ipfKey.inversePoleFigureDirection = yvector;
% and plot the orientation data
plot(ebsd,ipfKey.orientation2color(ebsd.orientations),'micronBar','off','figSize','medium')
% reconstruct grains
[grains,ebsd.grainId] = calcGrains(ebsd,'angle',15*degree);
% remove small grains
ebsd(grains(grains.diameter<=5)) = [];
% redo grain reconstruction
[grains,ebsd.grainId] = calcGrains(ebsd,'angle',15*degree);
% smooth grain boundaries
grains = smooth(grains,5);
hold on
plot(grains.boundary,'linewidth',2)
hold off
% a key the colorizes according to misorientation angle and axis
ipfKey = axisAngleColorKey(ebsd);
% set the grain mean orientations as reference orinetations
ipfKey.oriRef = grains(ebsd('indexed').grainId).meanOrientation;
% plot the data
plot(ebsd,ipfKey.orientation2color(ebsd('indexed').orientations),'micronBar','off','figSize','medium')
hold on
plot(grains.boundary,'linewidth',1.5)
hold off
% denoise orientation data
F = halfQuadraticFilter;
ebsd = smooth(ebsd('indexed'),F,'fill',grains);
% plot the denoised data
ipfKey.oriRef = grains(ebsd('indexed').grainId).meanOrientation;
plot(ebsd('indexed'),ipfKey.orientation2color(ebsd('indexed').orientations),'micronBar','off','figSize','medium')
hold on
plot(grains.boundary,'linewidth',1.5)
hold off
% consider only the Fe(alpha) phase
ebsd = ebsd('indexed').gridify;
% compute the curvature tensor
kappa = ebsd.curvature
% one can index the curvature tensors in the same way as the EBSD data.
% E.g. the curvature in pixel (2,3) is
kappa(2,3)
kappa12 = kappa{1,2};
size(kappa12)
newMtexFigure('nrows',3,'ncols',3);
% cycle through all components of the tensor
for i = 1:3
for j = 1:3
nextAxis(i,j)
plot(ebsd,kappa{i,j},'micronBar','off')
hold on; plot(grains.boundary,'linewidth',2); hold off
end
end
% unify the color rage - you may also use setColoRange equal
setColorRange([-0.005,0.005])
drawNow(gcm,'figSize','large')
alpha = kappa.dislocationDensity
alpha(2,3)
dS = dislocationSystem.fcc(ebsd.CS)
% size of the unit cell
a = norm(ebsd.CS.aAxis);
% in bcc and fcc the norm of the burgers vector is sqrt(3)/2 * a
[norm(dS(1).b), norm(dS(end).b), sqrt(3)/2 * a]
nu = 0.33;
% energy of the edge dislocations
dS(dS.isEdge).u = 7.01317231;
% energy of the screw dislocations
dS(dS.isScrew).u = 4.698825451;
dS(1).tensor
dSRot = ebsd.orientations * dS
[rho,factor] = fitDislocationSystems(kappa,dSRot);
% the restored dislocation density tensors
alpha = sum(dSRot.tensor .* rho,2);
% we have to set the unit manualy since it is not stored in rho
alpha.opt.unit = '1/um';
% the restored dislocation density tensor for pixel 2
alpha(2)
% the dislocation density dervied from the curvature in pixel 2
kappa(2).dislocationDensity
% we may also restore the complete curvature tensor with
kappa = alpha.curvature
% and plot it as we did before
newMtexFigure('nrows',3,'ncols',3);
% cycle through all components of the tensor
for i = 1:3
for j = 1:3
nextAxis(i,j)
plot(ebsd,kappa{i,j},'micronBar','off')
hold on; plot(grains.boundary,'linewidth',1); hold off
end
end
setColorRange([-0.005,0.005])
drawNow(gcm,'figSize','large');
factor
close all
plot(ebsd,factorsum(abs(rho . dSRot.u),2),'micronbar','off')
mtexColorMap('jet')
mtexColorbar
set(gca,'ColorScale','log'); % this works only starting with Matlab 2018a
set(gca,'CLim',[1e12 1e16]);
hold on
plot(grains.boundary,'linewidth',1)
hold off
% total
gnd_tot = factorsum(abs(rho . dSRot.u),2);
grainGND = accumarray(ebsd.grainId, gnd_tot, size(grains), @nanmean);
%total grain average GND map
plot(ebsd,grainGND,'micronbar','off')
mtexColorMap('jet')
mtexColorbar
set(gca,'ColorScale','log'); % this works only starting with Matlab 2018a
set(gca,'CLim',[5e12 1e16]);
hold on
plot(grains.boundary,'linewidth',1)
hold off
Is there anything wrong with the using of accumarray?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, Cheers, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
Does anyone know how to calculate the grain average GND map? I have obtained the GND map on each pixel for FCC metal based on the code on MTEX website: https://mtex-toolbox.github.io/GND.html.
But how to get the grain average GND map (Fig. 3h) and ### Grain average GND density plotted against grain area (Fig. 3i) as follows:
Thank you very much in advance!
Best regards,
Luqing Cui
Beta Was this translation helpful? Give feedback.
All reactions