From 0c41e334341da15de6033709f05657474b7bf576 Mon Sep 17 00:00:00 2001 From: "f.basile" Date: Thu, 4 Jun 2020 16:39:24 +0200 Subject: [PATCH] orientation.equivalent takes several rotations at the same time + small test" " "" --- python/damask/_orientation.py | 18 ++++++++++++++++-- python/damask/oritest.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 python/damask/oritest.py diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index e4dbc7d7c..6fa40c261 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -39,8 +39,8 @@ class Orientation: else: self.rotation = Rotation.from_quaternion(rotation) # assume quaternion - if self.rotation.quaternion.shape != (4,): - raise NotImplementedError('Support for multiple rotations missing') +# if self.rotation.quaternion.shape != (4,): +# raise NotImplementedError('Support for multiple rotations missing') def disorientation(self, other, @@ -80,6 +80,20 @@ class Orientation: def inFZ(self): 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=[]): """List of orientations which are symmetrically equivalent.""" diff --git a/python/damask/oritest.py b/python/damask/oritest.py new file mode 100644 index 000000000..43104a938 --- /dev/null +++ b/python/damask/oritest.py @@ -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()) + +