conspire/constitutive/solid/elastic/seth_hill_eulerian/
mod.rs1#[cfg(test)]
2mod test;
3
4use crate::{
5 constitutive::{
6 ConstitutiveError,
7 solid::{Solid, TWO_THIRDS, elastic::Elastic},
8 },
9 math::{ContractThirdFourthWithFirstSecond, IDENTITY, Quantity, Rank2, Spectrum, TensorRank4},
10 mechanics::{CauchyStress, CauchyTangentStiffness, Deformation, DeformationGradient, Scalar},
11 units::Stress,
12};
13
14#[doc = include_str!("doc.md")]
15#[derive(Clone, Debug)]
16pub struct SethHillEulerian {
17 pub bulk_modulus: Quantity<Stress>,
19 pub shear_modulus: Quantity<Stress>,
21 pub exponent: Scalar,
23}
24
25impl SethHillEulerian {
26 pub fn exponent(&self) -> Scalar {
28 self.exponent
29 }
30}
31
32impl Solid for SethHillEulerian {
33 fn bulk_modulus(&self) -> Quantity<Stress> {
34 self.bulk_modulus
35 }
36 fn shear_modulus(&self) -> Quantity<Stress> {
37 self.shear_modulus
38 }
39}
40
41impl Elastic for SethHillEulerian {
42 #[doc = include_str!("cauchy_stress.md")]
43 fn cauchy_stress(
44 &self,
45 deformation_gradient: &DeformationGradient,
46 ) -> Result<CauchyStress, ConstitutiveError> {
47 let jacobian = self.jacobian(deformation_gradient)?;
48 let left_cauchy_green = deformation_gradient.left_cauchy_green();
49 let (deviatoric_strain, strain_trace) = if self.exponent() == 0.0 {
50 (left_cauchy_green
51 .logm()
52 .map_err(|error| ConstitutiveError::upstream(error, self))?
53 * 0.5)
54 .deviatoric_and_trace()
55 } else {
56 ((left_cauchy_green
57 .powm(0.5 * self.exponent())
58 .map_err(|error| ConstitutiveError::upstream(error, self))?
59 - IDENTITY)
60 / self.exponent())
61 .deviatoric_and_trace()
62 };
63 Ok(deviatoric_strain * (2.0 * self.shear_modulus() / jacobian)
64 + IDENTITY * (self.bulk_modulus() * strain_trace / jacobian))
65 }
66 #[doc = include_str!("cauchy_tangent_stiffness.md")]
67 fn cauchy_tangent_stiffness(
68 &self,
69 deformation_gradient: &DeformationGradient,
70 ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
71 let jacobian = self.jacobian(deformation_gradient)?;
72 let left_cauchy_green = deformation_gradient.left_cauchy_green();
73 let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
74 if self.exponent() == 0.0 {
75 let (deviatoric_strain, strain_trace) = (left_cauchy_green
76 .logm()
77 .map_err(|error| ConstitutiveError::upstream(error, self))?
78 * 0.5)
79 .deviatoric_and_trace();
80 let scaled_deformation_gradient =
81 deformation_gradient * (self.shear_modulus() / jacobian);
82 return Ok((left_cauchy_green
83 .dlogm()
84 .map_err(|error| ConstitutiveError::upstream(error, self))?
85 .contract_third_fourth_with_first_second(
86 &(TensorRank4::dyad_il_jk(&scaled_deformation_gradient, &IDENTITY)
87 + TensorRank4::dyad_ik_jl(&IDENTITY, &scaled_deformation_gradient)),
88 ))
89 + TensorRank4::dyad_ij_kl(
90 &(IDENTITY
91 * ((self.bulk_modulus() - TWO_THIRDS * self.shear_modulus()) / jacobian)
92 - deviatoric_strain * (2.0 * self.shear_modulus() / jacobian)
93 - IDENTITY * (self.bulk_modulus() * strain_trace / jacobian)),
94 &inverse_transpose_deformation_gradient,
95 ));
96 }
97 let half_exponent = 0.5 * self.exponent();
98 let spectrum = Spectrum::new(&left_cauchy_green)
99 .map_err(|error| ConstitutiveError::upstream(error, self))?;
100 let (deviatoric_strain, strain_trace) = ((spectrum
101 .powm(half_exponent)
102 .map_err(|error| ConstitutiveError::upstream(error, self))?
103 - IDENTITY)
104 / self.exponent())
105 .deviatoric_and_trace();
106 let cauchy_stress = deviatoric_strain * (2.0 * self.shear_modulus() / jacobian)
107 + IDENTITY * (self.bulk_modulus() * strain_trace / jacobian);
108 let scaled_deformation_gradient =
109 deformation_gradient * (2.0 * self.shear_modulus() / (self.exponent() * jacobian));
110 let trace_term = spectrum
111 .powm(half_exponent - 1.0)
112 .map_err(|error| ConstitutiveError::upstream(error, self))?
113 * deformation_gradient;
114 Ok(spectrum
115 .dpowm(half_exponent)
116 .map_err(|error| ConstitutiveError::upstream(error, self))?
117 .contract_third_fourth_with_first_second(
118 &(TensorRank4::dyad_il_jk(&scaled_deformation_gradient, &IDENTITY)
119 + TensorRank4::dyad_ik_jl(&IDENTITY, &scaled_deformation_gradient)),
120 )
121 + TensorRank4::dyad_ij_kl(
122 &(IDENTITY
123 * ((self.bulk_modulus() - TWO_THIRDS * self.shear_modulus()) / jacobian)),
124 &trace_term,
125 )
126 - TensorRank4::dyad_ij_kl(&cauchy_stress, &inverse_transpose_deformation_gradient))
127 }
128}