parent
16ddd9c5b2
commit
a433f7ef54
|
@ -454,7 +454,7 @@ class DADF5():
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
x : str
|
||||||
Label of the dataset containing a scalar, vector, or tensor.
|
Label of scalar, vector, or tensor dataset to take absolute value of.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_absolute(x):
|
def _add_absolute(x):
|
||||||
|
@ -472,25 +472,25 @@ class DADF5():
|
||||||
self.__add_generic_pointwise(_add_absolute,{'x':x})
|
self.__add_generic_pointwise(_add_absolute,{'x':x})
|
||||||
|
|
||||||
|
|
||||||
def add_calculation(self,formula,label,unit='n/a',description=None,vectorized=True):
|
def add_calculation(self,label,formula,unit='n/a',description=None,vectorized=True):
|
||||||
"""
|
"""
|
||||||
Add result of a general formula.
|
Add result of a general formula.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
formula : str
|
|
||||||
Formula, refer to datasets by ‘#Label#‘.
|
|
||||||
label : str
|
label : str
|
||||||
Label of the dataset containing the result of the calculation.
|
Label of resulting dataset.
|
||||||
|
formula : str
|
||||||
|
Formula to calculate resulting dataset. Existing datasets are referenced by ‘#TheirLabel#‘.
|
||||||
unit : str, optional
|
unit : str, optional
|
||||||
Physical unit of the result.
|
Physical unit of the result.
|
||||||
description : str, optional
|
description : str, optional
|
||||||
Human readable description of the result.
|
Human-readable description of the result.
|
||||||
vectorized : bool, optional
|
vectorized : bool, optional
|
||||||
Indicate whether the formula is written in vectorized form. Default is ‘True’.
|
Indicate whether the formula can be used in vectorized form. Defaults to ‘True’.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if vectorized is False:
|
if not vectorized:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _add_calculation(**kwargs):
|
def _add_calculation(**kwargs):
|
||||||
|
@ -515,22 +515,22 @@ class DADF5():
|
||||||
self.__add_generic_pointwise(_add_calculation,dataset_mapping,args)
|
self.__add_generic_pointwise(_add_calculation,dataset_mapping,args)
|
||||||
|
|
||||||
|
|
||||||
def add_Cauchy(self,F='F',P='P'):
|
def add_Cauchy(self,P='P',F='F'):
|
||||||
"""
|
"""
|
||||||
Add Cauchy stress calculated from 1. Piola-Kirchhoff stress and deformation gradient.
|
Add Cauchy stress calculated from first Piola-Kirchhoff stress and deformation gradient.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
P : str, optional
|
P : str, optional
|
||||||
Label of the dataset containing the 1. Piola-Kirchhoff stress. Default value is ‘P’.
|
Label of the dataset containing the first Piola-Kirchhoff stress. Defaults to ‘P’.
|
||||||
F : str, optional
|
F : str, optional
|
||||||
Label of the dataset containing the deformation gradient. Default value is ‘F’.
|
Label of the dataset containing the deformation gradient. Defaults to ‘F’.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_Cauchy(F,P):
|
def _add_Cauchy(P,F):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': mechanics.Cauchy(F['data'],P['data']),
|
'data': mechanics.Cauchy(P['data'],F['data']),
|
||||||
'label': 'sigma',
|
'label': 'sigma',
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': P['meta']['Unit'],
|
'Unit': P['meta']['Unit'],
|
||||||
|
@ -541,110 +541,110 @@ class DADF5():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_Cauchy,{'F':F,'P':P})
|
self.__add_generic_pointwise(_add_Cauchy,{'P':P,'F':F})
|
||||||
|
|
||||||
|
|
||||||
def add_determinant(self,x):
|
def add_determinant(self,T):
|
||||||
"""
|
"""
|
||||||
Add the determinant of a tensor.
|
Add the determinant of a tensor.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
T : str
|
||||||
Label of the dataset containing a tensor.
|
Label of tensor dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_determinant(x):
|
def _add_determinant(T):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': np.linalg.det(x['data']),
|
'data': np.linalg.det(T['data']),
|
||||||
'label': 'det({})'.format(x['label']),
|
'label': 'det({})'.format(T['label']),
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': x['meta']['Unit'],
|
'Unit': T['meta']['Unit'],
|
||||||
'Description': 'Determinant of tensor {} ({})'.format(x['label'],x['meta']['Description']),
|
'Description': 'Determinant of tensor {} ({})'.format(T['label'],T['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_determinant v{}'.format(version)
|
'Creator': 'dadf5.py:add_determinant v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_determinant,{'x':x})
|
self.__add_generic_pointwise(_add_determinant,{'T':T})
|
||||||
|
|
||||||
|
|
||||||
def add_deviator(self,x):
|
def add_deviator(self,T):
|
||||||
"""
|
"""
|
||||||
Add the deviatoric part of a tensor.
|
Add the deviatoric part of a tensor.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
T : str
|
||||||
Label of the dataset containing a tensor.
|
Label of tensor dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_deviator(x):
|
def _add_deviator(T):
|
||||||
|
|
||||||
if not np.all(np.array(x['data'].shape[1:]) == np.array([3,3])):
|
if not np.all(np.array(T['data'].shape[1:]) == np.array([3,3])):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': mechanics.deviatoric_part(x['data']),
|
'data': mechanics.deviatoric_part(T['data']),
|
||||||
'label': 's_{}'.format(x['label']),
|
'label': 's_{}'.format(T['label']),
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': x['meta']['Unit'],
|
'Unit': T['meta']['Unit'],
|
||||||
'Description': 'Deviator of tensor {} ({})'.format(x['label'],x['meta']['Description']),
|
'Description': 'Deviator of tensor {} ({})'.format(T['label'],T['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_deviator v{}'.format(version)
|
'Creator': 'dadf5.py:add_deviator v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_deviator,{'x':x})
|
self.__add_generic_pointwise(_add_deviator,{'T':T})
|
||||||
|
|
||||||
|
|
||||||
def add_eigenvalues(self,x):
|
def add_eigenvalues(self,S):
|
||||||
"""
|
"""
|
||||||
Add eigenvalues of symmetric tensor.
|
Add eigenvalues of symmetric tensor.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
S : str
|
||||||
Label of the dataset containing a symmetric tensor.
|
Label of symmetric tensor dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_eigenvalue(x):
|
def _add_eigenvalue(S):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': mechanics.eigenvalues(x['data']),
|
'data': mechanics.eigenvalues(S['data']),
|
||||||
'label': 'lambda({})'.format(x['label']),
|
'label': 'lambda({})'.format(S['label']),
|
||||||
'meta' : {
|
'meta' : {
|
||||||
'Unit': x['meta']['Unit'],
|
'Unit': S['meta']['Unit'],
|
||||||
'Description': 'Eigenvalues of {} ({})'.format(x['label'],x['meta']['Description']),
|
'Description': 'Eigenvalues of {} ({})'.format(S['label'],S['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_eigenvalues v{}'.format(version)
|
'Creator': 'dadf5.py:add_eigenvalues v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_eigenvalue,{'x':x})
|
self.__add_generic_pointwise(_add_eigenvalue,{'S':S})
|
||||||
|
|
||||||
|
|
||||||
def add_eigenvectors(self,x):
|
def add_eigenvectors(self,S):
|
||||||
"""
|
"""
|
||||||
Add eigenvectors of symmetric tensor.
|
Add eigenvectors of symmetric tensor.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
S : str
|
||||||
Label of the dataset containing a symmetric tensor.
|
Label of symmetric tensor dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_eigenvector(x):
|
def _add_eigenvector(S):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': mechanics.eigenvectors(x['data']),
|
'data': mechanics.eigenvectors(S['data']),
|
||||||
'label': 'v({})'.format(x['label']),
|
'label': 'v({})'.format(S['label']),
|
||||||
'meta' : {
|
'meta' : {
|
||||||
'Unit': '1',
|
'Unit': '1',
|
||||||
'Description': 'Eigenvectors of {} ({})'.format(x['label'],x['meta']['Description']),
|
'Description': 'Eigenvectors of {} ({})'.format(S['label'],S['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_eigenvectors v{}'.format(version)
|
'Creator': 'dadf5.py:add_eigenvectors v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_eigenvector,{'x':x})
|
self.__add_generic_pointwise(_add_eigenvector,{'S':S})
|
||||||
|
|
||||||
|
|
||||||
def add_IPFcolor(self,q,p):
|
def add_IPFcolor(self,q,p):
|
||||||
|
@ -654,9 +654,9 @@ class DADF5():
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
q : str
|
q : str
|
||||||
Label of the dataset containing the orientation data as quaternions.
|
Label of the dataset containing the crystallographic orientation as quaternions.
|
||||||
p : list of int
|
p : list of int #ToDo: Direction / int?
|
||||||
Pole direction as Miller indices.
|
Pole (crystallographic direction or plane).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_IPFcolor(q,p):
|
def _add_IPFcolor(q,p):
|
||||||
|
@ -686,56 +686,56 @@ class DADF5():
|
||||||
self.__add_generic_pointwise(_add_IPFcolor,{'q':q},{'p':p})
|
self.__add_generic_pointwise(_add_IPFcolor,{'q':q},{'p':p})
|
||||||
|
|
||||||
|
|
||||||
def add_maximum_shear(self,x):
|
def add_maximum_shear(self,S):
|
||||||
"""
|
"""
|
||||||
Add maximum shear components of symmetric tensor.
|
Add maximum shear components of symmetric tensor.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
S : str
|
||||||
Label of the dataset containing a symmetric tensor.
|
Label of symmetric tensor dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_maximum_shear(x):
|
def _add_maximum_shear(S):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': mechanics.maximum_shear(x['data']),
|
'data': mechanics.maximum_shear(S['data']),
|
||||||
'label': 'max_shear({})'.format(x['label']),
|
'label': 'max_shear({})'.format(S['label']),
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': x['meta']['Unit'],
|
'Unit': S['meta']['Unit'],
|
||||||
'Description': 'Maximum shear component of of {} ({})'.format(x['label'],x['meta']['Description']),
|
'Description': 'Maximum shear component of {} ({})'.format(S['label'],S['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_maximum_shear v{}'.format(version)
|
'Creator': 'dadf5.py:add_maximum_shear v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_maximum_shear,{'x':x})
|
self.__add_generic_pointwise(_add_maximum_shear,{'S':S})
|
||||||
|
|
||||||
|
|
||||||
def add_Mises(self,x):
|
def add_Mises(self,S):
|
||||||
"""
|
"""
|
||||||
Add the equivalent Mises stress or strain of a symmetric tensor.
|
Add the equivalent Mises stress or strain of a symmetric tensor.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
S : str
|
||||||
Label of the dataset containing a symmetric stress or strain tensor.
|
Label of symmetric tensorial stress or strain dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_Mises(x):
|
def _add_Mises(S):
|
||||||
|
|
||||||
t = 'strain' if x['meta']['Unit'] == '1' else \
|
t = 'strain' if S['meta']['Unit'] == '1' else \
|
||||||
'stress'
|
'stress'
|
||||||
return {
|
return {
|
||||||
'data': mechanics.Mises_strain(x['data']) if t=='strain' else mechanics.Mises_stress(x['data']),
|
'data': mechanics.Mises_strain(S['data']) if t=='strain' else mechanics.Mises_stress(S['data']),
|
||||||
'label': '{}_vM'.format(x['label']),
|
'label': '{}_vM'.format(S['label']),
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': x['meta']['Unit'],
|
'Unit': S['meta']['Unit'],
|
||||||
'Description': 'Mises equivalent {} of {} ({})'.format(t,x['label'],x['meta']['Description']),
|
'Description': 'Mises equivalent {} of {} ({})'.format(t,S['label'],S['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_Mises v{}'.format(version)
|
'Creator': 'dadf5.py:add_Mises v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_Mises,{'x':x})
|
self.__add_generic_pointwise(_add_Mises,{'S':S})
|
||||||
|
|
||||||
|
|
||||||
def add_norm(self,x,ord=None):
|
def add_norm(self,x,ord=None):
|
||||||
|
@ -745,9 +745,9 @@ class DADF5():
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
x : str
|
||||||
Label of the dataset containing a vector or tensor.
|
Label of vector or tensor dataset.
|
||||||
ord : {non-zero int, inf, -inf, ‘fro’, ‘nuc’}, optional
|
ord : {non-zero int, inf, -inf, ‘fro’, ‘nuc’}, optional
|
||||||
Order of the norm. inf means numpy’s inf object. For details refer to numpy.linalg.norm.
|
Order of the norm. inf means NumPy’s inf object. For details refer to numpy.linalg.norm.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_norm(x,ord):
|
def _add_norm(x,ord):
|
||||||
|
@ -769,7 +769,7 @@ class DADF5():
|
||||||
'label': '|{}|_{}'.format(x['label'],o),
|
'label': '|{}|_{}'.format(x['label'],o),
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': x['meta']['Unit'],
|
'Unit': x['meta']['Unit'],
|
||||||
'Description': '{}-Norm of {} {} ({})'.format(ord,t,x['label'],x['meta']['Description']),
|
'Description': '{}-norm of {} {} ({})'.format(ord,t,x['label'],x['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_norm v{}'.format(version)
|
'Creator': 'dadf5.py:add_norm v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -777,22 +777,22 @@ class DADF5():
|
||||||
self.__add_generic_pointwise(_add_norm,{'x':x},{'ord':ord})
|
self.__add_generic_pointwise(_add_norm,{'x':x},{'ord':ord})
|
||||||
|
|
||||||
|
|
||||||
def add_PK2(self,F='F',P='P'):
|
def add_PK2(self,P='P',F='F'):
|
||||||
"""
|
"""
|
||||||
Add 2. Piola-Kirchhoff calculated from 1. Piola-Kirchhoff stress and deformation gradient.
|
Add 2. Piola-Kirchhoff calculated from first Piola-Kirchhoff stress and deformation gradient.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
P : str, optional
|
P : str, optional
|
||||||
Label of the dataset containing the 1. Piola-Kirchhoff stress. Default value is ‘P’.
|
Label first Piola-Kirchhoff stress dataset. Defaults to ‘P’.
|
||||||
F : str, optional
|
F : str, optional
|
||||||
Label of the dataset containing the deformation gradient. Default value is ‘F’.
|
Label of deformation gradient dataset. Defaults to ‘F’.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_PK2(F,P):
|
def _add_PK2(P,F):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': mechanics.PK2(F['data'],P['data']),
|
'data': mechanics.PK2(P['data'],F['data']),
|
||||||
'label': 'S',
|
'label': 'S',
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': P['meta']['Unit'],
|
'Unit': P['meta']['Unit'],
|
||||||
|
@ -803,7 +803,7 @@ class DADF5():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_PK2,{'F':F,'P':P})
|
self.__add_generic_pointwise(_add_PK2,{'P':P,'F':F})
|
||||||
|
|
||||||
|
|
||||||
def add_pole(self,q,p,polar=False):
|
def add_pole(self,q,p,polar=False):
|
||||||
|
@ -813,11 +813,11 @@ class DADF5():
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
q : str
|
q : str
|
||||||
Label of the dataset containing the crystallographic orientation as a quaternion.
|
Label of the dataset containing the crystallographic orientation as quaternions.
|
||||||
p : numpy.array of shape (3)
|
p : numpy.array of shape (3)
|
||||||
Pole in crystal frame.
|
Pole in crystal frame.
|
||||||
polar : bool, optional
|
polar : bool, optional
|
||||||
Give pole in polar coordinates. Default is false.
|
Give pole in polar coordinates. Defaults to false.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_pole(q,p,polar):
|
def _add_pole(q,p,polar):
|
||||||
|
@ -853,8 +853,8 @@ class DADF5():
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
F : str
|
F : str, optional
|
||||||
Label of the dataset containing a deformation gradient. Default value is ‘F’.
|
Label of deformation gradient dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_rotational_part(F):
|
def _add_rotational_part(F):
|
||||||
|
@ -872,49 +872,49 @@ class DADF5():
|
||||||
self.__add_generic_pointwise(_add_rotational_part,{'F':F})
|
self.__add_generic_pointwise(_add_rotational_part,{'F':F})
|
||||||
|
|
||||||
|
|
||||||
def add_spherical(self,x):
|
def add_spherical(self,T):
|
||||||
"""
|
"""
|
||||||
Add the spherical (hydrostatic) part of a tensor.
|
Add the spherical (hydrostatic) part of a tensor.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
x : str
|
T : str
|
||||||
Label of the dataset containing a tensor.
|
Label of tensor dataset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_spherical(x):
|
def _add_spherical(T):
|
||||||
|
|
||||||
if not np.all(np.array(x['data'].shape[1:]) == np.array([3,3])):
|
if not np.all(np.array(T['data'].shape[1:]) == np.array([3,3])):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'data': mechanics.spherical_part(x['data']),
|
'data': mechanics.spherical_part(T['data']),
|
||||||
'label': 'p_{}'.format(x['label']),
|
'label': 'p_{}'.format(T['label']),
|
||||||
'meta': {
|
'meta': {
|
||||||
'Unit': x['meta']['Unit'],
|
'Unit': T['meta']['Unit'],
|
||||||
'Description': 'Spherical component of tensor {} ({})'.format(x['label'],x['meta']['Description']),
|
'Description': 'Spherical component of tensor {} ({})'.format(T['label'],T['meta']['Description']),
|
||||||
'Creator': 'dadf5.py:add_spherical v{}'.format(version)
|
'Creator': 'dadf5.py:add_spherical v{}'.format(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.__add_generic_pointwise(_add_spherical,{'x':x})
|
self.__add_generic_pointwise(_add_spherical,{'T':T})
|
||||||
|
|
||||||
|
|
||||||
def add_strain_tensor(self,F='F',t='U',m=0):
|
def add_strain_tensor(self,F='F',t='V',m=0.0):
|
||||||
"""
|
"""
|
||||||
Add strain tensor calculated from a deformation gradient.
|
Add strain tensor of a deformation gradient.
|
||||||
|
|
||||||
For details refer to damask.mechanics.strain_tensor
|
For details refer to damask.mechanics.strain_tensor
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
F : str, optional
|
F : str, optional
|
||||||
Label of the dataset containing the deformation gradient. Default value is ‘F’.
|
Label of deformation gradient dataset. Defaults to ‘F’.
|
||||||
t : {‘V’, ‘U’}, optional
|
t : {‘V’, ‘U’}, optional
|
||||||
Type of the polar decomposition, ‘U’ for right stretch tensor and ‘V’ for left stretch tensor.
|
Type of the polar decomposition, ‘V’ for left stretch tensor and ‘U’ for right stretch tensor.
|
||||||
Default value is ‘U’.
|
Defaults to ‘V’.
|
||||||
m : float, optional
|
m : float, optional
|
||||||
Order of the strain calculation. Default value is ‘0.0’.
|
Order of the strain calculation. Defaults to ‘0.0’.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_strain_tensor(F,t,m):
|
def _add_strain_tensor(F,t,m):
|
||||||
|
@ -932,17 +932,17 @@ class DADF5():
|
||||||
self.__add_generic_pointwise(_add_strain_tensor,{'F':F},{'t':t,'m':m})
|
self.__add_generic_pointwise(_add_strain_tensor,{'F':F},{'t':t,'m':m})
|
||||||
|
|
||||||
|
|
||||||
def add_stretch_tensor(self,F='F',t='U'):
|
def add_stretch_tensor(self,F='F',t='V'):
|
||||||
"""
|
"""
|
||||||
Add stretch tensor calculated from a deformation gradient.
|
Add stretch tensor of a deformation gradient.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
F : str, optional
|
F : str, optional
|
||||||
Label of the dataset containing the deformation gradient. Default value is ‘F’.
|
Label of deformation gradient dataset. Defaults to ‘F’.
|
||||||
t : {‘V’, ‘U’}, optional
|
t : {‘V’, ‘U’}, optional
|
||||||
Type of the polar decomposition, ‘U’ for right stretch tensor and ‘V’ for left stretch tensor.
|
Type of the polar decomposition, ‘V’ for left stretch tensor and ‘U’ for right stretch tensor.
|
||||||
Default value is ‘U’.
|
Defaults to ‘V’.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def _add_stretch_tensor(F,t):
|
def _add_stretch_tensor(F,t):
|
||||||
|
@ -969,8 +969,8 @@ class DADF5():
|
||||||
----------
|
----------
|
||||||
func : function
|
func : function
|
||||||
Function that calculates a new dataset from one or more datasets per HDF5 group.
|
Function that calculates a new dataset from one or more datasets per HDF5 group.
|
||||||
datasets_requested : list of dictionaries
|
dataset_mapping : dictionary
|
||||||
Details of the datasets to be used: label (in HDF5 file) and arg (argument to which the data is parsed in func).
|
Mapping HDF5 data label to callback function argument
|
||||||
extra_args : dictionary, optional
|
extra_args : dictionary, optional
|
||||||
Any extra arguments parsed to func.
|
Any extra arguments parsed to func.
|
||||||
|
|
||||||
|
@ -1018,7 +1018,7 @@ class DADF5():
|
||||||
pool.wait_completion()
|
pool.wait_completion()
|
||||||
|
|
||||||
|
|
||||||
def to_vtk(self,labels,mode='Cell'):
|
def to_vtk(self,labels,mode='cell'):
|
||||||
"""
|
"""
|
||||||
Export to vtk cell/point data.
|
Export to vtk cell/point data.
|
||||||
|
|
||||||
|
@ -1026,12 +1026,12 @@ class DADF5():
|
||||||
----------
|
----------
|
||||||
labels : str or list of
|
labels : str or list of
|
||||||
Labels of the datasets to be exported.
|
Labels of the datasets to be exported.
|
||||||
mode : str, either 'Cell' or 'Point'
|
mode : str, either 'cell' or 'point'
|
||||||
Export in cell format or point format.
|
Export in cell format or point format.
|
||||||
Default value is 'Cell'.
|
Defaults to 'cell'.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if mode=='Cell':
|
if mode.lower()=='cell':
|
||||||
|
|
||||||
if self.structured:
|
if self.structured:
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def Cauchy(F,P):
|
def Cauchy(P,F):
|
||||||
"""
|
"""
|
||||||
Return Cauchy stress calculated from 1. Piola-Kirchhoff stress and deformation gradient.
|
Return Cauchy stress calculated from first Piola-Kirchhoff stress and deformation gradient.
|
||||||
|
|
||||||
Resulting tensor is symmetrized as the Cauchy stress needs to be symmetric.
|
Resulting tensor is symmetrized as the Cauchy stress needs to be symmetric.
|
||||||
|
|
||||||
|
@ -129,16 +129,16 @@ def Mises_stress(sigma):
|
||||||
return __Mises(sigma,3.0/2.0)
|
return __Mises(sigma,3.0/2.0)
|
||||||
|
|
||||||
|
|
||||||
def PK2(F,P):
|
def PK2(P,F):
|
||||||
"""
|
"""
|
||||||
Return 2. Piola-Kirchhoff stress calculated from 1. Piola-Kirchhoff stress and deformation gradient.
|
Calculate second Piola-Kirchhoff stress from first Piola-Kirchhoff stress and deformation gradient.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
F : numpy.array of shape (:,3,3) or (3,3)
|
|
||||||
Deformation gradient.
|
|
||||||
P : numpy.array of shape (:,3,3) or (3,3)
|
P : numpy.array of shape (:,3,3) or (3,3)
|
||||||
1. Piola-Kirchhoff stress.
|
1. Piola-Kirchhoff stress.
|
||||||
|
F : numpy.array of shape (:,3,3) or (3,3)
|
||||||
|
Deformation gradient.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if np.shape(F) == np.shape(P) == (3,3):
|
if np.shape(F) == np.shape(P) == (3,3):
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TestDADF5:
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_calculation(self,default):
|
def test_add_calculation(self,default):
|
||||||
default.add_calculation('2.0*np.abs(#F#)-1.0','x','-','test')
|
default.add_calculation('x','2.0*np.abs(#F#)-1.0','-','my notes')
|
||||||
loc = {'F': default.get_dataset_location('F'),
|
loc = {'F': default.get_dataset_location('F'),
|
||||||
'x': default.get_dataset_location('x')}
|
'x': default.get_dataset_location('x')}
|
||||||
in_memory = 2.0*np.abs(default.read_dataset(loc['F'],0))-1.0
|
in_memory = 2.0*np.abs(default.read_dataset(loc['F'],0))-1.0
|
||||||
|
@ -48,12 +48,12 @@ class TestDADF5:
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_Cauchy(self,default):
|
def test_add_Cauchy(self,default):
|
||||||
default.add_Cauchy('F','P')
|
default.add_Cauchy('P','F')
|
||||||
loc = {'F': default.get_dataset_location('F'),
|
loc = {'F': default.get_dataset_location('F'),
|
||||||
'P': default.get_dataset_location('P'),
|
'P': default.get_dataset_location('P'),
|
||||||
'sigma':default.get_dataset_location('sigma')}
|
'sigma':default.get_dataset_location('sigma')}
|
||||||
in_memory = mechanics.Cauchy(default.read_dataset(loc['F'],0),
|
in_memory = mechanics.Cauchy(default.read_dataset(loc['P'],0),
|
||||||
default.read_dataset(loc['P'],0))
|
default.read_dataset(loc['F'],0))
|
||||||
in_file = default.read_dataset(loc['sigma'],0)
|
in_file = default.read_dataset(loc['sigma'],0)
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class TestDADF5:
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_eigenvalues(self,default):
|
def test_add_eigenvalues(self,default):
|
||||||
default.add_Cauchy('F','P')
|
default.add_Cauchy('P','F')
|
||||||
default.add_eigenvalues('sigma')
|
default.add_eigenvalues('sigma')
|
||||||
loc = {'sigma' :default.get_dataset_location('sigma'),
|
loc = {'sigma' :default.get_dataset_location('sigma'),
|
||||||
'lambda(sigma)':default.get_dataset_location('lambda(sigma)')}
|
'lambda(sigma)':default.get_dataset_location('lambda(sigma)')}
|
||||||
|
@ -83,7 +83,7 @@ class TestDADF5:
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_eigenvectors(self,default):
|
def test_add_eigenvectors(self,default):
|
||||||
default.add_Cauchy('F','P')
|
default.add_Cauchy('P','F')
|
||||||
default.add_eigenvectors('sigma')
|
default.add_eigenvectors('sigma')
|
||||||
loc = {'sigma' :default.get_dataset_location('sigma'),
|
loc = {'sigma' :default.get_dataset_location('sigma'),
|
||||||
'v(sigma)':default.get_dataset_location('v(sigma)')}
|
'v(sigma)':default.get_dataset_location('v(sigma)')}
|
||||||
|
@ -92,7 +92,7 @@ class TestDADF5:
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_maximum_shear(self,default):
|
def test_add_maximum_shear(self,default):
|
||||||
default.add_Cauchy('F','P')
|
default.add_Cauchy('P','F')
|
||||||
default.add_maximum_shear('sigma')
|
default.add_maximum_shear('sigma')
|
||||||
loc = {'sigma' :default.get_dataset_location('sigma'),
|
loc = {'sigma' :default.get_dataset_location('sigma'),
|
||||||
'max_shear(sigma)':default.get_dataset_location('max_shear(sigma)')}
|
'max_shear(sigma)':default.get_dataset_location('max_shear(sigma)')}
|
||||||
|
@ -113,7 +113,7 @@ class TestDADF5:
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_Mises_stress(self,default):
|
def test_add_Mises_stress(self,default):
|
||||||
default.add_Cauchy('F','P')
|
default.add_Cauchy('P','F')
|
||||||
default.add_Mises('sigma')
|
default.add_Mises('sigma')
|
||||||
loc = {'sigma' :default.get_dataset_location('sigma'),
|
loc = {'sigma' :default.get_dataset_location('sigma'),
|
||||||
'sigma_vM':default.get_dataset_location('sigma_vM')}
|
'sigma_vM':default.get_dataset_location('sigma_vM')}
|
||||||
|
@ -130,12 +130,12 @@ class TestDADF5:
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
def test_add_PK2(self,default):
|
def test_add_PK2(self,default):
|
||||||
default.add_PK2('F','P')
|
default.add_PK2('P','F')
|
||||||
loc = {'F':default.get_dataset_location('F'),
|
loc = {'F':default.get_dataset_location('F'),
|
||||||
'P':default.get_dataset_location('P'),
|
'P':default.get_dataset_location('P'),
|
||||||
'S':default.get_dataset_location('S')}
|
'S':default.get_dataset_location('S')}
|
||||||
in_memory = mechanics.PK2(default.read_dataset(loc['F'],0),
|
in_memory = mechanics.PK2(default.read_dataset(loc['P'],0),
|
||||||
default.read_dataset(loc['P'],0))
|
default.read_dataset(loc['F'],0))
|
||||||
in_file = default.read_dataset(loc['S'],0)
|
in_file = default.read_dataset(loc['S'],0)
|
||||||
assert np.allclose(in_memory,in_file)
|
assert np.allclose(in_memory,in_file)
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ class TestMechanics:
|
||||||
def test_vectorize_Cauchy(self):
|
def test_vectorize_Cauchy(self):
|
||||||
P = np.random.random((self.n,3,3))
|
P = np.random.random((self.n,3,3))
|
||||||
F = np.random.random((self.n,3,3))
|
F = np.random.random((self.n,3,3))
|
||||||
assert np.allclose(mechanics.Cauchy(F,P)[self.c],
|
assert np.allclose(mechanics.Cauchy(P,F)[self.c],
|
||||||
mechanics.Cauchy(F[self.c],P[self.c]))
|
mechanics.Cauchy(P[self.c],F[self.c]))
|
||||||
|
|
||||||
def test_vectorize_deviatoric_part(self):
|
def test_vectorize_deviatoric_part(self):
|
||||||
x = np.random.random((self.n,3,3))
|
x = np.random.random((self.n,3,3))
|
||||||
|
@ -51,8 +51,8 @@ class TestMechanics:
|
||||||
def test_vectorize_PK2(self):
|
def test_vectorize_PK2(self):
|
||||||
F = np.random.random((self.n,3,3))
|
F = np.random.random((self.n,3,3))
|
||||||
P = np.random.random((self.n,3,3))
|
P = np.random.random((self.n,3,3))
|
||||||
assert np.allclose(mechanics.PK2(F,P)[self.c],
|
assert np.allclose(mechanics.PK2(P,F)[self.c],
|
||||||
mechanics.PK2(F[self.c],P[self.c]))
|
mechanics.PK2(P[self.c],F[self.c]))
|
||||||
|
|
||||||
def test_vectorize_right_stretch(self):
|
def test_vectorize_right_stretch(self):
|
||||||
x = np.random.random((self.n,3,3))
|
x = np.random.random((self.n,3,3))
|
||||||
|
@ -90,7 +90,7 @@ class TestMechanics:
|
||||||
def test_Cauchy(self):
|
def test_Cauchy(self):
|
||||||
"""Ensure Cauchy stress is symmetrized 1. Piola-Kirchhoff stress for no deformation."""
|
"""Ensure Cauchy stress is symmetrized 1. Piola-Kirchhoff stress for no deformation."""
|
||||||
P = np.random.random((self.n,3,3))
|
P = np.random.random((self.n,3,3))
|
||||||
assert np.allclose(mechanics.Cauchy(np.broadcast_to(np.eye(3),(self.n,3,3)),P),
|
assert np.allclose(mechanics.Cauchy(P,np.broadcast_to(np.eye(3),(self.n,3,3))),
|
||||||
mechanics.symmetric(P))
|
mechanics.symmetric(P))
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class TestMechanics:
|
||||||
def test_PK2(self):
|
def test_PK2(self):
|
||||||
"""Ensure 2. Piola-Kirchhoff stress is symmetrized 1. Piola-Kirchhoff stress for no deformation."""
|
"""Ensure 2. Piola-Kirchhoff stress is symmetrized 1. Piola-Kirchhoff stress for no deformation."""
|
||||||
P = np.random.random((self.n,3,3))
|
P = np.random.random((self.n,3,3))
|
||||||
assert np.allclose(mechanics.PK2(np.broadcast_to(np.eye(3),(self.n,3,3)),P),
|
assert np.allclose(mechanics.PK2(P,np.broadcast_to(np.eye(3),(self.n,3,3))),
|
||||||
mechanics.symmetric(P))
|
mechanics.symmetric(P))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue