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

1#[cfg(test)]
2mod test;
3
4use super::*;
5
6#[doc = include_str!("model.md")]
7#[derive(Debug)]
8pub struct NeoHookean<P> {
9    parameters: P,
10}
11
12impl<P> Constitutive<P> for NeoHookean<P>
13where
14    P: Parameters,
15{
16    fn new(parameters: P) -> Self {
17        Self { parameters }
18    }
19}
20
21impl<P> Solid for NeoHookean<P>
22where
23    P: Parameters,
24{
25    fn bulk_modulus(&self) -> &Scalar {
26        self.parameters.get(0)
27    }
28    fn shear_modulus(&self) -> &Scalar {
29        self.parameters.get(1)
30    }
31}
32
33impl<P> Elastic for NeoHookean<P>
34where
35    P: Parameters,
36{
37    #[doc = include_str!("cauchy_stress.md")]
38    fn cauchy_stress(
39        &self,
40        deformation_gradient: &DeformationGradient,
41    ) -> Result<CauchyStress, ConstitutiveError> {
42        let jacobian = self.jacobian(deformation_gradient)?;
43        Ok(
44            deformation_gradient.left_cauchy_green().deviatoric() / jacobian.powf(FIVE_THIRDS)
45                * self.shear_modulus()
46                + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian),
47        )
48    }
49    #[doc = include_str!("cauchy_tangent_stiffness.md")]
50    fn cauchy_tangent_stiffness(
51        &self,
52        deformation_gradient: &DeformationGradient,
53    ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
54        let jacobian = self.jacobian(deformation_gradient)?;
55        let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
56        let scaled_shear_modulus = self.shear_modulus() / jacobian.powf(FIVE_THIRDS);
57        Ok(
58            (CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
59                + CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
60                - CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
61                    * (TWO_THIRDS))
62                * scaled_shear_modulus
63                + CauchyTangentStiffness::dyad_ij_kl(
64                    &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
65                        - deformation_gradient.left_cauchy_green().deviatoric()
66                            * (scaled_shear_modulus * FIVE_THIRDS)),
67                    &inverse_transpose_deformation_gradient,
68                ),
69        )
70    }
71}
72
73impl<P> Hyperelastic for NeoHookean<P>
74where
75    P: Parameters,
76{
77    #[doc = include_str!("helmholtz_free_energy_density.md")]
78    fn helmholtz_free_energy_density(
79        &self,
80        deformation_gradient: &DeformationGradient,
81    ) -> Result<Scalar, ConstitutiveError> {
82        let jacobian = self.jacobian(deformation_gradient)?;
83        Ok(0.5
84            * (self.shear_modulus()
85                * (deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS)
86                    - 3.0)
87                + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
88    }
89}