Multi-Material Topology โ
Finds where each of several materials goes in a solid, and where none is needed. Model a block - the space the structure may take up - in SSP Bricks or tetrahedra, support it and load it as usual, give the component two or more materials and the share of the volume each may fill, and it finds the layout that makes the block as stiff as possible: which part to keep, and of which material.
It is Topology Optimisation with a choice of materials. Read that page first: the model, the run, Keep, Step and AlpacaModel work the same way here.
๐ง Grasshopper component โ


KeepSolids to keep as modelled, of their own material, whatever the optimisation finds: by ElementId, tag or pattern.
MaterialsThe Elastic Isotropic materials to choose from, two or more.
VolumeFractionsThe share of the designed solids' volume each material may fill, one per material in the order of Materials; a shorter list repeats its last value.
IterationsHow many iterations at most.
true runs the optimisation, false pauses it.StepWhich iteration's design the outputs show: 0 the one the run starts from, 1 after the first iteration, and so on.
In the Settings menu:
| Input | Default | Description |
|---|---|---|
| Penalty | 3 | The penalty n: an element's stiffness takes each material's share to the power n, which pushes it to all or nothing. |
| PNorm | 6 | The p of the interpolation's p-norm: the larger, the more an element that mixes materials is penalised. 6 balances a clear result against a steady run; much larger makes the run unsteady. |
| FilterRadius | 2 elements | How far the densities are averaged over, in model units: about the thinnest member, and the thinnest layer of one material, the result can have. |
| Tolerance | 0.001 | Once the projection is at its sharpest, the run stops when the compliances of the last five iterations add up to within this share of the five before. Made smaller after a run, the run goes on from where it stopped. |
| MinStiffness | 1e-9 | The stiffness a void element keeps, as a share of the stiffest material's. |
| Move | 0.1 | The most a density can change in one iteration. |
| Threshold | 0.5 | The density of its material from which an element counts as that material, for Surface, Solid, Material and AlpacaModel. It changes nothing in the run. |
| System | Auto | The system of equations, as in Analysis Settings. |
SurfaceThe outline of each material: one closed mesh per material, in the order of Materials.
SolidThe solids that make the design, as new copies of the model's, each of the material it ended as - the solids in Keep of their own.
-1 where it is void or left out.true when the run ended at the sharpest projection with the compliance settled within Tolerance.It takes the assembled model and works on its solids, as Topology Optimisation does. Every solid gets a density of every material, and its stiffness mixes the materials' Young's moduli so that an element of one material alone pays least. Each iteration analyses the model and moves every density by MMA, the method of moving asymptotes, so that the model gets stiffer while each material stays within its share.
Nothing is ever cut out of the mesh. An element with no material keeps a billionth of the stiffest material's stiffness, so the model keeps all its nodes and connections.
What it does not do โ
- Only the Young's moduli count. Every solid keeps the Poisson's ratio of the material it was modelled in; the Poisson's ratios of Materials are not used. The component says so when they differ.
- Only stiffness is optimised. A material strong in tension goes where its stiffness pays, not where the tension is: give it steel and concrete and it will not put the steel in the ties and the concrete in the struts. The materials differ here by how stiff they are and how much of each you allow, nothing else.
Which elements โ
The same as Topology Optimisation: SSP Bricks, solved as OpenSees' eight point brick, and Ten Node Tetrahedra. Every solid needs an Elastic Isotropic material. Beams, trusses, shells and links are analysed with the solids but take no part.
โ๏ธ How it works โ
It follows Zheng, Yi, Peng and Yoon (2024), who extend the 88 line code to several materials with the mapping-based interpolation of Yi et al.
Densities. Every element e has a density x of every material i, between 0.001 and 1, all starting at 0.5.
Filter. Each material's densities are averaged over the elements within FilterRadius, as in Topology Optimisation, so that the result is members rather than a checkerboard.
Projection. The averaged densities xฬ are pushed towards 0 or 1 by a smoothed step, r = (tanh(ฮฒฮท) + tanh(ฮฒ(xฬ โ ฮท))) / (tanh(ฮฒฮท) + tanh(ฮฒ(1 โ ฮท))), with ฮท = 0.5. Its sharpness ฮฒ starts at 1 and doubles every 50 iterations up to 32, from iteration 251, so the design starts soft and ends nearly solid or void.
Interpolation. An element's modulus is
E = ฮฃแตข ฯแตขโฟ (Eแตข โ E_void) + E_void, with ฯแตข = rแตข ยท โrโโ / (โrโโ + ฮด)
ฯแตข is rแตข when the element has material i alone; when it mixes materials, the p-norm over the 1-norm makes each share count for less, so mixing does not pay. n is Penalty and p is PNorm.
Update. Each material has a volume limit of its own: ฮฃ vยทr of material i at most its share of the designed volume. Several limits are more than the optimality criteria of Topology Optimisation can take, so the densities are moved by MMA (Svanberg 1987), as the paper does. The compliance's derivatives come from each element's strain energy in OpenSees, through the interpolation, the projection and the filter.
Stopping. Some density moves by the full move limit in every iteration, even at the end, so the run stops on the compliance instead: once ฮฒ is 32, when the last five compliances add up to within Tolerance of the five before, the test BESO Topology uses.
Note
Give it 300 iterations. The design only becomes clear once the projection is sharp, after iteration 200 or so. A run of fewer iterations ends grey, with most elements a little of everything.
Without a license, Multi-Material Topology runs on models of up to 500 elements, counting any beams, shells and links with the solids, as Topology Optimisation does, and the design it finds is analysed and drawn free up to the same 500. A larger model needs one: see License.
How long it takes โ
Each iteration is an analysis, as long as one of Topology Optimisation, and an update by MMA, which takes longer the more materials and elements there are. The 27 000 bricks of the benchmark below took about 1.5 s of analysis and 1 to 3 s of update per iteration in the test bench, on an Apple M2 Pro, so its 300 iterations took about a quarter of an hour.
Example โ
The Multi-Material Bridge example is the block of the Topology Bridge - 16 m long, 2 m wide and 4 m high, pinned along both ends of its bottom, its top layer a deck kept solid under 10 kN/mยฒ - in steel and concrete, with at most 5% of the block below the deck in steel and 15% in concrete. The concrete goes into two broad legs from the supports to the deck; the steel into an arch slung under the middle of the deck. 3 456 bricks, 265 iterations, under a minute. Its last group analyses the design from AlpacaModel, each brick of its material.
The Truss Node and the Beam-Column Joint examples find a node where members meet in space - nine members of a space truss, a column and four beams - with all three topology optimisations side by side.
๐งช Checked against the papers โ
MMA. Svanberg's own test problem, from his note on MMA and GCMMA: every iterate is his table's to its four decimals, ending at fโ = 8.7702.
The derivatives. The compliance's derivatives by every kind of density, worked out through OpenSees, match central differences to about 1e-7, at a soft projection and a sharp one.
The paper's 3D cantilever. Zheng et al.'s cantilever on the grid of their Appendix B, 60 x 30 x 15 bricks, held at one end and loaded along the bottom edge of the other, with half the volume shared equally among the materials, filter radius 5 and 300 iterations:
Materials E Compliance The paper's Apart 2 1 and 5 437.50 432.94 +1.1% 3 1, 2 and 5 433.19 433.05 +0.03% 5 1, 2, 3, 4 and 5 400.98 400.24 +0.2% Two MMA codes take slightly different paths through a problem with many local optima, and a percent apart is as close as two of them come. The paper's code also projects the densities with the old sharpness once after each doubling, and has no void stiffness.
The checks and the benchmark are in Alpaca4d.Test/TopologyMethods in the Alpaca4d repository: ./run.sh bench zheng 3 runs the cantilever.
๐ References โ
- R. Zheng, B. Yi, X. Peng, G.-H. Yoon (2024). An efficient code for the multi-material topology optimization of 2D/3D continuum structures written in Matlab. Applied Sciences 14:657. โ the method, which Multi-Material Topology follows.
- K. Svanberg (1987). The method of moving asymptotes - a new method for structural optimization. International Journal for Numerical Methods in Engineering 24:359โ373.
- K. Svanberg (2007). MMA and GCMMA - two methods for nonlinear optimization. KTH, Stockholm. โ the MMA written here, equation by equation.
- F. Wang, B. S. Lazarov, O. Sigmund (2011). On projection methods, convergence and robust formulations in topology optimization. Structural and Multidisciplinary Optimization 43:767โ784. โ the projection.
- T. E. Bruns, D. A. Tortorelli (2001). Topology optimization of non-linear elastic structures and compliant mechanisms. Computer Methods in Applied Mechanics and Engineering 190:3443โ3459. โ the density filter.
Alpaca4d adds what a model drawn in Grasshopper needs, as in Topology Optimisation: elements of different sizes count by their volume, solids can be kept, and the energies come from OpenSees' element forces. The paper's code projects the densities with the old sharpness once after each doubling; here they are projected with the new one.
