Russell Tensor - Tensor analysis, calculus, and functions for continuum mechanics
This crate is part of Russell - Rust Scientific Library
Contents
Introduction
This library implements structures and functions for tensor analysis and calculus, with focus on applications in engineering and Continuum Mechanics. The essential functionality for the targeted applications includes first-order, second-order, third-order, and fourth-order tensors, scalar "invariants," and derivatives.
Capabilities
Tensor1โ first-order tensors (vectors in R3) with operations such as the dot and cross productsTensor2โ second-order tensors (symmetric or not) with functions such as the determinant, inverse, norm, and invariants (principal, deviatoric, Lode, octahedral, ...)Tensor3โ third-order tensors (minor-symmetric or not)Tensor4โ fourth-order tensors (minor-symmetric or not)- Operations between tensors โ addition, single and double contractions (dot and ddot), and dyadic products; most operations support both overwriting (
SET) and accumulation (ADD) - Analytical derivatives โ first and second derivatives of invariants and tensor functions (e.g., the inverse and squared tensors) with respect to tensors
EigenValuesT2,EigenProjsT2,EigenProjDerivsT2โ eigenvalues, eigenprojectors, and the derivatives of the eigenprojectors of symmetric second-order tensorsLinElasticityโ the linear elasticity equations for small-strain problems (Hooke's law)PiezoDatabaseโ a database of piezoelectric materials (permittivity, piezoelectric, and stiffness tensors) loaded from JSON- Constants โ identity, transposition, and projector tensors, as well as the
ADD/SEToperation selectors - Polar decomposition โ
F = R U = V Rvia the classic Eigen/SVD algorithms, Brannon's iterative algorithm, or the quaternion-based Higham & Noferini (2016) algorithm (PolarAlgo,polar_decomp_mx)
Kelvin-Mandel notation
Internally, tensors are stored as vectors/matrices with components given with respect to the Kelvin-Mandel basis, i.e., the Kelvin-Mandel notation, a norm-preserving alternative to Voigt notation. In the Kelvin-Mandel notation, a second-order tensor is mapped to a column matrix (vector), a third-order tensor is mapped to a rectangular matrix, and a fourth-order tensor is mapped to a square matrix. Factors such as โ2 multiply some components to yield the norm-preserving mapping.
The dimension โ the const generic N of Tensor2/Tensor4, and M/N of Tensor3 โ selects the representation:
9โ all components (general): 9ร1 / 9ร3 / 3ร9 / 9ร96โ symmetricTensor2/ minor-symmetricTensor3/Tensor4(3D): 6ร1 / 6ร3 / 3ร6 / 6ร64โ symmetricTensor2/ minor-symmetricTensor3/Tensor4(2D): 4ร1 / 4ร3 / 3ร4 / 4ร4
The dimensions above correspond to Tensor2 (vector), Tensor3 (Case A / Case B rectangular matrix), and Tensor4 (square matrix), respectively.
A Tensor3 is stored as a rectangular Kelvin-Mandel matrix with dimensions (M, N) set by const generics. Two cases are considered, where DIM (the leading dimension) is one of 4, 6, or 9:
- Case A โ
(DIM, 3), i.e.M = DIMandN = 3: the Tensor3 acts on aTensor1(vector) yielding aTensor2(T = H ยท u) - Case B โ
(3, DIM), i.e.M = 3andN = DIM: the Tensor3 acts on aTensor2yielding aTensor1(vector) (v = M : S)
For second-order tensors, the stored component order is:
| Representation | Stored components |
|---|---|
9 (general) |
T11, T22, T33, (T12 + T21)/โ2, (T23 + T32)/โ2, (T13 + T31)/โ2, (T12 - T21)/โ2, (T23 - T32)/โ2, (T13 - T31)/โ2 |
6 (symmetric) |
T11, T22, T33, โ2 T12, โ2 T23, โ2 T13 |
4 (symmetric 2D) |
T11, T22, T33, โ2 T12 |
Use the *_std* constructors and accessors when working with ordinary Cartesian
components, such as Tensor2::from_std_matrix and Tensor2::get_std. Use the
accessors without std only when working directly with the stored
Kelvin-Mandel components. For example, an off-diagonal component T12 = 4
is stored as โ2 ร 4 in a symmetric tensor, so from_std_matrix expects 4
while get(3) returns โ2 ร 4.
Documentation
Installation
This crate depends on russell_lab, which requires non-Rust high-performance libraries. See the main README file for the steps to install these dependencies.
Setting Cargo.toml
๐ Check the crate version and update your Cargo.toml accordingly:
[]
= "*"
Optional features
The following (Rust) features are available:
intel_mkl: Use Intel MKL instead of OpenBLAS
Note that the main README file presents the steps to compile the required libraries according to each feature.
๐ Examples
This section illustrates how to use russell_tensor. See also:
Computing the Invariants
use ;
Allocating Second Order Tensors
use ;
For developers
- This crate depends on
russell_lab, which requires non-Rust high-performance libraries (see the Installation section) - Run the examples with
cargo run --example <name>