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
203
204
205
206
207
208
//! Ottosen's four-parameter criterion — concrete.
//!
//! Concrete fails very differently in tension and in compression, and its
//! strength under a given pressure depends on **which** deviatoric direction the
//! stress points in. Neither von Mises (blind to pressure) nor Drucker-Prager
//! (blind to that direction) captures it. Ottosen's surface does, through a
//! dependence on the **Lode angle**:
//!
//! ```text
//! f(σ) = a·J₂/σ_c² + λ(θ)·√J₂/σ_c + b·I₁/σ_c − 1
//! ```
//!
//! ```text
//! λ(θ) = k₁·cos[⅓ arccos(k₂ cos3θ)] if cos3θ ≥ 0
//! λ(θ) = k₁·cos[π/3 − ⅓ arccos(−k₂ cos3θ)] if cos3θ < 0
//! ```
//!
//! with `cos3θ = (3√3/2)·J₃/J₂^{3/2}`. The four parameters `a`, `b`, `k₁`, `k₂`
//! are fitted to the uniaxial tensile and compressive strengths, the biaxial
//! compressive strength and one triaxial point; `σ_c` is the compressive
//! strength that scales the whole surface.
//!
//! The meridians are **curved** (the `J₂` term) and the deviatoric section is a
//! smooth rounded triangle that opens out towards compression — which is the
//! whole point.
//!
//! ## Integrated by cutting plane, with a numerical normal
//!
//! There is no usable closed-form return onto this surface. Worse, the normal
//! `∂f/∂σ` requires differentiating `λ(θ)` through `arccos` and `J₃` — an
//! expression long enough that a sign error in it would be invisible in review
//! and would show up only as a slightly wrong flow direction.
//!
//! So the return goes through the **cutting-plane** algorithm, which needs only
//! the scalar `f(σ)`, with the normal obtained by **central differences**. The
//! criterion is then exact, and the gradient accurate to `O(h²)`. Trading an
//! unverifiable analytic gradient for a numerical one that cannot be
//! mis-derived is the right trade here; the consistent tangent follows the same
//! reasoning ([`crate::models::plastic::consistent_tangent`]).
//!
//! Flow is **associated** (`g = f`), the usual choice for this criterion.
use crate;
use crate;
/// Ottosen's yield function, exactly as written above. Negative inside the
/// elastic domain.
///
/// ```
/// # 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(), "a".into(), "b".into(), "k_1".into(), "k_2".into(), "sigma_c".into()], &[30000.0, 0.2, 1.2759, 3.1962, 11.7365, 0.9801, 30.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() };
/// // Le critère distingue traction et compression par l'angle de Lode :
/// // à contrainte équivalente égale, la traction est bien plus pénalisante.
/// let q = 20.0;
/// let traction = plastic::ottosen::yield_function(&[q, 0.0, 0.0, 0.0, 0.0, 0.0], &mat)?;
/// let compression =
/// plastic::ottosen::yield_function(&[-q, 0.0, 0.0, 0.0, 0.0, 0.0], &mat)?;
/// assert!(traction > compression);
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```
/// `∂f/∂σ` by central differences, in the **tensor** sense (the caller contracts
/// it with the elastic modulus, which is also tensorial).
/// Cutting-plane return onto Ottosen's surface.
///
/// The algorithm is deliberately the *semi-implicit* one: the normal is
/// re-evaluated at the current iterate rather than solved for implicitly. It
/// converges robustly on a strongly curved surface without needing second
/// derivatives, which is what makes it the right choice here.
///
/// ```
/// # 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(), "a".into(), "b".into(), "k_1".into(), "k_2".into(), "sigma_c".into()], &[30000.0, 0.2, 1.2759, 3.1962, 11.7365, 0.9801, 30.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() };
/// // Un essai hors surface est ramené dessus : la fonction de charge
/// // s'annule à la solution.
/// let trial = [40.0, 0.0, 0.0, 0.0, 0.0, 0.0];
/// let pas = plastic::ottosen::return_map(&trial, &repos, &mat)?;
/// assert!(plastic::ottosen::yield_function(&pas.sigma, &mat)?.abs() < 1e-4);
/// assert!(pas.p > 0.0);
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```