conspire/constitutive/solid/hyperelastic/yeoh/
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, Scalar},
11 units::{EnergyDensity, Modulus, Stress},
12};
13
14const SEVEN_THIRDS: Scalar = 7.0 / 3.0;
15
16#[doc = include_str!("doc.md")]
17#[derive(Clone, Debug)]
18pub struct Yeoh {
19 pub bulk_modulus: Quantity<Stress>,
21 pub shear_moduli: Vec<Quantity<Modulus>>,
23}
24
25impl Solid for Yeoh {
26 fn bulk_modulus(&self) -> Quantity<Stress> {
27 self.bulk_modulus
28 }
29 fn shear_modulus(&self) -> Quantity<Stress> {
30 self.shear_moduli.first().copied().unwrap_or_default()
31 }
32}
33
34impl Elastic for Yeoh {
35 #[doc = include_str!("cauchy_stress.md")]
36 fn cauchy_stress(
37 &self,
38 deformation_gradient: &DeformationGradient,
39 ) -> Result<CauchyStress, ConstitutiveError> {
40 let jacobian = self.jacobian(deformation_gradient)?;
41 let (deviatoric_left_cauchy_green_deformation, left_cauchy_green_deformation_trace) =
42 deformation_gradient
43 .left_cauchy_green()
44 .deviatoric_and_trace();
45 let scalar_term = left_cauchy_green_deformation_trace / jacobian.powf(TWO_THIRDS) - 3.0;
46 Ok(deviatoric_left_cauchy_green_deformation
47 * self
48 .shear_moduli
49 .iter()
50 .enumerate()
51 .map(|(n, &modulus)| modulus * (((n as Scalar) + 1.0) * scalar_term.powi(n as i32)))
52 .sum::<Quantity<Modulus>>()
53 / jacobian.powf(FIVE_THIRDS)
54 + IDENTITY * self.bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian))
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 left_cauchy_green_deformation = deformation_gradient.left_cauchy_green();
64 let scalar_term = left_cauchy_green_deformation.trace() / jacobian.powf(TWO_THIRDS) - 3.0;
65 let scaled_modulus = self
66 .shear_moduli
67 .iter()
68 .enumerate()
69 .map(|(n, &modulus)| modulus * (((n as Scalar) + 1.0) * scalar_term.powi(n as i32)))
70 .sum::<Quantity<Modulus>>()
71 / jacobian.powf(FIVE_THIRDS);
72 let deviatoric_left_cauchy_green_deformation = left_cauchy_green_deformation.deviatoric();
73 let last_term = TensorRank4::dyad_ij_kl(
74 &deviatoric_left_cauchy_green_deformation,
75 &((left_cauchy_green_deformation.deviatoric()
76 * &inverse_transpose_deformation_gradient)
77 * (self
78 .shear_moduli
79 .iter()
80 .enumerate()
81 .skip(1)
82 .map(|(n, &modulus)| {
83 modulus
84 * (2.0
85 * ((n as Scalar) + 1.0)
86 * (n as Scalar)
87 * scalar_term.powi(n as i32 - 1))
88 })
89 .sum::<Quantity<Modulus>>()
90 / jacobian.powf(SEVEN_THIRDS))),
91 );
92 Ok((TensorRank4::dyad_ik_jl(&IDENTITY, deformation_gradient)
93 + TensorRank4::dyad_il_jk(deformation_gradient, &IDENTITY)
94 - TensorRank4::dyad_ij_kl(&IDENTITY, deformation_gradient) * (TWO_THIRDS))
95 * scaled_modulus
96 + TensorRank4::dyad_ij_kl(
97 &(IDENTITY * (self.bulk_modulus() * 0.5 * (jacobian + 1.0 / jacobian))
98 - deviatoric_left_cauchy_green_deformation * (scaled_modulus * FIVE_THIRDS)),
99 &inverse_transpose_deformation_gradient,
100 )
101 + last_term)
102 }
103}
104
105impl Hyperelastic for Yeoh {
106 #[doc = include_str!("helmholtz_free_energy_density.md")]
107 fn helmholtz_free_energy_density(
108 &self,
109 deformation_gradient: &DeformationGradient,
110 ) -> Result<Quantity<EnergyDensity>, ConstitutiveError> {
111 let jacobian = self.jacobian(deformation_gradient)?;
112 let scalar_term =
113 deformation_gradient.left_cauchy_green().trace() / jacobian.powf(TWO_THIRDS) - 3.0;
114 Ok(0.5
115 * (self
116 .shear_moduli
117 .iter()
118 .enumerate()
119 .map(|(n, &modulus)| modulus * scalar_term.powi((n + 1) as i32))
120 .sum::<Quantity<Modulus>>()
121 + self.bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
122 }
123}