conspire/constitutive/solid/
mod.rs

1//! Solid constitutive models.
2
3pub mod elastic;
4pub mod elastic_hyperviscous;
5pub mod elastic_viscoplastic;
6pub mod hyperelastic;
7pub mod hyperelastic_viscoplastic;
8pub mod hyperviscoelastic;
9pub mod thermoelastic;
10pub mod thermohyperelastic;
11pub mod viscoelastic;
12
13const TWO_THIRDS: Scalar = 2.0 / 3.0;
14const FIVE_THIRDS: Scalar = 5.0 / 3.0;
15
16use crate::{
17    constitutive::{Constitutive, ConstitutiveError},
18    math::{
19        ContractFirstSecondIndicesWithSecondIndicesOf, ContractSecondIndexWithFirstIndexOf,
20        IDENTITY, IDENTITY_00, Rank2, Tensor, TensorArray, ZERO_10,
21    },
22    mechanics::{
23        CauchyRateTangentStiffness, CauchyStress, CauchyTangentStiffness, Deformation,
24        DeformationError, DeformationGradient, DeformationGradientGeneral, DeformationGradientRate,
25        DeformationGradientRates, DeformationGradients, FirstPiolaKirchhoffRateTangentStiffness,
26        FirstPiolaKirchhoffStress, FirstPiolaKirchhoffTangentStiffness, Scalar,
27        SecondPiolaKirchhoffRateTangentStiffness, SecondPiolaKirchhoffStress,
28        SecondPiolaKirchhoffTangentStiffness, Times,
29    },
30};
31use std::fmt::Debug;
32
33impl<C> Constitutive for C where C: Solid {}
34
35/// Required methods for solid constitutive models.
36pub trait Solid
37where
38    Self: Constitutive,
39{
40    /// Returns the bulk modulus.
41    fn bulk_modulus(&self) -> Scalar;
42    /// Returns the shear modulus.
43    fn shear_modulus(&self) -> Scalar;
44    /// Calculates and returns the Jacobian.
45    fn jacobian<const I: usize, const J: usize>(
46        &self,
47        deformation_gradient: &DeformationGradientGeneral<I, J>,
48    ) -> Result<Scalar, ConstitutiveError> {
49        match deformation_gradient.jacobian() {
50            Err(DeformationError::InvalidJacobian(jacobian)) => Err(
51                ConstitutiveError::InvalidJacobian(jacobian, format!("{self:?}")),
52            ),
53            Ok(jacobian) => Ok(jacobian),
54        }
55    }
56}