A Method for Predicting Open Channel Water Quality by Coupled Mechanistic and Non-mechanistic Models

By combining mechanistic and non-mechanistic models, a one-dimensional hydrodynamic and water quality model is constructed and coupled using an LSTM model. This solves the problem of insufficient water quality prediction accuracy, achieves high-precision prediction of open channel water quality, and supports the scientific management of the water environment.

CN119884558BActive Publication Date: 2025-10-31CHINA INST OF WATER RESOURCES & HYDROPOWER RES
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411677162.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-10-31
Estimated Expiration
2044-11-22

AI Technical Summary

Technical Problem

Existing mechanistic and non-mechanistic water quality prediction methods are insufficient to meet the prediction accuracy requirements in water environment systems, especially in the context of complex urbanization, where the results of using traditional methods alone are difficult to meet the accuracy requirements.

Method used

By combining mechanistic and non-mechanistic models, a one-dimensional hydrodynamic model and a one-dimensional water quality model are constructed and coupled using an LSTM model to predict the water quality changes in open channels in the near future. The specific steps include data collection, model construction, data preprocessing, and model coupling.

Benefits of technology

It has improved the accuracy and precision of water quality forecasting, providing an important tool for water quality trend prediction and pollution early warning, and ensuring the intelligent management of the water environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119884558B_ABST
    Figure CN119884558B_ABST
Patent Text Reader

Abstract

This invention discloses a method for predicting open channel water quality by coupling mechanistic and non-mechanistic models, comprising the following steps: Step 1, data collection; Step 2, constructing an open channel mechanistic model; Step 3, constructing an open channel non-mechanistic model; Step 4, predicting the water quality of the open channel. The method of this invention combines the advantages of two types of water quality prediction methods by coupling mechanistic and non-mechanistic models. It uses an LSTM model to predict the upper boundary flow and water quality in the near future, and uses the prediction results as the upper boundary of the hydrodynamic and water quality models to predict the water quality changes at various cross-sections along the channel in the near future. This method improves the accuracy and precision of water quality prediction, and is an important tool for conducting water quality trend prediction and pollution early warning assessment. It provides technical support for intelligent water quality safety management and offers a scientific basis for solving water pollution and formulating relevant contingency plans.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of water quality prediction technology, and in particular relates to a method for predicting open channel water quality by coupling mechanistic and non-mechanistic models. Background Technology

[0002] Water quality forecasting is a fundamental and prerequisite task for achieving precise water pollution control. To understand the pollution situation in the water environment, it is necessary to predict and extrapolate future water quality trends in a timely and effective manner, especially during sudden water pollution events and seasonal water quality problems. This involves understanding the spatiotemporal changes of pollutants and developing contingency plans in advance. Currently, commonly used forecasting methods fall into two main categories: mechanistic methods and non-mechanistic methods. Mechanistic methods use mathematical language to describe the physical, chemical, biological, and ecological changes, inherent laws, and interrelationships of water components in a water body. Commonly used models include the Streeter-Phelps model, the QUAL model, the WASP model, the QUASAR model, and the MIKE model. Non-mechanistic models include grey model forecasting and artificial neural network model forecasting. Artificial neural network models are black-box models, where each neuron has independent computational and processing capabilities. For the same network structure, it can handle both linear and nonlinear problems. When solving problems, there are no requirements regarding the structure of the actual problem, and no assumptions need to be made about the relationships between variables. Therefore, they have been widely used in various fields.

[0003] With the rapid development of society and the acceleration of urbanization, the water environment system has deteriorated. The inherent complexity of the water environment system makes it difficult to meet the accuracy requirements of prediction by simply using traditional mechanistic and non-mechanistic methods. Therefore, it is urgent to establish a water quality prediction method that couples mechanistic and non-mechanistic models to provide a scientific basis for solving water pollution and formulating relevant contingency plans. Summary of the Invention

[0004] The purpose of this invention is to provide a method for predicting open channel water quality by coupling mechanistic and non-mechanistic models, so as to solve the above-mentioned technical problems.

[0005] To achieve the above objectives, the present invention provides the following technical solution:

[0006] This invention discloses a method for predicting open channel water quality by coupling mechanistic and non-mechanistic models, the method comprising the following steps:

[0007] Step 1: Data Collection: Collect cross-sectional data of the open channel, historical hydrodynamic data, location and historical flow data of the drainage outlet and branch outlet, location and historical measured gate opening, upstream and downstream water levels of the control gate, and historical water quality data. The historical hydrodynamic data includes the upper boundary flow and water level, and the lower boundary water level data. The historical water quality data includes the upper boundary water quality data and water quality data from monitoring points along the channel. The water quality data includes permanganate index, total nitrogen, total phosphorus, and ammonia nitrogen concentration data.

[0008] Step 2: Construct an open channel mechanism model: Based on the collected data, construct an open channel mechanism model, including a one-dimensional hydrodynamic model and a one-dimensional water quality model;

[0009] Step 3: Construct an open channel non-mechanistic model: Construct an LSTM model to extract internal patterns from historical flow and water quality data at the upper boundary. Utilize the selective memory advantage of the LSTM model to predict future short-term flow and water quality. That is, the collected historical flow and water quality data at the upper boundary are preprocessed and used as input to the LSTM model, and the output is the flow and water quality data at the upper boundary in the short term.

[0010] Step 4: Predict the water quality of the open channel: Couple the one-dimensional hydrodynamic and water quality model with the LSTM model to predict the water quality of all cross-sections of the open channel in the near future. Use the preprocessed historical flow and water quality data of the upper boundary as the input of the LSTM model, and the model output is the flow and water quality data of the upper boundary in the near future. Then, use the output of the LSTM model as the upper boundary condition of the one-dimensional hydrodynamic and water quality model to predict the water quality results of all cross-sections along the open channel in the near future.

[0011] Furthermore, the data collected in step 1 is obtained through two methods: automatic monitoring stations and supplementary on-site monitoring. The collected upper boundary flow and upper boundary water quality data are long-series data with a time period of no less than 5 years. The time period of other historical data is no less than 1 year.

[0012] Furthermore, the specific process of constructing the one-dimensional hydrodynamic model in step 2 is as follows: First, the topographic elevation is interpolated based on the channel cross-section data. Then, the upper and lower boundary conditions are set according to the upper boundary flow and water level and the lower boundary water level data, respectively. The initial conditions are set according to the upper boundary initial flow and the upper boundary initial water level, i.e., the flow and water level at the beginning. Then, the source and sink terms are set according to the location of the outlet and the diversion outlet and the historical flow. The inner boundary conditions are set based on the location of the control gate and the historical measured gate opening.

[0013] By utilizing the Saint-Venant equations, which include the mass conservation equation and the momentum conservation equation, and coupling them with the gate flow control equation, continuous simulation of the channel hydraulic response process can be achieved.

[0014] Take two adjacent cross sections, i.e., cross section X L and cross section X R The river section is used as a control unit. The division of the control unit takes into account the model simulation area, water flow characteristics, computational efficiency and key physical process factors. The size and distribution of the control unit can capture the changes in flow characteristics.

[0015] The mass conservation equation is:

[0016]

[0017] In the formula: Q is the upper boundary flow, m 3 / s; A is the cross-sectional area of ​​the water passage, m² 2 I represents the lateral inflow rate, including the flow rates at the outlet and the branch outlet, in meters. 3 / s; x is the length of the river segment, in meters; t is the time, in seconds; x L Let m be the upstream boundary position of the control unit; x be the value of the control unit. R For the downstream boundary position of the control unit, m; t D The control unit calculates the start time, s; t U For t D The time corresponding to the next time step, s;

[0018] The momentum conservation equation is:

[0019]

[0020] In the formula: β is the momentum-fluidity correction coefficient, which is dimensionless; V is the volume of the control volume, in meters. 3 g is the acceleration due to gravity, in m / s². 2 J represents the initial cross-sectional area, in meters. 2 ; S is the correction value for J, dimensionless; S0 is the bottom slope, %; S f C is the friction slope, dimensionless; D (w) ρ a U 2 For wind-induced shear pressure, N·s / m 3 C D (w) ρ is the wind-generated shear pressure coefficient, dimensionless; U is the wind speed; a Wind density, kg / m 3 ρ is the density of water, kg / m³ 3 ψ is the angle between the downstream flow direction and the wind direction, in degrees; T is the width of the water surface, in meters.

[0021] The gate overcurrent control equation is:

[0022] For the channel section through which the gate flows, the water flow satisfies the continuity condition at any given time. Assuming that the flow rate at the section upstream of the gate is equal to the flow rate at the section downstream of the gate, we obtain the following formula:

[0023]

[0024] In the formula, Q gz For the flow rate through the gate, m 3 / s, Q gz =Q+I; the superscript of the variable indicates the calculation time, i.e., j+1 represents time j+1; the subscript of the variable indicates the section number, i.e., i represents the i-th section;

[0025] When regulating water flow, the water flow state at the control gate is either weir flow or gate outlet flow. Depending on whether the downstream water level affects the flow capacity, it is further divided into gate outlet free flow, gate outlet submerged flow, weir flow free flow, and weir flow submerged flow.

[0026] According to the criteria for judging weir flow and gate outflow, when e / H i When the flow rate is ≤0.65, the outflow rate should be calculated according to the gate orifice outflow formula:

[0027] when At that time, the gate is in free outflow mode:

[0028]

[0029] when At that time, the sluice gate is for submerged outflow:

[0030]

[0031] In the formula, b represents the gate opening width (m); e represents the gate opening degree (m); H i The water depth at the cross section is in meters (m). To calculate the downstream water depth after the sluice gate at the specified time, in meters; To calculate the water depth at the contraction section at a given time, m; ε j+1 The lateral contraction coefficient of the gate at the calculated moment is dimensionless; φ is the velocity coefficient, dimensionless; μ is the free outflow coefficient of the broad-crested weir-type gate orifice, dimensionless; σ s The submerged outflow coefficient of the gate is dimensionless. The total head of the cross-section at the time of calculation includes the velocity head, in meters (m).

[0032] According to the criteria for judging weir flow and gate outflow, when e / H i When the value is greater than 0.65, the weir flow formula is used for calculation:

[0033] when At that time, the outflow was submerged by the weir:

[0034]

[0035] when At that time, the flow is free outflow from the weir:

[0036]

[0037] In the formula, The depth (in meters) of the water level downstream of the sluice gate exceeding the weir crest at the calculated time. To calculate the downstream water depth at a given time, m; z s The elevation of the weir bottom is m; μ is the overflow coefficient, dimensionless; the flow rate Q is the gate opening e and the upstream water level. and downstream water level The function, m 3 / s.

[0038] Furthermore, the specific process of constructing the one-dimensional water quality model in step 2 is as follows: Based on the upper boundary water quality data, a water quality boundary is set, and a one-dimensional water quality model is constructed on the basis of the one-dimensional hydrodynamic model. That is, based on the flow rate and water level calculated by the Saint Vincent's South African steady flow model, the convection and diffusion of water quality indicators in the water body, dilution, the self-reaction of water quality components, the interaction between water quality components, and the influence of external sources and sinks on component concentration are considered to establish a one-dimensional mathematical model describing water quality. i The equilibrium equations for water quality indicators between cross-sections i-1 and i are as follows:

[0039]

[0040] In the formula: c i Q represents the concentration of a water quality indicator, in mg / L. i-1 Let m be the inflow rate at section i-1. 3 / s;Q i Let m be the outflow rate at section i. 3 / s;Q out The water intake flow rate between section i-1 and section i is m. 3 / s;V i Let m be the volume between section i-1 and section i. 3 E i 'and E i-1 ' are the dispersion coefficients of cross section i and cross section i-1, respectively, m 3 / d;W i For external input, mg / d; t is time, s; k is the first-order degradation coefficient of the substance calculated in the simulation, d -1 ;

[0041] The model parameters were calibrated using water quality data from monitoring sections along the route, ensuring that the error between the simulated water quality results and the measured values ​​was within the allowable range.

[0042] Furthermore, the specific process of constructing the LSTM model described in step 3 is as follows: The LSTM model is a type of temporal recurrent neural network model. The LSTM model selectively retains information through a gating mechanism. An LSTM unit has three gates: an input gate, a forget gate, and an output gate. The input gate determines which new information is stored in the unit state; the forget gate controls the internal state C of the previous time step. t-1 How much information needs to be forgotten; the output gate controls the current internal state C. t How much information needs to be output to the external state h? t The calculation formula is as follows:

[0043] i t =σ(w i [x t ,h t-1 +b i ]) (9)

[0044] f t =σ(w f [x t ,h t-1 +b f (10)

[0045] o t =σ(w o [x t ,h t-1 +b o (11)

[0046] In the formula, σ() is the Sigmoid activation function, with a value between [0,1], representing the weights that allow information to pass through, and i t It is the output of the input gate; w i It is the weight matrix of the input gate; f t It is the output of the forget gate; w f This is the weight matrix of the forget gate; o t It is the output of the output gate, w o It is the weight matrix of the output gate;

[0047] The collected historical flow and water quality data at the upper boundary are preprocessed, including missing value handling, data slicing, and data normalization, to ensure data quality and usability. The preprocessed data is used as training data to train the model, and the model prediction results are validated. If the prediction error is within 5%, it indicates that the prediction effect is ideal, that is, the model training is complete.

[0048] Furthermore, the missing values ​​are handled by combining Lagrange interpolation and piecewise linear interpolation, as shown in the following formula:

[0049]

[0050]

[0051] In the formula: x k For missing values, x i and x j These represent missing values, basic data, and non-basic data, respectively. For x k Interpolation results for missing values; to avoid oscillations in Lagrange interpolation due to an excessively large interpolation range, a piecewise interpolation method is used in a small range, and adjustments are made based on measured data to ensure compliance with the rules;

[0052] The data slicing is as follows: the time step of the input and output data is determined during the training of the LSTM model; the training set and the test set are divided in a 7:3 ratio, that is, 70% is the training set and 30% is the test set; data slicing is performed in the form of a sliding window to determine the optimal window value;

[0053] x t+1 =f(x) t-n x t-n+1 ,…,x t (14)

[0054] In the formula [x t-n x t-n+1, …,x t As input, a sliding window is used throughout the training process; data of a fixed time length is passed through this window to train the time series model. t+1 As input; n is the data time length;

[0055] The data normalization process is as follows: the data is normalized using the min-max normalization method, with the following formula:

[0056]

[0057] In the formula, x represents the original sample data; min(x) and max(x) are the minimum and maximum values ​​of the original sample data, respectively.

[0058] Furthermore, the specific process of coupling the one-dimensional hydrodynamic and water quality model with the LSTM model in step 4 is as follows: the LSTM model is integrated with the one-dimensional hydrodynamic and water quality model using the Fortran language. That is, the upper boundary of the LSTM model output in the short term and the flow and water quality data in the future are linked to the boundary conditions of the one-dimensional hydrodynamic and water quality model to predict the water quality of each section of the open channel in the short term. During the prediction process, it is necessary to set the number of iterations n_estimators, the maximum depth of the tree max_depth, the learning rate learning_rate, the minimum diversion loss min_gamma, and the minimum sum of the leaf node sample weights min_child_weight. The initial value of the learning rate is set to 0.1 during the prediction process. The grid search method is used to optimize the number of iterations and the maximum depth of the tree first, and then the grid search method is used to optimize the learning rate parameter. Finally, the minimum diversion loss and the minimum leaf node sample weight parameters are set.

[0059] The beneficial effects of this invention are as follows: The method described in this invention combines the advantages of two types of water quality prediction methods by coupling mechanistic and non-mechanistic models. It uses an LSTM model to predict the upper boundary flow and water quality in the near future, and uses the prediction results as the upper boundary of the hydrodynamic and water quality models to predict water quality changes at various cross-sections along the channel in the near future. This method improves the accuracy and precision of water quality prediction, and is an important tool for conducting water quality trend prediction and pollution early warning assessment. It provides technical support for intelligent water quality safety management and offers a scientific basis for solving water pollution and formulating relevant contingency plans.

[0060] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. Attached Figure Description

[0061] Figure 1 This is a schematic diagram of the method flow described in this invention;

[0062] Figure 2 This is a schematic diagram of the control unit;

[0063] Figure 3 This is a schematic diagram of the upstream Taocha Canal Head and the downstream Beijuma River cross-section in Example 1;

[0064] Figure 4 This is a schematic diagram of the upper boundary flow process in Example 1;

[0065] Figure 5 This is a schematic diagram of the lower boundary water level process in Example 1;

[0066] Figure 6 This is a schematic diagram comparing the simulated and measured results of the water level before and after the gate and the flow rate through the gate in Example 1.

[0067] Figure 7 This is a schematic diagram illustrating the change process of water quality data at the upper boundary of the water quality model in Example 1;

[0068] Figure 8 This is a schematic diagram showing the comparison between the water quality model simulation and the actual measurement results in Example 1;

[0069] Figure 9 This is a schematic diagram of the LSTM model calibration and verification in Example 1;

[0070] Figure 10 This is a comparison chart of simulated and measured water quality results at the main cross-sections along the route in Example 1. Detailed Implementation

[0071] This invention discloses a method for predicting open channel water quality by coupling mechanistic and non-mechanistic models, such as... Figure 1 As shown, the method includes the following steps:

[0072] Step 1: Data Collection. Collect cross-sectional data of the open channel, historical hydrodynamic data (including upper boundary flow and water level, lower boundary water level, etc.), location and historical flow data of drainage outlets and branch outlets, location and historical measured gate opening, upstream and downstream water levels of hydraulic structures such as control gates, and historical water quality data (including upper boundary water quality data and water quality data from monitoring points along the channel; water quality data includes concentrations of permanganate index, total nitrogen, total phosphorus, and ammonia nitrogen). This data is generally obtained through automatic monitoring stations and supplementary on-site monitoring. The collected upper boundary flow and water quality data are long-term data, generally with a time span of no less than 5 years; other historical data generally have a time span of no less than 1 year.

[0073] Step 2: Constructing an open channel mechanism model: Based on the collected data, construct an open channel mechanism model, including a one-dimensional hydrodynamic model and a one-dimensional water quality model. This includes the following steps:

[0074] Step 21: Construct a one-dimensional hydrodynamic model: Construct a one-dimensional hydrodynamic model that can simulate complex hydraulic structures. First, interpolate the topographic elevation based on the channel cross-section data. Then, set the upper and lower boundary conditions based on historical hydrodynamic data such as the upper boundary flow and water level, and the lower boundary water level. Set the initial conditions based on the upper boundary initial flow and the upper boundary initial water level (i.e., the flow and water level at the beginning). Then, set the source and sink terms based on the location of the outlet and the diversion outlet and the historical flow. Finally, set the inner boundary conditions based on the location of hydraulic structures such as the control gate and the historical measured gate opening.

[0075] By utilizing the Saint-Venant equations, which include the continuity equations (mass conservation equations) reflecting the law of mass conservation and the motion equations (momentum conservation equations) reflecting the law of momentum conservation, and coupling them with the gate flow control equations, continuous simulation of the channel hydraulic response process can be achieved.

[0076] Among them, two adjacent cross sections, namely cross section X L and cross section X R The river section between them serves as a control unit, such as Figure 2 The diagram shown is a schematic of the control unit. The division of the control unit needs to take into account factors such as the model simulation area, water flow characteristics, computational efficiency, and key physical processes. The size and distribution of the control unit usually need to accurately capture the changes in complex flow characteristics such as water flow velocity and direction.

[0077] The mass conservation equation is:

[0078]

[0079] In the formula: Q is the upper boundary flow, m 3 / s; A is the cross-sectional area of ​​the water passage, m² 2 I represents the lateral inflow rate (including the outflow from the discharge outlet and the branch outlet), in meters. 3 / s; x is the length of the river segment, in meters; t is the time, in seconds; x L Let m be the upstream boundary position of the control unit; x be the value of the control unit. R For the downstream boundary position of the control unit, m; t D The control unit calculates the start time, s; t U For t D The time corresponding to the next time step, s.

[0080] The momentum conservation equation is:

[0081]

[0082] In the formula: β is the momentum-fluidity correction coefficient, which is dimensionless; V is the volume of the control volume, in meters. 3 g is the acceleration due to gravity, in m / s². 2 J represents the initial cross-sectional area, in meters. 2 ; S is the correction value for J, dimensionless; S0 is the bottom slope, %; S f C is the friction slope, dimensionless; D (w) ρ a U 2 For wind-induced shear pressure, N·s / m 3 C D (w) ρ is the wind-generated shear pressure coefficient, dimensionless; U is the wind speed; a Wind density, kg / m3 ρ is the density of water, kg / m³ 3 ψ is the angle between the downstream flow direction and the wind direction, in degrees; T is the width of the water surface, in meters.

[0083] Gate overcurrent control equation:

[0084] For a typical gate-controlled channel section, the water flow satisfies the continuity condition at any given time. Assuming the flow rate at the section upstream of the gate is equal to the flow rate at the section downstream of the gate, the following formula can be obtained:

[0085]

[0086] In the formula, Q gz For the flow rate through the gate, m 3 / s, Q gz =Q+I; the superscript of the variable indicates the calculation time, such as j+1 indicating time j+1; the subscript of the variable indicates the section number, such as i indicating the i-th section.

[0087] When regulating water flow, the flow state at the control gate can be either weir flow or gate outlet flow. Depending on whether the downstream water level affects the flow capacity, it can be further divided into gate outlet free flow, gate outlet submerged flow, weir flow free flow, and weir flow submerged flow. The corresponding empirical formulas are generally obtained through experiments.

[0088] According to the criteria for judging weir flow and gate outflow, when e / H i When the flow rate is ≤0.65, the outflow rate should be calculated according to the gate orifice outflow formula:

[0089] when At that time, the gate is in free outflow mode:

[0090]

[0091] when At that time, the sluice gate is for submerged outflow:

[0092]

[0093] In the formula, b represents the gate opening width (m); e represents the gate opening degree (m); H i The water depth at the cross section is in meters (m). To calculate the downstream water depth after the sluice gate at the specified time, in meters; To calculate the water depth at the contraction section at a given time, m; ε j+1 The lateral contraction coefficient of the gate at the calculated moment is dimensionless; φ is the velocity coefficient, dimensionless; μ is the free outflow coefficient of the broad-crested weir-type gate orifice, dimensionless; σ s The submerged outflow coefficient of the gate is dimensionless. The total head of the cross-section, including the velocity head, is given in meters at the time of calculation.

[0094] According to the criteria for judging weir flow and gate outflow, when e / H i When the value is greater than 0.65, the weir flow formula should be used for calculation.

[0095] when At that time, the outflow was submerged by the weir:

[0096]

[0097] when At that time, the flow is free outflow from the weir:

[0098]

[0099] In the formula, The depth (in meters) of the water level downstream of the sluice gate exceeding the weir crest at the calculated time. To calculate the downstream water depth at a given time, m; z s The elevation of the weir bottom is m; μ is the overflow coefficient, dimensionless; the flow rate Q is the gate opening e and the upstream water level. and downstream water level The function, m 3 / s.

[0100] Step 22: Construct a one-dimensional water quality model: Based on the upper boundary water quality data, set the water quality boundary and construct a one-dimensional water quality model on the basis of the one-dimensional hydrodynamic model. Use water quality data from monitoring sections along the route to calibrate the model parameters so that the error between the simulated water quality results and the measured values ​​at the sections along the route is within a reasonable range (the allowable error range).

[0101] Based on the flow rate and water level calculated by the Saint Vincent's South African steady-flow model, and considering the convection and diffusion, dilution, self-reaction of water quality indicators (such as total nitrogen, total phosphorus, ammonia nitrogen, permanganate index, etc.) in the water body, the interactions between water quality components, and the influence of external sources and sinks on component concentrations, a one-dimensional mathematical model describing water quality is established for a given concentration c. i The equilibrium equations for water quality indicators between cross-sections i-1 and i are as follows:

[0102]

[0103] In the formula: c i Q represents the concentration of a water quality indicator, in mg / L. i-1 Let m be the inflow rate at section i-1. 3 / s;Q i Let m be the outflow rate at section i. 3 / s;Q out The water intake flow rate between section i-1 and section i is m. 3 / s;V i Let m be the volume between section i-1 and section i.3 E i 'and E i-1 ' are the dispersion coefficients of cross section i and cross section i-1, respectively, m 3 / d;W i For external input, mg / d; t is time, s; k is the first-order degradation coefficient of the substance calculated in the simulation, d -1 .

[0104] Step 3: Constructing a non-mechanistic open channel model: Building an LSTM (Long Short-Term Memory) model: The LSTM model is a type of temporal recurrent neural network model, adept at handling and predicting events with relatively long time series intervals and delays. The LSTM model selectively retains information through a gating mechanism. An LSTM unit has three gates: the input gate, the forget gate, and the output gate. The input gate determines which new information is stored in the unit state; the forget gate controls the internal state C of the previous time step. t-1 How much information needs to be forgotten; the output gate controls the current internal state C. t How much information needs to be output to the external state h? t The calculation formula is as follows:

[0105] i t =σ(w i [x t ,h t-1 +b i ]) (9)

[0106] f t =σ(w f [x t ,h t-1 +b f (10)

[0107] o t =σ(w o [x t ,h t-1 +b o (11)

[0108] In the formula, σ() is the Sigmoid activation function, with a value between [0,1], representing the weights that allow information to pass through, and i t It is the output of the input gate; w i It is the weight matrix of the input gate; f t It is the output of the forget gate; w f This is the weight matrix of the forget gate; o t It is the output of the output gate, w o It is the weight matrix of the output gate.

[0109] The internal patterns are extracted from the historical flow and water quality data of the upper boundary. The selective memory advantage of the LSTM model is used to predict the short-term flow and water quality of the future. That is, the collected historical flow and water quality data of the upper boundary are preprocessed and used as the input of the LSTM model. The output is the flow and water quality data of the upper boundary in the short term (usually one week).

[0110] The collected historical flow and water quality data at the upper boundary are preprocessed, including missing value handling, data slicing, and data normalization, to ensure data quality and usability. The preprocessed data is then used as training data to train the model, and the model's prediction results are validated. If the prediction error is within 5%, it indicates that the prediction effect is ideal, and the model training is complete.

[0111] Specifically, missing values ​​are handled by combining Lagrange interpolation and piecewise linear interpolation, as shown in the following formula:

[0112]

[0113] In the formula: x k For missing values, x i and x j These represent missing values, basic data, and non-basic data, respectively. For x k Interpolation results for missing values. To avoid oscillations in Lagrange interpolation due to an excessively large interpolation range, a piecewise interpolation method is used within a small range, and adjustments are made based on measured data to ensure conformity.

[0114] Data slicing involves determining the time steps of the input and output data during LSTM model training. The training and test sets are divided in a 7:3 ratio, with 70% for training and 30% for testing. Data slicing is performed using a sliding window to determine the optimal window size.

[0115] x t+1 =f(x) t-n x t-n+1 ,…,x t (14)

[0116] In the formula [x t-n x t-n+1 ,…,x t As input, a sliding window is used throughout the training process; data of a fixed time length is passed through this window to train the time series model. t+1 As input; n is the data time length; training the model with different historical data lengths will produce different results.

[0117] Data normalization is necessary because different water quality indicators vary significantly in magnitude, requiring standardization to prevent model divergence during training. The min-max standardization method is used for data normalization, as shown in the following formula:

[0118]

[0119] In the formula, x represents the original sample data; min(x) and max(x) are the minimum and maximum values ​​of the original sample data, respectively.

[0120] Step 4: Predict the water quality of the open channel: Couple the one-dimensional hydrodynamic and water quality model with the LSTM model to predict the water quality of all cross-sections of the open channel in the near future. The specific prediction process is as follows: Use the preprocessed historical measured flow and water quality data of the upper boundary as input to the LSTM model. The model output is the flow and water quality data of the upper boundary in the near future. Then, use the output of the LSTM model as the upper boundary condition of the one-dimensional hydrodynamic and water quality model to predict the water quality results (i.e., the concentrations of water quality indicators such as permanganate index, total nitrogen, ammonia nitrogen, and total phosphorus) of all cross-sections along the open channel in the near future.

[0121] Specifically, an LSTM model is integrated with a one-dimensional hydrodynamic and water quality model using Fortran. This involves linking the upper boundary of the LSTM model's output—future short-term flow and water quality data—to the boundary conditions of the one-dimensional hydrodynamic and water quality model, enabling prediction of water quality at various cross-sections of the open channel in the near future. During the prediction process, the following parameters need to be set: the number of iterations (n_estimators), the maximum tree depth (max_depth), the learning rate (learning_rate), the minimum split loss (min_gamma), and the minimum sum of leaf node sample weights (min_child_weight). The initial learning rate is set to 0.1. A grid search method is used to first optimize the number of iterations and the maximum tree depth, followed by further optimization of the learning rate parameter using the grid search method. Finally, the minimum split loss and the minimum leaf node sample weight parameters are set.

[0122] Example 1

[0123] This embodiment is an application example of the above method.

[0124] This embodiment discloses a method for predicting open channel water quality by coupling mechanistic and non-mechanistic models, including the following steps:

[0125] Step 1: Data Collection: Collect topographic data of the Taocha-Beijuma River section, the flow and water level processes of the Taocha section at the upper boundary in 2018, the water level process of the Beijuma River section at the lower boundary in 2018, the location and flow of the drainage outlets and diversion outlets along the route, the water level in front of the gate, the water level after the gate, and the flow through the gate at each control gate along the route in 2018, the water quality process of the Taocha section at the upper boundary in 2018, and the water quality process of each water quality monitoring section along the route in 2018.

[0126] Step 2: Constructing an open channel mechanism model: This involves building a one-dimensional hydrodynamic model and a water quality model. Taking the South-to-North Water Diversion Project's central route as an example, the simulation scope covers the section from the Taocha headworks to the North Juma River, with a total simulated length of 1197 km and 1582 cross-sections. The upstream Taocha headworks and the downstream North Juma River cross-sections are shown below. Figure 3 As shown. Upper boundary: The hydrodynamic model uses the 2018 flow process at the Taocha headworks gate as the inflow boundary, as shown. Figure 4 As shown. Lower boundary: The hydrodynamic model uses the 2018 water level process of the Beijuma River control gate as the downstream boundary, as shown. Figure 5 As shown. Initial conditions: The initial conditions of the model are the flow rate and water level at the Taocha headworks control gate on January 1, 2018. Inner boundary: There are 61 control gates along the section from Taocha headworks to the North Juma River, and the gate type is arc gate. Source and sink terms: The flow process of the diversion gate and the drainage gate in 2018 is used as the source and sink terms. There are 74 diversion gates and 53 drainage gates in the section from Taocha to the North Juma River.

[0127] Simulation results of water level upstream and downstream of the control gate, and flow rate through the gate are as follows: Figure 6 As shown, the average relative error between the simulated and measured water levels before and after each control gate is less than 0.05%, and the average relative error of the flow rate through the gate is less than 5%, indicating good simulation results.

[0128] The upper boundary of the water quality model uses the measured water quality data from Taocha in 2018, such as... Figure 7 As shown. A water quality model is constructed based on a one-dimensional hydrodynamic model. The model is calibrated and validated using measured water quality data from cross-sections along the flow path (such as the flow channel). Comparisons between simulations and measurements are shown in the figure. Figure 8 As shown.

[0129] Step 3: Constructing a non-mechanistic open channel model: Since the research object selected in this embodiment is a water diversion project, the future flow rate at the Taocha section is determined by the engineering scheduling procedures. Therefore, this embodiment does not need to use an LSTM model to predict the flow rate, but only uses an LSTM model to predict the water quality. For the Taocha section, an LSTM model is constructed, and the LSTM model is validated using measured water quality data from 2017 to 2021. The results are as follows... Figure 9As shown, the average relative errors of the predictions for permanganate index, total nitrogen, total phosphorus, and ammonia nitrogen were 0.56%, 0.40%, 2.01%, and 0.06%, respectively, indicating that the prediction results were ideal.

[0130] Step 4: Predicting the water quality of the open channel: This embodiment takes the South-to-North Water Diversion Project's central route as an example. A calibrated and validated LSTM model is used to predict the water quality data for Taocha over the next 7 days (January 1st-7th, 2022). This data is then used as the upper boundary of the one-dimensional hydrodynamic and water quality model to predict the spatiotemporal distribution of water quality along the central route's main canal over the next 7 days. The simulation and measured results for the main cross-sections along the route are shown below. Figure 10 As shown in the figure, the average accuracy rate of water quality indicator prediction for the main cross-sections reached 91%.

[0131] Finally, it should be noted that the above description is only used to illustrate the technical solution of the present invention and not to limit it. Although the present invention has been described in detail with reference to the preferred arrangement, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A method for predicting open channel water quality using coupled mechanistic and non-mechanistic models, characterized in that, The method includes the following steps: Step 1: Data Collection: Collect cross-sectional data of the open channel, historical hydrodynamic data, location and historical flow data of the drainage outlet and branch outlet, location and historical measured gate opening, upstream and downstream water levels of the control gate, and historical water quality data. The historical hydrodynamic data includes the upper boundary flow and water level, and the lower boundary water level data. The historical water quality data includes the upper boundary water quality data and water quality data from monitoring points along the channel. The water quality data includes permanganate index, total nitrogen, total phosphorus, and ammonia nitrogen concentration data. Step 2: Construct an open channel mechanism model: Based on the collected data, construct an open channel mechanism model, including a one-dimensional hydrodynamic model and a one-dimensional water quality model; Step 3: Construct an open channel non-mechanistic model: Construct an LSTM model to extract internal patterns from historical flow and water quality data at the upper boundary. Utilize the selective memory advantage of the LSTM model to predict future short-term flow and water quality. That is, the collected historical flow and water quality data at the upper boundary are preprocessed and used as input to the LSTM model, and the output is the flow and water quality data at the upper boundary in the short term. Step 4: Predict the water quality of the open channel: Couple the one-dimensional hydrodynamic and water quality model with the LSTM model to predict the water quality of all cross-sections of the open channel in the near future. Use the preprocessed historical flow and water quality data of the upper boundary as the input of the LSTM model, and the model output is the flow and water quality data of the upper boundary in the near future. Then, use the output of the LSTM model as the upper boundary condition of the one-dimensional hydrodynamic and water quality model to predict the water quality results of all cross-sections along the open channel in the near future. The specific process of coupling the one-dimensional hydrodynamic and water quality model with the LSTM model is as follows: The LSTM model is integrated with the one-dimensional hydrodynamic and water quality model using Fortran language. Specifically, the upper boundary of the LSTM model outputs the flow and water quality data for the near future, which are then linked to the boundary conditions of the one-dimensional hydrodynamic and water quality model. This allows for the prediction of water quality at various cross-sections of the open channel in the near future. During the prediction process, the following parameters need to be set: iteration count n_estimators, maximum tree depth max_depth, learning rate learning_rate, minimum diversion loss min_gamma, and minimum leaf node sample weight sum min_child_weight. The initial learning rate is set to 0.

1. A grid search method is used to first optimize the iteration count and maximum tree depth, followed by further optimization of the learning rate parameter. Finally, the minimum diversion loss and minimum leaf node sample weight parameters are set.

2. The method for predicting open channel water quality based on coupled mechanistic and non-mechanistic models according to claim 1, characterized in that, The data collected in step 1 were obtained through two methods: automatic monitoring stations and supplementary on-site monitoring. The collected upper boundary flow and upper boundary water quality data are long-series data with a time period of no less than 5 years. The time period of other historical data is no less than 1 year.

3. The method for predicting open channel water quality based on coupled mechanistic and non-mechanistic models according to claim 1, characterized in that, The specific process of constructing the one-dimensional hydrodynamic model in step 2 is as follows: First, the topographic elevation is interpolated based on the channel cross-section data. Then, the upper and lower boundary conditions are set according to the upper boundary flow and water level and the lower boundary water level data, respectively. The initial conditions are set according to the upper boundary initial flow and the upper boundary initial water level, i.e., the flow and water level at the beginning. Then, the source and sink terms are set according to the location of the outlet and the diversion outlet and the historical flow. The inner boundary conditions are set according to the location of the control gate and the historical measured gate opening. By utilizing the Saint-Venant equations, which include the mass conservation equation and the momentum conservation equation, and coupling them with the gate flow control equation, continuous simulation of the channel hydraulic response process can be achieved. Take two adjacent cross sections, i.e., cross section X L and cross section X R The river section is used as a control unit. The division of the control unit takes into account the model simulation area, water flow characteristics, computational efficiency and key physical process factors. The size and distribution of the control unit can capture the changes in flow characteristics. The mass conservation equation is: In the formula: Q is the upper boundary flow, m 3 / s; A is the cross-sectional area of ​​the water passage, m² 2 I represents the lateral inflow rate, including the flow rates at the outlet and the branch outlet, in meters. 3 / s; x is the length of the river segment, in meters; t is the time, in seconds; x L Let m be the upstream boundary position of the control unit; x be the value of the control unit. R For the downstream boundary position of the control unit, m; t D The control unit calculates the start time, s; t U For t D The time corresponding to the next time step, s; The momentum conservation equation is: In the formula: β is the momentum-fluidity correction coefficient, which is dimensionless; V is the volume of the control volume, in meters. 3 g is the acceleration due to gravity, m / s² 2 J represents the initial cross-sectional area, in meters. 2 ; The correction factor for J is dimensionless; S0 represents the bottom slope, %; S f C is the friction slope, dimensionless; D (w) ρ a U 2 For wind-induced shear pressure, N·s / m 3 C D (w) is the wind-induced shear pressure coefficient, dimensionless; U represents wind speed; ρ a Wind density, kg / m 3 ρ is the density of water, kg / m³ 3 ψ is the angle between the downstream flow direction and the wind direction, in degrees; T is the width of the water surface, in meters. The gate overcurrent control equation is: For the channel section through which the gate flows, the water flow satisfies the continuity condition at any given time. Assuming that the flow rate at the section upstream of the gate is equal to the flow rate at the section downstream of the gate, we obtain the following formula: In the formula, Q gz For the flow rate through the gate, m 3 / s, Q gz =Q+I; the superscript of the variable indicates the calculation time, i.e., j+1 represents time j+1; the subscript of the variable indicates the section number, i.e., i represents the i-th section; When regulating water flow, the water flow state at the control gate is either weir flow or gate outlet flow. Depending on whether the downstream water level affects the flow capacity, it is further divided into gate outlet free flow, gate outlet submerged flow, weir flow free flow, and weir flow submerged flow. According to the criteria for judging weir flow and gate outflow, when e / H i When the flow rate is ≤0.65, the outflow rate should be calculated according to the gate orifice outflow formula: when At that time, the gate is in free outflow mode: when At that time, the sluice gate is for submerged outflow: In the formula, b represents the gate opening width (m); e represents the gate opening degree (m); H i The water depth at the cross section is in meters (m). To calculate the downstream water depth (m) after the sluice gate at the specified time; To calculate the water depth at the contraction section at a given time, m; ε j+1 The lateral contraction coefficient of the gate at the time of calculation is dimensionless; φ is the velocity coefficient, dimensionless. μ is the free outflow coefficient of a broad-crested weir-type gate, which is dimensionless; σ s The submerged outflow coefficient of the gate is dimensionless. The total head of the cross-section at the time of calculation includes the velocity head, in meters (m). According to the criteria for judging weir flow and gate outflow, when e / H i When the value is greater than 0.65, the weir flow formula is used for calculation: when At that time, the outflow was submerged by the weir: when At that time, the flow is free outflow from the weir: In the formula, The depth (in meters) of the water level downstream of the sluice gate exceeding the weir crest at the calculated time. To calculate the downstream water depth at a given time, m; z s The elevation of the weir bottom is m; μ is the overflow coefficient, dimensionless. The flow rate Q is the gate opening e and the upstream water level. and downstream water level The function, m 3 / s.

4. The method for predicting open channel water quality based on a coupled mechanistic and non-mechanistic model according to claim 3, characterized in that, The specific process of constructing a one-dimensional water quality model in step 2 is as follows: Based on the upper boundary water quality data, a water quality boundary is set. A one-dimensional water quality model is then constructed based on the one-dimensional hydrodynamic model. Specifically, based on the flow rate and water level calculated by the Saint Vincent's South African steady-flow model, a one-dimensional mathematical model describing water quality is established, considering the convection and diffusion of water quality indicators in the water body, dilution, the self-reaction of water quality components, the interaction between water quality components, and the influence of external sources and sinks on component concentrations. This model is then applied to a specific concentration c. i The equilibrium equations for water quality indicators between cross-sections i-1 and i are as follows: In the formula: c i Q represents the concentration of a water quality indicator, in mg / L. i-1 Let m be the inflow rate at section i-1. 3 / s;Q i Let m be the outflow rate at section i. 3 / s;Q out The water intake flow rate between section i-1 and section i is m. 3 / s;V i Let m be the volume between section i-1 and section i. 3 ; E i 'and E i-1 ' are the dispersion coefficients of cross section i and cross section i-1, respectively, m 3 / d;W i For external input, mg / d; t is time, s; k is the first-order degradation coefficient of the substance calculated in the simulation, d -1 ; The model parameters were calibrated using water quality data from monitoring sections along the route, ensuring that the error between the simulated water quality results and the measured values ​​was within the allowable range.

5. The method for predicting open channel water quality based on a coupled mechanistic and non-mechanistic model according to claim 1, characterized in that, The specific process of constructing the LSTM model in step 3 is as follows: The LSTM model is a type of temporal recurrent neural network model. The LSTM model selectively retains information through a gating mechanism. An LSTM unit has three gates: the input gate, the forget gate, and the output gate. The input gate determines which new information is stored in the unit state; the forget gate controls the internal state C of the previous time step. t-1 How much information needs to be forgotten; the output gate controls the current internal state C. t How much information needs to be output to the external state h? t The calculation formula is as follows: q t =σ(w i [x t ,h t-1 +b i ]) (9)f t =σ(w f [x t ,h t-1 +b f ]) (10)o t =σ(w o [x t ,h t-1 +b o In equation (11), σ() is the Sigmoid activation function with a value between [0,1], representing the weights that allow information to pass through, and q t It is the output of the input gate; w i It is the weight matrix of the input gate; f t It is the output of the forget gate; w f It is the weight matrix of the forget gate; o t It is the output of the output gate, w o It is the weight matrix of the output gate; The collected historical flow and water quality data at the upper boundary are preprocessed, including missing value handling, data slicing, and data normalization, to ensure data quality and availability. The preprocessed data is used as training data to train the model, and the model's prediction results are verified. If the prediction error is within 5%, it indicates that the prediction effect is ideal, that is, the model training is complete.

6. The method for predicting open channel water quality based on a coupled mechanistic and non-mechanistic model according to claim 5, characterized in that, The missing values ​​are handled by combining Lagrange interpolation and piecewise linear interpolation, as shown in the following formula: In the formula: x k For missing values, x i and x j These represent missing values, basic data, and non-basic data, respectively. For x k Interpolation results for missing values; to avoid oscillations in Lagrange interpolation due to an excessively large interpolation range, a piecewise interpolation method is used in a small range, and adjustments are made based on measured data to ensure compliance with the rules; The data slicing is as follows: the time step of the input and output data is determined during the training of the LSTM model; the training set and the test set are divided in a 7:3 ratio, that is, 70% is the training set and 30% is the test set; data slicing is performed in the form of a sliding window to determine the optimal window value; x t+1 =f(x t-n ,x t-n+1 ,…,x t ) (14) In the formula [x t-n x t-n+1, …,x t As input, a sliding window is used throughout the training process; data of a fixed time length is passed through this window to train the time series model. t+1 As input; n is the data time length; The data normalization process is as follows: the data is normalized using the min-max normalization method, with the following formula: In the formula, x represents the original sample data; min(x) and max(x) are the minimum and maximum values ​​of the original sample data, respectively.

Citation Information

Patent Citations

  • River monitoring section water quality prediction method

    CN115526378A

  • Multi-field coupled lb simulation method and system for heat and mass transfer flow, and storage medium

    US20240311536A1