don't compute silently the wrong von Mises kind
and allow the user to set it explicitly
This commit is contained in:
parent
7341b9830a
commit
1fcf9cb721
|
@ -789,12 +789,17 @@ class Result:
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _add_Mises(T_sym):
|
def _add_Mises(T_sym,kind):
|
||||||
t = 'strain' if T_sym['meta']['Unit'] == '1' else \
|
if kind is None:
|
||||||
'stress'
|
if T_sym['meta']['Unit'] == '1':
|
||||||
|
k = 'strain'
|
||||||
|
elif T_sym['meta']['Unit'] == 'Pa':
|
||||||
|
k = 'stress'
|
||||||
|
if k not in ['stress', 'strain']:
|
||||||
|
raise ValueError('invalid von Mises kind {kind}')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': (mechanics.Mises_strain if t=='strain' else mechanics.Mises_stress)(T_sym['data']),
|
'data': (mechanics.Mises_strain if k=='strain' else mechanics.Mises_stress)(T_sym['data']),
|
||||||
'label': f"{T_sym['label']}_vM",
|
'label': f"{T_sym['label']}_vM",
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': T_sym['meta']['Unit'],
|
'Unit': T_sym['meta']['Unit'],
|
||||||
|
@ -802,7 +807,7 @@ class Result:
|
||||||
'Creator': 'add_Mises'
|
'Creator': 'add_Mises'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def add_Mises(self,T_sym):
|
def add_Mises(self,T_sym,kind=None):
|
||||||
"""
|
"""
|
||||||
Add the equivalent Mises stress or strain of a symmetric tensor.
|
Add the equivalent Mises stress or strain of a symmetric tensor.
|
||||||
|
|
||||||
|
@ -810,9 +815,12 @@ class Result:
|
||||||
----------
|
----------
|
||||||
T_sym : str
|
T_sym : str
|
||||||
Label of symmetric tensorial stress or strain dataset.
|
Label of symmetric tensorial stress or strain dataset.
|
||||||
|
kind : {'stress', 'strain', None}, optional
|
||||||
|
Kind of the von Mises equivalent. Defaults to None, in which case
|
||||||
|
it is selected based on the unit of the dataset ('1' -> strain, 'Pa' -> stress').
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._add_generic_pointwise(self._add_Mises,{'T_sym':T_sym})
|
self._add_generic_pointwise(self._add_Mises,{'T_sym':T_sym},{'kind':kind})
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue