conspire/constitutive/solid/hyperelastic/hencky/
mod.rs1#[cfg(test)]
2mod test;
3
4use crate::{
5 constitutive::{
6 Constitutive, ConstitutiveError, Parameters,
7 solid::{Solid, TWO_THIRDS, elastic::Elastic, hyperelastic::Hyperelastic},
8 },
9 math::{ContractThirdFourthIndicesWithFirstSecondIndicesOf, IDENTITY, Rank2},
10 mechanics::{CauchyStress, CauchyTangentStiffness, Deformation, DeformationGradient, Scalar},
11};
12
13#[doc = include_str!("doc.md")]
14#[derive(Debug)]
15pub struct Hencky<P> {
16 parameters: P,
17}
18
19impl<P> Constitutive<P> for Hencky<P>
20where
21 P: Parameters,
22{
23 fn new(parameters: P) -> Self {
24 Self { parameters }
25 }
26}
27
28impl<P> Solid for Hencky<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 Hencky<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 let (deviatoric_strain, strain_trace) =
51 (deformation_gradient.left_cauchy_green().logm() * 0.5).deviatoric_and_trace();
52 Ok(deviatoric_strain * (2.0 * self.shear_modulus() / jacobian)
53 + IDENTITY * (self.bulk_modulus() * strain_trace / jacobian))
54 }
55 #[doc = include_str!("cauchy_tangent_stiffness.md")]
56 fn cauchy_tangent_stiffness(
57 &self,
58 deformation_gradient: &DeformationGradient,
59 ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
60 let jacobian = self.jacobian(deformation_gradient)?;
61 let left_cauchy_green = deformation_gradient.left_cauchy_green();
62 let (deviatoric_strain, strain_trace) =
63 (left_cauchy_green.logm() * 0.5).deviatoric_and_trace();
64 let scaled_deformation_gradient = deformation_gradient * self.shear_modulus() / jacobian;
65 Ok((left_cauchy_green
66 .dlogm()
67 .contract_third_fourth_indices_with_first_second_indices_of(
68 &(CauchyTangentStiffness::dyad_il_jk(&scaled_deformation_gradient, &IDENTITY)
69 + CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, &scaled_deformation_gradient)),
70 ))
71 + (CauchyTangentStiffness::dyad_ij_kl(
72 &(IDENTITY
73 * ((self.bulk_modulus() - TWO_THIRDS * self.shear_modulus()) / jacobian)
74 - deviatoric_strain * (2.0 * self.shear_modulus() / jacobian)
75 - IDENTITY * (self.bulk_modulus() * strain_trace / jacobian)),
76 &deformation_gradient.inverse_transpose(),
77 )))
78 }
79}
80
81impl<P> Hyperelastic for Hencky<P>
82where
83 P: Parameters,
84{
85 #[doc = include_str!("helmholtz_free_energy_density.md")]
86 fn helmholtz_free_energy_density(
87 &self,
88 deformation_gradient: &DeformationGradient,
89 ) -> Result<Scalar, ConstitutiveError> {
90 let _jacobian = self.jacobian(deformation_gradient)?;
91 let strain = deformation_gradient.left_cauchy_green().logm() * 0.5;
92 Ok(self.shear_modulus() * strain.squared_trace()
93 + 0.5
94 * (self.bulk_modulus() - TWO_THIRDS * self.shear_modulus())
95 * strain.trace().powi(2))
96 }
97}