conspire/constitutive/solid/hyperelastic/mooney_rivlin/
mod.rs1#[cfg(test)]
2mod test;
3
4use super::*;
5
6#[doc = include_str!("model.md")]
7#[derive(Debug)]
8pub struct MooneyRivlin<P> {
9 parameters: P,
10}
11
12impl<P> MooneyRivlin<P>
13where
14 P: Parameters,
15{
16 pub fn extra_modulus(&self) -> &Scalar {
18 self.parameters.get(2)
19 }
20}
21
22impl<P> Constitutive<P> for MooneyRivlin<P>
23where
24 P: Parameters,
25{
26 fn new(parameters: P) -> Self {
27 Self { parameters }
28 }
29}
30
31impl<P> Solid for MooneyRivlin<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 MooneyRivlin<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 Ok(((isochoric_left_cauchy_green_deformation.deviatoric()
56 * (self.shear_modulus() - self.extra_modulus())
57 - isochoric_left_cauchy_green_deformation
58 .inverse()
59 .deviatoric()
60 * self.extra_modulus())
61 + IDENTITY * (self.bulk_modulus() * 0.5 * (jacobian.powi(2) - 1.0)))
62 / jacobian)
63 }
64 #[doc = include_str!("cauchy_tangent_stiffness.md")]
65 fn cauchy_tangent_stiffness(
66 &self,
67 deformation_gradient: &DeformationGradient,
68 ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
69 let jacobian = self.jacobian(deformation_gradient)?;
70 let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
71 let scaled_delta_shear_modulus =
72 (self.shear_modulus() - self.extra_modulus()) / jacobian.powf(FIVE_THIRDS);
73 let inverse_isochoric_left_cauchy_green_deformation =
74 (deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS)).inverse();
75 let deviatoric_inverse_isochoric_left_cauchy_green_deformation =
76 inverse_isochoric_left_cauchy_green_deformation.deviatoric();
77 let term_1 = CauchyTangentStiffness::dyad_ij_kl(
78 &inverse_isochoric_left_cauchy_green_deformation,
79 &inverse_transpose_deformation_gradient,
80 ) * TWO_THIRDS
81 - CauchyTangentStiffness::dyad_ik_jl(
82 &inverse_isochoric_left_cauchy_green_deformation,
83 &inverse_transpose_deformation_gradient,
84 )
85 - CauchyTangentStiffness::dyad_il_jk(
86 &inverse_transpose_deformation_gradient,
87 &inverse_isochoric_left_cauchy_green_deformation,
88 );
89 let term_3 = CauchyTangentStiffness::dyad_ij_kl(
90 &deviatoric_inverse_isochoric_left_cauchy_green_deformation,
91 &inverse_transpose_deformation_gradient,
92 );
93 let term_2 = CauchyTangentStiffness::dyad_ij_kl(
94 &IDENTITY,
95 &((deviatoric_inverse_isochoric_left_cauchy_green_deformation * TWO_THIRDS)
96 * &inverse_transpose_deformation_gradient),
97 );
98 Ok(
99 (CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
100 + CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
101 - CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
102 * (TWO_THIRDS))
103 * scaled_delta_shear_modulus
104 + CauchyTangentStiffness::dyad_ij_kl(
105 &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
106 - deformation_gradient.left_cauchy_green().deviatoric()
107 * (scaled_delta_shear_modulus * FIVE_THIRDS)),
108 &inverse_transpose_deformation_gradient,
109 )
110 - (term_1 + term_2 - term_3) * self.extra_modulus() / jacobian,
111 )
112 }
113}
114
115impl<P> Hyperelastic for MooneyRivlin<P>
116where
117 P: Parameters,
118{
119 #[doc = include_str!("helmholtz_free_energy_density.md")]
120 fn helmholtz_free_energy_density(
121 &self,
122 deformation_gradient: &DeformationGradient,
123 ) -> Result<Scalar, ConstitutiveError> {
124 let jacobian = self.jacobian(deformation_gradient)?;
125 let isochoric_left_cauchy_green_deformation =
126 deformation_gradient.left_cauchy_green() / jacobian.powf(TWO_THIRDS);
127 Ok(0.5
128 * ((self.shear_modulus() - self.extra_modulus())
129 * (isochoric_left_cauchy_green_deformation.trace() - 3.0)
130 + self.extra_modulus()
131 * (isochoric_left_cauchy_green_deformation.second_invariant() - 3.0)
132 + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
133 }
134}