speed up for inversePole method. Now only performing symmetry equivalence when asked for SST.

This commit is contained in:
Philip Eisenlohr 2015-06-13 11:51:10 +00:00
parent 0efbd4b11f
commit 66ce1d0b33
1 changed files with 19 additions and 15 deletions

View File

@ -837,12 +837,12 @@ class Orientation:
axis rotated according to orientation (using crystal symmetry to ensure location falls into SST) axis rotated according to orientation (using crystal symmetry to ensure location falls into SST)
''' '''
for i,q in enumerate(self.symmetry.equivalentQuaternions(self.quaternion)): # test all symmetric equivalent orientations if SST: # pole requested to be within SST
if SST: # pole requested to be within SST for i,q in enumerate(self.symmetry.equivalentQuaternions(self.quaternion)): # test all symmetric equivalent orientations
pole = q.conjugated()*axis # align crystal direction to axis pole = q.conjugated()*axis # align crystal direction to axis
if self.symmetry.inSST(pole): break if self.symmetry.inSST(pole): print i;break # found SST version
else: else:
pole = q.conjugated()*axis # align crystal direction to axis pole = self.quaternion.conjugated()*axis # align crystal direction to axis
return pole return pole
@ -853,8 +853,8 @@ class Orientation:
color = np.zeros(3,'d') color = np.zeros(3,'d')
for i,q in enumerate(self.symmetry.equivalentQuaternions(self.quaternion)): for q in self.symmetry.equivalentQuaternions(self.quaternion):
pole = q.conjugated()*axis # align crystal direction to axis pole = q.conjugated()*axis # align crystal direction to axis
inSST,color = self.symmetry.inSST(pole,color=True) inSST,color = self.symmetry.inSST(pole,color=True)
if inSST: break if inSST: break
@ -870,25 +870,29 @@ class Orientation:
usage: usage:
a = Orientation(Eulers=np.radians([10, 10, 0]), symmetry='hexagonal') a = Orientation(Eulers=np.radians([10, 10, 0]), symmetry='hexagonal')
b = Orientation(Eulers=np.radians([20, 0, 0]), symmetry='hexagonal') b = Orientation(Eulers=np.radians([20, 0, 0]), symmetry='hexagonal')
avg = Orientation.getAverageOrientation([a,b])""" avg = Orientation.getAverageOrientation([a,b])
"""
if not all(isinstance(item, Orientation) for item in orientationList): if not all(isinstance(item, Orientation) for item in orientationList):
raise TypeError("Only instances of Orientation can be averaged.") raise TypeError("Only instances of Orientation can be averaged.")
n = len(orientationList) n = len(orientationList)
tmp_m = orientationList.pop(0).quaternion.asM() tmp_m = orientationList.pop(0).quaternion.asM()
for tmp_o in orientationList: for tmp_o in orientationList:
tmp_m += tmp_o.quaternion.asM() tmp_m += tmp_o.quaternion.asM()
eig, vec = np.linalg.eig(tmp_m/n) eig, vec = np.linalg.eig(tmp_m/n)
return Orientation( quaternion=Quaternion(quatArray=vec.T[eig.argmax()]) )
return Orientation(quaternion = Quaternion(quatArray = vec.T[eig.argmax()]))
def related(self, relationModel, direction, targetSymmetry=None): def related(self, relationModel, direction, targetSymmetry = None):
if relationModel not in ['KS','GT',"GT'",'NW','Bain']: return None if relationModel not in ['KS','GT',"GT'",'NW','Bain']: return None
variant = int(abs(direction)) variant = int(abs(direction))
me = 0 if direction > 0 else 1 (me,other) = (0,1) if direction > 0 else (1,0)
other = 1 if direction > 0 else 0
variant = variant -1 variant -= 1 # why not subtracting two lines above??
planes = {'KS': \ planes = {'KS': \
np.array([[[ 1, 1, 1],[ 0, 1, 1]],\ np.array([[[ 1, 1, 1],[ 0, 1, 1]],\