sorted alphabetically

This commit is contained in:
Martin Diehl 2020-11-19 14:05:59 +01:00
parent 5a5dd24687
commit 1c07152b96
2 changed files with 100 additions and 99 deletions

View File

@ -1,6 +1,6 @@
"""Finite-strain continuum mechanics.""" """Finite-strain continuum mechanics."""
from . import tensor from . import tensor as _tensor
import numpy as _np import numpy as _np
@ -17,10 +17,10 @@ def deformation_Cauchy_Green_left(F):
Returns Returns
------- -------
B : numpy.ndarray of shape (...,3,3) B : numpy.ndarray of shape (...,3,3)
Left Cauchy-Green deformation tensor. Left Cauchy-Green deformation _tensor.
""" """
return _np.matmul(F,tensor.transpose(F)) return _np.matmul(F,_tensor.transpose(F))
def deformation_Cauchy_Green_right(F): def deformation_Cauchy_Green_right(F):
@ -35,32 +35,10 @@ def deformation_Cauchy_Green_right(F):
Returns Returns
------- -------
C : numpy.ndarray of shape (...,3,3) C : numpy.ndarray of shape (...,3,3)
Right Cauchy-Green deformation tensor. Right Cauchy-Green deformation _tensor.
""" """
return _np.matmul(tensor.transpose(F),F) return _np.matmul(_tensor.transpose(F),F)
def stress_Cauchy(P,F):
"""
Calculate the Cauchy stress (true stress).
Resulting tensor is symmetrized as the Cauchy stress needs to be symmetric.
Parameters
----------
P : numpy.ndarray of shape (...,3,3)
First Piola-Kirchhoff stress.
F : numpy.ndarray of shape (...,3,3)
Deformation gradient.
Returns
-------
sigma : numpy.ndarray of shape (...,3,3)
Cauchy stress.
"""
return tensor.symmetric(_np.einsum('...,...ij,...kj',1.0/_np.linalg.det(F),P,F))
def deviatoric_part(T): def deviatoric_part(T):
@ -81,25 +59,6 @@ def deviatoric_part(T):
return T - spherical_part(T,tensor=True) return T - spherical_part(T,tensor=True)
def maximum_shear(T_sym):
"""
Calculate the maximum shear component of a symmetric tensor.
Parameters
----------
T_sym : numpy.ndarray of shape (...,3,3)
Symmetric tensor of which the maximum shear is computed.
Returns
-------
gamma_max : numpy.ndarray of shape (...)
Maximum shear of T_sym.
"""
w = tensor.eigenvalues(T_sym)
return (w[...,0] - w[...,2])*0.5
def equivalent_strain_Mises(epsilon): def equivalent_strain_Mises(epsilon):
""" """
Calculate the Mises equivalent of a strain tensor. Calculate the Mises equivalent of a strain tensor.
@ -136,27 +95,23 @@ def equivalent_stress_Mises(sigma):
return _equivalent_Mises(sigma,3.0/2.0) return _equivalent_Mises(sigma,3.0/2.0)
def stress_second_Piola_Kirchhoff(P,F): def maximum_shear(T_sym):
""" """
Calculate the second Piola-Kirchhoff stress. Calculate the maximum shear component of a symmetric tensor.
Resulting tensor is symmetrized as the second Piola-Kirchhoff stress
needs to be symmetric.
Parameters Parameters
---------- ----------
P : numpy.ndarray of shape (...,3,3) T_sym : numpy.ndarray of shape (...,3,3)
First Piola-Kirchhoff stress. Symmetric tensor of which the maximum shear is computed.
F : numpy.ndarray of shape (...,3,3)
Deformation gradient.
Returns Returns
------- -------
S : numpy.ndarray of shape (...,3,3) gamma_max : numpy.ndarray of shape (...)
Second Piola-Kirchhoff stress. Maximum shear of T_sym.
""" """
return tensor.symmetric(_np.einsum('...ij,...jk',_np.linalg.inv(F),P)) w = _tensor.eigenvalues(T_sym)
return (w[...,0] - w[...,2])*0.5
def rotational_part(T): def rotational_part(T):
@ -186,14 +141,14 @@ def spherical_part(T,tensor=False):
T : numpy.ndarray of shape (...,3,3) T : numpy.ndarray of shape (...,3,3)
Tensor of which the hydrostatic part is computed. Tensor of which the hydrostatic part is computed.
tensor : bool, optional tensor : bool, optional
Map spherical part onto identity tensor. Defaults to false Map spherical part onto identity _tensor. Defaults to false
Returns Returns
------- -------
p : numpy.ndarray of shape (...) p : numpy.ndarray of shape (...)
unless tensor == True: shape (...,3,3) unless tensor == True: shape (...,3,3)
Spherical part of tensor T, e.g. the hydrostatic part/pressure Spherical part of tensor T, e.g. the hydrostatic part/pressure
of a stress tensor. of a stress _tensor.
""" """
sph = _np.trace(T,axis2=-2,axis1=-1)/3.0 sph = _np.trace(T,axis2=-2,axis1=-1)/3.0
@ -213,7 +168,7 @@ def strain(F,t,m):
Deformation gradient. Deformation gradient.
t : {V, U} t : {V, U}
Type of the polar decomposition, V for left stretch tensor Type of the polar decomposition, V for left stretch tensor
and U for right stretch tensor. and U for right stretch _tensor.
m : float m : float
Order of the strain. Order of the strain.
@ -239,9 +194,55 @@ def strain(F,t,m):
return eps return eps
def stress_Cauchy(P,F):
"""
Calculate the Cauchy stress (true stress).
Resulting tensor is symmetrized as the Cauchy stress needs to be symmetric.
Parameters
----------
P : numpy.ndarray of shape (...,3,3)
First Piola-Kirchhoff stress.
F : numpy.ndarray of shape (...,3,3)
Deformation gradient.
Returns
-------
sigma : numpy.ndarray of shape (...,3,3)
Cauchy stress.
"""
return _tensor.symmetric(_np.einsum('...,...ij,...kj',1.0/_np.linalg.det(F),P,F))
def stress_second_Piola_Kirchhoff(P,F):
"""
Calculate the second Piola-Kirchhoff stress.
Resulting tensor is symmetrized as the second Piola-Kirchhoff stress
needs to be symmetric.
Parameters
----------
P : numpy.ndarray of shape (...,3,3)
First Piola-Kirchhoff stress.
F : numpy.ndarray of shape (...,3,3)
Deformation gradient.
Returns
-------
S : numpy.ndarray of shape (...,3,3)
Second Piola-Kirchhoff stress.
"""
return _tensor.symmetric(_np.einsum('...ij,...jk',_np.linalg.inv(F),P))
def stretch_left(T): def stretch_left(T):
""" """
Calculate left stretch of a tensor. Calculate left stretch of a _tensor.
Parameters Parameters
---------- ----------
@ -259,7 +260,7 @@ def stretch_left(T):
def stretch_right(T): def stretch_right(T):
""" """
Calculate right stretch of a tensor. Calculate right stretch of a _tensor.
Parameters Parameters
---------- ----------

View File

@ -11,42 +11,6 @@ to operate on numpy.ndarrays of shape (...,3,3).
import numpy as _np import numpy as _np
def symmetric(T):
"""
Symmetrize tensor.
Parameters
----------
T : numpy.ndarray of shape (...,3,3)
Tensor of which the symmetrized values are computed.
Returns
-------
T_sym : numpy.ndarray of shape (...,3,3)
Symmetrized tensor T.
"""
return (T+transpose(T))*0.5
def transpose(T):
"""
Transpose tensor.
Parameters
----------
T : numpy.ndarray of shape (...,3,3)
Tensor of which the transpose is computed.
Returns
-------
T.T : numpy.ndarray of shape (...,3,3)
Transpose of tensor T.
"""
return _np.swapaxes(T,axis2=-2,axis1=-1)
def eigenvalues(T_sym): def eigenvalues(T_sym):
""" """
Eigenvalues, i.e. principal components, of a symmetric tensor. Eigenvalues, i.e. principal components, of a symmetric tensor.
@ -89,3 +53,39 @@ def eigenvectors(T_sym,RHS=False):
if RHS: if RHS:
v[_np.linalg.det(v) < 0.0,:,2] *= -1.0 v[_np.linalg.det(v) < 0.0,:,2] *= -1.0
return v return v
def symmetric(T):
"""
Symmetrize tensor.
Parameters
----------
T : numpy.ndarray of shape (...,3,3)
Tensor of which the symmetrized values are computed.
Returns
-------
T_sym : numpy.ndarray of shape (...,3,3)
Symmetrized tensor T.
"""
return (T+transpose(T))*0.5
def transpose(T):
"""
Transpose tensor.
Parameters
----------
T : numpy.ndarray of shape (...,3,3)
Tensor of which the transpose is computed.
Returns
-------
T.T : numpy.ndarray of shape (...,3,3)
Transpose of tensor T.
"""
return _np.swapaxes(T,axis2=-2,axis1=-1)