small fixes (testing P=+1)

This commit is contained in:
Martin Diehl 2020-05-18 20:16:50 +02:00
parent b200894a40
commit b6eebcd704
2 changed files with 14 additions and 12 deletions

View File

@ -716,10 +716,10 @@ class Rotation:
ee = 0.5*eu ee = 0.5*eu
cPhi = np.cos(ee[...,1:2]) cPhi = np.cos(ee[...,1:2])
sPhi = np.sin(ee[...,1:2]) sPhi = np.sin(ee[...,1:2])
qu = np.block([ cPhi*np.cos(ee[...,0:1]+ee[...,2:3]), qu = np.block([ cPhi*np.cos(ee[...,0:1]+ee[...,2:3]),
-_P*sPhi*np.cos(ee[...,0:1]-ee[...,2:3]), -_P*sPhi*np.cos(ee[...,0:1]-ee[...,2:3]),
-_P*sPhi*np.sin(ee[...,0:1]-ee[...,2:3]), -_P*sPhi*np.sin(ee[...,0:1]-ee[...,2:3]),
-_P*cPhi*np.sin(ee[...,0:1]+ee[...,2:3])]) -_P*cPhi*np.sin(ee[...,0:1]+ee[...,2:3])])
qu[qu[...,0]<0.0]*=-1 qu[qu[...,0]<0.0]*=-1
return qu return qu
@ -804,7 +804,7 @@ class Rotation:
omc*ax[...,0:1]*ax[...,2:3] + s*ax[...,1:2], omc*ax[...,0:1]*ax[...,2:3] + s*ax[...,1:2],
omc*ax[...,1:2]*ax[...,2:3] - s*ax[...,0:1], omc*ax[...,1:2]*ax[...,2:3] - s*ax[...,0:1],
c+omc*ax[...,2:3]**2]).reshape(ax.shape[:-1]+(3,3)) c+omc*ax[...,2:3]**2]).reshape(ax.shape[:-1]+(3,3))
return om if _P < 0.0 else np.swapaxes(om,(-1,-2)) return om if _P < 0.0 else np.swapaxes(om,-1,-2)
@staticmethod @staticmethod
def ax2eu(ax): def ax2eu(ax):

View File

@ -31,12 +31,14 @@
import numpy as np import numpy as np
_P = -1 from damask import _rotation
_P = _rotation._P
# parameters for conversion from/to cubochoric # parameters for conversion from/to cubochoric
_sc = np.pi**(1./6.)/6.**(1./6.) _sc = _rotation._sc
_beta = np.pi**(5./6.)/6.**(1./6.)/2. _beta = _rotation._beta
_R1 = (3.*np.pi/4.)**(1./3.) _R1 = _rotation._R1
def iszero(a): def iszero(a):
return np.isclose(a,0.0,atol=1.0e-12,rtol=0.0) return np.isclose(a,0.0,atol=1.0e-12,rtol=0.0)
@ -53,7 +55,7 @@ def qu2om(qu):
om[2,1] = 2.0*(qu[2]*qu[3]-qu[0]*qu[1]) om[2,1] = 2.0*(qu[2]*qu[3]-qu[0]*qu[1])
om[2,0] = 2.0*(qu[1]*qu[3]+qu[0]*qu[2]) om[2,0] = 2.0*(qu[1]*qu[3]+qu[0]*qu[2])
om[0,2] = 2.0*(qu[3]*qu[1]-qu[0]*qu[2]) om[0,2] = 2.0*(qu[3]*qu[1]-qu[0]*qu[2])
return om if _P < 0.0 else np.swapaxes(om,(-1,-2)) return om if _P < 0.0 else np.swapaxes(om,-1,-2)
def qu2eu(qu): def qu2eu(qu):
"""Quaternion to Bunge-Euler angles.""" """Quaternion to Bunge-Euler angles."""
@ -127,7 +129,7 @@ def om2qu(a):
else: else:
s = 2.0 * np.sqrt( 1.0 + a[2,2] - a[0,0] - a[1,1] ) s = 2.0 * np.sqrt( 1.0 + a[2,2] - a[0,0] - a[1,1] )
qu = np.array([ (a[1,0] - a[0,1]) / s,(a[0,2] + a[2,0]) / s,(a[1,2] + a[2,1]) / s,0.25 * s]) qu = np.array([ (a[1,0] - a[0,1]) / s,(a[0,2] + a[2,0]) / s,(a[1,2] + a[2,1]) / s,0.25 * s])
return qu return qu*np.array([1.,_P,_P,_P])
def om2eu(om): def om2eu(om):
"""Rotation matrix to Bunge-Euler angles.""" """Rotation matrix to Bunge-Euler angles."""
@ -167,7 +169,7 @@ def eu2qu(eu):
ee = 0.5*eu ee = 0.5*eu
cPhi = np.cos(ee[1]) cPhi = np.cos(ee[1])
sPhi = np.sin(ee[1]) sPhi = np.sin(ee[1])
qu = np.array([ cPhi*np.cos(ee[0]+ee[2]), qu = np.array([ cPhi*np.cos(ee[0]+ee[2]),
-_P*sPhi*np.cos(ee[0]-ee[2]), -_P*sPhi*np.cos(ee[0]-ee[2]),
-_P*sPhi*np.sin(ee[0]-ee[2]), -_P*sPhi*np.sin(ee[0]-ee[2]),
-_P*cPhi*np.sin(ee[0]+ee[2]) ]) -_P*cPhi*np.sin(ee[0]+ee[2]) ])