fits better to stretch_left/right

This commit is contained in:
Martin Diehl 2020-11-19 22:46:52 +01:00
parent a87596cefc
commit 2de3a6a205
4 changed files with 14 additions and 14 deletions

View File

@ -942,17 +942,17 @@ class Result:
@staticmethod
def _add_rotational(F):
def _add_rotation(F):
return {
'data': mechanics.rotational(F['data']).as_matrix(),
'data': mechanics.rotation(F['data']).as_matrix(),
'label': f"R({F['label']})",
'meta': {
'Unit': F['meta']['Unit'],
'Description': f"Rotational part of {F['label']} ({F['meta']['Description']})",
'Creator': 'add_rotational'
'Creator': 'add_rotation'
}
}
def add_rotational(self,F):
def add_rotation(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,{'F':F})
self._add_generic_pointwise(self._add_rotation,{'F':F})
@staticmethod

View File

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

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(self,default):
default.add_rotational('F')
def test_add_rotation(self,default):
default.add_rotation('F')
loc = {'F': default.get_dataset_location('F'),
'R(F)': default.get_dataset_location('R(F)')}
in_memory = mechanics.rotational(default.read_dataset(loc['F'],0)).as_matrix()
in_memory = mechanics.rotation(default.read_dataset(loc['F'],0)).as_matrix()
in_file = default.read_dataset(loc['R(F)'],0)
assert np.allclose(in_memory,in_file)

View File

@ -32,7 +32,7 @@ def stress_second_Piola_Kirchhoff(P,F):
return symmetric(S)
def rotational(T):
def rotation(T):
return polar_decomposition(T,'R')[0]
@ -109,9 +109,9 @@ class TestMechanics:
def test_vectorize_rotation(self):
epsilon = Rotation.from_random(self.n).as_matrix()
epsilon_vec = np.reshape(epsilon,(self.n//10,10,3,3))
for i,v in enumerate(np.reshape(mechanics.rotational(epsilon_vec).as_matrix(),
mechanics.rotational(epsilon).as_matrix().shape)):
assert np.allclose(rotational(epsilon[i]),v)
for i,v in enumerate(np.reshape(mechanics.rotation(epsilon_vec).as_matrix(),
mechanics.rotation(epsilon).as_matrix().shape)):
assert np.allclose(rotation(epsilon[i]),v)
@pytest.mark.parametrize('vectorized,single',[(mechanics.stress_Cauchy, stress_Cauchy),
@ -146,7 +146,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(F).as_matrix()
R = mechanics.rotation(F).as_matrix()
V = mechanics.stretch_left(F)
U = mechanics.stretch_right(F)
assert np.allclose(np.matmul(R,U),