mtex-toolbox / mtex

MTEX is a free Matlab toolbox for quantitative texture analysis. Homepage:
http://mtex-toolbox.github.io/
GNU General Public License v2.0
281 stars 185 forks source link

Misorientation Axes (Regression with 4.0.20?) #66

Closed kilir closed 9 years ago

kilir commented 9 years ago

Hello Ralf, in short: determination of misorientation axes with 4.0.20 does not yield the same as with 4.0.15 and the those from 4.0.15 seem to make more sense to me.

In longer: When colorcoding grain boundaries according to their misorientation axis I noticed that with 4.0.20 some axis directions (wrt to sample reference frame) were determined differently on the same boundary, e.g. for vertical or horizontal segments. The difference seems not to be related with polarity of the vector3d of the misorientation axis wrt to the sample reference frame. Misorientation axes in crystal reference frame are identical. There are 11 boundareis with angles misorientation angles high enough that they do not scatter to much. With 4.0.15 I can find those 11 clusters in the polefigure for misorienatioon axes (wrt sample reference frame) while in 4.0.20, there are more then 11, coincident with the additional colors of boundaries as seen on the map. This wasn't an issue with 4.0.15 and I could not find the commit which might be the reason for it. Attached are sample code as well as a maps and pole figure of misorientation axes obtained with 4.0.20 and 4.0.15.

With 4.0.20 Misorientation axes (sample reference frame) mapped and orientation map. Boundary colorcoding according to the "beach ball" below. Note color jumping along grain boundary segments. misor_axes_sample_map

Misorientation axes (sample reference frame) and oM used to colorcode boundaries above. Markers colorcoded by misorientation angle. (Note, there are more clusters of points than boundaries), misor_axes_sample

Misorientation axes (crystal reference frame) mapped and orientation map. Boundary colorcoding according to the "piece of pie" below. misor_axes_crystal_map

Misorientation axes (crystal reference frame) and oM used to colorcode boundaries above. misor_axes_crystal

With 4.0.15 Misorientation axes (sample reference frame) mapped and orientation map. Boundary colorcoding according to the "beach ball" below. misor_axes_sample_map_mtex0 15

Misorientation axes (sample reference frame) and oM used to colorcode boundaries above.Markers colorcoded by misorientation angle. misor_axes_sample_mtex0 15

Misorientation axes (crystal reference frame) mapped and orientation map. Boundary colorcoding according to the "piece of pie" below. misor_axes_crystal_map_mtex0 15

Misorientation axes (crystal reference frame) and oM used to colorcode boundaries above. misor_axes_crystal_mtex0 15

The input can be found here: https://bitbucket.org/kiliru/stuff/downloads/test_ebsd.mat and this is the code I used with 4.0.20

% crystal symmetry
CS = {... 
  'notIndexed',...
  crystalSymmetry('-3m1', [4.913 4.913 5.504], 'X||a*', 'Y||b', 'Z||c', 'mineral', 'Quartz-new', 'color', 'light blue')};
% plotting convention
setMTEXpref('xAxisDirection','east');
setMTEXpref('zAxisDirection','intoPlane');
hs= [... % directions
    Miller(0,0,0,1,CS{2},'uvw'),... %c
    Miller(1,1,-2,0,CS{2},'uvw'),... %a
    Miller(1,0,-1,0,CS{2},'uvw'),... %m
    Miller(0,1,-1,1,CS{2},'uvw'),... %z
    Miller(1,0,-1,1,CS{2},'uvw'),... %r
    Miller(1,1,-2,2,CS{2},'uvw')... %xi
    ];
%-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
%load the data
load('test_ebsd.mat')
%do some grains
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd,'angle',10*degree);

%-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
%get the boundary
gb_sel= grains.boundary('Q','Q');
%get the boudnary orientations
gbo1 = ebsd(gb_sel.ebsdId(:,1)).orientations;
gbo2 = ebsd(gb_sel.ebsdId(:,2)).orientations;

%calc the crysta/ sample misorientation axes
misor= inv(gbo1).*gbo2;

%/////////////////////////////////////////////////////////////////////////
%wrt to crystal
%/////////////////////////////////////////////////////////////////////////
axis_crystal = axis(misor);

    %make orientation mapping Crystal / axis
    oMC = ipdfHSVOrientationMapping(axis_crystal);
    oMC.CS1=crystalSymmetry('-3m1');% I guess it needs a symmetry
    oMC.colorStretching =3;
    oMC.whiteCenter = Miller(1,1,-2,1,oMC.CS1);
    oMC.sR.N = vector3d(2,1,3);

%plot axes wrt to crystal
figure

plot(ebsd('Q'),oMC.orientation2color(ebsd('Q').orientations))
hold on
plot(gb_sel,'linecolor','k','linewidth',8)
hold on
plot(gb_sel,oMC.Miller2color(axis_crystal),'linewidth',4)
hold off

figure;
plot(oMC)
hold on
plot(Miller(axis_crystal.project2FundamentalRegion,oMC.CS1),...
    misor.angle./degree,'MarkerSize',10,'MarkerEdgeColor','k',...
    'antipodal')
hold off
colorbar
%that's ok so far

%/////////////////////////////////////////////////////////////////////////
%wrt to sample
%/////////////////////////////////////////////////////////////////////////
misor_ax_sample = gbo1.*axis_crystal;

%figure;plot(misor_ax_sample,angle(misor)./degree,'MarkerSize',8,'MarkerEdgeColor','k')
%misor_ax_sample = project2FundamentalRegion(misor_ax_sample,crystalSymmetry('-1'))
%figure;plot(misor_ax_sample,angle(misor)./degree,'MarkerSize',8,'MarkerEdgeColor','k')

    %make a nice oM for sample ref. frame
    oMs = ipdfHSVOrientationMapping(misor_ax_sample);
    oMs.CS1=oMs.CS1.Laue;
    oMs.whiteCenter = vector3d(0,-1,0)
    oMs.colorStretching =1
    oMs.colorPostRotation = reflection(vector3d(-1,0,-1))*rotation('axis',vector3d(1,0,0),'angle',180*degree);

figure   
plot(ebsd('Q'),oMC.orientation2color(ebsd('Q').orientations))
hold on
plot(gb_sel,'Linecolor','k','linewidth',8)
hold on
plot(gb_sel,oMs.Miller2color(misor_ax_sample),'linewidth',4)
hold off

figure
plot(oMs)
hold on
plot(misor_ax_sample,angle(misor)./degree,'MarkerSize',8,'MarkerEdgeColor','k','antipodal')
hold off
colorbar

%that's not ok

while this is the script used with 4.0.15. with the only difference using

%get the boundary
gb_sel= grains.boundary('Q','Q');
%get the boudnary orientations
ebsd.id=[1:size(ebsd)]' 
gbo1= ebsd.orientations(gb_sel.ebsdId(:,1))
gbo2= ebsd.orientations(gb_sel.ebsdId(:,2))
% crystal symmetry
CS = {... 
  'notIndexed',...
  crystalSymmetry('-3m1', [4.913 4.913 5.504], 'X||a*', 'Y||b', 'Z||c', 'mineral', 'Quartz-new', 'color', 'light blue')};
% plotting convention
setMTEXpref('xAxisDirection','east');
setMTEXpref('zAxisDirection','intoPlane');
hs= [... % directions
    Miller(0,0,0,1,CS{2},'uvw'),... %c
    Miller(1,1,-2,0,CS{2},'uvw'),... %a
    Miller(1,0,-1,0,CS{2},'uvw'),... %m
    Miller(0,1,-1,1,CS{2},'uvw'),... %z
    Miller(1,0,-1,1,CS{2},'uvw'),... %r
    Miller(1,1,-2,2,CS{2},'uvw')... %xi
    ];
%-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
%load the data
load('test_ebsd.mat')
%do some grains
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd,'angle',10*degree);

%-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
%get the boundary
gb_sel= grains.boundary('Q','Q');
%get the boudnary orientations
ebsd.id=[1:size(ebsd)]' 
gbo1= ebsd.orientations(gb_sel.ebsdId(:,1))
gbo2= ebsd.orientations(gb_sel.ebsdId(:,2))
%calc the crysta/ sample misorientation axes
misor= inv(gbo1).*gbo2;

%/////////////////////////////////////////////////////////////////////////
%wrt to crystal
%/////////////////////////////////////////////////////////////////////////
axis_crystal = axis(misor);

    %make orientation mapping Crystal / axis
    oMC = ipdfHSVOrientationMapping(axis_crystal);
    oMC.CS1=crystalSymmetry('-3m1');% I guess it needs a symmetry
    oMC.colorStretching =3;
    oMC.whiteCenter = Miller(1,1,-2,1,oMC.CS1);
    oMC.sR.N = vector3d(2,1,3);

%plot axes wrt to crystal
figure
plot(ebsd,oMC.orientation2color(ebsd('Q').orientations))
hold on
plot(gb_sel,'linecolor','k','linewidth',8)
hold on
plot(gb_sel,oMC.Miller2color(axis_crystal),'linewidth',4)
hold off

figure;
plot(oMC)
hold on
plot(Miller(axis_crystal.project2FundamentalRegion,oMC.CS1),...
    misor.angle./degree,'MarkerSize',10,'MarkerEdgeColor','k',...
    'antipodal')
hold off
colorbar
%that's ok so far

%/////////////////////////////////////////////////////////////////////////
%wrt to sample
%/////////////////////////////////////////////////////////////////////////
misor= inv(gbo1).*gbo2;
misor_ax_sample = gbo1.*axis_crystal;

%figure;plot(misor_ax_sample,angle(misor)./degree,'MarkerSize',8,'MarkerEdgeColor','k')
%misor_ax_sample = project2FundamentalRegion(misor_ax_sample,crystalSymmetry('1'),'antipodal')
%figure;plot(misor_ax_sample,angle(misor)./degree,'MarkerSize',8,'MarkerEdgeColor','k')

    %make a nice oM for sample ref. frame
    oMs = ipdfHSVOrientationMapping(misor_ax_sample);
    oMs.CS1=oMs.CS1.Laue;
    oMs.whiteCenter = vector3d(0,-1,0)
    oMs.colorStretching =1
    oMs.colorPostRotation = reflection(vector3d(-1,0,-1))*rotation('axis',vector3d(1,0,0),'angle',180*degree);

figure   
plot(ebsd('Q'),oMC.orientation2color(ebsd('Q').orientations))
hold on
plot(gb_sel,'Linecolor','k','linewidth',8)
hold on
plot(gb_sel,oMs.Miller2color(misor_ax_sample),'linewidth',4)
hold off

figure
plot(oMs)
hold on
plot(misor_ax_sample,angle(misor)./degree,'MarkerSize',8,'MarkerEdgeColor','k','antipodal')
hold off
colorbar

Do you have any idea, what is going wrong? All the best, Rüdiger

ralfHielscher commented 9 years ago

Hi Rüdiger,

this is a nice example to check colorcoding. I will do so and report my results.

Ralf.

ralfHielscher commented 9 years ago

Hi Rüdiger,

I did some experiments with your data. This is what I came up with: boundary

ipdf

some remarks:

I will uploaded a new MTEX version 4.0.22 which fixes orientation/axis function.

That's all quite difficult :)

Ralf.

PS: the code I used:

mori = inv(gbo1).*gbo2;

misor_ax_sample = axis(gbo1,gbo2);
% change sign according to the sorting of the grains
ind = gb.grainId(:,1) > gb.grainId(:,2);
misor_ax_sample(ind) = -misor_ax_sample(ind);

%make a nice oM for sample ref. frame
oMs = ipdfHSVOrientationMapping(crystalSymmetry('1'));

figure   
plot(ebsd('Q'),oMC.orientation2color(ebsd('Q').orientations))
hold on
plot(gb,'Linecolor','k','linewidth',8)
hold on
plot(gb,oMs.Miller2color(misor_ax_sample),'linewidth',4)
hold off

figure
plot(oMs)
hold on
plot(misor_ax_sample,mori.angle./degree,'MarkerSize',8,'MarkerEdgeColor','k')
hold off
colorbar(gcm)
kilir commented 9 years ago

Hi Ralf, thanks a lot for looking into it. I see that the direction of axis or sense of rotation depends on whether going from A to B or B to A. However, does anybody know of a physical meaning as it simply depends on the way the orientations are sampled. In other words, would there be any need to plot upper and lower for the axes wrt to sample reference frame? As an effect of the close to 60 degree rotation for the axis of grain 1 and 4, the axes flip between upper and lower hemisphere, however using the "beach ball" colorcoding, that wouldn't be noticed.

oMs = ipdfHSVOrientationMapping(crystalSymmetry('1'));
oMs.CS1=oMs.CS1.Laue
oMs.whiteCenter = vector3d(0,-1,0)
oMs.colorStretching =1
oMs.colorPostRotation = reflection(vector3d(-1,0,-))*rotation('axis',vector3d(1,0,0),'angle',180*degree);
figure   
plot(ebsd('Q'),ebsd('Q').orientations); 
hold on
plot(gb,'Linecolor','k','linewidth',8)
hold on
plot(gb,oMs.Miller2color(misor_ax_sample),'linewidth',4)
hold off

figure
plot(oMs)
hold on
plot(misor_ax_sample,mori.angle./degree,'MarkerSize',8,'MarkerEdgeColor','k','antipodal')
hold off
c = colorbar(gcm);
ylabel(c,'misor angle')

gives again the same results like 4.0.15 did, which is great and gives the correct result, testing it on an synthetic sample. (sorting of grains might actually not be required, at least not for the present example, but I guess it's a good idea). The only situation where color jumps could occur now, are for boundaries with axes at the very periphery.

Colorcoding and axes wrt to sample reference frame: misor_axes_sample_mtex0 22

Map of misor axes wrt to sample ref. frame: misor_axes_sample_map_mtex0 22

All the best, Rüdiger

ralfHielscher commented 9 years ago

Hi Rüdiger,

I'm a bit unsure - is this issue fixed now? Can I close it? I found two more bugs in misorientation calculations which I fixed in mtex-4.1.beta6.

Ralf.

kilir commented 9 years ago

Hello Ralf, consider it as resolved. As described above, color jumps are omitted, however one has to be happy with looking at a topologically incorrect color coding - just one half-sphere- but that's fine with me. All the best, Rüdiger

ralfHielscher commented 9 years ago

Hi Rüdiger,

I looked at it one again. The main problem is indeed that there is no jump free color key for axes. You could do something like this

oMs = ipdfHSVOrientationMapping(crystalSymmetry('-1'));
oMs.maxAngle = pi/2;

This key has no jumps, but all points at the equator gets the same color -> black.

key

May be this can even improved further by introducing some gray at the equator - but it will never be perfect.

Ralf.