Skip to content

Commit 74a9bc6

Browse files
committed
Merge branch 'master' of https://github.com/jonwright/ImageD11
2 parents e2eee91 + 0a48f16 commit 74a9bc6

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
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])

setup.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,14 @@ def build_extension(self, ext):
7878
c = self.compiler.compiler_type
7979
CF = [] ; LF=[]
8080
if "CFLAGS" in os.environ:
81-
CF = os.environ.get("CFLAGS").split(" ")
81+
CF = os.environ.get("CFLAGS").split()
8282
if "LDFLAGS" in os.environ:
83-
LF = os.environ.get("LDFLAGS").split(" ")
84-
for e in self.extensions:
85-
if c in copt:
86-
e.extra_compile_args = copt[ c ] + CF
87-
e.extra_link_args = lopt[ c ] + LF
88-
print("Customised compiler",c,e.extra_compile_args,
89-
e.extra_link_args)
83+
LF = os.environ.get("LDFLAGS").split()
84+
if c in copt:
85+
ext.extra_compile_args = copt[ c ] + CF
86+
ext.extra_link_args = lopt[ c ] + LF
87+
print("Customised compiler",c,ext.extra_compile_args,
88+
ext.extra_link_args)
9089
if ext.sources[0].endswith('.pyf'):
9190
name = ext.sources[0]
9291
# generate wrappers
@@ -105,7 +104,7 @@ def build_extension(self, ext):
105104

106105
csources = [os.path.join('src',c) for c in cnames.split()]
107106

108-
extension = Extension( "_cImageD11", csources,
107+
extension = Extension( "ImageD11._cImageD11", csources,
109108
include_dirs = [ 'src',numpy.get_include(), numpy.f2py.get_include() ])
110109

111110
################################################################################
@@ -211,7 +210,6 @@ def build_extension(self, ext):
211210
description='ImageD11',
212211
license = "GPL",
213212
# python_requires='<3.12', # Numba still not working for 3.12
214-
ext_package = "ImageD11", # Puts extensions in the ImageD11 directory
215213
ext_modules = [extension,],
216214
setup_requires = minimal, # to compile
217215
install_requires = minimal + useful,

0 commit comments

Comments
 (0)