pub struct Tensor2 {
pub data: [[f64; 3]; 3],
}Expand description
Second-order tensor (3×3 matrix) stored as row-major [[f64; 3]; 3].
Fields§
§data: [[f64; 3]; 3]Row-major 3×3 component array: data[i][j] is the (i,j) component.
Implementations§
Source§impl Tensor2
impl Tensor2
Sourcepub fn inverse(&self) -> Option<Tensor2>
pub fn inverse(&self) -> Option<Tensor2>
Inverse via cofactor expansion; returns None if |det| < 1e-14.
Sourcepub fn double_contract(&self, other: &Tensor2) -> f64
pub fn double_contract(&self, other: &Tensor2) -> f64
Double contraction A:B = Σ_ij A_ij B_ij.
Sourcepub fn deviatoric(&self) -> Tensor2
pub fn deviatoric(&self) -> Tensor2
Deviatoric part: A − (tr(A)/3) · I.
Sourcepub fn hydrostatic(&self) -> f64
pub fn hydrostatic(&self) -> f64
Hydrostatic (mean normal) stress: tr(A) / 3.
Sourcepub fn eigenvalues_symmetric(&self) -> [f64; 3]
pub fn eigenvalues_symmetric(&self) -> [f64; 3]
Eigenvalues of a symmetric 3×3 tensor via Cardano’s analytical formula.
The tensor is assumed symmetric; only the lower-triangular part is used. Returns eigenvalues sorted in ascending order.
Source§impl Tensor2
impl Tensor2
Sourcepub fn contract_vec(&self, v: [f64; 3]) -> [f64; 3]
pub fn contract_vec(&self, v: [f64; 3]) -> [f64; 3]
Single contraction: c_i = A_ij * v_j (same as apply, alias).
Sourcepub fn dyadic(a: [f64; 3], b: [f64; 3]) -> Tensor2
pub fn dyadic(a: [f64; 3], b: [f64; 3]) -> Tensor2
Tensor outer (dyadic) product from two vectors (static method alias).
Sourcepub fn rotate(&self, r: &Tensor2) -> Tensor2
pub fn rotate(&self, r: &Tensor2) -> Tensor2
Rotate a tensor by a rotation matrix R: R * A * R^T.
Sourcepub fn invariant_i1(&self) -> f64
pub fn invariant_i1(&self) -> f64
First invariant I1 = trace(A).
Sourcepub fn invariant_i2(&self) -> f64
pub fn invariant_i2(&self) -> f64
Second invariant I2 = 0.5 * (trace(A)^2 - trace(A^2)).
Sourcepub fn invariant_i3(&self) -> f64
pub fn invariant_i3(&self) -> f64
Third invariant I3 = det(A).
Sourcepub fn principal_invariants(&self) -> [f64; 3]
pub fn principal_invariants(&self) -> [f64; 3]
Principal invariants as an array [I1, I2, I3].
Sourcepub fn decompose_dev_hydro(&self) -> (Tensor2, f64)
pub fn decompose_dev_hydro(&self) -> (Tensor2, f64)
Deviatoric and hydrostatic decomposition.
Returns (deviatoric, hydrostatic_scalar).
Sourcepub fn from_voigt(v: [f64; 6]) -> Tensor2
pub fn from_voigt(v: [f64; 6]) -> Tensor2
Create a tensor from Voigt notation [xx, yy, zz, xy, yz, xz].
Sourcepub fn effective_strain(&self) -> f64
pub fn effective_strain(&self) -> f64
Effective strain (von Mises strain equivalent).
For a strain tensor: eps_eff = sqrt(2/3 * e_ij * e_ij) where e is the deviatoric strain.
Sourcepub fn is_symmetric(&self, tol: f64) -> bool
pub fn is_symmetric(&self, tol: f64) -> bool
Check if the tensor is symmetric within tolerance.
Sourcepub fn matrix_exp_approx(&self) -> Tensor2
pub fn matrix_exp_approx(&self) -> Tensor2
Matrix exponential approximation using Taylor series (for small tensors).
exp(A) ≈ I + A + A²/2! + A³/3! + … Uses 10 terms by default.
Auto Trait Implementations§
impl Freeze for Tensor2
impl RefUnwindSafe for Tensor2
impl Send for Tensor2
impl Sync for Tensor2
impl Unpin for Tensor2
impl UnsafeUnpin for Tensor2
impl UnwindSafe for Tensor2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.