From 9694767997933e55f8ae41e08b5282ac838a6677 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 20 May 2020 09:01:38 +0200 Subject: [PATCH] all seems to work now --- python/damask/_rotation.py | 8 ++++---- python/tests/rotation_conversion.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index d2698fd52..baa008391 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -694,7 +694,7 @@ class Rotation: @staticmethod def om2ax(om): """Rotation matrix to axis angle pair.""" - return Rotation.qu2ax(Rotation.om2qu(om)) # HOTFIX + #return Rotation.qu2ax(Rotation.om2qu(om)) # HOTFIX 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] @@ -878,14 +878,14 @@ class Rotation: ax = np.where(np.isfinite(ro[...,3:4]), np.block([ro[...,0:3]*np.linalg.norm(ro[...,0:3],axis=-1,keepdims=True),2.*np.arctan(ro[...,3:4])]), np.block([ro[...,0:3],np.broadcast_to(np.pi,ro[...,3:4].shape)])) - ax[np.abs(ro[...,3]) < 1.e-6] = np.array([ 0.0, 0.0, 1.0, 0.0 ]) + ax[np.abs(ro[...,3]) < 1.e-8] = np.array([ 0.0, 0.0, 1.0, 0.0 ]) return ax @staticmethod def ro2ho(ro): """Rodrigues-Frank vector to homochoric vector.""" f = np.where(np.isfinite(ro[...,3:4]),2.0*np.arctan(ro[...,3:4]) -np.sin(2.0*np.arctan(ro[...,3:4])),np.pi) - ho = np.where(np.broadcast_to(np.sum(ro[...,0:3]**2.0,axis=-1,keepdims=True) < 1.e-6,ro[...,0:3].shape), + ho = np.where(np.broadcast_to(np.sum(ro[...,0:3]**2.0,axis=-1,keepdims=True) < 1.e-8,ro[...,0:3].shape), np.zeros(3), ro[...,0:3]* (0.75*f)**(1.0/3.0)) return ho @@ -929,7 +929,7 @@ class Rotation: hm *= hmag_squared s += tfit[i] * hm with np.errstate(invalid='ignore'): - ax = np.where(np.broadcast_to(np.abs(hmag_squared)<1.e-6,ho.shape[:-1]+(4,)), + ax = np.where(np.broadcast_to(np.abs(hmag_squared)<1.e-8,ho.shape[:-1]+(4,)), [ 0.0, 0.0, 1.0, 0.0 ], np.block([ho/np.sqrt(hmag_squared),2.0*np.arccos(np.clip(s,-1.0,1.0))])) return ax diff --git a/python/tests/rotation_conversion.py b/python/tests/rotation_conversion.py index 3aca1a212..58ac9329f 100644 --- a/python/tests/rotation_conversion.py +++ b/python/tests/rotation_conversion.py @@ -147,7 +147,7 @@ def om2eu(om): def om2ax(om): """Rotation matrix to axis angle pair.""" - return qu2ax(om2qu(om)) # HOTFIX + #return qu2ax(om2qu(om)) # HOTFIX ax=np.empty(4) # first get the rotation angle @@ -262,7 +262,7 @@ def ax2ho(ax): #---------- Rodrigues-Frank vector ---------- def ro2ax(ro): """Rodrigues-Frank vector to axis angle pair.""" - if np.abs(ro[3]) < 1.e-6: + if np.abs(ro[3]) < 1.e-8: ax = np.array([ 0.0, 0.0, 1.0, 0.0 ]) elif not np.isfinite(ro[3]): ax = np.array([ ro[0], ro[1], ro[2], np.pi ]) @@ -274,7 +274,7 @@ def ro2ax(ro): def ro2ho(ro): """Rodrigues-Frank vector to homochoric vector.""" - if np.sum(ro[0:3]**2.0) < 1.e-6: + if np.sum(ro[0:3]**2.0) < 1.e-8: ho = np.zeros(3) else: f = 2.0*np.arctan(ro[3]) -np.sin(2.0*np.arctan(ro[3])) if np.isfinite(ro[3]) else np.pi