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

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