2019-10-19 00:20:03 +05:30
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
def Cauchy(F,P):
|
2019-10-19 12:21:51 +05:30
|
|
|
|
"""
|
2019-10-19 16:24:16 +05:30
|
|
|
|
Return Cauchy stress calculated from 1. Piola-Kirchhoff stress and deformation gradient.
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
|
|
|
|
Resulting tensor is symmetrized as the Cauchy stress needs to be symmetric.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
F : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:24:16 +05:30
|
|
|
|
Deformation gradient.
|
2019-10-19 12:21:51 +05:30
|
|
|
|
P : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:24:16 +05:30
|
|
|
|
1. Piola-Kirchhoff stress.
|
2019-10-19 16:40:46 +05:30
|
|
|
|
|
2019-10-19 12:21:51 +05:30
|
|
|
|
"""
|
2019-10-19 00:20:03 +05:30
|
|
|
|
if np.shape(F) == np.shape(P) == (3,3):
|
|
|
|
|
sigma = 1.0/np.linalg.det(F) * np.dot(F,P)
|
|
|
|
|
else:
|
2019-10-19 16:24:16 +05:30
|
|
|
|
sigma = np.einsum('i,ijk,ilk->ijl',1.0/np.linalg.det(F),P,F)
|
|
|
|
|
return symmetric(sigma)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def strain_tensor(F,t,ord):
|
|
|
|
|
"""
|
|
|
|
|
Return strain tensor calculated from deformation gradient.
|
|
|
|
|
|
|
|
|
|
For details refer to Albrecht Bertram: Elasticity and Plasticity of Large Deformations:
|
|
|
|
|
An Introduction (3rd Edition, 2012), p. 102.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
F : numpy.array of shape (x,3,3) or (3,3)
|
|
|
|
|
Deformation gradient.
|
|
|
|
|
t : {‘V’, ‘U’}
|
|
|
|
|
Type of the polar decomposition, ‘V’ for right stretch tensor and ‘U’ for left stretch tensor.
|
|
|
|
|
ord : float
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Order of the strain.
|
|
|
|
|
|
2019-10-19 16:24:16 +05:30
|
|
|
|
"""
|
|
|
|
|
if t == 'U':
|
2019-10-19 16:40:46 +05:30
|
|
|
|
B = np.matmul(F,transpose(F))
|
|
|
|
|
U,n = np.linalg.eigh(B)
|
|
|
|
|
lmd = np.log(U) if ord == 0 else \
|
|
|
|
|
U**ord - (np.broadcast_to(np.ones(3),[U.shape[0],3]) if len(F.shape) == 3 else np.ones(3))
|
2019-10-19 16:24:16 +05:30
|
|
|
|
elif t == 'V':
|
2019-10-19 16:40:46 +05:30
|
|
|
|
C = np.matmul(transpose(F),F)
|
|
|
|
|
V,n = np.linalg.eigh(C)
|
|
|
|
|
lmd = np.log(V) if ord == 0 else \
|
|
|
|
|
- 1.0/V**ord + (np.broadcast_to(np.ones(3),[V.shape[0],3]) if len(F.shape) == 3 else np.ones(3))
|
|
|
|
|
|
|
|
|
|
return np.dot(n,np.dot(np.diag(l),n.T)) if np.shape(F) == (3,3) else \
|
|
|
|
|
np.matmul(n,np.einsum('ij,ikj->ijk',lmd,n))
|
2019-10-19 00:20:03 +05:30
|
|
|
|
|
|
|
|
|
|
2019-10-19 12:21:51 +05:30
|
|
|
|
def deviatoric_part(x):
|
|
|
|
|
"""
|
2019-10-19 16:24:16 +05:30
|
|
|
|
Return deviatoric part of a tensor.
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
x : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Tensor of which the deviatoric part is computed.
|
|
|
|
|
|
2019-10-19 12:21:51 +05:30
|
|
|
|
"""
|
2019-10-19 16:24:16 +05:30
|
|
|
|
return x - np.eye(3)*spherical_part(x) if np.shape(x) == (3,3) else \
|
|
|
|
|
x - np.einsum('ijk,i->ijk',np.broadcast_to(np.eye(3),[x.shape[0],3,3]),spherical_part(x))
|
2019-10-19 00:20:03 +05:30
|
|
|
|
|
|
|
|
|
|
2019-10-19 12:21:51 +05:30
|
|
|
|
def spherical_part(x):
|
|
|
|
|
"""
|
2019-10-19 16:24:16 +05:30
|
|
|
|
Return spherical (hydrostatic) part of a tensor.
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
2019-10-19 16:24:16 +05:30
|
|
|
|
A single scalar is returned, i.e. the hydrostatic part is not mapped on the 3rd order identity
|
|
|
|
|
matrix.
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
x : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Tensor of which the hydrostatic part is computed.
|
|
|
|
|
|
2019-10-19 12:21:51 +05:30
|
|
|
|
"""
|
2019-10-19 16:24:16 +05:30
|
|
|
|
return np.trace(x)/3.0 if np.shape(x) == (3,3) else \
|
|
|
|
|
np.trace(x,axis1=1,axis2=2)/3.0
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def Mises_stress(sigma):
|
|
|
|
|
"""
|
2019-10-19 16:24:16 +05:30
|
|
|
|
Return the Mises equivalent of a stress tensor.
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
sigma : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Symmetric stress tensor of which the von Mises equivalent is computed.
|
|
|
|
|
|
2019-10-19 12:21:51 +05:30
|
|
|
|
"""
|
|
|
|
|
s = deviatoric_part(sigma)
|
2019-10-19 16:24:16 +05:30
|
|
|
|
return np.sqrt(3.0/2.0*np.trace(s)) if np.shape(sigma) == (3,3) else \
|
|
|
|
|
np.sqrt(3.0/2.0*np.einsum('ijk->i',s))
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def Mises_strain(epsilon):
|
|
|
|
|
"""
|
2019-10-19 16:24:16 +05:30
|
|
|
|
Return the Mises equivalent of a strain tensor.
|
2019-10-19 12:21:51 +05:30
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
2019-10-19 16:24:16 +05:30
|
|
|
|
epsilon : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Symmetric strain tensor of which the von Mises equivalent is computed.
|
|
|
|
|
|
2019-10-19 12:21:51 +05:30
|
|
|
|
"""
|
|
|
|
|
s = deviatoric_part(epsilon)
|
2019-10-19 16:24:16 +05:30
|
|
|
|
return np.sqrt(2.0/3.0*np.trace(s)) if np.shape(epsilon) == (3,3) else \
|
|
|
|
|
np.sqrt(2.0/3.0*np.einsum('ijk->i',s))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def symmetric(x):
|
|
|
|
|
"""
|
|
|
|
|
Return the symmetrized tensor.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
x : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Tensor of which the symmetrized values are computed.
|
|
|
|
|
|
2019-10-19 16:24:16 +05:30
|
|
|
|
"""
|
|
|
|
|
return (x+transpose(x))*0.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def maximum_shear(x):
|
|
|
|
|
"""
|
|
|
|
|
Return the maximum shear component of a symmetric tensor.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
x : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Symmetric tensor of which the maximum shear is computed.
|
|
|
|
|
|
2019-10-19 16:24:16 +05:30
|
|
|
|
"""
|
|
|
|
|
w = np.linalg.eigvalsh(symmetric(x)) # eigenvalues in ascending order
|
2019-10-19 16:40:46 +05:30
|
|
|
|
return (w[2] - w[0])*0.5 if np.shape(x) == (3,3) else \
|
2019-10-19 16:24:16 +05:30
|
|
|
|
(w[:,2] - w[:,0])*0.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def principal_components(x):
|
|
|
|
|
"""
|
|
|
|
|
Return the principal components of a symmetric tensor.
|
|
|
|
|
|
|
|
|
|
The principal components (eigenvalues) are sorted in descending order, each repeated according to
|
|
|
|
|
its multiplicity.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
x : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Symmetric tensor of which the principal compontents are computed.
|
|
|
|
|
|
2019-10-19 16:24:16 +05:30
|
|
|
|
"""
|
|
|
|
|
w = np.linalg.eigvalsh(symmetric(x)) # eigenvalues in ascending order
|
2019-10-19 16:40:46 +05:30
|
|
|
|
return w[::-1] if np.shape(x) == (3,3) else \
|
2019-10-19 16:24:16 +05:30
|
|
|
|
w[:,::-1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def transpose(x):
|
|
|
|
|
"""
|
|
|
|
|
Return the transpose of a tensor.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
x : numpy.array of shape (x,3,3) or (3,3)
|
2019-10-19 16:40:46 +05:30
|
|
|
|
Tensor of which the transpose is computer.
|
|
|
|
|
|
2019-10-19 16:24:16 +05:30
|
|
|
|
"""
|
|
|
|
|
return x.T if np.shape(x) == (3,3) else \
|
|
|
|
|
np.transpose(x,(0,2,1))
|