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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
//! Python wrappers for [`crate::ops::model`] — the physics declarations,
//! which produce a `Model`.
//!
//! Each one spans the **whole** support it is given (one zone per subspace);
//! heterogeneous physics compose with `|`.
use crateMpcTerm;
use crateMaterialSymmetry;
use crateKinematics;
use crate;
use cratemodel;
use cratePyFiniteElementSpace;
use cratePyMesh;
use cratePyModel;
use *;
/// `model.heat_conduction(fespace, symmetry=None)` — heat-conduction model
/// spanning **every** subspace of `fespace` (one zone per subspace). A
/// single-subspace space gives the unit case; several give one zone
/// each. Compose heterogeneous physics with `|`:
/// `model.heat_conduction(fes) | model.dirichlet(...)`.
///
/// `symmetry` is `"isotropic"` (the default), `"orthotropic"` or
/// `"anisotropic"`, and selects which conductivity the material field must
/// carry: the scalar `k`, the principal `k_1, k_2, k_3`, or the symmetric
/// tensor `k_11 … k_33`. The two oriented ones also require the material
/// axes — `V1X, V1Y` in 2-D, `V1X…V1Z, V2X…V2Z` in 3-D.
/// `model.fick(fespace, species, symmetry=None)` — Fickian diffusion of one
/// named **species**, spanning every subspace of `fespace`.
///
/// Every name carries the species: DOFs are `c_<species>` (primal) and
/// `j_<species>` (dual), the diffusivity is `D_<species>`, the reported flux
/// `j_<species>_x…`. Two species therefore share a mesh without colliding —
/// and no bare `c` can be mistaken for anything else. Its physics nature is
/// `"diffusion"`, so `model.filter("diffusion")` isolates it from a thermal
/// or mechanical model it is composed with.
///
/// `symmetry` is `"isotropic"` (the default), `"orthotropic"` or
/// `"anisotropic"`, selecting the diffusivity the material field must carry:
/// `D_<species>`, `D_1_<species> …`, or the symmetric `D_11_<species> …` —
/// the oriented ones plus the material axes `V1X, V1Y, …`. Those axes and
/// the optional storage `poro` keep **bare** names: they belong to the
/// medium, not to what diffuses through it.
/// `model.interface_transfer(side_a, side_b, kind=None, tol=None)` — the
/// exchange law `j·n = h(c₁ − c₂)` across an interface between two bodies
/// that do **not** share their nodes. `kind` is `"mass"` (the default:
/// concentration `c`, flux `j`, nature `"diffusion"`) or `"thermal"` (a
/// contact resistance: `T`, `q`, nature `"thermal"`); `h` is supplied at
/// assembly time.
///
/// `side_a` and `side_b` are the two facing **boundary** FE spaces, which
/// must be conforming — same element type, same cell count, and local node
/// `k` of a cell facing local node `k` of its counterpart, within `tol`
/// (default `1e-9`). A non-matching interface raises rather than being
/// projected.
///
/// This is what lets the field **jump** across the interface: with a shared
/// node it could not. The jump is `q/h` for a flux density `q`.
/// `model.elasticity(fespace, kinematics, symmetry=None)` — linear-elasticity
/// model spanning every subspace of `fespace`. `kinematics` is `"plane_stress"`,
/// `"plane_strain"` or `"axisymmetric"` (2-D), or `"full_3d"` (3-D). DOFs are
/// the vector displacement `u_x, u_y(, u_z)`; material is supplied at
/// assembly time.
///
/// `"axisymmetric"` requires a geometry built with `Coords.axisymmetric()`
/// (`x = r`, `y = z`): the hoop strain `ε_θθ = u_r / r` comes from the kinematics,
/// the `2πr` integration measure from the geometry, and the two must agree.
///
/// `symmetry` is the **material** axis, independent of the kinematic one:
/// `"isotropic"` (the default, material `E`, `nu`), `"orthotropic"`
/// (`E_1, E_2, E_3, nu_12, nu_13, nu_23, G_12, G_13, G_23`) or
/// `"anisotropic"` (the 21 constants `C_11 … C_66`). The two oriented ones
/// also require the material axes — `V1X, V1Y` in 2-D, `V1X…V1Z, V2X…V2Z`
/// in 3-D — which are orthonormalised internally.
/// `model.dirichlet(imposed_variable, target_dual, imposed_mesh,
/// multiplier_mesh, multiplier=None, imposed_value=None, sense="=")` —
/// Dirichlet constraint model (a single sub-model) imposed via Lagrange
/// multipliers.
///
/// `imposed_variable` is the constrained primary variable (e.g. `"T"`);
/// `target_dual` is the dual variable of the target physics it couples
/// `target` is the model being constrained: `variable` must be one of its
/// primals, and its dual row is read from it — the `T → q` map is the target's
/// business, not something to retype. `imposed_mesh` is the POI1 mesh of
/// constrained nodes; `multiplier_mesh` is the POI1 support of the multipliers
/// (same per-submesh cell count) — usually built from `imposed_mesh` with the
/// `barycenter` mesher. The multiplier and imposed-value names are derived,
/// `lambda_<variable>` / `imposed_<variable>`; the imposed value `u_d` is
/// written by the user in the load field at the multiplier node's
/// `imposed_<variable>` component.
///
/// **One variable, and one only** — compose for a clamp:
/// `dirichlet(m, "u_x", …) | dirichlet(m, "u_y", …)`, the two sharing their
/// multiplier mesh, since `lambda_u_x` and `lambda_u_y` on one node are distinct
/// DOFs.
///
/// `sense` (`"="`, `">="` or `"<="`, default `"="`) turns the constraint
/// unilateral (`u ≥ u_d` / `u ≤ u_d`) — such a model is solved with
/// `solve_unilateral`. See the model chapter of the book for the full semantics.
/// `model.mpc(terms, multiplier_mesh, multiplier=None, imposed_value=None,
/// sense="=")` — multi-point constraint (a single sub-model) imposing, per
/// relation, `Σₖ aₖ·u(nodeₖ, varₖ) = g` via Lagrange multipliers.
///
/// `terms` is a list of `(mesh, variable, target_dual, coefficient)` tuples:
/// each `mesh` is a POI1 mesh (one node per relation), paired
/// element-for-element with the others and with `multiplier_mesh` (relation
/// `r` = cell `r` of every mesh). Find `target_dual` with
/// `model.dual_of(variable)`. `multiplier` / `imposed_value` override the
/// derived names `lambda_mpc` / `mpc_rhs`. The right-hand side `g` is written
/// by the user in the load field at the multiplier node's `imposed_value`
/// component (default `0`). `sense` (`"="`, `">="` or `"<="`, default `"="`)
/// turns the relations unilateral (`Σ aₖ·uₖ ≥ g` / `≤ g`) — such a model is
/// solved with `solve_unilateral`. See the constraints chapter of the book.
/// `model.embedded(immersed, host, components, multipliers=None,
/// imposed_values=None, tol=None)` — embedded (immersed) constraint (a
/// single sub-model) tying each node of `immersed` to the interpolation of
/// `host` at that node, via Lagrange multipliers.
///
/// `immersed` and `host` are meshes sharing one Coords (e.g. a bar
/// « baignée » in a volume). `components` is a list of `(variable,
/// target_dual)` pairs — the field components to tie (e.g.
/// `[("u_x","f_x"), ("u_y","f_y"), ("u_z","f_z")]`); find each `target_dual`
/// with `model.dual_of(variable)`. The coupling weights are the host shape
/// functions at each immersed node, computed once at build by locating the
/// node in the host (an immersed node outside the host is an error).
/// `multipliers` / `imposed_values` override the per-component derived names
/// `lambda_<variable>` / `imposed_<variable>`; `tol` is the location
/// tolerance (default `1e-6`). The right-hand side `g` defaults to `0` (a
/// rigid tie). See the constraints chapter of the book.
/// `model.contact(slave, master, components, multiplier=None,
/// imposed_value=None)` — node-to-surface contact (a single sub-model):
/// prevent the nodes of `slave` from penetrating the oriented `master`
/// surface mesh, one **unilateral** relation (`≥`) per slave node.
///
/// Each slave node is paired at build with its closest master facet
/// (projection weights, facet normal, initial signed gap); the pairing is
/// then fixed (linearised, frictionless contact). The master surface must
/// be consistently oriented with its normal pointing toward the slave
/// body. `components` is a list of `(variable, target_dual)` pairs — one
/// per space dimension, in ambient order (e.g.
/// `[("u_x","f_x"), ("u_y","f_y")]`); find each `target_dual` with
/// `model.dual_of(variable)`. `multiplier` / `imposed_value` override the
/// derived names `lambda_contact` / `contact_gap`.
///
/// Solve with `solve_unilateral`; build the initial-gap right-hand side
/// with `contact_gaps()`. See the contact chapter of the book.