Transform-based reservoir dam front vertical water temperature prediction method

Through the Transformer-based water temperature prediction method, data normalization and model construction are used to normalize the data and build the model, the problem of low efficiency of vertical water temperature prediction in front of the reservoir dam is solved, more accurate and efficient water temperature prediction is achieved, and the scientific nature of water temperature stratified scheduling of the stacked beam door is improved.

CN120337720APending Publication Date: 2025-07-18CHINA THREE GORGES CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510342259.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-21
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

The existing vertical water temperature prediction method in front of the reservoir dam is inefficient and poor transplantability, making it difficult to provide accurate future water temperature distribution prediction, affecting the scientific nature of the water temperature stratified scheduling of the Mianliangmen.

Method used

Using Transformer-based water temperature prediction method, the data is normalized through the RevIN layer and the attention mechanism of the Transformer model is used to batch output vertical water temperature data to improve prediction accuracy and efficiency.

Benefits of technology

It improves the accuracy and efficiency of water temperature prediction, simplifies the parameter optimization process, and enhances the availability of prediction results and engineering application value.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120337720A_ABST
    Figure CN120337720A_ABST
Patent Text Reader

Abstract

The invention provides a reservoir dam front vertical water temperature prediction method based on Transform, and the method comprises the following steps: 1, collecting reservoir dam front vertical historical water temperature data, and carrying out the format conversion of the historical water temperature data, and obtaining formatted model data; 2, formatted model data are processed, and then a water temperature prediction model is built; 3, training the water temperature prediction model, and testing the water temperature prediction model; 4, displaying a test set result; and step 5, model prediction. The model firstly considers that a RevIN layer converts normalized data into the same distribution type, model errors can be reduced, then a Transform model is adopted, the model considers an attention mechanism, water temperature distribution differences in different time periods can be fully captured, model precision is improved, finally vertical water temperature data are output in batches, and prediction efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of water conservancy projects, and particularly relates to a method for predicting the vertical water temperature in front of a reservoir dam based on Transformer. Background Technique

[0002] During the water temperature stratification scheduling process of the stoplog gates in a reservoir, when formulating the water temperature stratification scheduling plan, generally, the number of lowered stoplog gates is selected based on the experience of the managers, and the timing and number of lowered gates are often not determined in advance. The main reason is that the water temperature distribution in front of the dam in the coming year is uncertain. If the vertical water temperature distribution in front of the dam in the coming year can be predicted in advance, it can provide a reference when formulating the stoplog gate lowering plan. Therefore, the technology for predicting the vertical water temperature in front of the dam in the future is a difficulty faced by the current water temperature stratification scheduling of stoplog gates.

[0003] Currently, the prediction of the vertical water temperature distribution in front of a reservoir dam mainly adopts semi-empirical methods and single-point prediction models. Among them, the semi-empirical methods mainly rely on the selected empirical functions, and use methods such as neural networks to predict the parameters in the empirical functions to obtain the vertical water temperature distribution; the single-point prediction model mainly adopts a point-to-point prediction method, that is, multiple neural network models are established for each point on the vertical water temperature distribution and simulated one by one. The above two methods are less efficient and less portable. Summary of the Invention

[0004] In view of the deficiencies of the existing methods for predicting the vertical water temperature in front of a reservoir dam, the present invention provides a method for predicting the vertical water temperature in front of a reservoir dam based on Transformer to solve the problem of predicting the vertical water temperature in front of the dam. This model first considers the RevIN layer to transform the normalized data into the same distribution type, which can reduce the model error. Then, the Transformer model is adopted. The model considers the attention mechanism, which can fully capture the differences in water temperature distribution between different time periods and improve the model accuracy. Finally, the vertical water temperature data is output in batches, which improves the prediction efficiency.

[0005] To achieve the above technical features, the object of the present invention is achieved as follows: A method for predicting the vertical water temperature in front of a reservoir dam based on Transformer includes the following steps: Step 1, collect the historical vertical water temperature data in front of the reservoir dam, and perform format conversion on the historical water temperature data to obtain formatted model data; Step 2, process the formatted model data, and then build a water temperature prediction model; Step 3, train the water temperature prediction model and test the water temperature prediction model; Step 4, display the results of the test set; Step 5, model prediction.

[0006] Preferably, the historical water temperature data in step 1 is in the elevation-water temperature data format. To ensure that the input data meets the model requirements, the data needs to be converted into a fixed format. Then, the historical water temperature data is converted into water depth-water temperature data, and finally, the formatted model data is obtained.

[0007] Preferably, the specific steps for converting the historical water temperature data into water depth-water temperature data are as follows: Taking the elevation of the surface water temperature as 0m, the water temperature at the next point is taken at a fixed interval, and the water temperatures at equal intervals at the next points are taken in turn until the appropriate depth is reached.

[0008] Preferably, the construction of the water temperature prediction model in step 2 specifically includes: Step 2.1, first, perform normalization processing on the formatted model data to convert the formatted model data to the range of 0 to 1; Step 2.2, after determining the output step size, use the sliding window technique to select the input and output variables; Step 2.3, start building the model. First, establish a RevIN layer, which is used to fix the mean and variance of the time series to a unified distribution type; secondly, use the nn module in Pytorch to build a Transformer model; finally, output the number of predicted vertical water temperatures through the fully connected layer Linear.

[0009] Preferably, the sliding window technique in step 2.2 is specifically: using the sequence length of i:i+tw as the input and i+output_window:i+tw+output_window as the output, where tw is the length of the input sequence and output_window is the length to be predicted.

[0010] Preferably, the construction of the Transformer model in step 2.3 specifically includes positional encoding, the construction of TransformerEncoderLayer, and the construction of TransformerEncoder.

[0011] Preferably, step 3 specifically includes: After the model is trained, start to verify the model error using the test set. Since it is multi-point output, the average value of the multi-point error results is taken.

[0012] Preferably, step 4 specifically includes: Adopt a two-dimensional cloud map drawing method to display the results of the validation set and compare them with the cloud map of the true values.

[0013] Preferably, step 5 specifically includes: Prepare the data in the input format and input it into the trained model to obtain the predicted results of the vertical water temperature.

[0014] The present invention has the following beneficial effects: 1. The present invention provides a method for predicting the vertical water temperature in front of a reservoir dam based on Transformer. The present invention divides river reaches and flow levels, groups the simulated water level errors of the one-dimensional hydrodynamic model according to different flow levels, and takes the unbiased estimation of the true water level mean of each group at each water level station as the optimization objective to determine the roughness optimization direction for each flow level; according to the change in the predicted mean absolute error at each water level station before and after roughness optimization, the iteration step size is reduced, and the river channel roughness corresponding to different flow levels is iteratively optimized. Compared with the manual trial-and-error method, it greatly improves the parameter calibration efficiency and reduces uncertainty; compared with the previous roughness inversion methods, it simplifies the optimization method. This method takes the mean of the predicted water level errors at each water level station under different flow levels approaching 0 as the optimization objective, adaptively optimizes the roughness of each river reach respectively, and is easy to implement. This method can obtain more refined roughness, taking into account both the changes along the way and the changes brought by the flow rate, improving the usability and facilitating its application in engineering practice.

[0015] 2. The model of the present invention first considers that the RevIN layer transforms the normalized data into the same distribution type, which can reduce the model error. Then, the Transformer model is adopted. The model considers the attention mechanism and can fully capture the differences in water temperature distribution between different time periods, improving the model accuracy. Finally, the vertical water temperature data is output in batches, improving the prediction efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The present invention will be further described below with reference to the drawings and embodiments.

[0017] Figure 1 It is a flowchart of the method provided by the embodiment of the present invention.

[0018] Figure 2 It is a cloud map of the true values of the vertical water temperature verification set provided by Embodiment 1 of the present invention.

[0019] Figure 3 It is a cloud map of the vertical water temperature predicted by the model of Embodiment 1 of the present invention according to the verification set data. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] The embodiments of the present invention will be further described below with reference to the drawings.

[0021] Embodiment 1: Please refer to Figure 1 , a method for predicting the vertical water temperature in front of a reservoir dam based on Transformer, comprising the following steps: Step 1: Collect the historical vertical water temperature data in front of the reservoir dam. Generally, the vertical water temperature data in front of the reservoir dam is in the format of elevation-water temperature data. To ensure that the input data meets the model requirements, the historical water temperature data needs to be converted into a fixed format, converting the historical water temperature into depth-water temperature data. The main steps are as follows: Denote the elevation of the surface water temperature as 0m, take the water temperature at the next point after a fixed distance interval, and take the water temperature at the next equally spaced point in a similar manner until the appropriate depth is obtained; Step 2: Process the formatted model data and then build a water temperature prediction model. The main steps are as follows: Step 2.1: First, perform normalization processing on the formatted model data to convert the formatted model data to the range of 0 to 1; Step 2.2: After determining the output step size, use the sliding window technique to select input and output variables. For example, use the sequence length of i:i+tw as the input and i+output_window:i+tw+output_window as the output, where tw is the length of the input sequence and output_window is the length to be predicted.

[0022] Step 2.3: Start building the model. First, establish the RevIN layer. Since the mean and variance of the time series generally change over time, but their overall distribution is fixed, the RevIN layer is mainly used to fix the mean and variance of the time series to a unified distribution type, which can significantly improve the model accuracy and reduce the impact of random changes on the results. Secondly, use the nn module in Pytorch to build a Transformer model, including position encoding (PositionEncoding), building TransformerEncoderLayer, building TransformerEncoder, and finally output the number of predicted vertical water temperatures through the fully connected layer Linear. The process Figure 1 is shown as follows.

[0023] Step 3: Train the water temperature prediction model and test the water temperature prediction model; After the model is trained, start to verify the model error situation using the test set. Since it is a multi-point output, take the average of the multi-point error results.

[0024] Step 4: Display the test set results; Use the two-dimensional cloud map drawing method to display the validation set results and compare them with the real value cloud map.

[0025] Step 5: Model prediction. Prepare the data into the input format and put it into the trained model to obtain the predicted results of the vertical water temperature.

[0026] Example 2: Step 1: Taking the Xiluodu Reservoir as an example, the data of the temperature chain in front of the dam of the Xiluodu Reservoir from January to May from 2020 to 2023 was collected. The data monitored by the vertical temperature chain in front of the reservoir dam was sorted out. Since the vertical temperature chain data of the reservoir is generally in the elevation-temperature structure, it needs to be converted into the water depth-temperature structure style. Taking the surface water depth of 0m as the reference, the water temperature data was intercepted at equal intervals of water depth. Table 1 shows the data format provided in Embodiment 1 of the present invention, only showing a partial situation

[0027] Step 2: Normalize the data of each year in the 0-1 interval, and then use the sliding window technique to select the length of the input time variable. Here, the data of the previous 3 days is selected, and the time series length of the output variable is selected as 1 day for prediction output. After traversing all the data, the input and output data sets are obtained, and the training set and validation set data are divided. Step 3: Build the model. First, build the RevIN layer, then establish the position encoding module. Secondly, use the Pytorch.nn module to build the TransformerEncoderLayer layer and the TransformerEncoder layer. Finally, taking the number of vertical water temperatures as the number of variable outputs, build the fully connected layer.

[0028] Step 4: Train and validate the model, and calculate the model error.

[0029] Step 5: Using the validation set data, input the validation set data into the trained model, and output the true value cloud map of the validation set ( Figure 2 ), and the predicted value cloud map of the validation set ( Figure 3 ). Through the true value and the predicted value, it can be found that the model predicts the situation of the validation set well.

Claims

1. A vertical water temperature prediction method for the front of a reservoir dam based on Transformer, characterized in that, It includes the following steps: Step 1: Collect the historical vertical water temperature data in front of the reservoir dam, and perform format conversion on the historical water temperature data to obtain formatted model data; Step 2: Process the formatted model data, and then build a water temperature prediction model; Step 3: Train the water temperature prediction model and test the water temperature prediction model; Step 4: Display the results of the test set; Step 5: Model prediction.

2. The method for predicting the vertical water temperature in front of a reservoir dam based on Transformer according to claim 1, wherein, The historical water temperature data described in Step 1 is in the elevation-water temperature data format. To ensure that the input data meets the model requirements, the data needs to be converted to a fixed format, and then the historical water temperature data is converted to water depth-water temperature data, and finally the formatted model data is obtained.

3. The method for predicting the vertical water temperature in front of the reservoir dam based on Transformer according to claim 2, characterized in that, The specific steps to convert the historical water temperature data to water depth-water temperature data are as follows: Taking the surface water temperature elevation as 0m, take the water temperature at the next point at a fixed interval, and so on to take the water temperature at equal intervals at the next point until the appropriate depth is obtained.

4. The method for predicting the vertical water temperature in front of a reservoir dam based on Transformer according to claim 1, wherein The specific steps to build the water temperature prediction model in Step 2 include: Step 2.1: First, perform normalization processing on the formatted model data to convert the formatted model data to the range of 0 to 1; Step 2.2: After determining the output step size, use the sliding window technique to select the input and output variables; Step 2.3: Start building the model. First, establish a RevIN layer, which is used to fix the mean and variance of the time series to a unified distribution type; secondly, use the nn module in Pytorch to build a Transformer model; finally, output the number of predicted vertical water temperatures through the fully connected layer Linear.

5. The method for predicting the vertical water temperature in front of a reservoir dam based on Transformer according to claim 4, characterized in that, The sliding window technique in Step 2.2 is specifically: taking the sequence length of i:i+tw as the input and i+output_window:i+tw+output_window as the output, where tw is the length of the input sequence and output_window is the length to be predicted.

6. The method for predicting the vertical water temperature in front of a reservoir dam based on Transformer according to claim 5, characterized in that, The specific steps to build the Transformer model in Step 2.3 include position encoding, building TransformerEncoderLayer, and building TransformerEncoder.

7. The method for predicting the vertical water temperature in front of the reservoir dam based on Transformer according to claim 6, wherein Step 3 specifically includes: After the model is trained, start to verify the model error using the test set. Since it is a multi-point output, take the average of the multi-point error results.

8. The method for predicting the vertical water temperature in front of a reservoir dam based on Transformer according to claim 7, characterized in that, Step 4 specifically includes: Use the two-dimensional cloud map drawing method to display the results of the validation set and compare them with the real value cloud map.

9. The method for predicting the vertical water temperature in front of a reservoir dam based on Transformer according to claim 7, wherein, Step 5 specifically includes: Prepare the data into the input format and put it into the trained model to obtain the predicted results of the vertical water temperature.