From 06cef4292767d067a3b57c25de909f21ad65790e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 28 Apr 2022 15:56:24 +0200 Subject: [PATCH] use physical/ISO convention --- python/damask/_rotation.py | 5 +++-- python/tests/test_Rotation.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 7c183ff98..a0baf1a0b 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -1137,14 +1137,15 @@ class Rotation: Examples -------- + tbd """ rng = np.random.default_rng(rng_seed) sigma_,alpha,beta = (np.radians(coordinate) for coordinate in (sigma,crystal,sample)) if degrees else \ map(np.array, (sigma,crystal,sample)) - d_cr = np.array([np.sin(alpha[1])*np.cos(alpha[0]), np.sin(alpha[1])*np.sin(alpha[0]), np.cos(alpha[1])]) - d_lab = np.array([np.sin( beta[1])*np.cos( beta[0]), np.sin( beta[1])*np.sin( beta[0]), np.cos( beta[1])]) + d_cr = np.array([np.sin(alpha[0])*np.cos(alpha[1]), np.sin(alpha[0])*np.sin(alpha[1]), np.cos(alpha[0])]) + d_lab = np.array([np.sin( beta[0])*np.cos( beta[1]), np.sin( beta[0])*np.sin( beta[1]), np.cos( beta[0])]) ax_align = np.append(np.cross(d_lab,d_cr), np.arccos(np.dot(d_lab,d_cr))) if np.isclose(ax_align[3],0.0): ax_align[:3] = np.array([1,0,0]) R_align = Rotation.from_axis_angle(ax_align if ax_align[3] > 0.0 else -ax_align,normalize=True) # rotate fiber axis from sample to crystal frame diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 2db08bc69..c9dfc68b8 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -1077,11 +1077,11 @@ class TestRotation: def test_from_fiber_component(self,sigma,shape): p = [] for run in range(5): - alpha = np.random.random()*2*np.pi,np.arccos(np.random.random()) - beta = np.random.random()*2*np.pi,np.arccos(np.random.random()) + alpha = np.arccos(np.random.random()),np.random.random()*2*np.pi + beta = np.arccos(np.random.random()),np.random.random()*2*np.pi - f_in_C = np.array([np.sin(alpha[1])*np.cos(alpha[0]), np.sin(alpha[1])*np.sin(alpha[0]), np.cos(alpha[1])]) - f_in_S = np.array([np.sin(beta[1] )*np.cos(beta[0] ), np.sin(beta[1] )*np.sin(beta[0] ), np.cos(beta[1] )]) + f_in_C = np.array([np.sin(alpha[0])*np.cos(alpha[1]), np.sin(alpha[0])*np.sin(alpha[1]), np.cos(alpha[0])]) + f_in_S = np.array([np.sin( beta[0])*np.cos( beta[1]), np.sin( beta[0])*np.sin( beta[1]), np.cos( beta[0])]) ax = np.append(np.cross(f_in_C,f_in_S), - np.arccos(np.dot(f_in_C,f_in_S))) n = Rotation.from_axis_angle(ax if ax[3] > 0.0 else ax*-1.0 ,normalize=True) # rotation to align fiber axis in crystal and sample system