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,613 @@
|
|
|
1
|
+
"""Finite strains: the behaviours of the points and the total Lagrangian finite elements.
|
|
2
|
+
|
|
3
|
+
The displacement gradient ``H = F - I`` of the reference configuration (the mesh) is the
|
|
4
|
+
measure of strain; the first Piola-Kirchhoff stress ``P`` (force per unit reference area)
|
|
5
|
+
its conjugate, and ``A = dP/dF`` the tangent. Tensors of 9 components are stored row by
|
|
6
|
+
row (``iJ -> 3 i + J``).
|
|
7
|
+
|
|
8
|
+
* Elastic, von Mises and porous points work in the space of the logarithmic strain
|
|
9
|
+
(Miehe, Apel & Lambrecht 2002): ``eps = 1/2 ln C`` (``C = F^T F``) replaces the small strain
|
|
10
|
+
in the behaviour of :mod:`morphogen.homogenization.behaviours`, whose stress ``T`` is
|
|
11
|
+
conjugate to it; ``S = T : 2 d eps/dC`` and ``P = F S``. Elasticity is then Hencky's
|
|
12
|
+
(the quadratic energy of the logarithmic strain), the plastic flow additive in ``eps``
|
|
13
|
+
and isochoric, and the formulation reduces to the small strain one for small strains.
|
|
14
|
+
The derivatives of the logarithm of ``C`` are those of a function of a symmetric
|
|
15
|
+
tensor, ``(Df(C)[H])_ab = f[c_a, c_b] H_ab`` in the eigenbasis of ``C`` and likewise
|
|
16
|
+
for the second derivative with the second divided differences (Daleckii-Krein), exact
|
|
17
|
+
for equal eigenvalues.
|
|
18
|
+
* Crystal plasticity is multiplicative, ``F = F_e F_p``
|
|
19
|
+
(:func:`morphogen.homogenization.crystal.cp_finite`).
|
|
20
|
+
|
|
21
|
+
The finite element equations are those of the small strains with ``P`` and ``A``: the
|
|
22
|
+
nodal forces ``int P . grad N dV_0``, the stiffness ``int grad N . A . grad N dV_0``. The
|
|
23
|
+
macroscopic gradient is upper triangular (``H_21 = H_31 = H_32 = 0``): every gradient is
|
|
24
|
+
one of them up to a rotation (its QR decomposition), which the behaviours ignore. Its six
|
|
25
|
+
components ``H_11, H_22, H_33, H_23, H_13, H_12`` are the macroscopic degrees of freedom,
|
|
26
|
+
in the Voigt order of the small strains (the shears ``H_ij``, ``i < j``, are simple
|
|
27
|
+
shears, the engineering shears of small strains), conjugate to the same components of
|
|
28
|
+
the mean of ``P`` (nominal stresses: forces per unit reference area). Free components
|
|
29
|
+
(zero stress) leave the faces of the box free of tractions but the reactions ``P_21,
|
|
30
|
+
P_31, P_32``, which keep the material lines along the first axis along it and the
|
|
31
|
+
planes normal to the third axis normal to it: a tension along an axis is then a uniaxial
|
|
32
|
+
Cauchy stress, whatever the anisotropy of the volume element.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
import math
|
|
38
|
+
|
|
39
|
+
import numpy as np
|
|
40
|
+
from numba import njit, prange
|
|
41
|
+
|
|
42
|
+
from morphogen.homogenization.behaviours import (
|
|
43
|
+
CRYSTAL,
|
|
44
|
+
HILL,
|
|
45
|
+
MFRONT,
|
|
46
|
+
PLASTIC,
|
|
47
|
+
POROUS,
|
|
48
|
+
_hill_set,
|
|
49
|
+
_hill_update,
|
|
50
|
+
_hill_works,
|
|
51
|
+
_j2_update,
|
|
52
|
+
point_chunks,
|
|
53
|
+
)
|
|
54
|
+
from morphogen.homogenization.crystal import cp_finite, work_block, work_blocks
|
|
55
|
+
from morphogen.homogenization.fe import CHUNKS, _geometry, _point_gradients, chunk_slots
|
|
56
|
+
from morphogen.homogenization.porous import _porous_set, _porous_update, _porous_works
|
|
57
|
+
from morphogen.homogenization.tensors import (
|
|
58
|
+
eigh3,
|
|
59
|
+
half_log,
|
|
60
|
+
log_divided,
|
|
61
|
+
log_divided2,
|
|
62
|
+
matmul3,
|
|
63
|
+
matmult3,
|
|
64
|
+
strain_voigt,
|
|
65
|
+
stress_tensor,
|
|
66
|
+
symmetrize,
|
|
67
|
+
tmatmul3,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
#: Revision of the kernels of the other modules compiled into
|
|
71
|
+
#: :func:`update_points_finite` (crystal, behaviours, porous): as
|
|
72
|
+
#: ``morphogen.homogenization.behaviours._KERNELS``, a change of those kernels comes
|
|
73
|
+
#: with a change of this number, which makes the caches of Numba of the earlier
|
|
74
|
+
#: versions stale (2: twins and cleavage planes among the systems of the crystals).
|
|
75
|
+
_KERNELS = 22
|
|
76
|
+
|
|
77
|
+
#: The six symmetric directions of dC in the tangent of the logarithmic points
|
|
78
|
+
_PAIRS = ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1))
|
|
79
|
+
#: Components (11, 22, 33, 23, 13, 12) of a tensor of 9 components of the macroscopic
|
|
80
|
+
#: strains and stresses: the upper triangle
|
|
81
|
+
MACRO = (0, 4, 8, 5, 2, 1)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# -- behaviours of the points ----------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@njit(cache=True)
|
|
88
|
+
def _log_point(kind, dm, par, nk, hg, eth, dt, old, new, pk1, tan, buf, lw, v6, tan6, f2,
|
|
89
|
+
hw, pw, sym=True): # fmt: skip
|
|
90
|
+
"""Elastic, von Mises, Hill or porous point (``kind``) in the space of the logarithmic
|
|
91
|
+
strain: displacement gradient ``hg``, thermal strain ``eth`` (tensor components,
|
|
92
|
+
logarithmic), work arrays ``hw`` of Hill's points and ``pw`` of the porous ones. Fills
|
|
93
|
+
the first Piola-Kirchhoff stress and the tangent ``dP/dF`` (of the tangent of the
|
|
94
|
+
logarithmic strain symmetrized with ``sym``); returns 1 on failure."""
|
|
95
|
+
f = lw[0]
|
|
96
|
+
e2 = lw[1]
|
|
97
|
+
q = lw[2]
|
|
98
|
+
tq = lw[3]
|
|
99
|
+
s = lw[4]
|
|
100
|
+
t1 = lw[5]
|
|
101
|
+
t2 = lw[6]
|
|
102
|
+
dcq = lw[7]
|
|
103
|
+
dtq = lw[8]
|
|
104
|
+
f1 = lw[9]
|
|
105
|
+
mu = v6[0]
|
|
106
|
+
eps6 = v6[1]
|
|
107
|
+
sig6 = v6[2]
|
|
108
|
+
d6 = v6[3]
|
|
109
|
+
ds6 = v6[4]
|
|
110
|
+
for i in range(3):
|
|
111
|
+
for j in range(3):
|
|
112
|
+
f[i, j] = (1.0 if i == j else 0.0) + hg[3 * i + j]
|
|
113
|
+
# C - I = H + H^T + H^T H, without cancellation for small strains
|
|
114
|
+
for i in range(3):
|
|
115
|
+
for j in range(3):
|
|
116
|
+
acc = hg[3 * i + j] + hg[3 * j + i]
|
|
117
|
+
for k in range(3):
|
|
118
|
+
acc += hg[3 * k + i] * hg[3 * k + j]
|
|
119
|
+
e2[i, j] = acc
|
|
120
|
+
for i in range(3):
|
|
121
|
+
for j in range(3):
|
|
122
|
+
t1[i, j] = e2[i, j]
|
|
123
|
+
eigh3(t1, mu, q)
|
|
124
|
+
for a in range(3):
|
|
125
|
+
if not (mu[a] > -1.0 and math.isfinite(mu[a])):
|
|
126
|
+
return 1
|
|
127
|
+
for i in range(3):
|
|
128
|
+
for j in range(3):
|
|
129
|
+
acc = 0.0
|
|
130
|
+
for a in range(3):
|
|
131
|
+
acc += q[i, a] * q[j, a] * half_log(mu[a])
|
|
132
|
+
t1[i, j] = acc
|
|
133
|
+
strain_voigt(t1, eps6)
|
|
134
|
+
if kind == PLASTIC:
|
|
135
|
+
if _j2_update(par, nk, eps6, eth, dt, old, new, sig6, tan6, buf, sym) != 0:
|
|
136
|
+
return 1
|
|
137
|
+
elif kind == HILL:
|
|
138
|
+
if _hill_update(par, nk, eps6, eth, dt, old, new, sig6, tan6, hw, sym) != 0:
|
|
139
|
+
return 1
|
|
140
|
+
elif kind == POROUS:
|
|
141
|
+
if _porous_update(par, eps6, eth, dt, old, new, sig6, tan6, pw, sym) != 0:
|
|
142
|
+
return 1
|
|
143
|
+
else:
|
|
144
|
+
for r in range(6):
|
|
145
|
+
d6[r] = eps6[r] - eth[r] * (1.0 if r < 3 else 2.0)
|
|
146
|
+
for r in range(6):
|
|
147
|
+
acc = 0.0
|
|
148
|
+
for c in range(6):
|
|
149
|
+
acc += dm[r, c] * d6[c]
|
|
150
|
+
tan6[r, c] = dm[r, c]
|
|
151
|
+
sig6[r] = acc
|
|
152
|
+
stress_tensor(sig6, t1)
|
|
153
|
+
tmatmul3(q, t1, t2)
|
|
154
|
+
matmul3(t2, q, tq)
|
|
155
|
+
# the divided differences are symmetric in their arguments: their 6 and 10 values
|
|
156
|
+
for a in range(3):
|
|
157
|
+
for b in range(a, 3):
|
|
158
|
+
v = log_divided(mu[a], mu[b])
|
|
159
|
+
f1[a, b] = v
|
|
160
|
+
f1[b, a] = v
|
|
161
|
+
for c in range(b, 3):
|
|
162
|
+
v = log_divided2(mu[a], mu[b], mu[c])
|
|
163
|
+
f2[a, b, c] = v
|
|
164
|
+
f2[a, c, b] = v
|
|
165
|
+
f2[b, a, c] = v
|
|
166
|
+
f2[b, c, a] = v
|
|
167
|
+
f2[c, a, b] = v
|
|
168
|
+
f2[c, b, a] = v
|
|
169
|
+
for a in range(3):
|
|
170
|
+
for b in range(3):
|
|
171
|
+
t1[a, b] = 2.0 * f1[a, b] * tq[a, b]
|
|
172
|
+
matmul3(q, t1, t2)
|
|
173
|
+
matmult3(t2, q, s)
|
|
174
|
+
matmul3(f, s, t1)
|
|
175
|
+
for i in range(3):
|
|
176
|
+
for j in range(3):
|
|
177
|
+
pk1[3 * i + j] = t1[i, j]
|
|
178
|
+
# dS is linear in dC: F dS for the six directions of dC, B = e_m (x) e_n + e_n (x) e_m
|
|
179
|
+
# (e_m (x) e_m when m = n), then for each dF = e_k (x) e_l the sum of the dC_mn F dS(B)
|
|
180
|
+
for bb in range(6):
|
|
181
|
+
m, n = _PAIRS[bb]
|
|
182
|
+
for a in range(3): # Q^T B Q
|
|
183
|
+
for b in range(3):
|
|
184
|
+
v = q[m, a] * q[n, b]
|
|
185
|
+
if m != n:
|
|
186
|
+
v += q[n, a] * q[m, b]
|
|
187
|
+
dcq[a, b] = v
|
|
188
|
+
for a in range(3):
|
|
189
|
+
for b in range(3):
|
|
190
|
+
t1[a, b] = f1[a, b] * dcq[a, b]
|
|
191
|
+
matmul3(q, t1, t2)
|
|
192
|
+
matmult3(t2, q, t1)
|
|
193
|
+
strain_voigt(t1, d6)
|
|
194
|
+
for r in range(6):
|
|
195
|
+
acc = 0.0
|
|
196
|
+
for c in range(6):
|
|
197
|
+
acc += tan6[r, c] * d6[c]
|
|
198
|
+
ds6[r] = acc
|
|
199
|
+
stress_tensor(ds6, t1)
|
|
200
|
+
tmatmul3(q, t1, t2)
|
|
201
|
+
matmul3(t2, q, dtq)
|
|
202
|
+
for a in range(3):
|
|
203
|
+
for b in range(3):
|
|
204
|
+
acc = 2.0 * f1[a, b] * dtq[a, b]
|
|
205
|
+
for c in range(3):
|
|
206
|
+
acc += 2.0 * f2[a, b, c] * (dcq[a, c] * tq[c, b] + tq[a, c] * dcq[c, b])
|
|
207
|
+
t1[a, b] = acc
|
|
208
|
+
matmul3(q, t1, t2)
|
|
209
|
+
matmult3(t2, q, t1)
|
|
210
|
+
matmul3(f, t1, lw[10 + bb])
|
|
211
|
+
for kl in range(9):
|
|
212
|
+
k = kl // 3
|
|
213
|
+
ll = kl % 3
|
|
214
|
+
# dC = dF^T F + F^T dF for dF = e_k (x) e_l: dC_mn = d_ml F_kn + d_nl F_km
|
|
215
|
+
for i in range(3):
|
|
216
|
+
for j in range(3):
|
|
217
|
+
t2[i, j] = 0.0
|
|
218
|
+
for bb in range(6):
|
|
219
|
+
m, n = _PAIRS[bb]
|
|
220
|
+
c = (f[k, n] if m == ll else 0.0) + (f[k, m] if n == ll else 0.0)
|
|
221
|
+
if c != 0.0:
|
|
222
|
+
g = lw[10 + bb]
|
|
223
|
+
for i in range(3):
|
|
224
|
+
for j in range(3):
|
|
225
|
+
t2[i, j] += c * g[i, j]
|
|
226
|
+
for i in range(3):
|
|
227
|
+
for j in range(3):
|
|
228
|
+
v = t2[i, j]
|
|
229
|
+
if i == k:
|
|
230
|
+
v += s[ll, j]
|
|
231
|
+
tan[3 * i + j, kl] = v
|
|
232
|
+
return 0
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@njit(parallel=True, cache=True)
|
|
236
|
+
def update_points_finite(kind, mat, pmat, data, hg, dtemp, dt, old, new, pk1, tangent, guess,
|
|
237
|
+
ratio, symmetric=True): # fmt: skip
|
|
238
|
+
"""First Piola-Kirchhoff stress, internal variables and tangent ``dP/dF`` (symmetrized
|
|
239
|
+
with ``symmetric``) of every integration point for the displacement gradients ``hg`` at
|
|
240
|
+
the end of a step: the finite strain counterpart of :func:`morphogen.homogenization.
|
|
241
|
+
behaviours.update_points` (same arguments). Returns the number of points whose
|
|
242
|
+
integration failed."""
|
|
243
|
+
matrices, eigen, params, nk, systems, cp_par, cp_h, cp_n = data
|
|
244
|
+
n = hg.shape[0]
|
|
245
|
+
n_chunks = point_chunks(n)
|
|
246
|
+
failed = np.zeros(n_chunks, dtype=np.int64)
|
|
247
|
+
# the work arrays of the laws, a set per chunk of points: allocated before the
|
|
248
|
+
# parallel loop, which holds them as plain memory (crystal.work_block)
|
|
249
|
+
blocks = work_blocks(n_chunks, cp_par.shape[1])
|
|
250
|
+
bufs = np.empty((n_chunks, 7, 6))
|
|
251
|
+
vectors = np.empty((n_chunks, 6))
|
|
252
|
+
lws = np.zeros((n_chunks, 16, 3, 3))
|
|
253
|
+
v6s = np.zeros((n_chunks, 5, 6))
|
|
254
|
+
tan6s = np.zeros((n_chunks, 6, 6))
|
|
255
|
+
f2s = np.zeros((n_chunks, 3, 3, 3))
|
|
256
|
+
hws = _hill_works(n_chunks)
|
|
257
|
+
pws = _porous_works(n_chunks)
|
|
258
|
+
for ch in prange(n_chunks):
|
|
259
|
+
buf = bufs[ch]
|
|
260
|
+
eth = vectors[ch]
|
|
261
|
+
lw = lws[ch]
|
|
262
|
+
v6 = v6s[ch]
|
|
263
|
+
tan6 = tan6s[ch]
|
|
264
|
+
f2 = f2s[ch]
|
|
265
|
+
work = work_block(blocks, ch)
|
|
266
|
+
hw = _hill_set(hws, ch)
|
|
267
|
+
pw = _porous_set(pws, ch)
|
|
268
|
+
for i in range(ch * n // n_chunks, (ch + 1) * n // n_chunks):
|
|
269
|
+
m = mat[i]
|
|
270
|
+
k = kind[i]
|
|
271
|
+
if k == MFRONT:
|
|
272
|
+
continue
|
|
273
|
+
for r in range(6):
|
|
274
|
+
eth[r] = dtemp * eigen[m, r] * (1.0 if r < 3 else 0.5)
|
|
275
|
+
if k == CRYSTAL:
|
|
276
|
+
c = pmat[i]
|
|
277
|
+
fail = cp_finite(systems[m], cp_par[c], cp_h[c], cp_n[c], matrices[m], hg[i],
|
|
278
|
+
eth, dt, old[i], new[i], pk1[i], tangent[i], guess, ratio,
|
|
279
|
+
work) # fmt: skip
|
|
280
|
+
else:
|
|
281
|
+
fail = _log_point(k, matrices[m], params[max(pmat[i], 0)], nk, hg[i], eth, dt,
|
|
282
|
+
old[i], new[i], pk1[i], tangent[i], buf, lw, v6, tan6,
|
|
283
|
+
f2, hw, pw, symmetric) # fmt: skip
|
|
284
|
+
if fail == 0 and symmetric:
|
|
285
|
+
symmetrize(tangent[i])
|
|
286
|
+
failed[ch] += fail
|
|
287
|
+
return int(failed.sum())
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
# -- finite elements -------------------------------------------------------------------------
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
@njit(parallel=True, cache=True)
|
|
294
|
+
def point_gradients(nodes, elements, order, u, gp, gw, hg, wts):
|
|
295
|
+
"""Displacement gradients (9 components) and weights of the integration points."""
|
|
296
|
+
n_el, nn = elements.shape
|
|
297
|
+
ng = gp.shape[0]
|
|
298
|
+
for e in prange(n_el):
|
|
299
|
+
x = np.empty((4, 3))
|
|
300
|
+
gl = np.empty((4, 3))
|
|
301
|
+
dev = np.empty((6, 3))
|
|
302
|
+
grad = np.empty((nn, 3))
|
|
303
|
+
vol, curved = _geometry(nodes, elements, e, x, gl, dev)
|
|
304
|
+
for g in range(ng):
|
|
305
|
+
ratio = _point_gradients(order, curved, gl, dev, gp[g], grad)
|
|
306
|
+
p = e * ng + g
|
|
307
|
+
for c in range(9):
|
|
308
|
+
hg[p, c] = 0.0
|
|
309
|
+
for a in range(nn):
|
|
310
|
+
k = elements[e, a]
|
|
311
|
+
for i in range(3):
|
|
312
|
+
ui = u[3 * k + i]
|
|
313
|
+
for j in range(3):
|
|
314
|
+
hg[p, 3 * i + j] += ui * grad[a, j]
|
|
315
|
+
wts[p] = gw[g] * vol * ratio
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
@njit(parallel=True, cache=True)
|
|
319
|
+
def internal_forces(nodes, elements, order, gp, pk1, wts, by_colour, colours, forces):
|
|
320
|
+
"""Nodal forces ``int P . grad N`` (into ``forces``), the integral of ``P`` (9) and the
|
|
321
|
+
norm of the contributions of the integration points; the elements of a colour in
|
|
322
|
+
parallel (``by_colour``, ``colours``:
|
|
323
|
+
:func:`~morphogen.homogenization.fe.element_colours`), the sums over all the elements
|
|
324
|
+
chunk by chunk, in the same order for any number of threads."""
|
|
325
|
+
nn = elements.shape[1]
|
|
326
|
+
ng = gp.shape[0]
|
|
327
|
+
for j in prange(forces.size):
|
|
328
|
+
forces[j] = 0.0
|
|
329
|
+
n_colours = colours.size - 1
|
|
330
|
+
# the sums of each chunk (rows wide enough for two chunks not to share a cache line)
|
|
331
|
+
slots = chunk_slots(colours)
|
|
332
|
+
sums = np.zeros((slots[n_colours], 24))
|
|
333
|
+
xs = np.empty((CHUNKS, 4, 3))
|
|
334
|
+
gls = np.empty((CHUNKS, 4, 3))
|
|
335
|
+
devs = np.empty((CHUNKS, 6, 3))
|
|
336
|
+
grads = np.empty((CHUNKS, nn, 3))
|
|
337
|
+
for colour in range(n_colours):
|
|
338
|
+
first = colours[colour]
|
|
339
|
+
count = colours[colour + 1] - first
|
|
340
|
+
chunks = min(count, CHUNKS)
|
|
341
|
+
for chunk in prange(chunks):
|
|
342
|
+
x = xs[chunk]
|
|
343
|
+
gl = gls[chunk]
|
|
344
|
+
dev = devs[chunk]
|
|
345
|
+
grad = grads[chunk]
|
|
346
|
+
part = sums[slots[colour] + chunk]
|
|
347
|
+
for q in range(first + chunk * count // chunks, first + (chunk + 1) * count // chunks):
|
|
348
|
+
e = by_colour[q]
|
|
349
|
+
_, curved = _geometry(nodes, elements, e, x, gl, dev)
|
|
350
|
+
for g in range(ng):
|
|
351
|
+
_point_gradients(order, curved, gl, dev, gp[g], grad)
|
|
352
|
+
p = e * ng + g
|
|
353
|
+
w = wts[p]
|
|
354
|
+
s = pk1[p]
|
|
355
|
+
for r in range(9):
|
|
356
|
+
part[r] += w * s[r]
|
|
357
|
+
for b in range(nn):
|
|
358
|
+
k = elements[e, b]
|
|
359
|
+
gx, gy, gz = grad[b, 0], grad[b, 1], grad[b, 2]
|
|
360
|
+
for i in range(3):
|
|
361
|
+
fi = w * (s[3 * i] * gx + s[3 * i + 1] * gy + s[3 * i + 2] * gz)
|
|
362
|
+
forces[3 * k + i] += fi
|
|
363
|
+
part[9] += fi * fi
|
|
364
|
+
total = np.zeros(9)
|
|
365
|
+
norm2 = 0.0
|
|
366
|
+
for k in range(sums.shape[0]):
|
|
367
|
+
for r in range(9):
|
|
368
|
+
total[r] += sums[k, r]
|
|
369
|
+
norm2 += sums[k, 9]
|
|
370
|
+
return total, math.sqrt(norm2)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
@njit(parallel=True, cache=True)
|
|
374
|
+
def fill_tangent(nodes, elements, order, gp, tangent, wts, indptr_n, indices_n, by_colour,
|
|
375
|
+
colours, data): # fmt: skip
|
|
376
|
+
"""CSR values of ``sum_e int grad N . A . grad N`` (node-level pattern), the elements
|
|
377
|
+
of a colour in parallel (``by_colour``, ``colours``:
|
|
378
|
+
:func:`~morphogen.homogenization.fe.element_colours`)."""
|
|
379
|
+
nn = elements.shape[1]
|
|
380
|
+
ng = gp.shape[0]
|
|
381
|
+
for i in prange(data.size):
|
|
382
|
+
data[i] = 0.0
|
|
383
|
+
xs = np.empty((CHUNKS, 4, 3))
|
|
384
|
+
gls = np.empty((CHUNKS, 4, 3))
|
|
385
|
+
devs = np.empty((CHUNKS, 6, 3))
|
|
386
|
+
grads = np.empty((CHUNKS, nn, 3))
|
|
387
|
+
dbs = np.empty((CHUNKS, nn, 9, 3))
|
|
388
|
+
kes = np.empty((CHUNKS, nn * 3, nn * 3))
|
|
389
|
+
places = np.empty((CHUNKS, nn, nn), dtype=np.int64)
|
|
390
|
+
for colour in range(colours.size - 1):
|
|
391
|
+
first = colours[colour]
|
|
392
|
+
count = colours[colour + 1] - first
|
|
393
|
+
chunks = min(count, CHUNKS)
|
|
394
|
+
for chunk in prange(chunks):
|
|
395
|
+
x = xs[chunk]
|
|
396
|
+
gl = gls[chunk]
|
|
397
|
+
dev = devs[chunk]
|
|
398
|
+
grad = grads[chunk]
|
|
399
|
+
db = dbs[chunk]
|
|
400
|
+
ke = kes[chunk]
|
|
401
|
+
pos = places[chunk]
|
|
402
|
+
for m in range(first + chunk * count // chunks, first + (chunk + 1) * count // chunks):
|
|
403
|
+
e = by_colour[m]
|
|
404
|
+
_, curved = _geometry(nodes, elements, e, x, gl, dev)
|
|
405
|
+
ke[:, :] = 0.0
|
|
406
|
+
for g in range(ng):
|
|
407
|
+
_point_gradients(order, curved, gl, dev, gp[g], grad)
|
|
408
|
+
p = e * ng + g
|
|
409
|
+
w = wts[p]
|
|
410
|
+
a9 = tangent[p]
|
|
411
|
+
for b in range(nn):
|
|
412
|
+
gx, gy, gz = grad[b, 0], grad[b, 1], grad[b, 2]
|
|
413
|
+
for r in range(9):
|
|
414
|
+
for k in range(3):
|
|
415
|
+
db[b, r, k] = (
|
|
416
|
+
a9[r, 3 * k] * gx
|
|
417
|
+
+ a9[r, 3 * k + 1] * gy
|
|
418
|
+
+ a9[r, 3 * k + 2] * gz
|
|
419
|
+
)
|
|
420
|
+
for a in range(nn):
|
|
421
|
+
gx, gy, gz = grad[a, 0], grad[a, 1], grad[a, 2]
|
|
422
|
+
for b in range(nn):
|
|
423
|
+
for i in range(3):
|
|
424
|
+
for k in range(3):
|
|
425
|
+
ke[3 * a + i, 3 * b + k] += w * (
|
|
426
|
+
gx * db[b, 3 * i, k]
|
|
427
|
+
+ gy * db[b, 3 * i + 1, k]
|
|
428
|
+
+ gz * db[b, 3 * i + 2, k]
|
|
429
|
+
)
|
|
430
|
+
for a in range(nn):
|
|
431
|
+
na = elements[e, a]
|
|
432
|
+
lo = indptr_n[na]
|
|
433
|
+
hi = indptr_n[na + 1]
|
|
434
|
+
for b in range(nn):
|
|
435
|
+
nb = elements[e, b]
|
|
436
|
+
left, right = lo, hi
|
|
437
|
+
while left < right:
|
|
438
|
+
mid = (left + right) // 2
|
|
439
|
+
if indices_n[mid] < nb:
|
|
440
|
+
left = mid + 1
|
|
441
|
+
else:
|
|
442
|
+
right = mid
|
|
443
|
+
pos[a, b] = left - lo
|
|
444
|
+
for a in range(nn):
|
|
445
|
+
na = elements[e, a]
|
|
446
|
+
length = indptr_n[na + 1] - indptr_n[na]
|
|
447
|
+
for c in range(3):
|
|
448
|
+
start = 9 * indptr_n[na] + c * 3 * length
|
|
449
|
+
for b in range(nn):
|
|
450
|
+
q = pos[a, b]
|
|
451
|
+
for c2 in range(3):
|
|
452
|
+
data[start + q * 3 + c2] += ke[3 * a + c, 3 * b + c2]
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
@njit(cache=True, inline="always")
|
|
456
|
+
def _macro_columns(a9, am):
|
|
457
|
+
"""``A M``: the columns of ``A`` of the six macroscopic components."""
|
|
458
|
+
for r in range(9):
|
|
459
|
+
for c in range(6):
|
|
460
|
+
am[r, c] = a9[r, MACRO[c]]
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
@njit(parallel=True, cache=True)
|
|
464
|
+
def coupling(nodes, elements, order, gp, tangent, wts, by_colour, colours, out, kee):
|
|
465
|
+
"""``int grad N . A M`` (nodal forces of the six unit macroscopic strains, into
|
|
466
|
+
``out``, n_dofs x 6) and ``M^T (int A) M`` (into ``kee``); the elements of a colour in
|
|
467
|
+
parallel, as :func:`internal_forces`."""
|
|
468
|
+
nn = elements.shape[1]
|
|
469
|
+
ng = gp.shape[0]
|
|
470
|
+
for j in prange(out.shape[0]):
|
|
471
|
+
for c in range(6):
|
|
472
|
+
out[j, c] = 0.0
|
|
473
|
+
n_colours = colours.size - 1
|
|
474
|
+
slots = chunk_slots(colours)
|
|
475
|
+
sums = np.zeros((slots[n_colours], 64)) # (54 values: the rows of two chunks apart)
|
|
476
|
+
ams = np.empty((CHUNKS, 9, 6))
|
|
477
|
+
xs = np.empty((CHUNKS, 4, 3))
|
|
478
|
+
gls = np.empty((CHUNKS, 4, 3))
|
|
479
|
+
devs = np.empty((CHUNKS, 6, 3))
|
|
480
|
+
grads = np.empty((CHUNKS, nn, 3))
|
|
481
|
+
for colour in range(n_colours):
|
|
482
|
+
first = colours[colour]
|
|
483
|
+
count = colours[colour + 1] - first
|
|
484
|
+
chunks = min(count, CHUNKS)
|
|
485
|
+
for chunk in prange(chunks):
|
|
486
|
+
am = ams[chunk]
|
|
487
|
+
x = xs[chunk]
|
|
488
|
+
gl = gls[chunk]
|
|
489
|
+
dev = devs[chunk]
|
|
490
|
+
grad = grads[chunk]
|
|
491
|
+
part = sums[slots[colour] + chunk]
|
|
492
|
+
for q in range(first + chunk * count // chunks, first + (chunk + 1) * count // chunks):
|
|
493
|
+
e = by_colour[q]
|
|
494
|
+
_, curved = _geometry(nodes, elements, e, x, gl, dev)
|
|
495
|
+
for g in range(ng):
|
|
496
|
+
_point_gradients(order, curved, gl, dev, gp[g], grad)
|
|
497
|
+
p = e * ng + g
|
|
498
|
+
w = wts[p]
|
|
499
|
+
_macro_columns(tangent[p], am)
|
|
500
|
+
for r in range(9):
|
|
501
|
+
for c in range(6):
|
|
502
|
+
part[6 * r + c] += w * am[r, c]
|
|
503
|
+
for b in range(nn):
|
|
504
|
+
k = elements[e, b]
|
|
505
|
+
gx, gy, gz = grad[b, 0], grad[b, 1], grad[b, 2]
|
|
506
|
+
for i in range(3):
|
|
507
|
+
for c in range(6):
|
|
508
|
+
out[3 * k + i, c] += w * (
|
|
509
|
+
gx * am[3 * i, c]
|
|
510
|
+
+ gy * am[3 * i + 1, c]
|
|
511
|
+
+ gz * am[3 * i + 2, c]
|
|
512
|
+
)
|
|
513
|
+
total = np.zeros((9, 6))
|
|
514
|
+
for k in range(sums.shape[0]):
|
|
515
|
+
for r in range(9):
|
|
516
|
+
for c in range(6):
|
|
517
|
+
total[r, c] += sums[k, 6 * r + c]
|
|
518
|
+
for r in range(6):
|
|
519
|
+
for c in range(6):
|
|
520
|
+
kee[r, c] = total[MACRO[r], c]
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
@njit(parallel=True, cache=True)
|
|
524
|
+
def group_sums(group, n_groups, wts, pk1, hg, p):
|
|
525
|
+
"""Integrals over each group of the macroscopic components of ``P`` (6) and of the
|
|
526
|
+
displacement gradient (6), of the cumulated plastic strain ``p``, the reference volume,
|
|
527
|
+
the Kirchhoff stress ``P F^T`` (6) and the volume change ``det F``."""
|
|
528
|
+
n = wts.shape[0]
|
|
529
|
+
n_chunks = min(max(n, 1), 256)
|
|
530
|
+
partial = np.zeros((n_chunks, n_groups, 21))
|
|
531
|
+
for ch in prange(n_chunks):
|
|
532
|
+
f = np.empty((3, 3))
|
|
533
|
+
for i in range(ch * n // n_chunks, (ch + 1) * n // n_chunks):
|
|
534
|
+
acc = partial[ch, group[i]]
|
|
535
|
+
w = wts[i]
|
|
536
|
+
s = pk1[i]
|
|
537
|
+
h = hg[i]
|
|
538
|
+
for r in range(6):
|
|
539
|
+
acc[r] += w * s[MACRO[r]]
|
|
540
|
+
acc[6 + r] += w * h[MACRO[r]]
|
|
541
|
+
acc[12] += w * p[i]
|
|
542
|
+
acc[13] += w
|
|
543
|
+
for a in range(3):
|
|
544
|
+
for b in range(3):
|
|
545
|
+
f[a, b] = (1.0 if a == b else 0.0) + h[3 * a + b]
|
|
546
|
+
for r in range(6):
|
|
547
|
+
a = (0, 1, 2, 1, 2, 0)[r]
|
|
548
|
+
b = (0, 1, 2, 2, 0, 1)[r]
|
|
549
|
+
acc[14 + r] += w * (
|
|
550
|
+
s[3 * a] * f[b, 0] + s[3 * a + 1] * f[b, 1] + s[3 * a + 2] * f[b, 2]
|
|
551
|
+
)
|
|
552
|
+
det = (
|
|
553
|
+
f[0, 0] * (f[1, 1] * f[2, 2] - f[1, 2] * f[2, 1])
|
|
554
|
+
- f[0, 1] * (f[1, 0] * f[2, 2] - f[1, 2] * f[2, 0])
|
|
555
|
+
+ f[0, 2] * (f[1, 0] * f[2, 1] - f[1, 1] * f[2, 0])
|
|
556
|
+
)
|
|
557
|
+
acc[20] += w * det
|
|
558
|
+
return partial.sum(axis=0)
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
# -- outputs -------------------------------------------------------------------------------
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def macro_part(t9) -> np.ndarray:
|
|
565
|
+
"""The macroscopic components (11, 22, 33, 23, 13, 12) of tensors of 9 components."""
|
|
566
|
+
return np.asarray(t9, dtype=float)[..., list(MACRO)]
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def gradient_of(e) -> np.ndarray:
|
|
570
|
+
"""Displacement gradient (9) of the macroscopic components ``e`` (..., 6): upper
|
|
571
|
+
triangular."""
|
|
572
|
+
e = np.asarray(e, dtype=float)
|
|
573
|
+
out = np.zeros((*e.shape[:-1], 9))
|
|
574
|
+
out[..., list(MACRO)] = e
|
|
575
|
+
return out
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
def _voigt(t) -> np.ndarray:
|
|
579
|
+
"""Voigt components (tensor shears) of symmetric 3 x 3 tensors (..., 3, 3)."""
|
|
580
|
+
return np.stack(
|
|
581
|
+
[t[..., 0, 0], t[..., 1, 1], t[..., 2, 2], t[..., 1, 2], t[..., 2, 0], t[..., 0, 1]],
|
|
582
|
+
axis=-1,
|
|
583
|
+
)
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
def cauchy(pk1, hg) -> np.ndarray:
|
|
587
|
+
"""Cauchy stress (Voigt) of first Piola-Kirchhoff stresses and displacement gradients
|
|
588
|
+
(..., 9): ``P F^T / det F``."""
|
|
589
|
+
p = np.asarray(pk1, dtype=float).reshape(*np.shape(pk1)[:-1], 3, 3)
|
|
590
|
+
f = np.eye(3) + np.asarray(hg, dtype=float).reshape(*np.shape(hg)[:-1], 3, 3)
|
|
591
|
+
tau = p @ np.swapaxes(f, -1, -2)
|
|
592
|
+
return _voigt(0.5 * (tau + np.swapaxes(tau, -1, -2))) / np.linalg.det(f)[..., None]
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
def log_strain(hg) -> np.ndarray:
|
|
596
|
+
"""Logarithmic (Hencky) strain ``1/2 ln(F^T F)`` (Voigt, engineering shears) of
|
|
597
|
+
displacement gradients (..., 9)."""
|
|
598
|
+
h = np.asarray(hg, dtype=float).reshape(*np.shape(hg)[:-1], 3, 3)
|
|
599
|
+
c_minus = h + np.swapaxes(h, -1, -2) + np.swapaxes(h, -1, -2) @ h
|
|
600
|
+
w, v = np.linalg.eigh(c_minus)
|
|
601
|
+
eps = (v * (0.5 * np.log1p(w))[..., None, :]) @ np.swapaxes(v, -1, -2)
|
|
602
|
+
out = _voigt(eps)
|
|
603
|
+
out[..., 3:] *= 2.0
|
|
604
|
+
return out
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def lattice_rotations(hg, fp_inv) -> np.ndarray:
|
|
608
|
+
"""Rotations ``R_e`` of the lattice (polar decomposition of ``F_e = F F_p^-1``) of
|
|
609
|
+
displacement gradients and ``F_p^-1`` (..., 9)."""
|
|
610
|
+
f = np.eye(3) + np.asarray(hg, dtype=float).reshape(*np.shape(hg)[:-1], 3, 3)
|
|
611
|
+
fe = f @ np.asarray(fp_inv, dtype=float).reshape(*np.shape(fp_inv)[:-1], 3, 3)
|
|
612
|
+
u, _, vt = np.linalg.svd(fe)
|
|
613
|
+
return u @ vt
|