Papers
Topics
Authors
Recent
Search
2000 character limit reached

A Constrained Natural-Language Interface for Variational Multi-Physics Finite Element Simulations in FEniCS

Published 9 Jun 2026 in cs.CE, cs.AI, cs.LG, and physics.comp-ph | (2606.10928v1)

Abstract: LLMs can reduce the manual effort required to set up finite element simulations, but they introduce reliability risks when generated solver code lies on the critical path. We present a constrained natural-language interface for multi-physics finite element analysis in which the LLM is limited to front-end tasks: parsing prompts into structured JSON, generating Gmsh code only for non-catalog geometries, and using retry feedback for those stages. It never writes FEniCS solver templates, derives weak forms, or writes the numerical solver core. A deterministic dispatcher maps the validated specification to five human-written FEniCS/UFL templates: linear elasticity, hyperelasticity, elastoplasticity, thermo-mechanical coupling, and phase-field fracture. We validate this deterministic template layer against analytical solutions and published 2D/3D benchmarks. Smooth cases reach sub-percent agreement on adequate meshes, while harder nonlinear cases reach the 2-5 percent range. We also evaluate the LLM-facing front end directly. In a 15-prompt parser benchmark, first-pass valid parses were obtained for 9 cases, and all remaining cases were repaired after retry, giving a final valid parse rate of 100.0 percent, 100.0 percent problem-class accuracy, and 97.1 percent field-extraction accuracy. In a 10-case custom-geometry benchmark routed through the real LLM-to-Gmsh path, first-pass and final success were both 90.0 percent, with one unrecovered invalid-geometry failure. These results show that the parser and constrained prompt/validation design are effective on these benchmarks. As an end-to-end demonstration, the system generates and analyzes a 3D elastoplastic L-bracket with a fillet and bolt hole from one natural-language prompt. The contribution is a measured architecture for natural-language-driven variational simulation, not open-ended autonomous code generation.

Summary

  • The paper introduces a constrained architecture that limits LLM roles to parsing natural-language prompts into structured JSON, preventing unsafe code generation.
  • It employs deterministic, validated backend templates for multi-physics finite element simulations, achieving sub-percent errors in benchmark tests.
  • The system demonstrates robust performance in parser and geometry synthesis, ensuring reproducibility and reliable error correction in FEniCS workflows.

A Constrained Natural-Language Interface for Variational Multi-Physics Finite Element Simulations in FEniCS

Introduction and Context

The paper presents a constrained architecture for interfacing LLMs with multi-physics finite element simulations in FEniCS (2606.10928). Unlike prior approaches that allow LLMs to generate solver or variational code—risking unrecoverable hallucinations and violations of physics constraints—this framework structurally excludes the LLM from the FEniCS/UFL path for form definition, solver logic, or finite element assembly. The LLM is restricted to parsing natural-language prompts into structured JSON specifications, generating Gmsh geometry code for non-catalog shapes, and serving as a front-end agent for error correction via targeted retries. All numerically sensitive operations, including weak form derivation and solver template construction, are deterministic and human-authored. Figure 1

Figure 1: Architecture of the FEniCS agent: natural-language input is parsed into a validated, structured specification, which then proceeds deterministically through template-mapped solver stages.

This architectural constraint directly addresses reliability pathologies observed in LLM-driven code-generation agents in computational science, particularly erroneous or non-physical weak forms, inconsistent constitutive models, and improper boundary condition implementation. The authors systematically delineate the LLM abstraction boundary, exhaustively validate each deterministic backend template on canonical multi-physics benchmarks, and separately assess front-end robustness for parsing and geometry synthesis.

Architectural Design

The system is organized as a strict, modular pipeline with seven stages: natural-language parsing, specification validation, geometry generation, adaptive meshing, deterministic variational template dispatch, solve execution, and postprocessing. Key design features include:

  • LLM Front-End: The LLM (temperature zero) parses engineering prompts into closed-schema JSON, using minimal and transparent inference rules for defaults (e.g., material property assignment based on object class). All suggestions are explicitly recorded and validated.
  • Geometry Handling: Standard geometries are produced by deterministic generators interfacing with Gmsh/OpenCASCADE. Complex or non-catalog shapes invoke an LLM-generated Gmsh script, but with enforced security guards and physical validation (positive volume, valid tags, surface area checks). Retry logic is deployed for correction attempts upon failure.
  • Variational Backend: Five deterministic UFL/FEniCS templates are provided—linear elasticity, compressible Neo-Hookean hyperelasticity, J2 elastoplasticity (with linear isotropic hardening), sequential thermo-mechanical coupling, and AT2 phase-field fracture. Each is mapped via a dispatcher using the problem_class field from the validated specification. There is no LLM influence on weak form construction, function space selection, or solver parameterization. Figure 2

    Figure 2: Variational form generation for elastoplasticity—deterministic mapping from parsed specification to complete FEniCS script; all code and weak form definition is LLM-excluded.

The architecture ensures traceability and robustness. Each pipeline component is testable in isolation, and every stage communicates via the same structured dictionary, simplifying provenance and enabling reproducibility.

Backend Template Validation

Mechanics validation is performed on benchmarks with known analytical or independent numerical reference solutions across all five supported physics classes in two and three dimensions.

Linear Elasticity: Convergence studies on cantilever beams and plate-with-hole problems strictly match beam theory and Kirsch stress-concentration factors, with sub-percent error at moderate mesh density. For a thick-walled Lamé cylinder, maximum von Mises stress converges to <1% error relative to closed-form. Figure 3

Figure 3: 2D convergence: cantilever beam tip deflection and plate-with-hole maximum stress converge numerically to theoretical references.

Figure 4

Figure 4: 3D cantilever beam with quadratic tetrahedral elements: tip deflection and stress at multiple sections match Timoshenko and Euler–Bernoulli theory to sub-percent error.

Hyperelasticity: Cook's membrane with Neo-Hookean constitutive law converges to 0.21% error relative to reference tip displacement at high mesh refinement. A 3D rubber block in compression yields error < 5×10−55 \times 10^{-5}% against closed-form load-displacement response. Figure 5

Figure 5: Hyperelastic Cook’s membrane: non-linear benchmark convergence from 8.79% error on coarse mesh to 0.21% on finest.

Figure 6

Figure 6: 3D rubber block: numerical force matches analytical compressible Neo-Hookean response to machine precision.

Elastoplasticity: Uniaxial tension of a 3D bar with linear hardening is benchmarked, yielding 10−410^{-4}% error in the elastic regime and approximately 5% post-yield due to load-step discretization effects. Figure 7

Figure 7: J2 elastoplasticity: load–displacement curve aligns with analytic elastic and post-yield branches; error spikes only at yield-step transition.

Thermo-Mechanical Coupling: Restrained steel beam under uniform temperature rise matches theoretical thermal stress and temperature field to within 10−310^{-3}%. Figure 8

Figure 8: Uniformly heated beam: simulated stress and temperatures reproduce analytic restrained thermal condition.

Phase-Field Fracture: 2D and 3D SENT benchmarks match Miehe reference fracture onset and peak force to ~2% error. Figure 9

Figure 9: 2D single edge-notched tension: load–displacement and damage field converge with reference solution; phase-field onset displacement error ~2%.

Figure 10

Figure 10: Damage localization at the crack tip in 2D phase-field fracture—corresponds to d→1d \to 1 region.

Figure 11

Figure 11: 3D phase-field damage field; topology reflects correct crack initiation and propagation under plane-strain boundary conditions.

All deterministic template benchmarks achieve quantitative agreement with published references, with sub-percent error in smooth problems and explainable 2–5% errors for strongly nonlinear or path-dependent cases.

Front-End Robustness: Parser and Geometry Generation

Robustness metrics are separately reported for the LLM-driven front-end. In a 15-prompt benchmark for structured specification generation, the first-pass valid parse rate is 60%. Crucially, after up to three retry/repair attempts using targeted validation feedback, the final valid parse rate reaches 100%, with 100% problem-class accuracy and 97.1% field-extraction accuracy. No wrong problem-class assignments are observed in labeled accept cases.

In a 10-case custom geometry benchmark, the LLM-to-Gmsh pipeline achieves 90% first-pass and overall success in geometry synthesis, meshing, and boundary tagging. The only non-recovered failure is an obround-slot geometry, highlighting the limitation of LLM-driven geometry generation for complex CAD-like primitives.

Parametric and Optimization Capabilities

The architecture natively supports Cartesian expansion for parametric studies and gradient-free optimization over low-dimensional design spaces via black-box wrappers and standard optimizer routines. Example use-cases include Pareto frontier exploration for mass-stress tradeoffs in plate-with-hole design and constrained optimization of maximum von Mises stress with respect to feature dimensions. Figure 12

Figure 12: Pareto front in mass–stress space for plate-with-hole geometry: trade-off curve reveals optimal region given design constraints.

Figure 13

Figure 13: Maximum von Mises stress, visualized across design space; independence from thickness at fixed radius is clearly evident.

End-to-End Demonstration: 3D L-Bracket with Custom Geometry

The full pipeline is demonstrated using a detailed natural-language prompt for a 3D L-bracket with a fillet and bolt hole—producing custom geometry via LLM-generated Gmsh code, running 40-step elastoplastic analysis in under 90 seconds, and outputting force-displacement, stress, and accumulated plastic strain fields. Figure 14

Figure 14: L-bracket: (Left) force–displacement with yield and post-yield regimes; (Top right) von Mises stress contours; (Bottom right) plastic strain localized at critical features.

Performance, Robustness, and Limitations

Solve time scales from sub-second for small linear cases to tens of seconds for full elastoplastic or phase-field analyses. Deterministic templates exhibit bit-identical reproducibility in smooth and path-independent regimes, with minor variance only in history-dependent nonlinear solves.

The deterministic, template-based approach eliminates hallucination and reliability risks in solver construction, with the trade-off being the requirement for human addition and validation of new templates for further physics extensions. Geometry generation reliability and parser robustness are currently bottlenecked by the LLM's capacity for complex composition of CAD-like geometries and by prompt sufficiency. Figure 15

Figure 15: Wall-clock breakdown per physics class—nonlinear elastoplastic and phase-field cases are dominated by solve time, whereas orchestration overhead is negligible for large problems.

Implications and Prospects

This framework demonstrates that robust, controlled natural-language-driven finite element simulation is achievable if the LLM is limited to structured front-end roles and deterministic templates are maintained for all weak form and solver logic. This eliminates the core failure modes associated with LLM code hallucination and uncaught specification errors in scientific computing.

Practical implications include streamline of simulation setup, increased auditability, and design space exploration capability. However, further research is warranted on LLM robustness in geometry synthesis for complex industrial parts, error-driven mesh adaptivity, adjoint-based gradient optimization for continuously differentiable subproblems, mixed formulations for incompressiblility, and automated validation benchmarks across a broader set of LLM backends.

Conclusion

The presented system delivers a rigorously constrained LLM interface for multi-physics FEniCS simulations, validated on both backend (physics) and front-end (interface) metrics (2606.10928). Strong numerical agreement is achieved for all supported problem classes, and front-end reliability is quantified in structured parser and geometry benchmarks. The architectural separation—LLM for task specification and geometry, deterministic code for all variational and solver logic—enables fast, auditable, and reliable automated finite element analysis, with extensibility conditioned on transparent template addition rather than opaque model retraining.

This approach sets a benchmark for reliable LLM-augmented scientific computing and clarifies the design tradeoffs and validation requirements for further integration of natural-language agents in computational science workflows.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 1 tweet with 2 likes about this paper.