Sigma 3 twinning overlaps computer#

Source: docs/sigma_3_twins.ipynb. Executed during the documentation build.

from scipy.spatial.transform import Rotation
import numpy as np, pylab as pl
import ImageD11.unitcell
# this is the rotation 180 degree around 111 (sigma3 twin)
v = np.array((1,1,1))
n = v / np.linalg.norm(v)
SigmaU = Rotation.from_rotvec(180*n, degrees=True).as_matrix()
# peak generation
a  = 3.61
uc = ImageD11.unitcell.unitcell([a,a,a,90,90,90], 'F')
uc.makerings( 5 )
hkls = np.concatenate( [ uc.ringhkls[ds] for ds in uc.ringds ] ).T
hkls.shape
(3, 6182)

#

g = (UB).h

h = inv(UB).g = inv(B).inv(U).g

UB == I

g = Ut.h h = Ut.T g

# this is Utwin . hkl 
# we assume the U matrix for the grain is the identity
gcalc = uc.B.dot( hkls )
gtwin = SigmaU.dot( gcalc )
pl.figure()
pl.plot( gcalc[0], gcalc[1], '+')
pl.plot( gtwin[0], gtwin[1], '.')
[<matplotlib.lines.Line2D at 0x7fdc9f66eae0>]
../_images/c6f5ff47fe6eaed35addf3bd916627aa030360dbffe220473bbb0f73e72413cf.png
ubi = np.linalg.inv( uc.B )
h = hindexed_from_twin = ubi.dot( gtwin )
olaps = ((h - np.round(h))**2).sum(axis=0) < 0.05
modh = (hkls**2).sum(axis=0)
pl.hist(modh,bins = modh.max()*2)
pl.hist(modh[olaps],bins = modh.max()*2);
../_images/9a446b130924f4f2d3a0cfc4b1e0468729cc617bc8e89157400bbccb6d6249f3.png
order = np.argsort( modh )
c= 0
print("#sum(h^2) [h k l] multiplicity #overlaps_percent")
for i in order:
    if modh[i] == c: # dont print M times the same
        continue
    c = modh[i]
    m = (modh[i] == modh)
    print( "( %2d %2d %2d )"%tuple(hkls[:,i]), "%5d  %5d   %5d"%(m.sum(), m[olaps].sum(), 100*m[olaps].sum()/m.sum(), ))
#sum(h^2) [h k l] multiplicity #overlaps_percent
( -1 -1 -1 )     8      2      25
( -2  0  0 )     6      0       0
( -2 -2  0 )    12      6      50
( -3 -1 -1 )    24     12      50
( -2 -2 -2 )     8      2      25
( -4  0  0 )     6      0       0
( -3 -3 -1 )    24      0       0
( -4 -2  0 )    24     12      50
( -4 -2 -2 )    24      6      25
( -5 -1 -1 )    32     14      43
( -4 -4  0 )    12      6      50
( -5 -3 -1 )    48     24      50
( -6  0  0 )    30     12      40
( -6 -2  0 )    24      0       0
( -5 -3 -3 )    24      0       0
( -6 -2 -2 )    24     12      50
( -4 -4 -4 )     8      2      25
( -5 -1 -5 )    48     12      25
( -6 -4  0 )    24      0       0
( -6 -4 -2 )    48     24      50
( -7 -3 -1 )    72     36      50
( -8  0  0 )     6      0       0
( -7 -3 -3 )    24      0       0
( -6 -4 -4 )    48     24      50
( -6 -6  0 )    36     18      50
( -7 -5 -1 )    56     14      25
( -6 -6 -2 )    24      0       0
( -8 -4  0 )    24     12      50
( -7 -5 -3 )    72     36      50
( -4 -2 -8 )    48     12      25
( -6 -6 -4 )    24      0       0
( -9 -3 -1 )    48      0       0
( -8 -4 -4 )    24      6      25
( -9 -3 -3 )    72     36      50
( -10  0  0 )    30      0       0
( -6 -2 -8 )    72     36      50
( -9 -5 -1 )    72     36      50
( -10 -2 -2 )    32     14      43
( -9 -5 -3 )    48      0       0
( -10 -4  0 )    72     36      50
( -10 -4 -2 )    48     12      25
( -11 -1 -1 )    48     12      25
( -8 -8  0 )    12      6      50
( -9 -5 -5 )   120     60      50
( -10 -4 -4 )    48     12      25
( -10 -6  0 )    48      0       0
( -9 -3 -7 )    72      0       0
( -10 -6 -2 )    48     24      50
( -12  0  0 )    30     12      40
( -11 -5 -1 )    56     14      25
( -12 -2  0 )    24      0       0
( -12 -2 -2 )    72     36      50
( -9 -5 -7 )    96     48      50
( -12 -4  0 )    24      0       0
( -9 -9 -1 )    24      0       0
( -8 -6 -8 )    96     48      50
( -10 -8 -2 )    48     12      25
( -13 -1 -1 )   120     48      40
( -10 -6 -6 )    24      0       0
( -12 -4 -4 )    24     12      50
( -7 -9 -7 )   120     60      50
( -12 -6  0 )    72     36      50
( -12 -6 -2 )    48      0       0
( -13 -3 -3 )    48      0       0
( -8 -8 -8 )     8      2      25
( -13 -5 -1 )    96     24      25
( -12 -6 -4 )    54      0       0
( -10 -10  0 )    84     42      50
( -13 -5 -3 )    96     48      50
( -10 -2 -10 )    48     12      25
( -12 -8  0 )    24      0       0
( -11 -9 -3 )    72      0       0
( -14 -4  0 )    72     36      50
( -14 -4 -2 )    96     42      43
( -13 -7 -1 )    96     24      25
( -12 -8 -4 )    48     24      50
( -15 -1 -1 )   120     60      50
( -14 -4 -4 )    48     12      25
( -14 -6  0 )    24      0       0
( -15 -3 -1 )    48      0       0
( -14 -6 -2 )    72     36      50
( -7 -5 -13 )   104     50      48
( -12 -10  0 )    72      0       0
( -10 -2 -12 )    96     48      50
( -13 -9 -1 )   168     84      50
( -16  0  0 )     6      0       0
( -13 -9 -3 )    96      0       0
( -16 -2  0 )    96     48      50
( -16 -2 -2 )    96     24      25
( -13 -7 -7 )    48     12      25
( -14 -6 -6 )    24      0       0
( -12 -8 -8 )    48     24      50
( -15 -7 -1 )   120     60      50
( -16 -4 -2 )    96     24      25
( -12 -10 -6 )    48      0       0
( -15 -7 -3 )    72      0       0
( -12 -12  0 )    36     18      50
( -13 -11 -1 )    96     24      25
( -12 -2 -12 )    48      0       0
( -16 -6 -2 )   120     60      50
( -17 -3 -1 )   192     96      50
( -14 -10 -2 )    56     14      25
( -12 -12 -4 )    24      0       0
( -15 -9 -1 )    72      0       0
( -16 -6 -4 )    96     48      50
( -14 -10 -4 )    48     12      25
( -17 -5 -1 )   144     72      50
( -16 -8  0 )    24     12      50
( -17 -5 -3 )    96     48      50
( -18  0  0 )   102     48      47