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