conspire/constitutive/solid/hyperelastic/mooney_rivlin/
mod.rs

1#[cfg(test)]
2mod test;
3
4use crate::{
5    constitutive::{
6        Constitutive, ConstitutiveError,
7        solid::{FIVE_THIRDS, Solid, TWO_THIRDS, elastic::Elastic, hyperelastic::Hyperelastic},
8    },
9    math::{IDENTITY, Rank2},
10    mechanics::{CauchyStress, CauchyTangentStiffness, Deformation, DeformationGradient, Scalar},
11};
12
13#[doc = include_str!("doc.md")]
14#[derive(Debug)]
15pub struct MooneyRivlin {
16    /// The bulk modulus $`\kappa`$.
17    pub bulk_modulus: Scalar,
18    /// The shear modulus $`\mu`$.
19    pub shear_modulus: Scalar,
20    /// The extra modulus $`\mu_m`$.
21    pub extra_modulus: Scalar,
22}
23
24impl MooneyRivlin {
25    /// Returns the extra modulus.
26    pub fn extra_modulus(&self) -> &Scalar {
27        &self.extra_modulus
28    }
29}
30
31impl Solid for MooneyRivlin {
32    fn bulk_modulus(&self) -> &Scalar {
33        &self.bulk_modulus
34    }
35    fn shear_modulus(&self) -> &Scalar {
36        &self.shear_modulus
37    }
38}
39
40impl Elastic for MooneyRivlin {
41    #[doc = include_str!("cauchy_stress.md")]
42    fn cauchy_stress(
43        &self,
44        deformation_gradient: &DeformationGradient,
45    ) -> Result<CauchyStress, ConstitutiveError> {
46        let jacobian = self.jacobian(deformation_gradient)?;
47        let isochoric_left_cauchy_green_deformation =
48            deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS);
49        Ok(((isochoric_left_cauchy_green_deformation.deviatoric()
50            * (self.shear_modulus() - self.extra_modulus())
51            - isochoric_left_cauchy_green_deformation
52                .inverse()
53                .deviatoric()
54                * self.extra_modulus())
55            + IDENTITY * (self.bulk_modulus() * 0.5 * (jacobian.powi(2) - 1.0)))
56            / jacobian)
57    }
58    #[doc = include_str!("cauchy_tangent_stiffness.md")]
59    fn cauchy_tangent_stiffness(
60        &self,
61        deformation_gradient: &DeformationGradient,
62    ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
63        let jacobian = self.jacobian(deformation_gradient)?;
64        let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
65        let scaled_delta_shear_modulus =
66            (self.shear_modulus() - self.extra_modulus()) / jacobian.powf(FIVE_THIRDS);
67        let inverse_isochoric_left_cauchy_green_deformation =
68            (deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS)).inverse();
69        let deviatoric_inverse_isochoric_left_cauchy_green_deformation =
70            inverse_isochoric_left_cauchy_green_deformation.deviatoric();
71        let term_1 = CauchyTangentStiffness::dyad_ij_kl(
72            &inverse_isochoric_left_cauchy_green_deformation,
73            &inverse_transpose_deformation_gradient,
74        ) * TWO_THIRDS
75            - CauchyTangentStiffness::dyad_ik_jl(
76                &inverse_isochoric_left_cauchy_green_deformation,
77                &inverse_transpose_deformation_gradient,
78            )
79            - CauchyTangentStiffness::dyad_il_jk(
80                &inverse_transpose_deformation_gradient,
81                &inverse_isochoric_left_cauchy_green_deformation,
82            );
83        let term_3 = CauchyTangentStiffness::dyad_ij_kl(
84            &deviatoric_inverse_isochoric_left_cauchy_green_deformation,
85            &inverse_transpose_deformation_gradient,
86        );
87        let term_2 = CauchyTangentStiffness::dyad_ij_kl(
88            &IDENTITY,
89            &((deviatoric_inverse_isochoric_left_cauchy_green_deformation * TWO_THIRDS)
90                * &inverse_transpose_deformation_gradient),
91        );
92        Ok(
93            (CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
94                + CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
95                - CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
96                    * (TWO_THIRDS))
97                * scaled_delta_shear_modulus
98                + CauchyTangentStiffness::dyad_ij_kl(
99                    &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
100                        - deformation_gradient.left_cauchy_green().deviatoric()
101                            * (scaled_delta_shear_modulus * FIVE_THIRDS)),
102                    &inverse_transpose_deformation_gradient,
103                )
104                - (term_1 + term_2 - term_3) * self.extra_modulus() / jacobian,
105        )
106    }
107}
108
109impl Hyperelastic for MooneyRivlin {
110    #[doc = include_str!("helmholtz_free_energy_density.md")]
111    fn helmholtz_free_energy_density(
112        &self,
113        deformation_gradient: &DeformationGradient,
114    ) -> Result<Scalar, ConstitutiveError> {
115        let jacobian = self.jacobian(deformation_gradient)?;
116        let isochoric_left_cauchy_green_deformation =
117            deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS);
118        Ok(0.5
119            * ((self.shear_modulus() - self.extra_modulus())
120                * (isochoric_left_cauchy_green_deformation.trace() - 3.0)
121                + self.extra_modulus()
122                    * (isochoric_left_cauchy_green_deformation.second_invariant() - 3.0)
123                + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
124    }
125}