1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//! von Mises (J2) plasticity — perfect, or with linear isotropic hardening.
//!
//! The archetypal metal-plasticity law: yielding depends on the **deviator**
//! alone, so it is insensitive to hydrostatic pressure and plastic flow is
//! isochoric. The yield surface is a cylinder about the hydrostatic axis,
//!
//! ```text
//! f(σ, p) = q − σ_y(p) q = √(3 J₂)
//! ```
//!
//! with `σ_y(p) = σ_y + H·p`. `H = 0` is the perfect law — one code path serves
//! both, which is why they share this file rather than duplicating a return map
//! that differs by a single term.
//!
//! ## The closed-form return
//!
//! Associated flow on a cylinder means the return is **radial**: the deviator
//! is scaled, its direction untouched, and the hydrostatic part is left alone.
//! Consistency gives the multiplier in one step, with no iteration:
//!
//! ```text
//! Δp = (q_trial − σ_y(p_A)) / (3μ + H)
//! ```
//!
//! That closed form is why von Mises does not go through the cutting plane: an
//! exact answer beats a converged one.
use crateResult;
use crate;
/// Radial return onto `q = σ_y + H·p`.
///
/// `hardening` is `H`; pass `0.0` for the perfect law. Returns the updated
/// `(σ, ε_p, p)`, all full 3-D.
///
/// ```
/// # use pyrucast::aggregate::Aggregate;
/// # use pyrucast::atoms::{ElementType, Node};
/// # use pyrucast::containers::element_field::SubElementField;
/// # use pyrucast::containers::finite_element_space::FiniteElementSpace;
/// # use pyrucast::containers::mesh::{Mesh, SubMesh};
/// # use pyrucast::coords::Coords;
/// # use pyrucast::handle::Handle;
/// # use pyrucast::models::plastic::{self, MatParams, PlasticLaw, PrevState};
/// # let coords = Handle::new(Coords::new(2).unwrap());
/// # let n: Vec<Node> = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]
/// # .iter().map(|p| Node::create_in(coords.clone(), p).unwrap()).collect();
/// # let mut sm = SubMesh::new(coords.clone(), ElementType::TRI3);
/// # sm.add_cell(&[n[0].id(), n[1].id(), n[2].id()]).unwrap();
/// # let fes = FiniteElementSpace::lagrange1(&Mesh::from_submesh(sm)).unwrap();
/// # let materiau = SubElementField::from_uniform_per_component(
/// # fes.get(0).unwrap(), vec!["E".into(), "nu".into(), "sigma_y".into()], &[210000.0, 0.3, 250.0]).unwrap();
/// # let mat = MatParams::new(&materiau, 0).unwrap();
/// # let repos = PrevState { eps: [0.0; 6], sigma: [0.0; 6], eps_p: [0.0; 6], p: 0.0,
/// # vars: Vec::new() };
/// // Sans écrouissage (`hardening = 0`), la projection ramène **exactement**
/// // q sur σ_y, et la déformation plastique est purement déviatorique.
/// let trial = [400.0, 0.0, 0.0, 0.0, 0.0, 0.0];
/// let pas = plastic::von_mises::return_map(&trial, &repos, &mat, 0.0)?;
/// assert!((plastic::von_mises_stress(&pas.sigma) - 250.0).abs() < 1e-6);
/// assert!(plastic::i1(&pas.eps_p).abs() < 1e-12); // écoulement isochore
///
/// // Avec écrouissage isotrope, le seuil monte de H·p : la contrainte
/// // retenue est **plus grande**.
/// let dur = plastic::von_mises::return_map(&trial, &repos, &mat, 20_000.0)?;
/// assert!(plastic::von_mises_stress(&dur.sigma) > 250.0);
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```
/// The consistent tangent `D_alg = ∂σ(B)/∂ε(B)` of the radial return, evaluated
/// at the trial stress — the classical algorithmic modulus,
///
/// ```text
/// D = K·1⊗1 + 2μθ·I_dev − 2μθ̄·n̂⊗n̂
/// θ = σ_y(p+Δp)/q_trial θ̄ = 3μ/(3μ + H) − (1 − θ)
/// ```
///
/// with `n̂ = s_trial/‖s_trial‖` the **unit** deviatoric direction. For `H = 0`
/// the two coefficients collapse (`θ̄ = θ`) and this is exactly the perfect-J2
/// tangent — which is why hardening costs one extra term rather than a second
/// derivation.
///
/// Note the difference from the **continuum** elastoplastic modulus: `θ` here
/// accounts for the *finite* step, and dropping it would cost Newton its
/// quadratic convergence.
///
/// ```
/// # use pyrucast::aggregate::Aggregate;
/// # use pyrucast::atoms::{ElementType, Node};
/// # use pyrucast::containers::element_field::SubElementField;
/// # use pyrucast::containers::finite_element_space::FiniteElementSpace;
/// # use pyrucast::containers::mesh::{Mesh, SubMesh};
/// # use pyrucast::coords::Coords;
/// # use pyrucast::handle::Handle;
/// # use pyrucast::models::plastic::{self, MatParams, PlasticLaw, PrevState};
/// # let coords = Handle::new(Coords::new(2).unwrap());
/// # let n: Vec<Node> = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]
/// # .iter().map(|p| Node::create_in(coords.clone(), p).unwrap()).collect();
/// # let mut sm = SubMesh::new(coords.clone(), ElementType::TRI3);
/// # sm.add_cell(&[n[0].id(), n[1].id(), n[2].id()]).unwrap();
/// # let fes = FiniteElementSpace::lagrange1(&Mesh::from_submesh(sm)).unwrap();
/// # let materiau = SubElementField::from_uniform_per_component(
/// # fes.get(0).unwrap(), vec!["E".into(), "nu".into(), "sigma_y".into()], &[210000.0, 0.3, 250.0]).unwrap();
/// # let mat = MatParams::new(&materiau, 0).unwrap();
/// # let repos = PrevState { eps: [0.0; 6], sigma: [0.0; 6], eps_p: [0.0; 6], p: 0.0,
/// # vars: Vec::new() };
/// // Sous le seuil, la tangente cohérente **est** la tangente élastique.
/// let sous = [100.0, 0.0, 0.0, 0.0, 0.0, 0.0];
/// let d = plastic::von_mises::tangent(&sous, &mat, 0.0, 0.0);
/// assert_eq!(d, plastic::elastic_tangent(mat.lambda, mat.mu));
///
/// // Au-delà, elle s'assouplit : le module apparent chute.
/// let au_dela = [400.0, 0.0, 0.0, 0.0, 0.0, 0.0];
/// let dp = plastic::von_mises::tangent(&au_dela, &mat, 0.0, 0.0);
/// assert!(dp[0][0] < d[0][0]);
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```