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

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