orientation.equivalent takes several rotations at the same time + small test"
" ""
This commit is contained in:
parent
512e54a7ee
commit
0c41e33434
|
@ -39,8 +39,8 @@ class Orientation:
|
||||||
else:
|
else:
|
||||||
self.rotation = Rotation.from_quaternion(rotation) # assume quaternion
|
self.rotation = Rotation.from_quaternion(rotation) # assume quaternion
|
||||||
|
|
||||||
if self.rotation.quaternion.shape != (4,):
|
# if self.rotation.quaternion.shape != (4,):
|
||||||
raise NotImplementedError('Support for multiple rotations missing')
|
# raise NotImplementedError('Support for multiple rotations missing')
|
||||||
|
|
||||||
def disorientation(self,
|
def disorientation(self,
|
||||||
other,
|
other,
|
||||||
|
@ -80,6 +80,20 @@ class Orientation:
|
||||||
def inFZ(self):
|
def inFZ(self):
|
||||||
return self.lattice.symmetry.inFZ(self.rotation.as_Rodrigues(vector=True))
|
return self.lattice.symmetry.inFZ(self.rotation.as_Rodrigues(vector=True))
|
||||||
|
|
||||||
|
def equivalent(self):
|
||||||
|
"""
|
||||||
|
List of orientations which are symmetrically equivalent.
|
||||||
|
Supported for multiple rotation with same lattice
|
||||||
|
Returns list [i] being i=range(24)
|
||||||
|
Returns list [i, num_rot] for multiple rotations
|
||||||
|
"""
|
||||||
|
if not self.rotation.shape:
|
||||||
|
return [self.__class__(q*self.rotation,self.lattice) \
|
||||||
|
for q in self.lattice.symmetry.symmetryOperations()]
|
||||||
|
else:
|
||||||
|
return np.reshape([self.__class__(q*Rotation.from_quaternion(self.rotation.as_quaternion()[l]),self.lattice) \
|
||||||
|
for q in self.lattice.symmetry.symmetryOperations() for l in range(self.rotation.shape[0])], (24,self.rotation.shape[0]))
|
||||||
|
|
||||||
|
|
||||||
def equivalentOrientations(self,members=[]):
|
def equivalentOrientations(self,members=[]):
|
||||||
"""List of orientations which are symmetrically equivalent."""
|
"""List of orientations which are symmetrically equivalent."""
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import damask
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
rot0= damask.Rotation.from_random()
|
||||||
|
rot1= damask.Rotation.from_random()
|
||||||
|
rot2= damask.Rotation.from_random()
|
||||||
|
|
||||||
|
ori0=damask.Orientation(rot0,'fcc')
|
||||||
|
ori1=damask.Orientation(rot1,'fcc')
|
||||||
|
ori2=damask.Orientation(rot2,'fcc')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
quat=np.array([rot0.as_quaternion(),rot1.as_quaternion(),rot2.as_quaternion()])
|
||||||
|
rot=damask.Rotation.from_quaternion(quat)
|
||||||
|
|
||||||
|
ori=damask.Orientation(rot,'fcc')
|
||||||
|
|
||||||
|
ori.equivalent()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# doesn't work this way, don't know why
|
||||||
|
#ori.equivalent()[:,0][0] == ori0.equivalentOrientations()[0]
|
||||||
|
|
||||||
|
for s in range(24):
|
||||||
|
print(ori.equivalent()[s,0].rotation.as_Eulers() == ori0.equivalentOrientations()[s].rotation.as_Eulers())
|
||||||
|
print(ori.equivalent()[s,1].rotation.as_Eulers() == ori1.equivalentOrientations()[s].rotation.as_Eulers())
|
||||||
|
print(ori.equivalent()[s,2].rotation.as_Eulers() == ori2.equivalentOrientations()[s].rotation.as_Eulers())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue