Source-linked AI summary

OpenFOAMGPT: a RAG-Augmented LLM Agent for OpenFOAM-Based Computational Fluid Dynamics

Sandeep Pandey, Ran Xu, Wenkang Wang, Xu Chu

arXiv:2501.06327v1physics.flu-dynphysics.comp-ph

TL;DR

OpenFOAMGPT addresses the goal of automating CFD simulation workflows and lowering the expertise threshold. It combines OpenAI foundation models with an iterative correction loop for OpenFOAM tasks, with o1 showing an edge on complex tasks despite higher token cost.

  • Problem

    Automating CFD workflows and lowering the expertise threshold are identified as goals for improving productivity.

  • Method

    OpenFOAMGPT is an LLM-based OpenFOAM agent integrating GPT-4o and a CoT-enabled o1 model with an iterative correction loop.

  • Results

    Despite costing about six times more per token, o1 demonstrated a clear edge on complex OpenFOAM tasks, including case setup, condition modifications, turbulence-model alternation, and code translation.

  • Takeaways & Limitations

    The agent is positioned to automate CFD workflows and reduce the expertise threshold for simulation practice.

  • Takeaways & Limitations

    The conclusion qualifies the robust performance of the pretrained language models, indicating that performance remains subject to author-stated limitations.

Abstract

from arXiv · show

This work presents a large language model (LLM)-based agent OpenFOAMGPT tailored for OpenFOAM-centric computational fluid dynamics (CFD) simulations, leveraging two foundation models from OpenAI: the GPT-4o and a chain-of-thought (CoT)-enabled o1 preview model. Both agents demonstrate success across multiple tasks. While the price of token with o1 model is six times as that of GPT-4o, it consistently exhibits superior performance in handling complex tasks, from zero-shot case setup to boundary condition modifications, turbulence model adjustments, and code translation. Through an iterative correction loop, the agent efficiently addressed single- and multi-phase flow, heat transfer, RANS, LES, and other engineering scenarios, often converging in a limited number of iterations at low token costs. To embed domain-specific knowledge, we employed a retrieval-augmented generation (RAG) pipeline, demonstrating how preexisting simulation setups can further specialize the agent for sub-domains such as energy and aerospace. Despite the great performance of the agent, human oversight remains crucial for ensuring accuracy and adapting to shifting contexts. Fluctuations in model performance over time suggest the need for monitoring in mission-critical applications. Although our demonstrations focus on OpenFOAM, the adaptable nature of this framework opens the door to developing LLM-driven agents into a wide range of solvers and codes. By streamlining CFD simulations, this approach has the potential to accelerate both fundamental research and industrial engineering advancements.

I. INTRODUCTION

LLMs are being applied across fluid mechanics to assist with equation discovery, shape optimization, prediction, and CFD workflow automation. This work introduces OpenFOAMGPT, a retrieval-augmented agent intended to automate OpenFOAM simulations while incorporating domain-specific information.

  • LLMs have supported fluid-mechanics applications including equation discovery, shape optimization, unsteady-flow prediction, and CFD workflow automation.
  • Prior CFD-oriented systems use natural-language interaction and retrieval-augmented generation to identify and correct errors while lowering technical barriers.
  • OpenFOAMGPT combines an LLM-based agent with retrieval of domain-specific information to generate contextually informed instructions for CFD simulations.
  • The proposed workflow aims to automate simulations, lower the expertise threshold, and improve productivity in CFD applications.
  • The framework is presented as adaptable beyond OpenFOAM to a wide range of other solvers and codes.

II. METHODOLOGY

OpenFOAMGPT couples OpenFOAM operations with GPT-based reasoning, retrieval-augmented domain knowledge, and iterative error correction. Its RAG layer retrieves tutorial and specialized information to support more accurate, domain-focused simulation plans.

  • OpenFOAMGPT uses GPT-4o and a chain-of-thought-enabled o1 preview model through the OpenAI API.
  • The agent combines system prompts and user queries with planning, model reasoning, OpenFOAM execution, and monitored iterative correction.
  • When a simulation fails, error data is appended to the user query so the workflow can iterate toward completion.
  • The RAG database derives from OpenFOAM tutorial descriptions and retrieves details such as solver names, case names, and flow types.
  • RAG supplements general model knowledge with validated practices and updated methodologies, improving prompting and reported accuracy.
  • Adding specialized topics such as aerodynamics, process engineering, and heat-transfer design adapts the agent toward domain-focused CFD solutions.

A. Performance of zero-shot prompting

Zero-shot performance depends strongly on the foundation model and input specification. The o1-preview agent handles more complex geometries than 4o, while detailed geometry files improve setup but do not eliminate failures on particle-flow cases.

  • Zero-shot prompting can produce desired outputs, but difficult problems may cause the model to fail.
  • Without RAG, 4o generates simple two-dimensional geometries, whereas o1-preview generates more complex cases such as Hotroom.
  • Supplying a detailed blockMeshDict file improves o1 performance for specifying intricate geometries.
  • With the detailed geometry input, o1 successfully handles Cavity flow, PitzDaily, Hotroom, Dambreak, and Mixed vessel without RAG.
  • Particle column remains unsolved because it combines unidirectional flow with particle flow.

B. Few-Shot Prompting with RAG

RAG improves the agent’s ability to configure complex CFD cases. Although 4o uses fewer tokens and costs less, RAG enables successful setup across all tested cases, while o1 incurs higher costs without reducing iterations or token usage.

  • The Particle column output differs from the RAG file because the output file has a length limit.
  • RAG enables the agent to successfully set up all tested cases, including complex CFD workflows.
  • 4o test scenarios cost $0.03 to $0.36, with execution times under ten minutes in each instance.
  • Switching to o1 does not reduce iterations or token usage, and its higher token price raises the Particle column cost to $1.60.
  • The 4o model is therefore reported as the more cost-effective choice under the evaluated conditions.

C. Alternate simulation conditions: initial- and boundary conditions, mesh

OpenFOAMGPT was evaluated on zero-shot changes to initial and boundary conditions and turbulence models across increasingly complex CFD scenarios. The o1-preview agent handled the tested changes broadly, while a more complex particle-column case exposed a difficulty.

  • Alternate initial- and boundary conditions: OpenFOAMGPT with o1-preview successfully handled all tested alternate initial- and boundary-condition changes, while GPT-4o accomplished most objectives.The evaluation included transitions from simple homogeneous steady-state cases toward unsteady and heterogeneous scenarios.
  • Alternate initial- and boundary conditions: The agent selected an appropriate codedFixedValue implementation for an unsteady sinusoidal cavity-flow boundary condition without being told how to implement it.The generated U-file code used a sineVelocity redirect type and computed velocity from amplitude, frequency, and simulation time.
  • Turbulence-model changes: o1 effectively added or swapped RANS and LES turbulence models, including less-common complex models and a standard Smagorinsky model.The tasks involved more than changing model names: transport-equation conditions and numerical schemes could also require adjustment.
  • Turbulence-model changes: The agent successfully handled most turbulence-model scenarios but encountered difficulties applying a k-ϵ model to the higher-complexity particle-column case.The authors present this result as evidence of potential to streamline or automate advanced CFD tasks with minimal intervention.

E. Zero-Shot code translation with o1-preview

The paper evaluates OpenFOAMGPT for translating tutorial cases between independently maintained OpenFOAM distributions that are generally incompatible and require substantial code and library modifications. Channel395 translated cleanly with o1-preview, while the other cases retained errors or convergence problems.

  • Cross-platform translation: OpenFOAMGPT with o1-preview facilitated translation from OpenFOAM 12 to OpenFOAM V2406 despite the distributions’ general incompatibility.The source code supplied to the agent covered only OpenFOAM 12 and omitted information about OpenFOAM V2406.
  • Translation results: One of four tutorial cases, Channel395, translated successfully without inconsistencies using the web-based o1-preview agent.The evaluated cases were T-Junction, Channel395, PitzDaily, and Motorbike.
  • Translation results: The remaining three o1-preview translations encountered errors, including inaccurate controlDict function entries and dimension mismatches in field operations.These issues demonstrate the complexity of translating code across OpenFOAM distributions and motivate meticulous validation and targeted debugging.
  • Translation results: With agent assistance, Motorbike experienced errors preventing execution, whereas PitzDaily failed to converge after a few steps.The authors describe the agent as effective for resolving similar cross-platform issues, while still requiring validation.

IV. CONCLUSION, LIMITATIONS AND OUTLOOK

OpenFOAMGPT combines two OpenAI foundation models with iterative correction and RAG to support diverse OpenFOAM CFD workflows. The demonstrations show broad task coverage, specialization through existing simulation setups, and practical limits requiring oversight and monitoring.

  • OpenFOAMGPT integrates GPT-4o and a chain-of-thought-enabled o1 model for OpenFOAM-focused computational fluid dynamics.
  • o1 costs about six times more in tokens than GPT-4o but shows a clear advantage on complex CFD tasks.
  • Through iterative correction, the agent handles zero-shot case setup, initial and boundary-condition changes, turbulence-model alternation, and code translation.
  • Demonstrated scenarios span single- and multi-phase flow, heat transfer, RANS, LES, and other engineering cases, resolved in limited iterations at low token expense.
  • RAG embeds domain-specific knowledge from existing simulation setups, enabling specialization for energy, aerospace, and other tailored CFD sub-domains.
  • Human oversight and monitoring remain critical because correctness depends on review and model performance can fluctuate over time, especially in mission-critical applications.
  • Although demonstrated with OpenFOAM, the adaptable framework is presented as applicable to a broad spectrum of solvers and codes and as a potential accelerator of research and engineering.
Loading 2501.06327v1…