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,245 @@
1
+ """The growth of a crack front in three dimensions, a tool of the tab Fracture of the
2
+ interface: an elliptical crack inside a block, inclined to the tension, each point of
3
+ whose front advances by its own amount and kinks by its own angle
4
+ (:mod:`morphogen.fracture.surface`)."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import math
9
+
10
+ import numpy as np
11
+
12
+ from morphogen.gui.tools import Field, tool
13
+
14
+
15
+ @tool(
16
+ "front_growth",
17
+ "fracture",
18
+ "Growth of a crack front in 3D",
19
+ "An elliptical crack inside a block in tension, its plane inclined to the load: the "
20
+ "stress intensity factors K_I, K_II and K_III along its curved front (interaction "
21
+ "integrals on a mesh conforming to the crack, refined around its front), against "
22
+ "those of the infinite body (Irwin 1962; Kassir & Sih 1966), and its growth: each "
23
+ "point of the front advances by its own amount, as its energy release rate to the "
24
+ "power of Paris' law, in the direction of the largest hoop stress of its own factors "
25
+ "(Erdogan & Sih). An ellipse grows towards a circle; an inclined crack turns its "
26
+ "surface towards the plane normal to the tension, by a different angle at each point "
27
+ "of its front. The mesh is rebuilt by MMG for each crack.",
28
+ [
29
+ Field("major", "float", 1.0, label="semi-axis a", unit="length", doc="along y"),
30
+ Field(
31
+ "minor",
32
+ "float",
33
+ label="semi-axis b",
34
+ unit="length",
35
+ doc="across y, in the plane of the crack (blank: a, a penny crack)",
36
+ ),
37
+ Field(
38
+ "inclination",
39
+ "float",
40
+ 30.0,
41
+ unit="degree",
42
+ doc="of the normal of the crack from the axis z of the tension, about y (0: "
43
+ "mode I alone)",
44
+ ),
45
+ Field(
46
+ "block",
47
+ "float",
48
+ label="edge of the block",
49
+ unit="length",
50
+ doc="a cube around the crack (blank: five times its largest semi-axis)",
51
+ ),
52
+ Field("young", "float", 1000.0, label="Young's modulus"),
53
+ Field("poisson", "float", 0.3, label="Poisson's ratio"),
54
+ Field("stress", "float", label="tension", doc="along z (blank: 0.001 E)"),
55
+ Field(
56
+ "element_size",
57
+ "float",
58
+ unit="length",
59
+ doc="of the block (blank: an eighth of its edge)",
60
+ ),
61
+ Field(
62
+ "front_size",
63
+ "float",
64
+ unit="length",
65
+ doc="of the elements around the front (blank: an eighth of the smallest semi-axis)",
66
+ ),
67
+ Field("stations", "int", 12, doc="along the front, of the factors"),
68
+ Field("steps", "int", 2, doc="advances of the front (0: the factors alone)"),
69
+ Field(
70
+ "increment",
71
+ "float",
72
+ unit="length",
73
+ doc="the advance of the fastest point at each step (blank: 0.3 of the smallest "
74
+ "semi-axis; four elements of the front at least)",
75
+ ),
76
+ Field(
77
+ "exponent",
78
+ "float",
79
+ 2.0,
80
+ label="exponent of Paris' law",
81
+ doc="the advance of a point: the increment times (G / G_max) to half of it",
82
+ ),
83
+ Field(
84
+ "paris",
85
+ "float",
86
+ label="coefficient of Paris' law",
87
+ doc="C of da/dN = C ΔK^m (blank: the cycles are not counted)",
88
+ ),
89
+ ],
90
+ order=3,
91
+ menu="Cracks",
92
+ )
93
+ def front_growth(p: dict, ctx) -> dict:
94
+ from matplotlib.figure import Figure
95
+ from scipy.special import ellipe
96
+
97
+ from morphogen.fracture import lefm
98
+ from morphogen.fracture.surface import SurfaceCrack, propagate_front
99
+ from morphogen.homogenization.materials import Material
100
+ from morphogen.mesh.conforming import has_mmg
101
+
102
+ if not has_mmg():
103
+ raise ValueError("the meshes of the cracks are made by MMG (pip install pymmg)")
104
+ a = float(p["major"])
105
+ b = a if p["minor"] is None else float(p["minor"])
106
+ if not (a > 0 and 0 < b <= a):
107
+ raise ValueError("semi-axes: positive, b at most a")
108
+ alpha = math.radians(float(p["inclination"]))
109
+ if not 0.0 <= alpha < math.radians(80.0):
110
+ raise ValueError("inclination: from 0 to 80 degrees")
111
+ edge = 5.0 * a if p["block"] is None else float(p["block"])
112
+ if edge < 2.5 * a:
113
+ raise ValueError("edge of the block: at least 2.5 times the semi-axis a")
114
+ young, nu = float(p["young"]), float(p["poisson"])
115
+ if not (young > 0 and -1.0 < nu < 0.5):
116
+ raise ValueError("Young's modulus: positive; Poisson's ratio: between -1 and 0.5")
117
+ stress = 1e-3 * young if p["stress"] is None else float(p["stress"])
118
+ size = edge / 8.0 if p["element_size"] is None else float(p["element_size"])
119
+ front = b / 8.0 if p["front_size"] is None else float(p["front_size"])
120
+ if not (0 < front <= size <= edge / 4.0):
121
+ raise ValueError("element sizes: that of the front at most that of the block, itself "
122
+ "at most a quarter of its edge") # fmt: skip
123
+ stations, steps = int(p["stations"]), int(p["steps"])
124
+ if not (4 <= stations <= 48 and 0 <= steps <= 12):
125
+ raise ValueError("stations: from 4 to 48; steps: from 0 to 12")
126
+ increment = 0.3 * b if p["increment"] is None else float(p["increment"])
127
+ if increment < 3.0 * front:
128
+ raise ValueError(
129
+ f"increment: at least three elements of the front ({3 * front:.3g}), in which the "
130
+ "factors of the kinked front are taken"
131
+ )
132
+ half = 0.5 * edge
133
+ normal = (math.sin(alpha), 0.0, math.cos(alpha))
134
+ crack = SurfaceCrack.ellipse((0.0, 0.0, 0.0), normal, a, b, major=(0.0, 1.0, 0.0), stations=64)
135
+ material = Material(young=young, poisson=nu)
136
+
137
+ def nearest(m, point):
138
+ return int(np.argmin(np.linalg.norm(m.nodes - np.asarray(point), axis=1)))
139
+
140
+ def forces(m):
141
+ f = lefm.face_forces(m, lambda c: c[:, 2] > half - 1e-9 * edge, [0.0, 0.0, stress])
142
+ return f + lefm.face_forces(m, lambda c: c[:, 2] < 1e-9 * edge - half, [0.0, 0.0, -stress])
143
+
144
+ def supports(m):
145
+ corners = ((-half, -half, -half), (half, -half, -half), (-half, half, -half))
146
+ i, j, k = (nearest(m, c) for c in corners)
147
+ return [(i, [0, 1, 2], 0.0), (j, [1, 2], 0.0), (k, 2, 0.0)]
148
+
149
+ done = {"count": 0}
150
+
151
+ def mesh_of(c):
152
+ ctx.progress(
153
+ 0.05 + 0.85 * done["count"] / (steps + 1),
154
+ f"crack {done['count']} of {steps}: mesh and solution",
155
+ )
156
+ done["count"] += 1
157
+ return lefm.crack_mesh((-half,) * 3, (half,) * 3, c, size=size, front_size=front,
158
+ front_radius=4.0 * front) # fmt: skip
159
+
160
+ domain = {"r_in": 1.2 * front, "r_out": min(3.5 * front, 0.9 * increment)}
161
+ growth = propagate_front(
162
+ mesh_of,
163
+ crack,
164
+ material,
165
+ supports,
166
+ forces=forces,
167
+ increment=increment,
168
+ steps=steps,
169
+ stations=stations,
170
+ exponent=float(p["exponent"]),
171
+ paris=None if p["paris"] is None else (float(p["paris"]), float(p["exponent"])),
172
+ domain=domain,
173
+ keep=True,
174
+ )
175
+ ctx.progress(0.92, "figures")
176
+ ctx.table(growth.rows(), "growth", "the crack at each step")
177
+ degrees = np.degrees(growth.s)
178
+ along = []
179
+ for k, (factors, angles) in enumerate(zip(growth.factors, growth.angles, strict=True)):
180
+ for s, f, turn in zip(degrees, factors, angles, strict=True):
181
+ along.append({"step": k, "s_deg": float(s), "K_I": float(f[0]), "K_II": float(f[1]),
182
+ "K_III": float(f[2]), "kink_deg": float(np.degrees(turn))}) # fmt: skip
183
+ ctx.table(along, "factors", "the factors and the angle of kinking along the front")
184
+ fig = Figure(figsize=(11.0, 3.6), layout="constrained")
185
+ for ax, mode, name in zip(fig.subplots(1, 3), range(3), ("K_I", "K_II", "K_III"), strict=True):
186
+ for k, factors in enumerate(growth.factors):
187
+ ax.plot(degrees, factors[:, mode], "o-", ms=3, lw=1.2, label=f"step {k}")
188
+ ax.set_xlabel("position along the front (degrees)")
189
+ ax.set_ylabel(name)
190
+ ax.grid(alpha=0.3)
191
+ fig.axes[0].legend(fontsize=8, frameon=False)
192
+ ctx.figure(fig, "factors", "stress intensity factors along the front")
193
+ # the fronts: in the plane of the first crack, and from its side
194
+ e1 = np.array([0.0, 1.0, 0.0])
195
+ e2 = np.cross(normal, e1)
196
+ fig = Figure(figsize=(9.2, 4.2), layout="constrained")
197
+ top, side = fig.subplots(1, 2)
198
+ for k, grown in enumerate(growth.cracks):
199
+ loop = np.vstack([grown.points[-1], grown.points[-1][:1]])
200
+ top.plot(loop @ e2, loop @ e1, lw=1.4, label=f"step {k}")
201
+ side.plot(loop[:, 0], loop[:, 2], lw=1.4)
202
+ top.set_title("fronts in the plane of the first crack", fontsize=9)
203
+ side.set_title("fronts from the side (x, z: the tension along z)", fontsize=9)
204
+ for ax in (top, side):
205
+ ax.set_aspect("equal")
206
+ ax.grid(alpha=0.3)
207
+ top.legend(fontsize=8, frameon=False)
208
+ ctx.figure(fig, "fronts", "the successive fronts of the crack")
209
+ first = growth.factors[0]
210
+ values = {
211
+ "nodes of the first mesh": int(growth.solutions[0].mesh.n_nodes),
212
+ "element size at the front": growth.solutions[0].element_size(),
213
+ "K_I along the first front (mean)": float(first[:, 0].mean()),
214
+ "largest |K_II| along the first front": float(np.abs(first[:, 1]).max()),
215
+ "largest |K_III| along the first front": float(np.abs(first[:, 2]).max()),
216
+ "largest angle of kinking of the first front (degrees)": float(
217
+ np.degrees(np.abs(growth.angles[0]).max())
218
+ ),
219
+ }
220
+ # the infinite body
221
+ unit = stress * math.sqrt(math.pi * b) / ellipe(1.0 - (b / a) ** 2)
222
+ if alpha == 0.0:
223
+ values["K_I of the infinite body, ends of the minor axis (Irwin)"] = unit
224
+ values["K_I of the infinite body, ends of the major axis (Irwin)"] = unit * math.sqrt(b / a)
225
+ elif b == a:
226
+ tau = math.sin(alpha) * math.cos(alpha)
227
+ base = 2.0 * stress * math.sqrt(a / math.pi)
228
+ values["K_I of the infinite body (Kassir & Sih)"] = base * math.cos(alpha) ** 2
229
+ values["largest K_II of the infinite body (Kassir & Sih)"] = 2.0 * base * tau / (2 - nu)
230
+ values["largest K_III of the infinite body (Kassir & Sih)"] = (
231
+ 2.0 * base * tau * (1 - nu) / (2 - nu)
232
+ )
233
+ if steps:
234
+ last = growth.cracks[-1]
235
+ values["area of the last crack over that of the first"] = last.area() / crack.area()
236
+ values["largest |K_II| along the last front"] = float(
237
+ np.abs(growth.factors[-1][:, 1]).max()
238
+ )
239
+ if p["paris"] is not None:
240
+ values["cycles"] = float(growth.cycles[-1])
241
+ shape = "penny" if b == a else "elliptical"
242
+ title = f"Growth of an {shape} crack" if b != a else "Growth of a penny crack"
243
+ if alpha:
244
+ title += f" inclined by {float(p['inclination']):g}°"
245
+ return {"values": values, "title": title}
@@ -0,0 +1,224 @@
1
+ """The tools of the tab Design: the rule of a cellular automaton whose structures match a
2
+ morphology (inverse design by a genetic algorithm over the birth and survival sets), and
3
+ the rigidity of strut lattices with defects (the counts of Maxwell and Calladine:
4
+ mechanisms, states of self-stress, floppy macroscopic strains)."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import numpy as np
9
+
10
+ from morphogen.automata.tilings import LATTICES, PLANAR, QUASIPERIODIC
11
+ from morphogen.gui.tools import Field, tab, tool
12
+
13
+ tab(
14
+ "design",
15
+ "Inverse design",
16
+ "Inverse design: the automaton rule whose structures match a morphology of the "
17
+ "workspace, and the rigidity of strut lattices (stretching- or bending-dominated) as "
18
+ "their struts are removed.",
19
+ order=75,
20
+ )
21
+
22
+
23
+ @tool(
24
+ "automaton_rule",
25
+ "design",
26
+ "Automaton rule of a morphology",
27
+ "The rule B.../S... of a cellular automaton, and the density of its initial noise, "
28
+ "whose structures best match a morphology of the workspace: its volume fraction, "
29
+ "interface density and two-point correlation at a few lags, searched by a genetic "
30
+ "algorithm over the birth and survival sets (all candidates run from the same noise). "
31
+ "The structure of the rule found joins the workspace.",
32
+ [
33
+ Field("source", "item", label="morphology", required=True),
34
+ Field("cells", "int", 24, label="cells per edge", doc="of the target and of the runs"),
35
+ Field("neighbourhood", "choice", "moore", choices=("moore", "von_neumann", "edges")),
36
+ Field("lattice", "choice", "square", choices=LATTICES,
37
+ doc="cells of the automaton: squares or cubes, triangles, hexagons, Penrose "
38
+ "rhombi, Ammann-Beenker squares and rhombi (prisms in 3D), BCC or FCC Voronoi "
39
+ "cells, golden rhombohedra (3D)"),
40
+ Field("steps", "int", 15, doc="updates of each candidate"),
41
+ Field("population", "int", 16),
42
+ Field("generations", "int", 10),
43
+ Field("seed", "int", 1),
44
+ ],
45
+ order=1,
46
+ ) # fmt: skip
47
+ def automaton_rule(p: dict, ctx) -> dict:
48
+ from matplotlib.figure import Figure
49
+
50
+ from morphogen.design.search import fit_rule
51
+ from morphogen.domain import Domain
52
+ from morphogen.gui import api
53
+ from morphogen.models.base import model_from_config
54
+ from morphogen.seeding import derive_seed
55
+
56
+ item = p["source"]
57
+ micro = item["micro"]
58
+ lengths = np.asarray(micro.domain.lengths, dtype=float)
59
+ n = int(p["cells"])
60
+ if not 8 <= n <= 64:
61
+ raise ValueError("cells per edge: from 8 to 64")
62
+ planar = bool(item.get("planar")) or lengths[2] < 0.05 * lengths[:2].max()
63
+ cell = float(lengths.max()) / n
64
+ target = micro.voxelize(voxel_size=cell)
65
+ if planar:
66
+ mid = target.data.shape[2] // 2
67
+ target_data = target.data[:, :, mid : mid + 1]
68
+ else:
69
+ target_data = target.data
70
+ shape = target_data.shape
71
+ total = int(p["generations"])
72
+
73
+ def progress(g, best, cost):
74
+ ctx.progress((g + 1) / max(total, 1), f"generation {g + 1} / {total}, cost {cost:.3g}")
75
+
76
+ lattice = p.get("lattice") or "square"
77
+ if planar and lattice not in PLANAR:
78
+ raise ValueError(f"lattice {lattice}: three-dimensional morphologies only")
79
+ periodic = lattice not in QUASIPERIODIC
80
+ fit = fit_rule(
81
+ (target_data == 1).astype(np.uint8),
82
+ neighbourhood=p["neighbourhood"],
83
+ dims=2 if planar else 3,
84
+ lattice=lattice,
85
+ shape=shape,
86
+ steps=int(p["steps"]),
87
+ population=int(p["population"]),
88
+ generations=total,
89
+ rng=np.random.default_rng(p["seed"]),
90
+ callback=progress,
91
+ )
92
+ spec = {"type": "cellular_automaton", "rule": fit.rule, "steps": int(p["steps"]),
93
+ "neighbourhood": p["neighbourhood"], "initial_fraction": float(fit.initial_fraction),
94
+ "cell_size": cell} # fmt: skip
95
+ if planar:
96
+ spec["dimension"] = 2
97
+ if lattice != "square":
98
+ spec["lattice"] = lattice
99
+ model = model_from_config(spec)
100
+ domain = Domain(size=tuple(float(v) for v in lengths), periodic=periodic)
101
+ grown = model.generate(domain, derive_seed(p["seed"], 0))
102
+ views = api.morphology_views(grown, 384)
103
+ names = ["volume fraction", "interface density"] + [
104
+ f"correlation, lag {k}" for k in range(1, len(fit.target) - 1)
105
+ ]
106
+ ctx.table(
107
+ [{"descriptor": name, "target": float(t), "rule": float(d)}
108
+ for name, t, d in zip(names, fit.target, fit.descriptors, strict=True)],
109
+ "descriptors", "descriptors of the target and of the rule found",
110
+ ) # fmt: skip
111
+ history = fit.history.get("best") or fit.history.get("cost") or []
112
+ if history:
113
+ fig = Figure(figsize=(5.4, 3.4), layout="constrained")
114
+ ax = fig.subplots()
115
+ ax.plot(np.arange(1, len(history) + 1), history, lw=1.8)
116
+ ax.set_xlabel("generation")
117
+ ax.set_ylabel("cost of the best rule")
118
+ ax.set_yscale("log")
119
+ ax.grid(alpha=0.3)
120
+ ctx.figure(fig, "search", "the genetic search")
121
+ for s in views["sections"]:
122
+ ctx.figures.append({"title": f"rule {fit.rule}, {s['title']}", "url": s["png"]})
123
+ ctx.add(
124
+ "morphology",
125
+ f"automaton {fit.rule} (from #{item['number']})",
126
+ micro=grown,
127
+ origin="design",
128
+ source=item["key"],
129
+ model=model.to_config(),
130
+ domain={"size": [float(v) for v in lengths], "periodic": periodic},
131
+ seed=p["seed"],
132
+ phases={"0": "phase 0", "1": "phase 1"},
133
+ thumbnail=views["thumbnail"],
134
+ fraction=views["fraction"],
135
+ planar=planar,
136
+ info={"model": "cellular_automaton", "rule": fit.rule},
137
+ )
138
+ return {
139
+ "values": {
140
+ "rule": fit.rule,
141
+ "initial fraction": float(fit.initial_fraction),
142
+ "cost": float(fit.cost),
143
+ "evaluations": int(fit.evaluations),
144
+ }
145
+ }
146
+
147
+
148
+ LATTICES = ("cubic", "bcc", "fcc", "octet", "kelvin", "diamond", "pyrochlore")
149
+
150
+
151
+ @tool(
152
+ "rigidity",
153
+ "design",
154
+ "Rigidity of a strut lattice",
155
+ "The periodic pin-jointed framework of a strut lattice (cubic, bcc, fcc, octet, "
156
+ "Kelvin, diamond, pyrochlore), its struts removed at random (to a mean coordination, "
157
+ "or a fraction of them) "
158
+ "and its nodes perturbed: the mechanisms, the states of self-stress and the floppy "
159
+ "macroscopic strains of its compatibility matrix (Maxwell 1864, Calladine 1978, "
160
+ "Pellegrino & Calladine 1986; Guest & Hutchinson 2003), whether it is stretching- or "
161
+ "bending-dominated, along a series of dilutions.",
162
+ [
163
+ Field("lattice", "choice", "octet", choices=LATTICES),
164
+ Field("cells", "int", 2, label="cells per edge"),
165
+ Field("dilution", "choice", "coordination", choices=(
166
+ ("coordination", "to a mean coordination"), ("fraction", "a fraction of the struts"))),
167
+ Field("targets", "floats", label="coordinations or fractions",
168
+ doc="blank: from the full lattice down to coordination 4 (or fractions 0 to 0.5)"),
169
+ Field("perturbation", "float", 0.0, label="node perturbation", unit="length",
170
+ doc="radius of the random displacement of the nodes (a fraction of the cell)"),
171
+ Field("seed", "int", 1),
172
+ ],
173
+ order=2,
174
+ ) # fmt: skip
175
+ def rigidity(p: dict, ctx) -> dict:
176
+ from matplotlib.figure import Figure
177
+
178
+ from morphogen.design.frames import Framework
179
+
180
+ base = Framework.lattice(p["lattice"], int(p["cells"]))
181
+ rng = np.random.default_rng(p["seed"])
182
+ full = base.coordination()
183
+ if p["dilution"] == "coordination":
184
+ targets = p["targets"] or [float(z) for z in np.linspace(full, 4.0, 7)]
185
+ else:
186
+ targets = p["targets"] or [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]
187
+ rows = []
188
+ for k, target in enumerate(targets):
189
+ ctx.progress(k / max(len(targets), 1), f"dilution {k + 1} / {len(targets)}")
190
+ frame = base
191
+ if p["dilution"] == "coordination" and target < full:
192
+ frame = base.diluted(rng, coordination=float(target))
193
+ elif p["dilution"] == "fraction" and target > 0:
194
+ frame = base.diluted(rng, fraction=float(target))
195
+ if p["perturbation"]:
196
+ frame = frame.perturbed(rng, float(p["perturbation"]))
197
+ r = frame.rigidity()
198
+ rows.append({"target": float(target), **r})
199
+ ctx.table(rows, "rigidity", "rigidity along the dilution")
200
+ fig = Figure(figsize=(5.6, 3.8), layout="constrained")
201
+ ax = fig.subplots()
202
+ z = [r["coordination"] for r in rows]
203
+ ax.plot(z, [r["mechanisms"] for r in rows], "o-", label="mechanisms")
204
+ ax.plot(z, [r["self_stresses"] for r in rows], "s-", label="states of self-stress")
205
+ ax.plot(z, [r["floppy_strains"] for r in rows], "^-", label="floppy macroscopic strains")
206
+ ax.axvline(6.0, color="0.5", lw=1, ls="--")
207
+ ax.text(6.0, ax.get_ylim()[1] * 0.95, " Z = 6", va="top", fontsize=8, color="0.4")
208
+ ax.set_xlabel("mean coordination Z")
209
+ ax.set_ylabel("count")
210
+ ax.set_title(f"{p['lattice']} lattice, {int(p['cells'])}³ cells", fontsize=10)
211
+ ax.grid(alpha=0.3)
212
+ ax.legend(fontsize=8, frameon=False)
213
+ ctx.figure(fig, "rigidity", "Maxwell–Calladine counts")
214
+ first = rows[0]
215
+ return {
216
+ "values": {
217
+ "lattice": p["lattice"],
218
+ "coordination of the full lattice": float(full),
219
+ "stretching-dominated (full)": bool(first["stretching_dominated"]),
220
+ "lowest stretching-dominated coordination": min(
221
+ (r["coordination"] for r in rows if r["stretching_dominated"]), default=float("nan")
222
+ ),
223
+ }
224
+ }