Skip to content

Commit 468c31c

Browse files
committed
bugfix: correct blending for misorientation
1 parent 6c25dfc commit 468c31c

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

python/damask/_rotation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def misorientation(self: MyType,
631631
Misorientation.
632632
633633
"""
634-
return other*~self
634+
return ~(self*~other)
635635

636636

637637
################################################################################################

python/tests/test_Orientation.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,26 @@ def test_disorientation360(self,family):
257257
o_2 = Orientation.from_Euler_angles(family=family,phi=[360,0,0],degrees=True)
258258
assert np.allclose((o_1.disorientation(o_2)).as_matrix(),np.eye(3))
259259

260+
@pytest.mark.parametrize('shape',[[None,None,()],
261+
[[2,3,4],[2,3,4],(2,3,4)],
262+
[[3,4],[4,5],(3,4,5)],
263+
[[3,2,4],[2,4,6],(3,2,4,6)],
264+
[[3,4,4],[4,4,2],(3,4,4,2)],
265+
[100,100,(100,)]])
266+
def test_shape_blending(self,shape):
267+
o_1 = Orientation.from_random(shape=shape[0],family='triclinic')
268+
o_2 = Orientation.from_random(shape=shape[1],family='triclinic')
269+
full = o_1.misorientation(o_2).as_axis_angle(pair=True)[1]
270+
composition = o_1*o_2
271+
assert full.shape == composition.shape == shape[2]
272+
273+
def test_disorientation_invalid(self):
274+
a,b = np.random.choice(list(crystal_families),2,False)
275+
o_1 = Orientation.from_random(family=a)
276+
o_2 = Orientation.from_random(family=b)
277+
with pytest.raises(NotImplementedError):
278+
o_1.disorientation(o_2)
279+
260280
@pytest.mark.parametrize('color',[{'label':'red', 'RGB':[1,0,0],'direction':[0,0,1]},
261281
{'label':'green','RGB':[0,1,0],'direction':[0,1,1]},
262282
{'label':'blue', 'RGB':[0,0,1],'direction':[1,1,1]}])

python/tests/test_Rotation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,19 @@ def test_composition_invalid(self):
11111111
with pytest.raises(TypeError):
11121112
Rotation()*np.ones(3)
11131113

1114+
@pytest.mark.parametrize('shape',[[None,None,()],
1115+
[[2,3,4],[2,3,4],(2,3,4)],
1116+
[[3,4],[4,5],(3,4,5)],
1117+
[[3,2,4],[2,4,6],(3,2,4,6)],
1118+
[[3,4,4],[4,4,2],(3,4,4,2)],
1119+
[100,100,(100,)]])
1120+
def test_shape_blending(self,shape):
1121+
r_1 = Rotation.from_random(shape=shape[0])
1122+
r_2 = Rotation.from_random(shape=shape[1])
1123+
full = r_1.misorientation(r_2).as_axis_angle(pair=True)[1]
1124+
composition = r_1*r_2
1125+
assert full.shape == composition.shape == shape[2]
1126+
11141127
def test_composition_inverse(self):
11151128
a,b = (Rotation.from_random(),Rotation.from_random())
11161129
c = a / b

0 commit comments

Comments
 (0)