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,572 @@
1
+ """Cracks of any surface and front in 3D: the surface swept by the successive positions of
2
+ a front, which advances by its own amount and kinks by its own angle at each of its
3
+ points.
4
+
5
+ The planar cracks of :mod:`morphogen.fracture.lefm` have a straight or circular front that
6
+ advances uniformly, and the kinked cracks of :mod:`morphogen.fracture.mixed` a path in a
7
+ plane, the same all along a straight front. A :class:`SurfaceCrack` is a grid of points,
8
+ ``rows x stations``: each row a position of the front, from the centre of the crack (a
9
+ closed front: a crack inside the body, such as an ellipse) or from its mouth (an open
10
+ front, which leaves the body by its two ends: a through, edge or surface crack) to the
11
+ front, the last row; each station follows its own path across the rows. Between the rows
12
+ the surface is that of the triangles of the grid.
13
+
14
+ *Front.* At each station the tangent ``τ`` of the front (along the stations), the
15
+ direction of propagation ``d`` (that of the last move of the station, made normal to
16
+ ``τ``) and the normal ``n = d × τ`` of the surface: the axes ``(d, n, t = d × n)`` of the
17
+ asymptotic fields. They are interpolated along the front, whose curvature the auxiliary
18
+ fields of the interaction integrals then see (Gosz & Moran 2002). A point has the
19
+ coordinates ``x1 = (x - f) · d`` and ``x2 = (x - f) · n`` from its nearest point ``f`` of the
20
+ front: ``ψ = x1`` (negative behind the front), and ``φ`` the signed distance to the
21
+ triangles behind the front and ``x2`` ahead of it, the surface continued along ``d``: the
22
+ two level sets that the conforming meshes and the opening of the lips take
23
+ (:func:`~morphogen.fracture.lefm.crack_mesh`, :func:`~morphogen.fracture.lefm.crack_faces`).
24
+ An open front is continued beyond its ends, and its surface behind its mouth.
25
+
26
+ *Growth* (:meth:`SurfaceCrack.grown`): a new row, each station moved by its advance at its
27
+ angle from ``d`` towards ``n``. :func:`propagate_front` solves the body on a mesh rebuilt
28
+ for each crack, takes the energy release rate and the stress intensity factors at
29
+ stations along the front (:meth:`~morphogen.fracture.mixed.CrackSolution.modes`), and
30
+ moves each point of the front in the direction of the largest hoop stress of its own
31
+ ``K_I`` and ``K_II`` (Erdogan & Sih 1963), by an advance that grows with its own energy
32
+ release rate, ``da = Δa (G / G_max)^(m / 2)`` (Paris' law ``da/dN = C ΔK^m`` for the
33
+ cycles that advance the fastest point by ``Δa``): an elliptical crack in tension grows
34
+ towards a circle, a crack inclined to the load turns its surface towards the plane normal
35
+ to it, by a different angle at each point of its front.
36
+ """
37
+
38
+ from __future__ import annotations
39
+
40
+ import math
41
+ from dataclasses import dataclass, field
42
+
43
+ import numpy as np
44
+ from numba import njit, prange
45
+
46
+ #: How far the surface of an open crack is continued beyond the ends of its front and
47
+ #: behind its mouth, in units of its size
48
+ FAR = 1e3
49
+
50
+ _COUNT = 400 # points of the front
51
+
52
+
53
+ @njit(cache=True)
54
+ def _closest_on_triangle(p, a, b, c):
55
+ """The barycentric coordinates of the point of the triangle ``abc`` nearest ``p``
56
+ (Ericson 2005)."""
57
+ ab, ac, ap = b - a, c - a, p - a
58
+ d1, d2 = ab @ ap, ac @ ap
59
+ if d1 <= 0.0 and d2 <= 0.0:
60
+ return 1.0, 0.0, 0.0
61
+ bp = p - b
62
+ d3, d4 = ab @ bp, ac @ bp
63
+ if d3 >= 0.0 and d4 <= d3:
64
+ return 0.0, 1.0, 0.0
65
+ vc = d1 * d4 - d3 * d2
66
+ if vc <= 0.0 and d1 >= 0.0 and d3 <= 0.0:
67
+ v = d1 / (d1 - d3)
68
+ return 1.0 - v, v, 0.0
69
+ cp = p - c
70
+ d5, d6 = ab @ cp, ac @ cp
71
+ if d6 >= 0.0 and d5 <= d6:
72
+ return 0.0, 0.0, 1.0
73
+ vb = d5 * d2 - d1 * d6
74
+ if vb <= 0.0 and d2 >= 0.0 and d6 <= 0.0:
75
+ w = d2 / (d2 - d6)
76
+ return 1.0 - w, 0.0, w
77
+ va = d3 * d6 - d5 * d4
78
+ if va <= 0.0 and (d4 - d3) >= 0.0 and (d5 - d6) >= 0.0:
79
+ w = (d4 - d3) / ((d4 - d3) + (d5 - d6))
80
+ return 0.0, 1.0 - w, w
81
+ denom = 1.0 / (va + vb + vc)
82
+ v, w = vb * denom, vc * denom
83
+ return 1.0 - v - w, v, w
84
+
85
+
86
+ @njit(parallel=True, cache=True)
87
+ def _signed_distance(points, vertices, triangles, normals):
88
+ """The distance of each point to the triangles (rows of three vertices), signed by
89
+ the normal of the surface interpolated at its nearest point (``normals``: those of
90
+ the vertices)."""
91
+ out = np.empty(len(points))
92
+ for i in prange(len(points)):
93
+ p = points[i]
94
+ best = np.inf
95
+ side = 1.0
96
+ for k in range(len(triangles)):
97
+ a = vertices[triangles[k, 0]]
98
+ b = vertices[triangles[k, 1]]
99
+ c = vertices[triangles[k, 2]]
100
+ u, v, w = _closest_on_triangle(p, a, b, c)
101
+ q = p - (u * a + v * b + w * c)
102
+ d2 = q @ q
103
+ if d2 < best:
104
+ best = d2
105
+ normal = (
106
+ u * normals[triangles[k, 0]]
107
+ + v * normals[triangles[k, 1]]
108
+ + w * normals[triangles[k, 2]]
109
+ )
110
+ side = 1.0 if q @ normal >= 0.0 else -1.0
111
+ out[i] = side * math.sqrt(best)
112
+ return out
113
+
114
+
115
+ @njit(parallel=True, cache=True)
116
+ def _nearest_on_front(points, front, closed):
117
+ """The segment of the front nearest each point and the position along it (0 at its
118
+ first station, 1 at its second; beyond them on the end segments of an open front,
119
+ which are continued)."""
120
+ m = len(front)
121
+ count = m if closed else m - 1
122
+ segment = np.empty(len(points), dtype=np.int64)
123
+ position = np.empty(len(points))
124
+ for i in prange(len(points)):
125
+ p = points[i]
126
+ best = np.inf
127
+ for k in range(count):
128
+ a = front[k]
129
+ e = front[(k + 1) % m] - a
130
+ u = ((p - a) @ e) / (e @ e)
131
+ low = -np.inf if (not closed and k == 0) else 0.0
132
+ high = np.inf if (not closed and k == count - 1) else 1.0
133
+ u = min(max(u, low), high)
134
+ q = p - a - u * e
135
+ d2 = q @ q
136
+ if d2 < best:
137
+ best = d2
138
+ segment[i] = k
139
+ position[i] = u
140
+ return segment, position
141
+
142
+
143
+ def _unit(v: np.ndarray) -> np.ndarray:
144
+ return v / np.maximum(np.linalg.norm(v, axis=-1, keepdims=True), 1e-300)
145
+
146
+
147
+ class SurfaceCrack:
148
+ """A crack of any surface (see the module): ``points`` (rows x stations x 3), the
149
+ successive positions of its front from its centre (``closed``: the stations go round
150
+ a front inside the body; the first row may be one point repeated) or from its mouth
151
+ (an open front, whose first and last stations lie outside the body or on its
152
+ boundary); the front is the last row. With the normal ``n`` of the surface towards
153
+ the reader, the stations of a closed front go anticlockwise."""
154
+
155
+ curved = True # the auxiliary fields of the interaction integrals turn along the front
156
+
157
+ def __init__(self, points, closed: bool = True) -> None:
158
+ p = np.array(points, dtype=float)
159
+ if p.ndim != 3 or p.shape[2] != 3 or p.shape[0] < 2 or p.shape[1] < (3 if closed else 2):
160
+ raise ValueError(
161
+ "SurfaceCrack: points (rows x stations x 3), two rows at least, three "
162
+ "stations around a closed front (two along an open one)"
163
+ )
164
+ if not np.all(np.isfinite(p)):
165
+ raise ValueError("SurfaceCrack: finite points")
166
+ p.setflags(write=False)
167
+ self.points = p
168
+ self.closed = bool(closed)
169
+ front = p[-1]
170
+ step = np.roll(front, -1, axis=0) - front if self.closed else np.diff(front, axis=0)
171
+ lengths = np.linalg.norm(step, axis=1)
172
+ if np.any(lengths <= 0.0):
173
+ raise ValueError("SurfaceCrack: two stations of the front at the same point")
174
+ self._lengths = lengths
175
+ self._length = float(lengths.sum())
176
+ if self.closed: # the tangent at a station: across its two neighbours
177
+ tangent = _unit(np.roll(front, -1, axis=0) - np.roll(front, 1, axis=0))
178
+ else:
179
+ tangent = np.empty_like(front)
180
+ tangent[1:-1] = front[2:] - front[:-2]
181
+ tangent[0], tangent[-1] = step[0], step[-1]
182
+ tangent = _unit(tangent)
183
+ back = front - p[-2]
184
+ back = back - np.einsum("ij,ij->i", back, tangent)[:, None] * tangent
185
+ if np.any(np.linalg.norm(back, axis=1) <= 1e-12 * self._length):
186
+ raise ValueError("SurfaceCrack: the last two rows meet, or the front runs along them")
187
+ self._d = _unit(back)
188
+ self._n = _unit(np.cross(self._d, tangent))
189
+ self._t = np.cross(self._d, self._n)
190
+ # the coordinate of the stations: the angle of a closed front (the length along it
191
+ # over its whole length), the length along an open one
192
+ arc = np.concatenate([[0.0], np.cumsum(lengths)])
193
+ self._arc = arc
194
+ self._s = -np.pi + 2 * np.pi * arc[:-1] / self._length if self.closed else arc
195
+ self._surface()
196
+
197
+ # -- the surface behind the front ---------------------------------------------------
198
+
199
+ def _surface(self) -> None:
200
+ """The triangles of the grid of the rows, with those that continue the surface
201
+ of an open crack beyond the ends of its front and behind its mouth, and the
202
+ normals of their vertices."""
203
+ grid = self.points
204
+ scale = float(np.ptp(grid.reshape(-1, 3), axis=0).max())
205
+ if not self.closed:
206
+ far = FAR * scale
207
+ first = _unit(grid[:, 1] - grid[:, 0])
208
+ last = _unit(grid[:, -1] - grid[:, -2])
209
+ grid = np.concatenate(
210
+ [(grid[:, 0] - far * first)[:, None], grid, (grid[:, -1] + far * last)[:, None]],
211
+ axis=1,
212
+ )
213
+ behind = grid[0] - far * _unit(grid[1] - grid[0])
214
+ grid = np.concatenate([behind[None], grid], axis=0)
215
+ rows, cols = grid.shape[:2]
216
+ index = np.arange(rows * cols).reshape(rows, cols)
217
+ nxt = np.roll(index, -1, axis=1)
218
+ if self.closed:
219
+ a, b, c, e = index[:-1], index[1:], nxt[:-1], nxt[1:]
220
+ else:
221
+ a, b, c, e = index[:-1, :-1], index[1:, :-1], index[:-1, 1:], index[1:, 1:]
222
+ triangles = np.concatenate(
223
+ [
224
+ np.stack([a, b, c], axis=-1).reshape(-1, 3),
225
+ np.stack([b, e, c], axis=-1).reshape(-1, 3),
226
+ ]
227
+ )
228
+ vertices = grid.reshape(-1, 3)
229
+ corners = vertices[triangles]
230
+ cross = np.cross(corners[:, 1] - corners[:, 0], corners[:, 2] - corners[:, 0])
231
+ area = np.linalg.norm(cross, axis=1)
232
+ keep = area > 1e-14 * scale * scale # (the fan around a centre repeated)
233
+ triangles, cross = triangles[keep], cross[keep]
234
+ normals = np.zeros_like(vertices)
235
+ for k in range(3):
236
+ np.add.at(normals, triangles[:, k], cross)
237
+ self._vertices = np.ascontiguousarray(vertices)
238
+ self._triangles = np.ascontiguousarray(triangles)
239
+ self._normals = np.ascontiguousarray(_unit(normals))
240
+ self._scale = scale
241
+
242
+ # -- constructors ---------------------------------------------------------------------
243
+
244
+ @classmethod
245
+ def ellipse(cls, centre, normal, a: float, b: float | None = None, *, major=None,
246
+ stations: int = 48, rows: int = 4) -> SurfaceCrack: # fmt: skip
247
+ """A planar elliptical crack of semi-axes ``a`` (along ``major``, by default the
248
+ axis of the frame least aligned with the normal, made normal to it) and ``b`` (by
249
+ default ``a``: a penny), its plane through ``centre`` normal to ``normal``: rows
250
+ from its centre to its front."""
251
+ n = _unit(np.asarray(normal, dtype=float))
252
+ b = float(a) if b is None else float(b)
253
+ if not (a > 0 and b > 0) or stations < 8 or rows < 2:
254
+ raise ValueError("SurfaceCrack.ellipse: positive semi-axes, 8 stations, 2 rows")
255
+ if major is None:
256
+ major = np.eye(3)[int(np.argmin(np.abs(n)))]
257
+ e1 = np.asarray(major, dtype=float)
258
+ e1 = _unit(e1 - (e1 @ n) * n)
259
+ e2 = np.cross(n, e1)
260
+ angle = 2 * np.pi * np.arange(stations) / stations
261
+ front = float(a) * np.outer(np.cos(angle), e1) + b * np.outer(np.sin(angle), e2)
262
+ radii = np.linspace(0.0, 1.0, rows)
263
+ return cls(np.asarray(centre, dtype=float) + radii[:, None, None] * front[None], True)
264
+
265
+ @classmethod
266
+ def of(cls, crack, lower=None, upper=None, *, stations: int = 48, rows: int = 4):
267
+ """The surface crack of a planar :class:`~morphogen.fracture.lefm.Crack` (a penny:
268
+ a closed front) or of a straight one or a
269
+ :class:`~morphogen.fracture.mixed.KinkedCrack` in the box ``[lower, upper]`` (an
270
+ open front, continued beyond the box)."""
271
+ if getattr(crack, "kind", None) == "penny":
272
+ return cls.ellipse(crack.point, crack.normal, crack.size, stations=stations, rows=rows)
273
+ from morphogen.fracture.mixed import KinkedCrack
274
+
275
+ path = crack if isinstance(crack, KinkedCrack) else KinkedCrack.of(crack)
276
+ if lower is None or upper is None:
277
+ raise ValueError("SurfaceCrack.of: the box of a crack with a straight front")
278
+ axis = np.asarray(path.axis)
279
+ corners = np.array(
280
+ [[(lower, upper)[i][k] for k, i in enumerate(bits)] for bits in np.ndindex(2, 2, 2)]
281
+ )
282
+ along = (corners - np.asarray(path.points[0])) @ axis
283
+ margin = 0.05 * (along.max() - along.min())
284
+ # the stations against the axis: the normal d × τ is then that of the path
285
+ s = np.linspace(along.max() + margin, along.min() - margin, stations)
286
+ base = np.asarray(path.points)
287
+ return cls(base[:, None, :] + s[None, :, None] * axis[None, None, :], False)
288
+
289
+ # -- the front -------------------------------------------------------------------------
290
+
291
+ @property
292
+ def stations(self) -> int:
293
+ return self.points.shape[1]
294
+
295
+ @property
296
+ def s(self) -> np.ndarray:
297
+ """The coordinate of the stations along the front: an angle from -π for a closed
298
+ front (the length along it over its whole length), a length for an open one."""
299
+ return self._s
300
+
301
+ @property
302
+ def length(self) -> float:
303
+ """The length of the front."""
304
+ return self._length
305
+
306
+ @property
307
+ def size(self) -> float:
308
+ """The size of the crack: the mean distance of the front to its centre (a closed
309
+ front), or the mean length of the paths of its stations."""
310
+ if self.closed:
311
+ front = self.points[-1]
312
+ return float(np.linalg.norm(front - front.mean(axis=0), axis=1).mean())
313
+ return float(np.linalg.norm(np.diff(self.points, axis=0), axis=2).sum(axis=0).mean())
314
+
315
+ @property
316
+ def reach(self) -> float:
317
+ """How far behind the front the surface stays in the plane of the axes ``d`` and
318
+ ``t`` of the front, at the station where it does least: the domain of a virtual
319
+ advance tangent to the lips (the size of a planar crack, the last advance of a
320
+ kinked one)."""
321
+ back = self.points[::-1] - self.points[-1][None] # the rows, from the front
322
+ off = np.abs(np.einsum("rij,ij->ri", back, self._n))
323
+ behind = -np.einsum("rij,ij->ri", back, self._d)
324
+ planar = np.logical_and.accumulate(off <= 1e-6 * self._scale, axis=0)
325
+ return float(np.where(planar, behind, 0.0).max(axis=0).min())
326
+
327
+ def area(self) -> float:
328
+ """The area of the surface (without its continuations)."""
329
+ grid = self.points
330
+ nxt = np.roll(grid, -1, axis=1) if self.closed else grid[:, 1:]
331
+ cur = grid if self.closed else grid[:, :-1]
332
+ a, b, c, e = cur[:-1], cur[1:], nxt[:-1], nxt[1:]
333
+ first = np.linalg.norm(np.cross(b - a, c - a), axis=-1)
334
+ second = np.linalg.norm(np.cross(e - b, c - b), axis=-1)
335
+ return float(0.5 * (first.sum() + second.sum()))
336
+
337
+ def _nearest(self, x):
338
+ """Of points: the nearest point of the front, its axes ``d``, ``n``, ``t``
339
+ (interpolated between the stations) and its coordinate along the front."""
340
+ x = np.ascontiguousarray(np.atleast_2d(np.asarray(x, dtype=float)))
341
+ front = np.ascontiguousarray(self.points[-1])
342
+ segment, u = _nearest_on_front(x, front, self.closed)
343
+ after = (segment + 1) % self.stations
344
+ f = front[segment] + u[:, None] * (front[after] - front[segment])
345
+ w = np.clip(u, 0.0, 1.0)[:, None]
346
+ n = _unit((1.0 - w) * self._n[segment] + w * self._n[after])
347
+ d = (1.0 - w) * self._d[segment] + w * self._d[after]
348
+ d = _unit(d - np.einsum("ij,ij->i", d, n)[:, None] * n)
349
+ s = self._arc[segment] + u * self._lengths[segment]
350
+ if self.closed:
351
+ s = -np.pi + 2 * np.pi * s / self._length
352
+ return x, f, d, n, np.cross(d, n), s
353
+
354
+ def local(self, x):
355
+ """The coordinates of points along the axes ``d`` and ``n`` of the front."""
356
+ x, f, d, n, _, _ = self._nearest(x)
357
+ y = x - f
358
+ return np.einsum("ij,ij->i", y, d), np.einsum("ij,ij->i", y, n)
359
+
360
+ def psi(self, x) -> np.ndarray:
361
+ """Distance beyond the front along its direction of propagation (negative behind
362
+ it)."""
363
+ return self.local(x)[0]
364
+
365
+ def phi(self, x) -> np.ndarray:
366
+ """Signed distance to the surface behind the front; ahead of it, to the surface
367
+ continued along the direction of propagation."""
368
+ x1, x2 = self.local(x)
369
+ x = np.ascontiguousarray(np.atleast_2d(np.asarray(x, dtype=float)))
370
+ behind = x1 < 0.0
371
+ out = x2.copy()
372
+ if np.any(behind):
373
+ out[behind] = _signed_distance(
374
+ x[behind], self._vertices, self._triangles, self._normals
375
+ )
376
+ return out
377
+
378
+ def frame(self, x):
379
+ """As :meth:`~morphogen.fracture.lefm.Crack.frame`: the distance ``r`` to the front,
380
+ the axes ``n``, ``d``, ``t`` of its nearest point and the coordinate ``s`` along
381
+ it."""
382
+ x, f, d, n, t, s = self._nearest(x)
383
+ y = x - f
384
+ r = np.hypot(np.einsum("ij,ij->i", y, d), np.einsum("ij,ij->i", y, n))
385
+ return r, n, d, t, s
386
+
387
+ def front(self, lower, upper, count: int = _COUNT):
388
+ """Points of the front inside the box ``[lower, upper]`` and the length of front
389
+ that each represents."""
390
+ front = self.points[-1]
391
+ ends = np.vstack([front, front[:1]]) if self.closed else front
392
+ at = (np.arange(count) + 0.5) * self._length / count
393
+ points = np.stack([np.interp(at, self._arc, ends[:, k]) for k in range(3)], axis=1)
394
+ inside = np.all(
395
+ (points >= np.asarray(lower) - 1e-9) & (points <= np.asarray(upper) + 1e-9), axis=1
396
+ )
397
+ return points[inside], np.full(int(inside.sum()), self._length / count)
398
+
399
+ # -- growth ----------------------------------------------------------------------------
400
+
401
+ def grown(self, da, angle=0.0) -> SurfaceCrack:
402
+ """The crack whose stations have advanced by ``da`` at ``angle`` (radians) from
403
+ their direction of propagation towards the normal of the surface (numbers, or one
404
+ value per station): a new row. A negative ``da``, the same at all the stations
405
+ and shorter than the last row, moves the front back along it."""
406
+ da = np.broadcast_to(np.asarray(da, dtype=float), (self.stations,))
407
+ angle = np.broadcast_to(np.asarray(angle, dtype=float), (self.stations,))
408
+ if np.all(da < 0.0):
409
+ if np.any(angle != 0.0) or np.any(-da >= (1 - 1e-9) * self.reach):
410
+ raise ValueError("SurfaceCrack.grown: shortened within its last row, straight")
411
+ front = self.points[-1] + da[:, None] * self._d
412
+ return SurfaceCrack(np.concatenate([self.points[:-1], front[None]]), self.closed)
413
+ if np.any(da <= 0.0):
414
+ raise ValueError("SurfaceCrack.grown: positive advances (or the same negative one)")
415
+ step = np.cos(angle)[:, None] * self._d + np.sin(angle)[:, None] * self._n
416
+ front = np.round(self.points[-1] + da[:, None] * step, 10)
417
+ return SurfaceCrack(np.concatenate([self.points, front[None]]), self.closed)
418
+
419
+
420
+ @dataclass
421
+ class FrontGrowth:
422
+ """The steps of the growth of a :class:`SurfaceCrack`: the ``cracks``, the coordinates
423
+ ``s`` of the stations of the interaction integrals along the front and, at them (steps
424
+ x stations), the energy release ``rates``, the stress intensity ``factors`` (a last
425
+ axis: the three modes) and the ``angles`` of kinking; the largest advance of each
426
+ step and the ``cycles`` (Paris), with ``keep`` the solutions."""
427
+
428
+ cracks: list
429
+ s: np.ndarray
430
+ rates: np.ndarray
431
+ factors: np.ndarray
432
+ angles: np.ndarray
433
+ advances: np.ndarray
434
+ cycles: np.ndarray
435
+ solutions: list = field(default_factory=list, repr=False)
436
+
437
+ def rows(self) -> list[dict]:
438
+ """A row per step: the size and the area of the crack, the extremes of the energy
439
+ release rate and of the factors along its front, the largest angle of kinking."""
440
+ out = []
441
+ for k, crack in enumerate(self.cracks):
442
+ f = self.factors[k]
443
+ out.append(
444
+ {
445
+ "step": k,
446
+ "size": crack.size,
447
+ "area": crack.area(),
448
+ "front_length": crack.length,
449
+ "G_min": float(self.rates[k].min()),
450
+ "G_max": float(self.rates[k].max()),
451
+ "K_I_min": float(f[:, 0].min()),
452
+ "K_I_max": float(f[:, 0].max()),
453
+ "K_II_max": float(np.abs(f[:, 1]).max()),
454
+ "K_III_max": float(np.abs(f[:, 2]).max()),
455
+ "angle_max_deg": float(np.degrees(np.abs(self.angles[k]).max())),
456
+ "N": float(self.cycles[k]),
457
+ }
458
+ )
459
+ return out
460
+
461
+
462
+ def at_stations(crack: SurfaceCrack, s, values, harmonics: int | None = None) -> np.ndarray:
463
+ """Values given at the coordinates ``s`` along the front (increasing), at the stations
464
+ of the crack: interpolated linearly, or, around a closed front whose ``s`` are evenly
465
+ spaced, by their Fourier series up to ``harmonics`` (a smooth distribution, less the
466
+ noise of the values from station to station)."""
467
+ s, values = np.asarray(s, dtype=float), np.asarray(values, dtype=float)
468
+ if not crack.closed:
469
+ return np.interp(crack.s, s, values)
470
+ if harmonics is None:
471
+ return np.interp(crack.s, s, values, period=2 * np.pi)
472
+ count = len(s)
473
+ if not np.allclose(np.diff(s), 2 * np.pi / count):
474
+ raise ValueError("at_stations: evenly spaced stations around the front")
475
+ series = np.fft.rfft(values) / count
476
+ out = np.full(crack.stations, series[0].real)
477
+ for k in range(1, min(int(harmonics), (count - 1) // 2) + 1):
478
+ out += 2.0 * (series[k] * np.exp(1j * k * (crack.s - s[0]))).real
479
+ return out
480
+
481
+
482
+ def propagate_front(
483
+ mesh_of,
484
+ crack: SurfaceCrack,
485
+ materials,
486
+ prescribed,
487
+ load: float = 1.0,
488
+ *,
489
+ increment: float,
490
+ steps: int,
491
+ stations: int = 12,
492
+ exponent: float = 2.0,
493
+ harmonics: int | None = None,
494
+ paris: tuple[float, float] | None = None,
495
+ kinematics: str = "small",
496
+ contact: float | bool | None = None,
497
+ domain: dict | None = None,
498
+ keep: bool = False,
499
+ **options,
500
+ ) -> FrontGrowth:
501
+ """Grow a crack of any surface, each point of its front by its own advance and at its
502
+ own angle (see the module): ``mesh_of(crack)`` meshes the body conforming to it
503
+ (:func:`~morphogen.fracture.lefm.crack_mesh`), ``prescribed`` (entries, or a function
504
+ of the opened mesh) and ``load`` load it (``options``: those of
505
+ :func:`~morphogen.fracture.mixed.solve_crack`). At each of the ``steps`` the energy
506
+ release rate and the factors are taken at ``stations`` along the front (at least two
507
+ elements apart), and the point where ``G`` is largest advances by ``increment``, the
508
+ others by ``increment (G / G_max)^(exponent / 2)`` (``exponent``: that of Paris' law;
509
+ with ``paris = (C, m)`` it is ``m``, and the cycles are counted), each in the
510
+ direction of the largest hoop stress of its ``K_I`` and ``K_II``; ``G`` is that of
511
+ the factors, ``(K_I² + K_II²) / E' + K_III² / 2μ``. ``domain``: the radii ``r_in``
512
+ and ``r_out`` of the domain of the interaction integrals (by default one and four
513
+ elements, within the last advance). Around a closed front the advances and the
514
+ angles are those of the Fourier series of their values at the stations up to
515
+ ``harmonics`` (by default a third of the stations): a front that stays smooth, where
516
+ the noise of the factors, raised to the power of Paris' law, would scallop it."""
517
+ from morphogen.fracture.mixed import _isotropic_moduli, kink_angle, solve_crack
518
+
519
+ if not increment > 0:
520
+ raise ValueError("propagate_front: a positive increment")
521
+ if paris is not None:
522
+ exponent = float(paris[1])
523
+ if harmonics is None and crack.closed:
524
+ harmonics = max(1, int(stations) // 3)
525
+ cracks, rates, factors, angles, advances, cycles, solutions = [], [], [], [], [], [], []
526
+ n, s = 0.0, None
527
+ for step in range(int(steps) + 1):
528
+ solution = solve_crack(mesh_of(crack), crack, materials, prescribed, load,
529
+ kinematics=kinematics, contact=contact, **options) # fmt: skip
530
+ modes = solution.modes(stations=stations, **(domain or {}))
531
+ s = modes["s"]
532
+ k = np.stack([modes["K_I"], modes["K_II"], modes["K_III"]], axis=1)
533
+ # the energy release rate of the factors: along a front that turns sharply it is
534
+ # more even than that of the G-θ method, whose domain the curvature narrows
535
+ young, nu = _isotropic_moduli(solution.materials[solution.front_phase()])
536
+ e_prime, mu = young / (1 - nu**2), young / (2 * (1 + nu))
537
+ g = (k[:, 0] ** 2 + k[:, 1] ** 2) / e_prime + k[:, 2] ** 2 / (2 * mu)
538
+ turn = np.array([kink_angle(a, b) for a, b in k[:, :2]])
539
+ cracks.append(crack)
540
+ rates.append(g)
541
+ factors.append(k)
542
+ angles.append(turn)
543
+ cycles.append(n)
544
+ if keep:
545
+ solutions.append(solution)
546
+ if step == steps:
547
+ advances.append(0.0)
548
+ break
549
+ top = float(g.max())
550
+ if not top > 0:
551
+ raise ValueError("propagate_front: no energy is released along the front")
552
+ share = at_stations(crack, s, (g / top) ** (0.5 * exponent), harmonics)
553
+ share = share / share.max() # the fastest station advances by the increment
554
+ advance = increment * np.clip(share, 0.02, 1.0) # (none left behind for good)
555
+ advances.append(float(advance.max()))
556
+ if paris is not None:
557
+ c, m = paris
558
+ n += increment / (c * math.sqrt(e_prime * top) ** m)
559
+ # the angles through their sines and cosines: no jump from π to -π between stations
560
+ sine = at_stations(crack, s, np.sin(turn), harmonics)
561
+ cosine = at_stations(crack, s, np.cos(turn), harmonics)
562
+ crack = crack.grown(advance, np.arctan2(sine, cosine))
563
+ return FrontGrowth(
564
+ cracks,
565
+ np.asarray(s),
566
+ np.array(rates),
567
+ np.array(factors),
568
+ np.array(angles),
569
+ np.array(advances),
570
+ np.array(cycles),
571
+ solutions,
572
+ )