conspire/constitutive/solid/elastic/almansi_hamel/
mod.rs

1#[cfg(test)]
2mod test;
3
4use crate::{
5    constitutive::{
6        Constitutive, ConstitutiveError,
7        solid::{Solid, TWO_THIRDS, elastic::Elastic},
8    },
9    math::{IDENTITY, Rank2},
10    mechanics::{CauchyStress, CauchyTangentStiffness, DeformationGradient, Scalar},
11};
12
13#[doc = include_str!("doc.md")]
14#[derive(Debug)]
15pub struct AlmansiHamel {
16    /// The bulk modulus $`\kappa`$.
17    pub bulk_modulus: Scalar,
18    /// The shear modulus $`\mu`$.
19    pub shear_modulus: Scalar,
20}
21
22impl Solid for AlmansiHamel {
23    fn bulk_modulus(&self) -> &Scalar {
24        &self.bulk_modulus
25    }
26    fn shear_modulus(&self) -> &Scalar {
27        &self.shear_modulus
28    }
29}
30
31impl Elastic for AlmansiHamel {
32    #[doc = include_str!("cauchy_stress.md")]
33    fn cauchy_stress(
34        &self,
35        deformation_gradient: &DeformationGradient,
36    ) -> Result<CauchyStress, ConstitutiveError> {
37        let jacobian = self.jacobian(deformation_gradient)?;
38        let inverse_deformation_gradient = deformation_gradient.inverse();
39        let strain = (IDENTITY
40            - inverse_deformation_gradient.transpose() * &inverse_deformation_gradient)
41            * 0.5;
42        let (deviatoric_strain, strain_trace) = strain.deviatoric_and_trace();
43        Ok(deviatoric_strain * (2.0 * self.shear_modulus() / jacobian)
44            + IDENTITY * (self.bulk_modulus() * strain_trace / jacobian))
45    }
46    #[doc = include_str!("cauchy_tangent_stiffness.md")]
47    fn cauchy_tangent_stiffness(
48        &self,
49        deformation_gradient: &DeformationGradient,
50    ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
51        let jacobian = self.jacobian(deformation_gradient)?;
52        let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
53        let inverse_left_cauchy_green_deformation = &inverse_transpose_deformation_gradient
54            * inverse_transpose_deformation_gradient.transpose();
55        let scaled_inverse_left_cauchy_green_deformation =
56            &inverse_left_cauchy_green_deformation * (self.shear_modulus() / jacobian);
57        let strain = (IDENTITY - &inverse_left_cauchy_green_deformation) * 0.5;
58        let (deviatoric_strain, strain_trace) = strain.deviatoric_and_trace();
59        Ok((CauchyTangentStiffness::dyad_il_jk(
60            &inverse_transpose_deformation_gradient,
61            &scaled_inverse_left_cauchy_green_deformation,
62        ) + CauchyTangentStiffness::dyad_ik_jl(
63            &scaled_inverse_left_cauchy_green_deformation,
64            &inverse_transpose_deformation_gradient,
65        )) + CauchyTangentStiffness::dyad_ij_kl(
66            &IDENTITY,
67            &(inverse_left_cauchy_green_deformation
68                * &inverse_transpose_deformation_gradient
69                * ((self.bulk_modulus() - self.shear_modulus() * TWO_THIRDS) / jacobian)),
70        ) - CauchyTangentStiffness::dyad_ij_kl(
71            &(deviatoric_strain * (2.0 * self.shear_modulus() / jacobian)
72                + IDENTITY * (self.bulk_modulus() * strain_trace / jacobian)),
73            &inverse_transpose_deformation_gradient,
74        ))
75    }
76}