Rapid temperature field simulation method based on multi-thread architecture and background calculation strategy

By adopting a multi-threaded architecture and background computing strategy in the two-dimensional temperature distribution simulation system of the temperature field, and using blocking queues and background computing strategies, the problems of complex calculations, time-consuming and multi-threaded data response in the existing system are solved, and asynchronous data response and efficient calculation of the fast temperature field simulation system are realized.

CN119849361AActive Publication Date: 2025-04-18ZHEJIANG UNIV
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411921517.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-18
Estimated Expiration
2044-12-25

AI Technical Summary

Technical Problem

Due to the complex and time-consuming calculations of the existing temperature field two-dimensional temperature distribution simulation system, it is unable to respond to the data playback requirements of the front-end equipment in real time, and the multi-threaded data response is prone to errors.

Method used

A rapid temperature field simulation method based on multi-threaded architecture and background computing strategy is adopted to realize data transmission and response between the main thread and the slave thread by blocking the queue, and the background computing strategy is used to call the CFD software in advance to simulate and calculate the temperature field data of the next cycle.

Benefits of technology

It effectively avoids the problem of misresponse of multi-threaded data, and solves the problem that complex model calculations cannot keep up with data playback, realizing asynchronous data response and efficient calculation of the fast temperature field simulation system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119849361A_ABST
    Figure CN119849361A_ABST
Patent Text Reader

Abstract

The invention discloses a quick temperature field simulation method based on a multi-thread architecture and a background calculation strategy, and relates to the field of information technologies and industrial processes. The method comprises the following steps: firstly, establishing data response logic of a main thread and a slave thread of a temperature field rapid simulation system based on a multi-thread architecture, blocking and releasing response actions of the threads by using a blocking queue, and improving the reliability of multi-thread data interaction; and secondly, establishing asynchronous data response logic of the temperature field rapid simulation system based on a background calculation strategy, calling CFD software in advance from a thread to simulate and calculate temperature field simulation data of a (k + 1) th period, and realizing uninterrupted asynchronous data playing and response of the temperature field rapid simulation system. According to the multi-thread asynchronous response method for the temperature field rapid simulation system, the problem that multi-thread data response of the temperature field rapid simulation system is disordered can be effectively avoided, meanwhile, the problem that calculation cannot keep up with data playing due to complex model calculation is solved, and the multi-thread asynchronous response method for the temperature field rapid simulation system with complex background calculation is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of information technology and industrial processes, and in particular, to a temperature field rapid simulation method based on a multi-threaded architecture and a background calculation strategy. Background Art

[0002] Multithreading is a form of parallelization. It is a way to split work so that it can be processed simultaneously, thereby improving work efficiency and resource utilization. Programs in different threads can be processed in parallel by different CPU cores, thereby saving computing time.

[0003] The temperature field simulation system is an indispensable simulation technology in the field of industrial processes. The actual industrial production control process must undergo a large number of simulation experiments to verify the safety and reliability of production. At the same time, in order to improve production quality, seeking more appropriate industrial production input parameters has also become one of the design goals of the temperature field simulation system. In the actual production process, the temperature distribution of the reaction chamber temperature field often reflects the intensity of production, the stage of chemical reaction, and the quality of the product. By simulating and calculating the two-dimensional temperature distribution of the temperature field, the change of the temperature field can be predicted, and the input parameters can be modified according to the prediction results to achieve the purpose of effective regulation.

[0004] However, the two-dimensional temperature distribution of the temperature field adopts a distributed partial differential equation model with a small grid division. Calculating such a model is a complex and time-consuming process. The model calculation speed cannot keep up with the real-time playback speed of the front-end device. Therefore, it is necessary to use a background calculation method to achieve asynchronous response of the temperature field simulation data.

[0005] A blocking queue is a special queue in the Java language. When the queue is empty, the operation of getting elements from the queue will be blocked, which can block the thread and put it into a waiting state until a new element is added to the queue and the thread resumes execution. The temperature field rapid simulation system is a multi-threaded system. In order to avoid timing confusion between the main thread and the slave thread, it is necessary to use a blocking queue to temporarily block the relevant threads to ensure the correctness of the main thread playing data. Summary of the invention

[0006] The purpose of the present invention is to overcome the defects in the prior art and provide a temperature field fast simulation method based on a multi-threaded architecture and background calculation strategy.

[0007] The specific technical solutions adopted by the present invention are as follows:

[0008] The present invention provides a temperature field fast simulation method based on a multi-threaded architecture and background calculation strategy, which is as follows:

[0009] S1. Establish the data response logic of the main thread and slave thread of the temperature field rapid simulation system based on the multi-threaded architecture;

[0010] S2. Establish the asynchronous data response logic of the temperature field rapid simulation system based on the background calculation strategy.

[0011] Preferably, in S1, the main thread and the slave thread perform calculations in parallel, and data transmission and response are performed through a blocking queue;

[0012] The data responses of the main thread and the slave thread both meet the following characteristics:

[0013]

[0014] Among them, X is the main thread data playback action, x i is the current moment data, α is the data response factor and is greater than 1, T is the data response cycle, Y is the slave thread data response action, y1 is the thread calculation action, y2 is the thread blocking action; k is an integer, representing a certain cycle.

[0015] Preferably, in S1, the data response logic of the main thread is as follows:

[0016] S111: Start the high-frequency timer and cyclically refresh the main thread program at a high frequency;

[0017] S112: Check whether there are any waiting results of temperature field simulation output in the response blocking queue; if there are waiting results, go to S113; if there are no waiting results, go to S115;

[0018] S113: store simulation data, and then enter S114;

[0019] S114: Calculate new temperature field control input parameters, the input parameters include main material flow and material ratio, store the simulation input parameters in the request blocking queue, and then enter S115;

[0020] S115: Determine whether the data on the front-end interface needs to be refreshed; if there is no data update, loop to S112; if there is data update, enter S116;

[0021] S116: Update the data on the front-end interface, refresh and display the two-dimensional temperature distribution results of the temperature field on the front-end interface, and then loop into S112.

[0022] Preferably, in S1, the data response logic of the slave thread is as follows:

[0023] S121: Start the slave thread;

[0024] S122: Detect whether there are temperature field simulation input parameters in the request blocking queue; if there are simulation input parameters, enter S123; if there are no simulation input parameters, the blocking queue can use its own characteristics to block the slave thread in this step, and the slave thread enters the waiting mode until it is detected that the request blocking queue has simulation input parameters, and then enters S123;

[0025] S123: taking out the temperature field simulation input parameters in the request blocking queue and storing them in an array, and then entering S124;

[0026] S124: The temperature field simulation input parameters are transmitted to the CFD software. The CFD software calculates the two-dimensional temperature distribution result of the temperature field according to the new simulation input parameters. After the calculation is completed, the two-dimensional temperature distribution result of the temperature field is returned to the slave thread.

[0027] S125: Store the two-dimensional temperature distribution result of the temperature field into the response blocking queue, and then loop into S122.

[0028] Preferably, in S2,

[0029] The main thread timing logic is:

[0030]

[0031] The slave thread timing logic is:

[0032]

[0033] Wherein, T is the data response period, and t is the current time.

[0034] Preferably, S2 is as follows:

[0035] S21: Establish communication between the temperature field rapid simulation system and the CFD software, and enter S22;

[0036] S22: Initialize and call the CFD software, simulate and calculate the temperature field simulation data of the first cycle, put the temperature field simulation results into the play queue, and enter S23;

[0037] S23: The main thread displays the temperature field simulation data in the playback queue second by second, and at the same time, the slave thread starts to calculate the temperature field simulation data of the k+1th cycle, and stores the temperature field simulation result of the k+1th cycle in the preparation queue. After the simulation of the k+1th cycle of the slave thread is completed, it enters the blocking state and enters S24;

[0038] S24: After the data in the k-th cycle playback queue is finished, the data of the k+1-th cycle in the preparation queue is stored in the playback queue, and the main thread starts playing the temperature field simulation data of the k+1-th cycle, and at the same time transmits new temperature field simulation input parameters to the slave thread, and the slave thread changes from a blocking state to a non-blocking state, and calls the CFD software to start simulating and calculating the temperature field simulation data of the k+2-th cycle, and then executes a cyclic simulation.

[0039] Compared with the prior art, the present invention has the following beneficial effects:

[0040] (1) To address the problem that multi-threaded data responses of a temperature field rapid simulation system are prone to confusion, the present invention establishes data response logic for a main thread and a slave thread of the temperature field rapid simulation system based on a multi-threaded architecture. The main thread uses a blocking queue to provide temperature field simulation input parameters, including main material flow and material ratio, to the slave thread, and blocks the slave thread after the simulation is completed until the next simulation cycle begins. The slave thread provides the main thread with a two-dimensional temperature distribution of the temperature field, and the main thread plays the data second by second until the playback is completed. Only then is a response signal given to the slave thread to start the simulation calculation of the next cycle.

[0041] (2) In order to solve the problem that the calculation of the two-dimensional temperature distribution of the temperature field in the temperature field rapid simulation system is complex and time-consuming, the present invention is based on a background calculation strategy, calls the CFD software from the thread one cycle in advance, simulates and calculates the two-dimensional temperature distribution of the temperature field, and stores the calculation results in a preparation queue. After the playback of the queue data is completed, the playback data of the next cycle can be immediately connected. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The purpose, features and advantages of the present invention can be further understood by describing the preferred embodiments of the present invention in conjunction with the accompanying drawings. The present invention is described in more detail below with reference to the accompanying drawings of the present invention. However, the present invention can also be implemented in many different forms, so it should not be considered that it is limited to the embodiments listed in the specification. On the contrary, such embodiments are provided to illustrate the implementation and completeness of the present invention, and to describe the specific implementation process of the present invention to those skilled in the art.

[0043] Figure 1 The data response logic diagram of the main thread and slave thread of the temperature field fast simulation system.

[0044] Figure 2 This is the flow chart of the background calculation method for the temperature field rapid simulation system.

[0045] Figure 3 This is the effect diagram of the background calculation method of the temperature field rapid simulation platform. DETAILED DESCRIPTION

[0046] The present invention is further described and illustrated below in conjunction with the accompanying drawings and specific embodiments. The technical features of each embodiment of the present invention can be combined accordingly without conflicting with each other.

[0047] The main thread and slave thread data response logic of the temperature field rapid simulation system are written in Java language. In Java, ArrayBlockingQueue, LinkedBlockingQueue, SynchronousQueue and other classes are generally used as the implementation form of blocking queues. The present invention uses the ArrayBlockingQueue class to define a double type blocking queue as the data response channel of the main thread and the slave thread. The present invention uses the Timer class to design the main thread timer of the temperature field rapid simulation system, and uses the Thread class to design the slave thread loop simulation logic of the temperature field rapid simulation system.

[0048] The present invention provides a temperature field rapid simulation method based on a multi-threaded architecture and background calculation strategy. The method first establishes the data response logic of the main thread and the slave thread of the temperature field rapid simulation system based on the multi-threaded architecture, and uses the blocking queue to block and release the response action of the thread to improve the reliability of multi-threaded data interaction; secondly, the asynchronous data response logic of the temperature field rapid simulation system is established based on the background calculation strategy, and the slave thread calls the CFD software to simulate and calculate the temperature field simulation data of the k+1th cycle in advance, so as to realize the uninterrupted asynchronous data playback and response of the temperature field rapid simulation system. Specifically, it includes the following two steps:

[0049] S1. Establish the data response logic of the main thread and slave thread of the temperature field rapid simulation system based on the multi-threaded architecture;

[0050] S2. Establish the asynchronous data response logic of the temperature field rapid simulation system based on the background calculation strategy.

[0051] As a preferred embodiment of the present invention, the data response logic of the main thread and the slave thread of the temperature field rapid simulation system is constructed based on the Java language. Figure 1 As shown, the temperature field fast simulation system is divided into a main thread and a slave thread. The main thread and the slave thread calculate in parallel, and transmit and respond data through a blocking queue. The data transmitted from the main thread to the slave thread include: the relevant parameters of the temperature field simulation input, specifically the main material flow rate and material ratio; the data transmitted from the slave thread to the main thread include: the relevant parameters of the temperature field simulation output, specifically the two-dimensional temperature distribution results of the temperature field. The specific implementation steps are as follows:

[0052] S11: The data response logic of the main thread is as follows:

[0053] S111: Start the high-frequency timer and cyclically refresh the main thread program at a high frequency;

[0054] S112: Check whether there are any waiting results of temperature field simulation output in the response blocking queue; if there are waiting results, go to S113; if there are no waiting results, go to S115;

[0055] S113: store simulation data, and then enter S114;

[0056] S114: Calculate new temperature field control input parameters, the input parameters include main material flow and material ratio, store the simulation input parameters in the request blocking queue, and then enter S115;

[0057] S115: Determine whether the data on the front-end interface needs to be refreshed; if there is no data update, loop to S112; if there is data update, enter S116;

[0058] S116: Update the data on the front-end interface, refresh and display the two-dimensional temperature distribution results of the temperature field on the front-end interface, and then loop into S112.

[0059] S12: The data response logic of the slave thread is as follows:

[0060] S121: Start the slave thread;

[0061] S122: Detect whether there are temperature field simulation input parameters in the request blocking queue; if there are simulation input parameters, enter S123; if there are no simulation input parameters, the blocking queue can use its own characteristics to block the slave thread in this step, and the slave thread enters the waiting mode until it is detected that the request blocking queue has simulation input parameters, and then enters S123;

[0062] S123: taking out the temperature field simulation input parameters in the request blocking queue and storing them in an array, and then entering S124;

[0063] S124: The temperature field simulation input parameters are transmitted to the CFD software. The CFD software calculates the two-dimensional temperature distribution result of the temperature field according to the new simulation input parameters. After the calculation is completed, the two-dimensional temperature distribution result of the temperature field is returned to the slave thread.

[0064] S125: Store the two-dimensional temperature distribution result of the temperature field into the response blocking queue, and then loop into S122.

[0065] The data responses of the main thread and the slave thread meet the following characteristics:

[0066]

[0067] Among them, X is the main thread data playback action, x iis the current moment data, α is the data response factor and is greater than 1, T is the data response cycle, Y is the slave thread data response action, y1 is the thread calculation action, y2 is the thread blocking action; k is an integer, representing a certain cycle.

[0068] As a preferred embodiment of the present invention, the asynchronous data response logic of the temperature field rapid simulation system is established based on the background calculation strategy. Figure 2 , 3 As shown, the CFD software uses a distributed partial differential equation model to calculate the two-dimensional temperature distribution of the temperature field, which is a complex and time-consuming process. Based on the background calculation strategy, the slave thread calls the CFD software to simulate and calculate the temperature field simulation data of the kth cycle in advance. The temperature field simulation data currently displayed by the main thread is actually the data of the k-1th cycle. When the main thread finishes playing the data of the k-1th cycle, it can play the simulation data of the kth cycle in time, and at the same time, the slave thread starts to calculate the temperature field simulation data of the k+1th cycle. This cycle is repeated to achieve asynchronous data response of the temperature field fast simulation system. The specific implementation steps are as follows:

[0069] S21: Establish communication between the temperature field rapid simulation system and the CFD software, and enter S22;

[0070] S22: Initialize and call the CFD software, simulate and calculate the temperature field simulation data of the first cycle, put the temperature field simulation results into the play queue, and enter S23;

[0071] S23: The main thread displays the temperature field simulation data in the playback queue second by second, and at the same time, the slave thread starts to calculate the temperature field simulation data of the k+1th cycle, and stores the temperature field simulation result of the k+1th cycle in the preparation queue. After the simulation of the k+1th cycle of the slave thread is completed, it enters the blocking state and enters S24;

[0072] S24: After the data in the k-th cycle playback queue is finished, the data of the k+1-th cycle in the preparation queue is stored in the playback queue, and the main thread starts playing the temperature field simulation data of the k+1-th cycle, and at the same time transmits new temperature field simulation input parameters to the slave thread, and the slave thread changes from a blocking state to a non-blocking state, and calls the CFD software to start simulating and calculating the temperature field simulation data of the k+2-th cycle, and then executes a cyclic simulation.

[0073] Main thread timing logic:

[0074]

[0075] From the thread timing logic:

[0076]

[0077] It can be seen that the method adopted in the present invention can effectively avoid the problem of disordered multi-threaded data response in the temperature field rapid simulation system, and at the same time solve the problem that the calculation cannot keep up with the data playback due to complex model calculations, thereby realizing a multi-threaded asynchronous response method for the temperature field rapid simulation system with complex background calculations.

[0078] The above-described embodiment is only a preferred solution of the present invention, but it is not intended to limit the present invention. A person skilled in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, any technical solution obtained by equivalent replacement or equivalent transformation falls within the protection scope of the present invention.

Claims

1. A temperature field fast simulation method based on multi-threaded architecture and background calculation strategy, characterized in that: The details are as follows: S1. Establish the data response logic of the main thread and slave thread of the temperature field rapid simulation system based on the multi-threaded architecture; S2. Establish the asynchronous data response logic of the temperature field rapid simulation system based on the background calculation strategy.

2. The temperature field rapid simulation method based on multi-threaded architecture and background calculation strategy according to claim 1 is characterized in that: In S1, the main thread and the slave thread perform parallel calculations, and data transmission and response are performed through a blocking queue; The data responses of the main thread and the slave thread both meet the following characteristics: Among them, X is the main thread data playback action, x i is the current moment data, α is the data response factor and is greater than 1, T is the data response cycle, Y is the slave thread data response action, y1 is the thread calculation action, y2 is the thread blocking action; k is an integer, representing a certain cycle.

3. The temperature field rapid simulation method based on multi-threaded architecture and background calculation strategy according to claim 1 is characterized in that: In S1, the data response logic of the main thread is as follows: S111: Start the high-frequency timer and cyclically refresh the main thread program at a high frequency; S112: Check whether there are any waiting results of temperature field simulation output in the response blocking queue; if there are waiting results, go to S113; if there are no waiting results, go to S115; S113: store simulation data, and then enter S114; S114: Calculate new temperature field control input parameters, the input parameters include main material flow and material ratio, store the simulation input parameters in the request blocking queue, and then enter S115; S115: Determine whether the data on the front-end interface needs to be refreshed; if there is no data update, loop to S112; if there is data update, enter S116; S116: Update the data on the front-end interface, refresh and display the two-dimensional temperature distribution results of the temperature field on the front-end interface, and then loop into S112.

4. The temperature field rapid simulation method based on multi-threaded architecture and background calculation strategy according to claim 1 is characterized in that: In S1, the data response logic of the slave thread is as follows: S121: Start the slave thread; S122: Detect whether there are temperature field simulation input parameters in the request blocking queue; if there are simulation input parameters, enter S123; if there are no simulation input parameters, the blocking queue can use its own characteristics to block the slave thread in this step, and the slave thread enters the waiting mode until it is detected that the request blocking queue has simulation input parameters, and then enters S123; S123: taking out the temperature field simulation input parameters in the request blocking queue and storing them in an array, and then entering S124; S124: The temperature field simulation input parameters are transmitted to the CFD software. The CFD software calculates the two-dimensional temperature distribution result of the temperature field according to the new simulation input parameters. After the calculation is completed, the two-dimensional temperature distribution result of the temperature field is returned to the slave thread. S125: Store the two-dimensional temperature distribution result of the temperature field into the response blocking queue, and then loop into S122.

5. The temperature field rapid simulation method based on multi-threaded architecture and background calculation strategy according to claim 1 is characterized in that: In S2, The main thread timing logic is: The slave thread timing logic is: Wherein, T is the data response period, and t is the current time.

6. The temperature field rapid simulation method based on multi-threaded architecture and background calculation strategy according to claim 1 is characterized in that: The S2 is specifically as follows: S21: Establish communication between the temperature field rapid simulation system and the CFD software, and enter S22; S22: Initialize and call the CFD software, simulate and calculate the temperature field simulation data of the first cycle, put the temperature field simulation results into the play queue, and enter S23; S23: The main thread displays the temperature field simulation data in the playback queue second by second, and at the same time, the slave thread starts to calculate the temperature field simulation data of the k+1th cycle, and stores the temperature field simulation result of the k+1th cycle in the preparation queue. After the simulation of the k+1th cycle of the slave thread is completed, it enters the blocking state and enters S24; S24: After the data in the k-th cycle playback queue is finished, the data of the k+1-th cycle in the preparation queue is stored in the playback queue, and the main thread starts playing the temperature field simulation data of the k+1-th cycle, and at the same time transmits new temperature field simulation input parameters to the slave thread, and the slave thread changes from a blocking state to a non-blocking state, and calls the CFD software to start simulating and calculating the temperature field simulation data of the k+2-th cycle, and then executes a cyclic simulation.

Citation Information

Patent Citations

  • Lock-free synchronization method for distributed real-time simulation task

    CN112379981A

  • Multi-thread data processing method, system and equipment based on blocking queue

    CN114253714A

  • Uranium hexafluoride conversion simulation platform, method and system

    CN114626160A

  • Multi-thread parallel combat simulation method and system based on hybrid propulsion

    CN114757057A

  • Multi-thread data processing method and device, equipment and storage medium

    CN116225663A