$$ \newcommand{\C}{{\mathbb{{C}}}} \newcommand{\R}{{\mathbb{{R}}}} \newcommand{\Q}{{\mathbb{{Q}}}} \newcommand{\Z}{{\mathbb{{Z}}}} \newcommand{\N}{{\mathbb{{N}}}} \newcommand{\uu}[1]{{\boldsymbol{{#1}}}} \newcommand{\uuuu}[1]{{\symbb{{#1}}}} \newcommand{\uv}[1]{{\underline{{#1}}}} \newcommand{\ve}[1]{{\uv{{e}}_{{#1}}}} \newcommand{\x}{{\uv{{x}}}} \newcommand{\n}{{\uv{{n}}}} \newcommand{\eps}{{\uu{{\varepsilon}}}} \newcommand{\E}{{\uu{{E}}}} \newcommand{\sig}{{\uu{{\sigma}}}} \newcommand{\Sig}{{\uu{{\Sigma}}}} \newcommand{\cod}{{\uv{{\symscr{b}}}}} % \newcommand{\trans}[1]{{{}^{t}{#1}}} \newcommand{\trans}[1]{{{#1}{}^\intercal}} \newcommand{\sotimes}{{\stackrel{s}{\otimes}}} \newcommand{\sboxtimes}{\stackrel{s}{\boxtimes}} \newcommand{\norm}[1]{{\lVert{{#1}}\rVert}} \newcommand{\ud}{{\,\mathrm{d}}} \newcommand{\mat}{\mathsf} \DeclareMathOperator{\arcosh}{arcosh} \DeclareMathOperator{\divz}{div} \DeclareMathOperator{\divu}{\uv{div}} \DeclareMathOperator{\hess}{hess} \DeclareMathOperator{\gradu}{\uv{grad}} \DeclareMathOperator{\graduu}{\uu{grad}} \DeclareMathOperator{\Mat}{Mat} \DeclareMathOperator{\tr}{tr} \DeclareMathOperator{\ISO}{ISO} \newcommand{\volt}[1]{{#1}^{-1\circ}} \newcommand{\dcirc}{\overset{\circ}{:}} \newcommand{\jump}[1]{\mathopen{[\![}\,#1\,\mathclose{]\!]}} $$

1  Kelvin-Mandel notation

Important Objectives

Before introducing the specific objects of echoes devoted to tensor calculations in isotropic or anisotropic contexts, this tutorial aims at providing the syntax allowing to represent second-order or fourth-order tensors under the form of matrices in the Kelvin-Mandel notation as detailed in Section A.2.

import numpy as np
from echoes import *
import math, random

np.set_printoptions(precision=8, suppress=True)
# to display only 8 significant digits of array components

A symmetric \(3×3\) second-order matrix can be transformed in a vector of \(\R^6\) by the function KM consistently with (A.14). The inverse is done by invKM.

α = np.random.rand(3, 3) ; ε =+α.T)/2
print("ε =\n",ε)
print("KM(ε) =\n",KM(ε))
assert np.allclose(invKM(KM(ε)), ε), "error"
ε =
 [[0.69709813 0.53506694 0.32442103]
 [0.53506694 0.94504071 0.77793264]
 [0.32442103 0.77793264 0.3123916 ]]
KM(ε) =
 [0.69709813 0.94504071 0.3123916  1.10016289 0.45880062 0.75669892]

Given a \(3×3×3×3\) array c (of type numpy.ndarray) satisfying major and minor symmetries (see Section A.2), the corresponding \(6×6\) matrix C obtained by Kelvin-Mandel transform is calculated by C = KM(c). Conversely, if C is a positive definite matrix, c is calculated by c = invKM(C).

A = np.random.rand(6,6)
C = A.T.dot(A) + np.eye(6) # generation of an arbitrary positive definite matrix
c = invKM(C)
print("C =\n",C)
print("c =\n",c)
assert np.allclose(KM(c), C), "error: KM(c) should be equal to C"
C =
 [[2.8344474  1.34244392 1.68007537 1.99254191 1.60339856 1.25473437]
 [1.34244392 2.80416731 1.9010566  1.6950774  1.97903622 0.90911807]
 [1.68007537 1.9010566  3.18344589 2.10720072 2.31111208 1.38175589]
 [1.99254191 1.6950774  2.10720072 3.43130947 2.12506884 1.71139854]
 [1.60339856 1.97903622 2.31111208 2.12506884 3.68201779 1.60227351]
 [1.25473437 0.90911807 1.38175589 1.71139854 1.60227351 2.64520247]]
c =
 [[[[2.8344474  0.88723118 1.133774  ]
   [0.88723118 1.34244392 1.4089399 ]
   [1.133774   1.4089399  1.68007537]]

  [[0.88723118 1.32260124 0.80113676]
   [1.32260124 0.64284356 0.85569927]
   [0.80113676 0.85569927 0.97704896]]

  [[1.133774   0.80113676 1.8410089 ]
   [0.80113676 1.39938993 1.06253442]
   [1.8410089  1.06253442 1.63420302]]]


 [[[0.88723118 1.32260124 0.80113676]
   [1.32260124 0.64284356 0.85569927]
   [0.80113676 0.85569927 0.97704896]]

  [[1.34244392 0.64284356 1.39938993]
   [0.64284356 2.80416731 1.19860072]
   [1.39938993 1.19860072 1.9010566 ]]

  [[1.4089399  0.85569927 1.06253442]
   [0.85569927 1.19860072 1.71565474]
   [1.06253442 1.71565474 1.49001592]]]


 [[[1.133774   0.80113676 1.8410089 ]
   [0.80113676 1.39938993 1.06253442]
   [1.8410089  1.06253442 1.63420302]]

  [[1.4089399  0.85569927 1.06253442]
   [0.85569927 1.19860072 1.71565474]
   [1.06253442 1.71565474 1.49001592]]

  [[1.68007537 0.97704896 1.63420302]
   [0.97704896 1.9010566  1.49001592]
   [1.63420302 1.49001592 3.18344589]]]]

\(\,\)