Thermal hydraulic system simulation model generation method based on AIGC
By using AIGC-based large language models and intelligent agent technology, a simulation model of a nuclear power thermal-hydraulic system is automatically constructed, solving the problems of information inconsistency and manual construction errors in traditional design modes, and achieving efficient and accurate simulation model generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional document-based nuclear power engineering design models struggle to ensure the completeness and consistency of design information, and it is difficult to assess and determine the relationships between data. Manually constructing thermal-hydraulic system models is prone to omissions and misalignments, making it difficult to adapt to complex systems and design changes.
We construct intelligent agents using a large language model based on AIGC, and achieve automatic construction from simulation system design requirements to modeling code through fine-tuning datasets and LoRA fine-tuning technology. We also utilize a multi-agent asynchronous framework and a graphical modeling platform for task decomposition and code generation.
It improves the generation speed and accuracy of nuclear power system simulation models, enhances the efficiency and accuracy of converting design information into simulation models, and reduces human error.
Smart Images

Figure CN121807284A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of nuclear power simulation, and particularly relates to a thermal-hydraulic system simulation model generation method based on AIGC. BACKGROUND
[0002] Nuclear power engineering design is a large complex system combining multiple disciplines and multiple specialties, involving nuclear reactor physics, thermal power, automatic control, mechanical electronics and other disciplines. The system design is complex, the cost is high, the construction period is long, and the operation safety requirement is high. The traditional design mode based on documents is difficult to ensure the integrity and consistency of design information, and it is difficult to evaluate and determine the relationship between data information. In the face of increasingly complex industrial systems, it is difficult to continue.
[0003] In the past one or two years, generative artificial intelligence technology represented by GPT has developed rapidly, far exceeding the traditional application scope of natural language processing. It has brought about tremendous changes not only in text generation, knowledge question and answer QA, search engines, code generation, and picture and video generation fields. In the field of design and simulation, Microsoft and Siemens have cooperated in the design-simulation code generation field of PLC, aiming to greatly improve the efficiency of PLC high-quality code generation. ANSYS and NVIDIA have jointly developed a new generation of simulation engine in the CAE field. Dassault has integrated LLM tools in its MBSE products to further improve the efficiency and accuracy of 3D modeling to simulation. For nuclear system-level simulation, the model file can also be regarded as a code file in a specific format. The current thermal-hydraulic system model is mainly constructed by manually filling in the input file, relying on different fields to fill in the system model configuration and parameters, which is very inconvenient and prone to errors such as omissions and misplacements. In the face of increasingly complex systems and frequent design changes, it is difficult to continue. Using LLM to realize the automatic conversion of design information to model code, while condensing the experience of modeling personnel, can improve the parameterization, standardization and automation level of the modeling process. For nuclear system-level simulation, the model file can also be regarded as a code file in a specific format. Using LLM to realize the conversion of design information to code, while condensing the experience of modeling personnel, is also a research hotspot in this field at present and in the future. SUMMARY
[0004] The purpose of the present application is to provide a thermal-hydraulic system simulation model generation method based on AIGC, which can realize the development of nuclear power process system intelligent modeling generation model based on fine-tuning technology of general large model, iteratively improve the model generation quality, and improve the simulation verification efficiency.
[0005] The technical scheme of the present application is as follows: a thermal hydraulic system simulation model generation method based on AIGC, which utilizes a large language model to construct an agent, realizes the demand of automatically generating modeling code according to user instructions, and includes the following steps:
[0006] Step 1: dataset generation;
[0007] Step 2: language model fine-tuning;
[0008] Download a pre-trained language model with code generation capability, fine-tune the dataset according to the automatically constructed instructions, perform LoRA fine-tuning in BF16 half-precision, and improve the performance of the language model in component modeling code generation tasks;
[0009] Step 3: agent construction
[0010] Two agents are constructed, a task decomposition agent responsible for decomposing modeling tasks and a modeling agent responsible for specific modeling code generation;
[0011] Step 4: model deployment integration
[0012] The weights of the fine-tuned modeling-specific large language model are deployed on a remote server, and the vLLM library is used to accelerate the inference performance of the model.
[0013] The fine-tuning dataset in step 1 is composed of instructions, input, and output, the instruction part describes the user's modeling instructions, the input part describes the specific component geometric parameters required for modeling, and the output part is the modeling code segment of the nuclear power simulation platform.
[0014] The fine-tuning dataset in step 1 is generated quickly and semi-automatically using an iterative method, a fine-tuning data seed set is constructed to guide the automatic generation of subsequent data, the SELF-INSTRUCT dataset generation framework is used in the construction process, and the existing language model is constructed and utilized to assist in expanding the training data automatically, the first step of iterative dataset generation constructs a few-shot prompt according to the seed set, generates new user modeling instructions using a large language model, after obtaining the modeling instructions, randomly generates parameter information of the component model as the input part of the fine-tuning data, and according to the modeling instructions and the randomly generated model parameter information, the corresponding modeling code is obtained by substituting the pre-defined code template, and the complete fine-tuning data is obtained.
[0015] The LoRA fine-tuning of the pre-trained language model in step 2 is implemented using the peft and transformer libraries. In the peft library, the LoraConfig method and the get_peft_model method are used to convert the pre-trained language model into a LoRA model. The LoraConfig method is used to define the model parameters and training hyperparameters used in LoRA fine-tuning. The get_peft_model method converts the corresponding language model into a corresponding LoRA language model according to LoraConfig.
[0016] After obtaining the LoRA model in step 2, the TrainingArguments method and the Trainer class in the transformer library are used to fine-tune the model. The TrainingArguments method is used to define the model fine-tuning hyperparameters. The Trainer class performs fine-tuning training according to the model fine-tuning hyperparameters corresponding to TrainingArguments.
[0017] In step 3, the task decomposition agent decomposes the requirements into a series of code generation agent subtasks. Each subtask is performed by the corresponding code generation agent, and the corresponding feedback information is obtained on the graphical modeling platform. The process is repeated until all subtasks are successfully completed. Finally, the task decomposition agent integrates all subtask codes to obtain modeling code that can meet the user's modeling requirements, and the graphical modeling platform executes the modeling requirements.
[0018] In step 3, the modeling agent is constructed using the MetaGPT multi-agent asynchronous framework. The workflow and action behavior of each agent are defined by constructing agent classes and action classes. The fine-tuned language model obtained in step 2 is used to perform task decomposition actions and generate modeling code actions. The task decomposition relies on the general language understanding and logical reasoning capabilities of the pre-trained language model. The modeling code generation relies on the ability to generate modeling code using specialized modeling APIs obtained through language model fine-tuning.
[0019] In step 4, the maximum context length and batch size are adjusted to reduce the inference delay of the model and improve the throughput of the inference. When running the multi-agent system locally, a request is generated to access the large language model deployed on a remote server. The model on the remote server returns the result to the local system through an HTTP request after generating the result, realizing the interaction and transmission of information.
[0020] The method of the present application can utilize the reasoning ability of a large language model to automatically construct modeling code from simulation system design requirements. At the same time, it can accelerate the generation speed of nuclear power system simulation models and improve the accuracy of design information conversion to simulation models. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 A flowchart for developing a simulation model intelligent generation module is provided.
[0022] It uses a large language model dedicated to nuclear power simulation modeling as the core, generates modeling instruction sequences (python scripts) for simulation modeling metadata information, and combines the script automatic planning / execution ability of the agent to automatically generate simulation models according to user instructions.
[0023] Figure 2 A semi-automatic generation process for the generative modeling dataset is described.
[0024] Combined with the artificially labeled seed dataset, the LLM is used to expand the training special dataset in batches, and filtering and screening are performed for model fine-tuning training.
[0025] Figure 3 The workflow of the code generation agent is described.
[0026] It consists of two parts: task decomposition and execution of code generation tasks. The task decomposition agent plans the modeling process and decomposes the user modeling task according to the instructions given by the user, decomposes the complex modeling task into a list of primitive tasks that can be solved by the code generation agent, and improves the list of primitive tasks according to the completion of the primitive tasks. The code generation agent mainly implements code generation for primitive modeling tasks and returns the test results of code generation and error attribution and correction when the generated code is incorrect. DETAILED DESCRIPTION
[0027] The present application will be further described in detail below in conjunction with the drawings and specific embodiments.
[0028] As shown in the drawings, Figure 1 A method for generating a thermal-hydraulic system simulation model based on AIGC, which utilizes a large language model to construct an efficient agent and realizes the demand for automatically generating modeling code according to user instructions, specifically including the following steps:
[0029] Step 1: Dataset generation
[0030] There are many function APIs in the graphical modeling platform, and many functions are not strongly related to modeling tasks. When using the original function API to realize automatic modeling, it is necessary to build complex code files, which increases the difficulty of automatic modeling. Large language models lack the ability to perform complex tasks, so tasks need to be broken down into a series of simple tasks, so it is necessary to redesign simple and clear APIs to meet modeling requirements and ensure the correctness of automatic modeling.
[0031] The fine-tuning dataset consists of three parts: instructions, inputs, and outputs. The instruction part describes the user's modeling instructions, the input part describes the specific component geometry parameters required for modeling, and the output part is the modeling code segment of the nuclear power simulation platform.
[0032] The fine-tuning dataset is generated iteratively and semi-automatically, and a seed set of fine-tuning data (about 100) needs to be constructed manually to guide the subsequent automatic generation of data. The construction process is as follows Figure 2 The SELF-INSTRUCT dataset generation framework is used to automatically generate training data by manually constructing and using existing language models to assist in expansion. The first step of iterative dataset generation is to construct a few-shot prompting based on the seed set, and use high-performance closed-source large language models (ChatGPT4, DeepSeek R1) to generate new user modeling instructions (Instruction). After obtaining the modeling instructions, the parameter information of the component model is randomly generated within a reasonable range as the input part of the fine-tuning data, and the modeling instructions and randomly generated model parameter information are substituted into the predefined code template to obtain the corresponding modeling code, thereby obtaining complete fine-tuning data. Finally, according to the semantic similarity and dataset length, etc. Filter out the semantic repetition and low-quality data and add the generated data to the data pool.
[0033] The SELF-INSTRUCT dataset generation framework uses seed set data to guide the subsequent automatic generation of data, and the task distribution and quality of the seed set are crucial. According to different modeling tasks, corresponding seed set data is constructed.
[0034] According to the experience of the previous experiment, the seed set data of the modeling task can be obtained according to the following standards:
[0035] 1. According to the component type classification, build the actual loop simulation model in the self-developed graphical modeling development tool and use the graphical modeling platform to export the corresponding python modeling code. Each component type and its possible attribute definitions need to be included.
[0036] 2. According to the actual loop simulation model derived python file, artificially divide each component to generate code segment (output), and write reasonable modeling instruction part (instruction) and structured model parameter part (input) to obtain complete seed set data. The final record of each component is about 20 or more.
[0037] Step 2: Language model fine-tuning
[0038] Download the pre-trained language model with code generation capability (Qwen2.5-Coder) on the Hugging Face platform, fine-tune the dataset according to the previous automated instructions, and perform LoRA fine-tuning in BF16 half precision to improve the performance of the language model in component modeling code generation tasks.
[0039] The LoRA fine-tuning of the pre-trained language model can be realized by using the peft and transformer libraries. In the peft library, the LoraConfig method and get_peft_model method are needed to convert the pre-trained language model into a LoRA model. The LoraConfig method is used to define the model parameters and training hyperparameters (model type, r, a, etc.) used in LoRA fine-tuning. The get_peft_model method converts the corresponding language model into a corresponding LoRA language model according to LoraConfig.
[0040] After obtaining the LoRA model, the TrainingArguments method and Trainer class in the transformer library are used to fine-tune the model. The TrainingArguments method is used to define the model fine-tuning hyperparameters (batch size, gradient accumulation step, training rounds, learning rate, etc.). The Trainer class fine-tunes the model according to the TrainingArguments corresponding model fine-tuning hyperparameters.
[0041] The training hyperparameters used in fine-tuning can be grid searched before and after the best practice values obtained from previous experience. Compare the performance of the language model after fine-tuning under different training hyperparameters to determine the best training hyperparameters.
[0042] Step 3: Agent construction
[0043] Design standard operation procedures to ensure the standardization of agent execution, construct effective prompt words for each agent, clearly define the behavior of the agent, and guide the language model to output standardized. For example Figure 3As shown, according to the automatic modeling code generation scenario of the present project, we can build two agents, one responsible for decomposing the modeling task, and the other responsible for specific modeling code generation. After the user presents the demand, the task decomposition agent decomposes the user's demand, and divides the user's demand into a series of subtasks familiar to the code generation agent. The code generation agent generates corresponding code for each subtask, and tests it on the graphical modeling platform to obtain feedback information for the code generation agent, until all subtasks are successfully completed. Finally, the task decomposition agent integrates all subtask codes to obtain modeling code that can meet the user's modeling requirements, and executes the modeling requirements on the graphical modeling platform.
[0044] Among them, the modeling agent is built using the MetaGPT multi-agent asynchronous framework. The workflow and action behavior of each agent are defined by constructing the agent (Roles) class and action (Actions) class. The fine-tuned language model obtained in step 2 is used when performing task decomposition actions and generating modeling code actions, where task decomposition relies on the general language understanding and logical reasoning capabilities of the language model pre-training; modeling code generation relies on the ability of the language model to generate modeling code using specialized modeling APIs.
[0045] Step 4: Model deployment integration
[0046] The weights of the fine-tuned modeling-specific large language model are deployed on a remote server, and the vLLM library is used to accelerate the inference performance of the model. In order to fully utilize the server's memory resources, the maximum context length and batch size can be adjusted to reduce the inference delay of the model and improve the throughput of the inference. When running the multi-agent system locally, HTTP requests similar to the OpenAI API format are generated to access the large language model deployed on the remote server. After the model on the remote server generates the result, it returns the result to the local system through the HTTP request, thereby realizing the interaction and transmission of information.
[0047] The automatic generation module and the graphical modeling platform can interact through code text. When the code generation agent in the multi-agent system generates modeling code for the corresponding primitive task, the automatic generation module passes the generated code to the test module of the graphical modeling platform, which tests the generated code and returns the corresponding generation result. When the generated code has errors, the test module of the graphical modeling platform integrates the error location and error information into a natural language and returns it to the automatic generation module.
Claims
1. A method for generating simulation models of thermal-hydraulic systems based on AIGC, which utilizes a large language model to construct an intelligent agent, thereby fulfilling the requirement of automatically generating modeling code according to user instructions, characterized in that... Includes the following steps: Step 1: Dataset generation; Step 2: Fine-tuning the language model; Download an open-source pre-trained language model with code generation capabilities, fine-tune it using an automatically constructed instruction fine-tuning dataset, and perform LoRA fine-tuning with BF16 half precision to improve the performance of the language model in the part modeling code generation task. Step 3: Agent Construction Two intelligent agents are constructed: a task decomposition agent is responsible for decomposing the modeling task, and a modeling agent is responsible for generating the specific modeling code. Step 4: Model Deployment and Integration The weights of the finely tuned modeling-specific large language model are deployed on a remote server, and the vLLM library is used to accelerate the model's inference performance.
2. The method for generating a simulation model of a thermal-hydraulic system based on AIGC as described in claim 1, characterized in that: The fine-tuning dataset in step 1 consists of three parts: instructions, inputs, and outputs. The instructions describe the user's modeling instructions, the inputs describe the specific geometric parameters of the components required for modeling, and the outputs are the modeling code segments of the nuclear power simulation platform.
3. The method for generating a simulation model of a thermal-hydraulic system based on AIGC as described in claim 2, characterized in that: The fine-tuning dataset in step 1 is generated rapidly and semi-automatically using an iterative method. A seed set for fine-tuning data is constructed to guide the automatic generation of subsequent data. The construction process uses the SELF-INSTRUCT dataset generation framework. The automatic generation of training data is achieved by constructing and utilizing existing language models for expansion. The first step in the iterative generation of the dataset is to construct a few-sample prompt words based on the seed set, and to generate new user modeling instructions using a large language model. After obtaining the modeling instructions, the parameter information of the component model is randomly generated as the input part of the fine-tuning data. The modeling instructions and the randomly generated model parameter information are substituted into a predefined code template to obtain the corresponding modeling code, thus obtaining the complete fine-tuning data.
4. The method for generating a simulation model of a thermal-hydraulic system based on AIGC as described in claim 1, characterized in that: In step 2, the LoRA fine-tuning of the pre-trained language model is implemented using the peft and transformer libraries. In the peft library, the LoraConfig and get_peft_model methods are used to convert the pre-trained language model into a LoRA model. The LoraConfig method is used to define the model parameters and training hyperparameters used during LoRA fine-tuning, and the get_peft_model method converts the corresponding language model into the corresponding LoRA language model according to LoraConfig.
5. The method for generating a simulation model of a thermal-hydraulic system based on AIGC as described in claim 4, characterized in that: After obtaining the LoRA model in step 2, the TrainingArguments method and Trainer class in the transformer library are used to fine-tune the LoRA model. The TrainingArguments method is used to define the model fine-tuning hyperparameters, and the Trainer class performs fine-tuning training based on the model fine-tuning hyperparameters corresponding to TrainingArguments.
6. The method for generating a simulation model of a thermal-hydraulic system based on AIGC as described in claim 1, characterized in that: In step 3, the task decomposition agent decomposes the requirements into a series of code generation agent subtasks, generates corresponding code for each subtask, tests it on the graphical modeling platform, and obtains corresponding feedback information from the code generation agent until all subtasks are successfully completed. Finally, the task decomposition agent integrates all sub-task code to obtain modeling code that can meet the user's modeling requirements, and the graphical modeling platform executes the modeling to achieve the modeling requirements.
7. The method for generating a simulation model of a thermal-hydraulic system based on AIGC as described in claim 1, characterized in that: In step 3, the modeling agents are constructed using the MetaGPT multi-agent asynchronous framework. By constructing agent classes and action classes, the workflow and action behaviors of each agent are defined. When executing task decomposition actions and generating modeling code actions, the fine-tuned language model obtained in step 2 is used. Task decomposition relies on the general language understanding and logical reasoning capabilities obtained from the pre-training of the language model. Modeling code generation relies on the ability to generate modeling code using a proprietary modeling API obtained from the fine-tuning of the language model.
8. The method for generating a simulation model of a thermal-hydraulic system based on AIGC as described in claim 1, characterized in that: In step 4, the inference latency of the model is reduced and the inference throughput is increased by adjusting the maximum context length and batch size. When the multi-agent system is running locally, a request is generated to access the large language model deployed on the remote server. After generating the results, the model on the remote server will return the results to the local system via an HTTP request, thus realizing the interaction and transmission of information.