conspire/constitutive/solid/elastic_plastic/
mod.rs1use crate::{
4 constitutive::{ConstitutiveError, fluid::plastic::Plastic, solid::Solid},
5 math::{ContractFirstSecondWithSecond, ContractSecondWithFirst, IDENTITY, Rank2},
6 mechanics::{
7 CauchyStress, CauchyTangentStiffness, DeformationGradient, DeformationGradientPlastic,
8 FirstPiolaKirchhoffStress, FirstPiolaKirchhoffTangentStiffness, Scalar,
9 SecondPiolaKirchhoffStress, SecondPiolaKirchhoffTangentStiffness,
10 },
11};
12
13pub enum AppliedLoad<'a> {
15 UniaxialStress(fn(Scalar) -> Scalar, &'a [Scalar]),
17 }
20
21pub trait ElasticPlasticOrViscoplastic
23where
24 Self: Solid + Plastic,
25{
26 fn cauchy_stress(
32 &self,
33 deformation_gradient: &DeformationGradient,
34 deformation_gradient_p: &DeformationGradientPlastic,
35 ) -> Result<CauchyStress, ConstitutiveError> {
36 Ok(deformation_gradient
37 * self.second_piola_kirchhoff_stress(deformation_gradient, deformation_gradient_p)?
38 * deformation_gradient.transpose()
39 / deformation_gradient.determinant())
40 }
41 fn cauchy_tangent_stiffness(
47 &self,
48 deformation_gradient: &DeformationGradient,
49 deformation_gradient_p: &DeformationGradientPlastic,
50 ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
51 let deformation_gradient_inverse_transpose = deformation_gradient.inverse_transpose();
52 let cauchy_stress = self.cauchy_stress(deformation_gradient, deformation_gradient_p)?;
53 let some_stress = &cauchy_stress * &deformation_gradient_inverse_transpose;
54 Ok(self
55 .second_piola_kirchhoff_tangent_stiffness(deformation_gradient, deformation_gradient_p)?
56 .contract_first_second_with_second(deformation_gradient, deformation_gradient)
57 / deformation_gradient.determinant()
58 - CauchyTangentStiffness::dyad_ij_kl(
59 &cauchy_stress,
60 &deformation_gradient_inverse_transpose,
61 )
62 + CauchyTangentStiffness::dyad_il_kj(&some_stress, &IDENTITY)
63 + CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, &some_stress))
64 }
65 fn first_piola_kirchhoff_stress(
71 &self,
72 deformation_gradient: &DeformationGradient,
73 deformation_gradient_p: &DeformationGradientPlastic,
74 ) -> Result<FirstPiolaKirchhoffStress, ConstitutiveError> {
75 Ok(
76 self.cauchy_stress(deformation_gradient, deformation_gradient_p)?
77 * deformation_gradient.inverse_transpose()
78 * deformation_gradient.determinant(),
79 )
80 }
81 fn first_piola_kirchhoff_tangent_stiffness(
87 &self,
88 deformation_gradient: &DeformationGradient,
89 deformation_gradient_p: &DeformationGradientPlastic,
90 ) -> Result<FirstPiolaKirchhoffTangentStiffness, ConstitutiveError> {
91 let deformation_gradient_inverse_transpose = deformation_gradient.inverse_transpose();
92 let first_piola_kirchhoff_stress =
93 self.first_piola_kirchhoff_stress(deformation_gradient, deformation_gradient_p)?;
94 Ok(self
95 .cauchy_tangent_stiffness(deformation_gradient, deformation_gradient_p)?
96 .contract_second_with_first(&deformation_gradient_inverse_transpose)
97 * deformation_gradient.determinant()
98 + FirstPiolaKirchhoffTangentStiffness::dyad_ij_kl(
99 &first_piola_kirchhoff_stress,
100 &deformation_gradient_inverse_transpose,
101 )
102 - FirstPiolaKirchhoffTangentStiffness::dyad_il_kj(
103 &first_piola_kirchhoff_stress,
104 &deformation_gradient_inverse_transpose,
105 ))
106 }
107 fn second_piola_kirchhoff_stress(
113 &self,
114 deformation_gradient: &DeformationGradient,
115 deformation_gradient_p: &DeformationGradientPlastic,
116 ) -> Result<SecondPiolaKirchhoffStress, ConstitutiveError> {
117 Ok(deformation_gradient.inverse()
118 * self.first_piola_kirchhoff_stress(deformation_gradient, deformation_gradient_p)?)
119 }
120 fn second_piola_kirchhoff_tangent_stiffness(
126 &self,
127 deformation_gradient: &DeformationGradient,
128 deformation_gradient_p: &DeformationGradientPlastic,
129 ) -> Result<SecondPiolaKirchhoffTangentStiffness, ConstitutiveError> {
130 let deformation_gradient_inverse_transpose = deformation_gradient.inverse_transpose();
131 let deformation_gradient_inverse = deformation_gradient_inverse_transpose.transpose();
132 let second_piola_kirchhoff_stress =
133 self.second_piola_kirchhoff_stress(deformation_gradient, deformation_gradient_p)?;
134 Ok(self
135 .cauchy_tangent_stiffness(deformation_gradient, deformation_gradient_p)?
136 .contract_first_second_with_second(
137 &deformation_gradient_inverse,
138 &deformation_gradient_inverse,
139 )
140 * deformation_gradient.determinant()
141 + SecondPiolaKirchhoffTangentStiffness::dyad_ij_kl(
142 &second_piola_kirchhoff_stress,
143 &deformation_gradient_inverse_transpose,
144 )
145 - SecondPiolaKirchhoffTangentStiffness::dyad_il_kj(
146 &second_piola_kirchhoff_stress,
147 &deformation_gradient_inverse_transpose,
148 )
149 - SecondPiolaKirchhoffTangentStiffness::dyad_ik_jl(
150 &deformation_gradient_inverse,
151 &second_piola_kirchhoff_stress,
152 ))
153 }
154}
155
156pub trait ElasticPlastic
158where
159 Self: ElasticPlasticOrViscoplastic,
160{
161}