haibarakiku/abaqus-ml-skills/abaqus-surrogate-fea-validation
Claude Code and agent skill by haibarakiku/abaqus-ml-skills
- community
Checking that the SKILL.md file is still in the repository.
Closed-loop inverse-design validation. Given a target deformation field, solve the inverse problem on a trained surrogate (Ridge / linear), then run an Abaqus FEA verification and compare surrogate-predicted vs. true displacement field. Reports MSE / MAE / max-abs-error / NRMSE side-by-side, plus saturated-channel count, so you can quantify the surrogate-FEA gap. Use when the user wants to evaluate "is my surrogate good enough for inverse design?", "how big is the surrogate-FEA gap on this target?", "did the optimizer find a real solution or just a surrogate hallucination?"
Install
npx vskill@latest install haibarakiku/abaqus-ml-skills/abaqus-surrogate-fea-validationSKILL.md
The same SKILL.md was published earlier as haibarakiku/abaqus-ml-skills/abaqus-surrogate-fea-validation.
Abaqus Surrogate ↔ FEA Validation Loop
Closes the verification loop on a surrogate-driven inverse design. Surrogates are fast but optimistic — they extrapolate, hallucinate, and reward saturated solutions that the real FEA cannot reproduce. This skill forces a side-by-side comparison between what the surrogate thinks it found and what Abaqus actually delivers, on the same target shape.
When to Use This Skill
Activate when the user wants to:
- Sanity-check a surrogate that was just trained ("is the model trustworthy?")
- Quantify the surrogate-FEA gap on a fixed set of validation targets before publishing claims
- Compare optimizer choices (PGD vs. L-BFGS-B vs. multi-start) under equal-FEA-budget conditions
- Generate a reproducible benchmark table for a paper / report
- Debug why an optimizer's surrogate solution looks great but FEA verification fails
Do NOT use this skill for:
- Forward-only FEA runs without a surrogate (use
abaqus-lhs-batch-dataset) - Surrogate training (this skill assumes
X_amplitude.csv+Y_grid_uz.csvalready exist; pair with the dataset / grid skills upstream) - Real-time hardware-in-the-loop (FEA validation is too slow; use a different loop)
The Loop
The key signal is the gap between surrogate_metrics and true_metrics. A small gap means the surrogate is faithful; a large gap means it's overfitting or extrapolating into unphysical regions.
Required Inputs
The user must provide:
- Aggregated training data (typically from the
abaqus-odb-to-grid-csvskill upstream):
X_amplitude.csv—sample_id, amplitude_0000..amplitude_(D-1)Y_grid_uz.csv—sample_id, uz_0000..uz_(N²-1)
- Target shape file(s) — one or more N×N CSV / TXT matrices of the desired deformation field. Common formats:
- Plain matrix CSV (no header, N rows × N columns)
- Headered CSV with
uz_0000..uz_(N²-1)columns (single row)
- `template_dir/` + `solver_script.py` — same as the
abaqus-lhs-batch-datasetskill. Required for the FEA verification step.
- Design bounds
[bounds_min, bounds_max](e.g.[-0.5, +0.5]) — must match the bounds the training data was sampled from. Mismatched bounds will produce saturated solutions that the FEA cannot realize.
- Target peak amplitude — most published targets are normalized. Scale them to a peak the surrogate's training range can actually produce (e.g.
target_peak = 2.5mm if training data uz spans ±3 mm).
The 4 Inverse Solvers
For a linear Ridge surrogate y_std = z @ W, the inverse problem is convex quadratic. Pick the solver based on your needs:
| Solver | When to use | Iters / cost | Notes | |
|---|---|---|---|---|
| PGD | Fastest, deterministic, no scipy needed | 1200 fixed steps | Good baseline; sensitive to lr. Default for stdlib-only environments. | |
| L-BFGS-B | Best convergence per iteration; needs scipy | ~50-200 iters | Initialize from closed-form solution; converges in O(D) on linear surrogates. Recommended default. | |
| multistart L-BFGS-B | Avoids saddle / boundary local minima | n_starts × ~100 iters | Use when D is large (>50) or bounds are tight (saturated_channels > D/4). | |
| Nelder-Mead | Derivative-free fallback; debug only | 5000 fevals | Slowest, no gradient; only useful when you suspect bugs in the gradient path. |
For nonlinear surrogates (MLP), only L-BFGS-B and Nelder-Mead are practical (the closed-form initialization step doesn't apply).
Workflow Steps
Step 1 — Fit / load surrogate
The Ridge weights W of shape (D, N²) constitute the standardized linear surrogate.
Step 2 — Per target
For each target file:
- Load matrix, bilinear-resample to the learning grid (
N×N), scale totarget_peak - Flatten + standardize:
y_target_std = (y_target - y_mean) / y_std - Standardize design bounds:
z_lo = (x_lo - x_mean) / x_std, similarlyz_hi - Solve inverse with the chosen solver →
z_sol - Unstandardize:
x_sol = z_sol * x_std + x_mean, then hard-clip to[bounds_min, bounds_max]
Step 3 — Surrogate-side metrics
Step 4 — FEA verification
Step 5 — Side-by-side report
Per target: write summary.csv with both surrogate_* and true_* metrics + saturated_channels + return_code + elapsed_seconds.
Across all targets: aggregate into surrogate_inverse_summary.csv. The columns make a publication table directly:
Critical Implementation Details
1. Standardization MUST be consistent
The same (x_mean, x_std, y_mean, y_std) used during training must be used at validation. Saving them to a .npz next to the trained surrogate avoids skew.
2. Hard-clip after unstandardize
z_sol lives in standardized space and respects (z_lo, z_hi). After converting back to x_sol, always re-clip to [bounds_min, bounds_max] because numerical drift can produce values like 0.5000001 that would crash the FEA's amplitude validation.
3. saturated_channels is the early-warning metric
Count entries within tol=1e-6 of the bounds. If > D/4 channels are saturated, the surrogate is asking the optimizer to extrapolate beyond the training distribution. The FEA will likely diverge or produce nonsense. Lower target_peak and re-run; don't trust either set of metrics in this regime.
4. NRMSE normalization choice
norm_mse = mse / max(|y_target|)² (the target_max_abs mode) makes errors directly comparable across targets of different magnitudes. Always specify the normalization in any reported number. Other valid choices: target_range = max(y_target) - min(y_target).
5. The 4 modes of failure
| Mode | Symptom | Diagnosis | |
|---|---|---|---|
| Surrogate hallucination | small surrogate_mse, large true_mse | Saturated channels, training data too narrow, or nonlinearity not captured | |
| FEA divergence | rc != 0, true metrics = NaN | Amplitudes too aggressive — reduce target_peak or tighten bounds | |
| Both fail | both metrics large | Target shape itself unreachable in the design space; check whether the basis can express it at all | |
| Both succeed but disagree | small surrogate_mse, small true_mse, but predicted-uz heatmap differs from FEA-uz heatmap | Mode-mixing — the L-BFGS-B found a local optimum the surrogate likes but the FEA reaches differently. Try multi-start. |
6. FEA cost dominates total runtime
Surrogate inverse solve takes ~milliseconds. Each FEA verification takes 2-5 minutes. Cache the surrogate fit (write Ridge weights to model_ridge.npz once) and reuse across targets. Do not re-fit on every target.
7. Reproducibility
Set numpy.random.seed(42) for any solver with stochastic initialization (multi-start). Record the seed in summary.csv. Without this, the multi-start results are not reproducible across runs.
Reference Implementation
A complete, dependency-light Python implementation is in references/surrogate_validation.py (~400 lines). It supports all 4 solvers, is parameterized via argparse, and produces the side-by-side summary CSV.
references/inverse_solvers.py — the 4 inverse-solver implementations (PGD pure stdlib + numpy; L-BFGS-B / multi-start / Nelder-Mead via scipy).
Output Schema
The 3 NxN CSVs (target_scaled, predicted_surrogate, predicted_true) are designed for direct heatmap plotting via matplotlib.imshow. Their per-cell errors are the most diagnostic visualization for "is the surrogate trustworthy" questions.
Quick Sanity Checks
After a validation run completes:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/abaqus-surrogate-fea-validation/SKILL.md
Popularity
- Repository stars
- 10
- Repository forks
- 1
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (Cursor)
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/haibarakiku/abaqus-ml-skills/abaqus-surrogate-fea-validation)