lattice-inverse-design
Skill16 starsChanged 16 days agoMITView on GitHub
Design 3D-printable lattice unit cells for a target stiffness — TPMS and hybrid-TPMS implicit cells, printability checks (one connected solid, no sealed cavities, periodic), voxel homogenisation of the full 6x6 stiffness (checked against exact solutions), parametric inverse search, a GLU3D-style stiffness-conditioned 3D diffusion model with surrogate guidance, and watertight tiled STL export. Based on GLU3D (Barati Farimani Lab). Use when someone needs a lightweight infill, core, or architected material with given E/G (isotropic or anisotropic), wants to compare TPMS against strut lattices, or wants to train a generative lattice model on their own cells.
In this repository34 other files it gives its agents.
- skills/cadsmith-text-to-cad/references/agents.mdAGENTS.md
- agentscad-fdm-dfamSkill
- am-alloy-screeningSkill
- am-literature-ragSkill
- cadsmith-text-to-cadSkill
- cfd-simulation-setupSkill
- design-review-packageSkill
- dfm-reviewSkill
- drawing-gdt-reviewSkill
- engineering-calc-reportSkill
- equation-discoverySkill
- image2gcodeSkill
- linkage-synthesisSkill
- llm-3d-print-monitorSkill
- llm-mechanical-designerSkill
- lpbf-defect-predictionSkill
- lpbf-superresSkill
- machine-element-sizingSkill
- material-selectionSkill
- mechanical-teardownSkill
- mechanics-visualsSkill
- meltpool-geometrySkill
- parametric-part-cadSkill
- query2cad-freecadSkill
- quick-feaSkill
- rocketsmithSkill
- sketch-to-cadSkill
- sls-process-optimizationSkill
- stress-field-surrogateSkill
- thermal-fluids-calcSkill
- thermal-porositySkill
- tolerance-stackupSkill
- worked-problem-generatorSkill
- my-new-skillSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Ask for E (or E1, E2, E3), optionally G, and either a density budget or "as light as possible".
- Distinctive: line 28
Ask for the process and its minimum wall or strut thickness, and the cell size.
- Very specific: line 68
Check printability in the slicer: minimum wall, and whether trapped powder or resin can drain.
- Distinctive: line 82
every void region must open to the faces, so there are no sealed cavities.
- Very specific: line 89
Use search for real designs until you have paper-scale data and a GPU.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Lattice inverse design (GLU3D)
GLU3D (Jadhav et al., Adv. Funct. Mater. 34 (2024) 2404165) works like this:
- It builds a dataset of unit cells from implicit equations: 22 TPMS families, plus hybrids that blend 2–4 families (Eqs. 3–7).
- It homogenises each cell to its 6 × 6 stiffness matrix.
- It trains a 3D conditional DDPM that turns a target stiffness into a new cell's implicit field. A tanh scaling (Eq. 9) keeps the surface at level set 0, which raised mesh yield from 33–51% to 100%.
- Printed PLA cells followed the requested modulus.
scripts/glu3d.py covers the whole loop. Everything except the neural models runs on numpy and
scipy; scikit-image and trimesh are needed for meshes, pyamg is optional for speed, and PyTorch is
needed for the models. Paper numbers and the interpretation choices are in
references/paper-notes.md.
Stiffness is relative to the solid (E/Es) unless you pass --Es. The cell is one period of
side 1; choose its printed size at export.
Workflow
- Pin down the target.
- Ask for E (or E1, E2, E3), optionally G, and either a density budget or "as light as possible".
- Ask for the process and its minimum wall or strut thickness, and the cell size. Convert walls to the cell scale: 0.5 mm walls in a 10 mm cell is 0.05 of the cell.
- Express targets relative to the solid: printed PLA ≈ 3.5 GPa, Ti-6Al-4V LPBF ≈ 110 GPa.
- Try a known cell first (seconds):
python scripts/glu3d.py families python scripts/glu3d.py cell --families gyroid --h 0.25 --png g.png python scripts/glu3d.py cell --families gyroid,primitive --mode H2 --t 0.3 --h 0.2 python scripts/glu3d.py cell --families gyroid --h 0.25 --freq 2,2,1 # anisotropic: E3 ≈ 2.8 E1 python scripts/glu3d.py compare --cells '[["gyroid sheet", {"families":["gyroid"]}]]' --png cmp.pngcellreports the printability checks, the periodicity error, the full C^H, E1–E3, G, ν, the Zener anisotropy ratio and the weakest and strongest directional modulus.comparesweeps the thickness against simple-cubic and BCC strut lattices.
- Inverse design without a GPU:
search --target E=0.08,G=0.03 [--data ds.npz] [--density-weight 0.2].- It ranks dataset cells (or random ones) by mean |log error| against the target.
- It then refines the thickness
hand biasaof the best three by re-homogenising. - This is the dependable route for one-off designs.
- Generative route (paper):
python scripts/glu3d.py dataset --n 3000 --res 65 --hres 32 --out ds.npz # paper: 3723 cells, 64^3 python scripts/glu3d.py train-surrogate --data ds.npz --out sur.pt python scripts/glu3d.py train --data ds.npz --out glu3d.pt --size 64 --chans 1,4,8,16,32,64 --surrogate sur.pt --device cuda python scripts/glu3d.py generate --model glu3d.pt --target E=0.1,G=0.04 --vfrac 0.3 --n 8 --steps 100 python scripts/glu3d.py evaluate --gen generated.npz --data ds.npz # success, periodicity, Dice/Chamfer/Hausdorff, FEM error- The defaults match the paper: cosine schedule, T = 500, Huber loss, 20% unconditional
training, stiffness entries standardised to mean 50, φ̂min = 0.75, and an ancestral DDPM
sampler with 500 steps (
--steps 100 --eta 0for fast DDIM). - The networks train on the periodic grid with circular padding, so generated cells are
exactly periodic. Other small-data fixes are listed in
references/paper-notes.md. - Generation also conditions on volume fraction by default, because the paper names its absence
as the reason high-modulus targets failed. Use
--paper-condfor the paper's stiffness-only setting. --guidance > 1turns on classifier-free guidance.- Always re-homogenise the generated cells (
evaluatedoes this) and keep only those that hit the target. The surrogate is for guidance, not for acceptance.
- The defaults match the paper: cosine schedule, T = 500, Huber loss, 20% unconditional
training, stiffness entries standardised to mean 50, φ̂min = 0.75, and an ancestral DDPM
sampler with 500 steps (
- Export:
stl --npz generated.npz --index 2 --cell-mm 10 --tiles 4,4,4 --out part.stl, orcell --spec '<spec JSON from search>' --stl part.stl --cell-mm 10 --tiles 4,4,4.- The mesh is watertight and capped at the boundary, with volume ≈ vfrac × box (tested).
- Check printability in the slicer: minimum wall, and whether trapped powder or resin can drain.
The
dfm-revieworagentscad-fdm-dfamskills can help.
Judgement calls
- Elastic only. C^H is the small-strain stiffness. The paper's claims about energy absorption and peak load came from compression tests. For crash or impact use, test coupons or run nonlinear FEA.
- Hand over the directional modulus, not just E1. A simple-cubic lattice has a high axial E, but
it is very weak in shear and off-axis (see
compare). - Resolution. The node grid is what you print. The voxel grid used for homogenisation needs at
least 3–4 voxels through each wall.
cell_stiffnessfalls back to full resolution if coarsening loses material. 24³ is within about 1% of 32³ for a gyroid at vf 0.25. - Printability filters, used for the dataset and for search:
- the solid must be one periodic piece that reaches every face;
- every void region must open to the faces, so there are no sealed cavities;
- 0.05 < vf < 0.95;
- Dice > 0.75 against an accepted cell counts as a duplicate.
- Cost and data. A 32³ homogenisation takes about 5–10 s on a laptop CPU, and a 24³ one about
3 s. The paper's 64³ DDPM took 16 h on 4 GPUs with 3723 cells.
- A CPU rehearsal with 300 cells at 16³ produces periodic but unusable cells: stiffness error of about 200%.
- Use
searchfor real designs until you have paper-scale data and a GPU.
Cite: Jadhav, Berthel, Hu, Panat, Beuth, Barati Farimani, Generative Lattice Units with 3D Diffusion for Inverse Design: GLU3D, Adv. Funct. Mater. 34 (2024) 2404165.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

