Skip to main content

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

1#[cfg(test)]
2mod test;
3
4use crate::{
5    constitutive::{
6        ConstitutiveError,
7        solid::{FIVE_THIRDS, Solid, TWO_THIRDS, elastic::Elastic, hyperelastic::Hyperelastic},
8    },
9    math::{IDENTITY, Quantity, Rank2, TensorRank4},
10    mechanics::{CauchyStress, CauchyTangentStiffness, Deformation, DeformationGradient, Scalar},
11    units::{EnergyDensity, Stress},
12};
13
14#[doc = include_str!("doc.md")]
15#[derive(Clone, Debug)]
16pub struct Fung {
17    /// The bulk modulus $`\kappa`$.
18    pub bulk_modulus: Quantity<Stress>,
19    /// The shear modulus $`\mu`$.
20    pub shear_modulus: Quantity<Stress>,
21    /// The extra modulus $`\mu_m`$.
22    pub extra_modulus: Quantity<Stress>,
23    /// The exponent $`c`$.
24    pub exponent: Scalar,
25}
26
27impl Fung {
28    /// Returns the extra modulus.
29    pub fn extra_modulus(&self) -> Quantity<Stress> {
30        self.extra_modulus
31    }
32    /// Returns the exponent.
33    pub fn exponent(&self) -> Scalar {
34        self.exponent
35    }
36}
37
38impl Solid for Fung {
39    fn bulk_modulus(&self) -> Quantity<Stress> {
40        self.bulk_modulus
41    }
42    fn shear_modulus(&self) -> Quantity<Stress> {
43        self.shear_modulus
44    }
45}
46
47impl Elastic for Fung {
48    #[doc = include_str!("cauchy_stress.md")]
49    fn cauchy_stress(
50        &self,
51        deformation_gradient: &DeformationGradient,
52    ) -> Result<CauchyStress, ConstitutiveError> {
53        let jacobian = self.jacobian(deformation_gradient)?;
54        let isochoric_left_cauchy_green_deformation =
55            deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS);
56        let (
57            deviatoric_isochoric_left_cauchy_green_deformation,
58            isochoric_left_cauchy_green_deformation_trace,
59        ) = isochoric_left_cauchy_green_deformation.deviatoric_and_trace();
60        Ok(deviatoric_isochoric_left_cauchy_green_deformation
61            * ((self.shear_modulus()
62                + self.extra_modulus()
63                    * ((self.exponent() * (isochoric_left_cauchy_green_deformation_trace - 3.0))
64                        .exp()
65                        - 1.0))
66                / jacobian)
67            + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian))
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 exponential =
83            (self.exponent() * (isochoric_left_cauchy_green_deformation_trace - 3.0)).exp();
84        let scaled_shear_modulus_0 = (self.shear_modulus()
85            + self.extra_modulus() * (exponential - 1.0))
86            / jacobian.powf(FIVE_THIRDS);
87        Ok((TensorRank4::dyad_ik_jl(&IDENTITY, deformation_gradient)
88            + TensorRank4::dyad_il_jk(deformation_gradient, &IDENTITY)
89            - TensorRank4::dyad_ij_kl(&IDENTITY, deformation_gradient) * (TWO_THIRDS))
90            * scaled_shear_modulus_0
91            + TensorRank4::dyad_ij_kl(
92                &deviatoric_isochoric_left_cauchy_green_deformation,
93                &((&deviatoric_isochoric_left_cauchy_green_deformation
94                    * &inverse_transpose_deformation_gradient)
95                    * (2.0 * self.exponent() * self.extra_modulus() * exponential / jacobian)),
96            )
97            + TensorRank4::dyad_ij_kl(
98                &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
99                    - deformation_gradient.left_cauchy_green().deviatoric()
100                        * (scaled_shear_modulus_0 * FIVE_THIRDS)),
101                &inverse_transpose_deformation_gradient,
102            ))
103    }
104}
105
106impl Hyperelastic for Fung {
107    #[doc = include_str!("helmholtz_free_energy_density.md")]
108    fn helmholtz_free_energy_density(
109        &self,
110        deformation_gradient: &DeformationGradient,
111    ) -> Result<Quantity<EnergyDensity>, ConstitutiveError> {
112        let jacobian = self.jacobian(deformation_gradient)?;
113        let scalar_term =
114            deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS) - 3.0;
115        Ok(0.5
116            * ((self.shear_modulus() - self.extra_modulus()) * scalar_term
117                + self.extra_modulus() / self.exponent()
118                    * ((self.exponent() * scalar_term).exp() - 1.0)
119                + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
120    }
121}