conspire/constitutive/hybrid/elastic/additive/
mod.rs

1#[cfg(test)]
2mod test;
3
4use crate::{
5    constitutive::{
6        ConstitutiveError,
7        hybrid::Additive,
8        solid::{Solid, elastic::Elastic},
9    },
10    mechanics::{
11        CauchyStress, CauchyTangentStiffness, DeformationGradient, FirstPiolaKirchhoffStress,
12        FirstPiolaKirchhoffTangentStiffness, Scalar, SecondPiolaKirchhoffStress,
13        SecondPiolaKirchhoffTangentStiffness,
14    },
15};
16
17impl<C1, C2> Solid for Additive<C1, C2>
18where
19    C1: Elastic,
20    C2: Elastic,
21{
22    fn bulk_modulus(&self) -> Scalar {
23        self.0.bulk_modulus() + self.1.bulk_modulus()
24    }
25    fn shear_modulus(&self) -> Scalar {
26        self.0.shear_modulus() + self.1.shear_modulus()
27    }
28}
29
30impl<C1, C2> Elastic for Additive<C1, C2>
31where
32    C1: Elastic,
33    C2: Elastic,
34{
35    /// Calculates and returns the Cauchy stress.
36    ///
37    /// ```math
38    /// \boldsymbol{\sigma}(\mathbf{F}) = \boldsymbol{\sigma}_1(\mathbf{F}) + \boldsymbol{\sigma}_2(\mathbf{F})
39    /// ```
40    fn cauchy_stress(
41        &self,
42        deformation_gradient: &DeformationGradient,
43    ) -> Result<CauchyStress, ConstitutiveError> {
44        Ok(self.0.cauchy_stress(deformation_gradient)?
45            + self.1.cauchy_stress(deformation_gradient)?)
46    }
47    /// Calculates and returns the tangent stiffness associated with the Cauchy stress.
48    ///
49    /// ```math
50    /// \mathcal{T}(\mathbf{F}) = \mathcal{T}_1(\mathbf{F}) + \mathcal{T}_2(\mathbf{F})
51    /// ```
52    fn cauchy_tangent_stiffness(
53        &self,
54        deformation_gradient: &DeformationGradient,
55    ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
56        Ok(self.0.cauchy_tangent_stiffness(deformation_gradient)?
57            + self.1.cauchy_tangent_stiffness(deformation_gradient)?)
58    }
59    /// Calculates and returns the first Piola-Kirchhoff stress.
60    ///
61    /// ```math
62    /// \mathbf{P}(\mathbf{F}) = \mathbf{P}_1(\mathbf{F}) + \mathbf{P}_2(\mathbf{F})
63    /// ```
64    fn first_piola_kirchhoff_stress(
65        &self,
66        deformation_gradient: &DeformationGradient,
67    ) -> Result<FirstPiolaKirchhoffStress, ConstitutiveError> {
68        Ok(self.0.first_piola_kirchhoff_stress(deformation_gradient)?
69            + self.1.first_piola_kirchhoff_stress(deformation_gradient)?)
70    }
71    /// Calculates and returns the tangent stiffness associated with the first Piola-Kirchhoff stress.
72    ///
73    /// ```math
74    /// \mathcal{C}(\mathbf{F}) = \mathcal{C}_1(\mathbf{F}) + \mathcal{C}_2(\mathbf{F})
75    /// ```
76    fn first_piola_kirchhoff_tangent_stiffness(
77        &self,
78        deformation_gradient: &DeformationGradient,
79    ) -> Result<FirstPiolaKirchhoffTangentStiffness, ConstitutiveError> {
80        Ok(self
81            .0
82            .first_piola_kirchhoff_tangent_stiffness(deformation_gradient)?
83            + self
84                .1
85                .first_piola_kirchhoff_tangent_stiffness(deformation_gradient)?)
86    }
87    /// Calculates and returns the second Piola-Kirchhoff stress.
88    ///
89    /// ```math
90    /// \mathbf{S}(\mathbf{F}) = \mathbf{S}_1(\mathbf{F}) + \mathbf{S}_2(\mathbf{F})
91    /// ```
92    fn second_piola_kirchhoff_stress(
93        &self,
94        deformation_gradient: &DeformationGradient,
95    ) -> Result<SecondPiolaKirchhoffStress, ConstitutiveError> {
96        Ok(self.0.second_piola_kirchhoff_stress(deformation_gradient)?
97            + self.1.second_piola_kirchhoff_stress(deformation_gradient)?)
98    }
99    /// Calculates and returns the tangent stiffness associated with the second Piola-Kirchhoff stress.
100    ///
101    /// ```math
102    /// \mathcal{G}(\mathbf{F}) = \mathcal{G}_1(\mathbf{F}) + \mathcal{G}_2(\mathbf{F})
103    /// ```
104    fn second_piola_kirchhoff_tangent_stiffness(
105        &self,
106        deformation_gradient: &DeformationGradient,
107    ) -> Result<SecondPiolaKirchhoffTangentStiffness, ConstitutiveError> {
108        Ok(self
109            .0
110            .second_piola_kirchhoff_tangent_stiffness(deformation_gradient)?
111            + self
112                .1
113                .second_piola_kirchhoff_tangent_stiffness(deformation_gradient)?)
114    }
115}