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

1#[cfg(test)]
2mod test;
3
4use crate::{
5    constitutive::{
6        Constitutive, ConstitutiveError,
7        solid::{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 Gent {
16    /// The bulk modulus $`\kappa`$.
17    pub bulk_modulus: Scalar,
18    /// The shear modulus $`\mu`$.
19    pub shear_modulus: Scalar,
20    /// The extensibility $`J_m`$.
21    pub extensibility: Scalar,
22}
23
24impl Gent {
25    /// Returns the extensibility.
26    pub fn extensibility(&self) -> &Scalar {
27        &self.extensibility
28    }
29}
30
31impl Solid for Gent {
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 Gent {
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        let (
50            deviatoric_isochoric_left_cauchy_green_deformation,
51            isochoric_left_cauchy_green_deformation_trace,
52        ) = isochoric_left_cauchy_green_deformation.deviatoric_and_trace();
53        let denominator =
54            self.extensibility() - isochoric_left_cauchy_green_deformation_trace + 3.0;
55        if denominator <= 0.0 {
56            Err(ConstitutiveError::Custom(
57                "Maximum extensibility reached.".to_string(),
58                format!("{:?}", &self),
59            ))
60        } else {
61            Ok((deviatoric_isochoric_left_cauchy_green_deformation
62                * self.shear_modulus()
63                * self.extensibility()
64                / jacobian)
65                / denominator
66                + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian))
67        }
68    }
69    #[doc = include_str!("cauchy_tangent_stiffness.md")]
70    fn cauchy_tangent_stiffness(
71        &self,
72        deformation_gradient: &DeformationGradient,
73    ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
74        let jacobian = self.jacobian(deformation_gradient)?;
75        let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
76        let isochoric_left_cauchy_green_deformation =
77            deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS);
78        let (
79            deviatoric_isochoric_left_cauchy_green_deformation,
80            isochoric_left_cauchy_green_deformation_trace,
81        ) = isochoric_left_cauchy_green_deformation.deviatoric_and_trace();
82        let denominator =
83            self.extensibility() - isochoric_left_cauchy_green_deformation_trace + 3.0;
84        if denominator <= 0.0 {
85            Err(ConstitutiveError::Custom(
86                "Maximum extensibility reached.".to_string(),
87                format!("{:?}", &self),
88            ))
89        } else {
90            let prefactor = self.shear_modulus() * self.extensibility() / jacobian / denominator;
91            Ok(
92                (CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
93                    + CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
94                    - CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
95                        * (TWO_THIRDS)
96                    + CauchyTangentStiffness::dyad_ij_kl(
97                        &deviatoric_isochoric_left_cauchy_green_deformation,
98                        deformation_gradient,
99                    ) * (2.0 / denominator))
100                    * (prefactor / jacobian.powf(TWO_THIRDS))
101                    + CauchyTangentStiffness::dyad_ij_kl(
102                        &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
103                            - deviatoric_isochoric_left_cauchy_green_deformation
104                                * prefactor
105                                * ((5.0
106                                    + 2.0 * isochoric_left_cauchy_green_deformation_trace
107                                        / denominator)
108                                    / 3.0)),
109                        &inverse_transpose_deformation_gradient,
110                    ),
111            )
112        }
113    }
114}
115
116impl Hyperelastic for Gent {
117    #[doc = include_str!("helmholtz_free_energy_density.md")]
118    fn helmholtz_free_energy_density(
119        &self,
120        deformation_gradient: &DeformationGradient,
121    ) -> Result<Scalar, ConstitutiveError> {
122        let jacobian = self.jacobian(deformation_gradient)?;
123        let factor = (deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS)
124            - 3.0)
125            / self.extensibility();
126        if factor >= 1.0 {
127            Err(ConstitutiveError::Custom(
128                "Maximum extensibility reached.".to_string(),
129                format!("{:?}", &self),
130            ))
131        } else {
132            Ok(0.5
133                * (-self.shear_modulus() * self.extensibility() * (1.0 - factor).ln()
134                    + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
135        }
136    }
137}