From a25dd1c4389165a74237706b0e83b4964892fb1d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 May 2020 08:01:34 +0200 Subject: [PATCH] cleaning --- python/damask/_rotation.py | 20 ++++++++++---------- python/tests/test_Orientation.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index bf5a2a4f3..e2d5963fe 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -35,8 +35,8 @@ class Rotation: ----- Vector "a" (defined in coordinate system "A") is passively rotated resulting in new coordinates "b" when expressed in system "B". - b = Q * a - b = np.dot(Q.asMatrix(),a) + b = Q @ a + b = np.dot(Q.as_matrix(),a) """ @@ -73,8 +73,8 @@ class Rotation: raise NotImplementedError('Support for multiple rotations missing') return '\n'.join([ 'Quaternion: (real={:.3f}, imag=<{:+.3f}, {:+.3f}, {:+.3f}>)'.format(*(self.quaternion)), - 'Matrix:\n{}'.format(self.asMatrix()), - 'Bunge Eulers / deg: ({:3.2f}, {:3.2f}, {:3.2f})'.format(*self.asEulers(degrees=True)), + 'Matrix:\n{}'.format(self.as_matrix()), + 'Bunge Eulers / deg: ({:3.2f}, {:3.2f}, {:3.2f})'.format(*self.as_Eulers(degrees=True)), ]) @@ -112,9 +112,9 @@ class Rotation: return A*other + B*self.quaternion[1:] + C * np.cross(self.quaternion[1:],other) elif other.shape == (3,3,): - return np.dot(self.asMatrix(),np.dot(other,self.asMatrix().T)) + return np.dot(self.as_matrix(),np.dot(other,self.as_matrix().T)) elif other.shape == (3,3,3,3,): - R = self.asMatrix() + R = self.as_matrix() return np.einsum('...im,...jn,...ko,...lp,...mnop',R,R,R,R,other) else: raise ValueError('Can only rotate vectors, 2nd order ternsors, and 4th order tensors') @@ -150,10 +150,10 @@ class Rotation: - p_m[...,(i+2)%3]*other[...,(i+1)%3])).reshape(self.shape+(1,)) for i in [0,1,2]]) if self.shape + (3,3) == other.shape: - R = self.asMatrix() + R = self.as_matrix() return np.einsum('...im,...jn,...mn',R,R,other) if self.shape + (3,3,3,3) == other.shape: - R = self.asMatrix() + R = self.as_matrix() return np.einsum('...im,...jn,...ko,...lp,...mnop',R,R,R,R,other) else: raise ValueError('Can only rotate vectors, 2nd order ternsors, and 4th order tensors') @@ -654,8 +654,8 @@ class Rotation: def om2ax(om): """Rotation matrix to axis angle pair.""" diag_delta = -_P*np.block([om[...,1,2:3]-om[...,2,1:2], - om[...,2,0:1]-om[...,0,2:3], - om[...,0,1:2]-om[...,1,0:1] + om[...,2,0:1]-om[...,0,2:3], + om[...,0,1:2]-om[...,1,0:1] ]) diag_delta[np.abs(diag_delta)<1.e-6] = 1.0 t = 0.5*(om.trace(axis2=-2,axis1=-1) -1.0).reshape(om.shape[:-2]+(1,)) diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 8dc526325..a8b8afdac 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -51,7 +51,7 @@ class TestOrientation: def test_relationship_reference(self,update,reference_dir,model,lattice): reference = os.path.join(reference_dir,'{}_{}.txt'.format(lattice,model)) ori = Orientation(Rotation(),lattice) - eu = np.array([o.rotation.asEulers(degrees=True) for o in ori.relatedOrientations(model)]) + eu = np.array([o.rotation.as_Eulers(degrees=True) for o in ori.relatedOrientations(model)]) if update: coords = np.array([(1,i+1) for i,x in enumerate(eu)]) table = damask.Table(eu,{'Eulers':(3,)})