stress-field-surrogate
Skill16 starsChanged 16 days agoMITView on GitHub
Predict full 2D von Mises stress fields from geometry, supports and loads in milliseconds for design iteration — StressD-style conditional diffusion (normalised field + scale network) or a direct regression baseline, a built-in plane-stress Q4 FEM generator for training data (checked against beam theory), and validation on unseen geometries with MAE, MSE and peak-stress error. Based on StressD (Barati Farimani Lab). Use when FEA is too slow inside a design loop, for generative/topology design screening, or to build an FEA surrogate for a part family.
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
- lattice-inverse-designSkill
- 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
- 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
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 45
Don't use surrogate output for a safety factor.
≈ “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
Stress-field surrogate (StressD)
StressD (Jadhav et al., CMAME 416 (2023) 116343) generates von Mises stress maps from a 5-channel input: geometry, support x/y and load x/y. It has two parts:
- a conditional diffusion model that produces the field normalised per sample;
- an auxiliary network that predicts the scale.
On Nie et al.'s cantilever dataset it cut MAE by about 78% compared with StressNet and StressGAN.
scripts/stressd.py reproduces the pipeline and adds a FEM data generator, so you can train on your
own part family. It needs numpy and scipy; the models need PyTorch. Paper numbers and the split
caveat are in references/paper-notes.md.
Workflow
- Data.
python scripts/stressd.py dataset --out cant.npz [--geoms 80 --angles 72 --mags 20]- Generates cantilever geometries in 6 families (plain, holes, notches, tapered, slots, truss openings) on a 32 × 24 grid, clamped on the left and loaded at a tip pad over 0–355° and 5–100 N.
- The plane-stress Q4 FEM uses E = 200 GPa, ν = 0.3, t = 1 mm, 1 mm elements. It is linear, so each geometry costs 2 solves however many load cases you want.
- The FEM matches Euler–Bernoulli bending stress within 1% on slender strips (tested).
- For your own parts, replace
random_geometrywith your parametric family, or rasterise CAD sections.
- Train.
train --data cant.npz --model diffusion --out sd.ptis StressD: cosine schedule, T = 500, L1 noise loss, and a ViT scale network on 4 × 4 patches.--model regressionis a direct U-Net baseline (StressNet-like).- Use
--split geometry(the default). The paper's 80/20 random split shares geometries between train and test. Since stress is linear in load, a geometry seen under other loads is nearly free to predict. Only unseen geometries test a design surrogate.
- Predict and score.
python scripts/stressd.py predict --model sd.pt --data cant.npz --out pred.npz --steps 50 python scripts/stressd.py metrics --pred pred.npz # MAE, MSE, peak-stress abs. error, MAPE (paper's metrics) python scripts/stressd.py plot --pred pred.npz --out cases.png - Use in design. Screen many candidate shapes with the surrogate, then confirm the winner
with real FEA (
quick-fea).- Peak stresses near notches and holes are where surrogates err most. Report the peak error alongside the mean.
- Don't use surrogate output for a safety factor.
Notes
- The diffusion sampler is stochastic. Average a few samples, or report spread, for critical regions; the paper averages 3 runs.
femruns a single solve for any 32 × 24 mask image, which is handy for spot checks.
Cite: Jadhav et al., StressD, Comput. Methods Appl. Mech. Engrg. 416 (2023) 116343.
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.

