fits better to stretch_left/right
This commit is contained in:
parent
a87596cefc
commit
2de3a6a205
|
@ -942,17 +942,17 @@ class Result:
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _add_rotational(F):
|
def _add_rotation(F):
|
||||||
return {
|
return {
|
||||||
'data': mechanics.rotational(F['data']).as_matrix(),
|
'data': mechanics.rotation(F['data']).as_matrix(),
|
||||||
'label': f"R({F['label']})",
|
'label': f"R({F['label']})",
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': F['meta']['Unit'],
|
'Unit': F['meta']['Unit'],
|
||||||
'Description': f"Rotational part of {F['label']} ({F['meta']['Description']})",
|
'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.
|
Add rotational part of a deformation gradient.
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ class Result:
|
||||||
Label of deformation gradient dataset.
|
Label of deformation gradient dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._add_generic_pointwise(self._add_rotational,{'F':F})
|
self._add_generic_pointwise(self._add_rotation,{'F':F})
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -97,7 +97,7 @@ def maximum_shear(T_sym):
|
||||||
return (w[...,0] - w[...,2])*0.5
|
return (w[...,0] - w[...,2])*0.5
|
||||||
|
|
||||||
|
|
||||||
def rotational(T):
|
def rotation(T):
|
||||||
"""
|
"""
|
||||||
Calculate the rotational part of a tensor.
|
Calculate the rotational part of a tensor.
|
||||||
|
|
||||||
|
|
|
@ -261,11 +261,11 @@ class TestResult:
|
||||||
in_file = default.read_dataset(loc['pole'])
|
in_file = default.read_dataset(loc['pole'])
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_rotational(self,default):
|
def test_add_rotation(self,default):
|
||||||
default.add_rotational('F')
|
default.add_rotation('F')
|
||||||
loc = {'F': default.get_dataset_location('F'),
|
loc = {'F': default.get_dataset_location('F'),
|
||||||
'R(F)': default.get_dataset_location('R(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)
|
in_file = default.read_dataset(loc['R(F)'],0)
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ def stress_second_Piola_Kirchhoff(P,F):
|
||||||
return symmetric(S)
|
return symmetric(S)
|
||||||
|
|
||||||
|
|
||||||
def rotational(T):
|
def rotation(T):
|
||||||
return polar_decomposition(T,'R')[0]
|
return polar_decomposition(T,'R')[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,9 +109,9 @@ class TestMechanics:
|
||||||
def test_vectorize_rotation(self):
|
def test_vectorize_rotation(self):
|
||||||
epsilon = Rotation.from_random(self.n).as_matrix()
|
epsilon = Rotation.from_random(self.n).as_matrix()
|
||||||
epsilon_vec = np.reshape(epsilon,(self.n//10,10,3,3))
|
epsilon_vec = np.reshape(epsilon,(self.n//10,10,3,3))
|
||||||
for i,v in enumerate(np.reshape(mechanics.rotational(epsilon_vec).as_matrix(),
|
for i,v in enumerate(np.reshape(mechanics.rotation(epsilon_vec).as_matrix(),
|
||||||
mechanics.rotational(epsilon).as_matrix().shape)):
|
mechanics.rotation(epsilon).as_matrix().shape)):
|
||||||
assert np.allclose(rotational(epsilon[i]),v)
|
assert np.allclose(rotation(epsilon[i]),v)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('vectorized,single',[(mechanics.stress_Cauchy, stress_Cauchy),
|
@pytest.mark.parametrize('vectorized,single',[(mechanics.stress_Cauchy, stress_Cauchy),
|
||||||
|
@ -146,7 +146,7 @@ class TestMechanics:
|
||||||
def test_polar_decomposition(self):
|
def test_polar_decomposition(self):
|
||||||
"""F = RU = VR."""
|
"""F = RU = VR."""
|
||||||
F = np.broadcast_to(np.eye(3),[self.n,3,3])*np.random.rand(self.n,3,3)
|
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)
|
V = mechanics.stretch_left(F)
|
||||||
U = mechanics.stretch_right(F)
|
U = mechanics.stretch_right(F)
|
||||||
assert np.allclose(np.matmul(R,U),
|
assert np.allclose(np.matmul(R,U),
|
||||||
|
|
Loading…
Reference in New Issue