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

Possible persistent bug with "symmetrise"? #1635

Closed AzdiarGazder closed 1 year ago

AzdiarGazder commented 1 year ago

Hi Ralf and Rudiger,

I understand this issue was initially brought up in: https://github.com/mtex-toolbox/mtex/issues/584 and dealt with in: https://github.com/mtex-toolbox/mtex/commit/2d89fb3e957d855ea6b9afbcc150dea7cb12da1b and implemented in a modified form in a subsequent stable release of Mtex.

However, I think I've come across a possible persistent bug with the "symmetrise" command. There are 2 issues I'm detailing as follows:

ISSUE 1 Commands:

CS = {... 
  'notIndexed',...
  crystalSymmetry('m-3m', [3.7 3.7 3.7], 'mineral', 'Iron fcc', 'color', [0 0 1])};

cs1 = crystalSymmetry('m-3m');
sS1 = slipSystem.fcc(cs1)
sS1 = symmetrise(sS1,'antipodal')

cs2 = crystalSymmetry('m-3m',[1 1 1]);
sS2 = slipSystem.fcc(cs2)
sS2 = symmetrise(sS2,'antipodal')

cs3 = crystalSymmetry('m-3m',[3.7 3.7 3.7]);
sS3 = slipSystem.fcc(cs3)
sS3 = symmetrise(sS3,'antipodal')

sS4 = slipSystem.fcc(CS{2})
sS4 = symmetrise(sS4,'antipodal')

Output:

sS1 = slipSystem (m-3m)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS1 = slipSystem (m-3m)
 size: 12 x 1

  u    v    w  | h    k    l CRSS
  0    1    1    1   -1    1    1
  1    0   -1    1   -1    1    1
  1    1    0    1   -1    1    1
  0    1   -1   -1    1    1    1
  1    0    1   -1    1    1    1
  1    1    0   -1    1    1    1
  0    1   -1   -1   -1   -1    1
  1   -1    0   -1   -1   -1    1
  1    0   -1   -1   -1   -1    1
  0    1    1    1    1   -1    1
  1   -1    0    1    1   -1    1
  1    0    1    1    1   -1    1

sS2 = slipSystem (m-3m)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS2 = slipSystem (m-3m)
 size: 12 x 1

  u    v    w  | h    k    l CRSS
  0    1    1    1   -1    1    1
  1    0   -1    1   -1    1    1
  1    1    0    1   -1    1    1
  0    1   -1   -1    1    1    1
  1    0    1   -1    1    1    1
  1    1    0   -1    1    1    1
  0    1   -1   -1   -1   -1    1
  1   -1    0   -1   -1   -1    1
  1    0   -1   -1   -1   -1    1
  0    1    1    1    1   -1    1
  1   -1    0    1    1   -1    1
  1    0    1    1    1   -1    1

sS3 = slipSystem (m-3m)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS3 = slipSystem (m-3m)
 size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1    1   -1    1   -1    1
  -1   -1    0   -1    1   -1    1
  -1    0    1   -1    1   -1    1
   0    1   -1   -1   -1   -1    1
   1   -1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
  -1   -1    0   -1    1    1    1
   0    1    1    1    1   -1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1

sS4 = slipSystem (Iron fcc)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS4 = slipSystem (Iron fcc)
 size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1    1   -1    1   -1    1
  -1   -1    0   -1    1   -1    1
  -1    0    1   -1    1   -1    1
   0    1   -1   -1   -1   -1    1
   1   -1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
  -1   -1    0   -1    1    1    1
   0    1    1    1    1   -1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1

Question: As you can see, the defined slip systems are not consistent. sS1 & sS2 match with each other and sS3 & sS4 match with each other. Ideally, shouldn't all sS1 to sS4 return the same output? %% ---------------------------------------------------------------

ISSUE 2 When the same commands are run on 2 different computers, I get different results. For example, when the commands are run using Matlab R2018b & Mtex 5.8.1 (stable or developer versions), I get the output as shown above.

However, when the commands are run using Matlab R2022b & Mtex 5.8.1 (stable version), I get the output as shown below.

sS1 = slipSystem (show methods, plot)
symmetry: m-3m
size: 1 x 1

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS1 = slipSystem (show methods, plot)
symmetry: m-3m
size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1    1    1   -1    1    1
   1    1    0    1   -1    1    1
  -1    0    1    1   -1    1    1
   0    1   -1    1   -1   -1    1
   1    0    1    1   -1   -1    1
   1    1    0    1   -1   -1    1
   0    1   -1   -1   -1   -1    1
  -1    1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1    1   -1   -1    1    1
   1    0    1   -1   -1    1    1
  -1    1    0   -1   -1    1    1

sS2 = slipSystem (show methods, plot)
symmetry: m-3m
size: 1 x 1

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS2 = slipSystem (show methods, plot)
symmetry: m-3m
size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1    1    1   -1    1    1
   1    1    0    1   -1    1    1
  -1    0    1    1   -1    1    1
   0    1   -1    1   -1   -1    1
   1    0    1    1   -1   -1    1
   1    1    0    1   -1   -1    1
   0    1   -1   -1   -1   -1    1
  -1    1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1    1   -1   -1    1    1
   1    0    1   -1   -1    1    1
  -1    1    0   -1   -1    1    1

sS3 = slipSystem (show methods, plot)
symmetry: m-3m
size: 1 x 1

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS3 = slipSystem (show methods, plot)
symmetry: m-3m
size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1    1   -1    1   -1    1
  -1   -1    0   -1    1   -1    1
  -1    0    1   -1    1   -1    1
   0    1   -1   -1   -1   -1    1
   1   -1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
  -1   -1    0   -1    1    1    1
   0    1    1   -1   -1    1    1
   1    0    1   -1   -1    1    1
   1   -1    0   -1   -1    1    1

sS4 = slipSystem (show methods, plot)
mineral: Iron fcc (m-3m)
size: 1 x 1

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS4 = slipSystem (show methods, plot)
mineral: Iron fcc (m-3m)
size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1    1   -1    1   -1    1
  -1   -1    0   -1    1   -1    1
  -1    0    1   -1    1   -1    1
   0    1   -1   -1   -1   -1    1
   1   -1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
  -1   -1    0   -1    1    1    1
   0    1    1   -1   -1    1    1
   1    0    1   -1   -1    1    1
   1   -1    0   -1   -1    1    1

Question: As you can see, the 2 computers return different results. Ideally, since the commands are the same, shouldn't the output be the same regardless of installation type? %% ---------------------------------------------------------------

I do not know for certain if this is a bug or the issue is simply one of incorrect commands. Either way, I'd be very grateful if you could please shed some light on this. :) Thank you in advance! :)

Warm regards, Azdi

frankNiessen commented 1 year ago

Hi Azdi,

I am not sure about your first issue, but about the second issue, could you check that your settings for the MTEX specimen directions are the same? Could you make sure to initialize the same settings for that?

AzdiarGazder commented 1 year ago

Hi Frank,

Thank you for the comment. Based on your suggestion, I ran the following script:

close all; clc; clear all; clear hidden;
startup_mtex

setMTEXpref('xAxisDirection','east');
setMTEXpref('zAxisDirection','IntoPlane');

% setMTEXpref('aAxisDirection','east');
% setMTEXpref('cAxisDirection','north');

CS = {... 
  'notIndexed',...
  crystalSymmetry('m-3m', [3.7 3.7 3.7], 'mineral', 'Iron fcc', 'color', [0 0 1])};

cs1 = crystalSymmetry('m-3m');
sS1 = slipSystem.fcc(cs1)
sS1 = symmetrise(sS1,'antipodal')

cs2 = crystalSymmetry('m-3m',[1 1 1]);
sS2 = slipSystem.fcc(cs2)
sS2 = symmetrise(sS2,'antipodal')

cs3 = crystalSymmetry('m-3m',[3.7 3.7 3.7]);
sS3 = slipSystem.fcc(cs3)
sS3 = symmetrise(sS3,'antipodal')

sS4 = slipSystem.fcc(CS{2})
sS4 = symmetrise(sS4,'antipodal')

And this is the example output:

sS1 = slipSystem (show methods, plot)
 symmetry: m-3m
 size: 1 x 1
  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS1 = slipSystem (show methods, plot)
 symmetry: m-3m
 size: 12 x 1
  u    v    w  | h    k    l CRSS
  0    1    1    1   -1    1    1
  1    0   -1    1   -1    1    1
  1    1    0    1   -1    1    1
  0    1   -1   -1    1    1    1
  1    0    1   -1    1    1    1
  1    1    0   -1    1    1    1
  0    1   -1   -1   -1   -1    1
  1   -1    0   -1   -1   -1    1
  1    0   -1   -1   -1   -1    1
  0    1    1    1    1   -1    1
  1   -1    0    1    1   -1    1
  1    0    1    1    1   -1    1

sS2 = slipSystem (show methods, plot)
 symmetry: m-3m
 size: 1 x 1
  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS2 = slipSystem (show methods, plot)
 symmetry: m-3m
 size: 12 x 1
  u    v    w  | h    k    l CRSS
  0    1    1    1   -1    1    1
  1    0   -1    1   -1    1    1
  1    1    0    1   -1    1    1
  0    1   -1   -1    1    1    1
  1    0    1   -1    1    1    1
  1    1    0   -1    1    1    1
  0    1   -1   -1   -1   -1    1
  1   -1    0   -1   -1   -1    1
  1    0   -1   -1   -1   -1    1
  0    1    1    1    1   -1    1
  1   -1    0    1    1   -1    1
  1    0    1    1    1   -1    1

sS3 = slipSystem (show methods, plot)
 symmetry: m-3m
 size: 1 x 1
  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS3 = slipSystem (show methods, plot)
 symmetry: m-3m
 size: 12 x 1
   u    v    w  | h    k    l CRSS
   0    1    1   -1    1   -1    1
  -1   -1    0   -1    1   -1    1
  -1    0    1   -1    1   -1    1
   0    1   -1   -1   -1   -1    1
   1   -1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
  -1   -1    0   -1    1    1    1
   0    1    1    1    1   -1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1

sS4 = slipSystem (show methods, plot)
 mineral: Iron fcc (m-3m)
 size: 1 x 1
  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS4 = slipSystem (show methods, plot)
 mineral: Iron fcc (m-3m)
 size: 12 x 1
   u    v    w  | h    k    l CRSS
   0    1    1   -1    1   -1    1
  -1   -1    0   -1    1   -1    1
  -1    0    1   -1    1   -1    1
   0    1   -1   -1   -1   -1    1
   1   -1    0   -1   -1   -1    1
  -1    0    1   -1   -1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
  -1   -1    0   -1    1    1    1
   0    1    1    1    1   -1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1

To cross-check all possible combinations, I ran the script using:

setMTEXpref('xAxisDirection','east');
setMTEXpref('zAxisDirection','IntoPlane');

% setMTEXpref('aAxisDirection','east');
% setMTEXpref('cAxisDirection','north');

then using:

% setMTEXpref('xAxisDirection','east');
% setMTEXpref('zAxisDirection','IntoPlane');

setMTEXpref('aAxisDirection','east');
setMTEXpref('cAxisDirection','north');

then using:

setMTEXpref('xAxisDirection','east');
setMTEXpref('zAxisDirection','IntoPlane');

setMTEXpref('aAxisDirection','east');
setMTEXpref('cAxisDirection','north');

In all instances, the defined slip systems are not consistent. sS1 & sS2 match each other and sS3 & sS4 match each other. Ideally, shouldn't all sS1 to sS4 return the same output?

Warm regards, Azdi

kilir commented 1 year ago

Hi, what you see is simply symmetrically equivalent slip systems appear in a different order.

Could you test this dc3ea453c1f13190589eec557ae9c801f708f177

Cheers, Rüdige

AzdiarGazder commented 1 year ago

Hi Rüdiger,

Thank you for the comment. Yes - of course they are symmetrically equivalent slip systems. My question is related to their order - shouldn't they all be the same? If not, how do you get a consistent list of symmetrically equivalent slip systems?

This consistency is important for example, when you are grouping slip systems by particular planes and comparing results obtained from different lines of code (like that shown above) or computers.

Warm regards, Azdi

Hi, what you see is simply symmetrically equivalent slip systems appear in a different order.

Could you test this dc3ea45

Cheers, Rüdige

AzdiarGazder commented 1 year ago

Hi Rüdiger,

I applied the change you implemented in dc3ea45 where line 98 in geometry/@vector3d/symmetrise.m was changed from:

  [vSym{j},idSym{j}] = unique(v.subSet(((1:dim1) + (j-1)*dim1).'),'noSymmetry',apUnique);

to

    [vSym{j},idSym{j}] = unique(v.subSet(((1:dim1) + (j-1)*dim1).'),'noSymmetry',apUnique,'stable');

I confirm that the implemented solution works for MTEX v5.8.1 and MTEX5.9 developer versions. Here is the output for the script I wrote above:

sS1 = slipSystem (m-3m)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS1 = slipSystem (m-3m)
 size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1   -1    1    1    1    1
  -1    0    1    1    1    1    1
   1   -1    0    1    1    1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1
   0    1    1    1    1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
   1    1    0   -1    1    1    1
  -1    0    1    1   -1    1    1
   1    1    0    1   -1    1    1
   0    1    1    1   -1    1    1

sS2 = slipSystem (m-3m)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS2 = slipSystem (m-3m)
 size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1   -1    1    1    1    1
  -1    0    1    1    1    1    1
   1   -1    0    1    1    1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1
   0    1    1    1    1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
   1    1    0   -1    1    1    1
  -1    0    1    1   -1    1    1
   1    1    0    1   -1    1    1
   0    1    1    1   -1    1    1

sS3 = slipSystem (m-3m)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS3 = slipSystem (m-3m)
 size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1   -1    1    1    1    1
  -1    0    1    1    1    1    1
   1   -1    0    1    1    1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1
   0    1    1    1    1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
   1    1    0   -1    1    1    1
  -1    0    1    1   -1    1    1
   1    1    0    1   -1    1    1
   0    1    1    1   -1    1    1

sS4 = slipSystem (Iron fcc)

  u    v    w  | h    k    l CRSS
  0    1   -1    1    1    1    1

sS4 = slipSystem (Iron fcc)
 size: 12 x 1

   u    v    w  | h    k    l CRSS
   0    1   -1    1    1    1    1
  -1    0    1    1    1    1    1
   1   -1    0    1    1    1    1
   1   -1    0    1    1   -1    1
   1    0    1    1    1   -1    1
   0    1    1    1    1   -1    1
   0    1   -1   -1    1    1    1
   1    0    1   -1    1    1    1
   1    1    0   -1    1    1    1
  -1    0    1    1   -1    1    1
   1    1    0    1   -1    1    1
   0    1    1    1   -1    1    1

Thank you so much Rüdiger!

Warm regards, Azdi