Skip to content

Commit 511e552

Browse files
committed
polishing
1 parent df7486e commit 511e552

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

python/damask/_rotation.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,11 @@ def from_ODF(weights: np.ndarray,
11901190
11911191
Notes
11921192
-----
1193-
Due to the distortion of Euler space in the vicinity of ϕ = 0, probability densities, p, defined on
1194-
grid points with ϕ = 0 will never result in reconstructed orientations as their dV/V = p dγ = p × 0.
1195-
Hence, it is recommended to transform any such dataset to a cell-centered version, which avoids grid points at ϕ = 0.
1193+
Due to the distortion of Euler space in the vicinity of ϕ = 0,
1194+
probability densities, p, defined on grid points with ϕ = 0 will never
1195+
result in reconstructed orientations as their dV/V = p dγ = p × 0.
1196+
Hence, it is recommended to transform any such dataset to a
1197+
cell-centered version, which avoids grid points at ϕ = 0.
11961198
11971199
References
11981200
----------
@@ -1422,9 +1424,9 @@ def _qu2eu(qu: np.ndarray) -> np.ndarray:
14221424
eu_sum = eu[...,0] + eu[...,2]
14231425
eu_diff = eu[...,0] - eu[...,2]
14241426

1425-
is_zero = np.isclose(eu[...,1],0.0)
1426-
is_pi = np.isclose(eu[...,1],np.pi)
1427-
is_ok = ~np.logical_or(is_zero,is_pi)
1427+
is_zero = np.isclose(eu[...,1],0.0)
1428+
is_pi = np.isclose(eu[...,1],np.pi)
1429+
is_ok = ~np.logical_or(is_zero,is_pi)
14281430

14291431
eu[...,0][is_zero] = 2*eu[...,0][is_zero]
14301432
eu[...,0][is_pi] = -2*eu[...,2][is_pi]

python/damask/mechanics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ def _polar_decomposition(T: _np.ndarray,
345345
if 'U' in requested:
346346
output+=[_np.einsum('...ji,...jk',R,T)]
347347

348-
if len(output) == 0:
349-
raise ValueError('output not in {V, R, U}')
348+
if len(output) == 0 or len(set(['V','R','U']).union(requested))> 3:
349+
raise ValueError(f'requested invalid dataset {requested}')
350350

351351
return tuple(output)
352352

python/tests/test_mechanics.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ def test_spherical_no_shear(self):
225225
A = tensor.spherical(tensor.symmetric(np.random.rand(self.n,3,3)),True)
226226
assert np.allclose(mechanics.maximum_shear(A),0.0)
227227

228-
def test_invalid_decomposition(self):
228+
@pytest.mark.parametrize('invalid',['A',['R','x']])
229+
def test_invalid_decomposition(self,invalid):
229230
with pytest.raises(ValueError):
230-
mechanics._polar_decomposition(np.random.rand(10,3,3),'A')
231+
mechanics._polar_decomposition(np.random.rand(10,3,3),invalid)
231232

232233
def test_invalid_strain(self):
233234
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)