LLM Agent for Fire Dynamics Simulations

Leidong Xu,Danyal Mohaddes,Yi Wang
2024-12-23
Abstract:Significant advances have been achieved in leveraging foundation models, such as large language models (LLMs), to accelerate complex scientific workflows. In this work we introduce FoamPilot, a proof-of-concept LLM agent designed to enhance the usability of FireFOAM, a specialized solver for fire dynamics and fire suppression simulations built using OpenFOAM, a popular open-source toolbox for computational fluid dynamics (CFD). FoamPilot provides three core functionalities: code insight, case configuration and simulation evaluation. Code insight is an alternative to traditional keyword searching leveraging retrieval-augmented generation (RAG) and aims to enable efficient navigation and summarization of the FireFOAM source code for developers and experienced users. For case configuration, the agent interprets user requests in natural language and aims to modify existing simulation setups accordingly to support intermediate users. FoamPilot's job execution functionality seeks to manage the submission and execution of simulations in high-performance computing (HPC) environments and provide preliminary analysis of simulation results to support less experienced users. Promising results were achieved for each functionality, particularly for simple tasks, and opportunities were identified for significant further improvement for more complex tasks. The integration of these functionalities into a single LLM agent is a step aimed at accelerating the simulation workflow for engineers and scientists employing FireFOAM for complex simulations critical for improving fire safety.
Artificial Intelligence,Fluid Dynamics
What problem does this paper attempt to address?
The main problem that this paper attempts to solve is to simplify and accelerate the usage process of FireFOAM (a computational fluid dynamics solver specifically used for fire dynamics and fire - extinguishing simulations). Specifically, the author has developed a large - scale language model (LLM) agent named FoamPilot, aiming to enhance the usability of FireFOAM mainly through the following three core functions: 1. **Code Insight**: - Through retrieval - augmented generation (RAG) technology, it helps users efficiently navigate and summarize the FireFOAM source code, enabling developers and experienced users to quickly find relevant code segments and understand their functions or make necessary modifications. 2. **Case Configuration**: - It interprets users' natural language requests and accurately creates and modifies existing simulation settings according to these requests, thus supporting intermediate - level users to adjust simulation parameters more conveniently. 3. **Job Execution**: - It manages the submission and execution of simulation tasks in a high - performance computing (HPC) environment and provides preliminary result analysis for less - experienced users to simplify the execution process of complex tasks. ### Specific Problems and Solutions #### 1. Code Insight Traditional methods such as `grep` and `find` are inefficient in large - scale open - source projects and it is difficult to understand complex code structures. For this reason, the paper proposes a RAG - based method to improve the accuracy and efficiency of code search through semantic search. Specific steps include: - Merging C++ header files and source files into a single document to ensure that declarations and implementations appear in the same context simultaneously. - Using an embedding model to vectorize the pre - processed code and retrieving relevant information through cosine similarity search. #### 2. Case Configuration In order to reduce the complexity and time required for non - expert users to configure simulations, FoamPilot can parse the natural language instructions provided by users and modify existing simulation cases accordingly. For example: - Users can describe the specific content they wish to modify, such as changing the burner size or cardboard thickness, without providing additional example cases. - FoamPilot will read the contents of the entire case directory, identify the configuration files that need to be modified, and make corresponding adjustments. #### 3. Job Execution For beginners, running FireFOAM simulations in a Linux environment, especially when using job schedulers such as SLURM, is very challenging. Therefore, FoamPilot provides two job execution methods: - **Serial Job**: Run the simulation directly on the local machine or the master node of the HPC system and provide preliminary result analysis after completion. - **Parallel Job**: Select an appropriate number of nodes according to the grid size and available resources, configure sub - domain decomposition, and submit it to the queue to execute large - scale simulations. ### Experimental Results and Discussion The experimental results show that FoamPilot has its own advantages and disadvantages in the performance of these three functions: - **Code Insight**: It performed excellently in the test, successfully finding the required mathematical formulas and correctly interpreting the code meaning. - **Case Configuration**: It works well for simple modification tasks (such as changing dimensions), but encounters difficulties for more complex modifications. - **Job Execution**: It can successfully complete serial jobs with detailed prompts, but is unstable in the HPC environment, especially prone to errors in environmental configuration. In conclusion, this research shows how to use LLM agents to significantly improve the user experience of FireFOAM, but further optimization is still required to meet the needs of more complex tasks.