Predictive Modeling and Real-Time Safety Control Methods for Biochemical Reactors in Wastewater Treatment Plants
By combining the Koopman matrix with deep learning, a predictive model and control method for biochemical reactors are constructed, which solves the stability and safety problems in existing technologies and realizes optimized control and energy-saving operation of biochemical reactors.
Patent Information
- Application Number
- CN202311334398.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-16
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-10-16
AI Technical Summary
Existing deep learning-based real-time control methods for biochemical reactors in wastewater treatment plants lack in-depth consideration of the operational stability of the biochemical reactors. The model structure and prediction results are difficult to interpret, and there are safety risks associated with abnormal outputs. Furthermore, they cannot effectively adapt to different changes.
By combining the Koopman matrix with deep learning, a predictive model for biochemical reaction tanks, Koopman Deep Learning (Koopman-DL), is constructed through data preprocessing, statistical and kinetic feature analysis. This model is then combined with the model predictive control method, Koopman Deep Learning Model Predictive Control (Koopman-DL-MPC), to verify its rationality and safety, and to optimize the control strategy.
It improves the operational stability and adaptability of the biochemical reaction tank in the wastewater treatment plant, reduces the aeration volume, achieves optimized control and energy-saving operation, and enhances the interpretability and reliability of the model.
Smart Images

Figure CN117389142B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer simulation technology, and in particular to a method for predictive simulation and real-time safety control of biochemical reaction tanks in wastewater treatment plants. Background Technology
[0002] Model predictive control is an effective method for achieving optimized real-time control. Existing research has shown that model predictive control can improve the treatment efficiency of biochemical reactors in wastewater treatment plants, achieving refined control by leveraging predictive information and optimization model methods, and saving energy and material consumption under the same influent conditions.
[0003] Existing methods leverage the powerful fitting and learning capabilities of deep learning models to learn from extensively collected operational data of biochemical reactors in wastewater treatment plants, achieving accurate predictions of actual process flows. These deep learning models are then used as predictive inference models in model predictive control, further combined with real-time optimization model solving to obtain time-step optimal control strategies, thereby optimizing the operation of the biochemical reactors. Because this method is data-driven, it avoids the impact of model tuning and computational errors compared to traditional predictive control methods based on biochemical reactor mechanism models. Furthermore, this method trains the predictive model using measured data, demonstrating better adaptability to complex influencing factors present in real-world systems.
[0004] However, this method still has shortcomings in the context of biological reaction tanks in wastewater treatment plants, specifically in the following aspects:
[0005] 1. Current research on real-time control models for biochemical reactors in wastewater treatment plants based on deep learning only focuses on whether the effluent quality meets standards, using this as the target for optimized control. Therefore, existing methods lack in-depth consideration of the operational stability of the biochemical reactor. However, the state data of the biochemical reactor is often one of the direct factors affecting the effluent quality.
[0006] 2. Machine learning-based predictive control is a black box model. Its model cannot reflect the dynamic characteristics and laws of the operation of the biochemical reaction tank, making its model structure and prediction results difficult to interpret.
[0007] 3. Existing research primarily selects and evaluates the inputs, outputs, and structural parameters of deep learning models through cross-validation and trial and error. However, effective analysis and evaluation methods are still lacking in the context of biochemical reaction tank simulation and prediction.
[0008] 4. Since this method is data-driven, its effectiveness is highly dependent on the reliability of the training data and the deep learning model. However, existing research has shown that current deep learning models may still produce abnormal outputs under certain input conditions, which could lead to a lack of security guarantees in the control commands obtained by this method.
[0009] Therefore, improving reliability, enhancing adaptability to different changes, and reducing the aeration volume of wastewater treatment plants while ensuring effluent quality, in order to achieve optimized control, has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0010] In view of the above-mentioned deficiencies of the prior art, the present invention provides a method for predictive simulation and real-time safety control of the biochemical reaction tank of a sewage treatment plant. The purpose is to improve reliability, enhance adaptability to different changes, reduce the aeration volume of the sewage treatment plant while ensuring the quality of the effluent, and achieve optimized control.
[0011] To achieve the above objectives, this invention discloses a method for predictive simulation and real-time safety control of biochemical reaction tanks in wastewater treatment plants, based on the Koopman matrix and deep learning, comprising the following steps:
[0012] Step 1: Preprocess the raw data from the biochemical reaction tank;
[0013] Step 2: Perform statistical and kinetic characteristic analysis on the biochemical reaction tank using a data-driven approach;
[0014] Step 3: Construct a prediction and extrapolation model for biochemical reaction tanks based on the Koopman matrix and deep learning methods, namely Koopman Deep Learning (Koopman-DL).
[0015] Step 4: Establishing a biochemical reaction tank model predictive control method based on the Koopman-DL predictive model, namely Koopman-DL-MPC;
[0016] Step 5: Construct a data-driven method for verifying the rationality and safety of the biochemical reaction pool using Koopman-DL-MPC.
[0017] Preferably, in step 1, the raw data for the biochemical reaction tank refers to the status data obtained by real-time monitoring of the biochemical reaction tank;
[0018] The preprocessing refers to cleaning and statistical analysis of the raw data;
[0019] The cleaning process refers to removing noise and abnormal fluctuations caused by equipment or environmental disturbances from the original data, and then supplementing the removed data using a time-averaging method.
[0020] More preferably, in step 1, removing the original data refers to calculating three times the standard deviation of the data within one hydraulic residence time before and after the data removal time point, and using this as the upper and lower limits to remove extreme outlier data. Then, the removed data is supplemented using interpolation methods based on the data within this time period, as detailed below:
[0021] Step 1.1: Organize the raw data, i.e. the data obtained from real-time monitoring of the biochemical reaction tank, according to the running time;
[0022] Step 1.2: Determine the time interval for cleaning the raw data based on the hydraulic retention time of the biochemical reaction tank;
[0023] Step 1.3: Calculate the mean and standard deviation of each data point in the biochemical reaction tank within each time interval;
[0024] Step 1.4: Delete extreme outlier data exceeding 3 standard deviations in the time interval and supplement them by interpolation;
[0025] Step 1.5: Normalize the interpolated data for subsequent data analysis and modeling;
[0026] The interpolation calculation formula is as follows:
[0027]
[0028] Where i represents the time node for which interpolation is required; datain i The calculated i-th interpolated data is used to replace the deleted data. This data is calculated from the data of TN time steps before and after the i-th time node, and the time steps during this period are represented by the variable j; DATA j The j-th original data within each time interval is used for interpolation calculation; the set of all interpolated data is called Data.
[0029] The normalization formula in step 1.5 is as follows:
[0030]
[0031] Here, inorm represents the data time point that needs to be normalized, and Data inorm DataNorm represents the interpolated data at time step innorm, where max(Data) and min(Data) are the maximum and minimum values of the interpolated data. inormDataNorm is the normalized data at the inorm time step; the set of all normalized data is called DataNorm.
[0032] Preferably, in step 1, the raw data includes COD, ammonia nitrogen, total nitrogen, total phosphorus, water temperature and flow rate of the influent of the biological reactor under different quarters and rainfall load conditions of the wastewater treatment plant; the mixed suspended solids concentration (MLSS) of the activated sludge in the biological reactor; the dissolved oxygen concentration (DO), oxidation-reduction potential (ORP), and nitrate nitrogen (NO3) in the anaerobic, anoxic, and aerobic sections of the reactor. - The aeration rate and chemical dosage of the biochemical reaction tank, the internal and external reflux flow rates, the sludge discharge rate, and the COD, total nitrogen, and total phosphorus of the effluent from the biochemical reaction tank;
[0033] The raw data is obtained through real-time online data monitoring, with a frequency of one data point every 10 minutes.
[0034] Preferably, in step 2, the original data after cleaning, i.e. the monitoring data obtained from the cleaned biochemical reaction tank, is used to analyze the statistical information of the data itself and the kinetic process of the biochemical reaction, select the features that affect the biochemical reaction tank, and then use the features and corresponding data as input data for the prediction and inference model.
[0035] The statistical and dynamic characteristics analysis of the data includes linear correlation analysis, nonlinear regression analysis, estimation of data probability distribution and conditional probability distribution, and Koopman matrix analysis of the dynamic system.
[0036] More preferably, in step 2, the process of statistically analyzing and performing kinetic analysis on the kinetics of the biochemical reaction is as follows:
[0037] Step 2.1: Through linear correlation analysis, the linear correlation between each data item in the normalized data, as well as between data items with time differences, is analyzed and evaluated. The specific formula for calculating the correlation coefficient is as follows:
[0038]
[0039] Where r(DataNorm,DataNorm) z+lt ) contains two arrays, DataNorm and DataNorm z+lt The linear correlation coefficient calculated between corresponding data items; z is a natural number greater than or equal to 1, representing the data number used for the correlation test; lt is a natural number greater than or equal to 1, representing the time difference of the data used for the correlation test; Cov is the covariance of the data; Var is the variance of the data.
[0040] Step 2.2: Through nonlinear regression analysis, the prediction model uses the input and output as the input and output of the regression problem. It uses the collected data to fit the data with the help of a deep learning model. Based on different model inputs, deep learning model structures, and hyperparameter selections, the model input data items and model structures with the best fitting performance are compared and determined.
[0041] The fitting process is shown in the following formula:
[0042]
[0043] Where Reg is the deep learning model used for regression fitting;
[0044] Num represents the amount of data used for nonlinear fitting;
[0045] k is the count variable for the data in the regression calculation, ranging from 1 to Num;
[0046] DataNorm k+1 and DataNorm k These are the input and output of the fit;
[0047] θ is the parameter used in the deep learning regression model;
[0048] Step 2.3: Estimation of data probability distribution and conditional probability distribution. Analyze the data to obtain its probability distribution and the conditional probability distribution between them, thereby analyzing the historical operating characteristics of the biochemical reactor from the perspective of data.
[0049] Step 2.3.1: Determine the maximum and minimum values of each data item based on the data, and divide the interval between the minimum and maximum values;
[0050] Step 2.3.2: Count the number of data points in each partition. After counting all data, the number of data points in each partition can be obtained, thus yielding the probability distribution of the data. The probability distribution directly reveals the value range of each data item and the historical status of the biochemical reaction tank.
[0051] Step 2.3.3: Filter data that meets certain conditions from the data, and count the amount of data contained in each partition of the filtered data to obtain the number of data contained in each partition, thereby obtaining the conditional probability distribution of the data;
[0052] Step 2.4: Combining Extended Dynamic Mode Decomposition (EDMD) with the original data, an approximate Koopman matrix and its eigenvalues are obtained to acquire an approximate Koopman matrix in the sense of the observation function. Specifically, this can be obtained by solving the following optimization problem:
[0053]
[0054] Where G is the observation function;
[0055] K is the Koopman matrix that needs to be solved. The size of the Koopman matrix provides a reference for the size of the Koopman matrix in the subsequent prediction model. At the same time, the properties of K can be used to analyze and judge the dynamic properties of the wastewater treatment A2O process. For example, the stability of the system can be judged by the eigenvalues of K.
[0056] DataNorm km+1 and DataNorm km The data used to solve the Koopman matrix is obtained from the cleaned data;
[0057] Numk is the total amount of data used to solve the Koopman matrix; km is the count variable of the data used to solve the Koopman matrix, ranging from 1 to Numk.
[0058] More preferably, in step 3, a deep learning-based prediction and extrapolation model for biochemical reaction tanks is constructed. This deep learning prediction and extrapolation model includes biochemical reaction tank data feature selection, model training and testing, selection and cross-validation of the Koopman matrix and hyperparameters of the deep learning model, and model robustness analysis. Specifically:
[0059] Step 3.1: Combining the results of nonlinear regression analysis with the cleaned data, select the input information of the prediction and inference model as the input and output of the Koopman-DL prediction and inference model;
[0060] The inputs to the prediction and extrapolation model are the influent data, biochemical reactor status data, and control data from a past period at the current moment; each specific data item is consistent with the data items selected by the regression model.
[0061] The output of the predictive model is the effluent water quality and the state of the biochemical reactor over a future period. The model's hyperparameters are selected based on nonlinear regression analysis and refined through cross-validation; the specific formulas are as follows:
[0062]
[0063] Where t represents the current time; lag is the predicted time span; X t ,...,X t+lag r represents the state variable from time t to t+lag. t ,...r t+lag Let a be the water inflow variable from time t to t+lag; t,...,a t+lag PreY is the control variable from time t to t+lag. t+lag+1 To predict water discharge variables, PreX t+lay+1 To predict state variables, both sets of data are derived from normalized data; For example, w is a deep neural network used to approximate the observation function corresponding to the Koopman matrix; w is the deep neural network... The parameters are obtained through training; K is the Koopman matrix;
[0064] Step 3.2, Model Training and Testing, refers to training the constructed prediction and inference model using the cleaned data. Training is achieved by minimizing the loss function, as shown in the following formula:
[0065]
[0066] Where t is the time counter for the training data, ranging from 1 to the number of training data points NumT; X t ,...,X t+lag r represents the state variable from time t to t+lag. t ,...r t+lag Let a be the water inflow variable from time t to t+lag; t ,...,a t+lag Y is the control variable from time t to t+lag. t+lag+1 To predict the true value of the water discharge variable; X t+lag+1 To predict the true value of the state variable;
[0067] The optimization model is solved using the Adam deep learning model training algorithm, and the trained model can be used for the prediction and simulation of biochemical reaction tank dynamics.
[0068] Step 3.3: Based on the comparison results of the hyperparameters of the regression model and the Koopman matrix, design the initial values of the hyperparameters of the deep learning model and the Koopman matrix of the Koopman matrix, as well as the matrix dimension, and further adjust the hyperparameters accordingly.
[0069] The aforementioned model hyperparameter tuning refers to testing different deep learning model structures and initial values of the Koopman operator based on the training process described above. Each time the parameters are reset, the model is retrained using the same algorithm to obtain the computational performance of the trained model. By comparing the model's performance under different hyperparameters and initial Koopman matrix values, the best-performing set is selected as the final model hyperparameters and initial Koopman matrix values. This corresponding model serves as the final Koopman-DL prediction and inference model, and is used for prediction.
[0070] Step 3.4: Perform robustness analysis on the trained prediction and inference model; the robustness analysis is performed by inputting different degrees of perturbation into the model and observing the range of change in its output;
[0071] If the output of the prediction and inference model can remain within a certain range under different random perturbation inputs, then the trained prediction and inference model can be considered to have good robustness.
[0072] The specific calculation formulas for the different degrees of disturbance are as follows:
[0073]
[0074]
[0075]
[0076] Where tc is a time counter for adding perturbation data. For the state data after adding perturbations, X tc For state data, For the control data after adding disturbance, a tc To control the data, To incorporate the perturbation into the influent data, r tc For influent data, δ~N(μ,σ) represents random disturbances that follow a normal distribution with mean μ and standard deviation σ.
[0077] More preferably, in step 4, based on the prediction and deduction model, and combined with the model predictive control method, i.e., MPC, the model predictive control method Koopman-DL-MPC for the biochemical reaction tank is constructed.
[0078] The predictive control method for biochemical reaction tank models based on deep learning predictive inference models is as follows:
[0079] Step 4.1: Construct a standard model predictive control framework (MPC); the model predictive control framework (MPC) is a biochemical reactor state and effluent prediction model based on the Koopman matrix and deep learning, namely Koopman-DL.
[0080] Step 4.2: Input the monitoring data of the biochemical reaction tank into the prediction model to predict the state of the biochemical reaction tank and the effluent quality;
[0081] Step 4.3: Based on the prediction results and control objectives, a score is assigned, and the score is used as the objective function for optimization. The optimization objectives include three aspects: the indicators of the biochemical reactor should be as stable as possible near the design operating conditions; the effluent quality should meet the specified effluent indicators; and the aeration volume should be as small as possible.
[0082] Step 4.4: Based on the optimization objective, optimize and adjust the control measures for the next time step, including aeration volume, drug dosage, and internal and external return flow, using the optimization algorithm to maximize the objective function value.
[0083] Step 4.5: Through repeated prediction and optimization, the optimal control strategy for the next time step can be obtained and used for control.
[0084] Step 4.6: Proceed to the next time step and repeat steps 4.1 to 4.5 above, thereby achieving real-time optimization control of the system;
[0085] The above process is described by the following time-step optimization model:
[0086] minJ+U+P
[0087]
[0088]
[0089]
[0090]
[0091] t∈{t0,t1,...,t M}
[0092] Where t represents time, lag represents the time span of the predicted output variable; J, U, and P represent the objective functions corresponding to the above three objectives; Xlow_bound, Xup_bound, Ylow_bound, and Yup_bound are the upper and lower limits of the biochemical reactor state variables and effluent indicators; abound is the target line of the control variable; X t Y t a t For input state variables, effluent indicators, and optimization control variables; PreX t+lay+1 PreY t+lay+1 All are state variables and effluent indicators for predicted output; Lagk is a counter for the optimized control variable;
[0093] In the model predictive control method, under the premise of ensuring that the effluent water quality meets the standards and the state of the biochemical reactor is stable, the total amount of aeration and the amount of chemicals added in the system should be reduced as much as possible to achieve optimized control and energy-saving operation of the biochemical reactor.
[0094] In the above process, any optimization algorithm can be used to solve the above optimization model, including but not limited to genetic algorithms, particle swarm optimization, etc.; the number of iteration steps of the optimization algorithm is calculated by the control time interval and the single optimization time, as shown in the following formula:
[0095]
[0096] Where STEP_OPT is the number of iterations calculated by the optimization algorithm, Δt is the control time interval, and TIME_OPT is the time required for a single iteration of the optimization algorithm;
[0097] The effectiveness of the above process control system is evaluated by calculating J+U+P. The lower the J+U+P obtained from the control process, the better the control effect.
[0098] More preferably, in step 5, based on the virtual real-time optimization control system of the biochemical reaction tank, the rationality and safety verification of the output control variables of the above-mentioned Koopman-DL-MPC are added.
[0099] The rationality and safety verification includes determining whether the current optimized control variable is within the artificially defined range, whether the current optimized control variable is consistent with similar historical cases, and whether the control effect of the current optimized control variable is feasible. The specific steps are as follows:
[0100] Step 5.1: Determine whether the current optimized control variables are within the artificially defined range; the optimized control strategy obtained through the model prediction control Koopman-DL-MPC needs to be compared with the relevant indicators in the artificially defined operating standards of the A2O process in wastewater treatment plants, and the optimized control strategy is determined to be within the range specified by the standards based on the comparison results; the specific steps are as follows:
[0101] Step 5.1.1: Directly collect historical data on control variables and calculate their mean and standard deviation;
[0102] Step 5.1.2: Based on the statistical principle of three standard deviations, the mean plus or minus three standard deviations is taken as the reasonable range. The optimized control variable is then directly tested to see if it remains within this range. The upper and lower limits can be calculated using the following formula:
[0103]
[0104]
[0105] Where upper and down are the upper and lower limits calculated from the data; a h This represents the historical data of the control variable, with a total of NumA data points; h is the count variable used when calculating the upper and lower limits of the control variable data; a represents the average value of the control variable data;
[0106] Step 5.1.3: Based on the recommended process parameters, further calibrate the above upper and lower limits; finally, take the intersection of the recommended process parameter range and the down and upper intervals as the final judgment range, that is, when the optimized control variable satisfies the following inequality condition, the current optimized control variable is considered to be within the artificially defined range:
[0107] aOPT∈[down,upper]∩[s down ,s upper ]
[0108] Where aOPT represents the optimized control variable; [down,upper] represents the numerical range determined by down and upper; s down and s upper These are the recommended upper and lower limits of process parameters; [s down ,s upper ] indicates that s down and s upper A defined range of values; ∩ represents the intersection of two range sets; aOPT∈ indicates that the control variable being optimized belongs to that set.
[0109] Step 5.2: Determine whether the current optimized control variable is consistent with similar historical cases; through normalized historical data, statistically analyze the conditional probability distribution of the control variable under similar conditions, and determine the reasonable upper and lower limits of the control variable based on the statistical principle of three standard deviations.
[0110] The conditional probability distribution under similar conditions refers to the process of calculating the optimized control variables at a certain moment, using the inflow and state variables at that moment, filtering control data from historical data that are close to the inflow and state variables, and statistically analyzing the probability distribution of these control data. The judgment of data similarity is made using vector distance, as shown in the following formula:
[0111]
[0112] Where, X s1 With X s2 This represents two sets of state data that need to be compared; r s1 With r s2This represents two sets of influent data to be compared; s1 and s2 are the indices of the two sets of data to be compared; when the distance is small enough, the two sets of data are considered to be close.
[0113] The calculation process for the reasonable upper and lower limits of the control variables is similar to that in step 5.1, the only difference being that the data for the control variables is filtered data.
[0114] The specific steps are as follows:
[0115] Step 5.2.1: Compare the current status data and water inflow data with the status data and historical data of all times in history, and calculate the distance between each set of data using the distance formula mentioned above;
[0116] Step 5.2.2: Set the distance threshold to 0.2, record the control variables corresponding to historical data with similarity less than the threshold, and obtain "control variable data in historical situations similar to the current state";
[0117] Step 5.2.3: Calculate the filtered data according to Step 5.1 to obtain the control variable judgment range of the conditional probability distribution under similar conditions; if the optimized control variable is within this range, it is considered that the current optimized control variable is consistent with the historical similar cases, and passes the "consistent with historical similar cases" test.
[0118] Step 5.3: Determine whether the control effect of the current optimized control variables is feasible; input the optimized control variables, the influent variables and the state variables at the current moment into the Koopman-DL prediction model to directly predict the state variables and effluent variables at future moments, thereby determining whether the control effect is feasible.
[0119] The specific steps are as follows:
[0120] Step 5.3.1: Use the optimized control variables and the current state as inputs to the inference and prediction model to perform a one-step prediction;
[0121] Step 5.3.2: Compare the prediction results with the operating standards of the biological reactor. If the state variables, including dissolved oxygen and MLSS, remain within the specified range of the biological reactor and the effluent quality meets the standards, then the optimized control variables given at the current moment are considered reasonable and feasible and can be used as the control output of the system. Otherwise, it is considered that the optimized effect of the currently given control variables can be achieved by saving control factors such as aeration.
[0122] Step 5.4: Determine the final safety and reasonableness of the optimized control variables; if the optimized control variables pass the tests in steps 5.1-5.3 above, then the control variables are considered safe and reasonable and can be used for actual control; otherwise, the optimized control variables are considered to be risky, and the process returns to step 4 to recalculate.
[0123] The beneficial effects of this invention are:
[0124] (1) The analysis method of the present invention has a wide range of applications and can be used to build a model prediction real-time control system based on a deep learning model for wastewater treatment plants with different AAO processes.
[0125] (2) This invention is the first to incorporate the stable operation of the biochemical reaction tank into the goal of optimization control. Under the premise of taking into account the quality of the effluent and the stability of the biochemical reaction tank, it further controls energy saving and optimizes the system operation.
[0126] (3) This invention is the first to combine the Koopman matrix with deep learning for the prediction and deduction of the dynamic process of the biochemical reaction tank in the sewage treatment plant. While taking into account its nonlinear simulation capabilities, the Koopman matrix is used to find the underlying linear structure and improve its interpretability.
[0127] (4) This invention is the first to propose a data-driven verification method for the control safety and rationality of the real-time control model of the black box model of the AAO process in sewage treatment plants, thereby improving its reliability and practicality.
[0128] The following will further explain the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Attached Figure Description
[0129] Figure 1 This is a schematic diagram of a method according to an embodiment of the present invention.
[0130] Figure 2 This is a schematic diagram of the Koopman-DL prediction and extrapolation model in one embodiment of the present invention.
[0131] Figure 3 This is a flowchart of a deep learning-based model prediction control system in one embodiment of the present invention.
[0132] Figure 4 This is a flowchart of a rationality and safety verification method in one embodiment of the present invention.
[0133] Figure 5 This is a graph showing the results of data correlation analysis in one embodiment of the present invention.
[0134] Figure 6 Comparison of control variables in an optimized control process according to one embodiment of the present invention
[0135] Figure 7 Comparison of state variables in the optimized control process in one embodiment of the present invention
[0136] Figure 8 This invention provides a comparison of control variables in an optimized control process incorporating rationality checks, as described in one embodiment.
[0137] Figure 9 This invention provides a comparison of state variables in an optimized control process incorporating rationality checks, as described in one embodiment. Detailed Implementation
[0138] Example 1
[0139] like Figures 1 to 4 As shown, the predictive simulation and real-time safety control method for biochemical reaction tanks in wastewater treatment plants, based on the Koopman matrix and deep learning, includes the following steps:
[0140] Step 1: Preprocess the raw data from the biochemical reaction tank;
[0141] Step 2: Statistical and kinetic characteristic analysis of the biochemical reaction tank is performed using a data-driven approach;
[0142] Step 3: Construct a prediction and extrapolation model for biochemical reaction tanks based on the Koopman matrix and deep learning methods, namely Koopman Deep Learning (Koopman-DL);
[0143] Step 4: Establishing a biochemical reaction tank model predictive control method based on the Koopman-DL predictive model (Koopman-DL-MPC);
[0144] Step 5: Construct a data-driven method for verifying the rationality and safety of the biochemical reaction pool using Koopman-DL-MPC.
[0145] This invention combines deep learning, Koopman matrices from dynamic systems research, mathematical statistics, and model predictive control technology to construct a method for predicting and optimizing the state and effluent of a biochemical reactor in a wastewater treatment plant in real time. First, by integrating Koopman matrices and deep learning, leveraging the linear structure built by Koopman matrices and the powerful learning and fitting capabilities of deep learning, the underlying linear structure of the black-box model is identified. This compensates for the shortcomings of black-box models in analyzing dynamic system characteristics while ensuring prediction accuracy, thus improving the interpretability of the data-driven model. Second, the state variables of the biochemical reactor are used as one of the objectives of optimization control, achieving energy-saving optimization control while considering the stable operation of the biochemical reactor. Next, mathematical statistics are used to analyze and test the dynamic laws of the biochemical reactor, providing a reference for selecting the input, output, and structural parameters of the deep learning model. Finally, three rationality checks are proposed for the output control strategy to constrain the control commands, ensuring that the output of the optimized model conforms to the actual situation and guaranteeing the safety of the model control output in practical applications in wastewater treatment plants.
[0146] In some embodiments, in step 1, the raw data for the biochemical reaction tank refers to the status data obtained by real-time monitoring of the biochemical reaction tank;
[0147] Analysis and preprocessing include cleaning the raw data;
[0148] Cleaning refers to removing abnormal data from the original data caused by equipment maintenance events, and removing noise and abnormal fluctuations from the original data through time averaging methods.
[0149] In practical applications, cleaning the raw data can make the processed data more stable and better reflect the kinetic characteristics of the biochemical reaction tank.
[0150] In some embodiments, in step 1, extreme outliers are removed based on the principle of three standard deviations in the original data, combined with the time interval characteristics of the biochemical reaction tank, and data is supplemented by interpolation methods. The specific process is as follows:
[0151] Step 1.1: Organize the raw data, i.e. the data obtained from real-time monitoring of the biochemical reaction tank, according to the running time;
[0152] Step 1.2: Determine the time interval for cleaning the raw data based on the hydraulic retention time of the biochemical reaction tank;
[0153] Step 1.3: Calculate the mean and standard deviation of each data point in the biochemical reactor within each time interval;
[0154] Step 1.4: Delete extreme outlier data exceeding 3 standard deviations in the time interval and supplement them by interpolation;
[0155] Step 1.5: Normalize the interpolated data for subsequent data analysis and modeling;
[0156] The interpolation calculation formula is as follows:
[0157]
[0158] Where i represents the time node for which interpolation is required; datain i The calculated i-th interpolated data is used to replace the deleted data. This data is calculated from the data of TN time steps before and after the i-th time node, and the time steps during this period are represented by the variable j; DATA j The j-th original data in each time interval is used for interpolation calculation; the set of all interpolated data is called Data.
[0159] The normalization formula in step 1.5 is as follows:
[0160]
[0161] Here, inorm represents the data time point that needs to be normalized, and Data inorm DataNorm represents the interpolated data at time step innorm, where max(Data) and min(Data) are the maximum and minimum values of the interpolated data. inorm DataNorm is the normalized data at the inorm time step; the set of all normalized data is called DataNorm.
[0162] In practical applications, the raw data processed by the above steps eliminates the influence of outliers and disturbances to a certain extent, and is adjusted by normalization to facilitate subsequent modeling, providing a data foundation for subsequent analysis and modeling.
[0163] In some embodiments, in step 1, the raw data includes COD, ammonia nitrogen, total nitrogen, total phosphorus, water temperature and flow rate of the influent portion of the biological reactor under different quarters and rainfall load conditions of the wastewater treatment plant; MLSS concentration of activated sludge in the biological reactor; dissolved oxygen concentration (DO) in the anaerobic, anoxic, and aerobic zones of the reactor; oxidation-reduction potential (ORP); and nitrate nitrogen (NO3) in the aerobic zone. - The aeration rate and chemical dosage of the biochemical reactor, the internal and external reflux flow rates, the sludge discharge rate, and the COD, total nitrogen, and total phosphorus of the effluent from the biochemical reactor.
[0164] The raw data is obtained through real-time online data monitoring, with a frequency of one data point every 10 minutes.
[0165] In practical applications, since the data needs to support the construction of dynamic characteristic analysis and predictive models, the amount of data needs to be as comprehensive as possible, at least including the operation of the wastewater treatment plant under different quarters and rainfall load conditions, in order to ensure the reliability of subsequent analysis results.
[0166] In some embodiments, in step 2, the kinetic process of the biochemical reaction is analyzed using cleaned and normalized data, the characteristics of the biochemical reaction affecting the biochemical reaction tank are selected, and then the influence of each characteristic on the kinetics of the biochemical reaction tank is analyzed. The characteristics and corresponding data are used as input data for the prediction and inference model.
[0167] The input data can take the form of linear correlation analysis, nonlinear regression analysis, estimation of data probability distribution and conditional probability distribution, and Koopman matrix analysis of dynamical systems.
[0168] In some embodiments, the process of analyzing the kinetics of the biochemical reaction in step 2 is as follows:
[0169] Step 2.1: Through linear correlation analysis, the linear correlation between each data item in the normalized data, as well as between data items with time differences, is analyzed and evaluated. The specific formula for calculating the correlation coefficient is as follows:
[0170]
[0171] Where r(DataNorm,DataNorm) z+lt ) contains two arrays, DataNorm and DataNorm z+lt The linear correlation coefficient calculated between corresponding data items; z is a natural number greater than or equal to 1, representing the data number used for the correlation test; lt is a natural number greater than or equal to 1, representing the time difference of the data used for the correlation test; Cov is the covariance of the data; Var is the variance of the data.
[0172] Step 2.2: Through nonlinear regression analysis, the prediction model uses the input and output as the input and output of the regression problem. It uses the collected data to fit the data with the help of a deep learning model. Based on different model inputs, deep learning model structures, and hyperparameter selections, the model input data items and model structures with the best fitting performance are compared and determined.
[0173] The fitting process is shown in the following formula:
[0174]
[0175] Where Reg is the deep learning model used for regression fitting;
[0176] Num represents the amount of data used for nonlinear fitting;
[0177] k is the count variable for the data in the regression calculation, ranging from 1 to Num;
[0178] DataNorm k+1 and DataNorm k These are the input and output of the fit;
[0179] θ is the parameter used in the deep learning regression model;
[0180] Step 2.3: Estimation of data probability distribution and conditional probability distribution. Analyze the data to obtain its probability distribution and the conditional probability distributions between them. This allows for analysis of the historical operational characteristics of the biochemical reactor from a data perspective. The specific steps are as follows:
[0181] Step 2.3.1: Determine the maximum and minimum values of each data item based on the data, and divide the interval between the minimum and maximum values;
[0182] Step 2.3.2: Count the number of data points in each partition. After counting all data, the number of data points in each partition can be obtained, thus yielding the probability distribution of the data. The probability distribution directly reveals the value range of each data item and the historical status of the biochemical reaction tank.
[0183] Step 2.3.3: Filter data that meets certain conditions from the data, and count the number of data contained in each partition of the filtered data to obtain the number of data contained in each partition, thereby obtaining the conditional probability distribution of the data;
[0184] Step 2.4: Combining Extended Dynamic Mode Decomposition (EDMD) with the original data, an approximate Koopman matrix and its eigenvalues are obtained to acquire an approximate Koopman matrix in the sense of the observation function. Specifically, this can be obtained by solving the following optimization problem:
[0185]
[0186] Where G is the observation function;
[0187] K is the Koopman matrix that needs to be solved. The size of the Koopman matrix provides a reference for the size of the Koopman matrix in the subsequent prediction model. At the same time, the properties of K can be used to analyze and judge the dynamic properties of the wastewater treatment A2O process. For example, the stability of the system can be judged by the eigenvalues of K.
[0188] DataNorm km+1 and DataNorm kmThe data used to solve the Koopman matrix is obtained from the cleaned data.
[0189] Numk is the total amount of data used to solve the Koopman matrix; km is the count variable of the data used to solve the Koopman matrix, ranging from 1 to Numk.
[0190] In practical applications, data correlation analysis is used to determine the mutual influence between various data points under different time-varying conditions. For example, calculating the correlation coefficient between influent COD data and MLSS data half an hour later (lt equals half an hour) analyzes the impact of changes in influent COD on the MLSS of the bioreactor half an hour later. This allows analysis of the main data factors affecting the kinetic processes of the bioreactor and their corresponding time spans, providing input features for subsequent modeling.
[0191] In practical applications, nonlinear regression analysis uses the input and output as the input and output of the regression problem. It uses the collected data to fit the data with the help of a deep learning model. By comparing different deep learning model structures and hyperparameter selections, the model with the best fitting performance can be obtained. This can help to preliminarily determine how to select the parameters that the prediction model should use, and provide a reference for subsequent modeling.
[0192] In practical applications, conditional probability requires conditional filtering when calculating the data volume in each segment. For example, when selecting "MLSS of the bioreactor when influent COD is greater than 600 mg / L," it is necessary to perform conditional judgment on the data at the same time to determine whether the selected data item meets the condition of "influent COD greater than 600 mg / L." Only data that meet the condition will be included in the statistics for each segment. After statistically analyzing all the data, the probability distribution of data meeting certain conditions can be obtained, i.e., the conditional probability distribution. Through the above data distribution, the historical operation and control characteristics of the bioreactor can be intuitively displayed, providing a reference for subsequent rationality verification.
[0193] In practical applications, the Extended Dynamic Mode Decomposition method is used to obtain an approximate Koopman matrix from the normalized data. The size of the Koopman matrix provides a reference for the size of the Koopman matrix in the subsequent prediction model. At the same time, its properties can be used to analyze and judge the kinetic properties of the wastewater treatment A2O process, such as judging the stability of the system through eigenvalues.
[0194] In some embodiments, in step 3, the normalized data is used to design and select features as input data for the prediction and inference model, with the help of nonlinear fitting results and the results of Koopman dynamics feature analysis, to construct and train a deep learning model and obtain the prediction and inference model.
[0195] The construction of the predictive model includes the selection of features from biochemical reaction tank data, model training and testing, selection and cross-validation of hyperparameters for the Koopman matrix and deep learning model, and model robustness analysis.
[0196] Specifically as follows:
[0197] Step 3.1: Combining the results of nonlinear regression analysis with the cleaned data, select the input information of the prediction and inference model as the input and output of the Koopman-DL prediction and inference model;
[0198] The inputs to the predictive model are the influent data, biochemical reactor status data, and control data from a past period at the current moment; the specific data items are consistent with the data items selected by the regression model.
[0199] The predictive model outputs the effluent water quality and the state of the biochemical reactor over a future period. The model's hyperparameters were selected based on nonlinear regression analysis and refined through cross-validation; the specific formulas are as follows:
[0200]
[0201] Where t represents the current time; lag is the predicted time span; X t ,...,X t+lag r represents the state variable from time t to t+lag. t ,...r t+lag Let a be the water inflow variable from time t to t+lag; t ,...,a t+lag PreY is the control variable from time t to t+lag. t+lag+1 To predict water discharge variables, PreX t+lay+1 To predict state variables, both sets of data are derived from normalized data; For example, w is a deep neural network used to approximate the observation function corresponding to the Koopman matrix; w is the deep neural network... The parameters are obtained through training; K is the Koopman matrix;
[0202] Step 3.2, Model Training and Testing, refers to training the constructed prediction and inference model using cleaned data. Training is achieved by minimizing the loss function, as shown in the following formula:
[0203]
[0204] Where t is the time counter for the training data, ranging from 1 to the number of training data points NumT; X t ,...,X t+lag r represents the state variable from time t to t+lag. t ,...r t+lag Let a be the water inflow variable from time t to t+lag; t ,...,a t+lag Y is the control variable from time t to t+lag. t+lag+1 To predict the true value of the water discharge variable; X t+lag+1 To predict the true value of the state variable;
[0205] The optimization model is solved using the Adam deep learning model training algorithm. Once trained, the model can be used for the prediction and simulation of biochemical reaction tank dynamics.
[0206] Step 3.3: Based on the comparison results of the hyperparameters of the regression model and the Koopman matrix, design the initial values of the hyperparameters of the deep learning model and the Koopman matrix of the Koopman matrix, as well as the matrix dimension, and further adjust the hyperparameters accordingly.
[0207] Model hyperparameter tuning refers to testing different deep learning model structures and initial values of the Koopman operator based on the training process described above. Each time the parameters are reset, the model is retrained using the same algorithm to obtain the computational performance of the trained model. By comparing the model's performance under different hyperparameters and initial Koopman matrix values, the best-performing set is selected as the final model hyperparameters and initial Koopman matrix values. This corresponding model becomes the final Koopman-DL prediction and inference model, and is used for prediction.
[0208] Step 3.4: Perform robustness analysis on the trained prediction and inference model; robustness analysis involves inputting different levels of perturbation into the model and observing the range of changes in its output.
[0209] If the output of the prediction and inference model can remain within a certain range under different random perturbation inputs, then the trained prediction and inference model can be considered to have good robustness.
[0210] The specific calculation formulas for different levels of disturbance are as follows:
[0211]
[0212]
[0213]
[0214] Where tc is a time counter for adding perturbation data. For the state data after adding perturbations, X tc For state data, For the control data after adding disturbance, a tc To control the data, To incorporate the perturbation into the influent data, r tc For influent data, δ~N(μ,σ) represents random disturbances that follow a normal distribution with mean μ and standard deviation σ.
[0215] In practical applications, the time length must be at least one hydraulic residence time, and its upper limit is obtained through the linear correlation analysis of the time lag mentioned above. When the data corresponding to a certain time lag has extremely low correlation with the data at the current time, the data within the lag time period is used as the input feature of the prediction model.
[0216] In some embodiments, in step 4, a virtual real-time optimization control system for the biochemical reaction tank is constructed based on the predictive model combined with the model predictive control method (MPC).
[0217] The predictive control of a biochemical reaction tank model based on a deep learning predictive inference model is as follows:
[0218] Step 4.1: Construct the standard Model Predictive Control Framework (MPC); The Model Predictive Control Framework (MPC) is the Koopman-DL model for predicting the state and effluent of a biochemical reactor based on the Koopman matrix and deep learning.
[0219] Step 4.2: Input the monitoring data of the biochemical reactor into the prediction model to predict the status of the biochemical reactor and the effluent quality;
[0220] Step 4.3: Based on the prediction results and control objectives, a score is assigned, and the score is used as the objective function for optimization. The optimization objectives include three aspects: the indicators of the biochemical reactor should be as stable as possible near the design operating conditions; the effluent quality should meet the specified effluent indicators; and the aeration volume should be as small as possible.
[0221] Step 4.4: Based on the optimization objective, optimize and adjust the control measures for the next time step, including aeration volume, drug dosage, and internal and external return flow, using the optimization algorithm to maximize the objective function value.
[0222] Step 4.5: Through repeated prediction and optimization, the optimal control strategy for the next time step can be obtained and used for control.
[0223] Step 4.6: Proceed to the next time step and repeat steps 4.1 to 4.5 above, thereby achieving real-time optimization control of the system;
[0224] The above process is described by the following time-step optimization model:
[0225] min J+U+P
[0226]
[0227]
[0228]
[0229]
[0230] t∈{t0,t1,...,t M}
[0231] Where t represents time, lag represents the time span of the predicted output variable; J, U, and P represent the objective functions corresponding to the above three objectives; Xlow_bound, Xup_bound, Ylow_bound, and Yup_bound are the upper and lower limits of the biochemical reactor state variables and effluent indicators; abound is the target line of the control variable; X t Y t a t For input state variables, effluent indicators, and optimization control variables; PreX t+lay+1 PreY t+lay+1 All are state variables and effluent indicators for predicted output; Lagk is a counter for the optimized control variable;
[0232] In the model predictive control method, under the premise of ensuring that the effluent water quality meets the standards and the state of the biochemical reactor is stable, the total amount of aeration and the amount of chemicals added in the system should be reduced as much as possible to achieve optimized control and energy-saving operation of the biochemical reactor.
[0233] The effectiveness of the above process control system is evaluated by calculating J+U+P. The lower the J+U+P obtained from the control process, the better the control effect.
[0234] In practical applications, maximizing this objective function means optimizing the control variable a in the control process at a future time step. t+lag This aims to ensure the biological reaction tank remains as stable as possible, that the effluent quality meets standards, and that control indicators conform to the designed requirements as much as possible, and to monitor all time intervals t0, t1, ..., t M All of these are optimized to achieve the goal of optimized control.
[0235] Any optimization algorithm can be used to solve the above optimization model, including but not limited to genetic algorithms and particle swarm optimization. However, considering the characteristics of real-time control of biochemical reactors, the optimization algorithm needs to impose a computation time limit when solving the above optimization problem in each time step. The optimization solution time should not exceed the control time interval. That is, the number of iteration steps of the optimization algorithm is calculated from the control time interval and the single optimization time, as shown in the following formula:
[0236]
[0237] Where STEP_OPT is the number of iterations calculated by the optimization algorithm, Δt is the control time interval, and TIME_OPT is the time required for a single iteration of the optimization algorithm;
[0238] During runtime, if the optimization algorithm fails to converge within a certain time, the algorithm is terminated, and the existing optimization results are output as a reference for subsequent control.
[0239] In some embodiments, in step 5, the rationality and safety of the control commands are verified based on the Koopman-DL-MPC real-time optimization control system of the biochemical reaction tank.
[0240] The rationality and safety verification includes determining whether the current optimized control variables are within the artificially defined range, whether the current optimized control variables are consistent with similar historical cases, and whether the control effect of the current optimized control variables is feasible. The specific steps are as follows:
[0241] Step 5.1: Determine whether the current optimized control variables are within the artificially defined range; the optimized control strategy obtained through model predictive control using Koopman-DL-MPC needs to be compared with relevant indicators in the artificially defined operating standards for the A2O process in wastewater treatment plants, and the optimized control strategy should be determined based on the comparison results to determine whether it is within the range specified in the standards; the specific steps are as follows:
[0242] Step 5.1.1: Directly collect historical data on control variables and calculate their mean and standard deviation;
[0243] Step 5.1.2: According to the statistical principle of three standard deviations, the mean plus or minus three standard deviations is taken as the reasonable range, and the optimized control variables are directly tested to see if they remain within this range. The upper and lower limits can be calculated using the following formula:
[0244]
[0245]
[0246] Where upper and down are the upper and lower limits calculated from the data; a h This represents the historical data of the control variable, with a total of NumA data points; h is the count variable used when calculating the upper and lower limits of the control variable data; Express the average value of the control variable data;
[0247] Step 5.1.3: Based on the recommended process parameters, further calibrate the above upper and lower limits; finally, take the intersection of the recommended process parameter range and the down and upper intervals as the final judgment range, that is, when the optimized control variable satisfies the following inequality condition, the current optimized control variable is considered to be within the artificially defined range:
[0248] aOPT∈[down,upper]∩[s down ,s upper ]
[0249] Where aOPT represents the optimized control variable; [down,upper] represents the numerical range determined by down and upper; s down and s upper These are the recommended upper and lower limits of process parameters; [s down ,s upper ] indicates that s down and s upper A defined range of values; ∩ represents the intersection of two range sets; aOPT∈ indicates that the control variable being optimized belongs to that set.
[0250] Step 5.2: Determine whether the current optimized control variable is consistent with similar historical cases; through normalized historical data, statistically analyze the conditional probability distribution of the control variable under similar conditions, and determine the reasonable upper and lower limits of the control variable based on the statistical principle of three standard deviations.
[0251] The conditional probability distribution under similar conditions refers to the process of calculating optimized control variables at a certain moment, using the inflow and state variables at that moment, selecting control data from historical data that are close to the inflow and state variables, and statistically analyzing the probability distribution of these control data. The similarity of the data is determined by vector distance, as shown in the following formula:
[0252]
[0253] Where, X s1 With X s2 This represents two sets of state data that need to be compared; r s1 With r s2This represents two sets of influent data to be compared; s1 and s2 are the indices of the two sets of data to be compared; when the distance is small enough, the two sets of data are considered to be close.
[0254] The calculation process for determining the reasonable upper and lower limits of control variables is similar to that in step 5.1, with the only difference being that the data for the control variables is filtered data.
[0255] The specific steps are as follows:
[0256] Step 5.2.1: Compare the current status data and water inflow data with the status data and historical data of all times in history, and calculate the distance between each set of data using the distance formula mentioned above;
[0257] Step 5.2.2: Set the distance threshold to 0.2, record the control variables corresponding to historical data with similarity less than the threshold, and obtain "control variable data in historical situations similar to the current state";
[0258] Step 5.2.3: Calculate the filtered data according to Step 5.1 to obtain the control variable judgment range of the conditional probability distribution under similar conditions; if the optimized control variable is within this range, it is considered that the current optimized control variable is consistent with the historical similar cases, and passes the "consistent with historical similar cases" test.
[0259] Step 5.3: Determine whether the control effect of the current optimized control variables is feasible; input the optimized control variables, the influent variables and the state variables at the current moment into the Koopman-DL prediction model to directly predict the state variables and effluent variables at future moments, thereby determining whether the control effect is feasible.
[0260] The specific steps are as follows:
[0261] Step 5.3.1: Use the optimized control variables and the current state as inputs to the inference and prediction model to perform a one-step prediction;
[0262] Step 5.3.2: Compare the prediction results with the operating standards of the biological reactor. If the state variables, including dissolved oxygen and MLSS, remain within the specified range of the biological reactor and the effluent quality meets the standards, then the optimized control variables given at the current moment are considered reasonable and feasible and can be used as the control output of the system. Otherwise, it is considered that the optimized effect of the currently given control variables can be achieved by saving control factors such as aeration.
[0263] Step 5.4: Determine the final safety and reasonableness of the optimized control variables; if the optimized control variables pass the tests in steps 5.1-5.3 above, then the control variables are considered safe and reasonable and can be used for actual control; otherwise, the optimized control variables are considered to be risky, and the process returns to step 4 to recalculate.
[0264] In practical applications, based on the virtual real-time optimization control system of the biochemical reaction tank, the rationality and safety verification capability of the control commands is added to ensure the reliability and safety of the system in actual operation, avoid fluctuations in control effect caused by output disturbances of the deep learning model or disturbances of the optimization results of the control system, and ensure the stable operation of the biochemical reaction tank.
[0265] By summarizing the above steps, the rationality and safety of the optimized control variables can be assessed, further improving the reliability and practicality of the optimization method.
[0266] Example 2
[0267] This case study uses the optimization of aeration rate and internal / external return flow control in a biological reactor as an example. The wastewater treatment plant in this case employs the AAO process, with a design flow rate of 800,000 m³ / h. 3 / d, which includes 8 parallel and independently operating biochemical reactors, each with a capacity of 100,000 m³. 3 / d. This case study selects one of the biochemical reaction tanks for analysis.
[0268] Step 1: Collect historical data of the biochemical reaction tank and preprocess the raw data.
[0269] Data is acquired directly from the real-time monitoring equipment of the biochemical reaction tank. Based on the raw data, its standard deviation and mean are calculated. Data exceeding three standard deviations are removed to eliminate outliers. Interpolation is then used to replace the deleted data, removing anomalies caused by equipment maintenance or other events. The data is then normalized to facilitate subsequent analysis and modeling.
[0270] Step 2: Perform statistical analysis and dynamic system characteristic analysis on the processed data.
[0271] Based on the above data, we directly perform the above-mentioned mathematical statistics and dynamic system characteristic analysis, including: linear correlation analysis of the data, nonlinear regression analysis, estimation of data probability distribution and conditional probability distribution, and Koopman matrix analysis of the dynamic system.
[0272] The linear correlation coefficient results are shown in Table 1. It can be seen that there is a significant positive correlation between aeration volume data and dissolved oxygen (DO) data after a period of time, which needs to be considered in subsequent modeling. Meanwhile, the influence of aeration volume on dissolved oxygen data varies at different monitoring sites; monitoring sites closer to the aeration location have higher correlation coefficients, while those further away have lower correlation coefficients. Therefore, selecting more relevant dissolved oxygen data as input can improve the model training effect.
[0273] Table 1. Correlation coefficients between aeration volume data and dissolved oxygen data at various monitoring points over different time spans (lt).
[0274]
[0275] Nonlinear regression uses a Long Short-Term Memory (LSTM) neural network as the regression model, and its performance is analyzed by testing different model hyperparameters. Different hyperparameter combinations are named Structure1-4, and the parameters are set in Table 2 below, using the number of LSTM layers as an example. The fitting results of the models constructed with each structure are shown below. Figure 6 As shown in the figure, a more complex model structure is better suited to the real-time monitoring data of this biochemical reaction tank. This provides a reference for subsequent modeling.
[0276] Table 2. Hyperparameter selection combinations for the four tests.
[0277]
[0278] The probability distribution and conditional probability distribution of the data can be directly obtained statistically using the methods described above. The conditional probability "MLSS of the biological reactor under different influent carbon-nitrogen ratios (C / N)" is shown in Table 3. The results in the table directly indicate that the internal operation of the biological reactor exhibits a certain fixed pattern under specific influent conditions. For example, when the influent carbon-nitrogen ratio is low, the MLSS value of the biological reactor remains between 3600 and 3300 mg / L. However, as the C / N ratio increases, although the MLSS concentration remains between 3600 and 3300 mg / L in most cases, higher values gradually appear, reaching a maximum of 3800 to 4100 mg / L. This allows us to determine the reasonable operating range of the biological reactor, providing a basis for subsequent optimization control and rationality verification.
[0279] Table 3. Distribution of MLSS data in the biological reactor under different influent carbon-to-nitrogen ratios (C / N).
[0280]
[0281]
[0282] By directly solving for the Koopman matrix of a dynamical system from the data, its corresponding Koopman matrix and eigenvalues can be obtained, thus reflecting the dynamic characteristics of the system. The eigenvalues are as follows: Figure 5 As shown in the figure, the eigenvalues of the Koopman matrix of the dynamic system corresponding to the biochemical reaction tank are all within the unit circle and are concentrated near the position where the real part is 1. Therefore, it can be concluded that the dynamic system corresponding to the biochemical reaction tank is stable, and under the premise of no external disturbance over a long period of time, the various state indicators will gradually tend to stabilize.
[0283] Step 3: Construct a predictive model for the Koopman-DL biochemical reaction chamber.
[0284] Based on the information analyzed above and the modeling methods described, a predictive model for the state and effluent of a biochemical reactor, combining the Koopman matrix and deep learning, is directly constructed. This model takes into account the influent data, reactor state data, and control data (aeration and return flow) from the past hydraulic retention time (HRT) of the biochemical reactor, and outputs the reactor state data and effluent quality data for the next half hour. The model structure is as follows: Figure 2 As shown in the figure, the model was trained using the Adam algorithm, a commonly used deep learning algorithm. The model validation data consisted of a certain period (May 1, 2020 to October 21, 2020, totaling 50,000 data points). The training data consisted of 1,000 randomly selected data points, while the test data comprised all 50,000 data points. The mean square error (MSE) and Nash-Sutcliffe efficiency coefficient (NSE) of the predicted effluent water quality data are shown in Table 4. The results show that the Koopman-DL model, through learning, can achieve relatively accurate predictions, with MSE and NSE reaching 2.6358 and 0.995 respectively, demonstrating the effectiveness of the method. Subsequently, random perturbations were added to the input during the testing process to test the model's prediction performance under perturbation conditions, thereby verifying its reliability.
[0285] Table 4. Mean Squared Error (MSE) and Nash Equilibrium Coefficient (NSE) of Prediction Results for Each Model
[0286]
[0287]
[0288] Step 4: Build model predictive control based on Koopman-DL.
[0289] The Koopman-DL model was directly embedded into the Model Predictive Control (MPC) structure to establish the Koopman-DL-MPC model predictive control system for the biochemical reactor. A particle optimization algorithm was used as the optimization algorithm. Considering the computation time limitations under actual real-time control conditions, the computation time of the optimization algorithm was set to not exceed half an hour of the control time step. If the optimization algorithm failed to converge after 20 minutes of computation, it was terminated, and the control command for the current optimization process was output for control. The optimization objectives, as mentioned above, include three aspects: the biochemical reactor indicators should be as stable as possible near the design operating conditions; the effluent quality should meet the specified effluent indicators; and the aeration rate and chemical dosage should be minimized.
[0290] A specific day in the historical data was selected as a case study for simulated control. The results of the simulated optimized control process were compared with the actual control process, and the results are as follows: Figure 6 Figure 7 As shown in the results, although the control process of Koopman-DL-MPC exhibits significant fluctuations, the aeration rate is significantly lower than the actual situation, and the state variables remain within a certain range. This indicates that the optimization algorithm can guarantee the above conditions, proving the effectiveness of the method.
[0291] Step 5: Combine Koopman-DL-MPC with rationality testing methods to improve control security.
[0292] Based on the Koopman-DL-MPC framework, the output control commands at each control time step are combined with a rationality check index to provide a rationality check for the control, thereby improving its control safety. Data from the same time period is used for testing, with the relevant Koopman-DL-MPC settings remaining unchanged. The resulting control results are as follows: Figure 8 Figure 9 As shown in the figure, the results indicate that, with the help of the rationality check, the control process is significantly more stable than before, and the state variables remain within a certain range, thus further improving safety while ensuring optimized control.
[0293] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
Claims
1. A method for predictive simulation and real-time safety control of biochemical reaction tanks in wastewater treatment plants; characterized in that, Based on the Koopman matrix and deep learning, the following steps are included: Step 1: Preprocess the raw data from the biochemical reaction tank; Based on the original data and the time interval characteristics of the biochemical reaction tank, extreme outliers are removed, data is supplemented using interpolation methods, and data information is improved using normalization methods. The specific process is as follows: Step 1.1: Organize the raw data, i.e. the data obtained from real-time monitoring of the biochemical reaction tank, according to the running time; Step 1.2: Determine the time interval for cleaning the raw data based on the hydraulic retention time of the biochemical reaction tank; Step 1.3: Calculate the mean and standard deviation of each data point in the biochemical reaction tank within each time interval; Step 1.4: Delete extreme outlier data exceeding 3 standard deviations in the time interval and supplement them by interpolation; Step 1.5: Normalize the interpolated data for subsequent data analysis and modeling; The interpolation calculation formula is as follows: ; Where i represents the time node for which interpolation is required; The calculated i-th interpolated data is used to replace the deleted data. This data is calculated from the data of TN time steps before and after the time node i. The time steps during this period are represented by the variable j. For the j-th original data within each time interval, interpolation calculation is performed; the set of all interpolated data is... ; The normalization formula in step 1.5 is as follows: ; Here, inorm represents the data time point that needs to be normalized. This is the data after interpolation at the inorm time step. and These are the maximum and minimum values of the interpolated data. The data is normalized at the inorm time step; the set of all normalized data is... ; Step 2: Perform statistical and kinetic characteristic analysis on the biochemical reaction tank using a data-driven approach; Step 3: Construct a prediction and extrapolation model for biochemical reaction tanks based on the Koopman matrix and deep learning methods, namely Koopman-DL; Using the cleaned and normalized data, and with the help of the results of Koopman matrix dynamics feature analysis, features are designed and selected as input data for the prediction and inference model. A deep learning model is then constructed and trained to obtain the prediction and inference model. The predictive model includes the selection of biochemical reaction tank data features, selection of hyperparameters for the Koopman matrix and deep learning model, model training and structural cross-validation, model testing, and model stability and reliability analysis. Specifically as follows: Step 3.1: Combining the results of nonlinear regression analysis with the cleaned data, select the input information of the prediction and inference model as the input and output of the Koopman-DL prediction and inference model; The inputs to the prediction and extrapolation model are the influent data, biochemical reactor status data, and control data from a past period at the current moment; each specific data item is consistent with the data items selected by the regression model. The output of the predictive model is the effluent water quality and the state of the biochemical reactor over a future period. The model's hyperparameters are selected based on nonlinear regression analysis and are adjusted through cross-validation. The specific formulas are as follows: ; Where t represents the current time; lag is the predicted time span; Let t be the state variable from time t to t+lag; The variable representing the water inflow from time t to time t+lag; The control variable is defined from time t to t+lag. To predict water outflow variables, To predict state variables, both sets of data are derived from normalized data; For example, w is a deep neural network used to approximate the observation function corresponding to the Koopman matrix; w is the deep neural network... The parameters are obtained through training; K is the Koopman matrix; Step 3.2, Model Training and Testing, refers to training the constructed prediction and inference model using cleaned data. Training is achieved by minimizing the loss function, as shown in the following formula: ; Where t is the time node counter for the training data, ranging from 1 to the number of training data NumT; Let t be the state variable from time t to t+lag; The variable representing the water inflow from time t to time t+lag; The control variable is defined from time t to t+lag. To predict the true value of the water discharge variable; To predict the true value of the state variable; The optimization model is solved using the Adam deep learning model training algorithm, and the trained model can be used for the prediction and simulation of biochemical reaction tank dynamics. Step 3.3: Based on the comparison results of the hyperparameters of the regression model and the Koopman matrix, design the initial values of the hyperparameters of the deep learning model and the Koopman matrix of the Koopman matrix, as well as the matrix dimension, and further adjust the hyperparameters accordingly. The aforementioned model hyperparameter tuning refers to testing different deep learning model structures and initial values of the Koopman operator based on the training process described above. Each time the parameters are reset, the model is retrained using the same training algorithm to obtain the computational performance of the trained model. By comparing the performance of the model under different hyperparameters and initial values of the Koopman matrix, the best-performing set is selected as the final model hyperparameters and initial values of the Koopman matrix. The model corresponding to this set is then used as the final Koopman-DL prediction and inference model, and this model is used for prediction. Step 3.4: Perform robustness analysis on the trained prediction and inference model; the robustness analysis involves inputting different levels of perturbation into the model and observing the range of changes in its output; If the output of the prediction and inference model can remain within a certain range under different random perturbation inputs, then the trained prediction and inference model can be considered to have good robustness. The specific calculation formulas for the different degrees of disturbance are as follows: , ; , ; , ; Where tc is a time counter for adding perturbation data. For the state data after adding perturbations, For state data, For control data after adding disturbance, To control the data, To incorporate the influent data after disturbance, For water intake data, To conform to the mean Standard deviation is Normally distributed random perturbations; Step 4: Establishing a biochemical reaction tank model predictive control method based on the Koopman-DL predictive model, namely Koopman-DL-MPC; Based on the prediction and deduction model and the model predictive control method (MPC), a virtual real-time optimization control system for the biochemical reaction tank is constructed. The predictive control of a biochemical reaction tank model based on a deep learning predictive inference model is as follows: Step 4.1: Construct a standard model predictive control framework (MPC); the model predictive control framework (MPC) is a biochemical reactor state and effluent prediction model based on the Koopman matrix and deep learning, namely Koopman-DL. Step 4.2: Input the monitoring data of the biochemical reaction tank into the prediction model to predict the state of the biochemical reaction tank and the effluent quality; Step 4.3: Based on the prediction results and control objectives, a score is assigned, and the score is used as the objective function for optimization. The optimization objectives include three aspects: the indicators of the biochemical reactor should be as stable as possible near the design operating conditions; the effluent quality should meet the specified effluent indicators; and the aeration volume should be as small as possible. Step 4.4: Based on the optimization objective, optimize and adjust the control measures for the next time step, including aeration volume, drug dosage, and internal and external return flow, using the optimization algorithm to maximize the objective function value. Step 4.5: Through repeated prediction and optimization, the optimal control strategy for the next time step can be obtained and used for control. Step 4.6: Proceed to the next time step and repeat steps 4.1 to 4.5 above, thereby achieving real-time optimization control of the system; The above process is described by the following time-step optimization model: ; ; ; ; ; ; Where t is time, lag is the time span of the predicted output variable; J, U, and P represent the objective functions corresponding to the above three objectives; , , , These are the upper and lower limits of the state variables and effluent indicators of the biochemical reaction tank; The target line for the control variables; , , Input state variables, effluent indicators, and optimization control variables; , All are state variables and effluent indicators for predicted output; Lagk is a counter for the optimized control variable; In the model predictive control method, under the premise of ensuring that the effluent water quality meets the standards and the state of the biochemical reactor is stable, the total amount of aeration and the amount of chemicals added in the system should be reduced as much as possible to achieve optimized control and energy-saving operation of the biochemical reactor. The control effect is evaluated using J+U+P. The lower the J+U+P obtained during the control process, the better the control effect. Any optimization algorithm can be used to solve the above optimization model, including but not limited to genetic algorithms and particle swarm optimization. However, considering the characteristics of real-time control of biochemical reactors, the optimization algorithm needs to increase the computation time limit when solving the above optimization problem in each time step. The optimization solution time should not exceed the control time interval. That is, the number of iteration steps of the optimization algorithm is calculated from the control time interval and the single optimization time, as shown in the following formula: ; in, The number of iterations calculated for the optimization algorithm. For control time intervals, This refers to the time required for a single iteration of the optimization algorithm. Step 5: Construct a data-driven method for verifying the rationality and safety of the biochemical reaction tank using Koopman-DL-MPC. Based on the virtual real-time optimization control system of the biochemical reaction tank, the rationality and safety of the control commands are verified. The rationality and safety verification includes range detection of control commands, rationality verification of control commands based on historical data, and estimation of control effect of control commands based on predictive inference models. The specific steps are as follows: Step 5.1: Determine whether the current optimized control variables are within the artificially defined range; the optimized control strategy obtained through the model prediction control Koopman-DL-MPC needs to be compared with the relevant indicators in the artificially defined operating standards of the AAO process in wastewater treatment plants, and the optimized control strategy is determined to be within the range specified by the standards based on the comparison results; the specific steps are as follows: Step 5.1.1: Directly collect historical data on control variables and calculate their mean and standard deviation; Step 5.1.2: Based on the statistical principle of three standard deviations, the mean plus or minus three standard deviations is taken as the reasonable range. The optimized control variable is then directly tested to see if it remains within this range. The upper and lower limits can be calculated using the following formula: ; ; Wherein, upper and down are the upper and lower limits calculated from the data; This represents the historical data of the control variable, with a total of NumA data points; h is the count variable used when calculating the upper and lower limits of the control variable data; Express the average value of the control variable data; Step 5.1.3: Based on the recommended process parameters, further calibrate the above upper and lower limits; finally, take the intersection of the recommended process parameter range and the down and upper intervals as the final judgment range, that is, when the optimized control variable satisfies the following inequality condition, the current optimized control variable is considered to be within the artificially defined range: ; in, This represents the optimized control variables; Indicates the range of values determined by down and upper; and These are the recommended upper and lower limits of process parameters; Indicates by and A defined range of values; This represents the intersection of two range sets; This indicates that the control variables being optimized belong to this set; Step 5.2: Determine whether the current optimized control variable is consistent with similar historical cases; through normalized historical data, statistically analyze the conditional probability distribution of the control variable under similar conditions, and determine the reasonable upper and lower limits of the control variable based on the statistical principle of three standard deviations. The conditional probability distribution under similar conditions refers to the process of calculating the optimized control variables at a certain moment, using the inflow and state variables at that moment, filtering control data from historical data that are close to the inflow and state variables, and statistically analyzing the probability distribution of these control data. The judgment of data similarity is made using vector distance, as shown in the following formula: ; in, and This represents two sets of state data that need to be compared. and This represents two sets of influent data to be compared; s1 and s2 are the indices of the two sets of data to be compared; when the distance is small enough, the two sets of data are considered to be close. The calculation process for the reasonable upper and lower limits of the control variables is similar to that in step 5.1, the only difference being that the data for the control variables is filtered data. The specific steps are as follows: Step 5.2.1: Compare the current status data and water inflow data with the status data and historical data of all times in history, and calculate the distance between each set of data using the distance formula mentioned above; Step 5.2.2: Set the distance threshold to 0.2, record the control variables corresponding to historical data with similarity less than the threshold, and obtain "control variable data in historical situations similar to the current state"; Step 5.2.3: Calculate the filtered data according to Step 5.1 to obtain the control variable judgment range of the conditional probability distribution under similar conditions; if the optimized control variable is within this range, it is considered that the current optimized control variable is consistent with the historical similar cases, and passes the "consistent with historical similar cases" test. Step 5.3: Determine whether the control effect of the current optimized control variables is feasible; input the optimized control variables, the influent variables and the state variables at the current moment into the Koopman-DL prediction model to directly predict the state variables and effluent variables at future moments, thereby determining whether the control effect is feasible; The specific steps are as follows: Step 5.3.1: Use the optimized control variables and the current state as inputs to the inference and prediction model to perform a one-step prediction; Step 5.3.2: Compare the prediction results with the operating standards of the biological reactor. If the state variables, including dissolved oxygen and MLSS, remain within the specified range of the biological reactor and the effluent quality meets the standards, then the optimized control variables given at the current moment are considered reasonable and feasible and can be used as the control output of the system. Otherwise, it is considered that the currently given control variables can achieve the optimization effect by saving aeration as a control factor. Step 5.4: Determine the final safety and reasonableness of the optimized control variables; if the optimized control variables pass the tests in steps 5.1-5.3 above, then the control variables are considered safe and reasonable and can be used for actual control; otherwise, the optimized control variables are considered to be risky, and the process returns to step 4 to recalculate.
2. The method for predictive simulation and real-time safety control of biochemical reaction tanks in wastewater treatment plants according to claim 1, characterized in that, In step 1, the raw data for the biochemical reaction tank refers to the status data obtained by real-time monitoring of the biochemical reaction tank; The analysis and preprocessing include cleaning and normalizing the raw data; The cleaning refers to removing abnormal data caused by equipment maintenance events from the original data, and removing noise and abnormal fluctuations from the original data through a time-averaging method. The normalization is to map the data to the range of -1 to 1 through calculation, so as to facilitate subsequent analysis and modeling.
3. The method for predictive simulation and real-time safety control of biochemical reaction tanks in wastewater treatment plants according to claim 1, characterized in that, In step 1, the raw data includes the following: COD, ammonia nitrogen, total nitrogen, total phosphorus, water temperature and flow rate of the influent section of the biological reactor under different quarters and rainfall load conditions of the wastewater treatment plant; MLSS concentration of activated sludge in the biological reactor; dissolved oxygen concentration (DO) in the anaerobic, anoxic, and aerobic sections of the reactor; oxidation-reduction potential (ORP); and nitrate nitrogen (NO3) in the aerobic section. - The aeration rate and chemical dosage of the biochemical reaction tank, the internal and external reflux flow rates, the sludge discharge rate, and the COD, total nitrogen, and total phosphorus of the effluent from the biochemical reaction tank; The raw data is obtained through real-time online data monitoring, with a frequency of one data point every 10 minutes.
4. The method for predictive simulation and real-time safety control of biochemical reaction tanks in wastewater treatment plants according to claim 1, characterized in that, In step 2, the normalized data after cleaning is used to perform statistical and kinetic characteristic analysis on the biochemical reaction data; The input data includes linear correlation analysis, nonlinear regression analysis, estimation of data probability distribution and conditional probability distribution, and Koopman matrix analysis of dynamical systems. Based on linear correlation analysis and nonlinear regression analysis, the characteristics of the biochemical reactions affecting the biochemical reactor are selected. The results are analyzed using probability distribution and conditional probability distribution. This allows for a data-driven analysis of the historical operating characteristics of the biochemical reactor, and the characteristics and corresponding data are used as input data for the predictive model. The size of the Koopman matrix dimension provides a reference for the size of the Koopman matrix in the subsequent predictive model. Furthermore, its properties allow for the analysis and judgment of the dynamic properties of the AAO process in wastewater treatment, including determining the system's stability through eigenvalue analysis.
5. The method for predictive simulation and real-time safety control of biochemical reaction tanks in wastewater treatment plants according to claim 4, characterized in that, In step 2, the kinetics of the biochemical reaction are analyzed as follows: Step 2.1: Through linear correlation analysis, the linear correlation between each data item in the normalized data, as well as between data items with time differences, is analyzed and evaluated. The specific formula for calculating the correlation coefficient is as follows: ; in, For two arrays of data and The linear correlation coefficient calculated between corresponding data items; z is a natural number greater than or equal to 1, representing the data number used for the correlation test; lt is a natural number greater than or equal to 1, representing the time difference of the data used for the correlation test; Cov is the covariance of the data; Var is the variance of the data. Step 2.2: Through nonlinear regression analysis, the prediction model uses the input and output as the input and output of the regression problem. It uses the collected data to fit the data with the help of a deep learning model. Based on different model inputs, deep learning model structures, and hyperparameter selections, the model input data items and model structures with the best fitting performance are compared and determined. The fitting process is shown in the following formula: ; Where Reg is the deep learning model used for regression fitting; Num represents the amount of data used for nonlinear fitting; k is the count variable for the data in the regression calculation, ranging from 1 to Num; and These are the input and output of the fit; These are the parameters used in the deep learning regression model; Step 2.3: Estimation of data probability distribution and conditional probability distribution. Analyze the data to obtain its probability distribution and the conditional probability distributions between them. This allows for analysis of the historical operational characteristics of the biochemical reactor from a data perspective. Specific steps are as follows: Step 2.3.1: Determine the maximum and minimum values of each data item based on the data, and divide the interval between the minimum and maximum values; Step 2.3.2: Count the amount of data contained in each partition. After counting all the data, the number of data contained in each partition can be obtained, thus obtaining the probability distribution of the data. Then, through the probability distribution, the value range of each data item and the historical situation of the biochemical reaction tank can be directly known. Step 2.3.3: Filter data that meets certain conditions from the data, and count the amount of data contained in each partition of the filtered data to obtain the number of data contained in each partition, thereby obtaining the conditional probability distribution of the data; Step 2.4: Combining Extended Dynamic Mode Decomposition (EDMD) with the original data, an approximate Koopman matrix and its eigenvalues are obtained to acquire an approximate Koopman matrix in the sense of the observation function. Specifically, this can be obtained by solving the following optimization problem: ; Where G is the observation function; K is the Koopman matrix that needs to be solved. The size of the Koopman matrix provides a reference for the size of the Koopman matrix in the subsequent prediction model. At the same time, the properties of K can be used to analyze and judge the dynamic properties of the wastewater treatment AAO process, including judging the stability of the system through the eigenvalues of K. and The data used to solve the Koopman matrix is obtained from the cleaned data; Numk is the total amount of data used to solve the Koopman matrix; km is the count variable of the data used to solve the Koopman matrix, ranging from 1 to Numk.
