conspire/constitutive/solid/elastic/hencky/
mod.rs1#[cfg(test)]
2mod test;
3
4use crate::{
5 constitutive::{
6 Constitutive, ConstitutiveError, Parameters,
7 solid::{Solid, TWO_THIRDS, elastic::Elastic},
8 },
9 math::{ContractThirdFourthIndicesWithFirstSecondIndicesOf, IDENTITY_00, Rank2},
10 mechanics::{
11 Deformation, DeformationGradient, Scalar, SecondPiolaKirchhoffStress,
12 SecondPiolaKirchhoffTangentStiffness,
13 },
14};
15
16#[doc = include_str!("doc.md")]
17#[derive(Debug)]
18pub struct Hencky<P> {
19 parameters: P,
20}
21
22impl<P> Constitutive<P> for Hencky<P>
23where
24 P: Parameters,
25{
26 fn new(parameters: P) -> Self {
27 Self { parameters }
28 }
29}
30
31impl<P> Solid for Hencky<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 Hencky<P>
44where
45 P: Parameters,
46{
47 #[doc = include_str!("second_piola_kirchhoff_stress.md")]
48 fn second_piola_kirchhoff_stress(
49 &self,
50 deformation_gradient: &DeformationGradient,
51 ) -> Result<SecondPiolaKirchhoffStress, ConstitutiveError> {
52 let _jacobian = self.jacobian(deformation_gradient)?;
53 let (deviatoric_strain, strain_trace) =
54 (deformation_gradient.right_cauchy_green().logm() * 0.5).deviatoric_and_trace();
55 Ok(deviatoric_strain * (2.0 * self.shear_modulus())
56 + IDENTITY_00 * (self.bulk_modulus() * strain_trace))
57 }
58 #[doc = include_str!("second_piola_kirchhoff_tangent_stiffness.md")]
59 fn second_piola_kirchhoff_tangent_stiffness(
60 &self,
61 deformation_gradient: &DeformationGradient,
62 ) -> Result<SecondPiolaKirchhoffTangentStiffness, ConstitutiveError> {
63 let _jacobian = self.jacobian(deformation_gradient)?;
64 let right_cauchy_green = deformation_gradient.right_cauchy_green();
65 let deformation_gradient_transpose = deformation_gradient.transpose();
66 let scaled_deformation_gradient_transpose =
67 &deformation_gradient_transpose * self.shear_modulus();
68 Ok((right_cauchy_green
69 .dlogm()
70 .contract_third_fourth_indices_with_first_second_indices_of(
71 &(SecondPiolaKirchhoffTangentStiffness::dyad_il_jk(
72 &IDENTITY_00,
73 &scaled_deformation_gradient_transpose,
74 ) + SecondPiolaKirchhoffTangentStiffness::dyad_ik_jl(
75 &scaled_deformation_gradient_transpose,
76 &IDENTITY_00,
77 )),
78 ))
79 + (SecondPiolaKirchhoffTangentStiffness::dyad_ij_kl(
80 &(IDENTITY_00 * (self.bulk_modulus() - TWO_THIRDS * self.shear_modulus())),
81 &deformation_gradient_transpose.inverse(),
82 )))
83 }
84}