Engineers who model soil and rock still spend weeks hand-writing "user material" subroutines. These are small programs that tell a finite element solver how a material yields and flows permanently once it is loaded past its strength. The standard strength law for these materials is the Mohr-Coulomb criterion, which says shear strength grows linearly with confining pressure, $\tau = c + \sigma\tan\phi$, with cohesion $c$ and friction angle $\phi$. In three dimensions its yield surface is a six-sided pyramid with sharp edges and an apex, and those non-smooth points are exactly where implementations break. Language models that write code and repair it from execution feedback have done well on general software. They have not been tried on this code, and the obvious feedback channel is close to useless here. A global solver that diverges reports "maximum Newton iterations exceeded." That message does not say whether the cause is an indexing bug, a wrong derivative, or an apex the code never handled.
This note proposes to replace that feedback with a mechanics-aware grader. The grader drives the generated routine one material point at a time along chosen stress paths, then checks whether the result is physically right, not merely whether it runs. It also sorts every failure into a category with a specific repair target. The main claim is that, for elastoplastic code, the quality and specificity of the feedback matter more than how many agents surround it. We test that claim directly. We also test a narrower hypothesis: separating the agent that writes the mathematical derivation from the agent that writes the code helps only because it makes derivation errors visible to the grader.
Core Claim
We claim that an LLM refinement loop fed by a material-point grader with failure triage will produce correct Mohr-Coulomb-family return-mapping routines far more often than one fed by global solver logs, at equal token budget. "Return mapping" is the standard algorithm that pulls an over-stressed trial state back onto the yield surface. We also claim this grader will push past the three-to-five-iteration plateau that Yan et al. report for compiler-feedback refinement.
The grader has four kinds of check. The first is consistency: after return, the stress must lie on or inside the yield surface. The second checks the envelope directly, $\tau \le c + \sigma\tan\phi$ on every plane. The third compares the routine's tangent stiffness against a finite-difference tangent. A mismatch here is what destroys quadratic Newton convergence in the global solve. The fourth runs targeted stress paths that land in the face, edge, and apex return regions.
Triage then assigns each failure to one of four classes: programming fault, wrong derivation, inconsistent tangent, or unhandled corner. One danger needs its own guard. An agent can "repair" the corner by quietly replacing Mohr-Coulomb with the smooth Drucker-Prager cone. That swap is a legitimate engineering choice made explicitly in WU Li-ming et al. and Wei et al.. It is cheating if it is not declared. The grader therefore measures how far the implemented surface deviates from the specified one. Any smoothing must be declared and must stay within a stated tolerance.
Positioning Against Prior Work
The closest work establishes that solver-in-the-loop generation is feasible but stops short of plasticity. AutoFEA generates CalculiX input decks step by step and repairs them from solver logs. Its tasks are mostly linear elastic, and a single model does the generation. GenCANN has an LLM design physics-constrained neural constitutive laws. Its refinement loop fixes only syntax errors, and the authors explicitly leave plasticity and pressure-dependent yield as future work. FuCe supplies a FEniCS-based hybrid modelling setup we can borrow for the solver side, but it uses no LLM and covers only hyperelastic materials. Firedrake geodynamics automates finite element code through a symbolic compiler. It is a reminder that some derivation work can be mechanized without any LLM, a point we return to below. These four papers motivate the gap and supply the solver infrastructure. None of them grades plasticity code by mechanics.
The multi-agent coding literature supplies the methods we reuse and the failure modes we must avoid. MAGIS and Self-collaboration split work by software role: manager, developer, tester. DRC-Coder separates rule interpretation from programming and checks against golden reports. That design is the nearest analogue to separating derivation from implementation. Adversarial Review shows that reviewers who must cite evidence avoid "false consensus," where agents agree on broken code. It also shows two costs: roughly 4.5 times the tokens of zero-shot generation, and over-editing of working code. MEIC contributes rollback to the last passing state, which we adopt. Two papers constrain the design. Srivastava et al. warn that shallow verifiers let refinement reinforce flaws. SciCode shows frontier models collapsing on chained scientific subproblems. Our tasks are such chains: yield function, flow direction, return region, tangent.
Research Program
The first deliverable is a benchmark of Mohr-Coulomb-family implementation tasks, specified as a set of graded variants. The simplest variants are Mohr-Coulomb with associated flow and with non-associated flow. Harder variants add a tension cutoff, or post-peak softening in which $c$ and $\phi$ decay with plastic strain. That softening addresses the limitation noted by Feng & Yin and Li et al.. Further variants are inscribed and circumscribed Drucker-Prager approximations, effective-stress coupling with pore pressure in the style of Wu et al., and a structural-parameter extension for loess following Wu, Dang, & Li.
Each task comes with an expert reference implementation and hidden material-point tests. Each also comes with two boundary-value checks with known answers. The first is the plastic-zone radius around a circular tunnel, checked against the closed-form elastoplastic solution in Li et al., which reports FLAC3D agreeing with theory to within an average error below 10%. The second is a slope safety factor from strength reduction, checked against the reference implementation and limit equilibrium. Targets are Python routines called from FEniCS and Fortran user-material routines for CalculiX, so everything runs on open solvers.
The second deliverable is the grader and the triage step. Triage classifies a failure by which check fails first. A crash or exception is a programming fault. A trial state returned off the specified surface means the derivation is wrong. A tangent that disagrees with finite differences while the return itself is correct means an inconsistent tangent. Failures confined to paths in the edge or apex regions mean an unhandled corner. We validate triage on a suite of deliberately injected faults before using it in any loop.
The third deliverable is the agent configuration, tested rather than assumed. A derivation agent writes the yield function, flow rule, return regions, and consistent tangent in symbolic form. The grader checks that symbolic form numerically against the specification, on its own and before any code exists. A coding agent then implements it. Triage routes each later failure either back to derivation or to code. A non-editing critic in the style of Adversarial Review may block acceptance, but only by citing a specific failing grader check. We add rollback and a diff-size cap to limit over-editing.
Baselines
The naive reference is one-shot generation by the same backbone model with chain-of-thought prompting, scored by the full grader. It tells us how hard the tasks are. SciCode suggests the answer will be "very": o1-preview passes 7.7% of main problems (SciCode).
The strongest existing method is an AutoFEA-style single-agent loop that repairs code from global solver logs and stdout (AutoFEA). It is the strongest competitor because it is the only published system that closes the loop with a finite element solver. AutoFEA reports a 90.2% success rate with GPT-4o on its CalculiX dataset. That number measures whether generated input decks run successfully on largely linear problems, so it is not comparable to our correctness metric. There is no reported result found on Lacuna for LLM-generated Mohr-Coulomb or return-mapping code. We will therefore rerun this baseline ourselves.
The second competitor is Adversarial Review applied unchanged, with generic code reviewers and no mechanics checks. Its reported numbers are 75.2% on SWE-bench Verified against 71.6% zero-shot, and 87% on LiveCodeBench against 77% (Adversarial Review). The third is best-of-N sampling filtered only by "runs without error."
Every method gets the same backbone model, the same task prompts and specification documents, and an identical cap on total tokens and solver calls. The cap is set by the most expensive method, and cheaper methods spend the surplus on extra samples. Prompt tuning gets the same budget for each method, on a held-out development split.
Two ablations isolate the ingredients. The first gives a single agent the full grader and triage, which separates the value of the feedback from the value of agent roles. The second gives the multi-agent system raw solver logs only. Beating a baseline means a higher rate of fully correct routines on held-out tasks. Fully correct means passing all hidden material-point tests and staying within 2% of the reference on both boundary-value checks. The improvement must be large enough that bootstrap confidence intervals over tasks and seeds do not overlap.
Why not just…?
Why not just use the built-in Mohr-Coulomb model in ABAQUS or FLAC3D? For textbook Mohr-Coulomb, practitioners should. The surveyed geomechanics papers mostly do, and that is why our benchmark weights its scoring toward variants that solvers do not ship: softening, coupled effective stress, loess structural parameters, and custom smoothing. The implementation overhead the file documents is exactly the cost of these custom routines. Plain Mohr-Coulomb remains in the benchmark only as a calibration task.
Why not just run a single agent with an AutoFEA-style solver feedback loop? This is the real threat, and the proposal is built around it. If a single agent with the mechanics grader matches the multi-agent configuration, the contribution is the grader and triage, and we will report it that way. The single-agent-plus-grader ablation decides this. We expect the multi-agent split to help only on tasks dominated by derivation errors, such as non-associated tangents and softening. On those tasks a coder that is also deriving can make its derivation and code agree with each other while both are wrong.
Why not just let symbolic tools derive the tangent, as Firedrake does with weak forms? Automatic differentiation can produce the tangent for the smooth parts of the surface. It does not decide which return region applies, and it does not handle the apex, where the derivative is undefined. Both are where we expect most failures. As an extra arm, we will give every method access to an autodiff tangent helper. If that removes the multi-agent advantage, the tangent-mismatch failure class was the whole story.
Why not just smooth everything to Drucker-Prager? Smoothing changes the material law, and errors in triaxial extension can be large. That is acceptable only when declared and bounded. The surface-deviation check exists so that no method earns credit by silently swapping the law it was asked to implement.
Proposed Experiments
The first experiment validates triage on several hundred faults injected into reference routines, spread across the four failure classes. It reports classification accuracy per class. Triage that cannot tell an inconsistent tangent from an unhandled corner at clearly better than chance would undercut the routing design. If that happens, we would fall back to feeding raw grader output to every agent.
The main experiment runs every method and ablation on the held-out tasks under the matched budget. We report the fully-correct rate, the rate of runs that merely execute (to expose the gap between running and being right), whether the global Newton solve keeps quadratic convergence, and error in plastic radius and safety factor. We also plot correctness against iteration to test whether triage-routed feedback keeps improving after the point where log-fed loops plateau.
A separate analysis counts undeclared Drucker-Prager substitutions and regressions caught by rollback in each method. This tests whether adversarial critics grounded in mechanics avoid both false consensus and over-editing. We repeat the main comparison with a mid-sized open model. Self-collaboration reports that role-play degrades in smaller models, so we check whether the grader's benefit survives where role decomposition fails.
The decisive outcomes fall into three cases. If the grader beats log feedback by a wide margin regardless of agent topology, the main claim holds. If the multi-agent configuration beats single-agent-plus-grader specifically on derivation-heavy tasks, the decomposition hypothesis holds. If neither gap appears, then solver-in-the-loop generation is already adequate for plasticity code, and that negative result is worth publishing for the geomechanics community.
References
- CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translation
- Analysis of Influences of Shield Tunneling Method on the Existing Upper Road Structures
- Research on the Postural Stability of Underwater Bottom Platforms with Different Burial Depths
- AutoFEA: Enhancing AI Copilot by Integrating Finite Element Analysis Using Large Language Models with Graph Neural Networks
- Automating modeling in mechanics: LLMs as designers of physics-constrained neural networks for constitutive modeling of materials
- FUsion-based ConstitutivE model (FuCe): Towards model-data augmentation in constitutive modelling
- Towards automatic finite-element methods for geodynamics via Firedrake
- MAGIS: LLM-Based Multi-Agent Framework for GitHub Issue Resolution
- Self-Collaboration Code Generation via ChatGPT
- DRC-Coder: Automated DRC Checker Code Generation Using LLM Autonomous Agent
- Adversarial Review: Structured Disagreement for Grounded Agentic Code Review
- MEIC: Re-thinking RTL Debug Automation using LLMs
- Do Users Write More Insecure Code with AI Assistants?
- SciCode: A Research Coding Benchmark Curated by Scientists
- Stability and displacement analysis of interlayered soft-hard slopes under seismic loading
- Elastoplastic Solution for Tunnel Composite Support Structures Based on Mohr–Coulomb Criterion
- Numerical Simulation Study of Rainfall-Induced Saturated–Unsaturated Landslide Instability and Failure
- Improvement of Structural Parameters of Loess and Its Relationship with Strength Indicators