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

1#[cfg(test)]
2mod test;
3
4use super::*;
5
6#[doc = include_str!("model.md")]
7#[derive(Debug)]
8pub struct Gent<P> {
9    parameters: P,
10}
11
12impl<P> Gent<P>
13where
14    P: Parameters,
15{
16    /// Returns the extensibility.
17    pub fn extensibility(&self) -> &Scalar {
18        self.parameters.get(2)
19    }
20}
21
22impl<P> Constitutive<P> for Gent<P>
23where
24    P: Parameters,
25{
26    fn new(parameters: P) -> Self {
27        Self { parameters }
28    }
29}
30
31impl<P> Solid for Gent<P>
32where
33    P: Parameters,
34{
35    fn bulk_modulus(&self) -> &Scalar {
36        self.parameters.get(0)
37    }
38    fn shear_modulus(&self) -> &Scalar {
39        self.parameters.get(1)
40    }
41}
42
43impl<P> Elastic for Gent<P>
44where
45    P: Parameters,
46{
47    #[doc = include_str!("cauchy_stress.md")]
48    fn cauchy_stress(
49        &self,
50        deformation_gradient: &DeformationGradient,
51    ) -> Result<CauchyStress, ConstitutiveError> {
52        let jacobian = self.jacobian(deformation_gradient)?;
53        let isochoric_left_cauchy_green_deformation =
54            deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS);
55        let (
56            deviatoric_isochoric_left_cauchy_green_deformation,
57            isochoric_left_cauchy_green_deformation_trace,
58        ) = isochoric_left_cauchy_green_deformation.deviatoric_and_trace();
59        let denominator =
60            self.extensibility() - isochoric_left_cauchy_green_deformation_trace + 3.0;
61        if denominator <= 0.0 {
62            Err(ConstitutiveError::Custom(
63                "Maximum extensibility reached.".to_string(),
64                deformation_gradient.clone(),
65                format!("{:?}", &self),
66            ))
67        } else {
68            Ok((deviatoric_isochoric_left_cauchy_green_deformation
69                * self.shear_modulus()
70                * self.extensibility()
71                / jacobian)
72                / denominator
73                + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian))
74        }
75    }
76    #[doc = include_str!("cauchy_tangent_stiffness.md")]
77    fn cauchy_tangent_stiffness(
78        &self,
79        deformation_gradient: &DeformationGradient,
80    ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
81        let jacobian = self.jacobian(deformation_gradient)?;
82        let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
83        let isochoric_left_cauchy_green_deformation =
84            deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS);
85        let (
86            deviatoric_isochoric_left_cauchy_green_deformation,
87            isochoric_left_cauchy_green_deformation_trace,
88        ) = isochoric_left_cauchy_green_deformation.deviatoric_and_trace();
89        let denominator =
90            self.extensibility() - isochoric_left_cauchy_green_deformation_trace + 3.0;
91        if denominator <= 0.0 {
92            Err(ConstitutiveError::Custom(
93                "Maximum extensibility reached.".to_string(),
94                deformation_gradient.clone(),
95                format!("{:?}", &self),
96            ))
97        } else {
98            let prefactor = self.shear_modulus() * self.extensibility() / jacobian / denominator;
99            Ok(
100                (CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
101                    + CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
102                    - CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
103                        * (TWO_THIRDS)
104                    + CauchyTangentStiffness::dyad_ij_kl(
105                        &deviatoric_isochoric_left_cauchy_green_deformation,
106                        deformation_gradient,
107                    ) * (2.0 / denominator))
108                    * (prefactor / jacobian.powf(TWO_THIRDS))
109                    + CauchyTangentStiffness::dyad_ij_kl(
110                        &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
111                            - deviatoric_isochoric_left_cauchy_green_deformation
112                                * prefactor
113                                * ((5.0
114                                    + 2.0 * isochoric_left_cauchy_green_deformation_trace
115                                        / denominator)
116                                    / 3.0)),
117                        &inverse_transpose_deformation_gradient,
118                    ),
119            )
120        }
121    }
122}
123
124impl<P> Hyperelastic for Gent<P>
125where
126    P: Parameters,
127{
128    #[doc = include_str!("helmholtz_free_energy_density.md")]
129    fn helmholtz_free_energy_density(
130        &self,
131        deformation_gradient: &DeformationGradient,
132    ) -> Result<Scalar, ConstitutiveError> {
133        let jacobian = self.jacobian(deformation_gradient)?;
134        let factor = (deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS)
135            - 3.0)
136            / self.extensibility();
137        if factor >= 1.0 {
138            Err(ConstitutiveError::Custom(
139                "Maximum extensibility reached.".to_string(),
140                deformation_gradient.clone(),
141                format!("{:?}", &self),
142            ))
143        } else {
144            Ok(0.5
145                * (-self.shear_modulus() * self.extensibility() * (1.0 - factor).ln()
146                    + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
147        }
148    }
149}