Where do we pull?
Pull my right face? It touches my own left face in the next copy.
So there is no surface to pull. What can we still change?
A periodic box has no outer surface, so there is nowhere to put a force. Here we see what we do instead, try it on a film between vacuum layers, and connect it to the Lippmann–Schwinger equation.
Pull my right face? It touches my own left face in the next copy.
So there is no surface to pull. What can we still change?
Stretch the box and all its copies together. That is Ē, the homogeneous strain.
Keep changing it until the average stress equals the target.
I sit above and below the film and substrate. Nothing can push through me, so their top and bottom are free.
Sideways, the box stays periodic. For this stack, sideways is where we pull.
A reader who knows what displacement and strain are can follow everything here. These are the other words we use, each in one exchange, with the symbol the code and the equations give it. The fold after the cards builds up the stiffness matrix. If you want one answer rather than a comparison, which solver should you use gives our verdict and walks through that solver step by step.
I am the matrix, the solid that fills most of the box. The box repeats me in every direction.
And I am the inclusion: a hole, a stiff disk or a rigid one. Only my stiffness differs.
Pull the whole box and I answer as if I were one material. That answer is my effective stiffness.
Here it is Y = Σₓₓ / ⟨eₓₓ⟩: the mean stress over the mean strain it produces.
Part of me is uniform: the mean Ē that every copy shares, the homogeneous strain.
The rest repeats with the box and averages to zero. It comes from a periodic displacement u. Together we are compatible: we fit.
I am the local strain. At each point I follow the stiffness there: σ = C(x) : e. That is the local law.
But your pieces may not fit together. Only when the solver has converged are we the same strain.
Inside me there is no body force, so the stress has zero divergence: ∂σᵢⱼ/∂xⱼ = 0. That is equilibrium.
And the mean stress ⟨σ⟩ over the box is what a load cell reads. Under stress control it is the prescribed Σ.
Keep pulling with a fixed Σ, and I choose my mean strain.
Or stretch me to a fixed Ē and read off the stress. The flag control picks one.
I work only in a uniform solid, C⁰. There each Fourier mode is one small algebra problem, which I solve exactly.
So every method here chooses a reference solid and iterates about it.
I am τ, the stress the real material carries beyond the reference solid at the same strain: τ = σ − C⁰ : e.
You are zero where the material is the reference. You live in the inclusion, and you act as a source inside the uniform solid.
Push the uniform solid at one point with a unit force. The displacement that appears at every other point is the response: that is the Green’s function. In a uniform solid it depends only on the distance between the two points.
So add that response over my whole source: a convolution, a product in Fourier space. Γ ∗ τ is minus the periodic strain I make, and e = Ē − Γ ∗ τ.
The finite contrast v is the stiffness ratio at h = 1. The diffuse interpolation matters too.
The ideal g = h cases are labeled separately. A finite stiff diffuse profile need not approach that same endpoint family.
I am h: 0 in the matrix, 1 in the inclusion, smooth across a few grid points. A Cahn–Hilliard run makes me.
And the stiffness is built from you: C = (1 − h) C⁰ for a void, S = (1 − h) S⁰ for a rigid disk.
| Parameter or condition | Value | What it means |
|---|---|---|
| \(C_{11}\) | \(320\) GPa; \(1997.282904\) eV/nm\(^3\) | Matrix stiffness |
| \(C_{12}\) | \(160\) GPa; \(998.641452\) eV/nm\(^3\) | Matrix stiffness |
| \(C_{44}\) | \(80\) GPa; \(499.320726\) eV/nm\(^3\) | Matrix stiffness |
| \(\mu,\nu,A_Z\) | \(80\) GPa; \(0.333333333\); \(1\) | The Schmidt–Gross parameters; \(A_Z=1\) is isotropic |
| Geometry | \(N_x=N_y=512\); \(\Delta x=\Delta y=1\) nm | Periodic \(512\) nm square; plane strain |
| Stored component order | \((xx,yy,xy)\) | Tensor shear \(e_{xy}\), rather than engineering shear; plane strain imposes \(e_{zz}=0\) |
| Inclusion radius | \(R_{\rm nominal}=40\) nm; \(R_{\rm area}=39.67765\) nm | Area radius from saved \(h\): \(R_{\rm area}=\sqrt{\langle h\rangle L_xL_y/\pi}\) |
| Stress control | \(\Sigma=(160,0,0)\) MPa | Prescribe mean stress; evaluate all components of \(\bar E\) |
| Strain control | \(\bar E=(0.000666666667,0,0)\) | Prescribe \(\bar E_{xx}=\Sigma_{xx}/Y_{\rm matrix}\); the mean stress is the output. The two loads are not equivalent: here the transverse strains are held at zero, so the mean stress comes out different from 160 MPa. |
| Matrix modulus | \(Y_{\rm matrix}=240\) GPa | Stress-controlled uniaxial modulus; fixed-strain matrix \(M_{11}=320\) GPa |
| Eigenstrain | \(e^*=0\) | No imposed physical eigenstrain in either loading condition |
| Finite contrasts | \(v=0.1,0.01,0.001,10,100,1000\) | Arithmetic stiffness \(C(h)=(1-h+vh)C^0\); exact void and rigid endpoints are labeled separately |
| Reporting regions | Matrix \(h\leq0.05\); inclusion \(h>0.95\) | Interface \(0.05\lt h\leq0.95\). The stopping rule keeps its own mask. |
| Iteration cap | \(20{,}000\) | A capped run is not converged; the unchanged checks are explained in the stopping-rule fold |
One cell is 1 nm, so a grid of 512 is a 512 nm square box. Stiffness, stress and energy density are stored in eV/nm\(^3\): \(1\ {\rm eV/nm^3}=160.2176634\) MPa. Stresses in the result tables are reported in MPa, moduli in GPa and strains are dimensionless.
We take an isotropic nickel-base matrix, \(\mu=80\) GPa, \(\nu=1/3\), \(A_Z=1\), in the parameters of Schmidt and Gross (1997) that our Elastic Lab uses. These are chosen model parameters, not a measured alloy- and temperature-specific dataset.
Thus \((C_{11},C_{12},C_{44})=(320,160,80)\) GPa. The chosen applied mean stress is \(\Sigma=(160,0,0)\) MPa. Fixed-strain comparisons instead prescribe \(\bar E=(\Sigma_{xx}/Y_{\rm matrix},0,0)\), which gives \((6.6666667\times10^{-4},0,0)\). That clamps transverse strain and is not the stress-equivalent heterogeneous state; its output modulus is labeled \(M_{11}^{\rm eff}\), not the stress-controlled uniaxial modulus \(Y\). No physical eigenstrain is applied in any reported material calculation.
The elastic solver works in the normalized coordinate \(x/L\). Its periodic displacement is multiplied by the box length to give it in nm. Strain and stress need no conversion, and the box length cancels in the stopping ratio. The interactive film below keeps its own teaching constants and misfit, so its numbers are not those of these tables.
Hooke's law says that stress is linear in strain, \(\sigma_{ij}=C_{ijkl}\,e_{kl}\), with the repeated indices summed. In three dimensions \(C\) has \(3^4=81\) numbers. Symmetry brings that down, and physics restricts what is left.
Two minor symmetries. The stress is symmetric, \(\sigma_{ij}=\sigma_{ji}\), so \(C_{ijkl}=C_{jikl}\). The strain is symmetric, so only the symmetric part of \(C_{ijkl}\) in \(kl\) can matter, and we take \(C_{ijkl}=C_{ijlk}\). Each pair \(ij\) and \(kl\) now takes six values, and \(C\) becomes a \(6\times6\) matrix. This is the Voigt notation: the pairs \(xx,\ yy,\ zz,\ yz,\ xz,\ xy\) become the indices 1 to 6, so \(C_{xxxx}=C_{11}\), \(C_{xxyy}=C_{12}\) and \(C_{xyxy}=C_{44}\). 36 numbers remain.
The major symmetry. An elastic solid stores energy, \(W=\tfrac12\,e_{ij}C_{ijkl}e_{kl}\), and the stress is its derivative, \(\sigma_{ij}=\partial W/\partial e_{ij}\). A second derivative does not care about the order, so \(C_{ijkl}=C_{klij}\): the \(6\times6\) matrix is symmetric, and 21 numbers remain. That is the most general crystal.
Crystal symmetry. If the crystal looks the same after a rotation, \(C\) must too. A cubic crystal keeps three numbers: \(C_{11}\) on the diagonal for the normal strains, \(C_{12}\) between different normal strains, \(C_{44}\) for the shears, and zeros elsewhere:
An isotropic solid looks the same after every rotation, which forces \(2C_{44}=C_{11}-C_{12}\), so two numbers remain: Lamé's \(\lambda=C_{12}\) and \(\mu=C_{44}\), with \(C_{11}=\lambda+2\mu\). The ratio \(A=2C_{44}/(C_{11}-C_{12})\) measures how far a cubic crystal is from isotropic; it is 1 for the matrix on this page. The sharp-interface solutions we compare with are for an isotropic plane-strain matrix, so we keep \(A=1\).
Stability. Every strain must cost energy, \(W>0\) for \(e\ne0\), so the matrix must be positive definite. For a cubic crystal this means \(C_{11}>\lvert C_{12}\rvert\), \(C_{11}+2C_{12}>0\) and \(C_{44}>0\). These are the cubic stability conditions; the two-dimensional plane-strain helper separately checks its in-plane block. The second one is the bulk modulus \((C_{11}+2C_{12})/3\) being positive.
Plane strain, which this page uses. We set \(e_{zz}=e_{yz}=e_{xz}=0\), as in a thick plate loaded in its plane. Then only the in-plane block acts:
The stress \(\sigma_{zz}\) exists, but it does nothing in the plane, so we never compute it. The block is positive definite when \(C_{11}>\lvert C_{12}\rvert\) and \(C_{44}>0\), which is what Cell checks. Its inverse, the compliance \(S=C^{-1}\), is what cell.S applies:
Pull along \(x\) with \(\sigma_{yy}=0\) and you get \(e_{yy}=-(C_{12}/C_{11})\,e_{xx}\) and \(\sigma_{xx}=\left(C_{11}-C_{12}^2/C_{11}\right)e_{xx}\). So the uniaxial modulus of the uniform solid in plane strain is \(Y=C_{11}-C_{12}^2/C_{11}\), which is \(1497.96\) eV/nm\(^3\), or \(240.0\) GPa, for the chosen matrix, and the Poisson ratio of the isotropic solid is \(\nu=\lambda/\bigl(2(\lambda+\mu)\bigr)=C_{12}/(C_{11}+C_{12})=1/3\).
The input isotropic parameter is \(\nu=1/3\). The apparent lateral ratio in a plane-strain uniaxial-stress calculation is a different quantity: \(-\bar E_{yy}/\bar E_{xx}=C_{12}/C_{11}=1/2\) for the homogeneous matrix. Under the fixed uniaxial-strain control, \(\bar E_{yy}=0\) is imposed; a reported zero lateral ratio is not an isotropic Poisson ratio of zero.
Tensor shear or engineering shear. The Voigt column uses the engineering shear \(\gamma_{xy}=2e_{xy}\), so that \(\sigma_{xy}=C_{44}\gamma_{xy}\). The code on this page stores the tensor component \(e_{xy}\) instead, so its shear line reads \(\sigma_{xy}=2C_{44}e_{xy}\), and a double contraction counts the shear twice. Our notebooks use \(\gamma_{xy}\). Mixing the two is the commonest mistake in a stiffness calculation, so we say which one every time.
The stiffnesses and the 1% film misfit are made up for learning. Each press runs one iteration of the direct method and recomputes \(\bar E\). Watch \(\sigma_{22}\): the free surfaces need it to vanish.
Careful: the target averages over the whole box, vacuum too. To load the solid, scale the target.
And we stay flat. A periodic box cannot curve, so the bending of a free bilayer is missing here.
This lab repeats the direct iteration on a stack whose fields vary only across the layers. A flat stack has an exact answer: with \(M=C_{11}-C_{12}^2/C_{11}\), \(\bar E_{11}=(\sigma^a+\langle M\epsilon^0\rangle)/\langle M\rangle\). On a 64 × 64 grid, the two-dimensional Python solver gave the values below. Its iteration counts differ a little from this lab because it stops on the change in displacement, while the lab stops on the change in strain.
| Vacuum ÷ solid | Iterations | \(\bar E_{11}\), solver | \(\bar E_{11}\), exact | Largest \(\lvert\sigma_{22}\rvert\) |
|---|---|---|---|---|
| \(10^{-2}\) | 513 | 0.0974331 | 0.0974331 | \(3\times10^{-10}\) |
| \(10^{-3}\) | 4180 | 0.0990274 | 0.0990274 | \(4\times10^{-10}\) |
The same pull stays on me. If my microstructure changes, I may change my length.
So Ē must be found again. The average stress stays fixed.
Pull me once, then fix my ends. Now Ē is frozen.
Then the average stress is free to change as the microstructure changes.
Applied stress can therefore enter a simulation through the strain: find the homogeneous strain that the stress produces, then hold it. Li and Chen (1999) grow and split \(\gamma'\) particles this way. They write the energy for both constraints. For the stress constraint, they find \(\bar E\) by minimizing the total potential energy, including the work of the load. Because they treat a small stiffness difference, \(\bar E\) comes from one approximate formula, with no iteration. The average compliance acting on the stress, \(\bar S:\sigma^{a}\), appears there too. Our direct method instead recomputes \(\bar E\) at each iteration, which also handles a large stiffness difference, including our soft vacuum.
Every solver on this page offers both constraints through one flag. control='stress', the default, prescribes the mean stress \(\Sigma\) and computes the mean strain. control='strain' prescribes the mean strain \(\bar E\) and lets the mean stress come out. The main tables prescribe \(\Sigma_{xx}=160\) MPa and zero other mean stresses; the homogeneous strain is evaluated. The separate fixed-strain fold reports every solver under \(\bar E=(\Sigma_{xx}/Y_{\rm matrix},0,0)\). The conjugate mean stress is then an output, not another prescribed target.
The film above was pulled only sideways. That was because of its shape, not because periodic boxes allow nothing else. What matters is whether the solid is connected in the direction we load.
I am a hole inside the solid. The load goes around me, and my stress stays almost zero.
I connect in every direction, so we can set the average stress in every direction. In 3D, that can be triaxial.
To reach the film, this pull must pass through me. So I carry the full stress, not zero, and I stretch without limit as I soften.
The average still reaches the target, so nothing warns us. But real vacuum cannot carry this.
We can clamp the box across the layers. I am so soft that I take up the strain.
So the clamp hardly reaches me. My top and bottom stay nearly free.
Eight runs of the direct method use a 64 nm square box of 1 nm cells, the same 80 GPa matrix, and no eigenstrain. Every case prescribes mean sigma11 = 160 MPa. The second condition is either mean sigma22 = 160 MPa or mean strain E22 = 0; mean shear stress is zero. Layers start from 26 solid rows and 38 vacuum rows; the circular hole has radius 12.9184 nm. A tanh transition has 0.01-to-0.99 width 2 nm. We report the vacuum as \(h>0.95\) and the solid as \(h\le0.05\), with the interface between them listed separately; the stopping rule keeps its own mask. Where the strains come out large they are beyond small-strain elasticity and show only the trend.
| Case | Vacuum / solid | Mean sigma22 in box (MPa) | Mean sigma22 in vacuum (MPa) | Largest |e22| in vacuum | Mean sigma22 in solid (MPa) | Iterations |
|---|---|---|---|---|---|---|
| Hole, stress target | 0.01 | 160 | 8.111 | 0.002229 | 182.4 | 338 |
| Hole, stress target | 0.001 | 160 | 1.12 | 0.003091 | 183.4 | 2549 |
| Hole, clamp | 0.01 | 69.48 | 4.53 | 0.0006299 | 78.92 | 336 |
| Hole, clamp | 0.001 | 68.8 | 0.6079 | 0.00101 | 78.72 | 2575 |
| Layers, stress target | 0.01 | 160 | 160 | 0.0496 | 160 | 644 |
| Layers, stress target | 0.001 | 160 | 160 | 0.4996 | 160 | 6531 |
| Layers, clamp | 0.01 | 4.501 | 4.501 | 0.0006092 | 4.501 | 279 |
| Layers, clamp | 0.001 | 0.4786 | 0.4786 | 0.0006761 | 0.4786 | 1553 |
In the code I am a very soft solid, so my stress is small.
Ē sets only the average. Your softness keeps your stress small, not Ē.
Grid 512, a 512 nm box, the Cahn–Hilliard inclusion of nominal radius 40 nm (39.68 nm by area), plane strain, and our isotropic matrix: \(C_{11}=1997.3\), \(C_{12}=998.6\), \(C_{44}=499.3\) eV/nm³ (\(\mu=80\) GPa, \(\nu=1/3\), \(A_Z=1\)). The prescribed stress is \(\Sigma_{xx}=160\) MPa; the homogeneous matrix has \(Y=240.0\) GPa.
| Vacuum ÷ solid | Iterations | \(\langle e_{xx}\rangle\times10^4\) | \(Y\) (GPa) |
|---|---|---|---|
| 0.1 | 45 | 6.944 | 230.40 |
| 0.01 | 321 | 7.031 | 227.58 |
| 0.001 | 1910 | 7.042 | 227.22 |
| 0, method C | 203 | 7.043 | 227.18 |
Make me softer, and the iterations keep growing.
The answer settles as you soften, but true vacuum is out of reach this way.
# <sigma> = <C>:E + <C:delta_eps> - <C:eps0> = sigma_applied, solved for E.
b11 = sa11 + t011 - (c11*de11 + c12*de22).mean()
b22 = sa22 + t022 - (c12*de11 + c11*de22).mean()
b12 = sa12 + t012 - (c44*dg12).mean()
E11 = (a11*b11 - a12*b22)/(a11**2 - a12**2)
E22 = (a11*b22 - a12*b11)/(a11**2 - a12**2)
G12 = b12/a44
The direct-iteration walkthrough derives this step. We call this approach method A. Its full code, explained line by line, is on that page, so we do not copy the solver here. Our paper, Bhattacharyya, Heo, Chang and Chen (2012), uses this soft-solid approach for cavities and cracks, and computes the effective elastic properties of polycrystals and multilayered composites. Gururajan and Abinandanan (2007) use the same iterative approach in their study of precipitate rafting under a uniaxial stress.
This is the whole of method A written with the Cell, set_load and finished of Step 1 of Method C, so we copy those first. It is the direct iteration of the walkthrough with this page's stopping rule and control flag, and the numbers for method A on this page come from it. The update of \(\bar E\) above is the line that corrects E by the error in the mean stress; here the correction is the inverse of the mean stiffness, \(\langle C\rangle=\langle f\rangle C\), and the reference is three quarters of the stiffest phase, for the reasons in the fold after the names. Two other codes do the same job with small differences. The basic scheme of CraFT iterates on the strain, \(e\leftarrow e-\Gamma*\sigma\), which Step 4 below shows is this same iteration, and under prescribed stress it sets the mean strain to \(\bar E-S^0:(\langle\sigma\rangle-\Sigma)\), our line exactly. Its automatic reference is the middle of the range of the phase stiffnesses. Our own Fortran solver, the one behind the walkthrough, takes the same midpoint reference and corrects the mean strain with the inverse of the mean stiffness \(\langle C\rangle\), which this code now does too: it solves \(\langle C\rangle:\bar E=\Sigma-\langle C:e'\rangle\) for the periodic part \(e'\) of the moment, which is exact for the mean once \(e'\) has converged. Both corrections have the same fixed point, since both vanish only when \(\langle\sigma\rangle=\Sigma\). That solver also offers a mixed control, stress along \(x\) and strain across, which CraFT has too and this page leaves out.
def solve_direct(c11, c12, c44, f, load, reference=None, max_iterations=20000, control='stress'):
"""Stiffness f(x)*C. Iterate on the displacement, about a uniform reference, reference*C: three quarters of the stiffest phase unless given.
Under stress control the mean strain is corrected each iteration with the mean stiffness <f>*C, as in our Fortran solver."""
reference = .75*f.max() if reference is None else reference
matrix = Cell(f.shape[0], c11, c12, c44)
cell = Cell(f.shape[0], reference*c11, reference*c12, reference*c44)
mean_cell = Cell(f.shape[0], f.mean()*c11, f.mean()*c12, f.mean()*c44)
Sigma, E0, _ = set_load(matrix, load, control, f)
E = E0 if Sigma is None else mean_cell.S(Sigma)
u = np.zeros((2,) + f.shape, complex)
law = np.zeros_like(E) # sigma = C:e holds by construction here
mean_old = E[:, 0, 0]
for iteration in range(1, max_iterations + 1):
e = E + cell.strain(u)
s = (f/reference)*cell.C(e)
u_old, u = u, cell.displacement(s - cell.C(e))
if Sigma is not None:
E = E + mean_cell.S(Sigma - s.mean(axis=(1, 2))[:, None, None]) # the mean stiffness moves the mean strain
if finished(cell, u, u_old, mean_old, e, s, law, (Sigma, E0)):
break
mean_old = e.mean(axis=(1, 2))
else:
not_converged('direct', iteration)
return e, s, iterationc11, c12, c44, f\(C,\ f(x)\)The matrix stiffness, and its multiple at each point.
load, control\(\Sigma\) or \(\bar E\)The mean stress or the mean strain.
reference\(C^0=\text{reference}\times C\)The uniform solid about which we iterate: 0.75 of the stiffest phase.
matrix\(C\)A Cell for the matrix: it reads the load.
set_load; initial E\(\Sigma,\ E_0,\ \bar E\)Read the load and fixed scale \(E_0\). Separately, \(E\) starts at \(\langle C\rangle^{-1}:\Sigma\) under stress control, or \(E_0\) under strain control.
cell\(C^0,\ \Gamma\)A Cell for the reference: its displacement() solves equilibrium for u below.
E\(\bar E\)The mean strain. Under stress control, moved each iteration by ⟨C⟩⁻¹:(Σ − ⟨s⟩), with mean_cell the Cell of ⟨f⟩C.
e\(e=\bar E+\text{strain of }u\)The strain.
s\(\sigma=f\,C:e\)The stress, from the local law.
e, s, iteration\(e,\ \sigma\)The strain, the stress and the iterations used.
finishedThe stopping rule, with u and u_old, mean_old, e, s and keep.
u = cell.displacement(s − cell.C(e))\(\tau=\sigma-C^0:e\)The new displacement from the polarization. This is the direct iteration.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
solve_direct | Method A as one function. It takes the matrix stiffness c11, c12, c44, the stiffness field f, the load, the reference, the cap max_iterations and the control flag, and returns the strain, the stress and the iterations used. | |
f | \(f(x)\) | The stiffness at each point divided by that of the matrix: \(1-h+vh\) for a soft phase of contrast \(v\). The vacuum is a small \(v\), never 0. |
reference | \(C^0=\text{reference}\times C\) | The uniform solid about which we iterate, as a multiple of the matrix stiffness: three quarters of the stiffest phase unless given. See the fold below for why. |
matrix, cell, mean_cell | \(C,\ C^0,\ \langle C\rangle\) | Three Cells from Step 1 of Method C: the matrix, which reads the load; the reference, which solves equilibrium; and the mean stiffness \(\langle f\rangle C\), whose compliance moves the mean strain. |
Sigma, E0, E | \(\Sigma,\ \bar E\) | From set_load. Under stress control E starts at \(\langle C\rangle^{-1}:\Sigma\) and is corrected every iteration by \(\langle C\rangle^{-1}\) times the error in the mean stress, as in our Fortran solver. Under strain control it stays at E0. |
u, u_old | \(\tilde u\) | The displacement, now and one iteration earlier. |
law | Zero: here the stress is \(f\,C:e\) by construction, so the local law never needs testing. | |
e, s | \(e,\ \sigma\) | The strain, \(\bar E\) plus the strain of u, and the stress \(f\,C:e\). |
cell.displacement(s - cell.C(e)) | \(\tau=\sigma-C^0:e\) | The new displacement from the polarization, which is the direct iteration written with Cell. |
mean_old, iteration | The previous mean strain for the rule, and the iterations used. |
The reference stiffness and the mean-strain correction are separate choices. The tables keep every reference we tried, both corrections, and every run that hit the cap. A run at the cap has not converged to our rule; the cap alone does not say whether it diverged, crawled or stalled. The last column is agreement with the separately recorded CG result on this same grid, not error against an exact continuum solution.
\(v=0.01\): returned CG \(Y=227.5689\) GPa (converged); \(v=0.001\): returned CG \(Y=227.2070\) GPa (converged); \(v=100\): returned CG \(Y=247.8432\) GPa (converged); \(v=1000\): returned CG \(Y=248.3374\) GPa (converged).
| Contrast | Reference | Reference factor | Mean correction | Iterations | Y (GPa) | Relative difference from CG |
|---|---|---|---|---|---|---|
| 0.01 | midpoint | 0.505 | S0 | 610 | 227.57 | 4.61e-06 |
| 0.01 | midpoint | 0.505 | Cavg | 242 | 227.57 | 2.51e-08 |
| 0.01 | 0.75 max | 0.75 | S0 | 352 | 227.57 | 2.89e-08 |
| 0.01 | 0.75 max | 0.75 | Cavg | 352 | 227.57 | 2.9e-08 |
| 0.01 | max | 1 | S0 | 470 | 227.57 | 2.91e-08 |
| 0.01 | max | 1 | Cavg | 470 | 227.57 | 2.91e-08 |
| 0.001 | midpoint | 0.5005 | S0 | 6085 | 227.21 | 4.73e-06 |
| 0.001 | midpoint | 0.5005 | Cavg | 1813 | 227.21 | 7.85e-08 |
| 0.001 | 0.75 max | 0.75 | S0 | 2703 | 227.21 | 8.05e-08 |
| 0.001 | 0.75 max | 0.75 | Cavg | 2703 | 227.21 | 8.05e-08 |
| 0.001 | max | 1 | S0 | 3605 | 227.21 | 8.04e-08 |
| 0.001 | max | 1 | Cavg | 3605 | 227.21 | 8.04e-08 |
| 100 | midpoint | 50.5 | S0 | 494 | 247.86 | 5.1e-05 |
| 100 | midpoint | 50.5 | Cavg | 20000, not converged | undefined | — |
| 100 | 0.75 max | 75 | S0 | 736 | 247.86 | 5.11e-05 |
| 100 | 0.75 max | 75 | Cavg | 541 | 247.84 | 8.32e-09 |
| 100 | max | 100 | S0 | 982 | 247.86 | 5.16e-05 |
| 100 | max | 100 | Cavg | 721 | 247.84 | 8.27e-09 |
| 1000 | midpoint | 500.5 | S0 | 4943 | 248.35 | 5.08e-05 |
| 1000 | midpoint | 500.5 | Cavg | 20000, not converged | undefined | — |
| 1000 | 0.75 max | 750 | S0 | 7409 | 248.35 | 5.08e-05 |
| 1000 | 0.75 max | 750 | Cavg | 5437 | 248.34 | 8.43e-09 |
| 1000 | max | 1000 | S0 | 9880 | 248.35 | 5.08e-05 |
| 1000 | max | 1000 | Cavg | 7243 | 248.34 | 8.37e-09 |
| 100 | 0.25 max | 25 | S0 | 20000, not converged | undefined | — |
| 100 | 0.25 max | 25 | Cavg | 20000, not converged | undefined | — |
| 100 | 0.375 max | 37.5 | S0 | 20000, not converged | undefined | — |
| 100 | 0.375 max | 37.5 | Cavg | 20000, not converged | undefined | — |
| 100 | 0.5 max | 50 | S0 | 20000, not converged | 247.84 | 1.45e-10 |
| 100 | 0.5 max | 50 | Cavg | 20000, not converged | undefined | — |
| 1000 | 0.25 max | 250 | S0 | 20000, not converged | undefined | — |
| 1000 | 0.25 max | 250 | Cavg | 20000, not converged | undefined | — |
| 1000 | 0.375 max | 375 | S0 | 20000, not converged | undefined | — |
| 1000 | 0.375 max | 375 | Cavg | 20000, not converged | undefined | — |
| 1000 | 0.5 max | 500 | S0 | 20000, not converged | 248.34 | 4.06e-10 |
| 1000 | 0.5 max | 500 | Cavg | 20000, not converged | undefined | — |
| 0.01 | <f> | 0.98132 | S0 | 462 | 227.57 | 2.88e-08 |
| 0.01 | <f> | 0.98132 | Cavg | 462 | 227.57 | 2.88e-08 |
| 0.001 | <f> | 0.98115 | S0 | 3537 | 227.21 | 8.04e-08 |
| 0.001 | <f> | 0.98115 | Cavg | 3537 | 227.21 | 8.04e-08 |
| 100 | <f> | 2.8678 | S0 | 20000, not converged | undefined | — |
| 100 | <f> | 2.8678 | Cavg | 20000, not converged | undefined | — |
| 1000 | <f> | 19.848 | S0 | 20000, not converged | undefined | — |
| 1000 | <f> | 19.848 | Cavg | 20000, not converged | undefined | — |
The direct method of the page keeps its reference of three quarters of the stiffest phase and its inverse mean-stiffness correction. The table shows how sensitive it is to those two choices; the solver itself is unchanged, and a capped trial is not called divergent.
The same iteration can be extended to new problems. Each of these papers changes something:
| Paper | What it adds |
|---|---|
| Hu and Chen (2001) | Phase-field model with strong elastic inhomogeneity; the iteration our later papers build on |
| Bhattacharyya, Heo, Chang and Chen (2011) | Stiffness that depends on grain orientation, with an applied stress driving grain boundary migration |
| Heo, Bhattacharyya and Chen (2011) | Diffusional transformations in elastically inhomogeneous polycrystals |
| Bhattacharyya, Heo, Chang and Chen (2012) | Cavities and cracks, and effective properties of polycrystals and multilayered composites |
| Sheng, Bhattacharyya and others (2012) | Effective moduli of polycrystalline magnesium, from first-principles constants and a phase-field grain structure |
| Wang, Bhattacharyya and others (2012) | Combines Eshelby’s equivalent inclusion, Khachaturyan’s microelasticity and the Hu–Chen iteration |
| Heo, Bhattacharyya and Chen (2013) | Elastically anisotropic polycrystalline binary solid solutions, with precipitates and segregation near grain boundaries |
We write everything with indices. Repeated indices are summed, and a comma means a derivative.
Choose a uniform reference stiffness \(C^0_{ijkl}\), and write \(C_{ijkl}(\mathbf x)=C^0_{ijkl}+\Delta C_{ijkl}(\mathbf x)\). The total strain is the average plus the periodic part:
With no imposed eigenstrain, the stiffness inhomogeneity is represented by one field, the polarization \(\tau_{ij}\).
Because \(\bar E\) and \(C^0\) are uniform, \(\sigma_{ij,j}=0\) becomes \(C^0_{ijkl}u_{k,lj}+\tau_{ij,j}=0\). With \(\partial_j\to\mathrm i k_j\):
Put \(\tilde u_k\) into \(\tilde\epsilon_{kl}=\tfrac{\mathrm i}{2}\left(k_l\tilde u_k+k_k\tilde u_l\right)\) for \(\mathbf k\neq0\). The two factors of \(\mathrm i\) give a minus sign:
Adding back the average at \(\mathbf k=0\) gives the Lippmann–Schwinger equation:
Our direct method takes the current strain, forms \(\tau_{ij}\), solves Step 2 for the new displacement, and differentiates it. That is Steps 2 and 3 exactly: \(\epsilon^{n+1}_{kl}=\bar E_{kl}-\Gamma_{klij}*\tau^{n}_{ij}\). In our code ts is \(-\tau\), apart from the uniform term \(C^0:\bar E\), which has no gradient and so no effect. So u_new = -1j*Omega*(k.ts) is the same line.
The basic scheme of Moulinec and Suquet (1998) writes \(\epsilon^{n+1}_{kl}=\epsilon^{n}_{kl}-\Gamma_{klij}*\sigma^{n}_{ij}\). To compare them, we use \(\sigma_{ij}=C^0_{ijmn}\epsilon_{mn}+\tau_{ij}\). The term with \(C^0\) needs one identity. For a compatible strain, \(\tilde\epsilon_{mn}=\tfrac{\mathrm i}{2}\left(k_n\tilde u_m+k_m\tilde u_n\right)\) and the symmetry of \(C^0\) give
because \(\Omega_{ki}Q_{im}=\delta_{km}\). So \(\Gamma*(C^0:\epsilon)=\epsilon-\bar E\), and therefore
The right side is our direct update. One iteration, written two ways, with \(C^0\) as the mean of the phases in both.
def gamma0(s11, s22, s12):
S11, S22, S12 = fft2(s11), fft2(s22), fft2(s12)
f1 = kx*S11 + ky*S12 # k_j s_1j
f2 = kx*S12 + ky*S22 # k_j s_2j
u1 = o11*f1 + o12*f2 # Omega_1i k_j s_ij
u2 = o12*f1 + o22*f2
u1[skip] = u2[skip] = 0 # k = 0 and the Nyquist modes
return ifft2(kx*u1).real, ifft2(ky*u2).real, ifft2(ky*u1 + kx*u2).real
# One iteration: the strain minus Gamma0 applied to the current stress.
g11, g22, g12 = gamma0(s11, s22, s12)
e11, e22, gam = e11 - g11, e22 - g22, gam - g12
Our direct method solves for the displacement. This form updates the strain. Are they different?
No. Steps 3 and 4 show it, and the numbers agree at every iteration. One catch: a mode called Nyquist.
Our wavenumbers follow the usual rule: \(k_i=i\,\Delta k\) for \(i\le N/2\), otherwise \((i-N)\,\Delta k\). The problem is only at \(i=N/2\). Its wave \((-1)^n\) has no partner \(-k\) on the grid, so \(k\) there cannot be odd, as a real field requires. The identity in Step 4 needs that oddness. As Johnson’s notes on FFT-based differentiation explain, a first derivative should set the Nyquist term to zero, while a second derivative keeps it, so a second derivative is not two first derivatives there. FFTW itself leaves this choice to us.
The strain and the divergence of the stress use sampled first derivatives with the Nyquist multiplier set to zero; the Cahn–Hilliard step uses a direct Laplacian that keeps its Nyquist term. We do not use Johnson's composite variable-coefficient scheme (his Algorithms 6 and 7) or a nine-channel lifted energy. Our unit-invariance check tests this discretization against itself at two stiffness scales, not against a field from another one.
This illustration comes from the earlier teaching calculation in normalized units and was not redrawn. It has not been rerun for the current physical matrix. Its energy entries are in that earlier normalized convention, not newly measured eV/nm³ values. The table illustrates sensitivity to discretization; none of its numbers supplies the current material tables, profiles or convergence claims.
| Test | Nyquist kept | Nyquist left out |
|---|---|---|
| Largest \(\lvert\Gamma*(C^0:\epsilon)-\epsilon\rvert\), random compatible strain of size about 1.5, 64 × 64 | \(0.12\) | \(9\times10^{-16}\) |
| Largest strain difference, direct form against \(\Gamma\) form, 40 iterations; strain about \(4\times10^{-3}\) | \(10^{-5}\) (30 iterations) | \(4\times10^{-18}\) |
| Energy of the default plate, 64 × 64 | \(2.227514\times10^{-6}\) | \(2.227535\times10^{-6}\) |
So on a smooth problem the choice changes the energy by about \(10^{-5}\) of its value and the largest \(\sigma_{11}\) difference is about 0.2% of its peak. It matters when we compare two codes to high accuracy, and in the method below.
What is it? A way to solve a problem with a constraint. Here the constraint is that two strains must agree: \(e\), which fits together across the box, and \(d\), which obeys the local stress law. We add a Lagrange multiplier \(\lambda\) and a penalty on any mismatch between them; the word “augmented” refers to that penalty. Because the local law is now solved separately at each point, zero stiffness causes no trouble.
How can we use it? When the contrast is truly infinite: a void, where \(C=0\), or a rigid inclusion, where \(C\to\infty\). Method A can only imitate these with a large finite contrast: a very soft phase for a void, a very stiff one for a rigid inclusion. We do not know in advance how large is large enough, so we repeat with ever larger contrast until the answer stops changing. With method B we set the limit itself. We give the stiffness fields, a reference stiffness and either a target stress or an average strain. We get back the stress field, the strain field and the average strain, which gives the effective stiffness. The reference stiffness is our choice, and it largely decides how fast the iteration settles.
I am e. I fit together across the box, but I ignore the local law.
I am d. I obey the local law, even where the stiffness is zero, but I may not fit together.
Let us join with a band. That is the penalty. But a band pulls only while it is stretched.
So some gap must stay. A stiffer band makes the gap smaller, never zero.
I am λ, a force at each point. I can pull with no stretch at all. Then d must solve C d = λ.
In vacuum C = 0, so that is 0 · d = λ. I cannot be found from it.
The band adds its own stiffness to my C. Now I have an answer even when C = 0.
Each round I add the band’s pull to my memory. When the gap closes the band goes slack, and I hold the pull. Then I am the stress.
In a void C = 0. I simply take whatever the band and λ give me, so I am free.
Then the two pulls cancel, and I come out exactly 0. No stress, at every round.
A rigid inclusion cannot strain. So we simply set me to 0, at every round.
Then I am free. I grow until e comes to 0 too, and I keep the stress that holds it there.
Here \(e\) and \(d\) are single numbers. Something holds \(e\) toward 1, and \(d\) has stiffness \(C\). The band stiffness plays the part of \(C^0\).
With band stiffness \(r\), the toy uses the same terms as the formal definition below:
With \(\lambda\) on, the solution is \(e=d=1/(1+C)\) and \(\lambda=C\,d\), whatever \(r\) is. For a rigid \(d\) we set \(d=0\), and then \(e=0\) and \(\lambda=1\). With the band alone and \(C>0\), the gap settles at \(1/\bigl(1+r(1+1/C)\bigr)\), which is \(1/3\) for \(C=r=1\).
This is the idea of the augmented Lagrangian method of Michel, Moulinec and Suquet (2001), also in their 2000 paper, designed for high or infinite contrast such as voids. We write it in our notation, with the tensor form first and the indicial form below it. In the indicial form, repeated indices are summed. The colon is a double contraction, and \(*\) is a convolution in real space. On a periodic box, \((f*g)(x)=\langle f(x')\,g(x-x')\rangle_{x'}\), an average over every point \(x'\) of the box, so the value at \(x\) depends on the whole of \(f\). In Fourier space it becomes a simple product, \(\widehat{f*g}=\hat f\,\hat g\). The tensor form does not depend on our choice of axes, though a square grid does. Elastic equilibrium is the minimum of the energy over strains that fit together with the chosen average, \(\bar E\):
One field has to do two jobs here: fit together, and meet \(C\) at each point. So we give each job its own field and demand that they agree:
There is one constraint for each component at each point, so we add one multiplier field \(\lambda_{ij}(x)\). This gives the Lagrangian:
The solution is a saddle point: a minimum in \(e\) and \(d\), and a maximum in \(\lambda\). Varying \(\lambda\) returns \(e=d\). Varying \(d\) gives \(C_{ijkl}d_{kl}=\lambda_{ij}\), so the multiplier is the stress. But where \(C=0\), this no longer fixes \(d\), and for \(\lambda\neq0\) the energy has no minimum in \(d\). So we augment \(L_0\) with the band:
with \(C^0\) a reference stiffness. The new term vanishes when \(e=d\), so the solution does not change. It only gives the \(d\) problem the stiffness \(C+C^0\). Now we take turns, holding the other fields fixed.
Minimize \(L\) over \(e\). This gives \(\partial_j\bigl[\lambda_{ij}+C^0_{ijkl}(e_{kl}-d_{kl})\bigr]=0\), an equilibrium problem in the uniform reference solid, which the FFT solves:
Minimize \(L\) over \(d\). No derivative of \(d\) appears, so this is a small local problem at each point:
Raise \(L\) in \(\lambda\). The gradient of \(L\) in \(\lambda\) is \(e-d\). We step along it, with \(C^0\) as the step size. That adds the band’s pull to \(\lambda\):
Where we impose the void and the rigid inclusion. Both live in the local step, and they mirror each other.
Everywhere else, the update gives \(\lambda^{n+1}_{ij}=C_{ijkl}d^{n+1}_{kl}\). When \(e=d\), the first line gives \(\Gamma*\lambda=0\), which is equilibrium.
A prescribed stress. With \(\Sigma\) given, the mean of \(e\) is not. We add the work of the load, \(-\boldsymbol{\Sigma}:\langle\boldsymbol{e}\rangle\), to \(L\), and minimize over the uniform part of \(e\) as well. That gives one more line in the Fourier step:
When the gap closes, \(\langle\lambda\rangle=\Sigma\): the multiplier is the stress, and its mean is the load. Under strain control this line is replaced by \(\langle e\rangle=\bar E\).
Using this code. Copy these snippets for learning, teaching and demonstration. For any other use, please email me with what you need it for.
This function uses Cell, set_load, material_region and finished from Step 1 of Method C, so we copy those first. The three commented lines are the three turns of the formal definition above: the Fourier step for \(e\), the local step for \(d\), and the update of \(\lambda\). The line before them sets the mean of \(e\): the computed mean under stress control, \(\bar E\) under strain control. The formal definition calls the band stiffness \(C^0\). The code writes it as \(\beta\,C^0\), so we can change the band with beta and keep the same cell.
Connection with the published method. Michel, Moulinec and Suquet (2000), A Computational Method Based on Augmented Lagrangians and Fast Fourier Transforms for Composites with High Contrast, uses a three-stage compatible solve, local material solve and multiplier update. The code below implements that algebraic split with a band \(\beta C^0\). Its stress-control mean correction, cubic plane-strain reference implementation and unchanged five-part stopping rule are stated explicitly here; numerical criteria and discretization details should not be assumed identical to a paper or another code. CraFT 1.2.3b selects its AL specialization with relaxation parameters \(\alpha=\beta=1\), while the reference stiffness is set separately. Those relaxation parameters are not this code's band factor. Its zero automatic reference fallback uses the stiffest phase.
The cartoons of the two limits speak of points where the local coefficient is exactly zero. The region we report as \(h>0.95\) does not have exactly zero stiffness or compliance at every point; the smooth core keeps very small positive values.
How stiff should the band be? The band changes the iteration, not the target material. These are the bands we tried; the best of them is the best of this sweep, not a universal optimum.
| Main stress-table limit | Recorded band factor | Iterations |
|---|---|---|
| rigid AL | 2.0 | 378 |
| void AL | 0.1 | 902 |
At finite contrast we take \(\beta=\sqrt v\). The stiff diffuse phase interpolates the stiffness, \(C=(1-h+vh)C_{\rm matrix}\), not the compliance as in our older runs. The ideal rigid endpoint remains a separate compliance model. In CraFT 1.2.3b, a zero automatic reference falls back to the stiffest phase; its relaxation parameters are distinct from this band factor. The sweeps under stress control and under strain control are reported separately.
| Case | \(\beta=0.05\) | \(\beta=0.1\) | \(\beta=0.2\) | \(\beta=0.5\) | \(\beta=1\) | \(\beta=2\) | \(\beta=5\) | \(\beta=10\) |
|---|---|---|---|---|---|---|---|---|
| contrast 0.01, stress | 137 | 72 | 94 | 238 | 474 | 946 | 2361 | 4718 |
| contrast 100, stress | 5564 | 2783 | 1393 | 558 | 280 | 140 | 76 | 80 |
| rigid, stress | 20000, not converged | 12302 | 6152 | 2462 | 1232 | 853 | 2493 | 4174 |
| void, stress | 4216 | 3835 | 7681 | 19210 | 20000, not converged | not run | not run | not run |
Measured on grid 256: the same 512 nm inclusion sampled at every second point, so the cells are 2 nm, the area-equivalent radius is 19.84 cells (39.7 nm) and the interface is one cell wide. Every method needs more steps here than on grid 512; the counts rank the bands and are not to be compared with the 512 table. A band not listed was not run.
| Case | \(\beta=0.05\) | \(\beta=0.1\) | \(\beta=0.2\) | \(\beta=0.5\) | \(\beta=1\) | \(\beta=2\) | \(\beta=5\) | \(\beta=10\) |
|---|---|---|---|---|---|---|---|---|
| contrast 0.01, strain | 206 | 106 | 99 | 237 | 471 | 937 | 2339 | 4674 |
| contrast 100, strain | 5503 | 2753 | 1377 | 552 | 276 | 138 | 71 | 77 |
| rigid, strain | 20000, not converged | 13026 | 6514 | 2607 | 1304 | 653 | 1386 | 2727 |
| void, strain | 4598 | 3613 | 7223 | 18056 | 20000, not converged | not run | not run | not run |
Measured on grid 256: the same 512 nm inclusion sampled at every second point, so the cells are 2 nm, the area-equivalent radius is 19.84 cells (39.7 nm) and the interface is one cell wide. Every method needs more steps here than on grid 512; the counts rank the bands and are not to be compared with the 512 table. A band not listed was not run.
When do we stop? Every solver on this page, including the ones in Method C below, stops by one rule, in finished. After each iteration we ask five questions, and we stop only when all say yes. Has the displacement stopped moving? We take the rms change of \(u\) between two iterations, divided by \(\lVert E_{\rm ref}\rVert_F L/(2\pi)\), the displacement scale set by the fixed reference load strain over one wavelength of the box, and ask for less than \(10^{-5}\). Under stress control, has the mean strain stopped moving, by \(10^{-5}\) relative to the fixed reference strain norm \(\lvert S^0:\Sigma\rvert\), and is the mean stress within \(10^{-4}\) of \(\Sigma\)? Is the stress in equilibrium, with a scaled divergence below \(10^{-4}\)? Does the local law hold at every point, using the original componentwise normalized threshold \(10^{-4}\)? In the exact void and rigid limits the region-dependent tests use the declared matrix-plus-interface mask \(g\le0.99\); finite contrast keeps the full cell. The reporting regions \(h>0.95\), \(h\le0.05\) and the interface between them are only for the tables; they do not enter this rule. Exact nonuniqueness concerns truly zero weights; small positive core weights can instead produce ill conditioning. Each solver gives up after 20000 iterations. A run that reaches that cap is not converged, and we say so in every table. The rule is not free: the displacement test needs two inverse transforms and the equilibrium test five more, against the six of a Fourier step, so finished asks the three cheap questions first, pointwise and on means, and transforms only when they all say yes.
The input strain and stress columns here store tensor shear. Write \(\lVert v\rVert_F=\sqrt{v_{xx}^2+v_{yy}^2+2v_{xy}^2}\). The fixed reference strain is \(E_{\rm ref}=S_{\rm matrix}:\Sigma\) under stress control, or the prescribed \(\bar E\) under strain control. Set \(a=\lVert E_{\rm ref}\rVert_F\) and \(b=\max_{ij}|(E_{\rm ref})_{ij}|\). These two normalization choices are different.
The law check takes the largest absolute component on the selected region. For the void stiffness law it tests \(\max_{ {\cal R},ij}|[s-(1-g)C^0:e]_{ij}|/(C^0_{11}b)\lt 10^{-4}\). For the rigid compliance law it tests \(\max_{ {\cal R},ij}|[e-(1-g)S^0:s]_{ij}|/b\lt 10^{-4}\). This is a componentwise maximum, not a Frobenius RMS. The direct method satisfies its local law by construction.
Unlike the other load-based denominators, the divergence denominator uses the current regional stress RMS, not the prescribed stress. RMS of a two-component displacement or divergence sums the component squares before averaging over selected pixels. Means in the macroscopic tests are global cell means. Finite-contrast tests use the full cell; exact endpoints use \({\cal R}=\{g\le0.99\}\) for the region-dependent checks. Under strain control the stress-target test is disabled and the prescribed homogeneous strain is enforced by construction. A tiny constant guards every denominator against zero. Nothing in the solvers or in this rule changed with the units.
The trace runs our five-part rule alongside the pointwise split and local-law tests of equation (29) of Michel, Moulinec and Suquet (2000). The trace uses our geometry, load and band, not the paper's. The modulus differences are measured against the last state of that trace, not against an exact modulus. A criterion the trace never meets is shown as such. The split-gap and local-law tests alone do not cover equilibrium or the macroscopic conditions.
| Case | Common rule: iteration | Relative modulus change | Split/law 1e-4: iteration | Relative modulus change | Split/law 1e-5: iteration | Relative modulus change | Gap at common stop | Law at common stop |
|---|---|---|---|---|---|---|---|---|
| void | 3835 | 9.13e-06 | 3339 | 1.1e-05 | not reached | — | 7.86e-05 | 8.26e-05 |
| rigid | 853 | 1.14e-06 | 765 | 1.32e-06 | not reached | — | 8.8e-05 | 8.8e-05 |
| contrast 0.01 | 72 | 3.13e-08 | 77 | 1.68e-08 | 100 | 9.08e-10 | 0.000143 | 0.000154 |
| contrast 100 | 80 | 3.88e-08 | 46 | 1.62e-06 | 64 | 2.16e-07 | 2.1e-06 | 2.1e-06 |
def solve_augmented_lagrangian(cell, g, kind, load, beta=1.0, max_iterations=20000, control='stress'):
"""Method B: a compatible strain e, a strain d obeying the local law, a multiplier lam. The band stiffness is beta*C0."""
Sigma, E, _ = set_load(cell, load, control, g)
keep = material_region(g)
d, lam = E.copy(), np.zeros_like(E) if Sigma is None else Sigma.copy()
u = np.zeros((2,) + g.shape, complex)
weight = 1/(1 - g + beta) if kind == 'void' else (1 - g)/((1 - g)*beta + 1)
mean_old = E[:, 0, 0]
for iteration in range(1, max_iterations + 1):
tau = lam/beta - cell.C(d)
u_old, u = u, cell.displacement(tau)
mean = E if Sigma is None else (d.mean(axis=(1, 2)) + cell.S((Sigma - lam).mean(axis=(1, 2)))/beta)[:, None, None]
e = mean + cell.strain(u) # step 1: Fourier, compatible strain
d = weight*(beta*e + cell.S(lam)) # step 2: local, point by point
lam = lam + beta*cell.C(e - d) # step 3: the multiplier remembers the pull
law = (lam - (1 - g)*cell.C(e))/cell.c11 if kind == 'void' else e - (1 - g)*cell.S(lam)
if finished(cell, u, u_old, mean_old, e, lam, law/scale_of(E), (Sigma, E), keep):
break
mean_old = e.mean(axis=(1, 2))
else:
not_converged(f'augmented Lagrangian ({kind})', iteration)
return e, lam, iteration
cell, g, kind\(C^0,\ g(x)\)The reference Cell, where the inclusion is, and its kind.
load, control\(\Sigma\) or \(\bar E\)The load and the flag, read by set_load. They set the mean strain of each round.
beta\(\beta\)The band stiffness, as a multiple of C⁰: the paper's c₀ = rE. The table above says how to choose it.
weight\(\frac{1}{1-g+\beta}\) or \(\frac{1-g}{(1-g)\beta+1}\)The factor from solving the local step at each point.
d, law\(d\)The strain that obeys the local law, from e and λ, and the error in that law.
lam\(\lambda\)The multiplier: it moves by β(e − d) each round, and ends as the stress.
tau = lam/beta − cell.C(d)\(\lambda/\beta-C^0:d\)What the Fourier step sees as its source.
u, u_old\(\tilde u\)The displacement, now and one round earlier.
mean, e\(\langle e\rangle,\ e\)The mean strain of this round, and the compatible strain: mean plus the strain of u.
not_convergedThe warning at the cap of 20000.
finishedThe stopping rule over keep.
e, lam, iteration\(e,\ \sigma\)The compatible strain, the multiplier as the stress, and the rounds used.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
solve_augmented_lagrangian | The solver. It returns the compatible strain, the multiplier as the stress, and the iterations used. | |
cell | \(C^0\) | A Cell from Step 1 of Method C. It holds the reference stiffness and the wavevectors. |
g | \(g(x)\) | Says where the inclusion is. For a true void or rigid phase, \(g=h\). For a finite contrast \(v\), \(g=(1-v)h\) for a soft phase; for the finite stiff arithmetic-stiffness profile first form \(f=1-h+vh\), then use \(g=1-1/f\). |
kind | 'void', where \(C=(1-g)C^0\), or 'rigid', where \(S=(1-g)S^0\). | |
load, control | \(\Sigma\) or \(\bar E\) | The mean stress, with control='stress' (the default), or the mean strain, with control='strain', as (xx, yy, xy). |
Sigma, E | \(\Sigma,\ \bar E\) | From set_load: the mean stress as three uniform fields, or None; and the mean strain, or its starting value \(S^0:\Sigma\), which also sets the scale of the tests. |
keep | The region from material_region where the tests are judged. | |
beta | \(\beta\) | Band stiffness as a multiple of \(C^0\): the paper's \(c_0=rE\). The table above says how to choose it. |
max_iterations | The cap, 20000. A loop that reaches it leaves with a warning from not_converged, and that result is not converged. | |
d | \(d\) | The strain that obeys the local law. It starts at \(\bar E\). |
lam | \(\lambda\) | The multiplier. It starts at \(\Sigma\) under stress control and at 0 under strain control, and at the end it is the stress. |
u, u_old | \(\tilde u\) | The Fourier coefficients of the displacement, now and one round earlier. |
weight | The factor from solving the local step at each point: \(1/(1-g+\beta)\) for a void, \((1-g)/((1-g)\beta+1)\) for a rigid phase. Where \(g=1\) in a rigid phase it is 0, so \(d=0\). | |
tau | \(\lambda/\beta-C^0:d\), what the Fourier step sees as its source. | |
mean_old, iteration | The mean strain of the previous round, for the rule, and the rounds used. | |
mean | \(\langle e\rangle\) | The mean strain of this round: computed from \(d\), \(\lambda\) and \(\Sigma\) under stress control, \(\bar E\) under strain control. |
e | \(e\) | The compatible strain: mean plus the strain of u. |
cell.S | \(S^0\) | The inverse of \(C^0\) applied to a field. |
law | The error in the local law at each point, which finished tests after scaling by the size of the load. | |
finished | The stopping rule above: true when all five tests pass over keep. |
This is our own short implementation of the idea, not the authors’ code. CraFT, from LMA Marseille, is free FFT software from this group, for computing the response of heterogeneous materials.
Grid 512, a 512 nm box, the Cahn–Hilliard inclusion of nominal radius 40 nm (39.68 nm by area), plane strain, and our isotropic matrix: \(C_{11}=1997.3\), \(C_{12}=998.6\), \(C_{44}=499.3\) eV/nm³ (\(\mu=80\) GPa, \(\nu=1/3\), \(A_Z=1\)). The prescribed stress is \(\Sigma_{xx}=160\) MPa; the homogeneous matrix has \(Y=240.0\) GPa. Every run uses the unchanged stopping rule. Method A uses a reference of three quarters of the stiffest phase and the inverse mean-stiffness correction. Method B uses \(\beta=\sqrt v\) at finite contrast. Where the two methods return slightly different states, both are shown; a result at the cap is not converged.
| Contrast | A: \(\langle e_{xx}\rangle\times10^4\) | A: Y (GPa) | A: iterations | B: \(\langle e_{xx}\rangle\times10^4\) | B: Y (GPa) | B: iterations |
|---|---|---|---|---|---|---|
| 0.1 | 6.944 | 230.40 | 45 | 6.944 | 230.40 | 26 |
| 0.01 | 7.031 | 227.58 | 321 | 7.031 | 227.58 | 73 |
| 0.001 | 7.042 | 227.22 | 1910 | 7.042 | 227.22 | 220 |
| 10 | 6.493 | 246.42 | 54 | 6.493 | 246.42 | 28 |
| 100 | 6.456 | 247.84 | 567 | 6.456 | 247.84 | 81 |
| 1000 | 6.443 | 248.33 | 5693 | 6.443 | 248.33 | 246 |
At the same finite contrast, methods A and B aim at the same answer. Method A reaches a limit only through ever larger contrasts, while method B can set the limit directly. In method B the reference stiffness largely decides how fast the iteration settles. At a finite contrast we can use the geometric mean of the two stiffnesses. An exact limit has no such mean, since it would be 0 for a void and \(\infty\) for a rigid inclusion, so there we pick \(C^0\) by hand.
We can do that too, when the matrix is uniform. Then we need no second strain field. The polarization \(\tau\) from the Lippmann–Schwinger section lives only inside the inclusion, and it acts as the multiplier.
I am τ, and I live only in this hole. The Fourier solve sees one uniform solid.
We adjust τ until the total stress in the hole is 0. Then the hole’s strain is what is left free.
The same τ, in the same place. Only the question changes.
We adjust τ until the strain inside is 0. Then the stress inside is what is left free, and it is τ.
With \(\chi(x)=1\) inside the inclusion and 0 outside, both cases share these two lines:
Rigid inclusion: a multiplier on the strain. We minimize the energy over compatible strains, with \(e=0\) inside as the constraint:
Varying \(e\) gives equilibrium of \(\sigma\), and varying \(\tau\) gives \(e=0\) inside. So \(\sigma=\tau\) inside: the multiplier is the stress, and we solve
Void: a multiplier on the stress. Now we minimize the complementary energy over stresses in equilibrium, with \(S^0=(C^0)^{-1}\) and \(\sigma=0\) inside as the constraint:
Here the multiplier \(\eta\) is the strain in the void, and it can be represented as an equivalent eigenstrain, not an additional imposed misfit: \(\tau=-C^0:\eta\). Setting \(\sigma=0\) inside gives
The two cases mirror each other: the rigid inclusion constrains the strain and leaves the stress as the multiplier, and the void constrains the stress and leaves the strain as the multiplier. Neither answer is unique inside. A rigid inclusion’s interior can hold any self-balanced stress, and a void’s interior can take any strain that fits together, but these choices do not change the matrix.
This is not an augmented Lagrangian. It has no band and no multiplier update. Here \(\tau\) is simply the unknown of one linear equation, which we can solve with conjugate gradients. The idea of a virtual eigenstrain that lives only inside voids and cracks, in a body of uniform stiffness, goes back to Jin, Wang and Khachaturyan (2003).
Why, then, do we need method B? Both impose a hard constraint: at the solution it holds exactly, unlike a soft solid, which only approaches it. But the two approaches swap what is exact along the way. Here equilibrium holds at every step and the constraint converges. In method B the constraint holds at every step and equilibrium converges. The direct form also relies on a uniform matrix. If the matrix varies too, \(\tau\) must live everywhere and no longer reduces to a constraint in the inclusion. Derivatives are simple in Fourier space and \(C(x)\) is simple in real space, and no single space makes both simple. That is why method B keeps two fields: \(e\) for the Fourier step and \(d\) for the local step.
We can drop the second strain field and put the band directly on the physical constraint inside the inclusion: \(e=0\) in a rigid inclusion, or \(\sigma=0\) in a void. The multiplier then adds the band’s pull each round, as in method B. In a sharp-interface test this was slower than the plain multiplier at tighter tolerance, so we do not use it. We did not test it on a diffuse interface.
S. Bhattacharyya, “How do we pull on a periodic box?,” web page, IIT Hyderabad, 3 November 2026. https://saswataiith.github.io/resources/elastic-solvers/homogenization/
@misc{Bhattacharyya-periodic-box,
author = {Bhattacharyya, Saswata},
title = {How do we pull on a periodic box?},
howpublished = {Web page, IIT Hyderabad},
year = {2026},
url = {https://saswataiith.github.io/resources/elastic-solvers/homogenization/}
}This page explains three formulations, including our own Method C, and reports their tests on Cahn–Hilliard inclusions. None of them is claimed to be new or the fastest in every case.
Every inclusion result on this page uses a smooth phase \(h\) computed from a Cahn–Hilliard run, not a drawn sharp circle. A real microstructure has a diffuse interface, and the FFT handles smooth fields well.
One parabola is A c², with its bottom at c = 0. The other is A(1 − c)², with its bottom at c = 1.
I blend them: h = c²(3 − 2c), and f = h A(1 − c)² + (1 − h) A c². The minima stay at c = 0 and c = 1.
We start with a small disk at c = 1, in a matrix slightly above c = 0. We call that matrix supersaturated.
After 10000 steps the sharp edge is smooth, about 7 grid points wide. The total amount of c never changes.
c stops a little short of 0 and 1. So we stretch it: ĉ = (c − c_min)/(c_max − c_min).
Then h = ĉ²(3 − 2ĉ). Now h runs exactly from 0 to 1.
Only points where h = 1 exactly have zero stiffness or compliance. Other core points can have small positive weights.
A reporting core is not automatically an exact null region. Its small positive weights can still make convergence difficult.
The total free energy adds a gradient term to the two wells, and the composition follows the gradient of its chemical potential, which conserves \(c\):
We use \(A=1\), mobility \(M=1\), \(\Delta t=10^{-4}\) and 10000 steps, with an interface of about 7 grid points. Each step is semi-implicit in Fourier space, with a stabilizing constant \(S\):
At \(k=0\) this leaves \(\tilde c\) unchanged, which is why the total amount of \(c\) stays fixed. The Laplacian keeps its Nyquist term, as the Nyquist section explains.
Using this code. Copy these snippets for learning, teaching and demonstration. For any other use, please email me with what you need it for.
This function uses np and fftw from the top of Step 1 of Method C. It defines the wells, picks \(\kappa\) from the interface width, builds the starting disk, repeats the step above, and finally rescales.
def relax_inclusion(n, fraction, points=7.0, supersaturation=1e-3, steps=10000, dt=1e-4):
"""A round inclusion relaxed by Cahn-Hilliard, then rescaled. Returns h, from 0 to 1."""
h_of = lambda c: c**2*(3 - 2*c)
well = lambda c: h_of(c)*(1 - c)**2 + (1 - h_of(c))*c**2 # two parabolas, A = 1
slope = lambda c: 6*c*(1 - c)*(1 - 2*c) - 2*h_of(c)*(1 - c) + 2*(1 - h_of(c))*c
# The gradient coefficient that makes c go from 0.01 to 0.99 over about `points` grid points.
grid = .01 + .98*(np.arange(20000) + .5)/20000
kappa = (points/n/(np.sum(1/np.sqrt(well(grid)))*.98/20000))**2
m = np.arange(n, dtype=float)
m[m > n//2] -= n
kx, ky = np.meshgrid(2*np.pi*m, 2*np.pi*m, indexing='ij') # the Nyquist term stays: this is a Laplacian
k2 = kx**2 + ky**2
x = (np.arange(n) + .5)/n - .5
X, Y = np.meshgrid(x, x, indexing='ij')
c = np.where(np.hypot(X, Y) < np.sqrt(fraction/np.pi), 1.0, supersaturation)
S = 8.0 # stabilizing term, the largest curvature of the wells
denominator = 1 + dt*k2*(S + 2*kappa*k2)
for _ in range(steps):
c = fftw.ifft2((fftw.fft2(c)*(1 + dt*k2*S) - dt*k2*fftw.fft2(slope(c)))/denominator).real
scaled = (c - c.min())/(c.max() - c.min()) # now exactly 0 and 1 at the extremes
return scaled**2*(3 - 2*scaled)n, fraction\(N\)The grid, and the area fraction of the starting disk.
points, supersaturationHow many grid points the interface spans, and the small starting c of the matrix.
steps, dt\(\Delta t\)The number of time steps and their size.
c\(c\)The composition field: a disk in a matrix, relaxed step by step.
denominator, S\(1+\Delta t\,k^2(S+\kappa k^2)\)The implicit part of the step, with S = 8 the stabilizer.
kappa\(\kappa\)The gradient coefficient, chosen so that the interface is points/n wide.
scaled\(\hat c\)The composition rescaled to run exactly from 0 to 1.
well, slope\(f(c),\ df/dc\)The double well with A = 1, and its derivative, which drives the step.
kx, ky, k2\(k_1,\ k_2,\ k^2\)Wavevectors for a Laplacian; here the Nyquist term stays.
h_of(scaled) → h\(h=\hat c^2(3-2\hat c)\)The phase field the solvers take.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
relax_inclusion | \(h\) | The function. It returns the phase field \(h\) as an array of shape (n, n). |
n, fraction | \(N\) | Grid size, and the area fraction of the starting disk. Its radius is \(\sqrt{\text{fraction}/\pi}\) on a box of side 1. |
points | Grid points over which \(c\) goes from 0.01 to 0.99. | |
supersaturation | The small starting \(c\) of the matrix. A curved interface is in equilibrium with a matrix slightly above \(c=0\). | |
steps, dt | \(\Delta t\) | The number of time steps and their size. |
h_of | \(h(c)=c^2(3-2c)\) | The blending function. |
well, slope | \(f(c),\ df/dc\) | The free energy with \(A=1\), and its derivative. |
grid | Points between 0.01 and 0.99 for a midpoint-rule integral. | |
kappa | \(\kappa\) | The gradient coefficient. In one dimension the interface obeys \(dc/dx=\sqrt{f/\kappa}\), so its width is \(\sqrt\kappa\int dc/\sqrt f\). We choose \(\kappa\) to make that width points/n. |
m, kx, ky, k2 | \(k_1,\ k_2,\ k^2\) | Wavevectors for a Laplacian, so the Nyquist term stays here, unlike in Cell. |
x, X, Y | Grid coordinates with the disk at the center of the box. | |
c | \(c\) | The composition field. |
S | \(S\) | The stabilizing term in the time step: 8, the largest curvature of the wells. |
denominator | The implicit part of the step. | |
scaled | \(\hat c\) | The rescaled composition, exactly 0 at its smallest and 1 at its largest. |
This example needs three more pieces, which come below: Cell and its helpers from Step 1 of Method C, solve_hard_constraint from Step 2, and solve_polarization_cg with its helpers from the polarization code. We paste those first, then this function, then these lines. They solve a soft phase and a rigid phase on the same inclusion under a prescribed mean stress, and print the mean strain and the iterations used. The example uses the same matrix as the tables and figures, \(\mu=80\) GPa and \(\nu=1/3\), whose plane-strain uniaxial modulus is 240 GPa. Its grid is 64 (a 64 nm box). The measured example output is shown below.
Its output, with the timing of the run:
Soft phase, contrast 0.01: mean strain [ 1.29400614e-03 -4.46731840e-04 -1.41564771e-18] Y (GPa) 123.64701718783417 iterations 61
Rigid phase, Method C: mean strain [ 3.73328969e-04 -1.58187219e-04 -4.39490840e-18] Y (GPa) 428.5764391626865 iterations 163
real 2.47
user 2.34
sys 0.11
n = 64
c11, c12, c44 = cubic(80*GPA) # the superalloy matrix: mu = 80 GPa, nu = 1/3, isotropic, in eV/nm^3
Sigma = (160*MPA, 0.0, 0.0) # the prescribed mean stress, 160 MPa; add control='strain' to prescribe a mean strain
h = relax_inclusion(n, 0.3)
cell = Cell(n, c11, c12, c44)
e, s, iterations = solve_polarization_cg(cell, 0.99*h, 'void', Sigma) # Contrast 0.01: g = (1 - 0.01) h
print('Soft phase, contrast 0.01: mean strain', e.mean(axis=(1, 2)), 'Y (GPa)', Sigma[0]/e[0].mean()/GPA, 'iterations', iterations)
e, s, iterations = solve_hard_constraint(cell, h, 'rigid', Sigma) # Method C, rigid phase
print('Rigid phase, Method C: mean strain', e.mean(axis=(1, 2)), 'Y (GPa)', Sigma[0]/e[0].mean()/GPA, 'iterations', iterations)n\(N\)A small grid, so that the example runs quickly.
c11, c12, c44\(C^0\)The matrix stiffness.
Sigma\(\Sigma\)The prescribed mean stress. With control='strain' this triple is the mean strain instead.
h = relax_inclusion(n, 0.3)\(h\)The inclusion, from a starting area fraction of 0.3. The hard-constraint solvers take it as it is.
cell = Cell(n, c11, c12, c44)\(C^0,\ \Gamma\)The Cell of the matrix, used as the reference.
solve_…(cell, h or g, kind, Sigma)Any of the five solvers, called in the same way.
0.99*h\(g=(1-v)h\)A soft phase of contrast v = 0.01: what the polarization solvers take instead of h.
e.mean(axis=(1, 2))\(Y=\Sigma_{11}/\langle e_{11}\rangle\)The mean strain, and from it the uniaxial modulus.
e, s, iterations\(e,\ \sigma\)The fields and the count.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
n | \(N\) | A small grid, so that the example runs quickly. |
c11, c12, c44 | \(C^0\) | The matrix stiffness in this example. |
Sigma | \(\Sigma\) | The prescribed mean stress: only \(\Sigma_{11}\) is not zero. Every solver takes control='strain' instead, and then this triple is the mean strain. |
h | \(h\) | The inclusion, from a starting area fraction of 0.3. |
cell | \(C^0\) | The Cell of the matrix, used as the reference. |
e, s | \(e,\ \sigma\) | The strain and stress fields that each solver returns. |
0.99*h | \(g\) | \(g=(1-v)h\) with \(v=0.01\): a soft phase of contrast 0.01. |
e.mean(axis=(1, 2)) | \(\langle e\rangle\) | The computed mean strain. \(\Sigma_{11}/\langle e_{11}\rangle\) is the uniaxial modulus \(Y\) of the cell under this load. |
iterations | The iterations the solver used. |
Method A replaces a void with a very soft solid. Method B uses two strains and a multiplier. Method C uses one unknown field, chosen so that the void or rigid condition holds at every iteration. The inclusion comes from a Cahn–Hilliard run, with the composition rescaled so that \(h\) runs from 0 to 1.
Here C = (1 − h) C⁰. Where h = 1, C = 0, so σ = 0 at every iteration.
We solve for e = Ē + sym grad u, so e is compatible at every iteration. Only equilibrium has to converge.
Here S = (1 − h) S⁰. Where h = 1, S = 0, so e = 0 at every iteration.
We solve for a stress in equilibrium at every iteration. Only compatibility of the strain has to converge.
Method B has two strains, so it needs λ to make them equal.
Method C has one unknown field, so it has no λ and no band stiffness to choose.
Apply the local law. Then project with Γ onto compatible strains, or onto stresses in equilibrium.
h varies smoothly from 0 to 1, so the same steps work across the diffuse interface.
With a prescribed mean stress \(\Sigma\), the mean strain is free and the load does work:
With a prescribed mean strain \(\bar E\), the roles swap: the void strain has \(\langle\boldsymbol{e}\rangle=\bar{\boldsymbol{E}}\) and no work term, and the rigid energy gains \(-\bar{\boldsymbol{E}}:\langle\boldsymbol{\sigma}\rangle\) with a free mean stress. The code takes control='stress', the default, or control='strain'.
Method C is our own; we do not claim it is new or always fastest. Related FFT conjugate-gradient work includes Zeman et al. (2010), and Lucarini et al. (2022) use MINRES with zero-stiffness phases. For related dual ideas, Bhattacharya and Suquet (2005) study a scalar/antiplane recoverable-strain problem; that citation is context, not a claim of an identical in-plane implementation. The implementation and its own stopping criteria are tested here on a rescaled Cahn–Hilliard inclusion.
Using this code. Copy these snippets for learning, teaching and demonstration. For any other use, please email me with what you need it for.
This class stores the wavevectors and the inverse acoustic tensor. displacement computes \(u\) from a polarization, strain computes its symmetric gradient, and gamma does both.
import warnings
import numpy as np
import pyfftw
fftw = pyfftw.interfaces.numpy_fft
# Units: one grid cell is 1 nm, so lengths are in nm; stiffness, stress and energy density are in eV/nm^3.
EV_NM3 = 1.602176634e-19/1e-27 # one eV/nm^3 in pascal: 1.602e8 Pa = 160.2 MPa
GPA, MPA = 1e9/EV_NM3, 1e6/EV_NM3 # one GPa and one MPa in eV/nm^3: 6.2415 and 0.0062415
def cubic(mu, nu=1/3, az=1.0):
"""Cubic constants C11, C12, C44 from the Schmidt-Gross parameters: the average shear modulus mu,
the effective Poisson parameter nu and the Zener ratio az (Schmidt and Gross 1997; our Elastic Lab).
az = 1 is isotropic: C44 = mu, C12 = 2 mu nu/(1 - 2 nu), C11 = 2 mu (1 - nu)/(1 - 2 nu)."""
p = (1 - 4*nu)/(1 - 2*nu)
return mu*(2*(2 + az)/(1 + az) - p), mu*(2*az/(1 + az) - p), mu*2*az/(1 + az)
MATRIX = cubic(80*GPA) # a superalloy matrix at high temperature: mu = 80 GPa = 499.3 eV/nm^3, nu = 1/3, isotropic
SIGMA = 160*MPA # the prescribed mean stress: 160 MPa, about the centrifugal load on a turbine blade
class Cell:
"""A periodic unit cell with a uniform reference stiffness C0 = (c11, c12, c44). Fields are [xx, yy, xy], with tensor shear."""
def __init__(self, n, c11, c12, c44):
if not (c11 > abs(c12) and c44 > 0):
raise ValueError('A stable stiffness needs C11 > |C12| and C44 > 0.')
self.c11, self.c12, self.c44 = c11, c12, c44
m = np.arange(n)
m = np.where(m > n//2, m - n, m)
k = 2*np.pi*m.astype(float)
k[n//2] = 0.0 # a first derivative drops the Nyquist term
self.kx, self.ky = np.meshgrid(k, k, indexing='ij')
kx, ky = self.kx, self.ky
q11, q22, q12 = c11*kx**2 + c44*ky**2, c44*kx**2 + c11*ky**2, (c12 + c44)*kx*ky
det = q11*q22 - q12**2
zero = (kx == 0) & (ky == 0)
det[zero] = 1.0
self.o11, self.o22, self.o12 = q22/det, q11/det, -q12/det
self.o11[zero] = self.o22[zero] = self.o12[zero] = 0.0
def C(self, e):
return np.array([self.c11*e[0] + self.c12*e[1], self.c12*e[0] + self.c11*e[1], 2*self.c44*e[2]])
def S(self, s):
d = self.c11**2 - self.c12**2
return np.array([(self.c11*s[0] - self.c12*s[1])/d, (self.c11*s[1] - self.c12*s[0])/d, s[2]/(2*self.c44)])
def displacement(self, tau):
"""The periodic displacement caused by a polarization: its strain is -Gamma*tau."""
a, b, c = fftw.fft2(tau[0]), fftw.fft2(tau[1]), fftw.fft2(tau[2])
f1, f2 = self.kx*a + self.ky*c, self.kx*c + self.ky*b
return np.array([1j*(self.o11*f1 + self.o12*f2), 1j*(self.o12*f1 + self.o22*f2)])
def strain(self, u):
return np.array([fftw.ifft2(1j*self.kx*u[0]).real, fftw.ifft2(1j*self.ky*u[1]).real,
.5*fftw.ifft2(1j*(self.ky*u[0] + self.kx*u[1])).real])
def gamma(self, tau):
return -self.strain(self.displacement(tau))
def G(self, tau):
"""Gamma plus the uniform mode: the mean strain is free, so the mean stress can be prescribed."""
return self.gamma(tau) + self.S(tau.mean(axis=(1, 2)))[:, None, None]
def divergence(self, s):
a, b, c = fftw.fft2(s[0]), fftw.fft2(s[1]), fftw.fft2(s[2])
return np.array([fftw.ifft2(1j*(self.kx*a + self.ky*c)).real, fftw.ifft2(1j*(self.kx*c + self.ky*b)).real])
def dot(a, b):
return np.sum(a[0]*b[0] + a[1]*b[1] + 2*a[2]*b[2])
def uniform(v, like):
return np.array([np.full_like(like, v[0]), np.full_like(like, v[1]), np.full_like(like, v[2])])
def set_load(cell, load, control, like):
"""control = 'stress': load is the mean stress Sigma, and the mean strain is computed. control = 'strain': load is the mean strain E, and Sigma is None."""
if control == 'stress':
Sigma = uniform(load, like)
return Sigma, cell.S(Sigma), cell.G
if control == 'strain':
return None, uniform(load, like), cell.gamma
raise ValueError("control must be 'stress' or 'strain'.")
def material_region(g):
"""The exact void and rigid limits (g reaches 1) are judged over the matrix and the diffuse interface. A finite contrast keeps the whole cell."""
return g <= .99 if g.max() == 1 else np.ones_like(g, bool)
def size(v):
return np.sqrt(v[0]**2 + v[1]**2 + 2*v[2]**2)
def scale_of(v):
"""The size of a load, kept away from zero so that a zero load is allowed."""
return max(float(np.abs(v).max()), 1e-300)
def not_converged(name, iteration):
"""Every solver says so when it leaves its loop before all tests pass: at the cap, or when rounding leaves nothing to solve."""
warnings.warn(f'{name} stopped at {iteration} iterations before all tests passed; the result is not converged.')
def finished(cell, u, u_old, mean_old, e, s, law, load, keep=None, tolerance=1e-5):
"""All tests together. Under stress control we also test the change in the mean strain and the mean stress.
The displacement change is its rms over the region, divided by |E| L/(2 pi), with L = 1."""
Sigma, E = load
keep = np.ones(E[0].shape, bool) if keep is None else keep
scale = max(size(E[:, 0, 0]), 1e-300)
strain_change = size(e.mean(axis=(1, 2)) - mean_old)/scale
stress_error = 0.0 if Sigma is None else size(s.mean(axis=(1, 2)) - Sigma[:, 0, 0])/max(size(Sigma[:, 0, 0]), 1e-300)
if not (strain_change < tolerance and stress_error < 1e-4 and np.abs(law)[:, keep].max() < 1e-4):
return False # the three cheap tests first: the two below cost seven FFTs
du = np.array([fftw.ifft2(u[0] - u_old[0]).real, fftw.ifft2(u[1] - u_old[1]).real])[:, keep]
change = np.sqrt(np.mean(np.sum(du**2, axis=0)))/(scale/(2*np.pi))
div = np.sqrt(np.mean(np.sum(cell.divergence(s)[:, keep]**2, axis=0)))/max(2*np.pi*np.sqrt(np.mean((s[0]**2 + s[1]**2 + 2*s[2]**2)[keep])), 1e-300)
return change < tolerance and div < 1e-4
n\(N\)Grid points along each side.
c11, c12, c44\(C^0\)The reference stiffness. It must be stable.
tau\(\tau\)A polarization: a stress field used as a source.
kx, ky\(k_1,\ k_2\)The wavevectors, with the Nyquist term dropped.
q11, q22, q12 → o11, o22, o12\(Q,\ Q^{-1}\)The acoustic tensor of the reference solid, and its inverse.
displacement(tau)\(\tilde u\)Equilibrium of the reference solid with that source, in Fourier space.
C(e), S(s)\(C^0:e,\ S^0:\sigma\)Stress from strain, and strain from stress, in the reference solid.
strain(u)\(\tfrac12(u_{i,j}+u_{j,i})\)The symmetric gradient of a displacement, as real fields.
gamma(tau)\(\Gamma*\tau\)The Green operator: minus the strain of that displacement.
material_region → keep\(g\le0.99\)Exact endpoints: g <= 0.99. Finite contrast: the full cell.
set_load(load, control)\(\Sigma\) or \(\bar E\)Reads the flag: the load, the starting mean strain S⁰:Σ, and which operator the solver sees.
G(tau)\(\Gamma+S^0\langle\cdot\rangle\)The same with the uniform mode, for stress control.
divergence(s), dot\(\sigma_{ij,j}\)The equilibrium test, and the double contraction summed over the grid.
finished(…)The stopping rule: five tests, the same for every solver.
not_convergedThe warning at the cap, or when rounding leaves nothing to solve.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
fftw | The pyFFTW functions, used in the same way as np.fft. | |
Cell, __init__ | The class that holds everything about the reference solid on this grid, and its constructor, which precomputes the wavevectors and the inverse acoustic tensor once. It refuses a stiffness that is not stable: we need \(C_{11}>\lvert C_{12}\rvert\) and \(C_{44}>0\), so that every strain costs energy. See the conditions on the stiffness. | |
n | \(N\) | Grid points along each side. We use \(N=2^n\). |
c11, c12, c44 | \(C^0_{11},\ C^0_{12},\ C^0_{44}\) | The reference stiffness \(C^0\) of the uniform solid. |
m, k | \(k_m=2\pi m\) | Mode numbers 0, 1, …, N/2, −N/2+1, …, −1, and their wavenumbers on a box of side 1. |
k[n//2] = 0.0 | The Nyquist rule for first derivatives. See the Nyquist section below. | |
kx, ky | \(k_1,\ k_2\) | The two wavevector components at every Fourier point. |
q11, q22, q12 | \(Q_{ik}=C^0_{ijkl}k_jk_l\) | The acoustic tensor of the reference solid. |
det, zero | The determinant of that tensor, and the mask for \(k=0\), where we set it to 1 to avoid dividing by 0. | |
o11, o22, o12 | \(Q^{-1}\) | The inverse acoustic tensor, set to 0 at \(k=0\). The average strain is held separately. |
C(e) | \(C^0:e\) | Stress from a strain field. Fields are [xx, yy, xy], with tensor shear, so the shear line carries \(2C^0_{44}\). |
S(s), d | \(S^0:\sigma\) | Strain from a stress field, with \(S^0=(C^0)^{-1}\). d is the determinant \((C^0_{11})^2-(C^0_{12})^2\) of the normal block. |
tau | \(\tau\) | A polarization: a stress field added to the uniform solid. |
a, b, c; f1, f2 | \(\tilde\tau_{ij}\); \(k_j\tilde\tau_{ij}\) | The transforms of the three parts of tau, and its divergence without the factor \(\mathrm i\). |
displacement | \(\tilde u_i=\mathrm i\,Q^{-1}_{im}k_j\tilde\tau_{mj}\) | Solves equilibrium of the uniform solid with tau as a source. The result stays in Fourier space. |
strain | \(\tfrac12(u_{i,j}+u_{j,i})\) | The symmetric gradient of that displacement, returned as real fields. |
gamma | \(\Gamma*\tau\) | The Green operator: minus the strain of the displacement caused by tau. |
G | \(G=\Gamma+S^0\langle\cdot\rangle\) | \(\Gamma\) plus the uniform mode. Under stress control the mean strain is free, and this is the operator that the polarization sees. |
divergence | \(\sigma_{ij,j}\) | The divergence of a stress, used to test equilibrium. |
dot | \(\sum a:b\) | The double contraction summed over the grid. Shear counts twice, because \(a_{12}\) and \(a_{21}\) are stored once. |
uniform, v, like | Turns a triple v = (xx, yy, xy) into three uniform fields shaped like like. | |
set_load, load, control | \(\Sigma,\ \bar E\) | Reads the control flag. 'stress': the load is the mean stress \(\Sigma\), the starting mean strain is \(S^0:\Sigma\), and the Green operator is G. 'strain': the load is the mean strain \(\bar E\), \(\Sigma\) is None, and the operator is gamma. |
material_region, g | Where the tests are judged. In the exact void and rigid limits, where \(g\) reaches 1, only the matrix and the diffuse interface, \(g\le0.99\). At a finite contrast, the whole cell. | |
size, scale_of | The size of a (xx, yy, xy) triple, and the size of a load kept away from zero, so that a zero load does not divide by zero. | |
not_converged, name, iteration | The warning every solver gives when it leaves its loop before all tests pass: at the cap, or when rounding leaves nothing to solve. | |
finished | The stopping rule, the same for every solver on this page. Its arguments: the cell; the displacement now and one iteration earlier, u and u_old, in Fourier space; the mean strain of the previous iteration, mean_old; the strain e, the stress s and the scaled local-law error law; the load as the pair (Sigma, E) from set_load; the region keep; and the tolerance, \(10^{-5}\). du is the change in displacement in real space over the region, and scale is \(\lvert\bar E\rvert\). | |
change, strain_change, stress_error, div | The five tests, as numbers, compared below. change: the rms change in displacement over the region, divided by \(\lvert\bar E\rvert L/2\pi\), is below tolerance, \(10^{-5}\). strain_change: under stress control, the change in the mean strain over \(\lvert\bar E\rvert\) is below \(10^{-5}\). stress_error: under stress control, the mean stress is within \(10^{-4}\) of \(\Sigma\). div: the scaled equilibrium residual is below \(10^{-4}\). law: the largest error in the local law is below \(10^{-4}\). |
local applies \((1-h)C^0\) or \((1-h)S^0\). project applies \(G\), or its dual for stresses, so that the unknown stays compatible, or stays in equilibrium with the right mean. In the loop, a conjugate-gradient step moves the unknown and the next lines set the new direction. The last lines build the displacement, the strain and the stress, and run the stopping rule.
def solve_hard_constraint(cell, h, kind, load, max_iterations=20000, control='stress'):
"""No multiplier. void: the unknown is a compatible strain. rigid: the unknown is an equilibrated stress.
Stress control: Sigma enters the void energy, and is the mean of the rigid stress. Strain control: E is the mean of the void strain, and enters the rigid energy."""
Sigma, E, green = set_load(cell, load, control, h)
keep = material_region(h)
if kind == 'void':
x = E.copy()
local = lambda v: (1 - h)*cell.C(v)
gradient = local(x) if Sigma is None else local(x) - Sigma
project = lambda g: -green(g) # onto compatible strains
energy = lambda z: dot(z, cell.C(z))
else:
x = np.zeros_like(E) if Sigma is None else Sigma.copy()
local = lambda v: (1 - h)*cell.S(v)
gradient = local(x) - E if Sigma is None else local(x)
project = lambda g: -(cell.C(g) - cell.C(green(cell.C(g)))) # onto equilibrated stresses
energy = lambda z: dot(z, cell.S(z))
z = project(gradient)
p, rho = z.copy(), energy(z)
rho0, done = rho, False
u = np.zeros((2,) + h.shape, complex)
mean_old = E[:, 0, 0]
for iteration in range(1, max_iterations + 1):
q = local(p)
curvature = dot(p, q)
exact = rho <= 1e-26*rho0 or curvature <= 0 # solved to rounding: more steps would only add noise
if not exact:
a = rho/curvature
x, gradient = x + a*p, gradient + a*q
z = project(gradient)
rho_new = energy(z)
p, rho = z + (rho_new/rho)*p, rho_new
s = local(x) if kind == 'void' else x
e_local = x if kind == 'void' else local(x)
u_old, u = u, cell.displacement(-cell.C(e_local)) # the compatible part of the strain
e = (E if Sigma is None else e_local.mean(axis=(1, 2))[:, None, None]) + cell.strain(u)
law = (s - (1 - h)*cell.C(e))/cell.c11 if kind == 'void' else e - (1 - h)*cell.S(s)
done = finished(cell, u, u_old, mean_old, e, s, law/scale_of(E), (Sigma, E), keep)
if done or exact:
break
mean_old = e.mean(axis=(1, 2))
if not done:
not_converged(f'hard constraint ({kind})', iteration)
return e, s, iteration
cell, h, kind\(C^0,\ h(x)\)The reference Cell, the phase field, and whether it is a void or a rigid phase.
load, control → Sigma, E, green, keep\(\Sigma\) or \(\bar E\)The load and the flag, read by set_load, and where the tests are judged.
local(v)\((1-h)C^0\) or \((1-h)S^0\)The local law, point by point.
project(g)\(G\) or its dualSends a field to compatible strains, or to stresses in equilibrium, so x stays allowed.
x\(e\) or \(\sigma\)The unknown: a compatible strain for a void, an equilibrium stress for a rigid phase.
u, e, s, law\(\tilde u,\ e,\ \sigma\)The fields built from x with the local law: displacement, compatible strain, stress and the error in the law.
q = local(p), curvature, a\(q,\ p\cdot q,\ \alpha\)The law applied to the direction, the curvature, and the step length that moves x.
z = project(gradient(x))\(z\)The projected gradient: the residual.
finishedThe stopping rule over keep.
p\(p\)The search direction: z plus a multiple of the old p.
rho, rho0, exact, energy\(z:C^0:z\)The size of z in the energy inner product, and the guard that takes no step when nothing is left to solve.
e, s, iteration\(e,\ \sigma\)The result, with done false at the cap.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
solve_hard_constraint | The solver. It returns the strain, the stress and the iterations used, like every solver on this page. | |
cell | \(C^0\) | A Cell from Step 1. |
h | \(h(x)\) | The rescaled phase field from the Cahn–Hilliard run, from 0 to 1. |
kind | 'void' or 'rigid'. | |
load, control | \(\Sigma\) or \(\bar E\) | The mean stress, with control='stress' (the default), or the mean strain, with control='strain', as (xx, yy, xy). |
Sigma, E, green | \(\Sigma,\ \bar E,\ G\) or \(\Gamma\) | From set_load. Under stress control, \(\Sigma\) enters the void energy and is the mean of the rigid stress. Under strain control, \(\bar E\) is the mean of the void strain and enters the rigid energy. |
keep | The region from material_region where the tests are judged. | |
x | \(e\) or \(\sigma\) | The unknown: a compatible strain for a void, a stress in equilibrium for a rigid phase. It starts at \(S^0:\Sigma\) or \(\bar E\) (void), and at \(\Sigma\) or 0 (rigid). |
max_iterations | The cap, 20000. | |
local, v | \((1-h)C^0\) or \((1-h)S^0\) | The local law, applied point by point to a field v. |
gradient | The gradient of the energy at x. | |
project, g | \(G\) or its dual | Sends a field g to compatible strains, or to stresses in equilibrium, so x stays allowed. Under stress control the void projection keeps the uniform mode. |
energy | \(z:C^0:z\) or \(z:S^0:z\) | The inner product in which the projection is symmetric. |
z | \(z\) | The projected gradient, which is the residual of this conjugate-gradient method. |
p | \(p\) | The search direction. |
rho, rho_new, rho0 | The size of z by energy, now, after the step, and at the start. | |
q, curvature | \(q,\ p\cdot q\) | The local law applied to the direction, and the curvature along it. |
exact | True when rho has fallen to \(10^{-26}\) of rho0 or the curvature is not positive: the problem is solved to rounding, so no step is taken. The fields are still built and tested, so the result is always judged by the same rule. | |
a | \(\alpha\) | The step length along p. |
s, e_local | \(\sigma\), local strain | The stress, and the strain that the local law gives. |
u, u_old | \(\tilde u\) | The displacement from the compatible part of the strain, now and one iteration earlier. |
e, mean_old | \(e\) | The compatible strain: the mean strain plus the strain of u. Under stress control the mean is the mean of the local strain, which is computed, not given. mean_old remembers the previous mean for the rule. |
law | The error in the local law at each point, passed to finished after scaling by the size of the load. | |
done, iteration | Whether the rule passed, and the iterations used. The loop leaves at the cap of 20000 with a warning from not_converged: that result is not converged, and we never call it so. |
We change coordinates so that \(\Gamma\) becomes an orthogonal projector \(P\). Then both limits read: project, multiply by \((1-h)\), project. That matrix is symmetric, so we hand it to SciPy’s minres. After each iteration, watch runs the same stopping test as Step 2, and it stops the solver as soon as that test passes.
from scipy.sparse.linalg import LinearOperator, minres
class Finished(Exception):
pass
def solve_hard_constraint_minres(cell, h, kind, load, max_iterations=20000, control='stress'):
"""Method C by MINRES. In coordinates w = C0^(1/2):e (void) or S0^(1/2):s (rigid), the Green operator is an orthogonal projector P,
and both limits read: project, multiply by (1 - h), project. The matrix is symmetric, and singular where h = 1."""
n = h.shape[0]
Sigma, E, green = set_load(cell, load, control, h)
keep = material_region(h)
p, q = np.sqrt(cell.c11 + cell.c12), np.sqrt(cell.c11 - cell.c12)
root_c = lambda v: np.array([.5*(p + q)*v[0] + .5*(p - q)*v[1], .5*(p - q)*v[0] + .5*(p + q)*v[1], np.sqrt(2*cell.c44)*v[2]])
root_s = lambda v: np.array([.5*(1/p + 1/q)*v[0] + .5*(1/p - 1/q)*v[1], .5*(1/p - 1/q)*v[0] + .5*(1/p + 1/q)*v[1], v[2]/np.sqrt(2*cell.c44)])
P = lambda w: root_c(green(root_c(w)))
project = P if kind == 'void' else (lambda w: w - P(w))
# In the shear slot the inner product carries a factor 2, so we store sqrt(2)*w_xy in the flat vector.
def flat(w):
v = w.copy(); v[2] = np.sqrt(2)*v[2]; return v.ravel()
def field(v):
w = v.reshape(3, n, n).copy(); w[2] = w[2]/np.sqrt(2); return w
apply = lambda v: flat(project((1 - h)*project(field(v))))
A = LinearOperator((3*n*n, 3*n*n), matvec=apply, dtype=float)
w_load = root_c(E) if Sigma is None else root_s(Sigma) # the load, in these coordinates
if Sigma is None:
b = flat(-project((1 - h)*w_load)) if kind == 'void' else flat(project(w_load))
else:
b = flat(project(h*w_load)) if kind == 'void' else flat(-project((1 - h)*w_load))
def fields(v):
w = field(v)
if kind == 'void':
e_local = E + root_s(w)
s = (1 - h)*cell.C(e_local)
else:
s = root_c(w) if Sigma is None else Sigma + root_c(w)
e_local = (1 - h)*cell.S(s)
u = cell.displacement(-cell.C(e_local))
e = (E if Sigma is None else e_local.mean(axis=(1, 2))[:, None, None]) + cell.strain(u)
law = (s - (1 - h)*cell.C(e))/cell.c11 if kind == 'void' else e - (1 - h)*cell.S(s)
return u, e, s, law/scale_of(E)
state = dict(u=np.zeros((2, n, n), complex), mean=E[:, 0, 0], iteration=0, x=np.zeros(3*n*n), done=False)
def watch(v):
state['iteration'] += 1
state['x'] = v.copy()
u, e, s, law = fields(v)
if finished(cell, u, state['u'], state['mean'], e, s, law, (Sigma, E), keep):
state['u'], state['done'] = u, True
raise Finished
state['u'], state['mean'] = u, e.mean(axis=(1, 2))
try:
minres(A, b, rtol=1e-14, maxiter=max_iterations, callback=watch)
except Finished:
pass
u, e, s, law = fields(state['x'])
if state['iteration'] == 0: # a zero right-hand side: minres returns at once, without calling watch
state['done'] = finished(cell, u, state['u'], state['mean'], e, s, law, (Sigma, E), keep)
if not state['done']:
not_converged(f'minres ({kind})', state['iteration'])
return e, s, state['iteration']
cell, h, kind, load, controlThe same inputs as Step 2. The load becomes w_load below.
root_c, root_s\((C^0)^{1/2},\ (S^0)^{1/2}\)Square roots of the reference stiffness and compliance, from p and q.
P\(P=(C^0)^{1/2}\Gamma(C^0)^{1/2}\)An orthogonal projector.
w\(w\)The unknown in new coordinates: (C⁰)^½:e or (S⁰)^½:σ.
flat, field\(v\)A field as the long vector SciPy wants, and back. Shear carries √2.
project\(P\) or \(1-P\)The projector for a void or a rigid phase.
w_load, b\(b\)The load in the new coordinates, and the right-hand side.
apply → A\(A\)The matrix: project, multiply by 1−h, project.
LinearOperatorTells SciPy how to apply A without storing it.
minresThe SciPy solver, with its own tolerance set small.
watch, state, FinishedAfter each iteration: builds the fields, runs the stopping rule, and raises Finished when it passes.
fields → e, s, iteration\(e,\ \sigma\)The fields from a vector, exactly as in Step 2, and the result.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
solve_hard_constraint_minres | The solver, with the same arguments as Step 2: cell, h, kind, load, max_iterations and control. n is the grid size. | |
Sigma, E, green, keep | From set_load and material_region, as in Step 2. | |
LinearOperator | Tells SciPy how to apply our matrix without storing it. | |
minres | The MINRES solver in scipy.sparse.linalg. rtol is its own tolerance, set small so that finished decides when to stop. | |
Finished | An exception we raise to leave minres as soon as finished is true. | |
p, q | \(\sqrt{C_{11}+C_{12}},\ \sqrt{C_{11}-C_{12}}\) | Square roots of the two eigenvalues of the normal block of \(C^0\). |
root_c, root_s | \((C^0)^{1/2},\ (S^0)^{1/2}\) | Apply the square roots of the reference stiffness and compliance. |
P | \(P\) | \((C^0)^{1/2}:\Gamma*(C^0)^{1/2}\), an orthogonal projector. |
project | \(P\) or \(1-P\) | The projector used for a void or for a rigid phase. |
w | \(w\) | The unknown in new coordinates: \((C^0)^{1/2}:e\) for a void, \((S^0)^{1/2}:\sigma\) for a rigid phase. |
flat, field, v | Convert between a field and the long vector v that SciPy wants. The factor \(\sqrt2\) on shear keeps the inner product correct. | |
apply, A | \(A\) | The matrix: project, multiply by \((1-h)\), project. |
w_load, b | \(b\) | The load in the new coordinates, \((S^0)^{1/2}:\Sigma\) or \((C^0)^{1/2}:\bar E\), and the right-hand side made from it. |
fields | Turns a vector into the local strain e_local, the stress s, the displacement u, the compatible strain e and the error law, exactly as Step 2 does. | |
state | A small dictionary that keeps the latest displacement, mean strain, iteration count and solution between calls, and whether the rule passed. | |
watch | Called by minres after each iteration. It runs the same stopping rule as the other solvers, and leaves minres as soon as the rule passes. At the cap, not_converged warns. |
Which solver for Method C. The operator is symmetric but only semi-definite: it is zero inside the inclusion, which MINRES tolerates, and it is nearly zero across the diffuse interface, where \(1-h\) runs from 1 to 0, which no Krylov method tolerates for free. That band sets the count. For the rigid disk the compliance vanishes only inside, and CG and MINRES both converge, at 221 and 61 iterations. For the void the stiffness vanishes, the band is where the stopping rule looks hardest, and CG runs out of its 20000 iterations while MINRES needs 203. So Method C is MINRES; the CG rows are kept as the control. A pointwise preconditioner, \(1/(1-h+\varepsilon)\), does not help, because the slow modes are strain fields spread over the band, not single points, and scaling them pointwise leaves their eigenvalues small. The preconditioner that would help is the inverse of the regularised problem itself, which is what the band stiffness of Method B approximates one step at a time. A warm start does not help either: starting MINRES from the converged contrast-0.01 solution saved 11 of 444 void steps on the 256 grid and none of the rigid ones, because the far field is cheap and the band modes, which the finite-contrast solution does not contain, are the whole cost. Inside the constrained phase the unknown is not determined by the energy, so we compare and plot only the fields outside it.
Each step uses only the current residual. The slowest modes set the rate, so iterations grow with the contrast κ.
Each step minimizes the energy over all directions used so far. Iterations grow with √κ.
A void or rigid phase gives a very large κ, so this difference is largest there.
It uses the same directions but minimizes the residual, so the residual never rises.
It also works for symmetric operators that are singular or indefinite. Ours is nearly singular where h = 1.
It is simple, and it extends directly to nonlinear laws.
CG and MINRES, as used here, need a linear, symmetric operator.
All three solve the same symmetric system \(A\,y=b\). In Method C, \(A\) means: project, multiply by \((1-h)\), project.
The equation we are solving. Write \(q=1-h\): it is 1 in the matrix, 0 inside the inclusion, and in between across the diffuse interface. Method C says: void, \(\sigma=q\,C^0:e\); rigid, \(e=q\,S^0:\sigma\). At \(h=1\) the void carries no stress and the rigid disk no strain, whatever the other field does there. The Green operator of Step 1 turns a stress-like field into the compatible strain it produces: \(G=\Gamma+S^0\langle\cdot\rangle\) under stress control, so that the mean strain is free, and \(G=\Gamma\) under strain control, where it is fixed. In the scaled coordinates \(w=(C^0)^{1/2}:e\) the operator \(P=(C^0)^{1/2}\,G\,(C^0)^{1/2}\) is a projector: \(P\) picks out the allowed strain corrections, and \(Q=I-P\) the allowed stress corrections. That is how the constraint is built in. The unknown is a \(w\) with \(Pw=w\) for the void or \(Qw=w\) for the rigid disk, and no field outside those spaces is ever formed.
Under a prescribed mean stress \(\Sigma\), start from the homogeneous answer \(E_0=S^0:\Sigma\) and write the void strain as \(e=E_0+(C^0)^{-1/2}w\), or the rigid stress as \(\sigma=\Sigma+(C^0)^{1/2}w\). Equilibrium of the void stress, or compatibility of the rigid strain, projected, is a linear system:
Under a prescribed mean strain, with \(w_E=(C^0)^{1/2}:\bar E\), the right-hand sides become \(-P(q\,w_E)\) and \(Q\,w_E\), and the mean stress is the output. In every case the operator is the same three moves: project, multiply by \(q(x)\), project again. The projections are FFTs; no matrix is ever stored. This is the \(A\) of \(A\,y=b\) in the folds below. It is symmetric, because multiplying by \(q\) is symmetric and a projector is its own transpose, and it is positive semi-definite, because \(y\cdot A\,y=\langle q\,|Py|^2\rangle\ge0\), with equality whenever \(Py\) lives only where \(q=0\). The map from the inclusion to the equation:
From the Cahn–Hilliard run: 0 in the matrix, 1 inside, smooth between.
From Step 1. A stress-like field in, the compatible strain it makes out. Under stress control it also moves the mean strain.
A mean stress, with the mean strain free, or a mean strain, with the mean stress free.
Void: \(\sigma=q\,C^0:e\). Rigid: \(e=q\,S^0:\sigma\). Where \(q=0\) the constraint holds by itself.
In the scaled coordinates \(w=(C^0)^{1/2}:e\). \(P\) keeps allowed strains, \(Q\) allowed stresses.
The load, projected: \(P[h\,(C^0)^{-1/2}:\Sigma]\) for the void, \(-Q[q\,(C^0)^{-1/2}:\Sigma]\) for the rigid disk.
Project, multiply by \(q\), project. Symmetric, semi-definite, never stored: three FFT moves.
By a Krylov method: the next chart. One application of \(A\) per step.
A correction that can only live in the allowed space, so the constraint is never violated.
Void: \(e=E_0+(C^0)^{-1/2}w\), \(\sigma=q\,C^0:e\). Rigid: \(\sigma=\Sigma+(C^0)^{1/2}w\), \(e=q\,S^0:\sigma\).
Displacement, mean strain, mean stress, equilibrium and the local law, tested on the matrix.
Arrows show what feeds what. Dashed blue boxes are what we start from, the green box is what comes out, and the orange box is the stopping rule.
What a Krylov method is. We cannot write \(A\) down, only apply it. After one application we know \(b\) and \(A\,b\); after \(k\), the vectors \(b,\,A\,b,\,\dots,\,A^{k-1}b\). The space they span is the Krylov space \(\mathcal K_k\). Every method below returns, at step \(k\), the best point of \(\mathcal K_k\) in some sense, and the methods differ only in what best means and in how cheaply they find it. One application of \(A\) per step, a handful of stored vectors and no matrix: that is why these methods suit FFT solvers. The family at a glance:
An operator we can only apply, and a right-hand side. Positive definite at finite contrast; only semi-definite for a void or a rigid disk.
Spanned by \(b,\,Ab,\,\dots,\,A^{k-1}b\): everything we can know after \(k\) applications. Each solver picks its best point of it.
The ratio of the largest to the smallest eigenvalue of \(A\). In the limits the smallest ones sit in the interface band, where \(q\) is tiny.
Best means: take the residual and step. Remembers nothing. Steps grow like \(\kappa\).
Best means: lowest energy, the bottom of the bowl. Directions are \(A\)-orthogonal, so no step undoes another. Divides by the curvature \(p\cdot Ap\). Steps grow like \(\sqrt\kappa\).
Best means: smallest residual. Lanczos makes \(A\) tridiagonal; one plane rotation per step keeps it triangular. Divides by nothing, so a zero curvature costs nothing.
Same residual, then a second factorisation, LQ after QR, picks the solution of smallest norm among all that fit. Stable when \(A\) is singular.
Void 642, rigid 653 iterations. Simple, and the one that carries over to nonlinear laws.
Rigid 221. Void: the cap, not converged. The bowl has a flat floor where \(q=0\), and the step divides by its curvature.
Void 203, rigid 61: the method we use for Method C. The band of tiny eigenvalues is still resolved one at a time.
Void 444, rigid 74: the same steps as plain MINRES, and the same interior field to twelve digits. Nothing to gain here.
Whatever the solver calls best, we stop only when displacement, equilibrium and the local law all say yes.
Arrows show what feeds what. Dashed blue boxes are what every solver starts from, green boxes are what each one gave on this page, and the orange box is the stopping rule they share.
Conjugate gradients. When \(A\) is symmetric and positive definite, solving \(A\,y=b\) is the same as finding the bottom of the bowl \(\tfrac12\,y\cdot A\,y-b\cdot y\). Steepest descent walks downhill along the residual \(r=b-A\,y\) and zigzags, because each step partly undoes the last. CG chooses directions \(p_k\) that are \(A\)-orthogonal, \(p_i\cdot A\,p_j=0\), so a step along \(p_k\) leaves the minimum along every earlier direction untouched, and after \(k\) steps \(y_k\) is the lowest point of the whole Krylov space. Its step length divides by the curvature \(p\cdot A\,p\). The number of steps grows like \(\sqrt\kappa\), where \(\kappa\) is the ratio of the largest to the smallest eigenvalue of \(A\); a fixed point grows like \(\kappa\) itself. That is the whole case for CG at finite contrast, where \(\kappa\) is set by the contrast.
Where CG breaks. For a void or a rigid disk, \(A\) is only semi-definite. There are directions with \(p\cdot A\,p=0\), the fields living where \(q=0\), and a whole band of directions with tiny curvature, the fields living where \(q\) is small across the interface. The bowl has a flat floor and a nearly flat rim. CG's step length divides by that curvature, so in those directions it either overshoots or stalls, and round-off fills the flat directions with noise that never leaves. The void hard CG row at the cap is this failure.
MINRES. Same Krylov space, different sense of best: \(y_k\) is the point of \(\mathcal K_k\) with the smallest residual \(\lVert b-A\,y\rVert\). The Lanczos recurrence builds an orthonormal basis \(v_1,v_2,\dots\) of that space three vectors at a time, and in this basis \(A\) is tridiagonal, so the least-squares problem for the best coefficients is tiny and is solved by one plane rotation per step, a QR factorisation built up as we go. Nothing divides by a curvature, so a zero or tiny eigenvalue costs nothing by itself. For a consistent system the residual falls monotonically and the flat directions are simply never entered. The band of tiny eigenvalues still has to be resolved one by one, which is why the void needs 203 steps and the rigid disk 61, not six. The algorithm is from Paige and Saunders (1975); its steps are in the third fold below.
MINRES-QLP. When \(A\) is singular there are many solutions, differing by anything in the flat directions, and in finite precision plain MINRES can drift along them as the residual nears round-off, which shows up as growth of \(\lVert y_k\rVert\). Choi, Paige and Saunders (2011) add a second factorisation of the tridiagonal matrix, an LQ after the QR, which lets the method pick, among all least-squares solutions, the one of smallest norm, and do so stably. For Method C that is exactly the interior ambiguity: the minimum-norm solution puts nothing inside the constrained phase that the energy does not ask for. The cost per step is the same single application of \(A\). We tried it on the 256 grid, the same inclusion on 2 nm cells, where every method needs more steps than on 512 because the interface is one cell wide: it took exactly the steps of plain MINRES, 444 for the void and 74 for the rigid disk, and returned the same interior field to twelve digits, so plain MINRES was never drifting here. The system is consistent and we stop by the physical rule, not by the residual alone, and that is enough.
Where the multiplier went. Method B keeps two strains, the compatible \(e\) and the local \(d\), and pulls them together with \(\lambda\), updated as \(\lambda\leftarrow\lambda+\beta\,C^0:(e-d)\). Method C has no second field and no \(\lambda\). The projection does the pulling, once per application of \(A\), and the constraint never has to converge because it is never violated. Both methods still earn their result the same way, through the displacement, equilibrium and local-law tests of the stopping rule.
Start with \(y_0=0\). Then repeat:
\(P\) is a fixed operator. In our polarization code, \(P=\boldsymbol{C}^0\). Each step uses \(r_k\) alone and forgets every earlier residual. Each error component is multiplied by a fixed factor per step. Components with small eigenvalues of \(P:A\) have a factor close to 1, so they decay slowly, and these set the number of iterations.
Start with \(y_0=0\), \(r_0=b\) and \(p_0=r_0\). Then repeat:
What this does. After \(k\) steps, \(y_k\) lies in the space spanned by \(b,\ Ab,\ \dots,\ A^{k-1}b\), called a Krylov space. Among all points in that space, \(y_k\) has the lowest energy \(\tfrac12\,y\cdot A\,y-b\cdot y\). The directions satisfy \(p_i\cdot A\,p_j=0\) for \(i\neq j\), so a later step does not undo an earlier one. Only the latest \(p\) and \(r\) need to be stored.
What it needs. \(A\) must be symmetric, and \(p\cdot A\,p\) must be positive. Zero local weights can produce a positive-semidefinite operator; an exact global kernel depends on the admissible compatible/equilibrated fields, not solely on the count of zero-weight pixels. CG still works if \(b\) has no part in that null space, but rounding errors can grow near convergence.
Start with \(y_0=0\), \(\beta_1=\lVert b\rVert\), \(v_1=b/\beta_1\), \(\bar\phi_1=\beta_1\) and \(v_0=d_0=d_{-1}=0\). Then repeat:
What this does. MINRES searches the same Krylov space as CG, but it picks the point with the smallest residual \(\lVert b-A\,y\rVert\). Its Euclidean residual is nonincreasing in exact arithmetic; finite-precision behavior is checked separately. Only a few vectors need to be stored.
What it needs. \(A\) must be symmetric. It need not be positive definite, and it never divides by \(p\cdot A\,p\). That is why it suits a nearly singular \(A\). In practice we call scipy.sparse.linalg.minres.
The algorithm is from Paige and Saunders (1975).
These scalings are the standard estimates, as given by Schneider (2021).
Both controls use the same solver functions and the same stopping rule. At finite contrast every method receives the same arithmetic stiffness field \(C=(1-h+vh)C_{\rm matrix}\). For a stiff phase the polarization input is \(g=1-1/(1-h+vh)\). The ideal rigid endpoint is a separate compliance limit \(S=(1-h)S_{\rm matrix}\), not the pointwise limit of that arithmetic-stiffness diffuse profile. Letting \(v\to\infty\) in it would make every point with \(h>0\) rigid, diffuse tails included, which is not the family of the \(g=h\) compliance endpoint. The docstring of the fixed-point solver still mentions a compliance profile for a finite stiff phase; the runs on this page build the stiffness field above and pass its \(g\). No physical eigenstrain is imposed.
Prescribed mean stress \((160,0,0)\) MPa; transverse mean strain is evaluated.
| Solver and contrast | \(\langle e_{xx}\rangle\times10^4\) | \(Y=\Sigma_{xx}/\langle e_{xx}\rangle\) (GPa) | Iterations | Converged |
|---|---|---|---|---|
| direct 0.1 | 6.944 | 230.40 | 45 | yes |
| CG 0.1 | 6.944 | 230.40 | 21 | yes |
| fixed point 0.1 | 6.944 | 230.40 | 50 | yes |
| AL 0.1 | 6.944 | 230.40 | 26 | yes |
| direct 0.01 | 7.031 | 227.58 | 321 | yes |
| CG 0.01 | 7.031 | 227.58 | 55 | yes |
| fixed point 0.01 | 7.031 | 227.58 | 336 | yes |
| AL 0.01 | 7.031 | 227.58 | 73 | yes |
| direct 0.001 | 7.042 | 227.22 | 1910 | yes |
| CG 0.001 | 7.042 | 227.22 | 130 | yes |
| fixed point 0.001 | 7.042 | 227.22 | 1736 | yes |
| AL 0.001 | 7.042 | 227.22 | 220 | yes |
| direct 10 | 6.493 | 246.42 | 54 | yes |
| CG 10 | 6.493 | 246.42 | 15 | yes |
| fixed point 10 | 6.493 | 246.42 | 45 | yes |
| AL 10 | 6.493 | 246.42 | 28 | yes |
| direct 100 | 6.456 | 247.84 | 567 | yes |
| CG 100 | 6.456 | 247.84 | 39 | yes |
| fixed point 100 | 6.456 | 247.84 | 287 | yes |
| AL 100 | 6.456 | 247.84 | 81 | yes |
| direct 1000 | 6.443 | 248.33 | 5693 | yes |
| CG 1000 | 6.443 | 248.33 | 87 | yes |
| fixed point 1000 | 6.443 | 248.33 | 1456 | yes |
| AL 1000 | 6.443 | 248.33 | 246 | yes |
| void MINRES | 7.043 | 227.18 | 203 | yes |
| void CG | 7.043 | 227.18 | 1034 | yes |
| void hard CG | 7.043 | 227.18 | 20000, not converged | no |
| void AL | 7.043 | 227.18 | 902 | yes |
| void fixed point | 7.043 | 227.18 | 642 | yes |
| rigid MINRES | 6.473 | 247.16 | 61 | yes |
| rigid CG | 6.473 | 247.16 | 258 | yes |
| rigid hard CG | 6.473 | 247.16 | 221 | yes |
| rigid AL | 6.473 | 247.16 | 378 | yes |
| rigid fixed point | 6.473 | 247.16 | 653 | yes |
All 34 rows are shown, including the ones at the cap. The 20,000-iteration cap is never interpreted as convergence.
Prescribed uniaxial strain \(\bar E=(0.000666666667,0,0)\), with no eigenstrain. The two loads are not equivalent: strain control clamps the transverse strains. The homogeneous matrix gives \(M_{11}=320\) GPa, whereas its stress-controlled uniaxial modulus is 240 GPa. The computed mean stress is an output; the ratio −Eyy/Exx is prescribed zero here and must not be called an isotropic Poisson ratio of zero.
| Solver and contrast | \(\langle e_{xx}\rangle\times10^4\) | \(M_{11}^{\rm eff}=\langle\sigma_{xx}\rangle/\bar E_{xx}\) (GPa) | Iterations | Converged |
|---|---|---|---|---|
| direct 0.1 | 6.667 | 305.15 | 45 | yes |
| CG 0.1 | 6.667 | 305.15 | 22 | yes |
| fixed point 0.1 | 6.667 | 305.15 | 52 | yes |
| AL 0.1 | 6.667 | 305.14 | 37 | yes |
| direct 0.01 | 6.667 | 299.88 | 328 | yes |
| CG 0.01 | 6.667 | 299.88 | 57 | yes |
| fixed point 0.01 | 6.667 | 299.88 | 357 | yes |
| AL 0.01 | 6.667 | 299.86 | 105 | yes |
| direct 0.001 | 6.667 | 299.18 | 1965 | yes |
| CG 0.001 | 6.667 | 299.18 | 134 | yes |
| fixed point 0.001 | 6.667 | 299.18 | 1924 | yes |
| AL 0.001 | 6.667 | 299.17 | 322 | yes |
| direct 10 | 6.667 | 327.87 | 53 | yes |
| CG 10 | 6.667 | 327.87 | 16 | yes |
| fixed point 10 | 6.667 | 327.87 | 45 | yes |
| AL 10 | 6.667 | 327.87 | 28 | yes |
| direct 100 | 6.667 | 329.47 | 556 | yes |
| CG 100 | 6.667 | 329.47 | 38 | yes |
| fixed point 100 | 6.667 | 329.47 | 285 | yes |
| AL 100 | 6.667 | 329.47 | 80 | yes |
| direct 1000 | 6.667 | 330.05 | 5577 | yes |
| CG 1000 | 6.667 | 330.05 | 87 | yes |
| fixed point 1000 | 6.667 | 330.05 | 1421 | yes |
| AL 1000 | 6.667 | 330.05 | 242 | yes |
| void MINRES | 6.667 | 299.10 | 202 | yes |
| void CG | 6.667 | 299.10 | 1436 | yes |
| void hard CG | 6.667 | 299.10 | 12524 | yes |
| void AL | 6.667 | 299.10 | 1008 | yes |
| void fixed point | 6.667 | 299.10 | 676 | yes |
| rigid MINRES | 6.667 | 328.65 | 62 | yes |
| rigid CG | 6.667 | 328.65 | 227 | yes |
| rigid hard CG | 6.667 | 328.65 | 197 | yes |
| rigid AL | 6.667 | 328.65 | 317 | yes |
| rigid fixed point | 6.667 | 328.65 | 628 | yes |
All 34 rows are shown, including the ones at the cap. The 20,000-iteration cap is never interpreted as convergence.
The grid-32 check assembles the dense primal and dual equations for its own Cahn–Hilliard inclusion with the same three-component Fourier discretization as the solvers. This is not the 512 nm physical experiment. The reference uses a recorded eigenvalue truncation in nearly singular cases; it is a discrete reference, not the exact continuum field. Stress and strain differences use tensor/Frobenius norms over the declared region h<=0.99. A run at the cap stays in the table, marked as such.
| Verification case | Iterations | Converged | Relative mean-strain difference | Relative stress difference | Relative strain difference |
|---|---|---|---|---|---|
| void MINRES | 111 | yes | 8.696e-05 | 0.00466 | 0.01982 |
| void hard CG | 695 | yes | 2.077e-05 | 0.001508 | 0.00509 |
| void CG | 602 | yes | 2.511e-05 | 0.001777 | 0.00632 |
| void fixed point | 894 | yes | 0.0002359 | 0.006264 | 0.02644 |
| void AL | 743 | yes | 0.0001 | 0.004828 | 0.02059 |
| rigid MINRES | 49 | yes | 3.889e-05 | 0.01089 | 0.002781 |
| rigid hard CG | 69 | yes | 2.148e-05 | 0.009135 | 0.002614 |
| rigid CG | 98 | yes | 2.138e-05 | 0.00914 | 0.002618 |
| rigid fixed point | 1155 | yes | 5.084e-05 | 0.009434 | 0.002847 |
| rigid AL | 539 | yes | 2.765e-05 | 0.009691 | 0.002468 |
| direct 0.01 | 199 | yes | 7.205e-07 | 1.212e-05 | 6.012e-05 |
| CG 0.01 | 55 | yes | 2.454e-09 | 1.307e-05 | 9.86e-05 |
| fixed point 0.01 | 343 | yes | 1.671e-06 | 1.494e-05 | 0.0001443 |
| AL 0.01 | 69 | yes | 1.012e-06 | 2.405e-05 | 2.746e-05 |
| direct 0.001 | 1264 | yes | 1.356e-06 | 2.834e-05 | 0.0001207 |
| CG 0.001 | 118 | yes | 1.54e-08 | 2.256e-05 | 0.0003121 |
| fixed point 0.001 | 1908 | yes | 3.51e-06 | 6.607e-05 | 0.0002882 |
| AL 0.001 | 215 | yes | 8.294e-07 | 1.889e-05 | 6.643e-06 |
| direct 100 | 20000, not converged | no | undefined | undefined | undefined |
| CG 100 | 35 | yes | 6.943e-09 | 0.0003617 | 3.332e-05 |
| fixed point 100 | 268 | yes | 2.48e-06 | 0.001239 | 4.812e-05 |
| AL 100 | 72 | yes | 5.58e-06 | 2.485e-05 | 1.546e-05 |
| direct 1000 | 20000, not converged | no | undefined | undefined | undefined |
| CG 1000 | 70 | yes | 1.191e-07 | 0.003776 | 0.0001291 |
| fixed point 1000 | 1089 | yes | 1.022e-05 | 0.01214 | 0.000336 |
| AL 1000 | 222 | yes | 6.072e-06 | 4.327e-05 | 1.526e-05 |
Of the 26 rows, 24 met the stopping rule. Among the converged rows the mean strains differ by at most 2.4 parts in \(10^{4}\). Passing the rule bounds the residuals, not the error of the fields.
void fixed point: the strains in the reported region differ by 2.644 %. This is a comparison with the dense reference, not something the stopping residual predicts.
fixed point 1000: the stresses in the reported region differ by 1.214 %. This is a comparison with the dense reference, not something the stopping residual predicts.
Not converged at the cap: direct 100, direct 1000. These trials of the direct method use the midpoint reference of the audit, not the three-quarters reference that the page's direct method uses.
Method C is our hard-constraint formulation, solved by CG or by MINRES. We call none of them new or the fastest in every case. Compare convergence status, mean response, field discrepancy, cost and the chosen reference/band together. Small steps and residuals can coexist with unresolved near-null fields.
To compare these solvers we use a polarization form that also handles a finite contrast. These pieces use Cell, dot, set_load, material_region and finished from Step 1 of Method C, and take the same control flag.
Using this code. Copy these snippets for learning, teaching and demonstration. For any other use, please email me with what you need it for.
We put \(\sigma=C^0:e+\tau\) and \(e=\bar E-\Gamma*\tau\) into the local law, and write \(\tau=\sqrt g\,y\) to keep the operator symmetric. This gives the system \(A\,y=b\) for each case:
Under stress control, \(\Gamma\) becomes \(G=\Gamma+S^0\langle\cdot\rangle\) and \(\bar E\) becomes \(S^0:\Sigma\): the uniform mode is part of the unknown, so the mean stress is \(\Sigma\) at every iteration and the mean strain is computed. polarization_operator returns \(A\) and the factor in \(b\). polarization_fields turns \(y\) into displacement, strain and stress.
def polarization_operator(cell, g, kind, green):
"""tau = sqrt(g)*y. void: C = (1 - g) C0. rigid: S = (1 - g) S0. Returns the operator A and the factor in b."""
root = np.sqrt(g)
if kind == 'void':
return (lambda y: cell.S(y) - root*green(root*y)), -root
return (lambda y: (1 - g)*cell.S(y) + root*green(root*y)), root
def polarization_fields(cell, g, kind, y, E, Sigma):
tau = np.sqrt(g)*y
u = cell.displacement(tau)
e = E + cell.strain(u) # strain control: e = E - Gamma:tau
if Sigma is not None:
e = e - cell.S(tau.mean(axis=(1, 2)))[:, None, None] # stress control: e = E - G:tau
s = cell.C(e) + tau
law = (s - (1 - g)*cell.C(e))/cell.c11 if kind == 'void' else e - (1 - g)*cell.S(s)
return u, e, s, law/scale_of(E)
green\(G\) or \(\Gamma\)The Green operator from set_load.
cell\(C^0,\ \Gamma\)The reference Cell. Both functions take it.
g, kind\(g(x)\)Where the inclusion is, with the contrast folded in: void C=(1−g)C⁰, rigid S=(1−g)S⁰.
polarization_operator → A, factor\(A,\ \pm\sqrt g\)The operator the solvers apply, and the factor that makes b from the load.
root\(\sqrt g\)On both sides of Γ, which keeps A symmetric.
y\(y\)The unknown field.
polarization_fields → u, e, s, law\(\tilde u,\ e,\ \sigma\)Displacement, compatible strain, stress and the error in the law, all from τ.
tau\(\tau=\sqrt g\,y\)The polarization. The stress is C⁰:e + τ.
E, Sigma\(\bar E,\ \Sigma\)Under stress control the strain subtracts S⁰:⟨τ⟩, so that ⟨σ⟩ = Σ at every iteration. polarization_fields uses them.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
polarization_operator, polarization_fields | The two functions: the operator \(A\) with the factor in \(b\), and the fields from a solution. Both take the cell from Step 1 of Method C. | |
g | \(g(x)\) | Where the inclusion is. \(g=h\) for the exact limit, \(g=(1-v)h\) for a soft phase of contrast \(v\), and \(g=1-1/(1-h+vh)\) for the finite arithmetic-stiffness profile. |
kind | 'void' means \(C=(1-g)C^0\). 'rigid' means \(S=(1-g)S^0\). | |
root | \(\sqrt g\) | Used on both sides of \(\Gamma\), which keeps \(A\) symmetric. |
green | \(G\) or \(\Gamma\) | The Green operator from set_load: with the uniform mode under stress control, without it under strain control. |
y | \(y\) | The unknown field, with \(\tau=\sqrt g\,y\). |
tau | \(\tau\) | The polarization. The stress is \(\sigma=C^0:e+\tau\). |
E, Sigma | \(\bar E,\ \Sigma\) | The mean strain and the mean stress. Under stress control, E is the starting mean \(S^0:\Sigma\), and the strain subtracts \(S^0:\langle\tau\rangle\), so that \(\langle\sigma\rangle=\Sigma\) at every iteration. |
u, e, s | \(\tilde u,\ e,\ \sigma\) | Displacement, compatible strain and stress, all from tau. |
law | The error in the local law, divided by the size of the load. |
Each iteration adds \(C^0\) times the current residual to \(y\), then rebuilds the fields and runs the stopping rule.
def solve_polarization_fixed_point(cell, g, kind, load, max_iterations=20000, control='stress'):
"""g = h for the exact limit. g = (1 - v) h (void) or (1 - 1/v) h (rigid) for a finite contrast v."""
Sigma, E, green = set_load(cell, load, control, g)
keep = material_region(g)
A, factor = polarization_operator(cell, g, kind, green)
b = factor*E
y, u = np.zeros_like(E), np.zeros((2,) + g.shape, complex)
mean_old = E[:, 0, 0]
for iteration in range(1, max_iterations + 1):
y = y + cell.C(b - A(y))
u_old = u
u, e, s, law = polarization_fields(cell, g, kind, y, E, Sigma)
if finished(cell, u, u_old, mean_old, e, s, law, (Sigma, E), keep):
break
mean_old = e.mean(axis=(1, 2))
else:
not_converged(f'fixed point ({kind})', iteration)
return e, s, iteration
The docstring above gives a finite stiff example that interpolates the compliance. The runs on this page instead form f = 1 - h + v*h and pass g = 1 - 1/f for a stiff phase. The two are different diffuse interpolations. The function takes g ready made; its body and stopping rule are the same either way. The rigid limit is the separate compliance endpoint, g = h.
cell, g, kind, load, controlThe inputs, as in Method C. E comes from set_load.
A, factor\(A,\ \pm\sqrt g\)From polarization_operator.
b = factor*E\(b\)The right-hand side.
y\(y_k\)The unknown, starting at 0.
y += cell.C(b − A(y))\(y_{k+1}=y_k+P:r_k\)The whole step: the residual, multiplied by P = C⁰.
u_old, mean_oldThe displacement and mean strain of the last iteration.
u, e, s, law\(\tilde u,\ e,\ \sigma\)The fields of the current y, from polarization_fields.
finishedThe stopping rule. At the cap, not_converged warns.
e, s, iteration\(e,\ \sigma\)The result.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
solve_polarization_fixed_point | The solver: cell, g, kind, load, max_iterations and control mean the same as in Method C. | |
Sigma, E, green, keep | From set_load and material_region. | |
A, factor | \(A,\ \pm\sqrt g\) | The operator and the factor in \(b\), from polarization_operator. |
b | \(b\) | The right-hand side, factor*E. |
cell.C(b - A(y)) | \(P:r_k\) | The residual \(r_k=b-Ay\), multiplied by \(P=C^0\). This is the whole step. |
u, e, s, law | The fields of the current y, from polarization_fields. | |
u_old, mean_old | The displacement and the mean strain of the last iteration, for the stopping rule. | |
iteration | The iterations used. At the cap of 20000, not_converged warns. |
The equation and the stopping rule are the same. Only the update changes: the steps are the ones in the fold above, and each iteration applies \(A\) once. A guard skips the step when nothing is left to solve, which happens with a zero load or a uniform cell, where the residual is zero from the start.
def solve_polarization_cg(cell, g, kind, load, max_iterations=20000, control='stress'):
"""The same equation A y = b, by conjugate gradients."""
Sigma, E, green = set_load(cell, load, control, g)
keep = material_region(g)
A, factor = polarization_operator(cell, g, kind, green)
y, u = np.zeros_like(E), np.zeros((2,) + g.shape, complex)
r = factor*E
p, rr = r.copy(), dot(r, r)
rr0, done = rr, False
mean_old = E[:, 0, 0]
for iteration in range(1, max_iterations + 1):
q = A(p)
curvature = dot(p, q)
exact = rr <= 1e-26*rr0 or curvature <= 0 # nothing left to solve (a zero load, or a uniform cell): a step would divide by 0
if not exact:
a = rr/curvature
y, r = y + a*p, r - a*q
rr_new = dot(r, r)
p, rr = r + (rr_new/rr)*p, rr_new
u_old = u
u, e, s, law = polarization_fields(cell, g, kind, y, E, Sigma)
done = finished(cell, u, u_old, mean_old, e, s, law, (Sigma, E), keep)
if done or exact:
break
mean_old = e.mean(axis=(1, 2))
if not done:
not_converged(f'cg ({kind})', iteration)
return e, s, iteration
A, b\(A,\ b\)The operator and the right-hand side, as in the fixed point. q = A(p) is the one application per iteration.
y → u, e, s, law\(y_k\)The unknown, starting at 0, and its fields from polarization_fields.
finishedThe stopping rule, with u_old and mean_old. If it never passes, not_converged warns.
r\(r_k=b-Ay_k\)The residual. It starts at b.
a\(\alpha_k=r\cdot r/(p\cdot q)\)The step length. It moves y along p and r along q.
e, s, iteration\(e,\ \sigma\)The result.
rr, rr_new\(r_k\cdot r_k,\ \beta_k\)The size of the residual before and after the step, and their ratio β.
p\(p_k\)The search direction: r plus β times the old p.
q = A(p)\(A\,p_k\)The one operator application in each iteration.
rr0, curvature, exactThe guard: when the residual is 10⁻²⁶ of its start, or the curvature p·q is not positive, no step is taken.
Arrows show what feeds what. Dashed blue boxes are what we give the code, green boxes are what it returns, and the orange box is the stopping rule. Every name, including the ones left out of the chart, is in the table.
| In the code | Symbol | Meaning |
|---|---|---|
solve_polarization_cg | The solver, with the same arguments as the fixed point: cell, g, kind, load, max_iterations and control. Sigma, E, green, keep, A and factor are set up in the same way. | |
y | \(y_k\) | The unknown, starting at 0. |
r | \(r_k\) | The residual. It starts at \(b\), because \(y_0=0\). |
p | \(p_k\) | The search direction. |
rr, rr_new | \(r_k\cdot r_k,\ r_{k+1}\cdot r_{k+1}\) | The size of the residual before and after the step, using dot. |
q | \(A\,p_k\) | The one operator application in each iteration. |
a | \(\alpha_k\) | The step length. |
rr_new/rr | \(\beta_k\) | The weight of the old direction in the new one. |
rr0, curvature, exact | The starting residual, the curvature \(p\cdot A\,p\), and the guard: when the residual has fallen to \(10^{-26}\) of its start or the curvature is not positive, nothing is left to solve, and a step would divide by zero. The fields are still built and tested. | |
u, e, s, law, u_old, mean_old | The fields of the current y, and the displacement and mean strain of the last iteration, as in the fixed point. | |
done, iteration | Whether the rule passed, and the iterations used. If the rule did not pass, not_converged warns, at the cap or after the guard. |
At m = N/2 the mode is cos(πNx). On the grid it is +1, −1, +1, −1.
Its derivative is −πN sin(πNx), which is 0 at every grid point. So a first derivative uses k = 0 here.
Every derivative in these solvers is a first derivative, so they all use this rule. The fields stay real.
The second derivative is −(πN)² cos(πNx), which is not 0. So the Cahn–Hilliard Laplacian keeps this term.
An FFT splits the grid into smaller parts. With N = 2ⁿ every split is even. The cost grows as N log N.
pyFFTW calls the FFTW library through a NumPy-compatible interface. The name numpy_fft is the interface; the transforms run in FFTW.
Timings from an older machine do not carry over.
The first-derivative rule is Algorithm 1 in Johnson’s notes on FFT-based differentiation.
We use the circular-inclusion geometry of Fig. 1 of Bhattacharyya, Heo, Chang and Chen (2012) with this page's matrix and the mean stress \(T=\Sigma_{xx}=160\) MPa. The grid and the area-equivalent radius of each run are read from its saved field. The matrix here has \(\nu=1/3\) and \(\kappa=3-4\nu=5/3\).
A sharp disk in an infinite plate has an exact solution. Let \(f\) be the stiffness of the disk divided by that of the matrix, with the same \(\nu\), and let \(\rho=R/r\). On the \(y\) axis, outside the disk, the stress along the load is
As \(f\to0\) we get \(\alpha=-T/2\) and \(\gamma=-T/4\), which is Kirsch’s solution for a hole. As \(f\to\infty\) we get the rigid limit, \(\alpha=mT/2\) and \(\gamma=T/(4\kappa)\).



Largest recorded section discrepancy beyond \(1.25R\), normalized by the applied reference stress. The last column shows the normalized soft/void peak or finite-stiffness center stress, with its sharp reference in brackets. Ideal-rigid internal stress is not used as an accuracy test. Area fractions are 0.44% and 1.91%; area-equivalent radii are 38.5 and 79.7 nm. Periodic images can contribute to the mismatch, but these two calculations do not separate them from diffuse-width, discretization and residual solver effects.
| \(R\) | Inclusion | Iterations | Y (GPa) | Largest discrepancy beyond \(1.25R\) | Peak / center (sharp) |
|---|---|---|---|---|---|
| \(R\approx38.5\) nm | Void | 207 | 236.85 | 0.65% | 2.63 |
| \(R\approx38.5\) nm | Contrast 0.01 | 54 | 236.95 | 0.63% | 2.58 |
| \(R\approx38.5\) nm | Contrast 0.001 | 130 | 236.86 | 0.64% | 2.63 |
| \(R\approx38.5\) nm | Ideal rigid compliance limit | 65 | 241.65 | 0.40% | excluded: ideal rigid internal stress |
| \(R\approx38.5\) nm | Finite stiffness ratio 100 | 40 | 241.80 | 9.25% | 1.415 (1.460) |
| \(R\approx38.5\) nm | Finite stiffness ratio 1000 | 88 | 241.92 | 14.22% | 1.393 (1.466) |
| \(R\approx79.7\) nm | Void | 237 | 227.04 | 2.69% | 2.81 |
| \(R\approx79.7\) nm | Contrast 0.01 | 54 | 227.43 | 2.61% | 2.74 |
| \(R\approx79.7\) nm | Contrast 0.001 | 132 | 227.08 | 2.68% | 2.80 |
| \(R\approx79.7\) nm | Ideal rigid compliance limit | 60 | 247.24 | 1.70% | excluded: ideal rigid internal stress |
| \(R\approx79.7\) nm | Finite stiffness ratio 100 | 38 | 247.52 | 4.52% | 1.440 (1.460) |
| \(R\approx79.7\) nm | Finite stiffness ratio 1000 | 91 | 247.81 | 6.73% | 1.434 (1.466) |
The limits of this comparison. The exact solutions have a sharp interface, an infinite plate and one disk. Ours has a diffuse interface, so the peak at the edge of the disk is smoothed. The stress inside a stiff or rigid disk is not uniform here, and in the exact rigid limit it is not unique, because the interior can hold any self-balanced stress. Our box is periodic, so the images of the disk enter as \((R/L)^2\).
FFT crystal plasticity extends the Moulinec–Suquet method to polycrystals, starting with Lebensohn (2001), who compares it with a self-consistent model of the kind in Lebensohn and Tomé (1993). Later work adds elasticity to the same framework, for example Lebensohn, Kanjarla and Eisenlohr (2012).
Complete notebooks are available on request: request details. Code use: teaching, learning and demonstration only. Any other use requires my written permission.