conspire/constitutive/hybrid/elastic_viscoplastic/additive/viscoplastic/
mod.rs1use crate::{
2 constitutive::{
3 ConstitutiveError,
4 fluid::{
5 plastic::Plastic,
6 viscoplastic::{Viscoplastic, ViscoplasticEvolution, ViscoplasticStateVariables},
7 },
8 hybrid::ElasticViscoplasticAdditiveViscoplastic,
9 solid::elastic_viscoplastic::ElasticViscoplastic,
10 },
11 math::{Differentiable, Quantity, Rank2, Tensor, TensorTuple},
12 mechanics::{MandelStressElastic, Scalar},
13 units::{Rate, Stress},
14};
15
16type GroupedViscoplasticStateVariables<Y1, Y2> = TensorTuple<ViscoplasticStateVariables<Y1>, Y2>;
17type NestedViscoplasticStateVariables<Y1, Y2> =
18 ViscoplasticStateVariables<GroupedViscoplasticStateVariables<Y1, Y2>>;
19type NestedViscoplasticEvolution<Y1, Y2> =
20 ViscoplasticEvolution<GroupedViscoplasticStateVariables<Y1, Y2>>;
21
22impl<C1, C2, Y1, Y2> Plastic for ElasticViscoplasticAdditiveViscoplastic<C1, C2, Y1, Y2>
23where
24 C1: ElasticViscoplastic<Y1>,
25 C2: Viscoplastic<Y2>,
26 Y1: Differentiable + Tensor,
27 Y2: Differentiable + Tensor,
28{
29 fn initial_yield_stress(&self) -> Quantity<Stress> {
30 self.1.initial_yield_stress()
31 }
32 fn hardening_slope(&self) -> Quantity<Stress> {
33 self.1.hardening_slope()
34 }
35}
36
37impl<C1, C2, Y1, Y2> Viscoplastic<GroupedViscoplasticStateVariables<Y1, Y2>>
38 for ElasticViscoplasticAdditiveViscoplastic<C1, C2, Y1, Y2>
39where
40 C1: ElasticViscoplastic<Y1>,
41 C2: Viscoplastic<Y2>,
42 Y1: Differentiable + Tensor,
43 Y2: Differentiable + Tensor,
44{
45 fn initial_state(&self) -> NestedViscoplasticStateVariables<Y1, Y2> {
46 let initial_state_1 = self.0.initial_state();
47 let (deformation_gradient, y_2) = self.1.initial_state().into();
48 (deformation_gradient, (initial_state_1, y_2).into()).into()
49 }
50 fn plastic_evolution(
51 &self,
52 mandel_stress: MandelStressElastic,
53 state_variables: &ViscoplasticStateVariables<GroupedViscoplasticStateVariables<Y1, Y2>>,
54 ) -> Result<NestedViscoplasticEvolution<Y1, Y2>, ConstitutiveError> {
55 let state_variables_1 = &state_variables.1.0;
56 let state_variables_2 = &(state_variables.0.clone(), state_variables.1.1.clone()).into();
57 let deformation_gradient = (&state_variables.0).into();
58 let deformation_gradient_p = &state_variables_1.0;
59 let jacobian = self.0.jacobian(deformation_gradient)?;
60 let deformation_gradient_e = deformation_gradient * deformation_gradient_p.inverse();
61 let cauchy_stress_1 = self
62 .0
63 .cauchy_stress(deformation_gradient, deformation_gradient_p)?;
64 let mandel_stress_1 = (deformation_gradient_e.transpose()
65 * &cauchy_stress_1
66 * deformation_gradient_e.inverse_transpose())
67 * jacobian;
68 let cauchy_stress_2 = mandel_stress - MandelStressElastic::from(cauchy_stress_1);
69 let evolution_1 = self
70 .0
71 .plastic_evolution(mandel_stress_1, state_variables_1)?;
72 let (deformation_gradient_rate, dydt_2) = self
73 .1
74 .plastic_evolution(cauchy_stress_2, state_variables_2)?
75 .into();
76 Ok((deformation_gradient_rate, (evolution_1, dydt_2).into()).into())
77 }
78 fn rate_sensitivity(&self) -> Scalar {
79 self.1.rate_sensitivity()
80 }
81 fn reference_flow_rate(&self) -> Quantity<Rate> {
82 self.1.reference_flow_rate()
83 }
84}