FoamGPT: A Fine-Tuned Language Model for Automation of CFD Simulations with OpenFOAM
Abstract
Setting up simulations in OpenFOAM, a leading Computational Fluid Dynamics (CFD) software, is a notoriously complex task. Existing Large Language Models (LLMs) struggle to automate this process, largely due to the inefficacy of monolithic generation strategies. In this paper, we introduce FoamGPT and propose a new paradigm that aligns with modern multi-agent workflows by employing specialist fine-tuning. Our core idea is to decouple the complex simulation setup: a planning agent first defines the required file structure, then invokes our specially fine-tuned FoamGPT as a "specialist generation agent." Instead of generating the entire simulation case at once, FoamGPT is fine-tuned on the sub-task of generating a single, high-fidelity file based on directives from the planner. To support this approach, we built a high-quality dataset covering 202 distinct cases, specifically curated for this expert-generation task. Experimental results validate our approach: FoamGPT boosts the success rate of GPT-4.1-mini from a baseline of 17.27% to 24.55%, outperforming the previous state-of-the-art method, AutoCFD (20.91%). Our work demonstrates that specialist fine-tuning for specific steps within an agentic workflow is a key strategy for unlocking the potential of LLMs in complex scientific automation. The code is open-sourced: https://anonymous.4open.science/r/FoamGPT-6102