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,557 @@
1
+ """Remeshed crack propagation in inelastic solids: the transfer of the state of a body
2
+ between the meshes of successive cracks, and the ductile growth of kinked cracks.
3
+
4
+ *Transfer* (:func:`transfer_state`). A solved body (a
5
+ :class:`~morphogen.fracture.mixed.CrackSolution` whose bulk is the behaviours of
6
+ morphoGen's points, :class:`~morphogen.fracture.bulk.PointBulk`: von Mises
7
+ elasto-viscoplasticity, porous or crystal plasticity, MFront laws) hands its state to the
8
+ mesh of the next crack: the internal variables of its points (one per linear tetrahedron),
9
+ their work density and committed stress, and the displacement of its nodes, the initial
10
+ guess of the next solution. Each point of the new mesh (an element centroid, or a node for
11
+ the displacement) is located in an element of the old mesh (barycentric coordinates, among
12
+ the elements whose centroids are nearest), the two lips of the old crack kept apart:
13
+ behind the old front, a point only takes the values of the elements of its own side (the
14
+ side of its element in the new mesh, or of the elements around a node). Then:
15
+
16
+ * ``"nearest"``: the values of that element (one point per element: the identity onto the
17
+ same mesh, exactly; a transfer that keeps the extreme values but carries the old elements'
18
+ facets into the new mesh);
19
+ * ``"projection"``: the values projected on the nodes of the old mesh (the means of the
20
+ elements around each node weighted by their volumes; the lips, whose nodes are
21
+ duplicated, apart) interpolated at the point: smoother, at the price of some diffusion of
22
+ the peaks of the fields.
23
+
24
+ In a polycrystal (meshes whose elements carry the grains of a tessellation, ``mesh.cell``,
25
+ and their orientations: :func:`~morphogen.fracture.lefm.crack_mesh` with ``grains``), a point
26
+ takes the values of its own grain only, located among its elements and projected on the
27
+ nodes from them (the nodes of a grain boundary have a value per grain): the slips and the
28
+ ``Fp⁻¹`` of the slip systems of a grain, in the axes of its lattice, are never mixed with
29
+ those of a neighbour. The displacement is interpolated linearly (exact for the old field),
30
+ across the grain boundaries. On the crack meshes of a morphology (whose phases are those of
31
+ its materials, the sides of the crack apart: :func:`~morphogen.fracture.lefm.crack_mesh`
32
+ with ``morphology``), the state moves material by material in the same way (the phases of
33
+ one material alike; grains and materials both, when the meshes have both). The ``Fp⁻¹`` of
34
+ crystals, interpolated, is made isochoric again (``det = 1``); the plastic strains of the
35
+ logarithmic space of finite strains, deviatoric, remain so. The strain measure committed
36
+ with the transferred stress is that of the transferred displacement on the new mesh, and
37
+ the work density is the dissipated part moved plus the free energy of the new state; the
38
+ transferred state, not in equilibrium on the new mesh, is brought to it at the load of the
39
+ transfer before the loading resumes (``CohesiveProblem.run(initial=..., start=...)``:
40
+ Newton's method over a vanishing time, the plastic correction of the points included, in
41
+ one step from the transferred state), which dissipates nothing: the dissipated energy moved
42
+ is kept and the free energy is that of the equilibrium.
43
+
44
+ *Ductile growth* (:func:`propagate_ductile`): at each load step (a fraction of the load
45
+ factor) the body is loaded further from its committed state; once the crack driving force
46
+ at the tip, ``J_tip`` (:meth:`~morphogen.fracture.mixed.CrackSolution.release_rate` with
47
+ ``energy="tip"``: the free energy and the configurational forces of the internal variables)
48
+ reaches the ``toughness``, or the porosity of the porous points near the tip reaches a
49
+ critical value (the local approach of ductile fracture: Rousselier 1987; Pineau 2006), the
50
+ front advances by an increment in the direction of kinking (the interaction integrals of
51
+ the elastic estimates), the body is meshed again for the new crack (a front grown into a
52
+ pore going through it), its state transferred and brought to equilibrium, and the
53
+ criterion checked again before the load grows. With a toughness of the phases and of their
54
+ interfaces (:mod:`morphogen.fracture.toughness`), ``J_tip`` is held against the toughness of
55
+ the phase at the front and the advance is the candidate of the largest ``G(θ) / Γ(θ)``, the
56
+ kink of the bulk or a deflection along an interface ahead, once that ratio reaches 1. The far
57
+ driving force at each advance against the advance draws the resistance curve: ``J_ψ`` on a
58
+ domain around the front (``energy="free"``: the configurational force of the free energy
59
+ on the domain, ``J_tip`` plus the shielding of the internal variables inside it, the
60
+ ``J_far`` of Simha, Fischer, Shan, Chen & Kolednik 2008), which rises as the plastic wake
61
+ of the growing crack shields its tip. The J of the deformation theory (``energy="work"``),
62
+ the measure of the loading of a stationary crack, is kept too; once the wake unloads it
63
+ depends on the domain.
64
+ """
65
+
66
+ from __future__ import annotations
67
+
68
+ import copy
69
+ import math
70
+ from dataclasses import dataclass, field
71
+
72
+ import numpy as np
73
+
74
+ from morphogen.fracture.cohesive import CohesiveProblem, Contact, Interfaces
75
+ from morphogen.fracture.lefm import crack_faces
76
+ from morphogen.fracture.mixed import (
77
+ CrackSolution,
78
+ _as_materials,
79
+ element_sides,
80
+ kink_angle,
81
+ material_groups,
82
+ through_voids,
83
+ )
84
+ from morphogen.mesh.tetra import TetMesh
85
+
86
+ #: Methods of transfer of the state of the points
87
+ METHODS = ("nearest", "projection")
88
+
89
+
90
+ def _labels_of_elements(mesh: TetMesh, crack, old_crack) -> np.ndarray:
91
+ """The side of each element behind the front of ``old_crack`` (``crack`` gives the sides
92
+ of the elements of ``mesh``), 0 ahead of it."""
93
+ centroids = mesh.nodes[mesh.elements[:, :4]].mean(axis=1)
94
+ return element_sides(mesh, crack) * (old_crack.psi(centroids) < 0)
95
+
96
+
97
+ def _labels_of_nodes(mesh: TetMesh, element_labels: np.ndarray) -> np.ndarray:
98
+ """The side of each node: that of the elements around it when they all have it, 0
99
+ otherwise."""
100
+ n = mesh.n_nodes
101
+ corners = mesh.elements[:, :4]
102
+ plus = np.bincount(corners.ravel(), np.repeat(element_labels > 0, 4), minlength=n)
103
+ minus = np.bincount(corners.ravel(), np.repeat(element_labels < 0, 4), minlength=n)
104
+ return np.where((plus > 0) & (minus == 0), 1.0, np.where((minus > 0) & (plus == 0), -1.0, 0.0))
105
+
106
+
107
+ def locate(points, mesh: TetMesh, point_labels=None, element_labels=None, k: int = 16,
108
+ point_groups=None, element_groups=None): # fmt: skip
109
+ """The element of ``mesh`` (linear tetrahedra) containing each point (rows) and its
110
+ barycentric coordinates there (points x 4), among the ``k`` elements whose centroids are
111
+ nearest and whose labels agree with the point's (a label 0 agrees with every one) and,
112
+ with ``point_groups`` and ``element_groups`` (grains), of its group (always, unless no
113
+ element of ``mesh`` is); points outside every candidate take the nearest one, their
114
+ coordinates clipped."""
115
+ from scipy.spatial import cKDTree
116
+
117
+ points = np.atleast_2d(np.asarray(points, dtype=float))
118
+ x = mesh.nodes[mesh.elements[:, :4]]
119
+ origin = x[:, 0]
120
+ inverse = np.linalg.inv(
121
+ np.stack([x[:, 1] - origin, x[:, 2] - origin, x[:, 3] - origin], axis=2)
122
+ )
123
+ tree = cKDTree(x.mean(axis=1))
124
+ n = len(points)
125
+ if point_labels is None:
126
+ point_labels = np.zeros(n)
127
+ if element_labels is None:
128
+ element_labels = np.zeros(mesh.n_elements)
129
+ groups = point_groups is not None and element_groups is not None
130
+ if groups:
131
+ point_groups = np.asarray(point_groups)
132
+ element_groups = np.asarray(element_groups)
133
+ chosen = np.zeros(n, dtype=np.int64)
134
+ bary = np.zeros((n, 4))
135
+ todo = np.arange(n)
136
+ for count in (k, 4 * k, None):
137
+ if count is None: # no candidate on the right side: the labels dropped
138
+ point_labels = np.zeros(n)
139
+ count = 4 * k
140
+ count = min(count, mesh.n_elements)
141
+ _, candidates = tree.query(points[todo], k=count)
142
+ candidates = candidates.reshape(len(todo), count)
143
+ local = np.einsum("nkij,nkj->nki", inverse[candidates],
144
+ points[todo, None, :] - origin[candidates]) # fmt: skip
145
+ coordinates = np.concatenate([1.0 - local.sum(axis=2, keepdims=True), local], axis=2)
146
+ mine = element_labels[candidates]
147
+ agree = (mine == 0) | (point_labels[todo, None] == 0) | (mine == point_labels[todo, None])
148
+ if groups:
149
+ agree &= element_groups[candidates] == point_groups[todo, None]
150
+ score = np.where(agree, coordinates.min(axis=2), -np.inf)
151
+ best = np.argmax(score, axis=1)
152
+ rows = np.arange(len(todo))
153
+ found = np.isfinite(score[rows, best])
154
+ chosen[todo[found]] = candidates[rows, best][found]
155
+ bary[todo[found]] = coordinates[rows, best][found]
156
+ todo = todo[~found]
157
+ if not len(todo):
158
+ break
159
+ if groups and len(todo): # far from the elements of their group: its nearest one
160
+ centroids = x.mean(axis=1)
161
+ for g in np.unique(point_groups[todo]):
162
+ members = np.flatnonzero(element_groups == g)
163
+ if not len(members): # a group that the mesh does not resolve: any element
164
+ members = np.arange(mesh.n_elements)
165
+ rows = todo[point_groups[todo] == g]
166
+ _, near = cKDTree(centroids[members]).query(points[rows])
167
+ chosen[rows] = members[near]
168
+ local = np.einsum(
169
+ "nij,nj->ni", inverse[chosen[rows]], points[rows] - origin[chosen[rows]]
170
+ )
171
+ bary[rows] = np.concatenate([1.0 - local.sum(axis=1, keepdims=True), local], axis=1)
172
+ bary = np.clip(bary, 0.0, None)
173
+ return chosen, bary / bary.sum(axis=1, keepdims=True)
174
+
175
+
176
+ def _nodal(mesh: TetMesh, values: np.ndarray, mask=None) -> np.ndarray:
177
+ """Element values (elements x m) projected on the nodes: the means of the elements
178
+ around each node weighted by their volumes (the elements of ``mask`` only)."""
179
+ corners = mesh.elements[:, :4]
180
+ if mask is not None:
181
+ corners, values = corners[mask], values[mask]
182
+ x = mesh.nodes[corners]
183
+ volumes = np.abs(np.einsum("ij,ij->i", x[:, 1] - x[:, 0],
184
+ np.cross(x[:, 2] - x[:, 0], x[:, 3] - x[:, 0]))) / 6.0 # fmt: skip
185
+ weight = np.bincount(corners.ravel(), np.repeat(volumes, 4), minlength=mesh.n_nodes)
186
+ out = np.zeros((mesh.n_nodes, values.shape[1]))
187
+ for a in range(4):
188
+ np.add.at(out, corners[:, a], volumes[:, None] * values)
189
+ return out / np.where(weight > 0, weight, 1.0)[:, None]
190
+
191
+
192
+ def transfer_displacement(source: CrackSolution, mesh: TetMesh, crack) -> np.ndarray:
193
+ """The displacement (nodes x 3) of a solved body interpolated at the nodes of the mesh
194
+ of another crack (see the module)."""
195
+ old = source.mesh
196
+ old_labels = _labels_of_elements(old, source.crack, source.crack)
197
+ new_labels = _labels_of_elements(mesh, crack, source.crack)
198
+ element, bary = locate(mesh.nodes, old, _labels_of_nodes(mesh, new_labels), old_labels)
199
+ corners = old.elements[element, :4]
200
+ return np.einsum("na,nac->nc", bary, source.displacement[corners])
201
+
202
+
203
+ def transfer_state(source: CrackSolution, mesh: TetMesh, bulk, crack, method: str = "projection"):
204
+ """The state of a solved inelastic body (its :class:`~morphogen.fracture.bulk.PointBulk`)
205
+ transferred to the ``bulk`` of the opened ``mesh`` of ``crack`` (see the module): the
206
+ internal variables, the work densities and the committed stresses of its points by
207
+ ``method`` (``"nearest"`` or ``"projection"``), the strain measures of the transferred
208
+ displacement, which it returns (nodes x 3)."""
209
+ if method not in METHODS:
210
+ raise ValueError(f"transfer: {METHODS}")
211
+ if source.bulk is None:
212
+ raise ValueError("transfer_state: the source has no bulk of points (an elastic body)")
213
+ old, before = source.mesh, source.bulk
214
+ if before.old.shape[1] != bulk.old.shape[1] or before.finite != bulk.finite:
215
+ raise ValueError("transfer_state: other behaviours or kinematics")
216
+ old_labels = _labels_of_elements(old, source.crack, source.crack)
217
+ new_labels = _labels_of_elements(mesh, crack, source.crack)
218
+ centroids = mesh.nodes[mesh.elements[:, :4]].mean(axis=1)
219
+ grains = old.cell is not None and mesh.cell is not None # a polycrystal: grain by grain
220
+ if grains and not _same_orientations(old, mesh):
221
+ raise ValueError("transfer_state: the grains of the two meshes differ")
222
+ old_groups, new_groups = _groups(old, mesh, bulk.materials) # by grain, by material
223
+ element, bary = locate(centroids, old, new_labels, old_labels, point_groups=new_groups,
224
+ element_groups=old_groups) # fmt: skip
225
+ dissipated = before.work - before.free_energy() # NaN for MFront laws: their work moves
226
+ fields = np.hstack([before.old, before.work[:, None], np.nan_to_num(dissipated)[:, None],
227
+ before.committed_stress]) # fmt: skip
228
+ if method == "nearest":
229
+ moved = fields[element]
230
+ elif old_groups is not None: # projected on the nodes from the elements of each group
231
+ moved = np.empty((len(element), fields.shape[1]))
232
+ for g in np.unique(old_groups[element]):
233
+ nodal = _nodal(old, fields, old_groups == g)
234
+ rows = np.flatnonzero(old_groups[element] == g)
235
+ corners = old.elements[element[rows], :4]
236
+ moved[rows] = np.einsum("na,nam->nm", bary[rows], nodal[corners])
237
+ else:
238
+ nodal = _nodal(old, fields)
239
+ moved = np.einsum("na,nam->nm", bary, nodal[old.elements[element, :4]])
240
+ width = before.old.shape[1]
241
+ state = moved[:, :width].copy()
242
+ if method == "projection" and bulk.finite: # Fp⁻¹ of crystals isochoric again
243
+ from morphogen.homogenization.behaviours import CRYSTAL
244
+ from morphogen.homogenization.crystal import CP_ALPHA
245
+
246
+ crystal = np.flatnonzero(bulk.kind == CRYSTAL)
247
+ if len(crystal):
248
+ slips = bulk.behaviours.data[7][bulk.pmat[crystal]]
249
+ for row, ns in zip(crystal, slips, strict=True):
250
+ off = CP_ALPHA + 2 * int(ns)
251
+ g = state[row, off : off + 9].reshape(3, 3) + np.eye(3)
252
+ g /= np.cbrt(np.linalg.det(g))
253
+ state[row, off : off + 9] = (g - np.eye(3)).ravel()
254
+ bulk.old[...] = state
255
+ bulk.new[...] = state
256
+ bulk.committed_stress[...] = moved[:, width + 2 :]
257
+ displacement = transfer_displacement(source, mesh, crack)
258
+ from morphogen.homogenization import finite as fin
259
+ from morphogen.homogenization.nonlinear import _point_strains
260
+
261
+ kernel = fin.point_gradients if bulk.finite else _point_strains
262
+ kernel(mesh.nodes, mesh.elements, 1, np.ascontiguousarray(displacement.ravel()), bulk.gp,
263
+ bulk.gw, bulk.grads, bulk.wts) # fmt: skip
264
+ bulk.committed_grads[...] = bulk.grads
265
+ # the work density: the dissipated part moves, the free energy is that of the new state
266
+ free = bulk.free_energy()
267
+ bulk.work[...] = np.where(np.isfinite(free), moved[:, width + 1] + free, moved[:, width])
268
+ return displacement
269
+
270
+
271
+ def _groups(old: TetMesh, new: TetMesh, materials: dict):
272
+ """The groups of the elements of two meshes between which the state of the points never
273
+ moves (None, None: no groups): the grains of polycrystals (``cell``), the materials of
274
+ the phases of the crack meshes of a morphology (whose sides are ``side``; phases of the
275
+ same material alike), or both."""
276
+ grains = old.cell is not None and new.cell is not None
277
+ phases = old.side is not None and new.side is not None
278
+ if not (grains or phases):
279
+ return None, None
280
+ count = 1 + int(max(old.phase.max(), new.phase.max())) if phases else 1
281
+ out = []
282
+ for m in (old, new):
283
+ g = np.zeros(m.n_elements, dtype=np.int64)
284
+ if phases:
285
+ g += material_groups(m.phase, materials)
286
+ if grains:
287
+ g += count * m.cell
288
+ out.append(g)
289
+ return out[0], out[1]
290
+
291
+
292
+ def _same_orientations(a: TetMesh, b: TetMesh) -> bool:
293
+ """Whether two meshes have the same crystal orientations of their cells."""
294
+ if a.orientations is None or b.orientations is None:
295
+ return a.orientations is None and b.orientations is None
296
+ return a.orientations.shape == b.orientations.shape and np.allclose(a.orientations,
297
+ b.orientations) # fmt: skip
298
+
299
+
300
+ def dissipation(solution: CrackSolution) -> float:
301
+ """The energy dissipated in the bulk of a solved body: its work less its free energy
302
+ (stored elastically and by hardening)."""
303
+ return solution.energy("work") - solution.energy("free")
304
+
305
+
306
+ # -- ductile growth ------------------------------------------------------------------------
307
+
308
+
309
+ @dataclass
310
+ class DuctileGrowth:
311
+ """A ductile growth (see the module): the cracks at each advance, the load factors of
312
+ the advances, the driving forces at the tip (``tip``) and far from it (``far``, ``J_ψ``
313
+ on the domain; ``work``, the J of the deformation theory), the stress intensity factors
314
+ of the elastic estimates (advances x 3), the angles of the advances, every load step
315
+ (``history``: rows of the advance, the load, the driving forces and the porosity near
316
+ the tip), with ``keep`` the solutions of the advances, and with a toughness of the
317
+ phases or of their interfaces the advances chosen (``advances``: the
318
+ :class:`~morphogen.fracture.toughness.Advance` of each crack; that of the last one is
319
+ not taken)."""
320
+
321
+ cracks: list
322
+ loads: np.ndarray
323
+ tip: np.ndarray
324
+ far: np.ndarray
325
+ work: np.ndarray
326
+ factors: np.ndarray
327
+ angles: np.ndarray
328
+ history: list
329
+ solutions: list = field(default_factory=list, repr=False)
330
+ advances: list = field(default_factory=list, repr=False)
331
+
332
+ def rows(self) -> list[dict]:
333
+ """One row per advance: the length, the advance, the load factor, the driving
334
+ forces, the factors and the angle (and with a toughness of the phases or of their
335
+ interfaces, the bulk or an interface, what it meets, its toughness and its ratio
336
+ ``G(θ) / Γ(θ)``)."""
337
+ from morphogen.fracture.mixed import _advance_columns
338
+
339
+ base = self.cracks[0].size if self.cracks else 0.0
340
+ rows = [
341
+ {"advance": k, "length": c.size, "delta_a": c.size - base, "load": float(lam),
342
+ "J_tip": float(jt), "J_far": float(jf), "J_work": float(jw), "K_I": float(f[0]),
343
+ "K_II": float(f[1]), "K_III": float(f[2]), "angle_deg": math.degrees(a)}
344
+ for k, (c, lam, jt, jf, jw, f, a) in enumerate(zip(
345
+ self.cracks, self.loads, self.tip, self.far, self.work, self.factors,
346
+ self.angles, strict=True))
347
+ ] # fmt: skip
348
+ if self.advances:
349
+ for row, advance in zip(rows, self.advances, strict=True):
350
+ row.update(_advance_columns(advance))
351
+ return rows
352
+
353
+ def resistance(self):
354
+ """The resistance curve: the advances of the crack and the far driving forces."""
355
+ base = self.cracks[0].size if self.cracks else 0.0
356
+ return np.array([c.size - base for c in self.cracks]), np.asarray(self.far)
357
+
358
+
359
+ def _problem(mesh, crack, materials, kinematics, contact, bulk):
360
+ """The opened mesh of a crack, its lips and its cohesive problem (as
361
+ :func:`~morphogen.fracture.mixed.solve_crack`)."""
362
+ opened, faces = crack_faces(mesh, crack)
363
+ materials = _as_materials(materials, opened)
364
+ if contact:
365
+ interfaces, law = faces, Contact(float(contact))
366
+ else:
367
+ empty = np.zeros((0, 3), dtype=np.int64)
368
+ interfaces, law = Interfaces(empty, empty, np.zeros((0, 2), dtype=np.int64)), Contact(1.0)
369
+ problem = CohesiveProblem(opened, interfaces, materials, law, kinematics=kinematics, bulk=bulk)
370
+ return opened, faces, materials, problem
371
+
372
+
373
+ def _snapshot(solution: CrackSolution) -> CrackSolution:
374
+ """A solution whose bulk keeps its state when the problem goes on."""
375
+ out = copy.copy(solution)
376
+ if solution.bulk is not None:
377
+ bulk = copy.copy(solution.bulk)
378
+ for name in ("old", "new", "work", "committed_stress", "committed_grads"):
379
+ setattr(bulk, name, getattr(solution.bulk, name).copy())
380
+ out.bulk = bulk
381
+ out._cache = {}
382
+ return out
383
+
384
+
385
+ def _tip_porosity(solution: CrackSolution, radius: float) -> float:
386
+ """The largest porosity of the porous points within ``radius`` of the front (0 without
387
+ porous points)."""
388
+ bulk = solution.bulk
389
+ if bulk is None:
390
+ return 0.0
391
+ from morphogen.homogenization.behaviours import POROUS
392
+ from morphogen.homogenization.porous import porosity
393
+
394
+ mesh = solution.mesh
395
+ r = solution.crack.frame(mesh.nodes[mesh.elements].mean(axis=1))[0]
396
+ near = (bulk.kind == POROUS) & (r < radius)
397
+ if not near.any():
398
+ return 0.0
399
+ return float(porosity(bulk.old[near], bulk.behaviours.data[2], bulk.pmat[near]).max())
400
+
401
+
402
+ def propagate_ductile(
403
+ mesh_of,
404
+ crack,
405
+ materials,
406
+ prescribed,
407
+ *,
408
+ load_step: float,
409
+ increment: float,
410
+ steps: int,
411
+ toughness=None,
412
+ porosity: float | None = None,
413
+ max_load: float = math.inf,
414
+ kinematics: str = "small",
415
+ transfer: str = "projection",
416
+ solver_steps: int = 2,
417
+ radius: float | None = None,
418
+ domain: tuple | None = None,
419
+ forces=None,
420
+ contact: float | None = None,
421
+ bulk: str = "auto",
422
+ kink: bool = True,
423
+ keep: bool = False,
424
+ **options,
425
+ ) -> DuctileGrowth:
426
+ """Grow a crack in an inelastic body (see the module): ``mesh_of(crack)`` meshes the body
427
+ conforming to it (:func:`~morphogen.fracture.lefm.crack_mesh`), ``prescribed`` (entries,
428
+ or a function of the opened mesh) and ``forces`` (nodal forces, or a function of the
429
+ opened mesh) are grown by ``load_step`` of the load factor in ``solver_steps`` steps
430
+ between the checks of the criterion: ``J_tip >= toughness``, or the porosity of the porous
431
+ points within ``radius`` of the front (by default 1.5 element) ``>= porosity``; each of
432
+ the ``steps`` advances the front by ``increment`` in the direction of kinking (straight
433
+ with ``kink=False``), the state transferred by ``transfer`` (``"nearest"`` or
434
+ ``"projection"``); the far driving forces on the ``domain`` ``(r_in, r_out)`` (by
435
+ default that of ``release_rate``: 1 to 4 elements); the loading stops at ``max_load``;
436
+ ``options`` those of
437
+ :meth:`~morphogen.fracture.cohesive.CohesiveProblem.run` (``tol``, ``max_newton``...),
438
+ but ``duration`` is the time of a unit of the load factor (by default 1: the load factor
439
+ is the time of the viscous behaviours), the same over all the loadings.
440
+
441
+ ``toughness``: one value, or a :class:`~morphogen.fracture.toughness.Toughness` of the
442
+ phases and of their interfaces (or a dict of the phases): the criterion is then, at each
443
+ load step, the largest ratio ``G(θ) / Γ(θ)`` of the candidate advances reaching 1
444
+ (:func:`~morphogen.fracture.toughness.advance_candidates`, the bulk taking ``J_tip``:
445
+ ``J_tip`` against the toughness of the phase at the front, unless the advance enters a
446
+ tougher phase within the increment or an interface ahead is more favourable), and the
447
+ advance is that candidate (``kink=False``: the bulk straight ahead)."""
448
+ from morphogen.fracture.toughness import (
449
+ Toughness,
450
+ advance_candidates,
451
+ choose_advance,
452
+ interface_paths,
453
+ )
454
+
455
+ if toughness is None and porosity is None:
456
+ raise ValueError("propagate_ductile: a toughness or a critical porosity")
457
+ if not (load_step > 0 and increment > 0):
458
+ raise ValueError("propagate_ductile: a positive load step and increment")
459
+ if transfer not in METHODS:
460
+ raise ValueError(f"transfer: {METHODS}")
461
+ rule = None if toughness is None or np.isscalar(toughness) else Toughness.of(toughness)
462
+ staged = rule is not None and not rule.uniform # the candidates at each load step
463
+ if rule is not None and rule.uniform:
464
+ toughness = rule.value
465
+ unit = options.pop("duration", None)
466
+
467
+ def timed(target): # run() spreads its duration over the loading from 0 to its target
468
+ return {} if unit is None else {"duration": float(unit) * target}
469
+
470
+ cracks, loads, tips, fars, works, factors, angles = [], [], [], [], [], [], []
471
+ history, solutions, advances = [], [], []
472
+ r_in, r_out = (None, None) if domain is None else domain
473
+ lam, previous = 0.0, None
474
+ finite = kinematics == "finite"
475
+ for advance in range(int(steps) + 1):
476
+ opened, faces, mats, problem = _problem(mesh_of(crack), crack, materials, kinematics,
477
+ contact, bulk) # fmt: skip
478
+ entries = prescribed(opened) if callable(prescribed) else prescribed
479
+ dead = forces(opened) if callable(forces) else forces
480
+ common = {**options, "forces": dead}
481
+ solution = paths = None
482
+ if previous is not None: # the state of the last crack, brought to equilibrium
483
+ if problem.bulk is not None:
484
+ u = transfer_state(previous, opened, problem.bulk, crack, transfer)
485
+ else:
486
+ u = transfer_displacement(previous, opened, crack)
487
+ result = problem.run(entries, lam, steps=1, start=lam, initial=u, **common,
488
+ **timed(lam)) # fmt: skip
489
+ while True:
490
+ target = min(lam + load_step, max_load)
491
+ if previous is None and solution is None: # the first loading, from rest
492
+ result = problem.run(entries, target, steps=solver_steps, **common,
493
+ **timed(target)) # fmt: skip
494
+ elif solution is not None: # a further load step
495
+ result = problem.run(entries, target, steps=solver_steps, start=lam,
496
+ initial=solution.displacement, equilibrate=False,
497
+ **common, **timed(target)) # fmt: skip
498
+ lam = float(result.loads[-1])
499
+ final = None if dead is None else lam * np.asarray(dead, dtype=float).ravel()
500
+ solution = CrackSolution(opened, faces, crack, mats, finite, result.displacement,
501
+ result, final, contact, bulk=problem.bulk) # fmt: skip
502
+ size = solution.element_size()
503
+ j_tip = solution.release_rate(energy="tip")
504
+ j_far = solution.release_rate(r_in, r_out, energy="free")
505
+ j_work = solution.release_rate(r_in, r_out, energy="work")
506
+ f_tip = _tip_porosity(solution, 1.5 * size if radius is None else float(radius))
507
+ row = {"advance": advance, "load": lam, "J_tip": j_tip, "J_far": j_far,
508
+ "J_work": j_work, "porosity_tip": f_tip} # fmt: skip
509
+ if staged: # the candidate advances, the bulk taking J_tip
510
+ modes = _modes(solution)
511
+ if paths is None: # the interfaces ahead: one mesh, one crack
512
+ paths = interface_paths(solution, rule, increment)
513
+ choice = choose_advance(advance_candidates(solution, rule, increment,
514
+ modes=modes, driving=j_tip,
515
+ kink=kink, paths=paths)) # fmt: skip
516
+ row["ratio"] = choice.ratio
517
+ broken = choice.ratio >= 1.0
518
+ else:
519
+ broken = toughness is not None and j_tip >= toughness
520
+ history.append(row)
521
+ met = broken or (porosity is not None and f_tip >= porosity)
522
+ if met or lam >= max_load:
523
+ break
524
+ if staged:
525
+ k = (modes["K_I"], modes["K_II"], modes["K_III"])
526
+ angle, grown = choice.angle, choice.crack
527
+ advances.append(choice)
528
+ else:
529
+ k = tuple(_modes(solution)[key] for key in ("K_I", "K_II", "K_III"))
530
+ angle = kink_angle(k[0], k[1]) if kink and np.all(np.isfinite(k[:2])) else 0.0
531
+ grown = crack.grown(increment, angle)
532
+ cracks.append(crack)
533
+ loads.append(lam)
534
+ tips.append(j_tip)
535
+ fars.append(j_far)
536
+ works.append(j_work)
537
+ factors.append(k)
538
+ angles.append(angle)
539
+ if keep:
540
+ solutions.append(_snapshot(solution))
541
+ if advance == steps or not met:
542
+ break
543
+ previous = solution
544
+ crack = through_voids(grown, solution.mesh, increment)
545
+ return DuctileGrowth(cracks, np.array(loads), np.array(tips), np.array(fars),
546
+ np.array(works), np.array(factors), np.array(angles), history,
547
+ solutions, advances) # fmt: skip
548
+
549
+
550
+ def _modes(solution: CrackSolution) -> dict:
551
+ """The modes of a solved body (the elastic estimates of its interaction integrals), NaN
552
+ without isotropic elasticity at the front."""
553
+ try:
554
+ return solution.modes()
555
+ except (TypeError, ValueError): # no isotropic elasticity at the front
556
+ keys = ("K_I", "K_II", "K_III", "G", "G_I", "G_II", "G_III", "angle")
557
+ return dict.fromkeys(keys, math.nan)