morphogen.homogenization.voxel_fe

The trilinear voxel elements of the FFT solvers assembled on the voxels of the materials, and solved by conjugate gradients preconditioned by a sparse factorization.

The FFT solvers (morphogen.homogenization.fft) discretize the periodic cell by trilinear hexahedra on the voxels and solve the equilibrium K w = f of the fluctuation without assembling K, by conjugate gradients preconditioned by the inverse of the stiffness K0 of a homogeneous reference medium (Schneider, Merkert & Kabel 2017). On a sparse phase surrounded by void near its rigidity threshold the preconditioner is a poor one: the energy of K0 spreads a displacement of the phase over the void around it, while the clusters of voxels pinned together at their corners and edges turn about them at an energy that vanishes with their rigidity, so that the iterations grow as about 45 L on planar images of L pixels (2,885 on 64²) and do not converge within 50 L + 1000 in 3-D (12³ to 16³ voxels of sites of the cubic lattice stop at relative residuals of 1e-6 to 2e-4, with moduli off by 5 to 16 %).

These problems solve the same discrete equations (the element matrices, loads, averages and fields of the FFT problems, which they extend) with the matrix assembled: the element matrices of the voxels that carry a material are summed into the sparse matrix of the degrees of freedom of their nodes (the void voxels, and the nodes that only they touch, are left out: their rows of K vanish), and K w = f is solved by conjugate gradients preconditioned by the sparse LU factorization (SuperLU, minimum-degree ordering of A^T + A, the pivots on the diagonal) of K + delta I, delta being shift (1e-12) times the mean of the diagonal. K itself is singular: the clusters that do not wrap around the periodic box float, and the floppy clusters, hinged at their corners and edges, have mechanisms (zero energy, zero strain at every Gauss point; at least 400 on a box of 24³ voxels of sites of the cubic lattice at its rigidity threshold), but the loads are orthogonal to them and the shifted factorization, which keeps the modes of K and maps its range onto itself, only preconditions: the iterates stay in the range of K, the moduli are those of K to the tolerance of the iterations, and the round-off that the factorization leaves in the mechanisms strains no voxel. The modes softer than delta take a few more iterations, the iterations restart from the true residual every CYCLE (the recursion accumulates the round-off of the mechanisms, which the preconditioner amplifies by 1 / delta), and one to three iterations suffice on the planar images and the boxes of up to 48³ voxels of the sites at their rigidity threshold. A larger shift is not safer: with 1e-10 one image of 24³ voxels in 558 stalled at a relative residual of 5e-7 after 2,200 iterations (its modulus off by 0.1 %), with 1e-8 at 2e-5, where 1e-12 takes 3 iterations to 1e-8 and 10 to 1e-10. The factorization is made once per problem, at the first solution (its time is the setup_s of the solutions), and serves all the loadings. The floppy images whose mechanisms take large displacements for a unit strain (1e3 to 7e5 on planar boxes of 96² to 256² pixels at their rigidity threshold) are not resolved by their stress averages: the round-off of the element matrices, the same in every voxel, acts on these displacements, and the stress average, linear in the error of the solution, strays to -1e-10, -1e-7 and -6e-7 where it should vanish, at any tolerance (-1.30e-7 at 1e-10 as at 5e-12, the floor of the residual, on 128² pixels); the energy, the mean of sigma : epsilon from the strains of the voxels, stationary, is an upper bound of the modulus whose error is of second order (3.6e-9 there, 1e-20 to 1e-11 for most; morphogen.analysis.percolation.rigidity_threshold() decides by it), and perturbing the element matrices at their round-off scatters it by 17 to 50 % for the floppy images, by 1.4e-3 at most for those that bear, whose stress averages agree with their energies within 30 % (3e-4 from 1e-7 up). load_bearing() keeps the voxels that bear alone, exactly: at their rigidity thresholds 79 to 82 % of the sites of the cubic lattice on 24³ to 64³ voxels (75 to 79 % of the degrees of freedom), 70 to 94 % of those of the square lattice on 32² and 48² pixels.

Its cost is that of the fill-in, which the FFT solvers do not have, and the fill grows steeply with the fraction of the voxels. On one process (the laptop on mains, otherwise idle), at the rigidity threshold of the sites of the cubic lattice (0.1307), the factorization takes 0.38 s on 32³ voxels (2.9 million entries in the factors, 0.03 GiB), 0.79 s on 40³, 1.5 s on 48³ (0.12 GiB), 2.6 s on 56³ and 4.1 s on 64³ (25 million, 0.28 GiB), the assembly 0.14 to 1.2 s and a solution with the factors 0.02 to 0.15 s; the voxels that bear alone take 0.30 s on 32³ and 3.5 s on 64³ (0.24 GiB), and finding them (load_bearing()) 0.1 s on 64³ and 0.7 s on 96³ (it took 0.5 s on 48³ and 2.5 s on 64³ while the union of its parts, a plain forest, grew chains as long as the parts). SuperLU commits its first guess of the fill, 20 times the entries of the matrix in four arrays (37 bytes per entry: 9.1 GiB on 64³ voxels at the threshold, 31 GiB on 96³), of which the factors fill 1.5 to 1.8 times the entries in 3-D and 2.1 to 2.4 in 2-D; Windows charges the untouched pages against the commit of the machine (its memory and page file), and a factorization that fails for want of memory does not free its arrays (SciPy 1.18): processes running side by side on large boxes want the commit of each factorization limited, between the guesses of 2.5 and 5 times the entries, which SuperLU meets by halving its guess (the same factors; 2.4 GiB on 64³). Above the threshold the factors fill in: on 48³ voxels 2.8 s at a fraction of 0.15, 12.8 s at 0.17 and 122 s (1.28 GiB) at 0.2096, the upper bound of the bisections of the first measurements, whose 7 s on 40³ voxels and 30 s on 48³ per solution were those of these images (the bisection of the rigidity threshold now tries its bounds last). The ordering is that of minimum degree on A^T + A, the matrix symmetric (SymmetricMode, diagonal pivots): on 24³ voxels at the threshold it fills 1.2 million entries in 0.45 s, where the column ordering COLAMD fills 3.8 million in 1.2 s, minimum degree on A^T A 1.8 million in 1.0 s and a nested dissection by planes of nodes (two per periodic axis, then the natural order) 13.7 million in 12.8 s, the planes cutting through a sparse random structure that minimum degree follows; SuperLU’s relaxed supernodes and panels (relax 3, panel_size 16) change nothing. The factors of one image do not precondition the next of a bisection, a few voxels apart (48³ voxels near the threshold, 345 to 727 voxels added or removed: 500 to 2,500 iterations without converging, 34 to 123 s, against 0.7 to 3.7 s for new factors and one iteration): the voxels added or removed change the mechanisms, which the shifted factors amplify by the inverse of the shift. Boolean discs of 4 pixels of radius at 0.61 take 4.8 s on 256² pixels and 22 s on 512² (0.47 GiB), spheres of 3 voxels of radius at 0.21 7.9 s on 48³ voxels (0.32 GiB; the machine loaded). In 2-D, at the rigidity threshold of the sites of the square lattice, the factorization and its solutions take 0.08 to 0.15 s on 64² pixels (against 2.8 to 7.8 s for 1,310 to 2,665 iterations of the FFT solver, CPU and GPU), 0.6 s on 128² (16 to 58 s for 7,000 to 7,400 iterations, most at the bound with a residual of 3e-5) and 4 s on 256², on the CPU, which the problems use. On a dense phase the FFT solvers converge in a few dozen iterations where the factors fill in (sites at 0.5: 0.14 s against 12.8 s on 16³ voxels, 0.8 s, 0.27 s on the GPU, against more than 8 min and 3.6 GB on 32³), and the voxels of the other phases at a contrast instead of void are all assembled (more than 6 min on 24³ voxels): these problems are for sparse phases surrounded by void, near their rigidity threshold.

morphogen.homogenization.voxel_fe.SHIFT = 1e-12

The shift of the diagonal of the matrix factorized for the preconditioner, over the mean of its diagonal

morphogen.homogenization.voxel_fe.CYCLE = 100

The iterations of a cycle of the conjugate gradients, which then restart from the residual of their iterate

morphogen.homogenization.voxel_fe.voxel_stiffness(shape, mat, matrices, nd: int) → tuple[csr_matrix, ndarray][source]

The matrix of the voxel elements of the periodic grid shape whose material mat (one per voxel, C order) is not void (-1), matrices[m] being the element matrix (8 nd x 8 nd, the corners in the order of morphogen.homogenization.kernels.CORNERS) of material m, summed on the degrees of freedom of their nodes alone; with these degrees of freedom, node * nd + component on the grid (increasing): the rows and columns of the matrix.

morphogen.homogenization.voxel_fe.load_bearing(mask, axis: int) → ndarray[source]

The voxels of mask (a periodic image, True where the material is, the others void) that bear a uniaxial strain, or conduct a gradient, along the axis number axis: the others carry no load in the exact solution, and the moduli and conductivities of the image along the axis are those of these voxels alone.

The trilinear voxels meet at the nodes they share. Cut at the nodes that join them alone (the articulation points of the graph of the voxels and their nodes), the voxels fall into parts, the biconnected components of that graph merged where they share a voxel, which meet one another at single nodes and form a tree: any part can translate (its temperature shift) as a whole to follow the node by which it hangs from the rest of its branch, at no energy, so that the parts bear independently. A part through which no cycle winds around the box along the axis takes the macroscopic strain (gradient) as a rigid translation of its lift, single-valued, at zero energy: it bears nothing, whether it dangles from a single corner, floats or lies between parts that bear, and is left out; those through which a cycle winds along the axis are kept. This is exact: the clusters hinged at two nodes (in 3-D an edge, a hinge), which may bear as bars between them, are kept with the part they belong to. An axis one voxel thick, whose two nodes the periodic grid folds into one, keeps every voxel.

class morphogen.homogenization.voxel_fe.VoxelFEElasticProblem(image, materials, bc: str = 'periodic', *, tol: float = 1e-08, maxiter: int | None = None, grains=None, orientations=None, shift: float = 1e-12)[source]

Bases: _AssembledProblem, FFTElasticProblem

Periodic linear elasticity of a voxel image, the discrete problem of FFTElasticProblem (trilinear voxels), assembled on the voxels of the materials and solved by conjugate gradients preconditioned by the sparse factorization of its matrix shifted by shift times its mean diagonal, on the CPU (see morphogen.homogenization.voxel_fe): the same solutions, to the tolerance tol, in a few iterations where the FFT solver needs thousands (sparse phases near their rigidity threshold, the other phases void).

class morphogen.homogenization.voxel_fe.VoxelFEThermalProblem(image, materials, bc: str = 'periodic', *, tol: float = 1e-08, maxiter: int | None = None, grains=None, orientations=None, shift: float = 1e-12)[source]

Bases: _AssembledProblem, FFTThermalProblem

Periodic steady heat conduction of a voxel image, the discrete problem of FFTThermalProblem, assembled on the voxels of the materials and solved as VoxelFEElasticProblem.