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.
- morphogen/__init__.py +60 -0
- morphogen/__main__.py +7 -0
- morphogen/_platform.py +55 -0
- morphogen/_public.py +153 -0
- morphogen/_utils.py +80 -0
- morphogen/_version.py +1 -0
- morphogen/analysis/__init__.py +174 -0
- morphogen/analysis/anisotropy.py +135 -0
- morphogen/analysis/basic.py +38 -0
- morphogen/analysis/cells.py +54 -0
- morphogen/analysis/connectivity.py +156 -0
- morphogen/analysis/correlation.py +195 -0
- morphogen/analysis/covariance.py +80 -0
- morphogen/analysis/fractal.py +54 -0
- morphogen/analysis/measures.py +188 -0
- morphogen/analysis/morphology.py +265 -0
- morphogen/analysis/particles.py +160 -0
- morphogen/analysis/percolation.py +2034 -0
- morphogen/analysis/power_laws.py +143 -0
- morphogen/analysis/random_sets.py +351 -0
- morphogen/analysis/stereology.py +289 -0
- morphogen/analysis/surface.py +107 -0
- morphogen/analysis/topology.py +92 -0
- morphogen/automata/__init__.py +74 -0
- morphogen/automata/engine.py +211 -0
- morphogen/automata/growth.py +686 -0
- morphogen/automata/lattice.py +143 -0
- morphogen/automata/reaction.py +255 -0
- morphogen/automata/rules.py +353 -0
- morphogen/automata/tilings.py +1715 -0
- morphogen/cli.py +3526 -0
- morphogen/config.py +2167 -0
- morphogen/contact/__init__.py +113 -0
- morphogen/contact/experiments.py +368 -0
- morphogen/contact/hertz.py +104 -0
- morphogen/contact/kernels.py +827 -0
- morphogen/contact/periodic.py +278 -0
- morphogen/contact/problem.py +578 -0
- morphogen/contact/surfaces.py +310 -0
- morphogen/coupling/__init__.py +43 -0
- morphogen/coupling/ageing.py +143 -0
- morphogen/coupling/diffusion.py +226 -0
- morphogen/coupling/fenicsx.py +484 -0
- morphogen/coupling/oxidation.py +447 -0
- morphogen/coupling/plates.py +247 -0
- morphogen/design/__init__.py +51 -0
- morphogen/design/csp.py +616 -0
- morphogen/design/frames.py +277 -0
- morphogen/design/search.py +287 -0
- morphogen/design/tiles.py +336 -0
- morphogen/distributions.py +312 -0
- morphogen/domain.py +203 -0
- morphogen/dynamics/__init__.py +179 -0
- morphogen/dynamics/model.py +638 -0
- morphogen/dynamics/openradioss.py +643 -0
- morphogen/dynamics/results.py +515 -0
- morphogen/fracture/__init__.py +170 -0
- morphogen/fracture/bulk.py +349 -0
- morphogen/fracture/cohesive.py +1614 -0
- morphogen/fracture/ductile.py +557 -0
- morphogen/fracture/lefm.py +1168 -0
- morphogen/fracture/mixed.py +1178 -0
- morphogen/fracture/periodic.py +733 -0
- morphogen/fracture/phasefield.py +714 -0
- morphogen/fracture/phasefield_finite.py +368 -0
- morphogen/fracture/surface.py +572 -0
- morphogen/fracture/toughness.py +566 -0
- morphogen/gpu.py +108 -0
- morphogen/gui/__init__.py +8 -0
- morphogen/gui/api.py +1927 -0
- morphogen/gui/desktop.py +387 -0
- morphogen/gui/icon.png +0 -0
- morphogen/gui/index.html +1909 -0
- morphogen/gui/server.py +229 -0
- morphogen/gui/tools/__init__.py +629 -0
- morphogen/gui/tools/compare.py +149 -0
- morphogen/gui/tools/contact.py +391 -0
- morphogen/gui/tools/couplings.py +1085 -0
- morphogen/gui/tools/crackfront.py +245 -0
- morphogen/gui/tools/design.py +224 -0
- morphogen/gui/tools/dynamics.py +824 -0
- morphogen/gui/tools/fracture.py +2586 -0
- morphogen/gui/tools/interop.py +1654 -0
- morphogen/gui/tools/learning.py +595 -0
- morphogen/gui/tools/mechanics.py +3881 -0
- morphogen/gui/tools/nonlocal_damage.py +1321 -0
- morphogen/gui/tools/phasefield.py +215 -0
- morphogen/gui/tools/physics.py +597 -0
- morphogen/gui/tools/stability.py +1756 -0
- morphogen/gui/tools/statistics.py +1408 -0
- morphogen/gui/viewer.js +1100 -0
- morphogen/homogenization/__init__.py +210 -0
- morphogen/homogenization/acoustics.py +566 -0
- morphogen/homogenization/amg.py +1005 -0
- morphogen/homogenization/apparent.py +1046 -0
- morphogen/homogenization/behaviours.cu +2285 -0
- morphogen/homogenization/behaviours.py +944 -0
- morphogen/homogenization/beremin.py +263 -0
- morphogen/homogenization/bifurcation.py +1085 -0
- morphogen/homogenization/bloch.py +507 -0
- morphogen/homogenization/bounds.py +226 -0
- morphogen/homogenization/core.py +458 -0
- morphogen/homogenization/coupled.py +1135 -0
- morphogen/homogenization/crystal.py +2967 -0
- morphogen/homogenization/dilatation.py +454 -0
- morphogen/homogenization/elements.py +157 -0
- morphogen/homogenization/fatigue.py +768 -0
- morphogen/homogenization/fe.py +1739 -0
- morphogen/homogenization/fenicsx.py +307 -0
- morphogen/homogenization/fft.py +499 -0
- morphogen/homogenization/fft_nonlinear.py +391 -0
- morphogen/homogenization/finite.py +613 -0
- morphogen/homogenization/flow.py +361 -0
- morphogen/homogenization/frames.py +1125 -0
- morphogen/homogenization/gpu.py +1241 -0
- morphogen/homogenization/harmonic.py +427 -0
- morphogen/homogenization/identification.py +579 -0
- morphogen/homogenization/kernels.py +760 -0
- morphogen/homogenization/laws.py +2061 -0
- morphogen/homogenization/materials.py +1080 -0
- morphogen/homogenization/mfront.py +589 -0
- morphogen/homogenization/networks.py +880 -0
- morphogen/homogenization/nonlinear.py +2612 -0
- morphogen/homogenization/ntfa.py +577 -0
- morphogen/homogenization/paths.py +476 -0
- morphogen/homogenization/photonic.py +467 -0
- morphogen/homogenization/poroelastic.py +212 -0
- morphogen/homogenization/porous.py +1120 -0
- morphogen/homogenization/postprocess.py +290 -0
- morphogen/homogenization/solvers.py +1140 -0
- morphogen/homogenization/tensors.py +240 -0
- morphogen/homogenization/voxel_fe.py +457 -0
- morphogen/homogenization/xfem.py +1016 -0
- morphogen/homogenization/zmat.py +1258 -0
- morphogen/iga/__init__.py +48 -0
- morphogen/iga/analysis.py +508 -0
- morphogen/iga/basis.py +214 -0
- morphogen/iga/geometry.py +501 -0
- morphogen/iga/homogenization.py +219 -0
- morphogen/iga/optimization.py +700 -0
- morphogen/iga/shapes.py +331 -0
- morphogen/image.py +128 -0
- morphogen/io/__init__.py +246 -0
- morphogen/io/amitex.py +741 -0
- morphogen/io/ebsd.py +881 -0
- morphogen/io/export.py +196 -0
- morphogen/io/geometry.py +158 -0
- morphogen/io/medit.py +147 -0
- morphogen/io/meshes.py +844 -0
- morphogen/io/metaimage.py +97 -0
- morphogen/io/mfront.py +1104 -0
- morphogen/io/native.py +57 -0
- morphogen/io/radioss.py +764 -0
- morphogen/io/solvers.py +371 -0
- morphogen/io/tables.py +278 -0
- morphogen/io/tiff.py +66 -0
- morphogen/io/vtk.py +701 -0
- morphogen/io/xdmf.py +200 -0
- morphogen/kernels/__init__.py +5 -0
- morphogen/kernels/annealing.py +192 -0
- morphogen/kernels/cells.py +69 -0
- morphogen/kernels/collective.py +87 -0
- morphogen/kernels/force_biased.py +595 -0
- morphogen/kernels/implicit.py +145 -0
- morphogen/kernels/leaves.py +132 -0
- morphogen/kernels/packing.py +304 -0
- morphogen/kernels/raster.py +279 -0
- morphogen/kernels/rsa.py +371 -0
- morphogen/kernels/union.py +135 -0
- morphogen/kernels/watershed.py +190 -0
- morphogen/laser/__init__.py +234 -0
- morphogen/laser/architectures.py +375 -0
- morphogen/laser/bending.py +216 -0
- morphogen/laser/cells.py +1694 -0
- morphogen/laser/design.py +940 -0
- morphogen/laser/figures.py +227 -0
- morphogen/laser/heat.py +804 -0
- morphogen/laser/materials.py +691 -0
- morphogen/laser/mechanics.py +1670 -0
- morphogen/laser/metallurgy.py +615 -0
- morphogen/laser/patterns.py +828 -0
- morphogen/laser/periodic.py +392 -0
- morphogen/laser/process.py +362 -0
- morphogen/laser/run.py +534 -0
- morphogen/laser/solid.py +216 -0
- morphogen/laser/specimen.py +200 -0
- morphogen/laser/structures.py +708 -0
- morphogen/learning/__init__.py +81 -0
- morphogen/learning/behaviour.py +398 -0
- morphogen/learning/data.py +328 -0
- morphogen/learning/learned.cpp +668 -0
- morphogen/learning/logarithmic.py +202 -0
- morphogen/learning/mfront.py +409 -0
- morphogen/learning/networks.py +767 -0
- morphogen/learning/run.py +212 -0
- morphogen/learning/standard.py +814 -0
- morphogen/learning/training.py +235 -0
- morphogen/mesh/__init__.py +29 -0
- morphogen/mesh/conforming.py +1423 -0
- morphogen/mesh/curved.py +600 -0
- morphogen/mesh/exact.py +1717 -0
- morphogen/mesh/octree.py +350 -0
- morphogen/mesh/polycrystal.py +1041 -0
- morphogen/mesh/polyhedra.py +677 -0
- morphogen/mesh/regularize.py +570 -0
- morphogen/mesh/surface.py +97 -0
- morphogen/mesh/tetra.py +512 -0
- morphogen/mesh/voxel.py +124 -0
- morphogen/micromorphic/__init__.py +31 -0
- morphogen/micromorphic/damage.py +359 -0
- morphogen/micromorphic/ductile.py +534 -0
- morphogen/micromorphic/finite.py +220 -0
- morphogen/micromorphic/microfoam.py +787 -0
- morphogen/micromorphic/space.py +341 -0
- morphogen/models/__init__.py +195 -0
- morphogen/models/affine.py +384 -0
- morphogen/models/automata.py +592 -0
- morphogen/models/base.py +500 -0
- morphogen/models/boolean.py +310 -0
- morphogen/models/bouligand.py +331 -0
- morphogen/models/branching.py +241 -0
- morphogen/models/combination.py +430 -0
- morphogen/models/deadleaves.py +766 -0
- morphogen/models/design.py +289 -0
- morphogen/models/ebsd.py +206 -0
- morphogen/models/fibers.py +1476 -0
- morphogen/models/foam.py +594 -0
- morphogen/models/gaussian.py +314 -0
- morphogen/models/growth.py +459 -0
- morphogen/models/hardcore.py +317 -0
- morphogen/models/hierarchical.py +269 -0
- morphogen/models/honeycomb.py +749 -0
- morphogen/models/implicit.py +177 -0
- morphogen/models/laminate.py +470 -0
- morphogen/models/lattice.py +351 -0
- morphogen/models/lattice_field.py +345 -0
- morphogen/models/levelset_foam.py +563 -0
- morphogen/models/nacre.py +411 -0
- morphogen/models/nested.py +924 -0
- morphogen/models/osteons.py +374 -0
- morphogen/models/pieces.py +167 -0
- morphogen/models/planar.py +126 -0
- morphogen/models/reconstruction.py +203 -0
- morphogen/models/scale_rich.py +1409 -0
- morphogen/models/scale_rich_3d.py +1616 -0
- morphogen/models/tessellation.py +735 -0
- morphogen/models/tiling_field.py +302 -0
- morphogen/models/tpms.py +197 -0
- morphogen/models/transparent.py +406 -0
- morphogen/models/union.py +141 -0
- morphogen/optimization/__init__.py +43 -0
- morphogen/optimization/cell.py +295 -0
- morphogen/optimization/filters.py +115 -0
- morphogen/optimization/mma.py +226 -0
- morphogen/optimization/run.py +219 -0
- morphogen/optimization/topology.py +632 -0
- morphogen/orientations.py +568 -0
- morphogen/parallel.py +599 -0
- morphogen/pipeline.py +978 -0
- morphogen/primitives.py +188 -0
- morphogen/results.py +564 -0
- morphogen/rve/__init__.py +73 -0
- morphogen/rve/report.py +627 -0
- morphogen/rve/scaling.py +363 -0
- morphogen/rve/study.py +1054 -0
- morphogen/rve/windows.py +345 -0
- morphogen/seeding.py +51 -0
- morphogen/settings.py +118 -0
- morphogen/stopping.py +48 -0
- morphogen/symmetry.py +384 -0
- morphogen/templates/activator_inhibitor.yaml +22 -0
- morphogen/templates/aggregation.yaml +23 -0
- morphogen/templates/boolean_cylinders.yaml +20 -0
- morphogen/templates/boolean_spheres.yaml +22 -0
- morphogen/templates/bouligand.yaml +28 -0
- morphogen/templates/cellular_automaton.yaml +25 -0
- morphogen/templates/coated_spheres.yaml +26 -0
- morphogen/templates/contact_fibers.yaml +27 -0
- morphogen/templates/cox_nanocomposite.yaml +22 -0
- morphogen/templates/cross_linked_fibers.yaml +26 -0
- morphogen/templates/curved_arcs.yaml +28 -0
- morphogen/templates/curved_fibers.yaml +24 -0
- morphogen/templates/dead_leaves.yaml +22 -0
- morphogen/templates/delaunay_network.yaml +22 -0
- morphogen/templates/dense_packing.yaml +22 -0
- morphogen/templates/diffusion.yaml +33 -0
- morphogen/templates/ebsd.yaml +34 -0
- morphogen/templates/ebsd_map.ctf +3087 -0
- morphogen/templates/fracture_composite.yaml +42 -0
- morphogen/templates/fracture_rubber.yaml +47 -0
- morphogen/templates/gaussian_excursion.yaml +17 -0
- morphogen/templates/graded_lattice.yaml +24 -0
- morphogen/templates/hardcore_fibers.yaml +22 -0
- morphogen/templates/hardcore_spheres.yaml +22 -0
- morphogen/templates/hierarchical_lattice.yaml +22 -0
- morphogen/templates/homogenization_acoustic_foam.yaml +36 -0
- morphogen/templates/homogenization_beremin.yaml +50 -0
- morphogen/templates/homogenization_cleavage.yaml +51 -0
- morphogen/templates/homogenization_cleavage_band.yaml +55 -0
- morphogen/templates/homogenization_contact.yaml +43 -0
- morphogen/templates/homogenization_crack_closure.yaml +49 -0
- morphogen/templates/homogenization_crystal_plasticity.yaml +50 -0
- morphogen/templates/homogenization_crystal_plasticity_fft.yaml +52 -0
- morphogen/templates/homogenization_crystallization.yaml +30 -0
- morphogen/templates/homogenization_debonding.yaml +43 -0
- morphogen/templates/homogenization_detwinning.yaml +58 -0
- morphogen/templates/homogenization_ductile_damage.yaml +47 -0
- morphogen/templates/homogenization_fatigue.yaml +40 -0
- morphogen/templates/homogenization_grain_fracture.yaml +56 -0
- morphogen/templates/homogenization_gyroid.yaml +30 -0
- morphogen/templates/homogenization_intergranular.yaml +43 -0
- morphogen/templates/homogenization_interphase.yaml +42 -0
- morphogen/templates/homogenization_mixed_loading.yaml +33 -0
- morphogen/templates/homogenization_ntfa.yaml +56 -0
- morphogen/templates/homogenization_piezoelectric.yaml +27 -0
- morphogen/templates/homogenization_polycrystal.yaml +30 -0
- morphogen/templates/homogenization_polycrystal_inclusions.yaml +30 -0
- morphogen/templates/homogenization_poroelastic.yaml +26 -0
- morphogen/templates/homogenization_rubber.yaml +40 -0
- morphogen/templates/homogenization_slip_cleavage.yaml +50 -0
- morphogen/templates/homogenization_spheres.yaml +31 -0
- morphogen/templates/homogenization_transport.yaml +29 -0
- morphogen/templates/homogenization_twinning.yaml +54 -0
- morphogen/templates/homogenization_viscoelastic.yaml +34 -0
- morphogen/templates/homogenization_viscoplastic.yaml +42 -0
- morphogen/templates/homogenization_voronoi.yaml +26 -0
- morphogen/templates/homogenization_xfem.yaml +23 -0
- morphogen/templates/hyperuniform_cells.yaml +24 -0
- morphogen/templates/laguerre.yaml +18 -0
- morphogen/templates/laser_bending.yaml +35 -0
- morphogen/templates/laser_cells.yaml +38 -0
- morphogen/templates/laser_corrugated.yaml +36 -0
- morphogen/templates/level_set_foam.yaml +29 -0
- morphogen/templates/menger_sponge.yaml +17 -0
- morphogen/templates/nacre.yaml +25 -0
- morphogen/templates/nucleation_growth.yaml +25 -0
- morphogen/templates/optimize_auxetic.yaml +29 -0
- morphogen/templates/optimize_auxetic_3d.yaml +27 -0
- morphogen/templates/optimize_bulk.yaml +23 -0
- morphogen/templates/optimize_conductivity.yaml +20 -0
- morphogen/templates/osteons.yaml +28 -0
- morphogen/templates/penetrable_spheres.yaml +21 -0
- morphogen/templates/poisson_fibers.yaml +21 -0
- morphogen/templates/random_laminate.yaml +26 -0
- morphogen/templates/random_lattice.yaml +27 -0
- morphogen/templates/random_walk_fibers.yaml +26 -0
- morphogen/templates/reaction_diffusion.yaml +22 -0
- morphogen/templates/reconstruction.yaml +22 -0
- morphogen/templates/rve_cellular_automaton.yaml +23 -0
- morphogen/templates/rve_crystal_plasticity_fft.yaml +51 -0
- morphogen/templates/rve_multiphysics.yaml +43 -0
- morphogen/templates/rve_poisson_fibers.yaml +22 -0
- morphogen/templates/rve_poisson_fibers_fe.yaml +33 -0
- morphogen/templates/rve_voronoi_windows.yaml +20 -0
- morphogen/templates/scale_rich_network.yaml +29 -0
- morphogen/templates/scale_rich_plates.yaml +30 -0
- morphogen/templates/sequential_dead_leaves.yaml +25 -0
- morphogen/templates/strut_lattice.yaml +21 -0
- morphogen/templates/tile_assembly.yaml +28 -0
- morphogen/templates/tpms.yaml +19 -0
- morphogen/templates/trabecular_bone.yaml +29 -0
- morphogen/templates/transparent_dead_leaves.yaml +23 -0
- morphogen/templates/vascular_tree.yaml +23 -0
- morphogen/templates/voronoi.yaml +20 -0
- morphogen/templates/wood.yaml +34 -0
- morphogen/templates/workflow.yaml +56 -0
- morphogen/texture.py +665 -0
- morphogen/theory.py +162 -0
- morphogen/viz/__init__.py +12 -0
- morphogen/viz/export.py +244 -0
- morphogen/viz/figures.py +707 -0
- morphogen/viz/png.py +148 -0
- morphogen/viz/sections.py +696 -0
- morphogen/viz/surfaces.py +1352 -0
- morphogen/viz/video.py +904 -0
- morphogen/viz/workflow.py +488 -0
- morphogen-1.0.0.dist-info/METADATA +2316 -0
- morphogen-1.0.0.dist-info/RECORD +381 -0
- morphogen-1.0.0.dist-info/WHEEL +4 -0
- morphogen-1.0.0.dist-info/entry_points.txt +5 -0
- morphogen-1.0.0.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
"""Debonding in the cells of the nonlinear homogenization: the interfaces of the phases of
|
|
2
|
+
a periodic cell (or the boundaries of its grains) that open, break, close again and rub
|
|
3
|
+
along a loading path.
|
|
4
|
+
|
|
5
|
+
:class:`CohesiveCell` is the periodic element of :class:`~morphogen.homogenization.nonlinear.
|
|
6
|
+
NonlinearFEProblem` (the fluctuation and the macroscopic strain components as unknowns,
|
|
7
|
+
loading paths in strains, stresses or both, the behaviours of morphoGen's points) with the
|
|
8
|
+
interface elements of :mod:`morphogen.fracture.cohesive` between its phases: the bilinear
|
|
9
|
+
mixed-mode law, the exponential one, or the contact of lips without adhesion, each with
|
|
10
|
+
Coulomb's friction of the broken share of a point.
|
|
11
|
+
|
|
12
|
+
*Insertion on the torus* (:func:`open_cell`). A periodic cell is a torus: a node of a face
|
|
13
|
+
of the cell and its translate on the opposite face are one point of the medium, and so
|
|
14
|
+
are a face of an element there and its translate. The faces to open are chosen among the
|
|
15
|
+
faces that two elements share on the torus — two elements of different phases on either
|
|
16
|
+
side of a face of the cell included — and the nodes are duplicated there: the corners of
|
|
17
|
+
the elements around each point of the torus are grouped by the faces (through that point)
|
|
18
|
+
by which they remain connected, and each group gets its own node, or its own nodes where
|
|
19
|
+
the point has translates in the cell; the nodes of a group are linked by the periodic
|
|
20
|
+
conditions, those of different groups are not. An interface that crosses a face of the
|
|
21
|
+
cell thus goes on in the next cell, its two lips each with their images.
|
|
22
|
+
|
|
23
|
+
*Images.* An interface element that lies on a face of the cell joins a face of an element
|
|
24
|
+
there and the image of a face of the opposite side: the image of a node of displacement
|
|
25
|
+
``u`` moved by a period ``L`` is displaced by ``u + H L``, ``H`` the macroscopic
|
|
26
|
+
displacement gradient, so that its separation is the jump of the fluctuation, and the
|
|
27
|
+
forces that the image receives go to the node itself.
|
|
28
|
+
|
|
29
|
+
*Macroscopic stress.* The tractions of an interface are opposite on its two lips, at one
|
|
30
|
+
place of the reference cell: they carry no part of the macroscopic stress, the integral of
|
|
31
|
+
the stress of the points over the volume of the cell — but for the interfaces on its
|
|
32
|
+
faces, whose forces work in a change of ``H`` by the force that crosses the face times
|
|
33
|
+
the period (``Σ f ⊗ X`` over the nodes, the images at their own places). The macroscopic
|
|
34
|
+
strain is that of the points and of the separations: ``E = <ε> + 1/V ∫ sym([u] ⊗ n) dS``.
|
|
35
|
+
|
|
36
|
+
*Softening.* An interface that breaks at once has no equilibrium beyond a limit point
|
|
37
|
+
under prescribed strains (a snap-back): the steps are divided, and the viscous
|
|
38
|
+
regularization of Gao & Bower (2004), with the time of the path, lets them through
|
|
39
|
+
(``viscosity``; :mod:`morphogen.fracture.cohesive`).
|
|
40
|
+
|
|
41
|
+
*Iterations.* Lips open, close and rub along Newton's corrections. The first tangent of
|
|
42
|
+
a step keeps closed the lips of broken points that touched at its start; the line search
|
|
43
|
+
is nonmonotone (the residual may rise, below the largest of the last :data:`WINDOW`
|
|
44
|
+
iterates: an active-set iteration that does not cycle); and Coulomb's bound is reached
|
|
45
|
+
over an elastic slip (``slip``) — lips that come to touch, whose pressure and slip both
|
|
46
|
+
start from nothing, would otherwise slide along a direction that means nothing.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
from __future__ import annotations
|
|
50
|
+
|
|
51
|
+
import math
|
|
52
|
+
|
|
53
|
+
import numpy as np
|
|
54
|
+
import scipy.sparse as sp
|
|
55
|
+
from scipy.sparse.csgraph import connected_components
|
|
56
|
+
|
|
57
|
+
from morphogen.fracture.cohesive import (
|
|
58
|
+
_GAUSS,
|
|
59
|
+
_GAUSS6,
|
|
60
|
+
BILINEAR,
|
|
61
|
+
BROKEN,
|
|
62
|
+
CONTACT,
|
|
63
|
+
STATE,
|
|
64
|
+
Bilinear,
|
|
65
|
+
Contact,
|
|
66
|
+
Exponential,
|
|
67
|
+
Interfaces,
|
|
68
|
+
_interfaces,
|
|
69
|
+
_interfaces6,
|
|
70
|
+
_shape6,
|
|
71
|
+
_with_mid_nodes,
|
|
72
|
+
)
|
|
73
|
+
from morphogen.homogenization.nonlinear import Extended, NonlinearFEProblem, _SurfacePaths
|
|
74
|
+
from morphogen.mesh.tetra import TET_EDGES, TET_FACES, TetMesh
|
|
75
|
+
|
|
76
|
+
#: The curves that a cell records at each step (``PathResult.series``): the area of the
|
|
77
|
+
#: interfaces that is broken (reference area), their mean damage, their largest normal
|
|
78
|
+
#: opening and the energy dissipated by friction
|
|
79
|
+
SERIES = ("debonded_area", "interface_damage", "interface_opening", "interface_dissipation")
|
|
80
|
+
|
|
81
|
+
#: The number of iterates whose largest residual bounds the line search of Newton's
|
|
82
|
+
#: corrections (a nonmonotone search)
|
|
83
|
+
WINDOW = 4
|
|
84
|
+
|
|
85
|
+
#: The parameters of the laws of the interfaces given as mappings (:func:`interface_law`)
|
|
86
|
+
LAW_OPTIONS = {
|
|
87
|
+
"bilinear": (
|
|
88
|
+
"stiffness",
|
|
89
|
+
"normal_strength",
|
|
90
|
+
"shear_strength",
|
|
91
|
+
"mode_I",
|
|
92
|
+
"mode_II",
|
|
93
|
+
"eta",
|
|
94
|
+
"friction",
|
|
95
|
+
),
|
|
96
|
+
"exponential": ("strength", "energy", "beta", "penalty", "friction"),
|
|
97
|
+
"contact": ("stiffness", "tangential", "friction"),
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def interface_law(spec, young: float, size: float):
|
|
102
|
+
"""The traction-separation law of a mapping: its ``law`` (``"bilinear"``, by default,
|
|
103
|
+
``"exponential"`` or ``"contact"``: lips without adhesion) and the parameters of
|
|
104
|
+
:class:`~morphogen.fracture.cohesive.Bilinear` (``normal_strength`` and ``mode_I`` at
|
|
105
|
+
least), :class:`~morphogen.fracture.cohesive.Exponential` (``strength`` and
|
|
106
|
+
``energy``) or :class:`~morphogen.fracture.cohesive.Contact`. Left out: the shear
|
|
107
|
+
strength is the normal one, the energy of mode II that of mode I times the square of
|
|
108
|
+
the ratio of the strengths (the separations at failure in the ratio of the
|
|
109
|
+
strengths), and the penalty ``stiffness`` is ``100 young / size``: a Young's modulus
|
|
110
|
+
(the stiffest of the cell) over a length (the size of its interface elements)."""
|
|
111
|
+
spec = dict(spec)
|
|
112
|
+
kind = spec.pop("law", "bilinear")
|
|
113
|
+
if kind not in LAW_OPTIONS:
|
|
114
|
+
raise ValueError(f"interfaces: the law is one of {list(LAW_OPTIONS)}, got {kind!r}")
|
|
115
|
+
unknown = sorted(set(spec) - set(LAW_OPTIONS[kind]))
|
|
116
|
+
if unknown:
|
|
117
|
+
raise ValueError(
|
|
118
|
+
f"interfaces: unknown parameters {unknown} of the law {kind!r}; "
|
|
119
|
+
f"use {list(LAW_OPTIONS[kind])}"
|
|
120
|
+
)
|
|
121
|
+
try:
|
|
122
|
+
values = {key: None if value is None else float(value) for key, value in spec.items()}
|
|
123
|
+
except (TypeError, ValueError):
|
|
124
|
+
raise ValueError(f"interfaces: the parameters of the law {kind!r} are numbers") from None
|
|
125
|
+
friction = values.get("friction") or 0.0
|
|
126
|
+
penalty = values.get("stiffness") or 100.0 * float(young) / float(size)
|
|
127
|
+
try:
|
|
128
|
+
if kind == "exponential":
|
|
129
|
+
return Exponential(
|
|
130
|
+
strength=values["strength"],
|
|
131
|
+
energy=values["energy"],
|
|
132
|
+
beta=values.get("beta") or 1.0,
|
|
133
|
+
penalty=values.get("penalty"),
|
|
134
|
+
friction=friction,
|
|
135
|
+
)
|
|
136
|
+
if kind == "contact":
|
|
137
|
+
return Contact(penalty, friction=friction, tangential=values.get("tangential"))
|
|
138
|
+
normal = values["normal_strength"]
|
|
139
|
+
shear = values.get("shear_strength") or normal
|
|
140
|
+
mode_i = values["mode_I"]
|
|
141
|
+
mode_ii = values.get("mode_II") or mode_i * (shear / normal) ** 2
|
|
142
|
+
return Bilinear(penalty, normal, shear, mode_i, mode_ii, values.get("eta") or 2.0, friction)
|
|
143
|
+
except KeyError as exc:
|
|
144
|
+
raise ValueError(f"interfaces: the law {kind!r} needs {exc.args[0]!r}") from None
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _classes(mesh: TetMesh, periodic: bool) -> tuple[np.ndarray, np.ndarray]:
|
|
148
|
+
"""The point of the torus of each node (the first node of its class of translates)
|
|
149
|
+
and its translation from it, in periods; without periodicity, each node its own."""
|
|
150
|
+
cls = np.arange(mesh.n_nodes)
|
|
151
|
+
shift = np.zeros((mesh.n_nodes, 3), dtype=np.int64)
|
|
152
|
+
if periodic:
|
|
153
|
+
slave, master, moved = mesh.periodic_links()
|
|
154
|
+
cls[slave], shift[slave] = master, moved
|
|
155
|
+
return cls, shift
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _links(ids, copy, orig, shift) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
159
|
+
"""The periodic links of nodes ``ids`` that are copies ``copy`` of points of the torus
|
|
160
|
+
(the nodes of one copy are translates), from the translations ``shift`` of their
|
|
161
|
+
original nodes ``orig``: each node but the first of its copy, the first, and the
|
|
162
|
+
periods between them."""
|
|
163
|
+
by = np.lexsort((ids, copy))
|
|
164
|
+
ids, copy, orig = ids[by], copy[by], orig[by]
|
|
165
|
+
lead = np.ones(len(ids), dtype=bool)
|
|
166
|
+
lead[1:] = copy[1:] != copy[:-1]
|
|
167
|
+
start = np.maximum.accumulate(np.where(lead, np.arange(len(ids)), 0))
|
|
168
|
+
rest = ~lead
|
|
169
|
+
return ids[rest], ids[start[rest]], shift[orig[rest]] - shift[orig[start[rest]]]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _selection(mesh: TetMesh, faces, e1, e2, centroids):
|
|
173
|
+
"""The faces to open among those that the elements ``e1`` and ``e2`` share, and
|
|
174
|
+
whether their two sides are to be swapped (side -: the lower label)."""
|
|
175
|
+
if callable(faces):
|
|
176
|
+
selected = np.asarray(faces(centroids), dtype=bool)
|
|
177
|
+
if selected.shape != e1.shape:
|
|
178
|
+
raise ValueError(f"open_cell: one value per shared face ({len(e1)})")
|
|
179
|
+
return selected, np.zeros(len(e1), dtype=bool)
|
|
180
|
+
pairs = None
|
|
181
|
+
if isinstance(faces, str):
|
|
182
|
+
if faces not in ("phases", "grains"):
|
|
183
|
+
raise ValueError(
|
|
184
|
+
"open_cell: 'phases', 'grains', pairs of phases or a function of centroids"
|
|
185
|
+
)
|
|
186
|
+
if faces == "grains" and mesh.cell is None:
|
|
187
|
+
raise ValueError("open_cell: 'grains' needs the grain of each element (mesh.cell)")
|
|
188
|
+
label = mesh.phase if faces == "phases" else mesh.cell
|
|
189
|
+
else:
|
|
190
|
+
try:
|
|
191
|
+
pairs = {tuple(sorted(int(p) for p in pair)) for pair in faces}
|
|
192
|
+
except (TypeError, ValueError):
|
|
193
|
+
pairs = None
|
|
194
|
+
if not pairs or any(len(pair) != 2 or pair[0] == pair[1] for pair in pairs):
|
|
195
|
+
raise ValueError(
|
|
196
|
+
"open_cell: 'phases', 'grains', pairs of two different phases or a "
|
|
197
|
+
"function of centroids"
|
|
198
|
+
)
|
|
199
|
+
label = mesh.phase
|
|
200
|
+
a, b = label[e1], label[e2]
|
|
201
|
+
selected = a != b
|
|
202
|
+
if pairs is not None:
|
|
203
|
+
low, high = np.minimum(a, b), np.maximum(a, b)
|
|
204
|
+
wanted = np.zeros(len(a), dtype=bool)
|
|
205
|
+
for p, q in pairs:
|
|
206
|
+
wanted |= (low == p) & (high == q)
|
|
207
|
+
selected &= wanted
|
|
208
|
+
return selected, a > b
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _open_corners(mesh: TetMesh, faces, periodic: bool):
|
|
212
|
+
""":func:`open_cell` for a mesh of 4-node elements; also the copy of the torus of
|
|
213
|
+
each node of the opened mesh (-1 for a node of no element)."""
|
|
214
|
+
tets = np.asarray(mesh.elements[:, :4], dtype=np.int64)
|
|
215
|
+
m, n = len(tets), mesh.n_nodes
|
|
216
|
+
size = np.asarray(mesh.size, dtype=float)
|
|
217
|
+
cls, shift = _classes(mesh, periodic)
|
|
218
|
+
local = np.asarray(TET_FACES)
|
|
219
|
+
corners = tets[:, local] # elements x 4 faces x 3
|
|
220
|
+
# the corners of each face in an order that its translates share: by their point of
|
|
221
|
+
# the torus, then by their translation
|
|
222
|
+
base = int(np.abs(shift).max(initial=0)) + 1
|
|
223
|
+
code = cls[corners]
|
|
224
|
+
for c in range(3):
|
|
225
|
+
code = code * (2 * base + 1) + shift[corners][..., c] + base
|
|
226
|
+
order = np.argsort(code, axis=-1, kind="stable")
|
|
227
|
+
canon = np.take_along_axis(corners, order, axis=-1)
|
|
228
|
+
moved = shift[canon]
|
|
229
|
+
key = np.concatenate(
|
|
230
|
+
[cls[canon], (moved[:, :, 1:] - moved[:, :, :1]).reshape(m, 4, 6)], axis=-1
|
|
231
|
+
).reshape(4 * m, 9)
|
|
232
|
+
_, inverse, counts = np.unique(key, axis=0, return_inverse=True, return_counts=True)
|
|
233
|
+
inverse = inverse.ravel()
|
|
234
|
+
if counts.max(initial=0) > 2:
|
|
235
|
+
raise ValueError("open_cell: a face shared by more than two elements")
|
|
236
|
+
paired = counts[inverse] == 2
|
|
237
|
+
if periodic: # every face of the boundary of the cell has its translate
|
|
238
|
+
if mesh.whole:
|
|
239
|
+
outer = mesh.outer.ravel()
|
|
240
|
+
else:
|
|
241
|
+
tol = mesh.tolerance()
|
|
242
|
+
low = np.all((np.abs(mesh.nodes - mesh.lower) <= tol)[corners], axis=2)
|
|
243
|
+
high = np.all((np.abs(mesh.nodes - mesh.upper) <= tol)[corners], axis=2)
|
|
244
|
+
outer = np.any(low | high, axis=-1).ravel()
|
|
245
|
+
if np.any(outer & ~paired):
|
|
246
|
+
raise ValueError(
|
|
247
|
+
"open_cell: the opposite faces of the cell do not carry the same faces of "
|
|
248
|
+
"elements (a periodic mesh: conforming_mesh(..., periodic=True), or the "
|
|
249
|
+
"mesh of a periodic voxel image)"
|
|
250
|
+
)
|
|
251
|
+
by = np.argsort(inverse, kind="stable")
|
|
252
|
+
same = inverse[by][1:] == inverse[by][:-1]
|
|
253
|
+
first, second = by[:-1][same], by[1:][same]
|
|
254
|
+
e1, f1, e2, f2 = first // 4, first % 4, second // 4, second % 4
|
|
255
|
+
centroids = mesh.nodes[corners[e1, f1]].mean(axis=1)
|
|
256
|
+
selected, swap = _selection(mesh, faces, e1, e2, centroids)
|
|
257
|
+
e1, e2 = np.where(swap, e2, e1), np.where(swap, e1, e2)
|
|
258
|
+
f1, f2 = np.where(swap, f2, f1), np.where(swap, f1, f2)
|
|
259
|
+
# the local nodes of the two sides of each shared face, in the shared order
|
|
260
|
+
l1 = np.take_along_axis(local[f1], order[e1, f1], axis=1)
|
|
261
|
+
l2 = np.take_along_axis(local[f2], order[e2, f2], axis=1)
|
|
262
|
+
kept = ~selected
|
|
263
|
+
graph = sp.coo_matrix(
|
|
264
|
+
(
|
|
265
|
+
np.ones(3 * int(kept.sum())),
|
|
266
|
+
((4 * e1[kept, None] + l1[kept]).ravel(), (4 * e2[kept, None] + l2[kept]).ravel()),
|
|
267
|
+
),
|
|
268
|
+
shape=(4 * m, 4 * m),
|
|
269
|
+
)
|
|
270
|
+
n_groups, group = connected_components(graph, directed=False)
|
|
271
|
+
# the points away from the opened faces keep their nodes, whatever holds their elements
|
|
272
|
+
flat = tets.ravel()
|
|
273
|
+
touched = np.zeros(n, dtype=bool)
|
|
274
|
+
touched[cls[np.take_along_axis(tets[e1[selected]], l1[selected], axis=1)]] = True
|
|
275
|
+
group = np.where(touched[cls[flat]], group, n_groups + cls[flat])
|
|
276
|
+
_, group = np.unique(group, return_inverse=True)
|
|
277
|
+
n_groups = int(group.max(initial=-1)) + 1
|
|
278
|
+
pair, inverse = np.unique(flat * n_groups + group, return_inverse=True)
|
|
279
|
+
orig, copy = pair // n_groups, pair % n_groups
|
|
280
|
+
head = np.ones(len(pair), dtype=bool)
|
|
281
|
+
head[1:] = orig[1:] != orig[:-1]
|
|
282
|
+
ids = np.where(head, orig, 0)
|
|
283
|
+
ids[~head] = n + np.arange(int((~head).sum()))
|
|
284
|
+
new_tets = ids[inverse.ravel()].reshape(m, 4)
|
|
285
|
+
opened = mesh._derived(np.concatenate([mesh.nodes, mesh.nodes[orig[~head]]]), new_tets)
|
|
286
|
+
node_copy = np.full(opened.n_nodes, -1, dtype=np.int64)
|
|
287
|
+
node_copy[ids] = copy
|
|
288
|
+
links = _links(ids, copy, orig, shift)
|
|
289
|
+
# the interface elements: the normal from side - to side +
|
|
290
|
+
a, b = e1[selected], e2[selected]
|
|
291
|
+
la, lb = l1[selected], l2[selected]
|
|
292
|
+
minus = np.take_along_axis(new_tets[a], la, axis=1)
|
|
293
|
+
plus = np.take_along_axis(new_tets[b], lb, axis=1)
|
|
294
|
+
oa, ob = np.take_along_axis(tets[a], la, axis=1), np.take_along_axis(tets[b], lb, axis=1)
|
|
295
|
+
periods = shift[ob[:, 0]] - shift[oa[:, 0]]
|
|
296
|
+
x = mesh.nodes[oa]
|
|
297
|
+
normal = np.cross(x[:, 1] - x[:, 0], x[:, 2] - x[:, 0])
|
|
298
|
+
towards = mesh.nodes[tets[b]].mean(axis=1) - periods * size - mesh.nodes[tets[a]].mean(axis=1)
|
|
299
|
+
flip = np.einsum("ij,ij->i", normal, towards) < 0
|
|
300
|
+
minus[flip] = minus[flip][:, [0, 2, 1]]
|
|
301
|
+
plus[flip] = plus[flip][:, [0, 2, 1]]
|
|
302
|
+
phases = np.stack([mesh.phase[a], mesh.phase[b]], axis=1)
|
|
303
|
+
return opened, Interfaces(minus, plus, phases), periods, links, node_copy
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def open_cell(mesh: TetMesh, faces="phases", *, periodic: bool = True):
|
|
307
|
+
"""Open faces of the mesh of a periodic cell on its torus (see the module): ``faces``
|
|
308
|
+
is ``"phases"`` (the faces between different phases; side - the lower phase),
|
|
309
|
+
``"grains"`` (between different grains of a polycrystal, ``mesh.cell``), pairs of
|
|
310
|
+
phases (the faces between the two phases of a pair) or a function of the centroids
|
|
311
|
+
(rows) of the faces that two elements share, returning a mask.
|
|
312
|
+
|
|
313
|
+
Returns the mesh with the duplicated nodes, whose :meth:`~morphogen.mesh.tetra.
|
|
314
|
+
TetMesh.periodic_links` are those of the copies (the two lips of an interface that
|
|
315
|
+
crosses a face of the cell each linked to their own translates); the interface
|
|
316
|
+
elements of the opened faces; and for each of them the periods (three integers) from
|
|
317
|
+
its side - to its side +: zeros inside the cell, the period that an interface on a
|
|
318
|
+
face of the cell crosses. ``periodic`` false: the faces of the cell are not joined
|
|
319
|
+
(:func:`~morphogen.fracture.cohesive.insert_interfaces`), as for kinematic
|
|
320
|
+
conditions. A mesh of 10-node elements is opened by its corners, its mid-edge nodes
|
|
321
|
+
made again where they were."""
|
|
322
|
+
if mesh.order == 1:
|
|
323
|
+
opened, interfaces, periods, links, _ = _open_corners(mesh, faces, periodic)
|
|
324
|
+
opened._cache["links"] = links
|
|
325
|
+
return opened, interfaces, periods
|
|
326
|
+
opened, interfaces, periods, links, node_copy = _open_corners(mesh.linear(), faces, periodic)
|
|
327
|
+
quad, interfaces = _with_mid_nodes(mesh, opened, interfaces)
|
|
328
|
+
# the mid-edge nodes: translates on the torus when their original nodes are, between
|
|
329
|
+
# the same copies of their two corners
|
|
330
|
+
cls, shift = _classes(mesh, periodic)
|
|
331
|
+
mids, index = np.unique(quad.elements[:, 4:].ravel(), return_index=True)
|
|
332
|
+
orig = mesh.elements[:, 4:].ravel()[index]
|
|
333
|
+
ends = node_copy[quad.elements[:, TET_EDGES].reshape(-1, 2)[index]]
|
|
334
|
+
key = np.column_stack([cls[orig], ends.min(axis=1), ends.max(axis=1)])
|
|
335
|
+
_, copy = np.unique(key, axis=0, return_inverse=True)
|
|
336
|
+
more = _links(mids, copy.ravel(), orig, shift)
|
|
337
|
+
quad._cache["links"] = tuple(np.concatenate([a, b]) for a, b in zip(links, more, strict=True))
|
|
338
|
+
return quad, interfaces, periods
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def _laws_by_pair(law) -> dict | None:
|
|
342
|
+
"""The laws of a mapping of pairs of phases (keys: two phases; the pairs sorted), or
|
|
343
|
+
None for one law: an object, or a mapping of its parameters."""
|
|
344
|
+
if not isinstance(law, dict):
|
|
345
|
+
if not (hasattr(law, "kind") and hasattr(law, "params")):
|
|
346
|
+
raise TypeError(
|
|
347
|
+
"CohesiveCell: a traction-separation law (Bilinear, Exponential or Contact "
|
|
348
|
+
"of morphogen.fracture), a mapping of its parameters, or a mapping of pairs "
|
|
349
|
+
"of phases to their laws"
|
|
350
|
+
)
|
|
351
|
+
return None
|
|
352
|
+
if not law or not all(isinstance(key, (tuple, list, frozenset)) for key in law):
|
|
353
|
+
return None
|
|
354
|
+
out = {}
|
|
355
|
+
for key, value in law.items():
|
|
356
|
+
try:
|
|
357
|
+
pair = tuple(sorted(int(p) for p in key))
|
|
358
|
+
except (TypeError, ValueError):
|
|
359
|
+
pair = ()
|
|
360
|
+
if len(pair) != 2:
|
|
361
|
+
raise ValueError(f"CohesiveCell: laws by pairs of two phases, got the key {key!r}")
|
|
362
|
+
if not isinstance(value, dict) and not (
|
|
363
|
+
hasattr(value, "kind") and hasattr(value, "params")
|
|
364
|
+
):
|
|
365
|
+
raise TypeError(f"CohesiveCell: the law of the pair {pair}: a law, or its parameters")
|
|
366
|
+
out[pair] = value
|
|
367
|
+
return out
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def _owners(mesh: TetMesh, interfaces: Interfaces) -> np.ndarray:
|
|
371
|
+
"""The elements on the two sides of each interface element (elements x 2): those of
|
|
372
|
+
which the corners of its side - and of its side + are a face."""
|
|
373
|
+
corners = np.sort(mesh.elements[:, np.asarray(TET_FACES)].reshape(-1, 3), axis=1)
|
|
374
|
+
sides = [np.sort(side[:, :3], axis=1) for side in (interfaces.minus, interfaces.plus)]
|
|
375
|
+
_, inverse = np.unique(np.concatenate([corners, *sides]), axis=0, return_inverse=True)
|
|
376
|
+
inverse = inverse.ravel()
|
|
377
|
+
owner = np.full(int(inverse.max()) + 1, -1, dtype=np.int64)
|
|
378
|
+
owner[inverse[: len(corners)]] = np.repeat(np.arange(mesh.n_elements), 4)
|
|
379
|
+
n = interfaces.n_elements
|
|
380
|
+
found = owner[inverse[len(corners) :]].reshape(2, n).T
|
|
381
|
+
if np.any(found < 0):
|
|
382
|
+
raise ValueError("CohesiveCell: interface elements that are not faces of the mesh")
|
|
383
|
+
return found
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def _point_positions(nodes: np.ndarray, faces: np.ndarray) -> np.ndarray:
|
|
387
|
+
"""The positions (elements x points x 3) of the integration points of interface
|
|
388
|
+
elements, on their side ``faces`` (3 or 6 nodes)."""
|
|
389
|
+
x = nodes[faces]
|
|
390
|
+
if faces.shape[1] == 3:
|
|
391
|
+
shapes = np.array([[1.0 - xi - eta, xi, eta] for xi, eta in _GAUSS])
|
|
392
|
+
else:
|
|
393
|
+
shapes = np.empty((len(_GAUSS6), 6))
|
|
394
|
+
dxi, deta = np.empty(6), np.empty(6)
|
|
395
|
+
for g, (xi, eta, _) in enumerate(_GAUSS6):
|
|
396
|
+
_shape6(xi, eta, shapes[g], dxi, deta)
|
|
397
|
+
return np.einsum("gi,eic->egc", shapes, x)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class CohesiveCell(NonlinearFEProblem):
|
|
401
|
+
"""A cell whose interfaces may debond along a loading path (see the module): the
|
|
402
|
+
``mesh`` of its phases (4- or 10-node tetrahedra; periodic conditions need the same
|
|
403
|
+
faces of elements on the opposite faces of the cell), their ``materials``, the
|
|
404
|
+
traction-separation ``law`` of the interfaces (:class:`~morphogen.fracture.cohesive.
|
|
405
|
+
Bilinear`, :class:`~morphogen.fracture.cohesive.Exponential`, or :class:`~morphogen.
|
|
406
|
+
fracture.cohesive.Contact` for lips without adhesion, each with its coefficient of
|
|
407
|
+
``friction``; or a mapping of its parameters: :func:`interface_law`, with the
|
|
408
|
+
stiffest Young's modulus of the cell and the size of its interface elements) and the
|
|
409
|
+
boundary conditions (``"periodic"`` or ``"kubc"``). A law for each pair of phases: a
|
|
410
|
+
mapping of the pairs to their laws, ``{(0, 1): law, (0, 2): other}`` — the interfaces
|
|
411
|
+
are then those of these pairs, unless ``faces`` says otherwise (``"grains"``: every
|
|
412
|
+
boundary of a grain, with the law of the two phases that it parts, ``(1, 1)`` for two
|
|
413
|
+
grains of the phase 1).
|
|
414
|
+
|
|
415
|
+
``faces``: the faces that are interfaces (:func:`open_cell`: ``"phases"``,
|
|
416
|
+
``"grains"``, pairs of phases or a function of centroids). ``viscosity``: the time of
|
|
417
|
+
the viscous regularization of the damage of the interfaces (Gao & Bower 2004), in the
|
|
418
|
+
time of the paths; 0: none. ``slip``: the elastic slip of the friction, over which
|
|
419
|
+
lips that stick reach Coulomb's bound (a stiffness of the stick of ``μ p / slip``,
|
|
420
|
+
whatever that of the law; by default 0.005 times the size of the interface
|
|
421
|
+
elements): the friction of lips that come to touch, whose pressure and slip both
|
|
422
|
+
start from nothing, would otherwise have no direction. The other options are those of
|
|
423
|
+
:class:`~morphogen.homogenization.nonlinear.NonlinearFEProblem` (``kinematics``:
|
|
424
|
+
``"small"`` by default, or ``"finite"``, the tractions then turning with the
|
|
425
|
+
interfaces; ``newton_tol``, ``max_cuts``...); the tangent is factorized
|
|
426
|
+
(``solver="direct"``) and kept whole.
|
|
427
|
+
|
|
428
|
+
:meth:`run` returns the response to a path with, in its ``series`` (columns of its
|
|
429
|
+
curves, :data:`SERIES`), at each step the area of the interfaces whose points are
|
|
430
|
+
broken ``debonded_area`` (reference area), their mean damage ``interface_damage``,
|
|
431
|
+
their largest normal opening ``interface_opening`` and the energy that friction
|
|
432
|
+
dissipated ``interface_dissipation``. Its fields have, for each element, the damage
|
|
433
|
+
and the opening of the interface elements on its faces (``interface_damage``,
|
|
434
|
+
``interface_opening``: the largest of their means; zero away from the interfaces).
|
|
435
|
+
|
|
436
|
+
``laws``: the laws of the interfaces, by pair of phases; ``law``: the first of them."""
|
|
437
|
+
|
|
438
|
+
def __init__(
|
|
439
|
+
self,
|
|
440
|
+
mesh: TetMesh,
|
|
441
|
+
materials,
|
|
442
|
+
law,
|
|
443
|
+
bc: str = "periodic",
|
|
444
|
+
*,
|
|
445
|
+
faces="phases",
|
|
446
|
+
viscosity: float = 0.0,
|
|
447
|
+
slip: float | None = None,
|
|
448
|
+
**options,
|
|
449
|
+
):
|
|
450
|
+
if options.pop("solver", "direct") not in ("direct", "auto"):
|
|
451
|
+
raise ValueError(
|
|
452
|
+
"CohesiveCell: the tangent of the interfaces is factorized (solver 'direct')"
|
|
453
|
+
)
|
|
454
|
+
by_pair = _laws_by_pair(law)
|
|
455
|
+
if by_pair is not None and isinstance(faces, str) and faces == "phases":
|
|
456
|
+
faces = [pair for pair in by_pair if pair[0] != pair[1]]
|
|
457
|
+
if not (math.isfinite(viscosity) and viscosity >= 0):
|
|
458
|
+
raise ValueError("CohesiveCell: a viscosity of 0 or more")
|
|
459
|
+
options.setdefault("tangent", "full")
|
|
460
|
+
super().__init__(mesh, materials, bc, solver="direct", **options)
|
|
461
|
+
if self.empty:
|
|
462
|
+
raise ValueError("CohesiveCell: no load-carrying material in the cell")
|
|
463
|
+
self.viscosity = float(viscosity)
|
|
464
|
+
# the mesh that carries the load (voids and floating parts left out), opened
|
|
465
|
+
opened, interfaces, periods = open_cell(self.mesh, faces, periodic=self.bc == "periodic")
|
|
466
|
+
if not interfaces.n_elements:
|
|
467
|
+
raise ValueError("CohesiveCell: no interface to open in the cell (faces)")
|
|
468
|
+
self.mesh, self.interfaces, self.periods = opened, interfaces, periods
|
|
469
|
+
self._areas = interfaces.areas(opened)
|
|
470
|
+
self._set_laws(law if by_pair is None else by_pair, materials)
|
|
471
|
+
#: the opening below which the lips of a point touch, for the predictor of a step
|
|
472
|
+
self._touch = 1e-6 * math.sqrt(float(self._areas.mean()))
|
|
473
|
+
self.slip = 0.005 * math.sqrt(float(self._areas.mean())) if slip is None else float(slip)
|
|
474
|
+
if not (math.isfinite(self.slip) and self.slip > 0):
|
|
475
|
+
raise ValueError("CohesiveCell: a positive elastic slip")
|
|
476
|
+
plus = interfaces.plus.copy()
|
|
477
|
+
crossing = np.any(periods != 0, axis=1)
|
|
478
|
+
node, offset = None, None
|
|
479
|
+
if crossing.any(): # the images of the nodes of the sides + across the faces
|
|
480
|
+
mine = interfaces.plus[crossing]
|
|
481
|
+
moved = np.repeat(periods[crossing][:, None, :], mine.shape[1], axis=1)
|
|
482
|
+
key = np.column_stack([mine.ravel(), moved.reshape(-1, 3)])
|
|
483
|
+
images, inverse = np.unique(key, axis=0, return_inverse=True)
|
|
484
|
+
plus[crossing] = opened.n_nodes + inverse.reshape(mine.shape)
|
|
485
|
+
node, offset = images[:, 0], -images[:, 1:] * np.asarray(opened.size, dtype=float)
|
|
486
|
+
self._extended = Extended(opened.nodes, node, offset)
|
|
487
|
+
self._plus = np.ascontiguousarray(plus)
|
|
488
|
+
side = np.hstack([interfaces.minus, self._plus])
|
|
489
|
+
nd = 3 * side.shape[1]
|
|
490
|
+
self._idofs = (3 * side[:, :, None] + np.arange(3)).reshape(len(side), nd)
|
|
491
|
+
self._rows = np.repeat(self._idofs, nd, axis=1).ravel()
|
|
492
|
+
self._cols = np.tile(self._idofs, (1, nd)).ravel()
|
|
493
|
+
self._points = 3 if interfaces.order == 1 else 6
|
|
494
|
+
self._owners = _owners(opened, interfaces)
|
|
495
|
+
# parts that the interfaces alone hold, once they are broken: a shift of the
|
|
496
|
+
# diagonal of the tangent
|
|
497
|
+
self.regularization = max(self.regularization, 1e-12)
|
|
498
|
+
# the scales of the residuals have floors: a cell whose interfaces are broken
|
|
499
|
+
# carries nothing, and no residual is small against forces that are zero. The
|
|
500
|
+
# force of the strength of the interfaces on one of their elements, and that
|
|
501
|
+
# strength as a stress of the cell
|
|
502
|
+
strength = self._strength(materials)
|
|
503
|
+
self._floor = strength * float(self._areas.mean())
|
|
504
|
+
self._floor_stress = strength * self.box_volume
|
|
505
|
+
#: the line search of Newton's corrections is not monotone: the residual may
|
|
506
|
+
#: rise, below the largest of this number of the last iterates, where lips open
|
|
507
|
+
#: and close along a correction (an active-set iteration)
|
|
508
|
+
self._window = WINDOW
|
|
509
|
+
self._virial = 0.0
|
|
510
|
+
self._dt = 0.0
|
|
511
|
+
self._begin()
|
|
512
|
+
|
|
513
|
+
def _set_laws(self, law, materials) -> None:
|
|
514
|
+
"""The laws of the interface elements: one for all (a law, or a mapping of its
|
|
515
|
+
parameters), or one for each pair of phases (a mapping of the pairs to theirs)."""
|
|
516
|
+
from morphogen.contact.problem import stiffest_modulus
|
|
517
|
+
|
|
518
|
+
stiffest = stiffest_modulus(materials, self.mesh.phase)
|
|
519
|
+
size = math.sqrt(float(self._areas.mean()))
|
|
520
|
+
|
|
521
|
+
def made(spec):
|
|
522
|
+
return interface_law(spec, stiffest, size) if isinstance(spec, dict) else spec
|
|
523
|
+
|
|
524
|
+
n = self.interfaces.n_elements
|
|
525
|
+
if not isinstance(law, dict) or not all(isinstance(key, tuple) for key in law):
|
|
526
|
+
self.laws = {None: made(law)}
|
|
527
|
+
index = [None]
|
|
528
|
+
else:
|
|
529
|
+
pairs = np.sort(self.interfaces.phases, axis=1)
|
|
530
|
+
found = sorted({(int(p), int(q)) for p, q in pairs})
|
|
531
|
+
missing = [pair for pair in found if pair not in law]
|
|
532
|
+
if missing:
|
|
533
|
+
raise ValueError(
|
|
534
|
+
f"CohesiveCell: no law for the interfaces between the phases {missing} "
|
|
535
|
+
f"(laws: {sorted(law)})"
|
|
536
|
+
)
|
|
537
|
+
self.laws = {pair: made(law[pair]) for pair in found}
|
|
538
|
+
index = [np.flatnonzero((pairs[:, 0] == p) & (pairs[:, 1] == q)) for p, q in found]
|
|
539
|
+
self.law = next(iter(self.laws.values()))
|
|
540
|
+
self.par = self.law.params()
|
|
541
|
+
#: for each law: its parameters, its interface elements (None: all of them)
|
|
542
|
+
self._groups = [
|
|
543
|
+
(one, one.params(), None if where is None or len(where) == n else where)
|
|
544
|
+
for one, where in zip(self.laws.values(), index, strict=True)
|
|
545
|
+
]
|
|
546
|
+
|
|
547
|
+
def _strength(self, materials) -> float:
|
|
548
|
+
"""The strength of the interfaces: the lowest of those of their laws, or for lips
|
|
549
|
+
without adhesion the stress of a strain of 1e-6 in the stiffest phase."""
|
|
550
|
+
values = [
|
|
551
|
+
getattr(law, name)
|
|
552
|
+
for law in self.laws.values()
|
|
553
|
+
for name in ("normal_strength", "shear_strength", "strength")
|
|
554
|
+
if hasattr(law, name)
|
|
555
|
+
]
|
|
556
|
+
if values:
|
|
557
|
+
return float(min(values))
|
|
558
|
+
from morphogen.contact.problem import stiffest_modulus
|
|
559
|
+
|
|
560
|
+
return 1e-6 * stiffest_modulus(materials, self.mesh.phase)
|
|
561
|
+
|
|
562
|
+
# -- the periodic conditions of the opened mesh ------------------------------------------
|
|
563
|
+
|
|
564
|
+
def _reduction(self, key):
|
|
565
|
+
if key[0] != "periodic":
|
|
566
|
+
return super()._reduction(key)
|
|
567
|
+
n = self.mesh.n_nodes
|
|
568
|
+
slave, master, _ = self.mesh.periodic_links()
|
|
569
|
+
target = np.arange(n)
|
|
570
|
+
target[slave] = master
|
|
571
|
+
masters = np.flatnonzero(target == np.arange(n))
|
|
572
|
+
position = np.full(n, -1)
|
|
573
|
+
position[masters] = np.arange(masters.size)
|
|
574
|
+
t_nodes = sp.csr_matrix(
|
|
575
|
+
(np.ones(n), (np.arange(n), position[target])), shape=(n, masters.size)
|
|
576
|
+
)
|
|
577
|
+
t = sp.kron(t_nodes, sp.identity(3), format="csr")
|
|
578
|
+
rep = (masters[:, None] * 3 + np.arange(3)).ravel()
|
|
579
|
+
keep = np.arange(0 if self.has_voids else 3, t.shape[1]) # translations: a node held
|
|
580
|
+
return t[:, keep].tocsr(), rep[keep]
|
|
581
|
+
|
|
582
|
+
def _stiffness(self):
|
|
583
|
+
raise NotImplementedError(
|
|
584
|
+
"CohesiveCell: the response to loading paths (run); the linear properties are "
|
|
585
|
+
"those of the mesh without interfaces (FEElasticProblem)"
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
# -- the forces of the interfaces ----------------------------------------------------------
|
|
589
|
+
|
|
590
|
+
def _discretization(self) -> _SurfacePaths:
|
|
591
|
+
return _SurfacePaths(self)
|
|
592
|
+
|
|
593
|
+
def _surface_forces(self, x, tangent: bool, first: bool):
|
|
594
|
+
"""The forces of the interface elements at the positions ``x`` of the extended
|
|
595
|
+
nodes, and their tangent; the state of their points is tried from that of the
|
|
596
|
+
start of the step. ``first``: the tangent is that of the predictor of a step, the
|
|
597
|
+
lips that touched at its start closed, and sticking where they are pressed —
|
|
598
|
+
those of broken points whose opening was below a millionth of the size of the
|
|
599
|
+
interface elements: a cell brought back to its shape at rest has all its lips
|
|
600
|
+
there, open or closed by a round-off."""
|
|
601
|
+
ext = self._extended
|
|
602
|
+
u = np.ascontiguousarray(x - ext.reference)
|
|
603
|
+
ni, nd = self._idofs.shape
|
|
604
|
+
fe = np.zeros((ni, nd))
|
|
605
|
+
ke = np.zeros((ni if tangent else 1, nd, nd))
|
|
606
|
+
trial = np.zeros_like(self._state)
|
|
607
|
+
kernel, gauss = (_interfaces, _GAUSS) if nd == 18 else (_interfaces6, _GAUSS6)
|
|
608
|
+
predict = tangent and first
|
|
609
|
+
start = None
|
|
610
|
+
if predict: # the lips that touched at the start of the step
|
|
611
|
+
start = self._state.copy()
|
|
612
|
+
start[..., 4] = np.where(start[..., 4] <= self._touch, 0.0, start[..., 4])
|
|
613
|
+
for law, base, where in self._groups:
|
|
614
|
+
par = base.copy()
|
|
615
|
+
par[6] = self._dt / self.viscosity if self.viscosity > 0 else 0.0
|
|
616
|
+
par[9] = -self.slip # the elastic slip of the friction
|
|
617
|
+
every = where is None
|
|
618
|
+
minus = self.interfaces.minus if every else self.interfaces.minus[where]
|
|
619
|
+
plus = self._plus if every else self._plus[where]
|
|
620
|
+
state = self._state if every else self._state[where]
|
|
621
|
+
mine = (trial, fe, ke) if every else (
|
|
622
|
+
np.zeros_like(state),
|
|
623
|
+
np.zeros((len(where), nd)),
|
|
624
|
+
np.zeros((len(where) if tangent else 1, nd, nd)),
|
|
625
|
+
) # fmt: skip
|
|
626
|
+
shared = (ext.reference, minus, plus, u, self.finite, law.kind)
|
|
627
|
+
kernel(*shared, par, state, mine[0], gauss, tangent and not predict, mine[1], mine[2])
|
|
628
|
+
if predict:
|
|
629
|
+
par = par.copy()
|
|
630
|
+
par[10] = 1.0
|
|
631
|
+
begun = start if every else start[where]
|
|
632
|
+
kernel(*shared, par, begun, np.zeros_like(state), gauss, True,
|
|
633
|
+
np.zeros_like(mine[1]), mine[2]) # fmt: skip
|
|
634
|
+
if not every:
|
|
635
|
+
trial[where], fe[where] = mine[0], mine[1]
|
|
636
|
+
if tangent:
|
|
637
|
+
ke[where] = mine[2]
|
|
638
|
+
self._trial = trial
|
|
639
|
+
n = 3 * len(ext.node)
|
|
640
|
+
f = np.bincount(self._idofs.ravel(), fe.ravel(), minlength=n)
|
|
641
|
+
if not tangent:
|
|
642
|
+
return f, None
|
|
643
|
+
return f, sp.csr_matrix((ke.ravel(), (self._rows, self._cols)), shape=(n, n))
|
|
644
|
+
|
|
645
|
+
def _extra_stress(self):
|
|
646
|
+
"""The part of the macroscopic stress that the interfaces on the faces of the
|
|
647
|
+
cell carry (see the module), at the last evaluation."""
|
|
648
|
+
return self._virial / self.box_volume
|
|
649
|
+
|
|
650
|
+
# -- the state of the interfaces along a path ---------------------------------------------
|
|
651
|
+
|
|
652
|
+
def _begin(self) -> None:
|
|
653
|
+
"""Sound interfaces, before a path."""
|
|
654
|
+
self._state = np.zeros((self.interfaces.n_elements, self._points, STATE))
|
|
655
|
+
self._trial = self._state.copy()
|
|
656
|
+
self._virial = 0.0
|
|
657
|
+
self._history = [(0.0, 0.0, 0.0, 0.0)]
|
|
658
|
+
|
|
659
|
+
def damage(self) -> np.ndarray:
|
|
660
|
+
"""The damage of the points of the interfaces (elements x points) at the end of
|
|
661
|
+
the last step."""
|
|
662
|
+
hist = self._state[..., 0]
|
|
663
|
+
out = hist.copy() # the bilinear law: its history is its damage
|
|
664
|
+
for law, par, where in self._groups:
|
|
665
|
+
mine = slice(None) if where is None else where
|
|
666
|
+
if law.kind == CONTACT: # the lips of a crack: broken; bonded points: sound
|
|
667
|
+
out[mine] = hist[mine] >= 0.0
|
|
668
|
+
elif law.kind != BILINEAR:
|
|
669
|
+
out[mine] = 1.0 - np.exp(-hist[mine] * math.e * par[0] / par[1])
|
|
670
|
+
return out
|
|
671
|
+
|
|
672
|
+
def _settle(self, state) -> bool:
|
|
673
|
+
"""On a converged state: the state of the points of the interfaces is kept, and
|
|
674
|
+
the step recorded."""
|
|
675
|
+
self._state = self._trial
|
|
676
|
+
damage = self.damage()
|
|
677
|
+
weights = self.interfaces.weights
|
|
678
|
+
broken = float(self._areas @ ((damage >= BROKEN) @ weights))
|
|
679
|
+
mean = float(self._areas @ (damage @ weights)) / float(self._areas.sum())
|
|
680
|
+
opening = max(float(self._state[..., 4].max()), 0.0)
|
|
681
|
+
rubbed = float(self._areas @ (self._state[..., 3] @ weights))
|
|
682
|
+
self._history.append((broken, mean, opening, rubbed))
|
|
683
|
+
return False
|
|
684
|
+
|
|
685
|
+
def run(self, path, **options):
|
|
686
|
+
"""The response to a loading path (:meth:`~morphogen.homogenization.nonlinear.
|
|
687
|
+
NonlinearFEProblem.run`) from sound interfaces, with the records of the
|
|
688
|
+
interfaces in its ``series`` (see the class)."""
|
|
689
|
+
self._begin()
|
|
690
|
+
try:
|
|
691
|
+
result = super().run(path, **options)
|
|
692
|
+
except RuntimeError as exc:
|
|
693
|
+
if self.viscosity > 0 or all(law.kind == CONTACT for law in self.laws.values()):
|
|
694
|
+
raise
|
|
695
|
+
raise RuntimeError(
|
|
696
|
+
f"{exc}; interfaces that break at once have no equilibrium under prescribed "
|
|
697
|
+
"strains (a snap-back): give the cell a viscosity, the time of the "
|
|
698
|
+
"regularization of their damage"
|
|
699
|
+
) from exc
|
|
700
|
+
history = np.array(self._history[: len(result.times)])
|
|
701
|
+
result.series.update({name: history[:, j] for j, name in enumerate(SERIES)})
|
|
702
|
+
return result
|
|
703
|
+
|
|
704
|
+
def _fields(self, sigma, grads, state, u) -> dict:
|
|
705
|
+
"""With the damage and the opening of the interfaces as fields of the elements
|
|
706
|
+
that they part (the largest of the means of the interface elements on the faces
|
|
707
|
+
of each element)."""
|
|
708
|
+
out = super()._fields(sigma, grads, state, u)
|
|
709
|
+
weights = self.interfaces.weights
|
|
710
|
+
damage = self.damage() @ weights
|
|
711
|
+
opening = np.maximum(self._state[..., 4], 0.0) @ weights
|
|
712
|
+
for name, values in (("interface_damage", damage), ("interface_opening", opening)):
|
|
713
|
+
field = np.zeros(self.mesh.n_elements)
|
|
714
|
+
for side in range(2):
|
|
715
|
+
np.maximum.at(field, self._owners[:, side], values)
|
|
716
|
+
out[name] = field
|
|
717
|
+
return out
|
|
718
|
+
|
|
719
|
+
def interface_points(self) -> dict:
|
|
720
|
+
"""The integration points of the interfaces at the end of the last path (rows:
|
|
721
|
+
elements x points): their ``position`` (reference), ``damage``, normal
|
|
722
|
+
``opening`` (negative: lips pressed on each other), frictional ``slip`` (two
|
|
723
|
+
components in the frame of each point), energy ``dissipated`` by friction per
|
|
724
|
+
unit area and ``weight`` (reference area)."""
|
|
725
|
+
weights = self.interfaces.weights
|
|
726
|
+
return {
|
|
727
|
+
"position": _point_positions(self.mesh.nodes, self.interfaces.minus).reshape(-1, 3),
|
|
728
|
+
"damage": self.damage().ravel(),
|
|
729
|
+
"opening": self._state[..., 4].ravel(),
|
|
730
|
+
"slip": self._state[..., 1:3].reshape(-1, 2),
|
|
731
|
+
"dissipated": self._state[..., 3].ravel(),
|
|
732
|
+
"weight": (self._areas[:, None] * weights[None, :]).ravel(),
|
|
733
|
+
}
|