Skip to content

Commit 0a48f16

Browse files
authored
Merge pull request FABLE-3DXRD#476 from haixing0a/master
fix a bug with symmetry operations for disorientation
2 parents 71de868 + b7bf195 commit 0a48f16

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

ImageD11/forward_model/grainmaps.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,8 @@ def to_tsl(symmetry):
10811081

10821082
def symmetry_operators(self, use_miller_bravais=False):
10831083
"""Define the equivalent crystal symmetries.
1084+
Note that it takes the highest symmetry in each of the 7 crystal systems
1085+
This may not be quite right if a specific point group with less symmetry is desired
10841086
10851087
Those come from Randle & Engler, 2000. For instance in the cubic
10861088
crystal struture, for instance there are 24 equivalent cube orientations.
@@ -1144,12 +1146,21 @@ def symmetry_operators(self, use_miller_bravais=False):
11441146
sym[8] = np.array([[-0.5, s60, 0.], [s60, 0.5, 0.], [0., 0., -1.]])
11451147
sym[9] = np.array([[-1., 0., 0.], [0., 1., 0.], [0., 0., -1.]])
11461148
sym[10] = np.array([[-0.5, -s60, 0.], [-s60, 0.5, 0.], [0., 0., -1.]])
1147-
sym[11] = np.array([[0.5, -s60, 0.], [-s60, -0.5, 0.], [0., 0., -1.]])
1149+
sym[11] = np.array([[0.5, -s60, 0.], [-s60, -0.5, 0.], [0., 0., -1.]])
1150+
elif self is Symmetry.trigonal:
1151+
sym = np.zeros((6, 3, 3), dtype=float)
1152+
s60 = np.sin(60 * np.pi / 180)
1153+
sym[0] = np.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
1154+
sym[1] = np.array([[-0.5, -s60, 0.], [s60, -0.5, 0.], [0., 0., 1.]])
1155+
sym[2] = np.array([[-0.5, s60, 0.], [-s60, -0.5, 0.], [0., 0., 1.]])
1156+
sym[3] = np.array([[1., 0., 0.], [0., -1., 0.], [0., 0., -1.]])
1157+
sym[4] = np.array([[-0.5, s60, 0.], [s60, 0.5, 0.], [0., 0., -1.]])
1158+
sym[5] = np.array([[-0.5, -s60, 0.], [-s60, 0.5, 0.], [0., 0., -1.]])
11481159
elif self is Symmetry.orthorhombic:
11491160
sym = np.zeros((4, 3, 3), dtype=float)
11501161
sym[0] = np.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
11511162
sym[1] = np.array([[1., 0., 0.], [0., -1., 0.], [0., 0., -1.]])
1152-
sym[2] = np.array([[-1., 0., -1.], [0., 1., 0.], [0., 0., -1.]])
1163+
sym[2] = np.array([[-1., 0., 0.], [0., 1., 0.], [0., 0., -1.]])
11531164
sym[3] = np.array([[-1., 0., 0.], [0., -1., 0.], [0., 0., 1.]])
11541165
elif self is Symmetry.tetragonal:
11551166
sym = np.zeros((8, 3, 3), dtype=float)
@@ -1161,6 +1172,10 @@ def symmetry_operators(self, use_miller_bravais=False):
11611172
sym[5] = np.array([[-1., 0., 0.], [0., 1., 0.], [0., 0., -1.]])
11621173
sym[6] = np.array([[0., 1., 0.], [1., 0., 0.], [0., 0., -1.]])
11631174
sym[7] = np.array([[0., -1., 0.], [-1., 0., 0.], [0., 0., -1.]])
1175+
elif self is Symmetry.monoclinic:
1176+
sym = np.zeros((2, 3, 3), dtype=float)
1177+
sym[0] = np.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
1178+
sym[1] = np.array([[-1., 0., 0.], [0., -1., 0.], [0., 0., 1.]])
11641179
elif self is Symmetry.triclinic:
11651180
sym = np.zeros((1, 3, 3), dtype=float)
11661181
sym[0] = np.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
@@ -1448,8 +1463,14 @@ def disorientation(ori1, ori2, crystal_structure=Symmetry.triclinic):
14481463
oi_list = np.einsum('nij,jk->nik', symmetries, ori2)
14491464

14501465
# Compute all combinations of symmetrized ori1 and ori2
1451-
oj_list_T = np.transpose(oj_list, axes=(0, 2, 1))
1452-
delta_list = np.einsum('bij,bjk->bik', oi_list, oj_list_T)
1466+
delta_list_AB = np.einsum('aij,bkj->abik', oi_list, oj_list)
1467+
delta_list_BA = np.einsum('aij,bkj->abik', oj_list, oi_list)
1468+
1469+
# Flatten (2*Nsymmetry*Nsymmetry, 3, 3)
1470+
delta_list = np.concatenate([
1471+
delta_list_AB.reshape(-1, 3, 3),
1472+
delta_list_BA.reshape(-1, 3, 3)
1473+
])
14531474

14541475
# Calculate misorientation angles for all delta matrices
14551476
mis_angles = np.array([misorientation_angle_from_delta(delta) for delta in delta_list])

0 commit comments

Comments
 (0)