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,1670 @@
|
|
|
1
|
+
"""Tensile tests of laser-architectured sheets: finite elements of a membrane in plane
|
|
2
|
+
stress, with large rotations and the flow law of each point.
|
|
3
|
+
|
|
4
|
+
The sheet is a membrane of quadrilaterals (bilinear, 2 x 2 Gauss points), each Gauss
|
|
5
|
+
point split into the layers of the treatment through the thickness, each layer in plane
|
|
6
|
+
stress with its own flow law (:mod:`morphogen.laser.materials`): a point treated on one
|
|
7
|
+
face only is a stack of layers of different hardness that stretch together (bending is
|
|
8
|
+
not modelled).
|
|
9
|
+
|
|
10
|
+
**Kinematics** (total Lagrangian displacements, corotational stresses). At each Gauss
|
|
11
|
+
point the increment ``ΔF = F F_n⁻¹`` of the in-plane deformation gradient splits into
|
|
12
|
+
its rotation and stretch, ``ΔF = ΔR ΔU`` (polar decomposition); the strain increment is
|
|
13
|
+
``ln ΔU``, the old Cauchy stress is updated in the frame of ``F_n`` then turned by
|
|
14
|
+
``ΔR`` (an incrementally objective scheme: exact for rigid rotations, the logarithmic
|
|
15
|
+
strains of proportional paths). The thickness strain of each layer comes from its plane
|
|
16
|
+
stress, ``h = h0 exp(Σ Δε33)``. The internal forces are ``∫ Bᵀ τ h0 dA0`` with the
|
|
17
|
+
Kirchhoff stress ``τ = J σ`` (``J = det F λ3``) and the spatial gradients of the shape
|
|
18
|
+
functions; the tangent, ``∫ (Bᵀ J C B + Gᵀ τ G) h0 dA0``, adds the geometric stiffness
|
|
19
|
+
of the stresses (the large rotations of the corrugated reinforcements that unbend).
|
|
20
|
+
|
|
21
|
+
**Plasticity** of each layer: von Mises, isotropic hardening ``σ_y(p)``; the radial
|
|
22
|
+
return of the trial stress in 3D with the thickness strain increment ``Δε33`` found by
|
|
23
|
+
Newton's method so that ``σ33 = 0``; the consistent tangent of the radial return (Simo &
|
|
24
|
+
Hughes 1998), condensed on the in-plane components,
|
|
25
|
+
``C_ps = C_ab − C_a3 C_3b / C_33``.
|
|
26
|
+
|
|
27
|
+
**Tensile test** (:func:`tensile_test`): the grips pull the ends of the specimen along x
|
|
28
|
+
(displacement control, lateral displacements of the gripped ends held, or free for a
|
|
29
|
+
strip with free ends); a virtual extensometer reads the elongation of the parallel part
|
|
30
|
+
(the mean axial displacement of two cross-sections). Results: the engineering curve, the
|
|
31
|
+
0.2 % proof stress, the tensile strength and the uniform elongation at the maximum force
|
|
32
|
+
(diffuse necking, Considère's criterion of the specimen), the energy absorbed up to it,
|
|
33
|
+
and the fields.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
from __future__ import annotations
|
|
37
|
+
|
|
38
|
+
import math
|
|
39
|
+
import time
|
|
40
|
+
from dataclasses import dataclass, field
|
|
41
|
+
|
|
42
|
+
import numpy as np
|
|
43
|
+
from numba import njit, prange
|
|
44
|
+
from scipy import sparse
|
|
45
|
+
from scipy.sparse import linalg as splinalg
|
|
46
|
+
|
|
47
|
+
from morphogen.laser.materials import LUDWIK_OFFSET
|
|
48
|
+
from morphogen.laser.specimen import QuadMesh, Specimen
|
|
49
|
+
|
|
50
|
+
# -- material point --------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@njit(cache=True)
|
|
54
|
+
def _flow(kind, s0, a, b, p, offset): # pragma: no cover - compiled
|
|
55
|
+
"""Flow stress and hardening modulus: 0 Ludwik, 1 Voce, 2 Swift (Hollomon from the
|
|
56
|
+
yield stress ``s0``: ``K (ε0 + p)^n``, ``ε0 = (s0/K)^(1/n)``)."""
|
|
57
|
+
if kind == 0:
|
|
58
|
+
q = p + offset
|
|
59
|
+
return s0 + a * (q**b - offset**b), b * a * q ** (b - 1.0)
|
|
60
|
+
if kind == 2:
|
|
61
|
+
q = (s0 / a) ** (1.0 / b) + p
|
|
62
|
+
return a * q**b, b * a * q ** (b - 1.0)
|
|
63
|
+
e = math.exp(-b * p)
|
|
64
|
+
return s0 + a * (1.0 - e), a * b * e
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@njit(cache=True)
|
|
68
|
+
def _flowm(law, p, offset): # pragma: no cover - compiled
|
|
69
|
+
"""The mixture ``(1 − w) σ_1(p) + w σ_2(p)`` of the two laws of a point
|
|
70
|
+
(``law``: kind, σ0, a, b of each, then w)."""
|
|
71
|
+
w = law[8]
|
|
72
|
+
s1, h1 = _flow(int(law[0]), law[1], law[2], law[3], p, offset)
|
|
73
|
+
if w == 0.0:
|
|
74
|
+
return s1, h1
|
|
75
|
+
s2, h2 = _flow(int(law[4]), law[5], law[6], law[7], p, offset)
|
|
76
|
+
return (1.0 - w) * s1 + w * s2, (1.0 - w) * h1 + w * h2
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@njit(cache=True)
|
|
80
|
+
def _return_3d(sig, de, p_old, law, G, K, offset, out, C): # pragma: no cover
|
|
81
|
+
"""Radial return of the trial stress ``sig + C_e de`` (Voigt 11, 22, 33, 23, 13,
|
|
82
|
+
12; engineering shears in ``de``); writes the stress in ``out`` and the consistent
|
|
83
|
+
tangent in ``C``; returns the plastic strain increment."""
|
|
84
|
+
lam = K - 2.0 * G / 3.0
|
|
85
|
+
tr = de[0] + de[1] + de[2]
|
|
86
|
+
for i in range(3):
|
|
87
|
+
out[i] = sig[i] + lam * tr + 2.0 * G * de[i]
|
|
88
|
+
for i in range(3, 6):
|
|
89
|
+
out[i] = sig[i] + G * de[i]
|
|
90
|
+
mean = (out[0] + out[1] + out[2]) / 3.0
|
|
91
|
+
s = np.empty(6)
|
|
92
|
+
for i in range(3):
|
|
93
|
+
s[i] = out[i] - mean
|
|
94
|
+
for i in range(3, 6):
|
|
95
|
+
s[i] = out[i]
|
|
96
|
+
norm = math.sqrt(s[0] ** 2 + s[1] ** 2 + s[2] ** 2 + 2.0 * (s[3] ** 2 + s[4] ** 2 + s[5] ** 2))
|
|
97
|
+
q = math.sqrt(1.5) * norm
|
|
98
|
+
sy, h = _flowm(law, p_old, offset)
|
|
99
|
+
for i in range(6):
|
|
100
|
+
for j in range(6):
|
|
101
|
+
C[i, j] = 0.0
|
|
102
|
+
for i in range(3):
|
|
103
|
+
for j in range(3):
|
|
104
|
+
C[i, j] = lam
|
|
105
|
+
C[i, i] = lam + 2.0 * G
|
|
106
|
+
for i in range(3, 6):
|
|
107
|
+
C[i, i] = G
|
|
108
|
+
if q - sy <= 1e-10 * max(sy, 1.0):
|
|
109
|
+
return 0.0
|
|
110
|
+
# Newton on the plastic strain increment, bracketed in [0, q / 3G]
|
|
111
|
+
lo, hi = 0.0, q / (3.0 * G)
|
|
112
|
+
dp = (q - sy) / (3.0 * G + h)
|
|
113
|
+
for _ in range(100):
|
|
114
|
+
if dp <= lo or dp >= hi:
|
|
115
|
+
dp = 0.5 * (lo + hi)
|
|
116
|
+
sy, h = _flowm(law, p_old + dp, offset)
|
|
117
|
+
g = q - 3.0 * G * dp - sy
|
|
118
|
+
if abs(g) <= 1e-12 * max(sy, 1.0):
|
|
119
|
+
break
|
|
120
|
+
if g > 0:
|
|
121
|
+
lo = dp
|
|
122
|
+
else:
|
|
123
|
+
hi = dp
|
|
124
|
+
dp = dp + g / (3.0 * G + h)
|
|
125
|
+
sy, h = _flowm(law, p_old + dp, offset)
|
|
126
|
+
ratio = 3.0 * G * dp / q
|
|
127
|
+
for i in range(6):
|
|
128
|
+
out[i] = (mean if i < 3 else 0.0) + (1.0 - ratio) * s[i]
|
|
129
|
+
theta = 1.0 - ratio
|
|
130
|
+
theta_bar = 1.0 / (1.0 + h / (3.0 * G)) - ratio
|
|
131
|
+
n = np.empty(6)
|
|
132
|
+
for i in range(6):
|
|
133
|
+
n[i] = s[i] / norm
|
|
134
|
+
for i in range(6):
|
|
135
|
+
for j in range(6):
|
|
136
|
+
C[i, j] = 0.0
|
|
137
|
+
for i in range(3):
|
|
138
|
+
for j in range(3):
|
|
139
|
+
C[i, j] = K - 2.0 * G * theta / 3.0
|
|
140
|
+
C[i, i] += 2.0 * G * theta
|
|
141
|
+
for i in range(3, 6):
|
|
142
|
+
C[i, i] = G * theta
|
|
143
|
+
for i in range(6):
|
|
144
|
+
for j in range(6):
|
|
145
|
+
C[i, j] -= 2.0 * G * theta_bar * n[i] * n[j]
|
|
146
|
+
return dp
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@njit(cache=True)
|
|
150
|
+
def _kinematics(F, Fn): # pragma: no cover - compiled
|
|
151
|
+
"""The increment ``ΔF = F Fn⁻¹`` split into its rotation ``ΔR`` (cosine, sine) and
|
|
152
|
+
the logarithm of its stretch ``ln ΔU`` (11, 22, 12) in the frame of ``Fn``;
|
|
153
|
+
``ok`` is false if the increment inverts the element."""
|
|
154
|
+
det_n = Fn[0, 0] * Fn[1, 1] - Fn[0, 1] * Fn[1, 0]
|
|
155
|
+
inv00, inv01 = Fn[1, 1] / det_n, -Fn[0, 1] / det_n
|
|
156
|
+
inv10, inv11 = -Fn[1, 0] / det_n, Fn[0, 0] / det_n
|
|
157
|
+
d00 = F[0, 0] * inv00 + F[0, 1] * inv10
|
|
158
|
+
d01 = F[0, 0] * inv01 + F[0, 1] * inv11
|
|
159
|
+
d10 = F[1, 0] * inv00 + F[1, 1] * inv10
|
|
160
|
+
d11 = F[1, 0] * inv01 + F[1, 1] * inv11
|
|
161
|
+
# polar decomposition dF = R U
|
|
162
|
+
th = math.atan2(d10 - d01, d00 + d11)
|
|
163
|
+
c, s = math.cos(th), math.sin(th)
|
|
164
|
+
u00 = c * d00 + s * d10
|
|
165
|
+
u01 = c * d01 + s * d11
|
|
166
|
+
u10 = -s * d00 + c * d10
|
|
167
|
+
u11 = -s * d01 + c * d11
|
|
168
|
+
u01 = 0.5 * (u01 + u10)
|
|
169
|
+
# logarithm of U (symmetric 2 x 2)
|
|
170
|
+
m = 0.5 * (u00 + u11)
|
|
171
|
+
r = math.sqrt(0.25 * (u00 - u11) ** 2 + u01 * u01)
|
|
172
|
+
l1, l2 = m + r, m - r
|
|
173
|
+
if l2 <= 0.0:
|
|
174
|
+
return c, s, 0.0, 0.0, 0.0, False
|
|
175
|
+
if r < 1e-14:
|
|
176
|
+
return c, s, math.log(l1), math.log(l2), 0.0, True
|
|
177
|
+
phi = 0.5 * math.atan2(2.0 * u01, u00 - u11)
|
|
178
|
+
cp, sp = math.cos(phi), math.sin(phi)
|
|
179
|
+
g1, g2 = math.log(l1), math.log(l2)
|
|
180
|
+
return (
|
|
181
|
+
c,
|
|
182
|
+
s,
|
|
183
|
+
g1 * cp * cp + g2 * sp * sp,
|
|
184
|
+
g1 * sp * sp + g2 * cp * cp,
|
|
185
|
+
(g1 - g2) * cp * sp,
|
|
186
|
+
True,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
#: The coefficients of Hill's 1948 criterion of an isotropic point (von Mises): F, G, H,
|
|
191
|
+
#: N (normalized by G + H = 1) and the angle of its rolling direction (radians).
|
|
192
|
+
ISOTROPIC = (0.5, 0.5, 0.5, 1.5, 0.0)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def hill_from_r(r0: float, r45: float, r90: float, angle: float = 0.0) -> tuple:
|
|
196
|
+
"""Hill's 1948 coefficients ``(F, G, H, N)`` of a sheet of Lankford coefficients
|
|
197
|
+
``r0``, ``r45``, ``r90`` (normalized by ``G + H = 1``: the yield stress along the
|
|
198
|
+
rolling direction), and the angle of its rolling direction from the axis of the
|
|
199
|
+
specimen (degrees; radians in the tuple): the anisotropy of a point of a
|
|
200
|
+
:class:`Membrane`."""
|
|
201
|
+
r0, r45, r90 = float(r0), float(r45), float(r90)
|
|
202
|
+
if min(r0, r45, r90) <= 0:
|
|
203
|
+
raise ValueError("hill_from_r: positive r values")
|
|
204
|
+
G = 1.0 / (1.0 + r0)
|
|
205
|
+
H = r0 / (1.0 + r0)
|
|
206
|
+
F = r0 / (r90 * (1.0 + r0))
|
|
207
|
+
N = (r0 + r90) * (1.0 + 2.0 * r45) / (2.0 * r90 * (1.0 + r0))
|
|
208
|
+
return (F, G, H, N, math.radians(angle))
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def yld2000_profile(alpha, a: float, angles=(0.0, 45.0, 90.0)) -> dict:
|
|
212
|
+
"""The yield stresses (over that along the rolling direction) and the Lankford
|
|
213
|
+
coefficients of Yld2000-2d ``(alpha, a)`` in uniaxial tension at ``angles``
|
|
214
|
+
(degrees), and in equibiaxial tension (``"b"``): ``{"stress": [...], "r": [...],
|
|
215
|
+
"stress_b", "r_b"}``."""
|
|
216
|
+
al = np.asarray(alpha, dtype=float)
|
|
217
|
+
T = np.eye(3)
|
|
218
|
+
n = np.empty(3)
|
|
219
|
+
out = {"stress": [], "r": []}
|
|
220
|
+
s0 = _yld_eq(np.array([1.0, 0.0, 0.0]), al, float(a), T, n)
|
|
221
|
+
for ang in np.atleast_1d(angles):
|
|
222
|
+
th = math.radians(float(ang))
|
|
223
|
+
c, s = math.cos(th), math.sin(th)
|
|
224
|
+
seq = _yld_eq(np.array([c * c, s * s, c * s]), al, float(a), T, n)
|
|
225
|
+
out["stress"].append(s0 / seq)
|
|
226
|
+
out["r"].append(-(n[0] * s * s + n[1] * c * c - n[2] * c * s) / (n[0] + n[1]))
|
|
227
|
+
seq = _yld_eq(np.array([1.0, 1.0, 0.0]), al, float(a), T, n)
|
|
228
|
+
out["stress_b"] = s0 / seq
|
|
229
|
+
out["r_b"] = n[1] / n[0]
|
|
230
|
+
return out
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def yld2000_from_data(
|
|
234
|
+
s0: float,
|
|
235
|
+
s45: float,
|
|
236
|
+
s90: float,
|
|
237
|
+
sb: float,
|
|
238
|
+
r0: float,
|
|
239
|
+
r45: float,
|
|
240
|
+
r90: float,
|
|
241
|
+
rb: float = 1.0,
|
|
242
|
+
a: float = 6.0,
|
|
243
|
+
angle: float = 0.0,
|
|
244
|
+
) -> tuple:
|
|
245
|
+
"""Barlat's Yld2000-2d coefficients α1 ... α8 fitted exactly to the yield stresses
|
|
246
|
+
``s0``, ``s45``, ``s90`` of uniaxial tension at 0°, 45°, 90° from the rolling
|
|
247
|
+
direction, ``sb`` of equibiaxial tension, the Lankford coefficients ``r0``, ``r45``,
|
|
248
|
+
``r90`` and the biaxial ratio ``rb`` (Barlat et al. 2003; the stresses in any unit,
|
|
249
|
+
the equivalent stress being normalized to ``s0``), with the exponent ``a`` (6 for
|
|
250
|
+
cubic-centred metals, 8 for face-centred), and the angle of the rolling direction
|
|
251
|
+
from the axis of the specimen (degrees): the anisotropy of a point of a
|
|
252
|
+
:class:`Membrane` (10 values)."""
|
|
253
|
+
from scipy.optimize import least_squares
|
|
254
|
+
|
|
255
|
+
data = np.array([1.0, s0 / s45, s0 / s90, s0 / sb, r0, r45, r90, rb], dtype=float)
|
|
256
|
+
if not np.all(np.isfinite(data)) or min(s0, s45, s90, sb, r0, r45, r90, rb) <= 0:
|
|
257
|
+
raise ValueError("yld2000_from_data: positive stresses and r values")
|
|
258
|
+
T = np.eye(3)
|
|
259
|
+
n = np.empty(3)
|
|
260
|
+
tests = []
|
|
261
|
+
for ang in (0.0, 45.0, 90.0):
|
|
262
|
+
th = math.radians(ang)
|
|
263
|
+
c, s = math.cos(th), math.sin(th)
|
|
264
|
+
tests.append((np.array([c * c, s * s, c * s]), c, s))
|
|
265
|
+
|
|
266
|
+
def residuals(x):
|
|
267
|
+
out = np.empty(8)
|
|
268
|
+
for k, (u, _c, _s) in enumerate(tests):
|
|
269
|
+
out[k] = _yld_eq(u, x, a, T, n) - data[k]
|
|
270
|
+
out[3] = _yld_eq(np.array([1.0, 1.0, 0.0]), x, a, T, n) - data[3]
|
|
271
|
+
for k, (u, c, s) in enumerate(tests):
|
|
272
|
+
_yld_eq(u, x, a, T, n)
|
|
273
|
+
out[4 + k] = -(n[0] * s * s + n[1] * c * c - n[2] * c * s) / (n[0] + n[1]) - data[4 + k]
|
|
274
|
+
_yld_eq(np.array([1.0, 1.0, 0.0]), x, a, T, n)
|
|
275
|
+
out[7] = n[1] / n[0] - data[7]
|
|
276
|
+
return out
|
|
277
|
+
|
|
278
|
+
sol = least_squares(residuals, np.ones(8), method="lm", xtol=1e-14, ftol=1e-14, gtol=1e-14)
|
|
279
|
+
worst = float(np.max(np.abs(sol.fun)))
|
|
280
|
+
if not worst < 1e-8:
|
|
281
|
+
raise ValueError(f"yld2000_from_data: no exact fit (residual {worst:.1e})")
|
|
282
|
+
return (*(float(v) for v in sol.x), float(a), math.radians(angle))
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@njit(cache=True)
|
|
286
|
+
def _isotropic(aniso): # pragma: no cover - compiled
|
|
287
|
+
return (
|
|
288
|
+
abs(aniso[0] - 0.5) < 1e-12
|
|
289
|
+
and abs(aniso[1] - 0.5) < 1e-12
|
|
290
|
+
and abs(aniso[2] - 0.5) < 1e-12
|
|
291
|
+
and abs(aniso[3] - 1.5) < 1e-12
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
@njit(cache=True)
|
|
296
|
+
def _inv3(A, out): # pragma: no cover - compiled
|
|
297
|
+
a, b, c = A[0, 0], A[0, 1], A[0, 2]
|
|
298
|
+
d, e, f = A[1, 0], A[1, 1], A[1, 2]
|
|
299
|
+
g, h, i = A[2, 0], A[2, 1], A[2, 2]
|
|
300
|
+
det = a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g)
|
|
301
|
+
out[0, 0], out[0, 1], out[0, 2] = (
|
|
302
|
+
(e * i - f * h) / det,
|
|
303
|
+
(c * h - b * i) / det,
|
|
304
|
+
(b * f - c * e) / det,
|
|
305
|
+
)
|
|
306
|
+
out[1, 0], out[1, 1], out[1, 2] = (
|
|
307
|
+
(f * g - d * i) / det,
|
|
308
|
+
(a * i - c * g) / det,
|
|
309
|
+
(c * d - a * f) / det,
|
|
310
|
+
)
|
|
311
|
+
out[2, 0], out[2, 1], out[2, 2] = (
|
|
312
|
+
(d * h - e * g) / det,
|
|
313
|
+
(b * g - a * h) / det,
|
|
314
|
+
(a * e - b * d) / det,
|
|
315
|
+
)
|
|
316
|
+
return det
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
@njit(cache=True)
|
|
320
|
+
def _hill_matrix(aniso, phi, P): # pragma: no cover - compiled
|
|
321
|
+
"""``σ_eq² = σᵀ P σ`` (σ = 11, 22, 12) of Hill's 1948 criterion in plane stress, its
|
|
322
|
+
rolling direction at the angle ``phi`` from the axis 1."""
|
|
323
|
+
pm = np.zeros((3, 3))
|
|
324
|
+
pm[0, 0] = aniso[1] + aniso[2]
|
|
325
|
+
pm[0, 1] = pm[1, 0] = -aniso[2]
|
|
326
|
+
pm[1, 1] = aniso[0] + aniso[2]
|
|
327
|
+
pm[2, 2] = 2.0 * aniso[3]
|
|
328
|
+
c, s = math.cos(phi), math.sin(phi)
|
|
329
|
+
T = np.empty((3, 3)) # the components in the axes of the rolling direction
|
|
330
|
+
T[0, 0], T[0, 1], T[0, 2] = c * c, s * s, 2.0 * c * s
|
|
331
|
+
T[1, 0], T[1, 1], T[1, 2] = s * s, c * c, -2.0 * c * s
|
|
332
|
+
T[2, 0], T[2, 1], T[2, 2] = -c * s, c * s, c * c - s * s
|
|
333
|
+
for i in range(3):
|
|
334
|
+
for j in range(3):
|
|
335
|
+
acc = 0.0
|
|
336
|
+
for k in range(3):
|
|
337
|
+
for m in range(3):
|
|
338
|
+
acc += T[k, i] * pm[k, m] * T[m, j]
|
|
339
|
+
P[i, j] = acc
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
@njit(cache=True)
|
|
343
|
+
def _hill_state(dg, tr, C, P, out): # pragma: no cover - compiled
|
|
344
|
+
"""The stress ``(I + dg C P)⁻¹ tr`` in ``out``; returns its equivalent stress."""
|
|
345
|
+
A = np.empty((3, 3))
|
|
346
|
+
for i in range(3):
|
|
347
|
+
for j in range(3):
|
|
348
|
+
acc = 0.0
|
|
349
|
+
for k in range(3):
|
|
350
|
+
acc += C[i, k] * P[k, j]
|
|
351
|
+
A[i, j] = (1.0 if i == j else 0.0) + dg * acc
|
|
352
|
+
Ai = np.empty((3, 3))
|
|
353
|
+
_inv3(A, Ai)
|
|
354
|
+
for i in range(3):
|
|
355
|
+
out[i] = Ai[i, 0] * tr[0] + Ai[i, 1] * tr[1] + Ai[i, 2] * tr[2]
|
|
356
|
+
q = 0.0
|
|
357
|
+
for i in range(3):
|
|
358
|
+
for j in range(3):
|
|
359
|
+
q += out[i] * P[i, j] * out[j]
|
|
360
|
+
return math.sqrt(max(q, 0.0))
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
@njit(cache=True)
|
|
364
|
+
def _hill_update(
|
|
365
|
+
sig_old, de, p_old, law, aniso, phi, E, nu, offset, out, Cp, mloc
|
|
366
|
+
): # pragma: no cover
|
|
367
|
+
"""The plane-stress return mapping of Hill's 1948 criterion (associated flow
|
|
368
|
+
``Δε_p = Δγ P σ``, ``Δp = Δγ σ_eq``; de Souza Neto, Perić & Owen 2008, ch. 9-10):
|
|
369
|
+
the stress (11, 22, 12) in ``out``, the consistent tangent in ``Cp``, ``d ln J / dε``
|
|
370
|
+
in ``mloc``; returns ``(Δp, Δε33)``."""
|
|
371
|
+
P = np.empty((3, 3))
|
|
372
|
+
_hill_matrix(aniso, phi, P)
|
|
373
|
+
k = E / (1.0 - nu * nu)
|
|
374
|
+
C = np.zeros((3, 3))
|
|
375
|
+
C[0, 0] = C[1, 1] = k
|
|
376
|
+
C[0, 1] = C[1, 0] = k * nu
|
|
377
|
+
C[2, 2] = 0.5 * k * (1.0 - nu)
|
|
378
|
+
tr = np.empty(3)
|
|
379
|
+
for i in range(3):
|
|
380
|
+
tr[i] = sig_old[i] + C[i, 0] * de[0] + C[i, 1] * de[1] + C[i, 2] * de[2]
|
|
381
|
+
q = 0.0
|
|
382
|
+
for i in range(3):
|
|
383
|
+
for j in range(3):
|
|
384
|
+
q += tr[i] * P[i, j] * tr[j]
|
|
385
|
+
q = math.sqrt(max(q, 0.0))
|
|
386
|
+
sy, h = _flowm(law, p_old, offset)
|
|
387
|
+
if q - sy <= 1e-10 * max(sy, 1.0): # elastic
|
|
388
|
+
for i in range(3):
|
|
389
|
+
out[i] = tr[i]
|
|
390
|
+
for j in range(3):
|
|
391
|
+
Cp[i, j] = C[i, j]
|
|
392
|
+
r = nu / (1.0 - nu)
|
|
393
|
+
mloc[0] = mloc[1] = 1.0 - r
|
|
394
|
+
mloc[2] = 0.0
|
|
395
|
+
return 0.0, -r * (de[0] + de[1])
|
|
396
|
+
# Newton on the multiplier, bracketed (the residual falls with it)
|
|
397
|
+
G = 0.5 * E / (1.0 + nu)
|
|
398
|
+
lo, hi = 0.0, 2.0 * (q - sy) / (3.0 * G * max(sy, 1.0))
|
|
399
|
+
sig = np.empty(3)
|
|
400
|
+
for _ in range(60):
|
|
401
|
+
seq = _hill_state(hi, tr, C, P, sig)
|
|
402
|
+
if seq - _flowm(law, p_old + hi * seq, offset)[0] < 0.0:
|
|
403
|
+
break
|
|
404
|
+
lo, hi = hi, 2.0 * hi
|
|
405
|
+
dg = 0.5 * (lo + hi)
|
|
406
|
+
for _ in range(80):
|
|
407
|
+
seq = _hill_state(dg, tr, C, P, sig)
|
|
408
|
+
res = seq - _flowm(law, p_old + dg * seq, offset)[0]
|
|
409
|
+
if abs(res) <= 1e-11 * max(sy, 1.0):
|
|
410
|
+
break
|
|
411
|
+
if res > 0.0:
|
|
412
|
+
lo = dg
|
|
413
|
+
else:
|
|
414
|
+
hi = dg
|
|
415
|
+
step = 1e-6 * max(dg, 1e-12)
|
|
416
|
+
seq2 = _hill_state(dg + step, tr, C, P, out)
|
|
417
|
+
res2 = seq2 - _flowm(law, p_old + (dg + step) * seq2, offset)[0]
|
|
418
|
+
slope = (res2 - res) / step
|
|
419
|
+
new = dg - res / slope if slope < 0.0 else 0.5 * (lo + hi)
|
|
420
|
+
if new <= lo or new >= hi:
|
|
421
|
+
new = 0.5 * (lo + hi)
|
|
422
|
+
dg = new
|
|
423
|
+
seq = _hill_state(dg, tr, C, P, sig)
|
|
424
|
+
dp = dg * seq
|
|
425
|
+
sy, h = _flowm(law, p_old + dp, offset)
|
|
426
|
+
# the consistent tangent: E_xi = (C^-1 + dg P)^-1, n = P sigma
|
|
427
|
+
Ci = np.empty((3, 3))
|
|
428
|
+
_inv3(C, Ci)
|
|
429
|
+
for i in range(3):
|
|
430
|
+
for j in range(3):
|
|
431
|
+
Ci[i, j] += dg * P[i, j]
|
|
432
|
+
Ex = np.empty((3, 3))
|
|
433
|
+
_inv3(Ci, Ex)
|
|
434
|
+
n = np.empty(3)
|
|
435
|
+
for i in range(3):
|
|
436
|
+
n[i] = P[i, 0] * sig[0] + P[i, 1] * sig[1] + P[i, 2] * sig[2]
|
|
437
|
+
En = np.empty(3)
|
|
438
|
+
for i in range(3):
|
|
439
|
+
En[i] = Ex[i, 0] * n[0] + Ex[i, 1] * n[1] + Ex[i, 2] * n[2]
|
|
440
|
+
a = n[0] * En[0] + n[1] * En[1] + n[2] * En[2]
|
|
441
|
+
beta = max(1.0 - h * dg, 1e-6)
|
|
442
|
+
coef = beta / (h * seq * seq + a * beta)
|
|
443
|
+
for i in range(3):
|
|
444
|
+
out[i] = sig[i]
|
|
445
|
+
for j in range(3):
|
|
446
|
+
Cp[i, j] = Ex[i, j] - coef * En[i] * En[j]
|
|
447
|
+
# the thickness: elastic (plane stress) and plastic (incompressible) parts
|
|
448
|
+
de33 = -nu / E * (sig[0] - sig_old[0] + sig[1] - sig_old[1]) - dg * (n[0] + n[1])
|
|
449
|
+
for j in range(3):
|
|
450
|
+
d33 = -nu / E * (Cp[0, j] + Cp[1, j]) - (n[0] + n[1]) * coef * En[j]
|
|
451
|
+
for i in range(2):
|
|
452
|
+
for m in range(3):
|
|
453
|
+
d33 -= dg * P[i, m] * Cp[m, j]
|
|
454
|
+
mloc[j] = (1.0 if j < 2 else 0.0) + d33
|
|
455
|
+
return dp, de33
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
#: The isotropic point of Barlat's Yld2000-2d criterion: α1 ... α8 = 1, the exponent 2
|
|
459
|
+
#: (von Mises), the angle of the rolling direction (radians).
|
|
460
|
+
YLD_ISOTROPIC = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 0.0)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
@njit(cache=True)
|
|
464
|
+
def _yld_phi(sx, sy, sxy, al, a, g): # pragma: no cover - compiled
|
|
465
|
+
"""Barlat's Yld2000-2d function ``φ = |X'1 − X'2|^a + |2X''2 + X''1|^a + |2X''1 +
|
|
466
|
+
X''2|^a`` (``X' = L' σ``, ``X'' = L'' σ``, their principal values; Barlat et al.
|
|
467
|
+
2003) of the plane stress ``(sx, sy, sxy)`` in the axes of the rolling direction, its
|
|
468
|
+
gradient ``(∂φ/∂sx, ∂φ/∂sy, ∂φ/∂sxy)`` in ``g``; ``al``: α1 ... α8."""
|
|
469
|
+
a1, a2, a3, a4, a5, a6, a7, a8 = al[0], al[1], al[2], al[3], al[4], al[5], al[6], al[7]
|
|
470
|
+
l00, l01 = 2.0 * a1 / 3.0, -a1 / 3.0
|
|
471
|
+
l10, l11 = -a2 / 3.0, 2.0 * a2 / 3.0
|
|
472
|
+
x0 = l00 * sx + l01 * sy
|
|
473
|
+
x1 = l10 * sx + l11 * sy
|
|
474
|
+
x2 = a7 * sxy
|
|
475
|
+
dx = x0 - x1
|
|
476
|
+
d1 = math.sqrt(dx * dx + 4.0 * x2 * x2)
|
|
477
|
+
phi = d1**a
|
|
478
|
+
if d1 > 0.0:
|
|
479
|
+
f = a * d1 ** (a - 2.0)
|
|
480
|
+
elif a <= 2.0 + 1e-12:
|
|
481
|
+
f = a
|
|
482
|
+
else:
|
|
483
|
+
f = 0.0
|
|
484
|
+
gx0, gx1, gx2 = f * dx, -f * dx, 4.0 * f * x2
|
|
485
|
+
g[0] = l00 * gx0 + l10 * gx1
|
|
486
|
+
g[1] = l01 * gx0 + l11 * gx1
|
|
487
|
+
g[2] = a7 * gx2
|
|
488
|
+
m00 = (-2.0 * a3 + 2.0 * a4 + 8.0 * a5 - 2.0 * a6) / 9.0
|
|
489
|
+
m01 = (a3 - 4.0 * a4 - 4.0 * a5 + 4.0 * a6) / 9.0
|
|
490
|
+
m10 = (4.0 * a3 - 4.0 * a4 - 4.0 * a5 + a6) / 9.0
|
|
491
|
+
m11 = (-2.0 * a3 + 8.0 * a4 + 2.0 * a5 - 2.0 * a6) / 9.0
|
|
492
|
+
y0 = m00 * sx + m01 * sy
|
|
493
|
+
y1 = m10 * sx + m11 * sy
|
|
494
|
+
y2 = a8 * sxy
|
|
495
|
+
S = y0 + y1
|
|
496
|
+
dy = y0 - y1
|
|
497
|
+
D = math.sqrt(dy * dy + 4.0 * y2 * y2)
|
|
498
|
+
A = 0.5 * (3.0 * S - D)
|
|
499
|
+
B = 0.5 * (3.0 * S + D)
|
|
500
|
+
phi += abs(A) ** a + abs(B) ** a
|
|
501
|
+
dA = a * abs(A) ** (a - 1.0) * (1.0 if A >= 0.0 else -1.0)
|
|
502
|
+
dB = a * abs(B) ** (a - 1.0) * (1.0 if B >= 0.0 else -1.0)
|
|
503
|
+
dS = 1.5 * (dA + dB)
|
|
504
|
+
if D > 1e-8 * (abs(y0) + abs(y1) + abs(y2) + 1e-300):
|
|
505
|
+
k = 0.5 * (dB - dA) / D
|
|
506
|
+
else: # the limit of (dB - dA) / 2D as the principal values meet
|
|
507
|
+
k = 0.5 * a * (a - 1.0) * abs(1.5 * S) ** (a - 2.0)
|
|
508
|
+
gy0 = dS + k * dy
|
|
509
|
+
gy1 = dS - k * dy
|
|
510
|
+
gy2 = 4.0 * k * y2
|
|
511
|
+
g[0] += m00 * gy0 + m10 * gy1
|
|
512
|
+
g[1] += m01 * gy0 + m11 * gy1
|
|
513
|
+
g[2] += a8 * gy2
|
|
514
|
+
return phi
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
@njit(cache=True)
|
|
518
|
+
def _yld_axes(phi, T): # pragma: no cover - compiled
|
|
519
|
+
"""The change of the stress components (11, 22, 12) to the axes of the rolling
|
|
520
|
+
direction at ``phi`` (radians) from the axis 1."""
|
|
521
|
+
c, s = math.cos(phi), math.sin(phi)
|
|
522
|
+
T[0, 0], T[0, 1], T[0, 2] = c * c, s * s, 2.0 * c * s
|
|
523
|
+
T[1, 0], T[1, 1], T[1, 2] = s * s, c * c, -2.0 * c * s
|
|
524
|
+
T[2, 0], T[2, 1], T[2, 2] = -c * s, c * s, c * c - s * s
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
@njit(cache=True)
|
|
528
|
+
def _yld_eq(sig, al, a, T, n): # pragma: no cover - compiled
|
|
529
|
+
"""The equivalent stress ``(φ/2)^(1/a)`` of Yld2000-2d (homogeneous of degree one:
|
|
530
|
+
the yield stress along the rolling direction when the α are fitted to it) and its
|
|
531
|
+
gradient ``n`` (engineering shear: ``Δε_p = Δγ n``, ``σ·n = σ_eq``)."""
|
|
532
|
+
sm0 = T[0, 0] * sig[0] + T[0, 1] * sig[1] + T[0, 2] * sig[2]
|
|
533
|
+
sm1 = T[1, 0] * sig[0] + T[1, 1] * sig[1] + T[1, 2] * sig[2]
|
|
534
|
+
sm2 = T[2, 0] * sig[0] + T[2, 1] * sig[1] + T[2, 2] * sig[2]
|
|
535
|
+
gm = np.empty(3)
|
|
536
|
+
phi = _yld_phi(sm0, sm1, sm2, al, a, gm)
|
|
537
|
+
if phi <= 0.0:
|
|
538
|
+
n[0] = n[1] = n[2] = 0.0
|
|
539
|
+
return 0.0
|
|
540
|
+
seq = (0.5 * phi) ** (1.0 / a)
|
|
541
|
+
fac = seq / (a * phi)
|
|
542
|
+
for i in range(3):
|
|
543
|
+
n[i] = fac * (T[0, i] * gm[0] + T[1, i] * gm[1] + T[2, i] * gm[2])
|
|
544
|
+
return seq
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
@njit(cache=True)
|
|
548
|
+
def _yld_hessian(sig, al, a, T, N): # pragma: no cover - compiled
|
|
549
|
+
"""``∂n/∂σ`` by central differences of the analytical gradient, symmetrized."""
|
|
550
|
+
h = 1e-6 * (abs(sig[0]) + abs(sig[1]) + abs(sig[2]) + 1e-3)
|
|
551
|
+
sp = np.empty(3)
|
|
552
|
+
npl = np.empty(3)
|
|
553
|
+
nmi = np.empty(3)
|
|
554
|
+
for j in range(3):
|
|
555
|
+
for i in range(3):
|
|
556
|
+
sp[i] = sig[i]
|
|
557
|
+
sp[j] = sig[j] + h
|
|
558
|
+
_yld_eq(sp, al, a, T, npl)
|
|
559
|
+
sp[j] = sig[j] - h
|
|
560
|
+
_yld_eq(sp, al, a, T, nmi)
|
|
561
|
+
for i in range(3):
|
|
562
|
+
N[i, j] = (npl[i] - nmi[i]) / (2.0 * h)
|
|
563
|
+
for i in range(3):
|
|
564
|
+
for j in range(i + 1, 3):
|
|
565
|
+
m = 0.5 * (N[i, j] + N[j, i])
|
|
566
|
+
N[i, j] = m
|
|
567
|
+
N[j, i] = m
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
@njit(cache=True)
|
|
571
|
+
def _yld_return(tr, p_old, law, al, a, T, Ci, offset, sig, n, N): # pragma: no cover
|
|
572
|
+
"""The closest-point return of Yld2000-2d from the trial stress ``tr``: Newton's
|
|
573
|
+
method on ``C⁻¹(σ − σ*) + Δγ n(σ) = 0``, ``σ_eq(σ) = σ_y(p + Δγ)`` with a
|
|
574
|
+
backtracking line search on the residual (the large curvature of the biaxial region:
|
|
575
|
+
Zhang et al. 2018); returns ``(Δγ, converged)``, the stress in ``sig``."""
|
|
576
|
+
seq = _yld_eq(tr, al, a, T, n)
|
|
577
|
+
sy, h = _flowm(law, p_old, offset)
|
|
578
|
+
scale = max(sy, 1.0)
|
|
579
|
+
C = np.empty((3, 3))
|
|
580
|
+
_inv3(Ci, C)
|
|
581
|
+
Cn = np.empty(3)
|
|
582
|
+
for i in range(3):
|
|
583
|
+
Cn[i] = C[i, 0] * n[0] + C[i, 1] * n[1] + C[i, 2] * n[2]
|
|
584
|
+
nCn = n[0] * Cn[0] + n[1] * Cn[1] + n[2] * Cn[2]
|
|
585
|
+
dg = max((seq - sy) / (nCn + max(h, 0.0)), 0.0)
|
|
586
|
+
for i in range(3):
|
|
587
|
+
sig[i] = tr[i] - dg * Cn[i]
|
|
588
|
+
J = np.empty((4, 4))
|
|
589
|
+
R = np.empty(4)
|
|
590
|
+
st = np.empty(3)
|
|
591
|
+
nt = np.empty(3)
|
|
592
|
+
Et = C[0, 0]
|
|
593
|
+
dgt = dg
|
|
594
|
+
for _ in range(80):
|
|
595
|
+
seq = _yld_eq(sig, al, a, T, n)
|
|
596
|
+
syk, hk = _flowm(law, p_old + dg, offset)
|
|
597
|
+
err = 0.0
|
|
598
|
+
for i in range(3):
|
|
599
|
+
R[i] = (
|
|
600
|
+
Ci[i, 0] * (sig[0] - tr[0])
|
|
601
|
+
+ Ci[i, 1] * (sig[1] - tr[1])
|
|
602
|
+
+ Ci[i, 2] * (sig[2] - tr[2])
|
|
603
|
+
+ dg * n[i]
|
|
604
|
+
)
|
|
605
|
+
err += (R[i] * Et) ** 2
|
|
606
|
+
R[3] = seq - syk
|
|
607
|
+
err = math.sqrt(err + R[3] ** 2) / scale
|
|
608
|
+
if err < 1e-10:
|
|
609
|
+
return dg, True
|
|
610
|
+
_yld_hessian(sig, al, a, T, N)
|
|
611
|
+
for i in range(3):
|
|
612
|
+
for j in range(3):
|
|
613
|
+
J[i, j] = Ci[i, j] + dg * N[i, j]
|
|
614
|
+
J[i, 3] = n[i]
|
|
615
|
+
J[3, i] = n[i]
|
|
616
|
+
J[3, 3] = -hk
|
|
617
|
+
dx = np.linalg.solve(J, -R)
|
|
618
|
+
t = 1.0
|
|
619
|
+
accepted = False
|
|
620
|
+
for _ls in range(30):
|
|
621
|
+
dgt = dg + t * dx[3]
|
|
622
|
+
if dgt >= 0.0:
|
|
623
|
+
for i in range(3):
|
|
624
|
+
st[i] = sig[i] + t * dx[i]
|
|
625
|
+
seqt = _yld_eq(st, al, a, T, nt)
|
|
626
|
+
syt = _flowm(law, p_old + dgt, offset)[0]
|
|
627
|
+
errt = 0.0
|
|
628
|
+
for i in range(3):
|
|
629
|
+
ri = (
|
|
630
|
+
Ci[i, 0] * (st[0] - tr[0])
|
|
631
|
+
+ Ci[i, 1] * (st[1] - tr[1])
|
|
632
|
+
+ Ci[i, 2] * (st[2] - tr[2])
|
|
633
|
+
+ dgt * nt[i]
|
|
634
|
+
)
|
|
635
|
+
errt += (ri * Et) ** 2
|
|
636
|
+
errt = math.sqrt(errt + (seqt - syt) ** 2) / scale
|
|
637
|
+
if errt < (1.0 - 1e-4 * t) * err:
|
|
638
|
+
accepted = True
|
|
639
|
+
break
|
|
640
|
+
t *= 0.5
|
|
641
|
+
if not accepted:
|
|
642
|
+
return dg, False
|
|
643
|
+
for i in range(3):
|
|
644
|
+
sig[i] = st[i]
|
|
645
|
+
dg = dgt
|
|
646
|
+
return dg, False
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
@njit(cache=True)
|
|
650
|
+
def _yld_update(
|
|
651
|
+
sig_old, de, p_old, law, aniso, phi, E, nu, offset, out, Cp, mloc
|
|
652
|
+
): # pragma: no cover
|
|
653
|
+
"""The plane-stress return mapping of Yld2000-2d (associated flow ``Δε_p = Δγ n``,
|
|
654
|
+
``Δp = Δγ``; the increment split in substeps if Newton's method fails): the stress
|
|
655
|
+
(11, 22, 12) in ``out``, the consistent tangent ``Ξ − (Ξn)(Ξn)ᵀ/(nᵀΞn + h)``,
|
|
656
|
+
``Ξ = (C⁻¹ + Δγ ∂n/∂σ)⁻¹`` (of the last substep), in ``Cp``, ``d ln J / dε`` in
|
|
657
|
+
``mloc``; returns ``(Δp, Δε33)``."""
|
|
658
|
+
al = aniso[:8]
|
|
659
|
+
a = aniso[8]
|
|
660
|
+
T = np.empty((3, 3))
|
|
661
|
+
_yld_axes(phi, T)
|
|
662
|
+
k = E / (1.0 - nu * nu)
|
|
663
|
+
C = np.zeros((3, 3))
|
|
664
|
+
C[0, 0] = C[1, 1] = k
|
|
665
|
+
C[0, 1] = C[1, 0] = k * nu
|
|
666
|
+
C[2, 2] = 0.5 * k * (1.0 - nu)
|
|
667
|
+
Ci = np.empty((3, 3))
|
|
668
|
+
_inv3(C, Ci)
|
|
669
|
+
n = np.empty(3)
|
|
670
|
+
N = np.empty((3, 3))
|
|
671
|
+
sig = np.empty(3)
|
|
672
|
+
start = np.empty(3)
|
|
673
|
+
tr = np.empty(3)
|
|
674
|
+
nsub = 1
|
|
675
|
+
p_cur = p_old
|
|
676
|
+
de33p = 0.0
|
|
677
|
+
dg = 0.0
|
|
678
|
+
last_plastic = False
|
|
679
|
+
while True:
|
|
680
|
+
for i in range(3):
|
|
681
|
+
start[i] = sig_old[i]
|
|
682
|
+
p_cur = p_old
|
|
683
|
+
de33p = 0.0
|
|
684
|
+
dg = 0.0
|
|
685
|
+
last_plastic = False
|
|
686
|
+
ok = True
|
|
687
|
+
for _sub in range(nsub):
|
|
688
|
+
for i in range(3):
|
|
689
|
+
tr[i] = start[i] + (C[i, 0] * de[0] + C[i, 1] * de[1] + C[i, 2] * de[2]) / nsub
|
|
690
|
+
q = _yld_eq(tr, al, a, T, n)
|
|
691
|
+
sy = _flowm(law, p_cur, offset)[0]
|
|
692
|
+
if q - sy <= 1e-10 * max(sy, 1.0): # an elastic substep
|
|
693
|
+
for i in range(3):
|
|
694
|
+
start[i] = tr[i]
|
|
695
|
+
last_plastic = False
|
|
696
|
+
continue
|
|
697
|
+
dg, conv = _yld_return(tr, p_cur, law, al, a, T, Ci, offset, sig, n, N)
|
|
698
|
+
if not conv:
|
|
699
|
+
ok = False
|
|
700
|
+
break
|
|
701
|
+
de33p -= dg * (n[0] + n[1]) # incompressible
|
|
702
|
+
p_cur += dg
|
|
703
|
+
for i in range(3):
|
|
704
|
+
start[i] = sig[i]
|
|
705
|
+
last_plastic = True
|
|
706
|
+
if ok or nsub >= 64:
|
|
707
|
+
break
|
|
708
|
+
nsub *= 2
|
|
709
|
+
de33 = -nu / E * (start[0] - sig_old[0] + start[1] - sig_old[1]) + de33p
|
|
710
|
+
if not last_plastic:
|
|
711
|
+
for i in range(3):
|
|
712
|
+
out[i] = start[i]
|
|
713
|
+
for j in range(3):
|
|
714
|
+
Cp[i, j] = C[i, j]
|
|
715
|
+
r = nu / (1.0 - nu)
|
|
716
|
+
mloc[0] = mloc[1] = 1.0 - r
|
|
717
|
+
mloc[2] = 0.0
|
|
718
|
+
return p_cur - p_old, de33
|
|
719
|
+
_yld_eq(start, al, a, T, n)
|
|
720
|
+
_yld_hessian(start, al, a, T, N)
|
|
721
|
+
h = _flowm(law, p_cur, offset)[1]
|
|
722
|
+
A = np.empty((3, 3))
|
|
723
|
+
for i in range(3):
|
|
724
|
+
for j in range(3):
|
|
725
|
+
A[i, j] = Ci[i, j] + dg * N[i, j]
|
|
726
|
+
Xi = np.empty((3, 3))
|
|
727
|
+
_inv3(A, Xi)
|
|
728
|
+
Xn = np.empty(3)
|
|
729
|
+
for i in range(3):
|
|
730
|
+
Xn[i] = Xi[i, 0] * n[0] + Xi[i, 1] * n[1] + Xi[i, 2] * n[2]
|
|
731
|
+
denom = n[0] * Xn[0] + n[1] * Xn[1] + n[2] * Xn[2] + max(h, 0.0)
|
|
732
|
+
for i in range(3):
|
|
733
|
+
out[i] = start[i]
|
|
734
|
+
for j in range(3):
|
|
735
|
+
Cp[i, j] = Xi[i, j] - Xn[i] * Xn[j] / denom
|
|
736
|
+
for j in range(3):
|
|
737
|
+
d33 = -nu / E * (Cp[0, j] + Cp[1, j]) - (n[0] + n[1]) * Xn[j] / denom
|
|
738
|
+
for i in range(2):
|
|
739
|
+
for m in range(3):
|
|
740
|
+
d33 -= dg * N[i, m] * Cp[m, j]
|
|
741
|
+
mloc[j] = (1.0 if j < 2 else 0.0) + d33
|
|
742
|
+
return p_cur - p_old, de33
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
@njit(cache=True)
|
|
746
|
+
def _point(F, Fn, sig_old, p_old, lam_old, law, aniso, E, nu, offset, sig_out, Cps, mvec):
|
|
747
|
+
"""Update of a layer of a Gauss point from ``Fn`` to ``F`` (2 x 2): the new in-plane
|
|
748
|
+
Cauchy stress (11, 22, 12) in ``sig_out``, the condensed spatial tangent in ``Cps``,
|
|
749
|
+
the derivative of ``ln J`` (in-plane trace plus thickness strain) in ``mvec``;
|
|
750
|
+
returns ``(p, λ3, ok)``. ``aniso``: Hill's coefficients and the rolling direction of
|
|
751
|
+
the point (5 values; :data:`ISOTROPIC`: von Mises, by the 3D radial return), or the
|
|
752
|
+
coefficients α1 ... α8 of Yld2000-2d, its exponent and the rolling direction (10;
|
|
753
|
+
:data:`YLD_ISOTROPIC`: von Mises)."""
|
|
754
|
+
G = E / (2.0 * (1.0 + nu))
|
|
755
|
+
K = E / (3.0 * (1.0 - 2.0 * nu))
|
|
756
|
+
c, s, e00, e11, e01, ok = _kinematics(F, Fn)
|
|
757
|
+
if not ok:
|
|
758
|
+
sig_out[:] = 0.0
|
|
759
|
+
return p_old, lam_old, False
|
|
760
|
+
Cp = np.empty((3, 3))
|
|
761
|
+
mloc = np.empty(3)
|
|
762
|
+
outv = np.empty(3)
|
|
763
|
+
yld = aniso.shape[0] == 10
|
|
764
|
+
if yld:
|
|
765
|
+
iso = abs(aniso[8] - 2.0) < 1e-12
|
|
766
|
+
for i in range(8):
|
|
767
|
+
if abs(aniso[i] - 1.0) > 1e-12:
|
|
768
|
+
iso = False
|
|
769
|
+
else:
|
|
770
|
+
iso = _isotropic(aniso)
|
|
771
|
+
if iso:
|
|
772
|
+
sig3 = np.zeros(6)
|
|
773
|
+
sig3[0], sig3[1], sig3[5] = sig_old[0], sig_old[1], sig_old[2]
|
|
774
|
+
de = np.zeros(6)
|
|
775
|
+
de[0], de[1], de[5] = e00, e11, 2.0 * e01
|
|
776
|
+
# thickness strain increment: Newton on sigma_33 = 0, bracketed
|
|
777
|
+
de[2] = -nu / (1.0 - nu) * (e00 + e11)
|
|
778
|
+
out = np.empty(6)
|
|
779
|
+
C = np.empty((6, 6))
|
|
780
|
+
lo, hi = -1.0, 1.0
|
|
781
|
+
dp = 0.0
|
|
782
|
+
ok = False
|
|
783
|
+
for _ in range(60):
|
|
784
|
+
dp = _return_3d(sig3, de, p_old, law, G, K, offset, out, C)
|
|
785
|
+
f = out[2]
|
|
786
|
+
scale = abs(out[0]) + abs(out[1]) + abs(out[5]) + 1.0
|
|
787
|
+
if abs(f) <= 1e-10 * scale:
|
|
788
|
+
ok = True
|
|
789
|
+
break
|
|
790
|
+
if f > 0:
|
|
791
|
+
hi = min(hi, de[2])
|
|
792
|
+
else:
|
|
793
|
+
lo = max(lo, de[2])
|
|
794
|
+
step = de[2] - f / C[2, 2]
|
|
795
|
+
if step <= lo or step >= hi:
|
|
796
|
+
step = 0.5 * (lo + hi)
|
|
797
|
+
de[2] = step
|
|
798
|
+
# condensed tangent on (11, 22, 12), and d(ln J)/d(eps): 1 + d(eps33)/d(eps)
|
|
799
|
+
idx = (0, 1, 5)
|
|
800
|
+
for i in range(3):
|
|
801
|
+
for j in range(3):
|
|
802
|
+
Cp[i, j] = C[idx[i], idx[j]] - C[idx[i], 2] * C[2, idx[j]] / C[2, 2]
|
|
803
|
+
mloc[i] = (1.0 if i < 2 else 0.0) - C[2, idx[i]] / C[2, 2]
|
|
804
|
+
outv[0], outv[1], outv[2] = out[0], out[1], out[5]
|
|
805
|
+
de33 = de[2]
|
|
806
|
+
else:
|
|
807
|
+
# the rolling direction turns with the material: the rotation of Fn
|
|
808
|
+
turn = math.atan2(Fn[1, 0] - Fn[0, 1], Fn[0, 0] + Fn[1, 1])
|
|
809
|
+
dvec = np.empty(3)
|
|
810
|
+
dvec[0], dvec[1], dvec[2] = e00, e11, 2.0 * e01
|
|
811
|
+
if yld:
|
|
812
|
+
dp, de33 = _yld_update(
|
|
813
|
+
sig_old, dvec, p_old, law, aniso, aniso[9] + turn, E, nu, offset, outv, Cp, mloc
|
|
814
|
+
)
|
|
815
|
+
else:
|
|
816
|
+
dp, de33 = _hill_update(
|
|
817
|
+
sig_old, dvec, p_old, law, aniso, aniso[4] + turn, E, nu, offset, outv, Cp, mloc
|
|
818
|
+
)
|
|
819
|
+
ok = True
|
|
820
|
+
# turn the stress and the tangent by the rotation of the increment
|
|
821
|
+
s00, s11, s01 = outv[0], outv[1], outv[2]
|
|
822
|
+
sig_out[0] = c * c * s00 - 2.0 * c * s * s01 + s * s * s11
|
|
823
|
+
sig_out[1] = s * s * s00 + 2.0 * c * s * s01 + c * c * s11
|
|
824
|
+
sig_out[2] = c * s * (s00 - s11) + (c * c - s * s) * s01
|
|
825
|
+
T = np.empty((3, 3))
|
|
826
|
+
T[0, 0], T[0, 1], T[0, 2] = c * c, s * s, -2.0 * c * s
|
|
827
|
+
T[1, 0], T[1, 1], T[1, 2] = s * s, c * c, 2.0 * c * s
|
|
828
|
+
T[2, 0], T[2, 1], T[2, 2] = c * s, -c * s, c * c - s * s
|
|
829
|
+
for i in range(3):
|
|
830
|
+
for j in range(3):
|
|
831
|
+
acc = 0.0
|
|
832
|
+
for k in range(3):
|
|
833
|
+
for m2 in range(3):
|
|
834
|
+
acc += T[i, k] * Cp[k, m2] * T[j, m2]
|
|
835
|
+
Cps[i, j] = acc
|
|
836
|
+
for i in range(3):
|
|
837
|
+
acc = 0.0
|
|
838
|
+
for k in range(3):
|
|
839
|
+
acc += T[i, k] * mloc[k]
|
|
840
|
+
mvec[i] = acc
|
|
841
|
+
return p_old + dp, lam_old * math.exp(de33), ok
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
@njit(parallel=True, cache=True)
|
|
845
|
+
def _elements(
|
|
846
|
+
coords,
|
|
847
|
+
quads,
|
|
848
|
+
dndX,
|
|
849
|
+
w0,
|
|
850
|
+
u,
|
|
851
|
+
Fn,
|
|
852
|
+
sig_n,
|
|
853
|
+
p_n,
|
|
854
|
+
lam_n,
|
|
855
|
+
law,
|
|
856
|
+
aniso,
|
|
857
|
+
E,
|
|
858
|
+
nu,
|
|
859
|
+
offset,
|
|
860
|
+
h0,
|
|
861
|
+
Ke,
|
|
862
|
+
fe,
|
|
863
|
+
sig,
|
|
864
|
+
p,
|
|
865
|
+
lam,
|
|
866
|
+
Fg,
|
|
867
|
+
bad,
|
|
868
|
+
): # pragma: no cover - compiled
|
|
869
|
+
"""Element stiffness matrices and internal forces (8 dofs: x0, y0, x1, y1...), the
|
|
870
|
+
states of the Gauss points and layers at the displacements ``u`` (``E``: Young's
|
|
871
|
+
modulus of each Gauss point and layer)."""
|
|
872
|
+
ne = quads.shape[0]
|
|
873
|
+
nl = sig_n.shape[2]
|
|
874
|
+
hl = h0 / nl
|
|
875
|
+
for e in prange(ne):
|
|
876
|
+
for i in range(8):
|
|
877
|
+
fe[e, i] = 0.0
|
|
878
|
+
for j in range(8):
|
|
879
|
+
Ke[e, i, j] = 0.0
|
|
880
|
+
for g in range(4):
|
|
881
|
+
F = np.eye(2)
|
|
882
|
+
for an in range(4):
|
|
883
|
+
node = quads[e, an]
|
|
884
|
+
for i in range(2):
|
|
885
|
+
for j in range(2):
|
|
886
|
+
F[i, j] += u[2 * node + i] * dndX[e, g, an, j]
|
|
887
|
+
for i in range(2):
|
|
888
|
+
for j in range(2):
|
|
889
|
+
Fg[e, g, i, j] = F[i, j]
|
|
890
|
+
det = F[0, 0] * F[1, 1] - F[0, 1] * F[1, 0]
|
|
891
|
+
if det <= 0.0:
|
|
892
|
+
bad[e] = True
|
|
893
|
+
continue
|
|
894
|
+
inv = np.empty((2, 2))
|
|
895
|
+
inv[0, 0], inv[0, 1] = F[1, 1] / det, -F[0, 1] / det
|
|
896
|
+
inv[1, 0], inv[1, 1] = -F[1, 0] / det, F[0, 0] / det
|
|
897
|
+
dndx = np.empty((4, 2))
|
|
898
|
+
for an in range(4):
|
|
899
|
+
for j in range(2):
|
|
900
|
+
dndx[an, j] = dndX[e, g, an, 0] * inv[0, j] + dndX[e, g, an, 1] * inv[1, j]
|
|
901
|
+
N = np.zeros(3)
|
|
902
|
+
D = np.zeros((3, 3))
|
|
903
|
+
so = np.empty(3)
|
|
904
|
+
Cl = np.empty((3, 3))
|
|
905
|
+
ml = np.empty(3)
|
|
906
|
+
for layer in range(nl):
|
|
907
|
+
pl, ll, ok = _point(
|
|
908
|
+
F,
|
|
909
|
+
Fn[e, g],
|
|
910
|
+
sig_n[e, g, layer],
|
|
911
|
+
p_n[e, g, layer],
|
|
912
|
+
lam_n[e, g, layer],
|
|
913
|
+
law[e, g, layer],
|
|
914
|
+
aniso[e, g, layer],
|
|
915
|
+
E[e, g, layer],
|
|
916
|
+
nu,
|
|
917
|
+
offset,
|
|
918
|
+
so,
|
|
919
|
+
Cl,
|
|
920
|
+
ml,
|
|
921
|
+
)
|
|
922
|
+
if not ok:
|
|
923
|
+
bad[e] = True
|
|
924
|
+
p[e, g, layer] = pl
|
|
925
|
+
lam[e, g, layer] = ll
|
|
926
|
+
for i in range(3):
|
|
927
|
+
sig[e, g, layer, i] = so[i]
|
|
928
|
+
jl = det * ll
|
|
929
|
+
# the Truesdell tangent of the Kirchhoff stress: J (C + sigma m) - S(tau)
|
|
930
|
+
t11, t22, t12 = jl * so[0], jl * so[1], jl * so[2]
|
|
931
|
+
for i in range(3):
|
|
932
|
+
N[i] += hl * jl * so[i]
|
|
933
|
+
for j in range(3):
|
|
934
|
+
D[i, j] += hl * jl * (Cl[i, j] + so[i] * ml[j])
|
|
935
|
+
D[0, 0] -= hl * 2.0 * t11
|
|
936
|
+
D[1, 1] -= hl * 2.0 * t22
|
|
937
|
+
D[0, 2] -= hl * t12
|
|
938
|
+
D[1, 2] -= hl * t12
|
|
939
|
+
D[2, 0] -= hl * t12
|
|
940
|
+
D[2, 1] -= hl * t12
|
|
941
|
+
D[2, 2] -= hl * 0.5 * (t11 + t22)
|
|
942
|
+
wg = w0[e, g]
|
|
943
|
+
B = np.zeros((3, 8))
|
|
944
|
+
for an in range(4):
|
|
945
|
+
B[0, 2 * an] = dndx[an, 0]
|
|
946
|
+
B[1, 2 * an + 1] = dndx[an, 1]
|
|
947
|
+
B[2, 2 * an] = dndx[an, 1]
|
|
948
|
+
B[2, 2 * an + 1] = dndx[an, 0]
|
|
949
|
+
for i in range(8):
|
|
950
|
+
acc = 0.0
|
|
951
|
+
for k in range(3):
|
|
952
|
+
acc += B[k, i] * N[k]
|
|
953
|
+
fe[e, i] += acc * wg
|
|
954
|
+
DB = np.zeros((3, 8))
|
|
955
|
+
for k in range(3):
|
|
956
|
+
for j in range(8):
|
|
957
|
+
acc = 0.0
|
|
958
|
+
for m in range(3):
|
|
959
|
+
acc += D[k, m] * B[m, j]
|
|
960
|
+
DB[k, j] = acc
|
|
961
|
+
for i in range(8):
|
|
962
|
+
for j in range(8):
|
|
963
|
+
acc = 0.0
|
|
964
|
+
for k in range(3):
|
|
965
|
+
acc += B[k, i] * DB[k, j]
|
|
966
|
+
Ke[e, i, j] += acc * wg
|
|
967
|
+
# geometric stiffness of the membrane forces
|
|
968
|
+
for an in range(4):
|
|
969
|
+
for bn in range(4):
|
|
970
|
+
gab = dndx[an, 0] * (N[0] * dndx[bn, 0] + N[2] * dndx[bn, 1]) + dndx[an, 1] * (
|
|
971
|
+
N[2] * dndx[bn, 0] + N[1] * dndx[bn, 1]
|
|
972
|
+
)
|
|
973
|
+
Ke[e, 2 * an, 2 * bn] += gab * wg
|
|
974
|
+
Ke[e, 2 * an + 1, 2 * bn + 1] += gab * wg
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
@njit(parallel=True, cache=True)
|
|
978
|
+
def _replay(Fh, law, aniso, w0, h0, E, nu, offset, work, plastic): # pragma: no cover
|
|
979
|
+
"""Replay of the deformation gradients ``Fh`` (steps, e, 4, 2, 2) of the Gauss points
|
|
980
|
+
with the flow laws ``law`` (e, 4, layers, 9): the stress work of each element up to
|
|
981
|
+
each step (``work``, steps x e, N mm = mJ) and the plastic strain of its points
|
|
982
|
+
(``plastic``, steps x e x 4 x layers)."""
|
|
983
|
+
ns, ne = Fh.shape[0], Fh.shape[1]
|
|
984
|
+
nl = law.shape[2]
|
|
985
|
+
hl = h0 / nl
|
|
986
|
+
for e in prange(ne):
|
|
987
|
+
so = np.empty(3)
|
|
988
|
+
Cl = np.empty((3, 3))
|
|
989
|
+
ml = np.empty(3)
|
|
990
|
+
for k in range(ns):
|
|
991
|
+
work[k, e] = 0.0
|
|
992
|
+
for g in range(4):
|
|
993
|
+
for layer in range(nl):
|
|
994
|
+
sig = np.zeros(3)
|
|
995
|
+
p, lam, j_old, w = 0.0, 1.0, 1.0, 0.0
|
|
996
|
+
lw = law[e, g, layer]
|
|
997
|
+
aw = aniso[e, g, layer]
|
|
998
|
+
vol = w0[e, g] * hl
|
|
999
|
+
plastic[0, e, g, layer] = 0.0
|
|
1000
|
+
for k in range(1, ns):
|
|
1001
|
+
F = Fh[k, e, g]
|
|
1002
|
+
c, s, e00, e11, e01, ok = _kinematics(F, Fh[k - 1, e, g])
|
|
1003
|
+
if ok:
|
|
1004
|
+
p, lam, ok = _point(
|
|
1005
|
+
F,
|
|
1006
|
+
Fh[k - 1, e, g],
|
|
1007
|
+
sig,
|
|
1008
|
+
p,
|
|
1009
|
+
lam,
|
|
1010
|
+
lw,
|
|
1011
|
+
aw,
|
|
1012
|
+
E[e, g, layer],
|
|
1013
|
+
nu,
|
|
1014
|
+
offset,
|
|
1015
|
+
so,
|
|
1016
|
+
Cl,
|
|
1017
|
+
ml,
|
|
1018
|
+
)
|
|
1019
|
+
if ok:
|
|
1020
|
+
# the new stress back in the frame of the old one, where ln dU is
|
|
1021
|
+
t00 = c * c * so[0] + 2.0 * c * s * so[2] + s * s * so[1]
|
|
1022
|
+
t11 = s * s * so[0] - 2.0 * c * s * so[2] + c * c * so[1]
|
|
1023
|
+
t01 = -c * s * (so[0] - so[1]) + (c * c - s * s) * so[2]
|
|
1024
|
+
j_new = (F[0, 0] * F[1, 1] - F[0, 1] * F[1, 0]) * lam
|
|
1025
|
+
dw = (
|
|
1026
|
+
(sig[0] + t00) * e00 + (sig[1] + t11) * e11 + 2.0 * (sig[2] + t01) * e01
|
|
1027
|
+
)
|
|
1028
|
+
w += 0.25 * dw * (j_old + j_new)
|
|
1029
|
+
j_old = j_new
|
|
1030
|
+
for i in range(3):
|
|
1031
|
+
sig[i] = so[i]
|
|
1032
|
+
work[k, e] += w * vol
|
|
1033
|
+
plastic[k, e, g, layer] = p
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
class Fracture:
|
|
1037
|
+
"""The fracture of the brittle points of a membrane (finite ``critical`` plastic
|
|
1038
|
+
strains, ``(e, 4, layers)``): ``local``, a point breaks at its critical strain; or
|
|
1039
|
+
nonlocal over a ``radius`` (mm), the plastic strain of the brittle points of each
|
|
1040
|
+
element averaged with that of its neighbours of the same critical strain (the same
|
|
1041
|
+
phase) within the radius (weights ``radius − d`` between centres times their brittle
|
|
1042
|
+
volume; Pijaudier-Cabot & Bažant 1987),
|
|
1043
|
+
against the critical strain of the element (the least of its points): the crack
|
|
1044
|
+
crosses a region of the size of a track, not a point of its edge."""
|
|
1045
|
+
|
|
1046
|
+
def __init__(self, centroids, w0, critical, radius: float | None = None):
|
|
1047
|
+
crit = np.asarray(critical, dtype=float)
|
|
1048
|
+
vol = np.broadcast_to(np.asarray(w0, dtype=float)[:, :, None], crit.shape)
|
|
1049
|
+
self.critical = crit
|
|
1050
|
+
self.finite = np.isfinite(crit)
|
|
1051
|
+
self.any = bool(self.finite.any())
|
|
1052
|
+
self.vol = np.where(self.finite, vol, 0.0)
|
|
1053
|
+
bvol = self.vol.sum(axis=(1, 2))
|
|
1054
|
+
self.share = bvol / vol.sum(axis=(1, 2))
|
|
1055
|
+
self.element_critical = np.where(self.finite, crit, np.inf).min(axis=(1, 2))
|
|
1056
|
+
self.radius = radius
|
|
1057
|
+
self.weights = None
|
|
1058
|
+
if radius and self.any:
|
|
1059
|
+
from scipy.spatial import cKDTree
|
|
1060
|
+
|
|
1061
|
+
c = np.asarray(centroids, dtype=float)
|
|
1062
|
+
pairs = cKDTree(c).query_pairs(radius, output_type="ndarray")
|
|
1063
|
+
d = np.linalg.norm(c[pairs[:, 0]] - c[pairs[:, 1]], axis=1)
|
|
1064
|
+
n = len(c)
|
|
1065
|
+
rows = np.concatenate([pairs[:, 0], pairs[:, 1], np.arange(n)])
|
|
1066
|
+
cols = np.concatenate([pairs[:, 1], pairs[:, 0], np.arange(n)])
|
|
1067
|
+
vals = np.concatenate([radius - d, radius - d, np.full(n, radius)])
|
|
1068
|
+
self.weights = sparse.csr_matrix((vals, (rows, cols)), shape=(n, n))
|
|
1069
|
+
self._bvol = bvol
|
|
1070
|
+
|
|
1071
|
+
def element_strain(self, plastic) -> np.ndarray:
|
|
1072
|
+
"""The mean plastic strain of the brittle points of each element (``(..., e, 4,
|
|
1073
|
+
layers)`` to ``(..., e)``)."""
|
|
1074
|
+
tot = self.vol.sum(axis=(1, 2))
|
|
1075
|
+
num = (np.asarray(plastic) * self.vol).sum(axis=(-2, -1))
|
|
1076
|
+
return np.where(tot > 0, num / np.where(tot > 0, tot, 1.0), 0.0)
|
|
1077
|
+
|
|
1078
|
+
def ratios(self, plastic, alive=None) -> np.ndarray:
|
|
1079
|
+
"""The ratio of the (averaged) plastic strain to the critical one of each
|
|
1080
|
+
element, ``(..., e)`` from the plastic strains ``(..., e, 4, layers)``; only the
|
|
1081
|
+
``alive`` elements (all by default) are averaged and have a ratio (the broken
|
|
1082
|
+
ones of a growing crack, :class:`Membrane`, none)."""
|
|
1083
|
+
p = np.asarray(plastic, dtype=float)
|
|
1084
|
+
if not self.any:
|
|
1085
|
+
return np.zeros(p.shape[:-2])
|
|
1086
|
+
live = np.ones(len(self.share), dtype=bool) if alive is None else np.asarray(alive)
|
|
1087
|
+
if self.weights is None:
|
|
1088
|
+
r = np.where(self.finite, p / np.where(self.finite, self.critical, 1.0), 0.0)
|
|
1089
|
+
return np.where(live, r.max(axis=(-2, -1)), 0.0)
|
|
1090
|
+
pe = self.element_strain(p)
|
|
1091
|
+
flat = pe.reshape(-1, pe.shape[-1]).T # e x steps
|
|
1092
|
+
avg = np.zeros_like(flat)
|
|
1093
|
+
for group in self._groups(): # each phase averaged with itself
|
|
1094
|
+
bv = self._bvol * (group & live)
|
|
1095
|
+
num = self.weights @ (flat * bv[:, None])
|
|
1096
|
+
den = (self.weights @ bv)[:, None]
|
|
1097
|
+
g = np.where(den > 0, num / np.where(den > 0, den, 1.0), 0.0)
|
|
1098
|
+
avg = np.where(group[:, None], g, avg)
|
|
1099
|
+
avg = avg.T.reshape(pe.shape)
|
|
1100
|
+
brittle = (self.share > 0) & live
|
|
1101
|
+
return np.where(brittle, avg / np.where(brittle, self.element_critical, 1.0), 0.0)
|
|
1102
|
+
|
|
1103
|
+
def _groups(self) -> list:
|
|
1104
|
+
"""The elements averaged together: those of one critical strain (a phase), or
|
|
1105
|
+
all the breakable ones when the critical strains vary continuously (densities)."""
|
|
1106
|
+
if getattr(self, "_cache", None) is None:
|
|
1107
|
+
crit = self.element_critical
|
|
1108
|
+
finite = np.isfinite(crit)
|
|
1109
|
+
values = np.unique(np.round(crit[finite], 12))
|
|
1110
|
+
if 1 < len(values) <= 8:
|
|
1111
|
+
self._cache = [finite & np.isclose(crit, v) for v in values]
|
|
1112
|
+
else:
|
|
1113
|
+
self._cache = [finite]
|
|
1114
|
+
return self._cache
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
# -- the problem -----------------------------------------------------------------------
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
@dataclass
|
|
1121
|
+
class TensileResult:
|
|
1122
|
+
"""A tensile test: the engineering ``strain`` (extensometer) and ``stress`` (force
|
|
1123
|
+
over the initial section of the parallel part), the ``force`` (N) and grip
|
|
1124
|
+
``displacement`` (mm) at each converged step, their measures and the final fields."""
|
|
1125
|
+
|
|
1126
|
+
strain: np.ndarray
|
|
1127
|
+
stress: np.ndarray
|
|
1128
|
+
force: np.ndarray
|
|
1129
|
+
displacement: np.ndarray
|
|
1130
|
+
yield_strength: float
|
|
1131
|
+
tensile_strength: float
|
|
1132
|
+
uniform_elongation: float
|
|
1133
|
+
energy: float
|
|
1134
|
+
necked: bool
|
|
1135
|
+
steps: int
|
|
1136
|
+
iterations: int
|
|
1137
|
+
time_s: float
|
|
1138
|
+
fields: dict = field(default_factory=dict, repr=False)
|
|
1139
|
+
failure_strain: float = math.nan
|
|
1140
|
+
history: list = field(default_factory=list, repr=False)
|
|
1141
|
+
width_strain: np.ndarray | None = field(default=None, repr=False)
|
|
1142
|
+
thickness_strain: np.ndarray | None = field(default=None, repr=False)
|
|
1143
|
+
|
|
1144
|
+
def r_value(self, strain: float | None = None) -> float:
|
|
1145
|
+
"""Lankford's coefficient of the gauge, the true width strain over the true
|
|
1146
|
+
thickness strain (their means over the extensometer) at an engineering strain
|
|
1147
|
+
(default: 10 %, or 0.8 of the uniform elongation if smaller)."""
|
|
1148
|
+
if self.width_strain is None or len(self.strain) < 3:
|
|
1149
|
+
return math.nan
|
|
1150
|
+
e = 0.1 if strain is None else float(strain)
|
|
1151
|
+
if strain is None and math.isfinite(self.uniform_elongation):
|
|
1152
|
+
e = min(e, 0.8 * self.uniform_elongation)
|
|
1153
|
+
e = min(e, float(self.strain[-1]))
|
|
1154
|
+
ew = float(np.interp(e, self.strain, self.width_strain))
|
|
1155
|
+
et = float(np.interp(e, self.strain, self.thickness_strain))
|
|
1156
|
+
return ew / et if et != 0 else math.nan
|
|
1157
|
+
|
|
1158
|
+
@property
|
|
1159
|
+
def ductility(self) -> float:
|
|
1160
|
+
"""The strain at which the specimen fails: the uniform elongation, or the strain at
|
|
1161
|
+
which a point reaches its critical plastic strain if earlier."""
|
|
1162
|
+
if math.isfinite(self.failure_strain):
|
|
1163
|
+
return min(self.uniform_elongation, self.failure_strain)
|
|
1164
|
+
return self.uniform_elongation
|
|
1165
|
+
|
|
1166
|
+
def work(self, strain: float | None = None) -> float:
|
|
1167
|
+
"""The work absorbed per unit volume of the parallel part (MJ/m³) up to an
|
|
1168
|
+
engineering strain (the last one reached by default; the failure strain if
|
|
1169
|
+
earlier): the area under the engineering curve."""
|
|
1170
|
+
e, s = self.strain, self.stress
|
|
1171
|
+
end = float(e[-1]) if strain is None else float(strain)
|
|
1172
|
+
if math.isfinite(self.failure_strain):
|
|
1173
|
+
end = min(end, self.failure_strain)
|
|
1174
|
+
end = min(end, float(e[-1]))
|
|
1175
|
+
keep = e <= end
|
|
1176
|
+
ee = np.append(e[keep], end)
|
|
1177
|
+
ss = np.append(s[keep], np.interp(end, e, s))
|
|
1178
|
+
return float(np.trapezoid(ss, ee))
|
|
1179
|
+
|
|
1180
|
+
def summary(self) -> dict:
|
|
1181
|
+
"""The measures as a mapping (MPa, engineering strain, MJ/m³)."""
|
|
1182
|
+
return {
|
|
1183
|
+
"yield_strength": self.yield_strength,
|
|
1184
|
+
"tensile_strength": self.tensile_strength,
|
|
1185
|
+
"uniform_elongation": self.uniform_elongation,
|
|
1186
|
+
"energy": self.energy,
|
|
1187
|
+
"strength_ductility": self.tensile_strength * self.uniform_elongation,
|
|
1188
|
+
"failure_strain": self.failure_strain,
|
|
1189
|
+
"ductility": self.ductility,
|
|
1190
|
+
"r_value": self.r_value(),
|
|
1191
|
+
"necked": self.necked,
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
def curve_measures(strain, stress, *, young: float | None = None, offset: float = 0.002):
|
|
1196
|
+
"""Measures of an engineering curve: the ``offset`` proof stress (the line of slope
|
|
1197
|
+
``young``, default the initial slope, shifted by the offset), the maximum (parabola
|
|
1198
|
+
through the three points around it) and its strain, and the energy absorbed up to it
|
|
1199
|
+
(MJ/m³ = MPa); ``necked``: the curve fell after its maximum."""
|
|
1200
|
+
e = np.asarray(strain, dtype=float)
|
|
1201
|
+
s = np.asarray(stress, dtype=float)
|
|
1202
|
+
if len(e) < 3:
|
|
1203
|
+
return math.nan, float(s.max(initial=0.0)), math.nan, math.nan, False
|
|
1204
|
+
k = int(np.argmax(s))
|
|
1205
|
+
uts, eu = float(s[k]), float(e[k])
|
|
1206
|
+
if 0 < k < len(s) - 1:
|
|
1207
|
+
x, y = e[k - 1 : k + 2], s[k - 1 : k + 2]
|
|
1208
|
+
c = np.polyfit(x - x[1], y, 2)
|
|
1209
|
+
if c[0] < 0:
|
|
1210
|
+
xm = -c[1] / (2 * c[0])
|
|
1211
|
+
if abs(xm) <= max(abs(x[0] - x[1]), abs(x[2] - x[1])):
|
|
1212
|
+
eu, uts = float(x[1] + xm), float(np.polyval(c, xm))
|
|
1213
|
+
if young is None:
|
|
1214
|
+
j = max(1, min(3, len(e) - 1))
|
|
1215
|
+
young = float(s[j] / e[j]) if e[j] > 0 else math.nan
|
|
1216
|
+
line = s - young * (e - offset)
|
|
1217
|
+
cross = np.flatnonzero((line[:-1] > 0) & (line[1:] <= 0))
|
|
1218
|
+
if cross.size:
|
|
1219
|
+
i = cross[0]
|
|
1220
|
+
f = line[i] / (line[i] - line[i + 1])
|
|
1221
|
+
ys = float(s[i] + f * (s[i + 1] - s[i]))
|
|
1222
|
+
else:
|
|
1223
|
+
ys = math.nan
|
|
1224
|
+
mask = e <= eu
|
|
1225
|
+
ee = np.append(e[mask], eu)
|
|
1226
|
+
ss = np.append(s[mask], uts)
|
|
1227
|
+
energy = float(np.trapezoid(ss, ee))
|
|
1228
|
+
necked = bool(k < len(s) - 1 and s[-1] < uts * (1.0 - 1e-3))
|
|
1229
|
+
return ys, uts, eu, energy, necked
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
class Membrane:
|
|
1233
|
+
"""The finite element problem of a specimen: its mesh, the flow laws of its Gauss
|
|
1234
|
+
points and layers ``(kind, σ0, a, b)``, each ``(elements, 4, layers)`` — or two laws
|
|
1235
|
+
and the weight ``w`` of the second, ``(kind1, σ01, a1, b1, kind2, σ02, a2, b2, w)``,
|
|
1236
|
+
the flow stress of a point then ``(1 − w) σ_1(p) + w σ_2(p)`` (the phases of an
|
|
1237
|
+
ideal design, the densities of a topology optimization) —, elasticity (MPa; Young's
|
|
1238
|
+
modulus one value or one per point and layer, ``(elements, 4, layers)``: phases of
|
|
1239
|
+
different stiffness), thickness (mm) and the critical plastic strains of the points
|
|
1240
|
+
(``critical``: the fracture of a brittle phase; infinite by default), local or averaged over
|
|
1241
|
+
``fracture_radius`` (:class:`Fracture`); ``springs``: linear bars ``(i, j, k, e)``
|
|
1242
|
+
between nodes (stiffness ``k`` N/mm along the unit vector ``e``: the pins of a
|
|
1243
|
+
specimen, which turn freely about them); ``anisotropy``: Hill's 1948 coefficients and
|
|
1244
|
+
the angle of the rolling direction of the points ``(..., 5)`` (:func:`hill_from_r`;
|
|
1245
|
+
:data:`ISOTROPIC` by default: von Mises), or Barlat's Yld2000-2d coefficients, its
|
|
1246
|
+
exponent and the angle ``(..., 10)`` (:func:`yld2000_from_data`)."""
|
|
1247
|
+
|
|
1248
|
+
def __init__(
|
|
1249
|
+
self,
|
|
1250
|
+
mesh: QuadMesh,
|
|
1251
|
+
flow,
|
|
1252
|
+
*,
|
|
1253
|
+
young=210000.0,
|
|
1254
|
+
poisson: float = 0.3,
|
|
1255
|
+
thickness: float = 1.0,
|
|
1256
|
+
critical=None,
|
|
1257
|
+
fracture_radius: float | None = None,
|
|
1258
|
+
springs=None,
|
|
1259
|
+
anisotropy=None,
|
|
1260
|
+
):
|
|
1261
|
+
self.mesh = mesh
|
|
1262
|
+
self.coords = np.ascontiguousarray(mesh.nodes, dtype=float)
|
|
1263
|
+
self.quads = np.ascontiguousarray(mesh.quads, dtype=np.int64)
|
|
1264
|
+
self.points, self.dndX, self.w0 = mesh.gauss()
|
|
1265
|
+
parts = [np.asarray(v, dtype=float) for v in flow]
|
|
1266
|
+
if len(parts) == 4:
|
|
1267
|
+
parts = parts + parts + [np.zeros_like(parts[0])]
|
|
1268
|
+
if len(parts) != 9:
|
|
1269
|
+
raise ValueError("flow: 4 arrays (one law) or 9 (two laws and a weight)")
|
|
1270
|
+
ne = len(self.quads)
|
|
1271
|
+
shape = parts[0].shape
|
|
1272
|
+
if len(shape) != 3 or shape[:2] != (ne, 4):
|
|
1273
|
+
raise ValueError("flow: arrays of shape (elements, 4, layers)")
|
|
1274
|
+
self.law = np.ascontiguousarray(np.stack(np.broadcast_arrays(*parts), axis=-1))
|
|
1275
|
+
self.layers = shape[2]
|
|
1276
|
+
self.critical = (
|
|
1277
|
+
np.full(shape, np.inf)
|
|
1278
|
+
if critical is None
|
|
1279
|
+
else np.broadcast_to(np.asarray(critical, dtype=float), shape).copy()
|
|
1280
|
+
)
|
|
1281
|
+
#: Young's modulus of each point and layer; ``young``: their mean over the area
|
|
1282
|
+
#: (the modulus of the sheet along stiff and soft bands, the scale of the forces)
|
|
1283
|
+
self.moduli = np.ascontiguousarray(
|
|
1284
|
+
np.broadcast_to(np.asarray(young, dtype=float), shape), dtype=float
|
|
1285
|
+
)
|
|
1286
|
+
if not np.all(self.moduli > 0):
|
|
1287
|
+
raise ValueError("young: positive moduli")
|
|
1288
|
+
self.young = float((self.moduli.mean(axis=2) * self.w0).sum() / self.w0.sum())
|
|
1289
|
+
self.poisson, self.thickness = float(poisson), float(thickness)
|
|
1290
|
+
self.fracture_radius = fracture_radius
|
|
1291
|
+
self.centroids = self.coords[self.quads].mean(axis=1)
|
|
1292
|
+
self.fracture = Fracture(self.centroids, self.w0, self.critical, fracture_radius)
|
|
1293
|
+
aniso = np.asarray(ISOTROPIC if anisotropy is None else anisotropy, dtype=float)
|
|
1294
|
+
if aniso.shape[-1] not in (5, 10):
|
|
1295
|
+
raise ValueError("anisotropy: 5 values (Hill 1948) or 10 (Yld2000-2d) a point")
|
|
1296
|
+
self.aniso = np.ascontiguousarray(np.broadcast_to(aniso, (*shape, aniso.shape[-1])))
|
|
1297
|
+
self.springs = None
|
|
1298
|
+
if springs is not None: # bars (i, j, stiffness, unit direction): pins, links
|
|
1299
|
+
i, j, k, e = (np.asarray(v) for v in springs)
|
|
1300
|
+
i, j = i.astype(np.int64), j.astype(np.int64)
|
|
1301
|
+
k = np.broadcast_to(np.asarray(k, dtype=float), i.shape).astype(float)
|
|
1302
|
+
e = np.asarray(e, dtype=float).reshape(-1, 2)
|
|
1303
|
+
blocks = k[:, None, None] * e[:, :, None] * e[:, None, :] # n x 2 x 2
|
|
1304
|
+
dofs = np.stack([2 * i, 2 * i + 1, 2 * j, 2 * j + 1], axis=1)
|
|
1305
|
+
kb = np.zeros((len(i), 4, 4))
|
|
1306
|
+
kb[:, :2, :2], kb[:, 2:, 2:] = blocks, blocks
|
|
1307
|
+
kb[:, :2, 2:], kb[:, 2:, :2] = -blocks, -blocks
|
|
1308
|
+
self.springs = (dofs, kb)
|
|
1309
|
+
dofs = np.empty((ne, 8), dtype=np.int64)
|
|
1310
|
+
dofs[:, 0::2] = 2 * self.quads
|
|
1311
|
+
dofs[:, 1::2] = 2 * self.quads + 1
|
|
1312
|
+
self.dofs = dofs
|
|
1313
|
+
self._rows = np.repeat(dofs, 8, axis=1).ravel()
|
|
1314
|
+
self._cols = np.tile(dofs, (1, 8)).ravel()
|
|
1315
|
+
self.ndof = 2 * len(self.coords)
|
|
1316
|
+
self.reset()
|
|
1317
|
+
|
|
1318
|
+
#: The stiffness left to a broken element, a share of its elastic one.
|
|
1319
|
+
residual = 1e-6
|
|
1320
|
+
|
|
1321
|
+
def reset(self) -> None:
|
|
1322
|
+
ne, nl = len(self.quads), self.layers
|
|
1323
|
+
self.alive = np.ones(ne, dtype=bool) # the elements a crack has not broken
|
|
1324
|
+
self.u = np.zeros(self.ndof)
|
|
1325
|
+
self.Fn = np.tile(np.eye(2), (ne, 4, 1, 1))
|
|
1326
|
+
self.sig_n = np.zeros((ne, 4, nl, 3))
|
|
1327
|
+
self.p_n = np.zeros((ne, 4, nl))
|
|
1328
|
+
self.lam_n = np.ones((ne, 4, nl))
|
|
1329
|
+
|
|
1330
|
+
def evaluate(self, u):
|
|
1331
|
+
"""Internal forces, tangent matrix and the trial states at displacements ``u``."""
|
|
1332
|
+
ne, nl = len(self.quads), self.layers
|
|
1333
|
+
Ke = np.empty((ne, 8, 8))
|
|
1334
|
+
fe = np.empty((ne, 8))
|
|
1335
|
+
sig = np.empty((ne, 4, nl, 3))
|
|
1336
|
+
p = np.empty((ne, 4, nl))
|
|
1337
|
+
lam = np.empty((ne, 4, nl))
|
|
1338
|
+
Fg = np.empty((ne, 4, 2, 2))
|
|
1339
|
+
bad = np.zeros(ne, dtype=np.bool_)
|
|
1340
|
+
_elements(
|
|
1341
|
+
self.coords,
|
|
1342
|
+
self.quads,
|
|
1343
|
+
self.dndX,
|
|
1344
|
+
self.w0,
|
|
1345
|
+
u,
|
|
1346
|
+
self.Fn,
|
|
1347
|
+
self.sig_n,
|
|
1348
|
+
self.p_n,
|
|
1349
|
+
self.lam_n,
|
|
1350
|
+
self.law,
|
|
1351
|
+
self.aniso,
|
|
1352
|
+
self.moduli,
|
|
1353
|
+
self.poisson,
|
|
1354
|
+
LUDWIK_OFFSET,
|
|
1355
|
+
self.thickness,
|
|
1356
|
+
Ke,
|
|
1357
|
+
fe,
|
|
1358
|
+
sig,
|
|
1359
|
+
p,
|
|
1360
|
+
lam,
|
|
1361
|
+
Fg,
|
|
1362
|
+
bad,
|
|
1363
|
+
)
|
|
1364
|
+
self.inverted = bad.copy() # the elements this displacement turns inside out
|
|
1365
|
+
dead = ~self.alive
|
|
1366
|
+
if dead.any(): # broken elements: a residual elastic stiffness, their state frozen
|
|
1367
|
+
Kd = self.residual * self.elastic_stiffness()[dead]
|
|
1368
|
+
Ke[dead] = Kd
|
|
1369
|
+
fe[dead] = np.einsum("eij,ej->ei", Kd, u[self.dofs[dead]])
|
|
1370
|
+
sig[dead] = 0.0
|
|
1371
|
+
p[dead], lam[dead], Fg[dead] = self.p_n[dead], self.lam_n[dead], self.Fn[dead]
|
|
1372
|
+
bad[dead] = False
|
|
1373
|
+
f = np.bincount(self.dofs.ravel(), weights=fe.ravel(), minlength=self.ndof)
|
|
1374
|
+
K = sparse.csr_matrix((Ke.ravel(), (self._rows, self._cols)), shape=(self.ndof, self.ndof))
|
|
1375
|
+
if self.springs is not None: # linear bars, their directions fixed
|
|
1376
|
+
dofs, kb = self.springs
|
|
1377
|
+
fs = np.einsum("nab,nb->na", kb, u[dofs])
|
|
1378
|
+
f = f + np.bincount(dofs.ravel(), weights=fs.ravel(), minlength=self.ndof)
|
|
1379
|
+
rows = np.repeat(dofs, 4, axis=1).ravel()
|
|
1380
|
+
cols = np.tile(dofs, (1, 4)).ravel()
|
|
1381
|
+
K = K + sparse.csr_matrix((kb.ravel(), (rows, cols)), shape=K.shape)
|
|
1382
|
+
return f, K, (sig, p, lam, Fg), bool(bad.any())
|
|
1383
|
+
|
|
1384
|
+
def commit(self, u, trial) -> None:
|
|
1385
|
+
sig, p, lam, Fg = trial
|
|
1386
|
+
self.u = u.copy()
|
|
1387
|
+
self.sig_n, self.p_n, self.lam_n, self.Fn = sig, p, lam, Fg
|
|
1388
|
+
|
|
1389
|
+
def elastic_stiffness(self) -> np.ndarray:
|
|
1390
|
+
"""The small-strain elastic stiffness of each element in its initial shape
|
|
1391
|
+
(``(e, 8, 8)``, plane stress over the thickness; computed once)."""
|
|
1392
|
+
if getattr(self, "_kel", None) is None:
|
|
1393
|
+
nu = self.poisson
|
|
1394
|
+
D = np.array([[1.0, nu, 0.0], [nu, 1.0, 0.0], [0.0, 0.0, 0.5 * (1.0 - nu)]]) / (
|
|
1395
|
+
1.0 - nu * nu
|
|
1396
|
+
)
|
|
1397
|
+
ne = len(self.quads)
|
|
1398
|
+
B = np.zeros((ne, 4, 3, 8))
|
|
1399
|
+
B[:, :, 0, 0::2] = self.dndX[..., 0]
|
|
1400
|
+
B[:, :, 1, 1::2] = self.dndX[..., 1]
|
|
1401
|
+
B[:, :, 2, 0::2] = self.dndX[..., 1]
|
|
1402
|
+
B[:, :, 2, 1::2] = self.dndX[..., 0]
|
|
1403
|
+
wE = self.w0 * self.moduli.mean(axis=2) # the modulus of each point
|
|
1404
|
+
self._kel = np.einsum("egai,ab,egbj,eg->eij", B, D, B, wE) * self.thickness
|
|
1405
|
+
return self._kel
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
@dataclass
|
|
1409
|
+
class Replay:
|
|
1410
|
+
"""The replay of the history of a tensile test with other flow laws: at each
|
|
1411
|
+
recorded step, the extensometer ``strain``, the grip ``displacement`` (mm), the
|
|
1412
|
+
stress ``work`` of each element (steps x elements, mJ), the ``plastic`` strains of
|
|
1413
|
+
the points (steps x elements x 4 x layers) and the ``ratio`` of each element to
|
|
1414
|
+
fracture (:class:`Fracture`)."""
|
|
1415
|
+
|
|
1416
|
+
strain: np.ndarray
|
|
1417
|
+
displacement: np.ndarray
|
|
1418
|
+
work: np.ndarray
|
|
1419
|
+
plastic: np.ndarray
|
|
1420
|
+
ratio: np.ndarray
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
def replay(membrane: Membrane, history, law=None, critical=None, anisotropy=None) -> Replay:
|
|
1424
|
+
"""Replay the deformation gradients of the Gauss points recorded by
|
|
1425
|
+
:func:`tensile_test` (``record_history``) with the flow laws ``law`` (the
|
|
1426
|
+
membrane's by default; an array ``(elements, 4, layers, 9)`` like
|
|
1427
|
+
``Membrane.law``) and the ``critical`` plastic strains (the fracture of the
|
|
1428
|
+
membrane, its radius): the work and the fracture each element would have seen had
|
|
1429
|
+
it followed the same path with another material (the kinematics held, the
|
|
1430
|
+
first-order effect of a change of material: the sensitivities of
|
|
1431
|
+
:mod:`morphogen.laser.cells`)."""
|
|
1432
|
+
if not history:
|
|
1433
|
+
raise ValueError("replay: no history (tensile_test(record_history=True))")
|
|
1434
|
+
strain = np.array([h[0] for h in history], dtype=float)
|
|
1435
|
+
disp = np.array([h[1] for h in history], dtype=float)
|
|
1436
|
+
Fh = np.ascontiguousarray(np.stack([h[2] for h in history]))
|
|
1437
|
+
law = membrane.law if law is None else np.ascontiguousarray(law, dtype=float)
|
|
1438
|
+
if law.shape != membrane.law.shape:
|
|
1439
|
+
raise ValueError(f"replay: law of shape {membrane.law.shape}")
|
|
1440
|
+
if critical is None:
|
|
1441
|
+
fracture = membrane.fracture
|
|
1442
|
+
else:
|
|
1443
|
+
crit = np.broadcast_to(np.asarray(critical, dtype=float), law.shape[:3])
|
|
1444
|
+
fracture = Fracture(membrane.centroids, membrane.w0, crit, membrane.fracture_radius)
|
|
1445
|
+
ns, ne = Fh.shape[0], Fh.shape[1]
|
|
1446
|
+
work = np.zeros((ns, ne))
|
|
1447
|
+
plastic = np.zeros((ns, *law.shape[:3]))
|
|
1448
|
+
if anisotropy is None:
|
|
1449
|
+
aniso = membrane.aniso
|
|
1450
|
+
else:
|
|
1451
|
+
aniso = np.asarray(anisotropy, dtype=float)
|
|
1452
|
+
aniso = np.ascontiguousarray(np.broadcast_to(aniso, (*law.shape[:3], aniso.shape[-1])))
|
|
1453
|
+
_replay(
|
|
1454
|
+
Fh,
|
|
1455
|
+
law,
|
|
1456
|
+
aniso,
|
|
1457
|
+
membrane.w0,
|
|
1458
|
+
membrane.thickness,
|
|
1459
|
+
membrane.moduli,
|
|
1460
|
+
membrane.poisson,
|
|
1461
|
+
LUDWIK_OFFSET,
|
|
1462
|
+
work,
|
|
1463
|
+
plastic,
|
|
1464
|
+
)
|
|
1465
|
+
return Replay(strain, disp, work, plastic, fracture.ratios(plastic))
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
def tensile_test(
|
|
1469
|
+
specimen: Specimen,
|
|
1470
|
+
membrane: Membrane,
|
|
1471
|
+
*,
|
|
1472
|
+
max_strain: float = 0.3,
|
|
1473
|
+
step: float = 0.002,
|
|
1474
|
+
max_step: float = 0.01,
|
|
1475
|
+
drop: float = 0.02,
|
|
1476
|
+
beyond: float = 0.02,
|
|
1477
|
+
tol: float = 1e-5,
|
|
1478
|
+
max_iterations: int = 20,
|
|
1479
|
+
max_steps: int = 600,
|
|
1480
|
+
callback=None,
|
|
1481
|
+
keep_fields: bool = True,
|
|
1482
|
+
failure_margin: float | None = None,
|
|
1483
|
+
record_history: bool = False,
|
|
1484
|
+
) -> TensileResult:
|
|
1485
|
+
"""Pull the specimen (see the module): steps of grip displacement of ``step`` times
|
|
1486
|
+
the parallel length at first, grown up to ``max_step`` while Newton's method
|
|
1487
|
+
converges in few iterations (shrunk when it needs many, halved when it fails), back
|
|
1488
|
+
to ``step`` after the maximum force; until the extensometer reads ``max_strain``,
|
|
1489
|
+
or the force has fallen by ``drop`` after its maximum, or the strain exceeds that of
|
|
1490
|
+
the maximum by ``beyond`` (the neck has formed: the measures are taken). A point
|
|
1491
|
+
whose plastic strain reaches its critical one (``Membrane.critical``: a brittle
|
|
1492
|
+
phase) sets the ``failure_strain`` of the specimen (interpolated between the steps);
|
|
1493
|
+
the test stops ``failure_margin`` beyond it if given; ``record_history`` keeps the
|
|
1494
|
+
deformation gradients of the Gauss points at every step (the replays of
|
|
1495
|
+
:func:`replay`)."""
|
|
1496
|
+
t0 = time.perf_counter()
|
|
1497
|
+
mesh = membrane.mesh
|
|
1498
|
+
nodes = mesh.nodes
|
|
1499
|
+
left, right = mesh.left, mesh.right
|
|
1500
|
+
fixed = [2 * left, 2 * right]
|
|
1501
|
+
if specimen.kind == "strip" and not specimen.clamped:
|
|
1502
|
+
mid = left[len(left) // 2]
|
|
1503
|
+
fixed.append(np.array([2 * mid + 1]))
|
|
1504
|
+
else:
|
|
1505
|
+
fixed += [2 * left + 1, 2 * right + 1]
|
|
1506
|
+
fixed = np.unique(np.concatenate(fixed))
|
|
1507
|
+
free = np.setdiff1d(np.arange(membrane.ndof), fixed)
|
|
1508
|
+
pull = 2 * right # the x dofs of the moving grip
|
|
1509
|
+
float(nodes[right, 0].mean() - nodes[left, 0].mean())
|
|
1510
|
+
xa, xb = specimen.extensometer_ends()
|
|
1511
|
+
gauge = xb - xa
|
|
1512
|
+
section = specimen.width * specimen.thickness
|
|
1513
|
+
|
|
1514
|
+
membrane.reset()
|
|
1515
|
+
u = membrane.u.copy()
|
|
1516
|
+
disp = 0.0
|
|
1517
|
+
record = {"strain": [0.0], "stress": [0.0], "force": [0.0], "displacement": [0.0]}
|
|
1518
|
+
inc = step * specimen.length
|
|
1519
|
+
fmax, e_peak, iterations, steps = 0.0, 0.0, 0, 0
|
|
1520
|
+
min_inc = 1e-4 * step * specimen.length
|
|
1521
|
+
f, K, _, _ = membrane.evaluate(u) # the tangent of the converged state
|
|
1522
|
+
history = [(0.0, 0.0, membrane.Fn.copy())] if record_history else []
|
|
1523
|
+
has_critical = membrane.fracture.any
|
|
1524
|
+
failure, ratio_prev = math.nan, 0.0
|
|
1525
|
+
xs_all = np.unique(np.round(nodes[:, 0], 9))
|
|
1526
|
+
sections = {}
|
|
1527
|
+
for xc in (xa, xb):
|
|
1528
|
+
j = int(np.clip(np.searchsorted(xs_all, xc) - 1, 0, len(xs_all) - 2))
|
|
1529
|
+
wgt = (xc - xs_all[j]) / (xs_all[j + 1] - xs_all[j])
|
|
1530
|
+
sections[xc] = [
|
|
1531
|
+
(np.flatnonzero(np.abs(nodes[:, 0] - xs_all[j]) < 1e-9), 1.0 - wgt),
|
|
1532
|
+
(np.flatnonzero(np.abs(nodes[:, 0] - xs_all[j + 1]) < 1e-9), wgt),
|
|
1533
|
+
]
|
|
1534
|
+
|
|
1535
|
+
def ext_disp(v):
|
|
1536
|
+
def at(xc):
|
|
1537
|
+
return sum(wv * v[2 * sel].mean() for sel, wv in sections[xc])
|
|
1538
|
+
|
|
1539
|
+
return at(xb) - at(xa)
|
|
1540
|
+
|
|
1541
|
+
# the width and the thickness of the gauge (Lankford's coefficient)
|
|
1542
|
+
top, bottom = mesh.top, mesh.bottom
|
|
1543
|
+
lateral = len(top) > 0 and len(top) == len(bottom)
|
|
1544
|
+
if lateral:
|
|
1545
|
+
inside = (nodes[top, 0] >= xa - 1e-9) & (nodes[top, 0] <= xb + 1e-9)
|
|
1546
|
+
top, bottom = top[inside], bottom[inside]
|
|
1547
|
+
lateral = len(top) > 1
|
|
1548
|
+
gp_x = membrane.points[..., 0]
|
|
1549
|
+
gw = np.where((gp_x >= xa) & (gp_x <= xb), membrane.w0, 0.0)
|
|
1550
|
+
record["width_strain"], record["thickness_strain"] = [0.0], [0.0]
|
|
1551
|
+
|
|
1552
|
+
def lateral_strains(v):
|
|
1553
|
+
if not lateral:
|
|
1554
|
+
return math.nan, math.nan
|
|
1555
|
+
w = (nodes[top, 1] + v[2 * top + 1]) - (nodes[bottom, 1] + v[2 * bottom + 1])
|
|
1556
|
+
w0 = nodes[top, 1] - nodes[bottom, 1]
|
|
1557
|
+
ew = float(np.log(np.mean(w) / np.mean(w0)))
|
|
1558
|
+
et = float((np.log(membrane.lam_n).mean(axis=2) * gw).sum() / max(gw.sum(), 1e-300))
|
|
1559
|
+
return ew, et
|
|
1560
|
+
|
|
1561
|
+
while True:
|
|
1562
|
+
target = disp + inc
|
|
1563
|
+
# tangent predictor: the grip moves, the free dofs follow the tangent
|
|
1564
|
+
trial = u.copy()
|
|
1565
|
+
dpull = np.zeros(membrane.ndof)
|
|
1566
|
+
dpull[pull] = target - disp
|
|
1567
|
+
rhs = -(f[free] + K[free][:, pull] @ dpull[pull])
|
|
1568
|
+
Kff = K[free][:, free].tocsc()
|
|
1569
|
+
try:
|
|
1570
|
+
trial[free] += splinalg.spsolve(Kff, rhs)
|
|
1571
|
+
except RuntimeError:
|
|
1572
|
+
pass
|
|
1573
|
+
trial[fixed] = 0.0
|
|
1574
|
+
trial[pull] = target
|
|
1575
|
+
converged = False
|
|
1576
|
+
state = None
|
|
1577
|
+
it = 0
|
|
1578
|
+
for it in range(max_iterations): # noqa: B007 (it counts the iterations)
|
|
1579
|
+
fi, Ki, state, bad = membrane.evaluate(trial)
|
|
1580
|
+
iterations += 1
|
|
1581
|
+
if bad or not np.all(np.isfinite(fi)):
|
|
1582
|
+
break
|
|
1583
|
+
r = fi[free]
|
|
1584
|
+
scale = max(np.linalg.norm(fi[fixed]), 1e-9 * membrane.young * section)
|
|
1585
|
+
if np.linalg.norm(r) <= tol * scale:
|
|
1586
|
+
converged = True
|
|
1587
|
+
break
|
|
1588
|
+
try:
|
|
1589
|
+
du = splinalg.spsolve(Ki[free][:, free].tocsc(), -r)
|
|
1590
|
+
except RuntimeError:
|
|
1591
|
+
break
|
|
1592
|
+
if not np.all(np.isfinite(du)):
|
|
1593
|
+
break
|
|
1594
|
+
trial[free] += du
|
|
1595
|
+
if not converged:
|
|
1596
|
+
inc *= 0.5
|
|
1597
|
+
if inc < min_inc:
|
|
1598
|
+
break
|
|
1599
|
+
continue
|
|
1600
|
+
u, f, K = trial, fi, Ki
|
|
1601
|
+
membrane.commit(u, state)
|
|
1602
|
+
disp = target
|
|
1603
|
+
steps += 1
|
|
1604
|
+
force = float(f[pull].sum())
|
|
1605
|
+
strain = ext_disp(u) / gauge
|
|
1606
|
+
if record_history:
|
|
1607
|
+
history.append((strain, disp, membrane.Fn.copy()))
|
|
1608
|
+
ratio = float(membrane.fracture.ratios(membrane.p_n).max()) if has_critical else 0.0
|
|
1609
|
+
if ratio >= 1.0 and not math.isfinite(failure):
|
|
1610
|
+
e_prev = record["strain"][-1]
|
|
1611
|
+
f_ = (1.0 - ratio_prev) / max(ratio - ratio_prev, 1e-12)
|
|
1612
|
+
failure = e_prev + min(max(f_, 0.0), 1.0) * (strain - e_prev)
|
|
1613
|
+
ratio_prev = ratio
|
|
1614
|
+
record["strain"].append(strain)
|
|
1615
|
+
ew_, et_ = lateral_strains(u)
|
|
1616
|
+
record["width_strain"].append(ew_)
|
|
1617
|
+
record["thickness_strain"].append(et_)
|
|
1618
|
+
record["stress"].append(force / section)
|
|
1619
|
+
record["force"].append(force)
|
|
1620
|
+
record["displacement"].append(disp)
|
|
1621
|
+
if callback is not None:
|
|
1622
|
+
callback(steps, strain, force / section)
|
|
1623
|
+
flat = force - record["force"][-2] < 0.004 * abs(force) # near the maximum
|
|
1624
|
+
if force > fmax:
|
|
1625
|
+
fmax, e_peak = force, strain
|
|
1626
|
+
past = force < fmax
|
|
1627
|
+
if (
|
|
1628
|
+
strain >= max_strain
|
|
1629
|
+
or (past and force < (1.0 - drop) * fmax)
|
|
1630
|
+
or (past and strain > e_peak + beyond)
|
|
1631
|
+
or steps >= max_steps
|
|
1632
|
+
or (failure_margin is not None and strain >= failure + failure_margin)
|
|
1633
|
+
):
|
|
1634
|
+
break
|
|
1635
|
+
if it <= 4:
|
|
1636
|
+
inc *= 1.5
|
|
1637
|
+
elif it >= 8:
|
|
1638
|
+
inc *= 0.7
|
|
1639
|
+
inc = min(inc, (step if past or flat else max_step) * specimen.length)
|
|
1640
|
+
inc = max(inc, min_inc)
|
|
1641
|
+
arr = {k: np.asarray(v) for k, v in record.items()}
|
|
1642
|
+
ys, uts, eu, energy, necked = curve_measures(arr["strain"], arr["stress"], young=membrane.young)
|
|
1643
|
+
fields = {}
|
|
1644
|
+
if keep_fields:
|
|
1645
|
+
fields = {
|
|
1646
|
+
"mesh": (mesh.nodes, mesh.quads),
|
|
1647
|
+
"displacement": u.reshape(-1, 2).copy(),
|
|
1648
|
+
"plastic_strain": membrane.p_n.mean(axis=2),
|
|
1649
|
+
"stress": membrane.sig_n.mean(axis=2),
|
|
1650
|
+
"thickness": membrane.lam_n.mean(axis=2) * membrane.thickness,
|
|
1651
|
+
}
|
|
1652
|
+
return TensileResult(
|
|
1653
|
+
strain=arr["strain"],
|
|
1654
|
+
stress=arr["stress"],
|
|
1655
|
+
force=arr["force"],
|
|
1656
|
+
displacement=arr["displacement"],
|
|
1657
|
+
yield_strength=ys,
|
|
1658
|
+
tensile_strength=uts,
|
|
1659
|
+
uniform_elongation=eu,
|
|
1660
|
+
energy=energy,
|
|
1661
|
+
necked=necked,
|
|
1662
|
+
steps=steps,
|
|
1663
|
+
iterations=iterations,
|
|
1664
|
+
time_s=time.perf_counter() - t0,
|
|
1665
|
+
failure_strain=failure,
|
|
1666
|
+
history=history,
|
|
1667
|
+
fields=fields,
|
|
1668
|
+
width_strain=arr["width_strain"],
|
|
1669
|
+
thickness_strain=arr["thickness_strain"],
|
|
1670
|
+
)
|