shorter (but still self-explanatory) name

This commit is contained in:
Martin Diehl 2020-11-19 15:19:15 +01:00
parent 6e5cb60132
commit a4b5c2a537
5 changed files with 14 additions and 15 deletions

View File

@ -942,17 +942,17 @@ class Result:
@staticmethod
def _add_rotational_part(F):
def _add_rotational(F):
return {
'data': mechanics.rotational_part(F['data']),
'data': mechanics.rotational(F['data']),
'label': f"R({F['label']})",
'meta': {
'Unit': F['meta']['Unit'],
'Description': f"Rotational part of {F['label']} ({F['meta']['Description']})",
'Creator': 'add_rotational_part'
'Creator': 'add_rotational'
}
}
def add_rotational_part(self,F):
def add_rotational(self,F):
"""
Add rotational part of a deformation gradient.
@ -962,7 +962,7 @@ class Result:
Label of deformation gradient dataset.
"""
self._add_generic_pointwise(self._add_rotational_part,{'F':F})
self._add_generic_pointwise(self._add_rotational,{'F':F})
@staticmethod

View File

@ -96,7 +96,7 @@ def maximum_shear(T_sym):
return (w[...,0] - w[...,2])*0.5
def rotational_part(T):
def rotational(T):
"""
Calculate the rotational part of a tensor.

View File

@ -77,7 +77,6 @@ def spherical(T,tensor=True):
"""
Calculate spherical part of a tensor.
Parameters
----------
T : numpy.ndarray of shape (...,3,3)

View File

@ -261,11 +261,11 @@ class TestResult:
in_file = default.read_dataset(loc['pole'])
assert np.allclose(in_memory,in_file)
def test_add_rotational_part(self,default):
default.add_rotational_part('F')
def test_add_rotational(self,default):
default.add_rotational('F')
loc = {'F': default.get_dataset_location('F'),
'R(F)': default.get_dataset_location('R(F)')}
in_memory = mechanics.rotational_part(default.read_dataset(loc['F'],0))
in_memory = mechanics.rotational(default.read_dataset(loc['F'],0))
in_file = default.read_dataset(loc['R(F)'],0)
assert np.allclose(in_memory,in_file)

View File

@ -31,7 +31,7 @@ def stress_second_Piola_Kirchhoff(P,F):
return symmetric(S)
def rotational_part(T):
def rotational(T):
return polar_decomposition(T,'R')[0]
@ -96,7 +96,7 @@ class TestMechanics:
@pytest.mark.parametrize('vectorized,single',[(mechanics.maximum_shear, maximum_shear),
(mechanics.equivalent_stress_Mises, equivalent_stress_Mises),
(mechanics.equivalent_strain_Mises, equivalent_strain_Mises),
(mechanics.rotational_part, rotational_part),
(mechanics.rotational, rotational),
(mechanics.stretch_left, stretch_left),
(mechanics.stretch_right, stretch_right),
])
@ -138,7 +138,7 @@ class TestMechanics:
def test_polar_decomposition(self):
"""F = RU = VR."""
F = np.broadcast_to(np.eye(3),[self.n,3,3])*np.random.rand(self.n,3,3)
R = mechanics.rotational_part(F)
R = mechanics.rotational(F)
V = mechanics.stretch_left(F)
U = mechanics.stretch_right(F)
assert np.allclose(np.matmul(R,U),
@ -162,7 +162,7 @@ class TestMechanics:
@pytest.mark.parametrize('t',['V','U'])
def test_strain_rotation(self,m,t):
"""Ensure that pure rotation results in no strain."""
F = mechanics.rotational_part(np.random.rand(self.n,3,3))
F = mechanics.rotational(np.random.rand(self.n,3,3))
assert np.allclose(mechanics.strain(F,t,m),
0.0)
@ -173,7 +173,7 @@ class TestMechanics:
Should be +1, but random F might contain a reflection.
"""
x = np.random.rand(self.n,3,3)
assert np.allclose(np.abs(np.linalg.det(mechanics.rotational_part(x))),
assert np.allclose(np.abs(np.linalg.det(mechanics.rotational(x))),
1.0)
def test_deviatoric_Mises(self):