INHOMOGENEOUS ELASTICITY · HOMOGENIZATION

How do we pull on a periodic box?

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.

The puzzle

1

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?

2

The average strain

Stretch the box and all its copies together. That is Ē, the homogeneous strain.

Keep changing it until the average stress equals the target.

3

Vacuum makes the surfaces

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.

The words on this page

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.

1

Box, matrix, inclusion

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.

2

Homogenization

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.

3

Homogeneous and periodic strain

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.

4

Local law, local strain

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.

5

Equilibrium, mean stress

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 Σ.

6

Stress control, strain control

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.

7

Reference solid

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.

8

Polarization

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.

9

Green’s function and Γ

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 = Ē − Γ ∗ τ.

10

Contrast, void, rigid

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.

11

Phase field h

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.

One matrix, with physical units

Parameter or conditionValueWhat 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\) nmPeriodic \(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\) nmArea radius from saved \(h\): \(R_{\rm area}=\sqrt{\langle h\rangle L_xL_y/\pi}\)
Stress control\(\Sigma=(160,0,0)\) MPaPrescribe 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\) GPaStress-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 regionsMatrix \(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.

\[p=\frac{1-4\nu}{1-2\nu},\qquad C_{11}=\mu\left[\frac{2(2+A_Z)}{1+A_Z}-p\right],\]\[C_{12}=\mu\left[\frac{2A_Z}{1+A_Z}-p\right],\qquad C_{44}=\mu\frac{2A_Z}{1+A_Z}.\]

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.

The stiffness matrix, and what it must satisfy

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:

\[\begin{pmatrix}\sigma_{xx}\\\sigma_{yy}\\\sigma_{zz}\\\sigma_{yz}\\\sigma_{xz}\\\sigma_{xy}\end{pmatrix}=\begin{pmatrix}C_{11}&C_{12}&C_{12}&0&0&0\\C_{12}&C_{11}&C_{12}&0&0&0\\C_{12}&C_{12}&C_{11}&0&0&0\\0&0&0&C_{44}&0&0\\0&0&0&0&C_{44}&0\\0&0&0&0&0&C_{44}\end{pmatrix}\begin{pmatrix}e_{xx}\\e_{yy}\\e_{zz}\\2e_{yz}\\2e_{xz}\\2e_{xy}\end{pmatrix}.\]

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:

\[\begin{pmatrix}\sigma_{xx}\\\sigma_{yy}\\\sigma_{xy}\end{pmatrix}=\begin{pmatrix}C_{11}&C_{12}&0\\C_{12}&C_{11}&0\\0&0&C_{44}\end{pmatrix}\begin{pmatrix}e_{xx}\\e_{yy}\\2e_{xy}\end{pmatrix},\qquad\sigma_{zz}=C_{12}\left(e_{xx}+e_{yy}\right).\]

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:

\[e_{xx}=\frac{C_{11}\sigma_{xx}-C_{12}\sigma_{yy}}{C_{11}^2-C_{12}^2},\qquad e_{yy}=\frac{C_{11}\sigma_{yy}-C_{12}\sigma_{xx}}{C_{11}^2-C_{12}^2},\qquad 2e_{xy}=\frac{\sigma_{xy}}{C_{44}}.\]

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.

Now you try: a film on a substrate

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.

Vacuum stiffness ÷ solid:
Iterations
0
\(\bar E_{11}\)
0
\(\langle\sigma_{11}\rangle\)
0
Largest \(\lvert\sigma_{22}\rvert\)
0

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.

The numerical details

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 ÷ solidIterations\(\bar E_{11}\), solver\(\bar E_{11}\), exactLargest \(\lvert\sigma_{22}\rvert\)
\(10^{-2}\)5130.09743310.0974331\(3\times10^{-10}\)
\(10^{-3}\)41800.09902740.0990274\(4\times10^{-10}\)

Two ways to hold the load

1

Keep pulling: stress constraint

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.

2

Pull, then clamp: strain constraint

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.

Can we also pull across the vacuum?

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.

1

A hole: pull every way

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.

2

Layers: pull across

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.

3

Layers: clamp across

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.

The numbers behind these pictures

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.

CaseVacuum / solidMean sigma22 in box (MPa)Mean sigma22 in vacuum (MPa)Largest |e22| in vacuumMean sigma22 in solid (MPa)Iterations
Hole, stress target0.011608.1110.002229182.4338
Hole, stress target0.0011601.120.003091183.42549
Hole, clamp0.0169.484.530.000629978.92336
Hole, clamp0.00168.80.60790.0010178.722575
Layers, stress target0.011601600.0496160644
Layers, stress target0.0011601600.49961606531
Layers, clamp0.014.5014.5010.00060924.501279
Layers, clamp0.0010.47860.47860.00067610.47861553

What does our direct method do? Soft vacuum

1

A nearly empty solid

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 Ē.

2

The price

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 ÷ solidIterations\(\langle e_{xx}\rangle\times10^4\)\(Y\) (GPa)
0.1456.944230.40
0.013217.031227.58
0.00119107.042227.22
0, method C2037.043227.18

Make me softer, and the iterations keep growing.

The answer settles as you soften, but true vacuum is out of reach this way.

The update, from our direct solver

# <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.

Method A: the code

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, iteration
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
solve_directMethod 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.
lawZero: 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, iterationThe previous mean strain for the rule, and the iterations used.
Reference stiffness and mean-strain correction: what we measured

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).

ContrastReferenceReference factorMean correctionIterationsY (GPa)Relative difference from CG
0.01midpoint0.505S0610227.574.61e-06
0.01midpoint0.505Cavg242227.572.51e-08
0.010.75 max0.75S0352227.572.89e-08
0.010.75 max0.75Cavg352227.572.9e-08
0.01max1S0470227.572.91e-08
0.01max1Cavg470227.572.91e-08
0.001midpoint0.5005S06085227.214.73e-06
0.001midpoint0.5005Cavg1813227.217.85e-08
0.0010.75 max0.75S02703227.218.05e-08
0.0010.75 max0.75Cavg2703227.218.05e-08
0.001max1S03605227.218.04e-08
0.001max1Cavg3605227.218.04e-08
100midpoint50.5S0494247.865.1e-05
100midpoint50.5Cavg20000, not convergedundefined—
1000.75 max75S0736247.865.11e-05
1000.75 max75Cavg541247.848.32e-09
100max100S0982247.865.16e-05
100max100Cavg721247.848.27e-09
1000midpoint500.5S04943248.355.08e-05
1000midpoint500.5Cavg20000, not convergedundefined—
10000.75 max750S07409248.355.08e-05
10000.75 max750Cavg5437248.348.43e-09
1000max1000S09880248.355.08e-05
1000max1000Cavg7243248.348.37e-09
1000.25 max25S020000, not convergedundefined—
1000.25 max25Cavg20000, not convergedundefined—
1000.375 max37.5S020000, not convergedundefined—
1000.375 max37.5Cavg20000, not convergedundefined—
1000.5 max50S020000, not converged247.841.45e-10
1000.5 max50Cavg20000, not convergedundefined—
10000.25 max250S020000, not convergedundefined—
10000.25 max250Cavg20000, not convergedundefined—
10000.375 max375S020000, not convergedundefined—
10000.375 max375Cavg20000, not convergedundefined—
10000.5 max500S020000, not converged248.344.06e-10
10000.5 max500Cavg20000, not convergedundefined—
0.01<f>0.98132S0462227.572.88e-08
0.01<f>0.98132Cavg462227.572.88e-08
0.001<f>0.98115S03537227.218.04e-08
0.001<f>0.98115Cavg3537227.218.04e-08
100<f>2.8678S020000, not convergedundefined—
100<f>2.8678Cavg20000, not convergedundefined—
1000<f>19.848S020000, not convergedundefined—
1000<f>19.848Cavg20000, not convergedundefined—

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.

One iteration, many variants

The same iteration can be extended to new problems. Each of these papers changes something:

PaperWhat 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

The same form: Lippmann–Schwinger, step by step

We write everything with indices. Repeated indices are summed, and a comma means a derivative.

Step 1: Split the stiffness

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:

\[\epsilon_{kl}=\bar E_{kl}+\tfrac12\left(u_{k,l}+u_{l,k}\right),\qquad \sigma_{ij}=C_{ijkl}\epsilon_{kl}=C^0_{ijkl}\epsilon_{kl}+\tau_{ij},\]
\[\tau_{ij}=\Delta C_{ijkl}\,\epsilon_{kl}.\]

With no imposed eigenstrain, the stiffness inhomogeneity is represented by one field, the polarization \(\tau_{ij}\).

Step 2: Equilibrium in Fourier space

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\):

\[Q_{ik}\,\tilde u_k=\mathrm i\,k_j\,\tilde\tau_{ij},\qquad Q_{ik}=C^0_{ijkl}k_jk_l,\qquad \tilde u_k=\mathrm i\,\Omega_{ki}\,k_j\,\tilde\tau_{ij},\quad \Omega=Q^{-1}.\]

Step 3: From displacement to strain

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:

\[\tilde\epsilon_{kl}=-\tilde\Gamma_{klij}\,\tilde\tau_{ij},\qquad \tilde\Gamma_{klij}=\tfrac12\left(k_l\Omega_{ki}+k_k\Omega_{li}\right)k_j.\]

Adding back the average at \(\mathbf k=0\) gives the Lippmann–Schwinger equation:

\[\epsilon_{kl}(\mathbf x)=\bar E_{kl}-\left(\Gamma_{klij}*\tau_{ij}\right)(\mathbf x).\]

Step 4: Why the two iterations are the same

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

\[\tilde\Gamma_{klij}C^0_{ijmn}\tilde\epsilon_{mn}=\tfrac12\left(k_l\Omega_{ki}+k_k\Omega_{li}\right)\,\mathrm i\,Q_{im}\tilde u_m=\tfrac{\mathrm i}{2}\left(k_l\tilde u_k+k_k\tilde u_l\right)=\tilde\epsilon_{kl},\quad \mathbf k\neq 0,\]

because \(\Omega_{ki}Q_{im}=\delta_{km}\). So \(\Gamma*(C^0:\epsilon)=\epsilon-\bar E\), and therefore

\[\epsilon^{n}-\Gamma*\sigma^{n}=\epsilon^{n}-\left(\epsilon^{n}-\bar E\right)-\Gamma*\tau^{n}=\bar E-\Gamma*\tau^{n}.\]

The right side is our direct update. One iteration, written two ways, with \(C^0\) as the mean of the phases in both.

Step 5: The same thing in two-dimensional components

\[Q_{11}=C^0_{11}k_1^2+C^0_{44}k_2^2,\quad Q_{22}=C^0_{44}k_1^2+C^0_{11}k_2^2,\quad Q_{12}=\left(C^0_{12}+C^0_{44}\right)k_1k_2,\]
\[\tilde u_1=\mathrm i\left[\Omega_{11}\left(k_1\tilde\tau_{11}+k_2\tilde\tau_{12}\right)+\Omega_{12}\left(k_1\tilde\tau_{12}+k_2\tilde\tau_{22}\right)\right],\]
\[\tilde u_2=\mathrm i\left[\Omega_{12}\left(k_1\tilde\tau_{11}+k_2\tilde\tau_{12}\right)+\Omega_{22}\left(k_1\tilde\tau_{12}+k_2\tilde\tau_{22}\right)\right].\]
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.

The catch: the Nyquist mode on an even grid

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.

Scope of this discretization

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.

The Nyquist illustration, in the old units

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.

TestNyquist keptNyquist 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.

Method B: the augmented Lagrangian

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.

1

Two strains that disagree

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.

2

A rubber band alone

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.

3

A multiplier alone

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.

4

Both together

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.

5

In a void: no 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.

6

In a rigid inclusion: no strain

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.

Now you try: two strains, one band

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\).

Joined by:
Stiffness \(C\):
Band stiffness:
Rounds
0
Gap \(\lvert e-d\rvert\)
0
\(\lambda\)
0
Stress \(C\,d\)
0
This toy in equations

With band stiffness \(r\), the toy uses the same terms as the formal definition below:

\[L=\tfrac12(e-1)^2+\tfrac12Cd^2+\lambda(e-d)+\tfrac12r(e-d)^2.\]

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\).

The formal definition

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\):

\[\min_{\boldsymbol{e}}\ \left\langle\tfrac12\,\boldsymbol{e}:\boldsymbol{C}:\boldsymbol{e}\right\rangle.\]\[\min_{e}\ \left\langle\tfrac12 e_{ij}C_{ijkl}e_{kl}\right\rangle.\]

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:

\[\min_{\boldsymbol{e},\,\boldsymbol{d}}\ \left\langle\tfrac12\,\boldsymbol{d}:\boldsymbol{C}:\boldsymbol{d}\right\rangle\quad\text{subject to}\quad\boldsymbol{e}(x)=\boldsymbol{d}(x).\]\[\min_{e,\,d}\ \left\langle\tfrac12 d_{ij}C_{ijkl}d_{kl}\right\rangle\quad\text{subject to}\quad e_{ij}(x)=d_{ij}(x).\]

There is one constraint for each component at each point, so we add one multiplier field \(\lambda_{ij}(x)\). This gives the Lagrangian:

\[L_0=\left\langle\tfrac12\,\boldsymbol{d}:\boldsymbol{C}:\boldsymbol{d}\right\rangle+\left\langle\boldsymbol{\lambda}:\left(\boldsymbol{e}-\boldsymbol{d}\right)\right\rangle.\]\[L_0(e,d,\lambda)=\left\langle\tfrac12 d_{ij}C_{ijkl}d_{kl}\right\rangle+\left\langle\lambda_{ij}\left(e_{ij}-d_{ij}\right)\right\rangle.\]

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:

\[L=L_0+\tfrac12\left\langle\left(\boldsymbol{e}-\boldsymbol{d}\right):\boldsymbol{C}^0:\left(\boldsymbol{e}-\boldsymbol{d}\right)\right\rangle,\]\[L(e,d,\lambda)=L_0(e,d,\lambda)+\tfrac12\left\langle\left(e_{ij}-d_{ij}\right)C^0_{ijkl}\left(e_{kl}-d_{kl}\right)\right\rangle,\]

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:

\[\boldsymbol{e}^{n+1}=\bar{\boldsymbol{E}}-\boldsymbol{\Gamma}*\left(\boldsymbol{\lambda}^{n}-\boldsymbol{C}^0:\boldsymbol{d}^{n}\right).\]\[e^{n+1}_{kl}=\bar E_{kl}-\Gamma_{klij}*\left(\lambda^{n}_{ij}-C^0_{ijmn}d^{n}_{mn}\right).\]

Minimize \(L\) over \(d\). No derivative of \(d\) appears, so this is a small local problem at each point:

\[\left(\boldsymbol{C}+\boldsymbol{C}^0\right):\boldsymbol{d}^{n+1}=\boldsymbol{\lambda}^{n}+\boldsymbol{C}^0:\boldsymbol{e}^{n+1}.\]\[\left(C_{ijkl}+C^0_{ijkl}\right)d^{n+1}_{kl}=\lambda^{n}_{ij}+C^0_{ijkl}e^{n+1}_{kl}.\]

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\):

\[\boldsymbol{\lambda}^{n+1}=\boldsymbol{\lambda}^{n}+\boldsymbol{C}^0:\left(\boldsymbol{e}^{n+1}-\boldsymbol{d}^{n+1}\right).\]\[\lambda^{n+1}_{ij}=\lambda^{n}_{ij}+C^0_{ijkl}\left(e^{n+1}_{kl}-d^{n+1}_{kl}\right).\]

Where we impose the void and the rigid inclusion. Both live in the local step, and they mirror each other.

  • Void: zero stress. We set \(C=0\), so the local step gives \(C^0_{ijkl}d^{n+1}_{kl}=\lambda^{n}_{ij}+C^0_{ijkl}e^{n+1}_{kl}\). Putting this in the update gives \(\lambda^{n+1}_{ij}=0\). The stress is zero at every iteration, with no soft solid and no tolerance, and the strain \(d\) is free. What must still converge is the match \(e=d\).
  • Rigid inclusion: zero strain. As \(C\to\infty\), the local step gives \(d^{n+1}_{kl}=0\), so in the code we set \(d=0\) at those points. The strain \(d\) is zero at every iteration, and the stress \(\lambda\) is free: the update becomes \(\lambda^{n+1}_{ij}=\lambda^{n}_{ij}+C^0_{ijkl}e^{n+1}_{kl}\), which keeps changing until \(e\) also reaches 0. We cannot get this stress from \(C:d\), which would be \(\infty\cdot0\). It is \(\lambda\).

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:

\[\langle\boldsymbol{e}\rangle^{n+1}=\langle\boldsymbol{d}\rangle^{n}+\tfrac1\beta\,\boldsymbol{S}^0:\left(\boldsymbol{\Sigma}-\langle\boldsymbol{\lambda}\rangle^{n}\right).\]\[\langle e_{kl}\rangle^{n+1}=\langle d_{kl}\rangle^{n}+\tfrac1\beta\,S^0_{klij}\left(\Sigma_{ij}-\langle\lambda_{ij}\rangle^{n}\right).\]

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\).

Method B: the code

Using this code. Copy these snippets for learning, teaching and demonstration. For any other use, please email me with what you need it for.

Code request details

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.

  • contrast 0.01, stress control, grid 256: smallest observed count 72 at \(\beta=0.1\)
  • contrast 100, stress control, grid 256: smallest observed count 76 at \(\beta=5\)
  • rigid, stress control, grid 256: smallest observed count 853 at \(\beta=2\)
  • void, stress control, grid 256: smallest observed count 3835 at \(\beta=0.1\)
  • contrast 0.01, strain control, grid 256: smallest observed count 99 at \(\beta=0.2\)
  • contrast 100, strain control, grid 256: smallest observed count 71 at \(\beta=5\)
  • rigid, strain control, grid 256: smallest observed count 653 at \(\beta=2\)
  • void, strain control, grid 256: smallest observed count 3613 at \(\beta=0.1\)
Main stress-table limitRecorded band factorIterations
rigid AL2.0378
void AL0.1902

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, stress137729423847494623614718
contrast 100, stress5564278313935582801407680
rigid, stress20000, not converged1230261522462123285324934174
void, stress4216383576811921020000, not convergednot runnot runnot 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, strain2061069923747193723394674
contrast 100, strain5503275313775522761387177
rigid, strain20000, not converged1302665142607130465313862727
void, strain4598361372231805620000, not convergednot runnot runnot 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 five normalizations, exactly as in finished()

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.

\[r_u=\frac{\operatorname{RMS}_{\cal R}(u^{n+1}-u^n)}{aL/(2\pi)}\lt 10^{-5},\qquad r_{\bar E}=\frac{\lVert\langle e^{n+1}\rangle-\langle e^n\rangle\rVert_F}{a}\lt 10^{-5}.\]\[r_\Sigma=\frac{\lVert\langle s\rangle-\Sigma\rVert_F}{\lVert\Sigma\rVert_F}\lt 10^{-4}\quad\text{(stress control only)}.\]

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.

\[r_{\rm div}=\frac{\operatorname{RMS}_{\cal R}(\nabla\cdot s)}{(2\pi/L)\sqrt{\langle s_{xx}^2+s_{yy}^2+2s_{xy}^2\rangle_{\cal R}}}\lt 10^{-4}.\]

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.

Compare the stopping tests on the same recorded iterates

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.

CaseCommon rule: iterationRelative modulus changeSplit/law 1e-4: iterationRelative modulus changeSplit/law 1e-5: iterationRelative modulus changeGap at common stopLaw at common stop
void38359.13e-0633391.1e-05not reached—7.86e-058.26e-05
rigid8531.14e-067651.32e-06not reached—8.8e-058.8e-05
contrast 0.01723.13e-08771.68e-081009.08e-100.0001430.000154
contrast 100803.88e-08461.62e-06642.16e-072.1e-062.1e-06
  • void: common rule 3835, paper-style 1e-4 3339, paper-style 1e-5 not reached; relative modulus change from the common-rule stop to the final recorded state 9.13e-06
  • rigid: common rule 853, paper-style 1e-4 765, paper-style 1e-5 not reached; relative modulus change from the common-rule stop to the final recorded state 1.14e-06
  • contrast 0.01: common rule 72, paper-style 1e-4 77, paper-style 1e-5 100; relative modulus change from the common-rule stop to the final recorded state 3.13e-08
  • contrast 100: common rule 80, paper-style 1e-4 46, paper-style 1e-5 64; relative modulus change from the common-rule stop to the final recorded state 3.88e-08
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
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
solve_augmented_lagrangianThe 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.
keepThe 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_iterationsThe 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.
weightThe 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, iterationThe 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.
lawThe error in the local law at each point, which finished tests after scaling by the size of the load.
finishedThe 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.

Method A and method B on a Cahn–Hilliard inclusion

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.

ContrastA: \(\langle e_{xx}\rangle\times10^4\)A: Y (GPa)A: iterationsB: \(\langle e_{xx}\rangle\times10^4\)B: Y (GPa)B: iterations
0.16.944230.40456.944230.4026
0.017.031227.583217.031227.5873
0.0017.042227.2219107.042227.22220
106.493246.42546.493246.4228
1006.456247.845676.456247.8481
10006.443248.3356936.443248.33246

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.

Why not a multiplier on the stress or strain itself?

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.

1

A void: ask for zero stress

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.

2

A rigid inclusion: ask for zero strain

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:

\[\boldsymbol{e}=\bar{\boldsymbol{E}}-\boldsymbol{\Gamma}*\left(\chi\,\boldsymbol{\tau}\right),\qquad\boldsymbol{\sigma}=\boldsymbol{C}^0:\boldsymbol{e}+\chi\,\boldsymbol{\tau}.\]\[e_{kl}=\bar E_{kl}-\Gamma_{klij}*\left(\chi\,\tau_{ij}\right),\qquad\sigma_{ij}=C^0_{ijkl}e_{kl}+\chi\,\tau_{ij}.\]

Rigid inclusion: a multiplier on the strain. We minimize the energy over compatible strains, with \(e=0\) inside as the constraint:

\[L=\left\langle\tfrac12\,\boldsymbol{e}:\boldsymbol{C}^0:\boldsymbol{e}\right\rangle+\left\langle\chi\,\boldsymbol{\tau}:\boldsymbol{e}\right\rangle.\]\[L=\left\langle\tfrac12 e_{ij}C^0_{ijkl}e_{kl}\right\rangle+\left\langle\chi\,\tau_{ij}e_{ij}\right\rangle.\]

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

\[\chi\,\boldsymbol{\Gamma}*\left(\chi\,\boldsymbol{\tau}\right)=\chi\,\bar{\boldsymbol{E}}.\]\[\chi\,\Gamma_{klij}*\left(\chi\,\tau_{ij}\right)=\chi\,\bar E_{kl}.\]

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:

\[L^{*}=\left\langle\tfrac12\,\boldsymbol{\sigma}:\boldsymbol{S}^0:\boldsymbol{\sigma}\right\rangle+\left\langle\chi\,\boldsymbol{\eta}:\boldsymbol{\sigma}\right\rangle-\bar{\boldsymbol{E}}:\langle\boldsymbol{\sigma}\rangle.\]\[L^{*}=\left\langle\tfrac12 \sigma_{ij}S^0_{ijkl}\sigma_{kl}\right\rangle+\left\langle\chi\,\eta_{ij}\sigma_{ij}\right\rangle-\bar E_{ij}\langle\sigma_{ij}\rangle.\]

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

\[\chi\left(\boldsymbol{S}^0:\chi\,\boldsymbol{\tau}-\boldsymbol{\Gamma}*\left(\chi\,\boldsymbol{\tau}\right)\right)=-\chi\,\bar{\boldsymbol{E}}.\]\[\chi\left(S^0_{klij}\,\chi\,\tau_{ij}-\Gamma_{klij}*\left(\chi\,\tau_{ij}\right)\right)=-\chi\,\bar E_{kl}.\]

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.

What if the band acts on the constraint itself?

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.

How to cite this page

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/
The same citation in BibTeX
@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.

How we make the inclusion: Cahn–Hilliard

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.

1

Two parabolas, two wells

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.

2

Let it relax

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.

3

Stretch it to 0 and 1

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.

4

How empty is the void?

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 equations and the settings

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\):

\[F=\int\left(f(c)+\kappa\lvert\nabla c\rvert^2\right)dx,\qquad\frac{\partial c}{\partial t}=M\,\nabla^2\left(f^{\prime}(c)-2\kappa\nabla^2c\right).\]

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\):

\[\left(1+\Delta t\,k^2\left(S+2\kappa k^2\right)\right)\tilde c^{\,n+1}=\left(1+\Delta t\,k^2S\right)\tilde c^{\,n}-\Delta t\,k^2\,\widetilde{f^{\prime}(c^n)}.\]

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.

Code request details

The code

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)
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
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.
pointsGrid points over which \(c\) goes from 0.01 to 0.99.
supersaturationThe 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.
gridPoints 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, YGrid 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.
denominatorThe implicit part of the step.
scaled\(\hat c\)The rescaled composition, exactly 0 at its smallest and 1 at its largest.

Put it together

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)
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
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.
iterationsThe iterations the solver used.

Method C: the hard constraint

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.

1

Void: the unknown is strain

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.

2

Rigid disk: the unknown is stress

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.

3

No multiplier

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.

4

One iteration

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.

The two problems

With a prescribed mean stress \(\Sigma\), the mean strain is free and the load does work:

\[\text{Void:}\quad\min_{\boldsymbol{e}\ \text{compatible}}\ \left\langle\tfrac12\,\boldsymbol{e}:(1-h)\boldsymbol{C}^0:\boldsymbol{e}\right\rangle-\boldsymbol{\Sigma}:\langle\boldsymbol{e}\rangle,\qquad\boldsymbol{\sigma}=(1-h)\boldsymbol{C}^0:\boldsymbol{e}.\]\[\text{Rigid:}\quad\min_{\boldsymbol{\sigma}\ \text{in equilibrium},\ \langle\boldsymbol{\sigma}\rangle=\boldsymbol{\Sigma}}\ \left\langle\tfrac12\,\boldsymbol{\sigma}:(1-h)\boldsymbol{S}^0:\boldsymbol{\sigma}\right\rangle,\qquad\boldsymbol{e}=(1-h)\boldsymbol{S}^0:\boldsymbol{\sigma}.\]

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.

Code request details

Step 1: a cell that knows \(\Gamma\)

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
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
fftwThe 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.0The 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, zeroThe 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, likeTurns 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, gWhere 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_ofThe 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, iterationThe warning every solver gives when it leaves its loop before all tests pass: at the cap, or when rounding leaves nothing to solve.
finishedThe 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, divThe 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}\).

Step 2: the hard-constraint solver

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
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
solve_hard_constraintThe 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.
keepThe 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_iterationsThe cap, 20000.
local, v\((1-h)C^0\) or \((1-h)S^0\)The local law, applied point by point to a field v.
gradientThe gradient of the energy at x.
project, g\(G\) or its dualSends 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, rho0The 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.
exactTrue 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 strainThe 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.
lawThe error in the local law at each point, passed to finished after scaling by the size of the load.
done, iterationWhether 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.
Step 3: the same problem by MINRES

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']
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
solve_hard_constraint_minresThe solver, with the same arguments as Step 2: cell, h, kind, load, max_iterations and control. n is the grid size.
Sigma, E, green, keepFrom set_load and material_region, as in Step 2.
LinearOperatorTells SciPy how to apply our matrix without storing it.
minresThe MINRES solver in scipy.sparse.linalg. rtol is its own tolerance, set small so that finished decides when to stop.
FinishedAn 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, vConvert 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.
fieldsTurns 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.
stateA small dictionary that keeps the latest displacement, mean strain, iteration count and solution between calls, and whether the rule passed.
watchCalled 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.

Why conjugate gradients or MINRES, and not a fixed point?

1

Fixed point

Each step uses only the current residual. The slowest modes set the rate, so iterations grow with the contrast κ.

2

Conjugate gradients

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.

3

MINRES

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.

4

When a fixed point is still useful

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.

New to these solvers? Start here

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:

\[\text{Void:}\quad P\,q\,P\,w=P\big[h\,(C^0)^{-1/2}:\Sigma\big],\qquad\text{Rigid:}\quad Q\,q\,Q\,w=-Q\big[q\,(C^0)^{-1/2}:\Sigma\big].\]

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:

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:

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.

The fixed point, step by step

Start with \(y_0=0\). Then repeat:

\[r_k=b-A\,y_k,\qquad y_{k+1}=y_k+P:r_k.\]

\(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.

Conjugate gradients, step by step

Start with \(y_0=0\), \(r_0=b\) and \(p_0=r_0\). Then repeat:

  1. Step length: \(\alpha_k=\dfrac{r_k\cdot r_k}{p_k\cdot A\,p_k}\).
  2. Move: \(y_{k+1}=y_k+\alpha_k\,p_k\).
  3. New residual: \(r_{k+1}=r_k-\alpha_k\,A\,p_k\).
  4. Next direction: \(\beta_k=\dfrac{r_{k+1}\cdot r_{k+1}}{r_k\cdot r_k}\), \(\quad p_{k+1}=r_{k+1}+\beta_k\,p_k\).

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.

MINRES, step by step

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:

  1. Build the next basis vector (Lanczos). \(w=A\,v_k-\beta_k\,v_{k-1}\), \(\ \alpha_k=v_k\cdot w\), \(\ w\leftarrow w-\alpha_k\,v_k\), \(\ \beta_{k+1}=\lVert w\rVert\), \(\ v_{k+1}=w/\beta_{k+1}\). In this basis, \(A\) is tridiagonal.
  2. Keep that matrix triangular. Apply the last two plane rotations to the new column \((\beta_k,\alpha_k,\beta_{k+1})\), giving \((\varepsilon_k,\delta_k,\bar\gamma_k,\beta_{k+1})\). Then choose a new rotation with \(\gamma_k=\sqrt{\bar\gamma_k^2+\beta_{k+1}^2}\), \(\ c_k=\bar\gamma_k/\gamma_k\), \(\ s_k=\beta_{k+1}/\gamma_k\).
  3. Update the residual size. \(\phi_k=c_k\bar\phi_k\), \(\ \bar\phi_{k+1}=s_k\bar\phi_k\). The residual norm is \(\lvert\bar\phi_{k+1}\rvert\), so we know it without computing \(b-A\,y_k\).
  4. Update the solution. \(d_k=\left(v_k-\varepsilon_k\,d_{k-2}-\delta_k\,d_{k-1}\right)/\gamma_k\), \(\ y_k=y_{k-1}+\phi_k\,d_k\).

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).

Every solver on the same inclusion

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.

Every grid-512 stress-controlled result

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)IterationsConverged
direct 0.16.944230.4045yes
CG 0.16.944230.4021yes
fixed point 0.16.944230.4050yes
AL 0.16.944230.4026yes
direct 0.017.031227.58321yes
CG 0.017.031227.5855yes
fixed point 0.017.031227.58336yes
AL 0.017.031227.5873yes
direct 0.0017.042227.221910yes
CG 0.0017.042227.22130yes
fixed point 0.0017.042227.221736yes
AL 0.0017.042227.22220yes
direct 106.493246.4254yes
CG 106.493246.4215yes
fixed point 106.493246.4245yes
AL 106.493246.4228yes
direct 1006.456247.84567yes
CG 1006.456247.8439yes
fixed point 1006.456247.84287yes
AL 1006.456247.8481yes
direct 10006.443248.335693yes
CG 10006.443248.3387yes
fixed point 10006.443248.331456yes
AL 10006.443248.33246yes
void MINRES7.043227.18203yes
void CG7.043227.181034yes
void hard CG7.043227.1820000, not convergedno
void AL7.043227.18902yes
void fixed point7.043227.18642yes
rigid MINRES6.473247.1661yes
rigid CG6.473247.16258yes
rigid hard CG6.473247.16221yes
rigid AL6.473247.16378yes
rigid fixed point6.473247.16653yes

All 34 rows are shown, including the ones at the cap. The 20,000-iteration cap is never interpreted as convergence.

Every grid-512 fixed-strain result

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)IterationsConverged
direct 0.16.667305.1545yes
CG 0.16.667305.1522yes
fixed point 0.16.667305.1552yes
AL 0.16.667305.1437yes
direct 0.016.667299.88328yes
CG 0.016.667299.8857yes
fixed point 0.016.667299.88357yes
AL 0.016.667299.86105yes
direct 0.0016.667299.181965yes
CG 0.0016.667299.18134yes
fixed point 0.0016.667299.181924yes
AL 0.0016.667299.17322yes
direct 106.667327.8753yes
CG 106.667327.8716yes
fixed point 106.667327.8745yes
AL 106.667327.8728yes
direct 1006.667329.47556yes
CG 1006.667329.4738yes
fixed point 1006.667329.47285yes
AL 1006.667329.4780yes
direct 10006.667330.055577yes
CG 10006.667330.0587yes
fixed point 10006.667330.051421yes
AL 10006.667330.05242yes
void MINRES6.667299.10202yes
void CG6.667299.101436yes
void hard CG6.667299.1012524yes
void AL6.667299.101008yes
void fixed point6.667299.10676yes
rigid MINRES6.667328.6562yes
rigid CG6.667328.65227yes
rigid hard CG6.667328.65197yes
rigid AL6.667328.65317yes
rigid fixed point6.667328.65628yes

All 34 rows are shown, including the ones at the cap. The 20,000-iteration cap is never interpreted as convergence.

Compare stopping status with measured field accuracy

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 caseIterationsConvergedRelative mean-strain differenceRelative stress differenceRelative strain difference
void MINRES111yes8.696e-050.004660.01982
void hard CG695yes2.077e-050.0015080.00509
void CG602yes2.511e-050.0017770.00632
void fixed point894yes0.00023590.0062640.02644
void AL743yes0.00010.0048280.02059
rigid MINRES49yes3.889e-050.010890.002781
rigid hard CG69yes2.148e-050.0091350.002614
rigid CG98yes2.138e-050.009140.002618
rigid fixed point1155yes5.084e-050.0094340.002847
rigid AL539yes2.765e-050.0096910.002468
direct 0.01199yes7.205e-071.212e-056.012e-05
CG 0.0155yes2.454e-091.307e-059.86e-05
fixed point 0.01343yes1.671e-061.494e-050.0001443
AL 0.0169yes1.012e-062.405e-052.746e-05
direct 0.0011264yes1.356e-062.834e-050.0001207
CG 0.001118yes1.54e-082.256e-050.0003121
fixed point 0.0011908yes3.51e-066.607e-050.0002882
AL 0.001215yes8.294e-071.889e-056.643e-06
direct 10020000, not convergednoundefinedundefinedundefined
CG 10035yes6.943e-090.00036173.332e-05
fixed point 100268yes2.48e-060.0012394.812e-05
AL 10072yes5.58e-062.485e-051.546e-05
direct 100020000, not convergednoundefinedundefinedundefined
CG 100070yes1.191e-070.0037760.0001291
fixed point 10001089yes1.022e-050.012140.000336
AL 1000222yes6.072e-064.327e-051.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.

The polarization code

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.

Code request details

The operator

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:

\[\text{Void:}\quad S^0:y-\sqrt g\,\Gamma*\left(\sqrt g\,y\right)=-\sqrt g\,\bar E.\]\[\text{Rigid:}\quad(1-g)\,S^0:y+\sqrt g\,\Gamma*\left(\sqrt g\,y\right)=\sqrt g\,\bar E.\]

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)
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
polarization_operator, polarization_fieldsThe 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.
lawThe error in the local law, divided by the size of the load.

The fixed point

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.

Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
solve_polarization_fixed_pointThe solver: cell, g, kind, load, max_iterations and control mean the same as in Method C.
Sigma, E, green, keepFrom 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, lawThe fields of the current y, from polarization_fields.
u_old, mean_oldThe displacement and the mean strain of the last iteration, for the stopping rule.
iterationThe iterations used. At the cap of 20000, not_converged warns.

Conjugate gradients

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
Names in this code

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.

Every name, in a table
In the codeSymbolMeaning
solve_polarization_cgThe 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, exactThe 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_oldThe fields of the current y, and the displacement and mean strain of the last iteration, as in the fixed point.
done, iterationWhether the rule passed, and the iterations used. If the rule did not pass, not_converged warns, at the cap or after the guard.

Nyquist, \(2^n\) grids and pyFFTW

1

The Nyquist mode

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.

2

First and second derivatives

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.

3

Grids of \(2^n\) points

An FFT splits the grid into smaller parts. With N = 2ⁿ every split is even. The cost grows as N log N.

4

pyFFTW

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.

How close are we to the sharp-interface solutions?

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

\[\kappa=3-4\nu,\qquad m=\frac{\kappa-1}{2},\qquad\alpha=m\,\frac T2\,\frac{f-1}{f+m},\qquad\gamma=\frac T4\,\frac{f-1}{f\kappa+1},\]\[\sigma_{xx}=T-\alpha\rho^2-6\gamma\rho^4.\]

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)\).

Stress sections normalized by applied stress for the saved smaller diffuse disk and the isolated sharp-circle reference.
Grid 1024, \(R\approx38.5\) nm, prescribed mean stress 160 MPa. Symbols are computed periodic diffuse fields and lines are isolated sharp-interface references. The normalized void peak is 2.63; its sharp boundary value is 3. This difference contains diffuse-interface, grid, solver and boundary-condition contributions. 6 of 6 returned profile states met the rule.
Normalized stress sections for the saved larger diffuse disk and the isolated sharp-circle reference.
Grid 1024, \(R\approx79.7\) nm. The measured normalized void peak is 2.81. The finite periodic cell is not an isolated infinite plane; the interface width and grid representation also differ from a sharp analytical boundary. 6 of 6 returned profile states met the rule.
Normalized void stress against r/R for two saved radii. Computed peaks: 2.63 and 2.81; sharp boundary value 3.
The void stress section plotted against distance divided by radius. Smaller-disk peak 2.63 at r/R 1.05; larger-disk peak 2.81 at r/R 1.02. Holding a transition width in cells does not hold its width relative to radius fixed. This is a model comparison, not a pure solver-error measurement.

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\)InclusionIterationsY (GPa)Largest discrepancy beyond \(1.25R\)Peak / center (sharp)
\(R\approx38.5\) nmVoid207236.850.65%2.63
\(R\approx38.5\) nmContrast 0.0154236.950.63%2.58
\(R\approx38.5\) nmContrast 0.001130236.860.64%2.63
\(R\approx38.5\) nmIdeal rigid compliance limit65241.650.40%excluded: ideal rigid internal stress
\(R\approx38.5\) nmFinite stiffness ratio 10040241.809.25%1.415 (1.460)
\(R\approx38.5\) nmFinite stiffness ratio 100088241.9214.22%1.393 (1.466)
\(R\approx79.7\) nmVoid237227.042.69%2.81
\(R\approx79.7\) nmContrast 0.0154227.432.61%2.74
\(R\approx79.7\) nmContrast 0.001132227.082.68%2.80
\(R\approx79.7\) nmIdeal rigid compliance limit60247.241.70%excluded: ideal rigid internal stress
\(R\approx79.7\) nmFinite stiffness ratio 10038247.524.52%1.440 (1.460)
\(R\approx79.7\) nmFinite stiffness ratio 100091247.816.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\).

The same idea elsewhere

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.