Spray combustion sub-model integrated development method and equipment based on large language model
By adopting an integrated development method for spray combustion sub-models based on large language models, the problem of cross-framework integration in engine simulation platforms was solved, achieving efficient integration and verification of spray combustion models and improving the numerical simulation capabilities and accuracy of engine simulation platforms.
Patent Information
- Application Number
- CN202511885759.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-03-20
AI Technical Summary
Existing engine simulation platforms are difficult to extend to different simulation frameworks, which makes the engineering development and integration verification of spray combustion models difficult. The lack of high-precision algorithm models also affects the numerical calculation capabilities of engine simulation platforms.
We adopted an integrated development method for spray combustion sub-models based on large language models. By using a retrieval-enhanced generation system and a multi-agent collaborative framework, we integrated spray combustion modules from different programming languages and version frameworks into a unified OpenFOAM simulation platform. This included source code analysis, function and interface planning, code generation and encapsulation, layered testing and verification graph generation, and debugging and repair processes.
It significantly improves the numerical simulation capability of the engine simulation platform, shortens the development time and the time cost of manual code processing, ensures the syntactic and logical correctness of the generated code, and improves the integration efficiency and accuracy of the spray combustion model.
Smart Images

Figure CN121704850A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of engine technology, specifically relating to a method and equipment for the integrated development of spray combustion sub-models based on a large language model. Background Technology
[0002] With the rapid development of Computational Fluid Dynamics (CFD), modern simulation tools have been widely applied to all stages of engine design and development, significantly reducing time and economic costs in the R&D process. Numerical simulation technology runs through the entire process of combustion system conceptual design, prototype design, and finalization, making it possible to quantitatively analyze flow, spray, and combustion characteristics under the complex and constrained environment of high temperature and high pressure in engines. Against this backdrop, the flexible development and integration of various advanced mathematical models, and the continuous improvement of engine simulation software, have significant application value for accurately simulating the working process of advanced engines and thus optimizing efficient and clean combustion technology pathways.
[0003] In the ever-evolving paradigms of scientific research, the rise of Large Language Models (LLMs) has gradually led researchers to create more intelligent simulation development methods. Some studies have already made initial attempts to use LLMs to assist in CFD simulation development. For example, emerging frameworks such as MetaOpenFOAM (arXiv:2407.21320), ChatCFD (arXiv:2506.02019), and OpenFOAM-GPT (arXiv:2504.19338) automate the CFD simulation process through natural language commands. However, it should be noted that the above studies cannot directly generate solver code; instead, they are limited to creating the input files required for simulation (such as boundary condition configurations, mesh settings, and solver configuration files) to automate the entire numerical simulation workflow. Furthermore, most simulation examples are limited to incompressible and non-reactive flows.
[0004] Furthermore, related research indicates that code (or scripts) can be created based on prompts to call existing functions in the underlying library / external software to configure simulation cases and perform engineering shape optimization LLM-PSO (arXiv:2412.08072). However, the code capacity of the scientific computing library has not been expanded, and the reliability of this framework does not meet the requirements of scientific research when dealing with complex simulation calculation tasks involving high-dimensional, multi-physics coupling.
[0005] Furthermore, LLMs are reshaping the landscape of code and software development. Models trained on broader code datasets, such as CodeX, CodeLlama, Claude Code, and DeepSeek-Coder, have demonstrated superior performance on numerous benchmarks and are better suited for coding tasks. However, large models still face significant challenges when applied to code development for complex engineering numerical simulations. The LLM-PDEveloper (arXiv:2509.25194) has preliminarily explored the ability of large-scale multi-agent models to secondary develop partial differential equation (PDE) libraries, automating the process of "mathematical / algorithm description—source code—extending new / old modules of the PDE library." The results show that syntax errors in code generated by LLM multi-agent models can be significantly reduced through rule-based hints; however, semantic errors (i.e., code that compiles and runs but produces logically incorrect results) still require manual intervention for location and correction. CFDLLMBench (arXiv:2509.20374) conducted a systematic evaluation from three aspects: CFD knowledge question answering, code generation and verification, and natural language-driven OpenFOAM simulation. The results show that the multi-agent framework combining RAG and Reviewer can significantly improve the overall performance. However, the current test corpus mainly consists of typical one-dimensional / two-dimensional examples (such as solving the Burgers equation, Laplace equation, steady / transient heat conduction equation, etc.), and has not yet covered the complex models and codes commonly used in engineering spray combustion simulation, such as the Lagrange spray model, equilibrium phase spray model, and flame generation manifold model. Similarly, CodePDE (arXiv:2505.08783) proposed an LLM inference framework with code generation as its core, introducing inference-time techniques such as chained inference, automatic debugging, and autonomous improvement. It performs well in generating code for solving basic PDE problems such as convection equation, Burgers equation, and compressible NS equation, but its accuracy and stability in reaction-diffusion problems are still insufficient. It is worth noting that, compared to the actual spray combustion model, the generation of the Reaction-Diffusion problem solution code is still a simplified test.
[0006] The current field of engine simulation may not lack high-precision algorithm models, but rather the numerical computation capabilities of engine simulation platforms are limited by their inability to scale to different simulation frameworks. For example, migrating an FGM combustion model from OpenFOAM v7 to the more advanced v2406 version often requires a lengthy development and debugging cycle; similarly, migrating a spray-wall collision sub-model based on Kiva3v Fortran to current mainstream simulation platforms frequently results in lengthy development processes due to differences in data structures and interface incompatibility. Although some work has explored the feasibility of using multi-agent frameworks to generate PDE solvers and develop new turbulence models, the engineering development and integrated verification of complex engine spray combustion models remain largely unaddressed. Therefore, how to construct a multi-agent framework to realize the development, construction, and deep optimization of practical solvers for LLM-based engineering applications has become a key research topic. Summary of the Invention
[0007] The present invention aims to at least partially solve one of the technical problems in the aforementioned related technologies.
[0008] Therefore, the purpose of this invention is to provide a method and device for the integrated development of spray combustion sub-models based on a large language model. This method can not only integrate existing spray combustion modules with different programming languages and different versions of frameworks into a unified OpenFOAM simulation platform, but also expand the functional boundaries of the existing simulation platform, greatly improving the numerical simulation capabilities of the existing engine simulation platform.
[0009] To solve the above-mentioned technical problems, the present invention is implemented as follows: This invention provides an integrated development method for a spray combustion sub-model based on a large language model. The method relies on a retrieval-enhanced generation system and a multi-agent collaborative framework. The steps of the method include: S1. User Instructions and Paper Extraction: Users propose sub-module expansion requirements, and the retrieval enhancement generation system extracts core information from relevant technical literature to form structured documents; S2. Source Code Analysis and Comparison Data Generation: The source code of the agent to be extended sub-model is analyzed, and tests are run on the source code based on the structured file of S1 to generate comparison data; S3. Function and Interface Planning: Complete the adaptation planning of the original model to the OpenFOAM platform through input and output contract agents, and generate new module function interfaces and coupling structured specification documents; S4. Code Generation and Encapsulation: The generating agent performs code conversion, dependency handling, test case generation, and compilation and encapsulation. S5. Layered testing and verification graph generation: The new module is verified in two levels through testing agents, and a verification graph is generated to ensure that the new module has correct syntax, correct logic, and meets performance standards. S6. Debugging and Repair: By executing the localization-repair-regression closed-loop process through the debugging agent, the new OpenFOAM module that meets the standards, the final verification graph, and the modification record markdown document are obtained.
[0010] In addition, the spray combustion sub-model integration development method based on a large language model according to the present invention may also have the following additional technical features: In some implementations, the core information extracted includes: the mathematical equations of the sub-model, variables and units, boundary / initial conditions, and discrete points.
[0011] In some implementations, step S3 includes: Based on the OpenFOAM interface list in the S1 structured file and the OpenFOAM source code / documents retrieved by the RAG system, the function signature of each function in the new module is determined; the key intermediate quantities, physical constraints and test tolerances that need to be aligned are identified; and the access points and field initialization / return positions of the new module in OpenFOAM are planned.
[0012] In some of these implementations, in step S4: Code conversion: Convert the original code function by function into OpenFOAM-compatible C / C++ code, keeping the formulas, constants, and solution process completely consistent; Dependency handling involves scanning the OpenFOAM header files related to thermo / reaction / chemistry, generating the interface files, composite type definitions, and registered macros required for new modules, and checking the integrity of the dependency header files. Test case generation: Create minimal test cases that contain only the core functionality of the new module; The generated code is compiled into an external library that can be called by OpenFOAM and linked to the OpenFOAM simulation platform.
[0013] In some implementations, the two-level verification of step S5 includes: The first-level verification is the minimum module verification: using the same fixed boundary conditions as S2, the new module is input, and the differences between the function output value, key intermediate variable value and control data are compared item by item to determine whether it meets the test tolerance. Level 2 verification is platform integration verification: If Level 1 verification passes, a small-scale time-lapse test is run to check the integration effect of the new module in OpenFOAM.
[0014] In some implementations, the content of the verification graph generated in step S5 includes: The post-processing tool automatically generates a comparison chart of key performance indicators, which intuitively demonstrates the consistency between the new module and the original model.
[0015] In some of these implementations, the integration effects checked in the secondary verification include: numerical positivity, physical conservation, and residual convergence trend.
[0016] In some implementations, the location-repair-regression closed-loop process in step S6 includes: Problem identification: Locate the code problem based on the error log; Minimal modification fixes: Make minimal changes to the code without altering the core logic of the original model; Regression testing: After the fix, the two-level verification of S5 will be automatically re-executed to determine whether the standard is met; Iteration limit: a maximum of 5 iterations to avoid endless debugging and balance efficiency and reliability.
[0017] In some implementations, the retrieval enhancement generation system performs preprocessing-related tasks, including: The data collected includes: OpenFOAM official user guide and target version interface / configuration file descriptions; Structured segmentation: This describes a two-level slicing of the document from chapters to paragraphs; formula / parameter tables are grouped into separate blocks, retaining metadata such as page numbers, titles, and figure / table numbers; Index: A dual index of vector retrieval and BM25 is used to achieve function signature-level retrieval and fragment-level fine sorting.
[0018] This invention also provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the spray combustion sub-model integration development method based on a large language model as described in any of the preceding embodiments.
[0019] Compared with the prior art, the present invention has at least the following beneficial effects: In this embodiment of the invention, the spray combustion sub-model integration and development method based on a large language model provides an end-to-end automatic code development and integration framework, realizing full automation from literature and code library retrieval to spray combustion sub-model code integration, development, and verification, which greatly reduces the time and effort cost of manually processing a large amount of function code under traditional methods; In this embodiment of the invention, the spray combustion sub-model integration development method based on a large language model introduces a quantitative verification and closed-loop repair mechanism. It incorporates key indicators such as gas-liquid phase penetration distance, Sotter average diameter, ignition delay time, and flame rise length into automatic evaluation, forming a complete process of "code generation → compilation → minimum case running → comparison → adjustment and repair". This makes code generation more accurate and verification more rigorous, significantly reducing the time spent on "correcting syntax errors and fixing logic leaks" during the debugging phase.
[0020] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0021] Figure 1 This is a flowchart of an integrated development method for a spray combustion sub-model based on a large language model, as disclosed in an embodiment of the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and specific examples and application scenarios.
[0024] In some embodiments of the present invention, a method for integrating and developing a spray combustion sub-model based on a large language model is provided. This method requires the pre-construction of a Retrieval Augmented Generation (RAG) system, specifically including document and interface data retrieval, segmentation, and indexing. 1. Scope of data collection: OpenFOAM official user guide and target version interface / configuration file description.
[0025] 2. Structured segmentation: This describes a two-level slicing of the document from chapters to paragraphs; formula / parameter tables are grouped into separate blocks, retaining metadata such as page numbers, titles, and figure / table numbers; 3. Indexing: The system employs a dual indexing approach commonly used in RAG systems, combining vector retrieval and BM25, to achieve function signature-level retrieval and fragment-level ranking. The model used is not specifically limited; BERT, CodeBERT, and SentenceTransformer are all acceptable.
[0026] Please see Figure 1As shown, in some embodiments of the present invention, a method for integrating and developing a spray combustion sub-model based on a large language model is provided. The steps of this method include: Step 1. User Instructions and Paper Extraction Users propose sub-modules to be expanded (such as RK-PR state equations). The system extracts equations, variables and units, boundary / initial conditions, and discrete key points from the literature to form a structured file.
[0027] Step 2. Source code analysis and data comparison Read the original implementation (e.g., Matlab / KIVA / Fortran), list the functions, inputs / outputs, and key intermediate quantities, run it on the original implementation with fixed boundary conditions, and derive the output. <func>The .csv file serves as the control data.
[0028] Step 3. Function and Interface Planning By combining Constraints.yaml (constraints document) and api_inventory.csv, and using the RAG system to retrieve OpenFOAM source code and documentation, the function signature, intermediate quantities that need to be aligned, physical constraints and test tolerances of each function are clarified; at the same time, the access points and field initialization / return positions are given, and a new module function interface and coupling structure description file are generated.
[0029] Step 4. Code Generation and Encapsulation The original function is strictly converted into an OpenFOAM C / C++ implementation, maintaining consistency in formulas, constants, solution process, and root-finding / interpolation algorithms; OpenFOAM interface files, new combination types, registered macros, etc. are generated, and dependent header files are checked; a minimal test case is generated; and the entire external library (.so) is compiled and linked to the OpenFOAM simulation platform.
[0030] Step 5. Stratified Testing and Verification Diagram First, test the new module using the same input as the test boundary conditions in step 2, comparing the function output with the values of key intermediate variables item by item; after passing, use a small-scale time step to check the positivity, conservation and residual trends; finally, automatically draw comparative verification charts such as gas / liquid phase penetration distance and flame floating length based on the post-processing results.
[0031] Step 6. Debugging and Repairing (Limiting the Number of Iterative Repairs) If any item fails to meet the standard, the problem is located based on the logs and comparison results. After making minimal changes, automatic regression testing is performed. After a maximum of 5 iterations, the new module and verification graph are returned to the user.
[0032] In some embodiments of the present invention, at the tool execution level, compilation, execution, post-processing and plotting tools are integrated, supporting wmake compilation, OpenFOAM test script execution, result parsing, and plotting of dot-line / bar charts.
[0033] Example 1: In this embodiment of the invention, the technical solution of the invention is further described in detail using the "real gas equation of state module development" as an example of one of the spray combustion model sub-modules. The steps of the method in this embodiment include: Step 1: The user submits specific instructions for the extended development of the spray combustion submodule, such as extending the OpenFOAM v2406 version real gas equation of state module using the RK-PR equation of state. First, the API literature search function is used to obtain a predetermined number of search results based on the keyword "RK-PR equation of state". The sections on Numerical method / Model setup / Boundary & Initial conditions are extracted and saved according to a unified template, including LaTeX format equations, variable meanings and units, boundary conditions, and discretization formats. Items not mentioned in the paper are marked as "pending". A structured file Constraints.yaml is generated.
[0034] Constraints.yaml is used to describe the mathematical expression, variable information, boundary conditions, and numerical constraints of the target submodule (such as state equations). Its content typically includes, but is limited to, the following main fields: equations: The core set of equations of the model (LaTeX or structured expression). variables: the name, physical meaning, and unit of all variables; constants: physical constants or empirical coefficients involved and their units; ic_bc: Quantities and their forms appearing in the initial and boundary conditions; Discretization: If the paper involves discrete formats (such as central difference, upwind format, etc.), record them; parts not involved are marked as "to be determined"; constraints: physical constraints (such as positivity, conservation, dimensional consistency, etc.) and the allowable error range of the system; Notes: Parts of the paper that are not explicitly stated or require manual supplementation.
[0035] This file uses the standard YAML format, which is convenient for IO-Contract-Agent to parse.
[0036] Step 2: The Reader-Agent parses the function listings, call graphs, input / output, and key intermediate variables (such as the compression factor Z) of the Matlab m-language or Kiva Fortran-language. Then, it calls the Test runner, setting a set of fixed test pressures P, temperature T, and component mass fraction fields Yi based on the boundary conditions obtained in Step 1. The runner is executed on the Matlab / Kiva source code implementation, and the output results and key intermediate variable values are exported to... <func>The .csv file (in this case, EosExtension.csv) serves as reference data for subsequent iterations and debugging of newly generated OpenFOAM modules.
[0037] Step 3: Input / Output Contract Agent. Combining the structured files generated in Steps 1 and 2, and retrieving the v2406 version documentation through the RAG system, plan the structure of the new OpenFOAM module. Define the function signature for each function in the new module, intermediate variables for debugging and alignment, and physical constraints (such as mass conservation and temperature output limits). Additionally, define the location of the output state equation access point and the variable initialization process.
[0038] Step 4: Generate the Agent. Using the RAG-enhanced prompt and the structured document generated in the previous steps, implement the following: 1) Strictly convert the original function implementation (Matlab / Fortran / Python) to C / C++, keeping the formulas, constants, solution process, and root finding / interpolation algorithms consistent; 2) Generate OpenFOAM interface files, scan the thermo / reaction / chemistry related header / source files in OpenFOAM, parse the combination type definition location, registered macro location, etc., perform dependency header file checks, and generate new thermophysical property combination types and other dependency files; 3) Generate simple test cases.
[0039] Step 5: Test Agent. Perform layered verification on the module generated in Step 4. First, perform minimal module verification, passing the same input as in Step 2 to the new module generated in Step 4 and comparing the output / intermediate variable values with the original implementation. If the error exceeds the tolerance limit, the log information is passed to the Debug Agent for iterative repair. Otherwise, further verification is performed using a short time step of a simple OpenFOAM test case. Observe whether the differences between the gas / liquid phase penetration distance and flame levitation length calculated by the new module and the prediction results of the source model meet the set error range. If the verification passes, the comparison results are used to generate a verification graph using Python plotting commands.
[0040] Step 6: The debug agent locates and repairs the non-compliant items in step 5 based on the incoming error and runtime log information. All changes are recorded in a markdown document, and a maximum of 5 iterations of repair are agreed upon.
[0041] Any part of this invention not described in detail can be referred to in the prior art or in the art known to those skilled in the art. This embodiment does not limit such part and will not describe it in detail here.
[0042] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.< / func> < / func>
Claims
1. A method for integrating and developing a spray combustion sub-model based on a large language model, characterized in that, The method is implemented based on a retrieval-enhanced generation system and a multi-agent collaborative framework. The steps of the method include: S1. User Instructions and Paper Extraction: Users propose sub-module expansion requirements, and the retrieval enhancement generation system extracts core information from relevant technical literature to form structured documents; S2. Source Code Analysis and Comparison Data Generation: The source code of the agent to be extended sub-model is analyzed, and tests are run on the source code based on the structured file of S1 to generate comparison data; S3. Function and Interface Planning: Complete the adaptation planning of the original model to the OpenFOAM platform through input and output contract agents, and generate new module function interfaces and coupling structured specification documents; S4. Code Generation and Encapsulation: The generating agent performs code conversion, dependency handling, test case generation, and compilation and encapsulation. S5. Layered testing and verification graph generation: The new module is verified in two levels through testing agents, and a verification graph is generated to ensure that the new module has correct syntax, correct logic, and meets performance standards. S6. Debugging and Repair: By executing the localization-repair-regression closed-loop process through the debugging agent, the new OpenFOAM module that meets the standards, the final verification graph, and the modification record markdown document are obtained.
2. The integrated development method for spray combustion sub-model based on a large language model according to claim 1, characterized in that, The core information extracted includes: the mathematical equations of the sub-model, variables and units, boundary / initial conditions, and key discretization points.
3. The method for integrating and developing spray combustion sub-models based on a large language model according to claim 1, characterized in that, Step S3 includes: Based on the OpenFOAM interface list in the S1 structured file and the OpenFOAM source code / documents retrieved by the RAG system, the function signature of each function in the new module is determined; the key intermediate quantities, physical constraints and test tolerances that need to be aligned are identified; and the access points and field initialization / return positions of the new module in OpenFOAM are planned.
4. The method for integrating and developing spray combustion sub-models based on a large language model according to claim 1, characterized in that, In step S4: Code conversion: Convert the original code function by function into OpenFOAM-compatible C / C++ code, keeping the formulas, constants, and solution process completely consistent; Dependency handling involves scanning the OpenFOAM header files related to thermo / reaction / chemistry, generating the interface files, composite type definitions, and registered macros required for new modules, and checking the integrity of the dependency header files. Test case generation: Create minimal test cases that contain only the core functionality of the new module; The generated code is compiled into an external library that can be called by OpenFOAM and linked to the OpenFOAM simulation platform.
5. The method for integrating and developing spray combustion sub-models based on a large language model according to claim 1, characterized in that, The two-level verification in step S5 includes: The first-level verification is the minimum module verification: using the same fixed boundary conditions as S2, the new module is input, and the differences between the function output value, key intermediate variable value and control data are compared item by item to determine whether it meets the test tolerance. Level 2 verification is platform integration verification: If Level 1 verification passes, a small-scale time-lapse test is run to check the integration effect of the new module in OpenFOAM.
6. The method for integrating and developing spray combustion sub-models based on a large language model according to claim 1, characterized in that, The content of the verification graph generated in step S5 includes: The post-processing tool automatically generates a comparison chart of key performance indicators, which intuitively demonstrates the consistency between the new module and the original model.
7. The method for integrating and developing spray combustion sub-models based on a large language model according to claim 5, characterized in that, The integration effects checked in the secondary verification include: numerical positivity, physical conservation, and residual convergence trend.
8. The method for integrating and developing a spray combustion sub-model based on a large language model according to claim 1, characterized in that, The location-repair-regression closed-loop process in step S6 includes: Problem identification: Locate the code problem based on the error log; Minimal modification fixes: Make minimal changes to the code without altering the core logic of the original model; Regression testing: After the fix, the two-level verification of S5 will be automatically re-executed to determine whether the standard is met; Iteration limit: a maximum of 5 iterations to avoid endless debugging and balance efficiency and reliability.
9. The method for integrating and developing spray combustion sub-models based on a large language model according to claim 1, characterized in that, The retrieval enhancement generation system performs preprocessing-related tasks, including: The data collected includes: OpenFOAM official user guide and target version interface / configuration file descriptions; Structured segmentation: This describes a two-level slicing of the document from chapters to paragraphs; formula / parameter tables are grouped into separate blocks, retaining metadata such as page numbers, titles, and figure / table numbers; Index: A dual index of vector retrieval and BM25 is used to achieve function signature-level retrieval and fragment-level fine sorting.
10. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the spray combustion sub-model integration development method based on any one of claims 1-9.
Citation Information
Cited By
Simulation error correction method, device and system based on multi-agent cooperation
CN122152585A
Simulation error correction methods, devices, and systems based on multi-agent cooperation
CN122152585B