conspire/constitutive/solid/hyperelastic/neo_hookean/
mod.rs1#[cfg(test)]
2mod test;
3
4use crate::{
5 constitutive::{
6 Constitutive, ConstitutiveError, Parameters,
7 solid::{FIVE_THIRDS, 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!("model.md")]
14#[derive(Debug)]
15pub struct NeoHookean<P> {
16 parameters: P,
17}
18
19impl<P> Constitutive<P> for NeoHookean<P>
20where
21 P: Parameters,
22{
23 fn new(parameters: P) -> Self {
24 Self { parameters }
25 }
26}
27
28impl<P> Solid for NeoHookean<P>
29where
30 P: Parameters,
31{
32 fn bulk_modulus(&self) -> &Scalar {
33 self.parameters.get(0)
34 }
35 fn shear_modulus(&self) -> &Scalar {
36 self.parameters.get(1)
37 }
38}
39
40impl<P> Elastic for NeoHookean<P>
41where
42 P: Parameters,
43{
44 #[doc = include_str!("cauchy_stress.md")]
45 fn cauchy_stress(
46 &self,
47 deformation_gradient: &DeformationGradient,
48 ) -> Result<CauchyStress, ConstitutiveError> {
49 let jacobian = self.jacobian(deformation_gradient)?;
50 Ok(
51 deformation_gradient.left_cauchy_green().deviatoric() / jacobian.powf(FIVE_THIRDS)
52 * self.shear_modulus()
53 + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian),
54 )
55 }
56 #[doc = include_str!("cauchy_tangent_stiffness.md")]
57 fn cauchy_tangent_stiffness(
58 &self,
59 deformation_gradient: &DeformationGradient,
60 ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
61 let jacobian = self.jacobian(deformation_gradient)?;
62 let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
63 let scaled_shear_modulus = self.shear_modulus() / jacobian.powf(FIVE_THIRDS);
64 Ok(
65 (CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
66 + CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
67 - CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
68 * (TWO_THIRDS))
69 * scaled_shear_modulus
70 + CauchyTangentStiffness::dyad_ij_kl(
71 &(IDENTITY * (0.5 * self.bulk_modulus() * (jacobian + 1.0 / jacobian))
72 - deformation_gradient.left_cauchy_green().deviatoric()
73 * (scaled_shear_modulus * FIVE_THIRDS)),
74 &inverse_transpose_deformation_gradient,
75 ),
76 )
77 }
78}
79
80impl<P> Hyperelastic for NeoHookean<P>
81where
82 P: Parameters,
83{
84 #[doc = include_str!("helmholtz_free_energy_density.md")]
85 fn helmholtz_free_energy_density(
86 &self,
87 deformation_gradient: &DeformationGradient,
88 ) -> Result<Scalar, ConstitutiveError> {
89 let jacobian = self.jacobian(deformation_gradient)?;
90 Ok(0.5
91 * (self.shear_modulus()
92 * (deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS)
93 - 3.0)
94 + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
95 }
96}