conspire/constitutive/solid/hyperelastic/neo_hookean/
mod.rs1#[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},
11 units::{EnergyDensity, Stress},
12};
13
14#[doc = include_str!("doc.md")]
15#[derive(Clone, Debug)]
16pub struct NeoHookean {
17 pub bulk_modulus: Quantity<Stress>,
19 pub shear_modulus: Quantity<Stress>,
21}
22
23impl Solid for NeoHookean {
24 fn bulk_modulus(&self) -> Quantity<Stress> {
25 self.bulk_modulus
26 }
27 fn shear_modulus(&self) -> Quantity<Stress> {
28 self.shear_modulus
29 }
30}
31
32impl Elastic for NeoHookean {
33 #[doc = include_str!("cauchy_stress.md")]
34 fn cauchy_stress(
35 &self,
36 deformation_gradient: &DeformationGradient,
37 ) -> Result<CauchyStress, ConstitutiveError> {
38 let jacobian = self.jacobian(deformation_gradient)?;
39 Ok(
40 deformation_gradient.left_cauchy_green().deviatoric() / jacobian.powf(FIVE_THIRDS)
41 * self.shear_modulus()
42 + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian),
43 )
44 }
45 #[doc = include_str!("cauchy_tangent_stiffness.md")]
46 fn cauchy_tangent_stiffness(
47 &self,
48 deformation_gradient: &DeformationGradient,
49 ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
50 let jacobian = self.jacobian(deformation_gradient)?;
51 let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
52 let scaled_shear_modulus = self.shear_modulus() / jacobian.powf(FIVE_THIRDS);
53 Ok((TensorRank4::dyad_ik_jl(&IDENTITY, deformation_gradient)
54 + TensorRank4::dyad_il_jk(deformation_gradient, &IDENTITY)
55 - TensorRank4::dyad_ij_kl(&IDENTITY, deformation_gradient) * (TWO_THIRDS))
56 * scaled_shear_modulus
57 + TensorRank4::dyad_ij_kl(
58 &(IDENTITY * (self.bulk_modulus() * 0.5 * (jacobian + 1.0 / jacobian))
59 - deformation_gradient.left_cauchy_green().deviatoric()
60 * (scaled_shear_modulus * FIVE_THIRDS)),
61 &inverse_transpose_deformation_gradient,
62 ))
63 }
64}
65
66impl Hyperelastic for NeoHookean {
67 #[doc = include_str!("helmholtz_free_energy_density.md")]
68 fn helmholtz_free_energy_density(
69 &self,
70 deformation_gradient: &DeformationGradient,
71 ) -> Result<Quantity<EnergyDensity>, ConstitutiveError> {
72 let jacobian = self.jacobian(deformation_gradient)?;
73 Ok(0.5
74 * (self.shear_modulus()
75 * (deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS)
76 - 3.0)
77 + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
78 }
79}