conspire/constitutive/solid/hyperelastic/neo_hookean/
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(Clone, Debug)]
15pub struct NeoHookean {
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 NeoHookean {
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 NeoHookean {
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        Ok(
39            deformation_gradient.left_cauchy_green().deviatoric() / jacobian.powf(FIVE_THIRDS)
40                * self.shear_modulus()
41                + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian),
42        )
43    }
44    #[doc = include_str!("cauchy_tangent_stiffness.md")]
45    fn cauchy_tangent_stiffness(
46        &self,
47        deformation_gradient: &DeformationGradient,
48    ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
49        let jacobian = self.jacobian(deformation_gradient)?;
50        let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
51        let scaled_shear_modulus = self.shear_modulus() / jacobian.powf(FIVE_THIRDS);
52        Ok(
53            (CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
54                + CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
55                - CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
56                    * (TWO_THIRDS))
57                * scaled_shear_modulus
58                + CauchyTangentStiffness::dyad_ij_kl(
59                    &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
60                        - deformation_gradient.left_cauchy_green().deviatoric()
61                            * (scaled_shear_modulus * FIVE_THIRDS)),
62                    &inverse_transpose_deformation_gradient,
63                ),
64        )
65    }
66}
67
68impl Hyperelastic for NeoHookean {
69    #[doc = include_str!("helmholtz_free_energy_density.md")]
70    fn helmholtz_free_energy_density(
71        &self,
72        deformation_gradient: &DeformationGradient,
73    ) -> Result<Scalar, ConstitutiveError> {
74        let jacobian = self.jacobian(deformation_gradient)?;
75        Ok(0.5
76            * (self.shear_modulus()
77                * (deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS)
78                    - 3.0)
79                + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
80    }
81}