morphogen 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. morphogen/__init__.py +60 -0
  2. morphogen/__main__.py +7 -0
  3. morphogen/_platform.py +55 -0
  4. morphogen/_public.py +153 -0
  5. morphogen/_utils.py +80 -0
  6. morphogen/_version.py +1 -0
  7. morphogen/analysis/__init__.py +174 -0
  8. morphogen/analysis/anisotropy.py +135 -0
  9. morphogen/analysis/basic.py +38 -0
  10. morphogen/analysis/cells.py +54 -0
  11. morphogen/analysis/connectivity.py +156 -0
  12. morphogen/analysis/correlation.py +195 -0
  13. morphogen/analysis/covariance.py +80 -0
  14. morphogen/analysis/fractal.py +54 -0
  15. morphogen/analysis/measures.py +188 -0
  16. morphogen/analysis/morphology.py +265 -0
  17. morphogen/analysis/particles.py +160 -0
  18. morphogen/analysis/percolation.py +2034 -0
  19. morphogen/analysis/power_laws.py +143 -0
  20. morphogen/analysis/random_sets.py +351 -0
  21. morphogen/analysis/stereology.py +289 -0
  22. morphogen/analysis/surface.py +107 -0
  23. morphogen/analysis/topology.py +92 -0
  24. morphogen/automata/__init__.py +74 -0
  25. morphogen/automata/engine.py +211 -0
  26. morphogen/automata/growth.py +686 -0
  27. morphogen/automata/lattice.py +143 -0
  28. morphogen/automata/reaction.py +255 -0
  29. morphogen/automata/rules.py +353 -0
  30. morphogen/automata/tilings.py +1715 -0
  31. morphogen/cli.py +3526 -0
  32. morphogen/config.py +2167 -0
  33. morphogen/contact/__init__.py +113 -0
  34. morphogen/contact/experiments.py +368 -0
  35. morphogen/contact/hertz.py +104 -0
  36. morphogen/contact/kernels.py +827 -0
  37. morphogen/contact/periodic.py +278 -0
  38. morphogen/contact/problem.py +578 -0
  39. morphogen/contact/surfaces.py +310 -0
  40. morphogen/coupling/__init__.py +43 -0
  41. morphogen/coupling/ageing.py +143 -0
  42. morphogen/coupling/diffusion.py +226 -0
  43. morphogen/coupling/fenicsx.py +484 -0
  44. morphogen/coupling/oxidation.py +447 -0
  45. morphogen/coupling/plates.py +247 -0
  46. morphogen/design/__init__.py +51 -0
  47. morphogen/design/csp.py +616 -0
  48. morphogen/design/frames.py +277 -0
  49. morphogen/design/search.py +287 -0
  50. morphogen/design/tiles.py +336 -0
  51. morphogen/distributions.py +312 -0
  52. morphogen/domain.py +203 -0
  53. morphogen/dynamics/__init__.py +179 -0
  54. morphogen/dynamics/model.py +638 -0
  55. morphogen/dynamics/openradioss.py +643 -0
  56. morphogen/dynamics/results.py +515 -0
  57. morphogen/fracture/__init__.py +170 -0
  58. morphogen/fracture/bulk.py +349 -0
  59. morphogen/fracture/cohesive.py +1614 -0
  60. morphogen/fracture/ductile.py +557 -0
  61. morphogen/fracture/lefm.py +1168 -0
  62. morphogen/fracture/mixed.py +1178 -0
  63. morphogen/fracture/periodic.py +733 -0
  64. morphogen/fracture/phasefield.py +714 -0
  65. morphogen/fracture/phasefield_finite.py +368 -0
  66. morphogen/fracture/surface.py +572 -0
  67. morphogen/fracture/toughness.py +566 -0
  68. morphogen/gpu.py +108 -0
  69. morphogen/gui/__init__.py +8 -0
  70. morphogen/gui/api.py +1927 -0
  71. morphogen/gui/desktop.py +387 -0
  72. morphogen/gui/icon.png +0 -0
  73. morphogen/gui/index.html +1909 -0
  74. morphogen/gui/server.py +229 -0
  75. morphogen/gui/tools/__init__.py +629 -0
  76. morphogen/gui/tools/compare.py +149 -0
  77. morphogen/gui/tools/contact.py +391 -0
  78. morphogen/gui/tools/couplings.py +1085 -0
  79. morphogen/gui/tools/crackfront.py +245 -0
  80. morphogen/gui/tools/design.py +224 -0
  81. morphogen/gui/tools/dynamics.py +824 -0
  82. morphogen/gui/tools/fracture.py +2586 -0
  83. morphogen/gui/tools/interop.py +1654 -0
  84. morphogen/gui/tools/learning.py +595 -0
  85. morphogen/gui/tools/mechanics.py +3881 -0
  86. morphogen/gui/tools/nonlocal_damage.py +1321 -0
  87. morphogen/gui/tools/phasefield.py +215 -0
  88. morphogen/gui/tools/physics.py +597 -0
  89. morphogen/gui/tools/stability.py +1756 -0
  90. morphogen/gui/tools/statistics.py +1408 -0
  91. morphogen/gui/viewer.js +1100 -0
  92. morphogen/homogenization/__init__.py +210 -0
  93. morphogen/homogenization/acoustics.py +566 -0
  94. morphogen/homogenization/amg.py +1005 -0
  95. morphogen/homogenization/apparent.py +1046 -0
  96. morphogen/homogenization/behaviours.cu +2285 -0
  97. morphogen/homogenization/behaviours.py +944 -0
  98. morphogen/homogenization/beremin.py +263 -0
  99. morphogen/homogenization/bifurcation.py +1085 -0
  100. morphogen/homogenization/bloch.py +507 -0
  101. morphogen/homogenization/bounds.py +226 -0
  102. morphogen/homogenization/core.py +458 -0
  103. morphogen/homogenization/coupled.py +1135 -0
  104. morphogen/homogenization/crystal.py +2967 -0
  105. morphogen/homogenization/dilatation.py +454 -0
  106. morphogen/homogenization/elements.py +157 -0
  107. morphogen/homogenization/fatigue.py +768 -0
  108. morphogen/homogenization/fe.py +1739 -0
  109. morphogen/homogenization/fenicsx.py +307 -0
  110. morphogen/homogenization/fft.py +499 -0
  111. morphogen/homogenization/fft_nonlinear.py +391 -0
  112. morphogen/homogenization/finite.py +613 -0
  113. morphogen/homogenization/flow.py +361 -0
  114. morphogen/homogenization/frames.py +1125 -0
  115. morphogen/homogenization/gpu.py +1241 -0
  116. morphogen/homogenization/harmonic.py +427 -0
  117. morphogen/homogenization/identification.py +579 -0
  118. morphogen/homogenization/kernels.py +760 -0
  119. morphogen/homogenization/laws.py +2061 -0
  120. morphogen/homogenization/materials.py +1080 -0
  121. morphogen/homogenization/mfront.py +589 -0
  122. morphogen/homogenization/networks.py +880 -0
  123. morphogen/homogenization/nonlinear.py +2612 -0
  124. morphogen/homogenization/ntfa.py +577 -0
  125. morphogen/homogenization/paths.py +476 -0
  126. morphogen/homogenization/photonic.py +467 -0
  127. morphogen/homogenization/poroelastic.py +212 -0
  128. morphogen/homogenization/porous.py +1120 -0
  129. morphogen/homogenization/postprocess.py +290 -0
  130. morphogen/homogenization/solvers.py +1140 -0
  131. morphogen/homogenization/tensors.py +240 -0
  132. morphogen/homogenization/voxel_fe.py +457 -0
  133. morphogen/homogenization/xfem.py +1016 -0
  134. morphogen/homogenization/zmat.py +1258 -0
  135. morphogen/iga/__init__.py +48 -0
  136. morphogen/iga/analysis.py +508 -0
  137. morphogen/iga/basis.py +214 -0
  138. morphogen/iga/geometry.py +501 -0
  139. morphogen/iga/homogenization.py +219 -0
  140. morphogen/iga/optimization.py +700 -0
  141. morphogen/iga/shapes.py +331 -0
  142. morphogen/image.py +128 -0
  143. morphogen/io/__init__.py +246 -0
  144. morphogen/io/amitex.py +741 -0
  145. morphogen/io/ebsd.py +881 -0
  146. morphogen/io/export.py +196 -0
  147. morphogen/io/geometry.py +158 -0
  148. morphogen/io/medit.py +147 -0
  149. morphogen/io/meshes.py +844 -0
  150. morphogen/io/metaimage.py +97 -0
  151. morphogen/io/mfront.py +1104 -0
  152. morphogen/io/native.py +57 -0
  153. morphogen/io/radioss.py +764 -0
  154. morphogen/io/solvers.py +371 -0
  155. morphogen/io/tables.py +278 -0
  156. morphogen/io/tiff.py +66 -0
  157. morphogen/io/vtk.py +701 -0
  158. morphogen/io/xdmf.py +200 -0
  159. morphogen/kernels/__init__.py +5 -0
  160. morphogen/kernels/annealing.py +192 -0
  161. morphogen/kernels/cells.py +69 -0
  162. morphogen/kernels/collective.py +87 -0
  163. morphogen/kernels/force_biased.py +595 -0
  164. morphogen/kernels/implicit.py +145 -0
  165. morphogen/kernels/leaves.py +132 -0
  166. morphogen/kernels/packing.py +304 -0
  167. morphogen/kernels/raster.py +279 -0
  168. morphogen/kernels/rsa.py +371 -0
  169. morphogen/kernels/union.py +135 -0
  170. morphogen/kernels/watershed.py +190 -0
  171. morphogen/laser/__init__.py +234 -0
  172. morphogen/laser/architectures.py +375 -0
  173. morphogen/laser/bending.py +216 -0
  174. morphogen/laser/cells.py +1694 -0
  175. morphogen/laser/design.py +940 -0
  176. morphogen/laser/figures.py +227 -0
  177. morphogen/laser/heat.py +804 -0
  178. morphogen/laser/materials.py +691 -0
  179. morphogen/laser/mechanics.py +1670 -0
  180. morphogen/laser/metallurgy.py +615 -0
  181. morphogen/laser/patterns.py +828 -0
  182. morphogen/laser/periodic.py +392 -0
  183. morphogen/laser/process.py +362 -0
  184. morphogen/laser/run.py +534 -0
  185. morphogen/laser/solid.py +216 -0
  186. morphogen/laser/specimen.py +200 -0
  187. morphogen/laser/structures.py +708 -0
  188. morphogen/learning/__init__.py +81 -0
  189. morphogen/learning/behaviour.py +398 -0
  190. morphogen/learning/data.py +328 -0
  191. morphogen/learning/learned.cpp +668 -0
  192. morphogen/learning/logarithmic.py +202 -0
  193. morphogen/learning/mfront.py +409 -0
  194. morphogen/learning/networks.py +767 -0
  195. morphogen/learning/run.py +212 -0
  196. morphogen/learning/standard.py +814 -0
  197. morphogen/learning/training.py +235 -0
  198. morphogen/mesh/__init__.py +29 -0
  199. morphogen/mesh/conforming.py +1423 -0
  200. morphogen/mesh/curved.py +600 -0
  201. morphogen/mesh/exact.py +1717 -0
  202. morphogen/mesh/octree.py +350 -0
  203. morphogen/mesh/polycrystal.py +1041 -0
  204. morphogen/mesh/polyhedra.py +677 -0
  205. morphogen/mesh/regularize.py +570 -0
  206. morphogen/mesh/surface.py +97 -0
  207. morphogen/mesh/tetra.py +512 -0
  208. morphogen/mesh/voxel.py +124 -0
  209. morphogen/micromorphic/__init__.py +31 -0
  210. morphogen/micromorphic/damage.py +359 -0
  211. morphogen/micromorphic/ductile.py +534 -0
  212. morphogen/micromorphic/finite.py +220 -0
  213. morphogen/micromorphic/microfoam.py +787 -0
  214. morphogen/micromorphic/space.py +341 -0
  215. morphogen/models/__init__.py +195 -0
  216. morphogen/models/affine.py +384 -0
  217. morphogen/models/automata.py +592 -0
  218. morphogen/models/base.py +500 -0
  219. morphogen/models/boolean.py +310 -0
  220. morphogen/models/bouligand.py +331 -0
  221. morphogen/models/branching.py +241 -0
  222. morphogen/models/combination.py +430 -0
  223. morphogen/models/deadleaves.py +766 -0
  224. morphogen/models/design.py +289 -0
  225. morphogen/models/ebsd.py +206 -0
  226. morphogen/models/fibers.py +1476 -0
  227. morphogen/models/foam.py +594 -0
  228. morphogen/models/gaussian.py +314 -0
  229. morphogen/models/growth.py +459 -0
  230. morphogen/models/hardcore.py +317 -0
  231. morphogen/models/hierarchical.py +269 -0
  232. morphogen/models/honeycomb.py +749 -0
  233. morphogen/models/implicit.py +177 -0
  234. morphogen/models/laminate.py +470 -0
  235. morphogen/models/lattice.py +351 -0
  236. morphogen/models/lattice_field.py +345 -0
  237. morphogen/models/levelset_foam.py +563 -0
  238. morphogen/models/nacre.py +411 -0
  239. morphogen/models/nested.py +924 -0
  240. morphogen/models/osteons.py +374 -0
  241. morphogen/models/pieces.py +167 -0
  242. morphogen/models/planar.py +126 -0
  243. morphogen/models/reconstruction.py +203 -0
  244. morphogen/models/scale_rich.py +1409 -0
  245. morphogen/models/scale_rich_3d.py +1616 -0
  246. morphogen/models/tessellation.py +735 -0
  247. morphogen/models/tiling_field.py +302 -0
  248. morphogen/models/tpms.py +197 -0
  249. morphogen/models/transparent.py +406 -0
  250. morphogen/models/union.py +141 -0
  251. morphogen/optimization/__init__.py +43 -0
  252. morphogen/optimization/cell.py +295 -0
  253. morphogen/optimization/filters.py +115 -0
  254. morphogen/optimization/mma.py +226 -0
  255. morphogen/optimization/run.py +219 -0
  256. morphogen/optimization/topology.py +632 -0
  257. morphogen/orientations.py +568 -0
  258. morphogen/parallel.py +599 -0
  259. morphogen/pipeline.py +978 -0
  260. morphogen/primitives.py +188 -0
  261. morphogen/results.py +564 -0
  262. morphogen/rve/__init__.py +73 -0
  263. morphogen/rve/report.py +627 -0
  264. morphogen/rve/scaling.py +363 -0
  265. morphogen/rve/study.py +1054 -0
  266. morphogen/rve/windows.py +345 -0
  267. morphogen/seeding.py +51 -0
  268. morphogen/settings.py +118 -0
  269. morphogen/stopping.py +48 -0
  270. morphogen/symmetry.py +384 -0
  271. morphogen/templates/activator_inhibitor.yaml +22 -0
  272. morphogen/templates/aggregation.yaml +23 -0
  273. morphogen/templates/boolean_cylinders.yaml +20 -0
  274. morphogen/templates/boolean_spheres.yaml +22 -0
  275. morphogen/templates/bouligand.yaml +28 -0
  276. morphogen/templates/cellular_automaton.yaml +25 -0
  277. morphogen/templates/coated_spheres.yaml +26 -0
  278. morphogen/templates/contact_fibers.yaml +27 -0
  279. morphogen/templates/cox_nanocomposite.yaml +22 -0
  280. morphogen/templates/cross_linked_fibers.yaml +26 -0
  281. morphogen/templates/curved_arcs.yaml +28 -0
  282. morphogen/templates/curved_fibers.yaml +24 -0
  283. morphogen/templates/dead_leaves.yaml +22 -0
  284. morphogen/templates/delaunay_network.yaml +22 -0
  285. morphogen/templates/dense_packing.yaml +22 -0
  286. morphogen/templates/diffusion.yaml +33 -0
  287. morphogen/templates/ebsd.yaml +34 -0
  288. morphogen/templates/ebsd_map.ctf +3087 -0
  289. morphogen/templates/fracture_composite.yaml +42 -0
  290. morphogen/templates/fracture_rubber.yaml +47 -0
  291. morphogen/templates/gaussian_excursion.yaml +17 -0
  292. morphogen/templates/graded_lattice.yaml +24 -0
  293. morphogen/templates/hardcore_fibers.yaml +22 -0
  294. morphogen/templates/hardcore_spheres.yaml +22 -0
  295. morphogen/templates/hierarchical_lattice.yaml +22 -0
  296. morphogen/templates/homogenization_acoustic_foam.yaml +36 -0
  297. morphogen/templates/homogenization_beremin.yaml +50 -0
  298. morphogen/templates/homogenization_cleavage.yaml +51 -0
  299. morphogen/templates/homogenization_cleavage_band.yaml +55 -0
  300. morphogen/templates/homogenization_contact.yaml +43 -0
  301. morphogen/templates/homogenization_crack_closure.yaml +49 -0
  302. morphogen/templates/homogenization_crystal_plasticity.yaml +50 -0
  303. morphogen/templates/homogenization_crystal_plasticity_fft.yaml +52 -0
  304. morphogen/templates/homogenization_crystallization.yaml +30 -0
  305. morphogen/templates/homogenization_debonding.yaml +43 -0
  306. morphogen/templates/homogenization_detwinning.yaml +58 -0
  307. morphogen/templates/homogenization_ductile_damage.yaml +47 -0
  308. morphogen/templates/homogenization_fatigue.yaml +40 -0
  309. morphogen/templates/homogenization_grain_fracture.yaml +56 -0
  310. morphogen/templates/homogenization_gyroid.yaml +30 -0
  311. morphogen/templates/homogenization_intergranular.yaml +43 -0
  312. morphogen/templates/homogenization_interphase.yaml +42 -0
  313. morphogen/templates/homogenization_mixed_loading.yaml +33 -0
  314. morphogen/templates/homogenization_ntfa.yaml +56 -0
  315. morphogen/templates/homogenization_piezoelectric.yaml +27 -0
  316. morphogen/templates/homogenization_polycrystal.yaml +30 -0
  317. morphogen/templates/homogenization_polycrystal_inclusions.yaml +30 -0
  318. morphogen/templates/homogenization_poroelastic.yaml +26 -0
  319. morphogen/templates/homogenization_rubber.yaml +40 -0
  320. morphogen/templates/homogenization_slip_cleavage.yaml +50 -0
  321. morphogen/templates/homogenization_spheres.yaml +31 -0
  322. morphogen/templates/homogenization_transport.yaml +29 -0
  323. morphogen/templates/homogenization_twinning.yaml +54 -0
  324. morphogen/templates/homogenization_viscoelastic.yaml +34 -0
  325. morphogen/templates/homogenization_viscoplastic.yaml +42 -0
  326. morphogen/templates/homogenization_voronoi.yaml +26 -0
  327. morphogen/templates/homogenization_xfem.yaml +23 -0
  328. morphogen/templates/hyperuniform_cells.yaml +24 -0
  329. morphogen/templates/laguerre.yaml +18 -0
  330. morphogen/templates/laser_bending.yaml +35 -0
  331. morphogen/templates/laser_cells.yaml +38 -0
  332. morphogen/templates/laser_corrugated.yaml +36 -0
  333. morphogen/templates/level_set_foam.yaml +29 -0
  334. morphogen/templates/menger_sponge.yaml +17 -0
  335. morphogen/templates/nacre.yaml +25 -0
  336. morphogen/templates/nucleation_growth.yaml +25 -0
  337. morphogen/templates/optimize_auxetic.yaml +29 -0
  338. morphogen/templates/optimize_auxetic_3d.yaml +27 -0
  339. morphogen/templates/optimize_bulk.yaml +23 -0
  340. morphogen/templates/optimize_conductivity.yaml +20 -0
  341. morphogen/templates/osteons.yaml +28 -0
  342. morphogen/templates/penetrable_spheres.yaml +21 -0
  343. morphogen/templates/poisson_fibers.yaml +21 -0
  344. morphogen/templates/random_laminate.yaml +26 -0
  345. morphogen/templates/random_lattice.yaml +27 -0
  346. morphogen/templates/random_walk_fibers.yaml +26 -0
  347. morphogen/templates/reaction_diffusion.yaml +22 -0
  348. morphogen/templates/reconstruction.yaml +22 -0
  349. morphogen/templates/rve_cellular_automaton.yaml +23 -0
  350. morphogen/templates/rve_crystal_plasticity_fft.yaml +51 -0
  351. morphogen/templates/rve_multiphysics.yaml +43 -0
  352. morphogen/templates/rve_poisson_fibers.yaml +22 -0
  353. morphogen/templates/rve_poisson_fibers_fe.yaml +33 -0
  354. morphogen/templates/rve_voronoi_windows.yaml +20 -0
  355. morphogen/templates/scale_rich_network.yaml +29 -0
  356. morphogen/templates/scale_rich_plates.yaml +30 -0
  357. morphogen/templates/sequential_dead_leaves.yaml +25 -0
  358. morphogen/templates/strut_lattice.yaml +21 -0
  359. morphogen/templates/tile_assembly.yaml +28 -0
  360. morphogen/templates/tpms.yaml +19 -0
  361. morphogen/templates/trabecular_bone.yaml +29 -0
  362. morphogen/templates/transparent_dead_leaves.yaml +23 -0
  363. morphogen/templates/vascular_tree.yaml +23 -0
  364. morphogen/templates/voronoi.yaml +20 -0
  365. morphogen/templates/wood.yaml +34 -0
  366. morphogen/templates/workflow.yaml +56 -0
  367. morphogen/texture.py +665 -0
  368. morphogen/theory.py +162 -0
  369. morphogen/viz/__init__.py +12 -0
  370. morphogen/viz/export.py +244 -0
  371. morphogen/viz/figures.py +707 -0
  372. morphogen/viz/png.py +148 -0
  373. morphogen/viz/sections.py +696 -0
  374. morphogen/viz/surfaces.py +1352 -0
  375. morphogen/viz/video.py +904 -0
  376. morphogen/viz/workflow.py +488 -0
  377. morphogen-1.0.0.dist-info/METADATA +2316 -0
  378. morphogen-1.0.0.dist-info/RECORD +381 -0
  379. morphogen-1.0.0.dist-info/WHEEL +4 -0
  380. morphogen-1.0.0.dist-info/entry_points.txt +5 -0
  381. morphogen-1.0.0.dist-info/licenses/LICENSE +674 -0
@@ -0,0 +1,708 @@
1
+ """Load cases of laser-architectured sheets beyond the tensile test of a dog-bone: the
2
+ compact tension specimen (the blunting of a crack, the third application of SCOLASTIC)
3
+ and the L-shaped plate (the strength at a re-entrant corner), and the tensile test
4
+ itself as one of them.
5
+
6
+ **Meshes.** Structured blocks of quadrilaterals graded towards the singular points
7
+ (:func:`graded`: elements of ``fine`` mm there, growing geometrically to ``element``
8
+ mm): the CT specimen of ASTM E399 proportions (width ``W`` from the load line, height
9
+ 1.2 W, pin holes of diameter 0.25 W at 0.275 W from the crack plane, a crack of length
10
+ ``a`` from the load line, its faces unconnected nodes; each pin a node joined by stiff
11
+ bars to the half of its hole it bears on, so that the specimen turns about it: the
12
+ elastic load-line compliance within 2.5 % of Saxena & Hudak 1978), the L-shaped plate
13
+ (a square of side ``size`` without the quadrant beyond the ``arm``).
14
+
15
+ **Test** (:func:`load_test`): displacement control of a set of degrees of freedom along
16
+ a direction (the load-line displacement ``δ``), others held, the force the reaction
17
+ along that direction; the same Newton iterations and adaptive steps as
18
+ :func:`~morphogen.laser.mechanics.tensile_test`, until a displacement, a drop of the
19
+ force after its maximum, or a margin beyond the first fracture of a point (the critical
20
+ plastic strains of the membrane, averaged over its fracture radius: the initiation of a
21
+ crack, ductile in the matrix, brittle in a hard phase). The curve is nominal: the force
22
+ over a ``section`` and the displacement over a ``length`` (MPa and strain), so that
23
+ :func:`~morphogen.laser.cells.failure_measures` reads its maximum (the limit load), the
24
+ first fracture (the initiation), the work up to it.
25
+
26
+ **Cases** (:class:`TensionCase`, :class:`CompactTension`, :class:`LPlate`): a mesh, the
27
+ conditions of the test, the nominal section and length, the region of the cells of a
28
+ design (:class:`~morphogen.laser.cells.CellProblem` takes a case).
29
+ """
30
+
31
+ from __future__ import annotations
32
+
33
+ import math
34
+ import time
35
+ from dataclasses import dataclass, field
36
+
37
+ import numpy as np
38
+ from scipy.sparse import linalg as splinalg
39
+
40
+ from morphogen.laser.mechanics import Membrane, TensileResult, curve_measures, tensile_test
41
+ from morphogen.laser.specimen import QuadMesh, Specimen
42
+
43
+ # -- meshes ----------------------------------------------------------------------------
44
+
45
+
46
+ def graded(
47
+ a: float,
48
+ b: float,
49
+ element: float,
50
+ *,
51
+ focus=(),
52
+ fine: float | None = None,
53
+ growth: float = 1.2,
54
+ box: tuple | None = None,
55
+ ) -> np.ndarray:
56
+ """Coordinates from ``a`` to ``b``: elements of ``fine`` at the ``focus`` points,
57
+ growing by ``growth`` to ``element`` away from them (uniform without focus); or
58
+ uniform elements of ``fine`` over ``box = (lo, hi)`` (on the grid of the first
59
+ focus inside it), growing away from its ends."""
60
+ if not b > a:
61
+ raise ValueError("graded: b > a")
62
+ if box is not None and fine is not None:
63
+ lo, hi = max(float(box[0]), a), min(float(box[1]), b)
64
+ anchor = next((float(f) for f in focus if lo <= f <= hi), lo)
65
+ k0 = math.ceil((lo - anchor) / fine - 1e-9)
66
+ k1 = math.floor((hi - anchor) / fine + 1e-9)
67
+ inner = anchor + fine * np.arange(k0, k1 + 1)
68
+ left = (
69
+ graded(a, inner[0], element, focus=(inner[0],), fine=fine, growth=growth)
70
+ if inner[0] > a + 1e-9
71
+ else np.array([a])
72
+ )
73
+ right = (
74
+ graded(inner[-1], b, element, focus=(inner[-1],), fine=fine, growth=growth)
75
+ if inner[-1] < b - 1e-9
76
+ else np.array([b])
77
+ )
78
+ return np.unique(np.concatenate([left, inner, right]).round(12))
79
+ focus = [float(f) for f in focus if a - 1e-12 <= f <= b + 1e-12]
80
+ if not focus or fine is None:
81
+ n = max(1, math.ceil((b - a) / element))
82
+ return np.linspace(a, b, n + 1)
83
+ pts = {a, b, *focus}
84
+ for f in focus:
85
+ for sign in (-1.0, 1.0):
86
+ x, h = f, fine
87
+ while True:
88
+ x += sign * h
89
+ end = b if sign > 0 else a
90
+ if abs(end - x) < 0.5 * h or not a < x < b: # no sliver at the ends
91
+ break
92
+ pts.add(x)
93
+ h = min(h * growth, element)
94
+ xs = np.array(sorted(pts))
95
+ # merge points closer than a third of the local size, keeping the ends and foci
96
+ keep = [xs[0]]
97
+ fixed = {a, b, *focus}
98
+ for x in xs[1:]:
99
+ if x - keep[-1] < 0.3 * min(fine, element):
100
+ if x in fixed:
101
+ keep[-1] = x
102
+ continue
103
+ keep.append(x)
104
+ return np.array(keep)
105
+
106
+
107
+ def _tensor(xs, ys):
108
+ """Nodes and counter-clockwise quadrilaterals of the grid ``xs x ys``."""
109
+ X, Y = np.meshgrid(xs, ys, indexing="ij")
110
+ nodes = np.column_stack([X.ravel(), Y.ravel()])
111
+ ny = len(ys)
112
+ idx = np.arange(len(xs) * ny).reshape(len(xs), ny)
113
+ quads = np.column_stack(
114
+ [idx[:-1, :-1].ravel(), idx[1:, :-1].ravel(), idx[1:, 1:].ravel(), idx[:-1, 1:].ravel()]
115
+ )
116
+ return nodes, quads
117
+
118
+
119
+ def _compact(nodes, quads):
120
+ """Drop the nodes no quadrilateral uses; the new numbering of the old nodes."""
121
+ used = np.unique(quads)
122
+ new = -np.ones(len(nodes), dtype=np.int64)
123
+ new[used] = np.arange(len(used))
124
+ return nodes[used], new[quads], new
125
+
126
+
127
+ def _quadmesh(nodes, quads) -> QuadMesh:
128
+ empty = np.zeros(0, dtype=np.int64)
129
+ return QuadMesh(
130
+ np.asarray(nodes, float), np.asarray(quads, np.int64), empty, empty, empty, empty, (0, 0)
131
+ )
132
+
133
+
134
+ @dataclass
135
+ class Domain:
136
+ """A mesh and its named sets of nodes."""
137
+
138
+ mesh: QuadMesh
139
+ sets: dict = field(default_factory=dict)
140
+ points: dict = field(default_factory=dict)
141
+
142
+
143
+ def ct_mesh(
144
+ width: float = 20.0,
145
+ crack: float = 0.5,
146
+ *,
147
+ element: float = 1.0,
148
+ fine: float = 0.125,
149
+ growth: float = 1.2,
150
+ refine: tuple | None = None,
151
+ ) -> Domain:
152
+ """The compact tension specimen (ASTM E399 proportions; the module): ``x`` from the
153
+ load line, the crack along ``y = 0`` from the front face ``x = −0.25 W`` to ``x =
154
+ a = crack W``; elements of ``fine`` at the tip, or over the box ``refine = (x0, x1,
155
+ y1)`` (``x0 ≤ x ≤ x1``, ``|y| ≤ y1``: the paths of a growing crack). Sets:
156
+ ``upper_pin`` and ``lower_pin`` (the halves of the pin holes the pins bear on),
157
+ ``mouth_upper`` and ``mouth_lower`` (the crack mouth); points: ``tip``."""
158
+ W = float(width)
159
+ a = float(crack) * W
160
+ if not 0.2 * W <= a <= 0.8 * W:
161
+ raise ValueError("ct: 0.2 <= a/W <= 0.8")
162
+ h = 0.6 * W
163
+ r, yc = 0.125 * W, 0.275 * W
164
+ bx = by = None
165
+ if refine is not None: # a box of uniform fine elements (on the grid of the tip)
166
+ x0, x1, y1 = (float(v) for v in refine)
167
+ bx, by = (x0, x1), (0.0, y1)
168
+ xs = graded(-0.25 * W, W, element, focus=(a,), fine=fine, growth=growth, box=bx)
169
+ ys = graded(0.0, h, element, focus=(0.0,), fine=fine, growth=growth, box=by)
170
+ up_n, up_q = _tensor(xs, ys)
171
+ lo_n, lo_q = _tensor(xs, -ys[::-1])
172
+ nx, ny = len(xs), len(ys)
173
+ # the lower block: its row y = 0 is its last; merge the ligament nodes with the upper
174
+ offset = len(up_n)
175
+ lo_ids = np.arange(len(lo_n)) + offset
176
+ lo_grid = lo_ids.reshape(nx, ny)
177
+ up_grid = np.arange(len(up_n)).reshape(nx, ny)
178
+ lig = xs >= a - 1e-9
179
+ lo_grid[lig, -1] = up_grid[lig, 0]
180
+ remap = lo_grid.ravel()
181
+ nodes = np.vstack([up_n, lo_n])
182
+ quads = np.vstack([up_q, remap[lo_q]])
183
+ # the pin holes
184
+ cen = nodes[quads].mean(axis=1)
185
+ inside = np.zeros(len(quads), dtype=bool)
186
+ for s in (1.0, -1.0):
187
+ inside |= np.hypot(cen[:, 0], cen[:, 1] - s * yc) < r
188
+ removed, kept = quads[inside], quads[~inside]
189
+ nodes, kept, new = _compact(nodes, kept)
190
+ rim = np.intersect1d(np.unique(removed), np.unique(quads[~inside]))
191
+ rim = new[rim]
192
+ rim = rim[rim >= 0]
193
+ p = nodes[rim]
194
+ upper = rim[(p[:, 1] > 0) & (p[:, 1] >= yc)]
195
+ lower = rim[(p[:, 1] < 0) & (p[:, 1] <= -yc)]
196
+ front = np.isclose(nodes[:, 0], -0.25 * W) & np.isclose(nodes[:, 1], 0.0)
197
+ # the pins: a node at the centre of each hole, bars to the half of the rim it bears on
198
+ first = len(nodes)
199
+ nodes = np.vstack([nodes, [[0.0, yc], [0.0, -yc]]])
200
+ mouth = np.flatnonzero(front)
201
+ # the two nodes at the mouth: the one of the upper block first
202
+ mu = new[up_grid[0, 0]]
203
+ ml = new[lo_grid[0, -1]]
204
+ if not (np.isin(mu, mouth) and np.isin(ml, mouth)): # pragma: no cover - geometry
205
+ raise RuntimeError("ct: crack mouth not found")
206
+ tip = new[up_grid[np.flatnonzero(lig)[0], 0]]
207
+ return Domain(
208
+ _quadmesh(nodes, kept),
209
+ {
210
+ "upper_pin": upper,
211
+ "lower_pin": lower,
212
+ "mouth_upper": np.array([mu]),
213
+ "mouth_lower": np.array([ml]),
214
+ "pins": np.array([first, first + 1]),
215
+ },
216
+ {"tip": nodes[tip].copy(), "a": a, "W": W},
217
+ )
218
+
219
+
220
+ def pin_springs(domain: Domain, stiffness: float) -> tuple:
221
+ """Bars from each pin node to the rim nodes it bears on (see :func:`ct_mesh`): the
222
+ specimen turns freely about its pins."""
223
+ nodes = domain.mesh.nodes
224
+ i, j = [], []
225
+ rims = (domain.sets["upper_pin"], domain.sets["lower_pin"])
226
+ for pin, rim in zip(domain.sets["pins"], rims, strict=True):
227
+ i += [pin] * len(rim)
228
+ j += list(rim)
229
+ i, j = np.array(i), np.array(j)
230
+ d = nodes[j] - nodes[i]
231
+ e = d / np.linalg.norm(d, axis=1, keepdims=True)
232
+ return i, j, np.full(len(i), float(stiffness)), e
233
+
234
+
235
+ def l_mesh(
236
+ size: float = 40.0,
237
+ arm: float = 16.0,
238
+ *,
239
+ element: float = 1.0,
240
+ fine: float = 0.25,
241
+ growth: float = 1.2,
242
+ ) -> Domain:
243
+ """The L-shaped plate: the square ``[0, size]²`` without ``[arm, size]²``, the
244
+ re-entrant corner at ``(arm, arm)``. Sets: ``top`` (``y = size``, held), ``tip``
245
+ (``x = size``, loaded)."""
246
+ L, b = float(size), float(arm)
247
+ if not 0 < b < L:
248
+ raise ValueError("l-plate: 0 < arm < size")
249
+ xs = graded(0.0, L, element, focus=(b,), fine=fine, growth=growth)
250
+ nodes, quads = _tensor(xs, xs)
251
+ cen = nodes[quads].mean(axis=1)
252
+ keep = ~((cen[:, 0] > b) & (cen[:, 1] > b))
253
+ nodes, quads, _ = _compact(nodes, quads[keep])
254
+ top = np.flatnonzero(np.isclose(nodes[:, 1], L))
255
+ tip = np.flatnonzero(np.isclose(nodes[:, 0], L))
256
+ return Domain(_quadmesh(nodes, quads), {"top": top, "tip": tip}, {"corner": np.array([b, b])})
257
+
258
+
259
+ # -- the test --------------------------------------------------------------------------
260
+
261
+
262
+ def load_test(
263
+ membrane: Membrane,
264
+ fixed,
265
+ moved,
266
+ direction,
267
+ *,
268
+ length: float,
269
+ section: float,
270
+ max_disp: float,
271
+ step: float = 0.004,
272
+ max_step: float = 0.02,
273
+ drop: float = 0.05,
274
+ tol: float = 1e-5,
275
+ max_iterations: int = 20,
276
+ max_steps: int = 400,
277
+ failure_margin: float | None = None,
278
+ record_history: bool = False,
279
+ monitors: dict | None = None,
280
+ keep_fields: bool = True,
281
+ erosion: bool = False,
282
+ max_breaks: int = 2000,
283
+ until=None,
284
+ ) -> TensileResult:
285
+ """Displacement control (see the module): the dofs ``moved`` follow ``δ
286
+ direction`` (or a path: ``direction`` a function of ``δ`` giving their values and
287
+ their derivatives, the force then the work-conjugate of ``δ``), the dofs ``fixed``
288
+ are held; steps of ``step`` (then up to
289
+ ``max_step``) times ``max_disp``; stops at ``max_disp``, when the force falls by
290
+ ``drop`` after its maximum, or ``failure_margin`` (nominal strain) beyond the
291
+ first fracture. With ``erosion``, the crack grows: after each step the elements
292
+ whose ratio to fracture reaches one break (:class:`~morphogen.laser.mechanics.Membrane`:
293
+ a residual stiffness; the averages over the living elements), the specimen is
294
+ brought back to equilibrium at the same displacement, again until none breaks
295
+ (a crack that runs unstably at fixed displacement); ``fields["broken"]``: the
296
+ broken elements in their order and the strain at which each broke (at most
297
+ ``max_breaks``). The result's strain is ``δ / length``, its stress the force over
298
+ ``section``; ``monitors``: functions of the displacements recorded at each step
299
+ (``fields["monitors"]``, kept with or without the fields). The membrane may be seen
300
+ through a linear map of reduced unknowns (its ``full`` gives the nodal displacements:
301
+ the periodic cell of :mod:`~morphogen.laser.periodic`). ``until``: a function of the
302
+ displacements checked after each step (after the monitors): the test stops when it
303
+ returns true."""
304
+ t0 = time.perf_counter()
305
+ fixed = np.unique(np.asarray(fixed, dtype=np.int64))
306
+ moved = np.asarray(moved, dtype=np.int64)
307
+ if callable(direction): # a path: the values of the moved dofs and their rates
308
+ path = direction
309
+ else:
310
+ dirn = np.asarray(direction, dtype=float)
311
+
312
+ def path(d):
313
+ return d * dirn, dirn
314
+
315
+ if np.shape(path(0.0)[0]) != moved.shape:
316
+ raise ValueError("load test: one direction per moved dof")
317
+ held = np.unique(np.concatenate([fixed, moved]))
318
+ free = np.setdiff1d(np.arange(membrane.ndof), held)
319
+ membrane.reset()
320
+ u = membrane.u.copy()
321
+ f, K, _, _ = membrane.evaluate(u)
322
+ disp, inc = 0.0, step * max_disp
323
+ min_inc = 1e-4 * step * max_disp
324
+ rec = {"strain": [0.0], "stress": [0.0], "force": [0.0], "displacement": [0.0]}
325
+ mons = {k: [float(fn(u))] for k, fn in (monitors or {}).items()}
326
+ history = [(0.0, 0.0, membrane.Fn.copy())] if record_history else []
327
+ has_critical = membrane.fracture.any
328
+ failure, ratio_prev = math.nan, 0.0
329
+ fmax, steps, iterations = 0.0, 0, 0
330
+ scale_f = 1e-9 * membrane.young * section
331
+ broken, broken_at = [], []
332
+
333
+ breakable = membrane.fracture.finite.any(axis=(1, 2))
334
+
335
+ def newton(trial):
336
+ """Newton's method at fixed displacements; a correction that turns an element
337
+ inside out is halved (the iterates near a crack tip, after a break)."""
338
+ nonlocal iterations
339
+ fi, Ki, state, bad = membrane.evaluate(trial)
340
+ iterations += 1
341
+ if bad or not np.all(np.isfinite(fi)):
342
+ return False, trial, fi, Ki, state, 0
343
+ for it in range(max_iterations):
344
+ r = fi[free]
345
+ scale = max(np.linalg.norm(fi[held]), scale_f)
346
+ if np.linalg.norm(r) <= tol * scale:
347
+ return True, trial, fi, Ki, state, it
348
+ try:
349
+ du = splinalg.spsolve(Ki[free][:, free].tocsc(), -r)
350
+ except RuntimeError:
351
+ break
352
+ if not np.all(np.isfinite(du)):
353
+ break
354
+ step, done = 1.0, False
355
+ for _ in range(8):
356
+ cand = trial.copy()
357
+ cand[free] += step * du
358
+ f2, K2, s2, bad2 = membrane.evaluate(cand)
359
+ iterations += 1
360
+ if not bad2 and np.all(np.isfinite(f2)):
361
+ done = True
362
+ break
363
+ step *= 0.5
364
+ if not done:
365
+ break
366
+ trial, fi, Ki, state = cand, f2, K2, s2
367
+ return False, trial, fi, Ki, state, max_iterations
368
+
369
+ while True:
370
+ target = disp + inc
371
+ trial = u.copy()
372
+ dpres = np.zeros(membrane.ndof)
373
+ dpres[moved] = path(target)[0] - path(disp)[0]
374
+ rhs = -(f[free] + K[free][:, moved] @ dpres[moved])
375
+ try:
376
+ trial[free] += splinalg.spsolve(K[free][:, free].tocsc(), rhs)
377
+ except RuntimeError:
378
+ pass
379
+ trial[fixed] = 0.0
380
+ trial[moved] = path(target)[0]
381
+ converged, trial, fi, Ki, state, it = newton(trial)
382
+ if not converged and erosion and has_critical and broken:
383
+ # no equilibrium: the elements of the front of the crack the trial turned
384
+ # inside out have failed, broken before the step is cut
385
+ ratios = membrane.fracture.ratios(membrane.p_n, membrane.alive)
386
+ quads = membrane.mesh.quads
387
+ front = np.isin(quads, quads[~membrane.alive]).any(axis=1)
388
+ inv = np.flatnonzero(
389
+ getattr(membrane, "inverted", np.zeros(len(ratios), bool))
390
+ & membrane.alive
391
+ & breakable
392
+ & front
393
+ )
394
+ if inv.size and len(broken) < max_breaks:
395
+ inv = inv[np.argsort(-ratios[inv])][:2]
396
+ membrane.alive[inv] = False
397
+ broken.extend(inv.tolist())
398
+ broken_at.extend([disp / length] * len(inv))
399
+ ok, trial2, fi2, Ki2, state2, _ = newton(u.copy())
400
+ if ok:
401
+ u, f, K = trial2, fi2, Ki2
402
+ membrane.commit(u, state2)
403
+ continue
404
+ if not converged:
405
+ inc *= 0.5
406
+ if inc < min_inc:
407
+ break
408
+ continue
409
+ u, f, K = trial, fi, Ki
410
+ membrane.commit(u, state)
411
+ disp = target
412
+ steps += 1
413
+ strain = disp / length
414
+ if erosion and has_critical: # the crack grows at this displacement
415
+ while len(broken) < max_breaks:
416
+ ratios = membrane.fracture.ratios(membrane.p_n, membrane.alive)
417
+ now = np.flatnonzero(ratios >= 1.0)
418
+ if not now.size:
419
+ break
420
+ # the most critical first, one at a time: the stresses redistribute
421
+ now = now[np.argsort(-ratios[now])][:1]
422
+ membrane.alive[now] = False
423
+ broken.extend(now.tolist())
424
+ broken_at.extend([strain] * len(now))
425
+ ok, trial2, fi2, Ki2, state2, _ = newton(u.copy())
426
+ if not ok: # the element broken, the step kept as it is
427
+ break
428
+ u, f, K = trial2, fi2, Ki2
429
+ membrane.commit(u, state2)
430
+ force = float(f[moved] @ path(disp)[1])
431
+ if record_history:
432
+ history.append((strain, disp, membrane.Fn.copy()))
433
+ ratio = (
434
+ float(membrane.fracture.ratios(membrane.p_n).max())
435
+ if has_critical and not broken
436
+ else (1.0 if broken else 0.0)
437
+ )
438
+ if ratio >= 1.0 and not math.isfinite(failure):
439
+ e_prev = rec["strain"][-1]
440
+ frac = (1.0 - ratio_prev) / max(ratio - ratio_prev, 1e-12)
441
+ failure = e_prev + min(max(frac, 0.0), 1.0) * (strain - e_prev)
442
+ ratio_prev = ratio
443
+ rec["strain"].append(strain)
444
+ rec["stress"].append(force / section)
445
+ rec["force"].append(force)
446
+ rec["displacement"].append(disp)
447
+ for k, fn in (monitors or {}).items():
448
+ mons[k].append(float(fn(u)))
449
+ fmax = max(fmax, force)
450
+ if (
451
+ disp >= max_disp * (1 - 1e-12)
452
+ or (force < (1.0 - drop) * fmax)
453
+ or steps >= max_steps
454
+ or (failure_margin is not None and strain >= failure + failure_margin)
455
+ or (until is not None and until(u))
456
+ ):
457
+ break
458
+ if it <= 4:
459
+ inc *= 1.5
460
+ elif it >= 8:
461
+ inc *= 0.7
462
+ inc = max(min(inc, max_step * max_disp, max_disp - disp), min_inc)
463
+ arr = {k: np.asarray(v) for k, v in rec.items()}
464
+ ys, uts, eu, energy, necked = curve_measures(arr["strain"], arr["stress"])
465
+ fields = {"monitors": {k: np.asarray(v) for k, v in mons.items()}} if monitors else {}
466
+ if erosion:
467
+ fields["broken"] = (np.asarray(broken, dtype=np.int64), np.asarray(broken_at))
468
+ if keep_fields:
469
+ full = getattr(membrane, "full", None) # the nodal displacements of reduced unknowns
470
+ fields.update(
471
+ {
472
+ "mesh": (membrane.mesh.nodes, membrane.mesh.quads),
473
+ "displacement": (u if full is None else full(u)).reshape(-1, 2).copy(),
474
+ "plastic_strain": membrane.p_n.mean(axis=2),
475
+ "stress": membrane.sig_n.mean(axis=2),
476
+ "monitors": {k: np.asarray(v) for k, v in mons.items()},
477
+ }
478
+ )
479
+ return TensileResult(
480
+ strain=arr["strain"],
481
+ stress=arr["stress"],
482
+ force=arr["force"],
483
+ displacement=arr["displacement"],
484
+ yield_strength=ys,
485
+ tensile_strength=uts,
486
+ uniform_elongation=eu,
487
+ energy=energy,
488
+ necked=necked,
489
+ steps=steps,
490
+ iterations=iterations,
491
+ time_s=time.perf_counter() - t0,
492
+ failure_strain=failure,
493
+ history=history,
494
+ fields=fields,
495
+ )
496
+
497
+
498
+ # -- the cases -------------------------------------------------------------------------
499
+
500
+
501
+ @dataclass
502
+ class TensionCase:
503
+ """The tensile test of a specimen (:func:`~morphogen.laser.mechanics.tensile_test`):
504
+ the cells over its parallel part, the tracks continuing to the grips."""
505
+
506
+ specimen: Specimen = field(default_factory=Specimen)
507
+ element: float = 0.5
508
+
509
+ kind = "tension"
510
+ extend = True
511
+ columns = True
512
+
513
+ def __post_init__(self):
514
+ self.specimen = Specimen.from_config(self.specimen)
515
+ self.mesh = self.specimen.mesh(self.element)
516
+ self.thickness = self.specimen.thickness
517
+ self.region = self.specimen.band()
518
+ self.section = self.specimen.width * self.specimen.thickness
519
+ self.springs = None
520
+
521
+ def run(
522
+ self,
523
+ membrane,
524
+ *,
525
+ max_strain=0.35,
526
+ failure_margin=0.03,
527
+ record_history=False,
528
+ keep_fields=True,
529
+ ):
530
+ return tensile_test(
531
+ self.specimen,
532
+ membrane,
533
+ max_strain=max_strain,
534
+ failure_margin=failure_margin,
535
+ record_history=record_history,
536
+ keep_fields=keep_fields,
537
+ )
538
+
539
+
540
+ @dataclass
541
+ class CompactTension:
542
+ """A compact tension specimen (see the module) pulled by its pins: the nominal
543
+ stress ``F / (B W)``, the nominal strain the load-line displacement over ``W``; the
544
+ cells over ``region`` (default: a box around the crack tip and the ligament); the
545
+ crack mouth opening displacement among the monitors; ``refine``: the box of fine
546
+ elements (:func:`ct_mesh`); ``propagate``: the crack grows by the breaking of the
547
+ elements (:func:`load_test` with ``erosion``) until the force has fallen to 5 % of
548
+ its maximum (the specimen separated) or ``max_disp``."""
549
+
550
+ width: float = 20.0
551
+ crack: float = 0.5
552
+ thickness: float = 1.0
553
+ element: float = 1.0
554
+ fine: float = 0.125
555
+ growth: float = 1.2
556
+ region: tuple | None = None
557
+ max_disp: float | None = None
558
+ refine: tuple | None = None
559
+ propagate: bool = False
560
+
561
+ kind = "ct"
562
+ extend = False
563
+ columns = False
564
+
565
+ def __post_init__(self):
566
+ self.domain = ct_mesh(
567
+ self.width,
568
+ self.crack,
569
+ element=self.element,
570
+ fine=self.fine,
571
+ growth=self.growth,
572
+ refine=self.refine,
573
+ )
574
+ self.mesh = self.domain.mesh
575
+ W, a = self.width, self.crack * self.width
576
+ if self.region is None:
577
+ self.region = (a - 0.2 * W, a + 0.4 * W, -0.25 * W, 0.25 * W)
578
+ self.section = self.thickness * W
579
+ self.length = W
580
+ s = self.domain.sets
581
+ pu, pl = s["pins"]
582
+ self.springs = pin_springs(self.domain, 1e3 * 210000.0 * self.thickness)
583
+ self.fixed = np.array([2 * pu, 2 * pl]) # the pins hold x and turn freely
584
+ self.moved = np.array([2 * pu + 1, 2 * pl + 1])
585
+ self.direction = np.array([0.5, -0.5])
586
+ mu, ml = s["mouth_upper"][0], s["mouth_lower"][0]
587
+ self.monitors = {"cmod": lambda u, mu=mu, ml=ml: u[2 * mu + 1] - u[2 * ml + 1]}
588
+
589
+ def run(
590
+ self,
591
+ membrane,
592
+ *,
593
+ max_strain=None,
594
+ failure_margin=0.01,
595
+ record_history=False,
596
+ keep_fields=True,
597
+ ):
598
+ max_disp = self.max_disp or 0.1 * self.width
599
+ if max_strain is not None:
600
+ max_disp = min(max_disp, max_strain * self.width)
601
+ if self.propagate: # the crack grows through the ligament, to separation
602
+ return load_test(
603
+ membrane,
604
+ self.fixed,
605
+ self.moved,
606
+ self.direction,
607
+ length=self.length,
608
+ section=self.section,
609
+ max_disp=max_disp,
610
+ drop=0.95,
611
+ record_history=record_history,
612
+ monitors=self.monitors,
613
+ keep_fields=keep_fields,
614
+ erosion=True,
615
+ max_steps=2000,
616
+ )
617
+ return load_test(
618
+ membrane,
619
+ self.fixed,
620
+ self.moved,
621
+ self.direction,
622
+ length=self.length,
623
+ section=self.section,
624
+ max_disp=max_disp,
625
+ failure_margin=failure_margin,
626
+ record_history=record_history,
627
+ monitors=self.monitors,
628
+ keep_fields=keep_fields,
629
+ )
630
+
631
+
632
+ @dataclass
633
+ class LPlate:
634
+ """An L-shaped plate (see the module) held along its top edge and pulled down at the
635
+ end of its arm: the nominal stress ``F / (t arm)``, the nominal strain the
636
+ displacement over ``size``; the cells over ``region`` (default: around the
637
+ re-entrant corner)."""
638
+
639
+ size: float = 40.0
640
+ arm: float = 16.0
641
+ thickness: float = 1.0
642
+ element: float = 1.0
643
+ fine: float = 0.25
644
+ growth: float = 1.2
645
+ region: tuple | None = None
646
+ max_disp: float | None = None
647
+
648
+ kind = "l_plate"
649
+ extend = False
650
+ columns = False
651
+
652
+ def __post_init__(self):
653
+ self.domain = l_mesh(
654
+ self.size, self.arm, element=self.element, fine=self.fine, growth=self.growth
655
+ )
656
+ self.mesh = self.domain.mesh
657
+ b = self.arm
658
+ if self.region is None:
659
+ self.region = (0.0, 2.0 * b, 0.0, 2.0 * b)
660
+ self.section = self.thickness * b
661
+ self.length = self.size
662
+ top, tip = self.domain.sets["top"], self.domain.sets["tip"]
663
+ self.springs = None
664
+ self.fixed = np.concatenate([2 * top, 2 * top + 1])
665
+ self.moved = 2 * tip + 1
666
+ self.direction = -np.ones(len(tip))
667
+ self.monitors = {}
668
+
669
+ def run(
670
+ self,
671
+ membrane,
672
+ *,
673
+ max_strain=None,
674
+ failure_margin=0.005,
675
+ record_history=False,
676
+ keep_fields=True,
677
+ ):
678
+ max_disp = self.max_disp or 0.1 * self.size
679
+ if max_strain is not None:
680
+ max_disp = min(max_disp, max_strain * self.size)
681
+ return load_test(
682
+ membrane,
683
+ self.fixed,
684
+ self.moved,
685
+ self.direction,
686
+ length=self.length,
687
+ section=self.section,
688
+ max_disp=max_disp,
689
+ failure_margin=failure_margin,
690
+ record_history=record_history,
691
+ keep_fields=keep_fields,
692
+ )
693
+
694
+
695
+ CASES = {"tension": TensionCase, "ct": CompactTension, "l_plate": LPlate}
696
+
697
+
698
+ def case_from_config(data):
699
+ """A case of :data:`CASES` from a mapping (``kind`` and its parameters)."""
700
+ if data is None:
701
+ return None
702
+ if not isinstance(data, dict):
703
+ return data
704
+ d = dict(data)
705
+ kind = d.pop("kind", "tension")
706
+ if kind not in CASES:
707
+ raise ValueError(f"case: one of {sorted(CASES)}")
708
+ return CASES[kind](**d)