Cascade control method and system for alum adding process of water plant
By combining LSTM-Transformer network and SAM algorithm with cascade control method of MPC and PID controller, the problem of unstable turbidity of effluent during alum addition in water treatment plant was solved, and the precise adjustment of alum dosage was realized, thus improving the intelligence and automation level of water treatment system.
Patent Information
- Application Number
- CN202511344274.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-19
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2045-09-19
AI Technical Summary
Existing methods for controlling alum addition in water treatment plants are insufficient to accurately and promptly adjust the amount of coagulant added when faced with sudden changes in water quality, resulting in unstable turbidity in the effluent.
A feedforward alum dosage prediction model was constructed using an LSTM-Transformer network prediction model. The SAM algorithm was combined to segment the alum floc image and calculate its geometric features and physical parameters. Cascade control was performed using MPC and PID controllers to achieve precise adjustment of the alum dosage.
It improves the prediction accuracy and response speed of the alum addition process, ensures that the turbidity of the effluent is always within the standard range, enhances the intelligence and automation of the water treatment system, and reduces maintenance costs.
Smart Images

Figure CN120831903A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to a water plant alum addition process cascade control method and belongs to the technical field of automatic control of water plants. BACKGROUND
[0002] With the rapid development of social economy and the improvement of people's living standards, urban safe water is also paid more and more attention. In order to effectively guarantee the quality of people's living water, more stringent requirements are put forward for the operation and management of water supply plants. The water plant needs to ensure that the effluent water quality meets the standard, and pays attention to energy saving and consumption reduction during operation, and improves economic and social benefits. In the water treatment process of the current water plant, alum or other coagulants are added as an important step in the coagulation process. Alum addition can not only effectively remove suspended solids, colloidal substances and pathogenic microorganisms in water, but also optimize the subsequent filtration and disinfection process.
[0003] The alum addition control of the existing water plant still adopts manual control or traditional feedback control based on proportional water flow, but has certain limitations in the face of sudden water quality changes such as heavy rain or sewage accidents. In addition, since the alum addition process has hysteresis, the coagulation reaction and sedimentation formation need a certain time, which makes the control of the alum addition process more complex. SUMMARY
[0004] The technical problem to be solved by the application is to overcome the deficiencies in the prior art and to realize more accurate and timely adjustment of the alum addition amount, so as to ensure that the effluent turbidity is always within the standard range.
[0005] To achieve the above purpose, the application adopts the following technical scheme:
[0006] A water plant alum addition process cascade control method comprises the following steps:
[0007] Obtain the original operation data and alum flower images of the water plant, and pretreat the original operation data and alum flower images;
[0008] Construct a feedforward alum addition amount prediction model by using an LSTM-Transformer network prediction model; input the pretreated original operation data into the pre-trained feedforward alum addition amount prediction model to obtain the feedforward alum addition amount prediction value at the current time;
[0009] Segment the shape of the alum flower from the pretreated alum flower image by using a SAM algorithm, and generate a mask list; extract the boundary coordinates of the segmented region layer by layer based on the mask list by using an OpenCV contour detection algorithm, calculate the geometric features and physical parameters of the alum flower, and calculate the settling velocity according to the geometric features and physical parameters;
[0010] The water turbidity prediction model and the settling velocity prediction model are constructed by using an LSTM-Transformer network prediction model; the input of the water turbidity prediction model is the settling velocity set value calculated by the MPC controller, and the output is the water turbidity prediction value; the input of the settling velocity prediction model is the sedimentation tank inflow, and the output is the settling velocity prediction value;
[0011] According to the water turbidity prediction value, the optimal set value of the settling velocity is calculated by the MPC controller of the main loop, and according to the deviation between the optimal set value of the settling velocity and the settling velocity prediction value, the PID controller of the secondary loop is used to control the alum dosage;
[0012] The alum dosage output by the PID controller of the secondary loop is added to the feedforward alum dosage prediction value to generate the final alum dosage.
[0013] The aforementioned water plant alum addition process cascade control method, the preprocessing includes the following steps:
[0014] Obtain the original operation data with time sequence characteristics; the original operation data includes raw water turbidity, inflow, pH value, ammonia nitrogen amount, and sedimentation tank inflow; therefore, after cleaning and filtering the obtained original operation data, normalization processing is performed;
[0015] The SAM algorithm is used for preprocessing of the alum flower image, including:
[0016] The original BGR alum flower image is converted to grayscale by using the weighted average method:
[0017] ;
[0018] wherein, is the original three-channel image pixel value, is the grayscale value;
[0019] After grayscale conversion, spatial filtering is performed by using a 5*5 Gaussian kernel, and the spatial filtering kernel function is defined as:
[0020] ;
[0021] wherein, is the position weight of the coordinates in the Gaussian kernel, is the coordinate offset relative to the center in the Gaussian kernel, is the standard deviation;
[0022] Adaptive binarization is realized based on the OSTU algorithm dynamic calculation of the global optimal threshold, and the formula is:
[0023] ;
[0024] wherein, The foreground / background pixel ratio, respectively, The foreground / background pixel mean, respectively, The intra-class mean, The inter-class variance, The binary threshold value;
[0025] The open operation based on a 5*5 rectangular kernel, the hole is closed and the flocculation edge is smoothed by the operation of erosion followed by inflation, and the formula is:
[0026] ;
[0027] Wherein, A is the alum flower image after processing, The open operation, B is the element of the 5*5 structure matrix, 、 Respectively, erosion and inflation operation;
[0028] The optimized binary inflation is used for the original image to suppress non-background and generate the region of interest image.
[0029] The aforementioned water plant alum addition process cascade control method, in the LSTM-Transformer network prediction model, first utilize LSTM model to encode input sequence, obtain the local feature of sequence, then transmit the output of LSTM model to Transformer model as input, extract dependent feature and global feature of sequence, finally predict.
[0030] The aforementioned water plant alum addition process cascade control method, the LSTM-Transformer network prediction model structure includes:
[0031] Add a Dropout layer after each LSTM model, repeat three layers;
[0032] In the Transformer model, in turn, multi-head attention layer, residual connection, Dropout layer, full connection layer;
[0033] Select ReLU function as the activation function, select Adam optimizer, select appropriate window length;
[0034] Root mean square error RMSE is used as the core evaluation index of sliding window length:
[0035] ;
[0036] Wherein, And The actual value and the measured value, respectively, The sample number.
[0037] In the aforementioned cascade control method for alum addition in a water plant, the calculation method of the geometric characteristics and physical parameters is as follows:
[0038] Green's formula is used to convert the area integral of a two-dimensional closed area into a boundary line integral. The formula is:
[0039] ;
[0040] in, is the area of a single alum flower, Indicates the The pixel coordinates of the contour boundary points, is the total number of contour points; the pixel area of each segmented area is accumulated to obtain the total area of the aggregate ;
[0041] The continuous boundary is discretized into a combination of horizontal, vertical or diagonal line segments through the chain approximation method, and the segment lengths are accumulated segment by segment:
[0042] ;
[0043] in, is the length of each segmented region, is the number of discretized continuous boundary segments; the length of each segmented area is accumulated to obtain the total length of the aggregate ;
[0044] The irregularly shaped aggregate is equivalent to a circle with the same area, and a simplified geometric model is established. The formula is:
[0045] ;
[0046] in, is the actual area of the contour, is the equivalent diameter of a single alum flower, and its unit is consistent with the pixel size;
[0047] The closed contours in the binary image are identified by edge tracking algorithm, and each closed contour is regarded as a separate alum flower individual. The number of alum flowers is recorded as ;
[0048] The calculation methods of physical parameters and sedimentation velocity are as follows:
[0049] Dynamic viscosity :Calculated using the VFT equation:
[0050] ;
[0051] in, is the pre-exponential factor, D and C are both constants, is the water temperature;
[0052] Calculate the equivalent density of flocculent particles using a nonlinear adjustment formula ,
[0053] ;
[0054] in, is the equivalent diameter of the flocs;
[0055] Derivation of mechanical radius using area-perimeter ratio method :
[0056] ;
[0057] in, is the total area of the aggregate, is the total length of the aggregate, is the amount of aggregate;
[0058] Sedimentation velocity The calculation method is as follows:
[0059] ;
[0060] in, is the density of the fluid, is the acceleration due to gravity.
[0061] In the aforementioned cascade control method for the alum addition process in a water plant, the objective function of the MPC controller is:
[0062] ;
[0063] in, is the effluent turbidity output predicted at step i, is the setting value of step i, is the weight of the control variable, is the manipulated variable weight, It is The control input increment of the step, To predict the horizon, To control the field of view, is the objective function of the MPC controller, k is the time step index;
[0064] The MPC controller uses the sequential least squares programming algorithm to solve the optimal control sequence and extracts the first value as the optimal settling velocity setting value of the secondary loop.
[0065] The formula of the sequential least squares programming algorithm for the aforementioned cascade control method of the alum addition process in a water plant is as follows:
[0066] ;
[0067] ;
[0068] wherein, is the objective function, is the constraint condition, is the Lagrange function, is the Lagrange multiplier, is the Hessian matrix of the Lagrange function at is the search direction, is the transpose of the gradient of the objective function at is the transpose of the gradient of the objective function at is the transpose of the gradient of the objective function at
[0069] satisfies the following constraint condition:
[0070] ;
[0071] ;
[0072] wherein, is the gradient of the constraint function at is the equality constraint quantity, is the total constraint quantity, is the function value of the constraint function at is the function value of the constraint function at
[0073] The aforementioned alum addition process cascade control method for water plants corrects the predicted value of the water turbidity prediction model through real-time instrument readings:
[0074] The deviation of the corrected water turbidity prediction value from the water turbidity set value and the settling velocity change value obtained by the SLSQP algorithm optimization are then included in the objective function of the MPC controller, and the optimal value of the settling velocity at the next time is solved by the SLSQP algorithm as the input of the secondary loop;
[0075] In the secondary loop, the settling velocity is calculated by segmenting the alum flower image, the settling velocity prediction value output by the settling velocity prediction model is dynamically corrected by the calculated settling velocity, and the feedback alum addition amount is calculated by the PID controller.
[0076] A computer system includes a memory, a processor, and a computer program stored on the memory, the processor executing the computer program to implement the steps of the above method.
[0077] A computer readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the above method.
[0078] The water plant alum addition process cascade control method based on the alum flower image recognition result provided by the present application adopts an MPC controller based on an LSTM-Transformer prediction model, can better grasp the local mode of time series data and the information relationship of long time span, has higher prediction accuracy, can output high-contrast color visual images and more accurate data based on SAM algorithm segmentation of alum flower images, and combines feedforward-feedback compound control for prediction correction to accurately control the alum addition amount. Compared with the traditional method relying on artificial judgment and simple rules, the feedforward-feedback compound control of the present application has faster response speed and better stability, can more accurately and timely adjust the alum addition amount, so as to ensure that the effluent turbidity is always within the standard range, greatly improves the intelligentization and automation degree of the treatment process, and reduces the maintenance cost.
[0079] The present application realizes dynamic regulation and management of the whole water treatment process by real-time acquisition and analysis of key water quality parameters and process operation data, and construction of a treatment process intelligent optimization model by means of a deep learning algorithm. The operation efficiency and stability of the water treatment system are significantly improved. BRIEF DESCRIPTION OF DRAWINGS
[0080] Figure 1 is a flowchart of the water plant alum addition process cascade control method provided by example 1;
[0081] Figure 2 is a comparison chart of each stage of alum flower preprocessing provided by example 1;
[0082] Figure 3 is an LSTM-Transformer model structure diagram provided by example 1;
[0083] Figure 4 is a comparison chart of alum addition amount prediction results provided by example 1;
[0084] Figure 5 is a comparison chart of effluent turbidity prediction results provided by example 1;
[0085] Figure 6 is a comparison chart of settling velocity prediction results provided by example 1;
[0086] Figure 7 is a comparison chart of alum flower before and after segmentation provided by example 1;
[0087] Figure 8 is a feedforward-feedback compound control flowchart provided by example 1;
[0088] Figure 9 is an experimental result diagram of the feedforward-feedback compound control provided by example 1. DETAILED DESCRIPTION
[0089] The application will be further described below with reference to the drawings. The following examples are only used to more clearly illustrate the technical solutions of the application, and cannot be used to limit the protection scope of the application.
[0090] Example 1
[0091] As Figure 1 shown, the embodiment provides a water plant alum process cascade control method, comprising:
[0092] Step one, obtaining the original running data of the water plant and the alum flower image; and preprocessing the original running data and the alum flower image.
[0093] The preprocessing includes the following steps:
[0094] 1) Obtain the original running data with time sequence characteristics; the original running data includes raw water turbidity, inflow, pH value, ammonia nitrogen amount, and sedimentation tank inflow;
[0095] 2) If the sensor fails, the collected data may be biased or incorrect, or due to the lagging nature of manual alum adjustment, some data may be abnormal, the effluent turbidity value cannot meet the effluent turbidity requirement, or redundant data under the same working condition, leading to overfitting of the neural network model.
[0096] Therefore, after cleaning and filtering the obtained running data, normalization processing is performed, size transformation is adopted, the minimum value and the maximum value of the data range are taken and unified transformation is performed to reduce the difference in absolute error between large and small values.
[0097] The formula for transforming the data in the interval [-1, 1] is:
[0098] ;
[0099] Among them, indicates the input or output data, indicates the normalized data, and respectively represent the minimum value and the maximum value in the data range.
[0100] 3) As Figure 2 shown, the alum flower image data of the water plant is collected and the alum flower image data is preprocessed, including:
[0101] The SAM algorithm is used to preprocess the alum flower image data, including:
[0102] First, the original BGR alum flower image is converted to grayscale by using the weighted average method:
[0103] ;
[0104] wherein, is the original three-channel image pixel value, is the gray value.
[0105] After gray scale conversion, spatial filtering is performed using a 5x5 Gaussian kernel. The spatial filtering kernel function is defined as:
[0106] ;
[0107] wherein, is the position weight of the coordinates in the Gaussian kernel, is the coordinate offset relative to the center in the Gaussian kernel, is the standard deviation, .
[0108] Subsequently, the global optimal threshold is dynamically calculated based on the OSTU algorithm to realize adaptive binarization. The formula is:
[0109] ;
[0110] wherein, are the foreground / background pixel proportions, respectively, are the foreground / background pixel means, respectively, is the intra-class mean, is the inter-class variance, is the binarization threshold.
[0111] Based on the opening operation of the 5x5 rectangular kernel, small holes are closed and the flock edge is smoothed through the operation of erosion followed by dilation. The formula is:
[0112] ;
[0113] wherein, is the treated alum flower image, is the opening operation, is the 5x5 structure matrix element, , respectively represent the erosion and dilation operations. Finally, the optimized binary dilation is used for the original image to suppress non-background and generate an image of the region of interest with low noise and clear details.
[0114] Step two, using the LSTM-Transformer network prediction model as the framework, a feedforward plus alum amount prediction model is constructed. The pretreated running data is used as the input data, including raw water turbidity, inflow, pH value, and ammonia nitrogen amount. The pre-trained feedforward plus alum amount prediction model is used to obtain the feedforward plus alum amount prediction value at the current time.
[0115] In the LSTM-Transformer network prediction model, the input sequence is first encoded by the LSTM model to obtain the local features of the sequence, and then the output of the LSTM model is transmitted to the Transformer model as input to extract longer-range dependency features and global features of the sequence, and finally the prediction is performed.
[0116] The LSTM-Transformer network prediction model can fully utilize the sequence representation capability of the LSTM model and the global capability of the Transformer model to improve the performance of the model.
[0117] In order to realize the LSTM-Transformer prediction model to adaptively select the most relevant input features at each time, an attention mechanism is added in the decoder stage, and the decoder uses the attention mechanism to combine the hidden layer information to give a certain weight to each input feature. At the same time, an attention mechanism is also introduced in the encoder stage, and the LSTM model is used to weight and sum the hidden states of the encoder to capture long-term dependencies.
[0118] As shown in Figure 3 , the LSTM-Transformer network prediction model structure includes:
[0119] 1) A Dropout layer is added after each LSTM model, and three layers are repeated. It can prevent overfitting of the model and fully extract the time series patterns contained in the data.
[0120] 2) In the Transformer model, a multi-head attention layer, a residual connection, a Dropout layer, and a fully connected layer are sequentially arranged. It can use the Transformer model to obtain super-long distance dependency information, which is helpful for information flow and gradient propagation, prevents gradient vanishing in deep networks, changes the dimension of the extracted data and performs nonlinear transformation, and makes output prediction.
[0121] 3) Select ReLU function as the activation function, select Adam optimizer, and select appropriate window length.
[0122] In the LSTM-Transformer network prediction model, the root mean square error (RMSE) is used as the core evaluation index of the sliding window length:
[0123] ;
[0124] Wherein, and are the actual value and the measured value, is the number of samples.
[0125] The optimal window number was selected according to the comparison results, wherein the RMSE of the alum dosage prediction window number 15 was the smallest, the RMSE of the effluent turbidity prediction window number 3 was the smallest, and the RMSE of the settling velocity prediction window number 15 was the smallest.
[0126] As shown in Figure 4 , Figure 5 and Figure 6 , the prediction alum dosage RMSE of the LSTM, Transformer and combined model was 1.370 mg / L, 1.229 mg / L and 1.065 mg / L, the combined model reduced by 22.3% compared with the LSTM model and by 13.3% compared with the Transformer model; the prediction effluent turbidity RMSE of the LSTM, Transformer and combined model was 0.175 NTU, 0.163 NTU and 0.155 NTU, the combined model reduced by 11.1% compared with the LSTM model and by 4.5% compared with the Transformer model; the prediction settling velocity RMSE of the LSTM, Transformer and combined model was 0.0024 m / s, 0.0026 m / s and 0.0019 m / s, the combined model reduced by 20.8% compared with the LSTM model and by 26.9% compared with the Transformer model. The prediction effect based on the LSTM-Transformer prediction model has the smallest error with the actual value and has higher prediction accuracy.
[0127] Step three, alum flower feature extraction: the SAM algorithm is used to accurately segment the shape of the alum flower from the preprocessed alum flower image and generate a mask list. The OpenCV contour detection algorithm is used to extract the boundary coordinates of the segmented area layer by layer based on the mask list, and the following four geometric features and two physical parameters of the alum flower are calculated, and the settling velocity is calculated according to the four geometric features and two physical parameters.
[0128] The calculation method of the four geometric features and physical parameters is as follows:
[0129] Area parameter: the area integral of a two-dimensional plane closed region is converted into a boundary line integral by using Green's formula, and the formula is:
[0130] ;
[0131] wherein, is the area of a single alum flower, represents the pixel coordinates of the contour boundary point, is the total number of contour points; the pixel area of each segmented region is accumulated, and finally the total area of the coagulation body is obtained.
[0132] Perimeter parameter: The continuous boundary is discretized into a combination of horizontal, vertical or diagonal line segments by chain approximation method, and the length of each segment is accumulated:
[0133] ;
[0134] wherein, L is the length of each partition region, N is the number of discretized continuous boundary segments.
[0135] The length of each partition region is accumulated, and the total length L is finally obtained .
[0136] Equivalent diameter: The irregular shape of the coagulum is equivalent to a circular shape with the same area, and a geometric simplification model is established, and the formula is:
[0137] ;
[0138] wherein, A is the actual area of the outline, D is the equivalent diameter of a single alum flower, with the same unit as the pixel size.
[0139] Number statistics: The closed contour in the binary image is identified by the edge tracking algorithm, and each closed contour is regarded as a single alum flower individual, and the number of alum flowers is recorded as N. .
[0140] The calculation method of the two physical parameters and the settling velocity is as follows:
[0141] Dynamic viscosity : used to represent the resistance of fluid to particle motion, calculated by VFT equation:
[0142] ;
[0143] wherein, is the pre-exponential factor, with a value of 2.414×10 -5 , unit is , D=247.8, C=140 are constants, T is the water temperature.
[0144] Equivalent density: the equivalent density of the flocculation particle is calculated by the nonlinear adjustment formula ,
[0145] ;
[0146] wherein, D is the equivalent diameter of the flocculation.
[0147] Considering that the actual alum flowers usually present irregular fractal structure, such as dendritic aggregate, the area-perimeter ratio method is used to derive the mechanical radius for better fitting the real fluid action :
[0148] ;
[0149] wherein, is the total area of the coagulum, is the total length of the coagulum, is the number of coagulums.
[0150] The settling velocity is calculated as follows:
[0151] ;
[0152] wherein, is the density of the fluid, is , is the acceleration of gravity, and the value is .
[0153] As shown in Figure 7 , in order to more intuitively show the segmentation performance of the algorithm, the segmentation results are rendered, so that the morphology, size, distribution and other characteristics of the alum flower individuals can be quickly observed, and the preparation for the accurate measurement of the characteristics such as the area, perimeter and equivalent diameter of the alum flower is made.
[0154] Step four, as shown in Figure 8 , the water turbidity prediction model and the settling velocity prediction model are constructed by using the LSTM-Transformer network prediction model. The input of the water turbidity prediction model is the settling velocity set value calculated by the MPC controller, and the output is the water turbidity prediction value; the input of the settling velocity prediction model is the inflow of the sedimentation tank, and the output is the settling velocity prediction value.
[0155] The formula of the LSTM model is as follows:
[0156] ;
[0157] ;
[0158] ;
[0159] ;
[0160] ;
[0161] ;
[0162] wherein is the input feature, is the output of the input gate, is a sigmoid activation function, is the weight matrix of the input gate, are bias terms, is the current input, is the output at the previous time step, is the output of the forget gate, is the weight matrix of the forget gate, is the output gate, is the weight matrix of the output gate, is the candidate cell state, is a hyperbolic tangent activation function, is the weight matrix of the candidate cell state, is an element-wise product, is the cell state at the previous time step, is the output of the time series feature.
[0163] The formula of the Transformer model is as follows:
[0164] ;
[0165] ;
[0166] ;
[0167] ;
[0168] ;
[0169] wherein, are the query vector, the key vector, and the value vector, respectively, is a learnable weight matrix, is the i-th single-head attention output result, is the dimension of the vector, is a multi-head attention function, is a layer normalization function, is a random dropout function, is an activation function, is the weight matrix of the output layer, is the bias term of the output layer, are the alumina prediction value, the water turbidity prediction value, and the sedimentation velocity prediction value.
[0170] Step 5: Based on the predicted value of the effluent turbidity, the MPC controller of the main loop calculates the optimal settling velocity setting value; based on the deviation between the optimal settling velocity setting value and the predicted settling velocity value, the secondary loop uses a PID controller to control the alum dosage to achieve cascade control of alum dosage.
[0171] Based on the designed LSTM-Transformer network prediction model, the objective function of the MPC controller is selected:
[0172] ;
[0173] in, is the effluent turbidity output predicted at step i, is the setting value of step i, is the weight of the control variable, is the manipulated variable weight, It is The control input increment of the step, To predict the horizon, To control the field of view, is the objective function of the MPC controller, and k is the time step index.
[0174] The MPC controller uses the Sequential Least Squares Programming (SLSQP) algorithm to solve the optimal control sequence and extracts the first value as the optimal settling velocity setting value of the secondary loop.
[0175] The formula for the sequential least squares programming algorithm is as follows:
[0176] ;
[0177] ;
[0178] in, is the objective function, is the constraint condition, is the Lagrangian function, is the Lagrange multiplier, is the Lagrangian function in The Hessian matrix at , is the search direction, The objective function is The transpose of the gradient at .
[0179] The following constraints are satisfied, where the first one is an equality constraint and the second one is an inequality constraint:
[0180] ;
[0181] ;
[0182] wherein, is the gradient of the constraint function at , is the equality constraint quantity, is the total constraint quantity, is the function value of the constraint function at .
[0183] The main loop MPC controller calculates the setting value of the settling velocity, and the secondary loop controller adjusts the alum dosage on the basis of the setting value to achieve the purpose of stabilizing the effluent water quality, reducing the turbidity variation of the effluent, and optimizing the water treatment system.
[0184] In the control of the secondary loop, a simple proportional control algorithm is used, and the proportional control acts on the optimal setting value determined by the control given by the MPC in the secondary loop control strategy. The size of the alum dosage is also adjusted by proportional control, thereby making up for the influence of nonlinearity and disturbance in the secondary loop control system.
[0185] Step six, based on the cascade control system of the main loop and the secondary loop in step five, to further enhance the anti-interference ability of the system, the alum dosage prediction value output by the feedforward alum dosage prediction model in step four is added to the alum dosage output by the PID controller in the secondary loop to generate the final alum dosage, which is sent to the alum dosage device to construct a feedforward-feedback composite control algorithm.
[0186] As shown in Figure 8 , the prediction value of the effluent turbidity prediction model is corrected by real-time instrument readings:
[0187] The deviation of the corrected effluent turbidity prediction value and the effluent turbidity setting value, and the settling velocity change value optimized by the SLSQP algorithm are then taken into the objective function of the MPC controller, and the optimal value of the settling velocity at the next moment is solved by the SLSQP algorithm as the input of the secondary loop;
[0188] In the secondary loop, the settling velocity is calculated by dividing the alum flower image, and the settling velocity prediction value output by the LSTM-Transformer settling velocity prediction model in step four is dynamically corrected by the calculated settling velocity, and the feedback alum dosage is calculated by the PID controller.
[0189] The change data of the raw water quality are monitored and input into the feedforward alum dosage prediction model, and the feedforward alum dosage prediction model outputs the feedforward alum dosage prediction value.
[0190] Finally, the feedforward alum dosage prediction value and the feedback alum dosage output by the PID controller are summed according to weights to obtain a final alum dosage, so as to realize accurate control of the alum adding process.
[0191] As shown in Figure 9 The feedforward-feedback composite control method successfully controls the effluent turbidity in a relatively stable range by controlling the alum dosage, and the effluent turbidity variance is 0.0053 , which is more stable in terms of effluent turbidity stability. The cascade control can quickly respond to changes in the settling velocity through timely feedback adjustment of the secondary loop PID, and quickly adjust the alum dosage in the case of poor coagulation effect, so as to realize the stability of the effluent water quality.
[0192] The technical concept of the present application is to use an MPC controller based on an LSTM-Transformer prediction model, segment alum flower images based on a SAM algorithm, and combine feedforward-feedback composite control for prediction correction to accurately control the alum dosage.
[0193] The LSTM-Transformer prediction model of the present application combines the memory capability of LSTM and the self-attention mechanism of Transformer, significantly enhancing the ability to capture long-term and short-term dependencies and parallel processing capabilities. The prediction model uses a multi-layer LSTM stacking architecture to gradually dig into the time sequence dependencies in the input sequence, ensuring that the model still maintains good generalization ability even with limited training data, which enables the LSTM module to output stable and representative local features. LSTM processes long-term dependencies in sequence data, while the self-attention mechanism of Transformer can handle larger relationships, effectively avoiding the problem of gradient vanishing or explosion, and better capturing local patterns and long-time span information of time series data, improving prediction accuracy. The alum dosage prediction model of LSTM-Transformer can more intuitively reflect the running changes of the alum adding system. In addition, the LSTM-Transformer prediction model can dynamically reflect the influence of the settling velocity on the effluent turbidity. With the long-term and short-term memory of LSTM and the self-attention mechanism of Transformer, it can represent the long-term and short-term correlation in time series data, and the model has obvious advantages in fitting complex nonlinear relationships. Practical application results verify the efficiency and accuracy of the LSTM-Transformer prediction model in predicting alum dosage in water treatment plants. The model not only can accurately predict the optimal alum dosage according to historical and real-time water quality data, but also can dynamically adjust with changes in water quality, improving the adaptability and efficiency of the treatment process. By reducing the effluent turbidity, the present application shows significant advantages in ensuring water supply safety and stability, and provides an efficient and reliable technical solution for the operation and management of water treatment plants.
[0194] In order to well obtain various parameters in the alum added water treatment system, various water quality sensors are arranged at the raw water inlet, and a water quality monitoring device is arranged at the outlet of the sedimentation tank. The application realizes real-time collection and analysis of key water quality indexes and treatment process parameters, and uses deep learning technology to intelligently optimize and manage the treatment process. The efficiency and stability of the water treatment process are significantly improved, the dependence on manual operation is reduced, and the evolution of the water treatment field towards intelligence and automation is promoted. Through the implementation of the method of the application, the optimal operation of the water treatment facility under various environmental conditions can be ensured, and the continuity, quality and safety of the water supply can be ensured.
[0195] Example 2
[0196] A computer system comprising a memory, a processor and a computer program stored on the memory, the processor executing the computer program to implement the steps of the method as described in examples 1-3.
[0197] Example 3
[0198] A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method as described in examples 1-3.
[0199] Those skilled in the art will appreciate that embodiments of the application can be provided as methods, systems, or computer program products. Accordingly, the application can be embodied in the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the application can be embodied in the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk memory, CD-ROMs, optical storage media, etc.) having computer usable program code embodied therein.
[0200] The application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems) and computer program products according to embodiments of the application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 An apparatus for performing each flow or a combination of flows and / or blocks Figure 1 An apparatus for performing each flow or a combination of flows and / or blocks
[0201] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the flow Figure 1 The functions of a flow or multiple flows and / or a block or multiple blocks in accordance with the embodiments herein can be implemented as computer program instructions. Figure 1
[0202] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flow Figure 1 The functions of a flow or multiple flows and / or a block or multiple blocks in accordance with the embodiments herein can be implemented as computer program instructions. Figure 1
[0203] The above description is only preferred embodiments of the application. It should be pointed out that for those skilled in the art, some improvements and refinements can be made without departing from the principles of the application, and these improvements and refinements should also be considered as the protection scope of the application.
Claims
1. A method for alum process cascade control in a water treatment plant, characterized by, The method comprises the following steps: Obtain the original operation data and alum flower images from the waterworks, and preprocess the original operation data and alum flower images; Construct a feedforward alum dosage prediction model by using an LSTM-Transformer network prediction model; input the preprocessed original operation data into the pre-trained feedforward alum dosage prediction model to obtain a feedforward alum dosage prediction value at the current time; Segment the shape of the alum flower from the preprocessed alum flower images by using a SAM algorithm, and generate a mask list; Extract the boundary coordinates of the segmented region layer by layer based on the mask list by using an OpenCV contour detection algorithm, calculate the geometric features and physical parameters of the alum flower, and calculate the settling velocity according to the geometric features and physical parameters; Construct a water turbidity prediction model and a settling velocity prediction model by using an LSTM-Transformer network prediction model; the input of the water turbidity prediction model is the settling velocity setpoint calculated by the MPC controller, and the output is the water turbidity prediction value; the input of the settling velocity prediction model is the inlet flow of the sedimentation tank, and the output is the settling velocity prediction value; According to the water turbidity prediction value, calculate the optimal setpoint of the settling velocity by the MPC controller of the main loop, and according to the deviation between the optimal setpoint of the settling velocity and the settling velocity prediction value, control the alum dosage by using a PID controller of the auxiliary loop; Add the alum dosage output by the PID controller of the auxiliary loop to the feedforward alum dosage prediction value to obtain the final alum dosage.
2. The alum process cascade control method for a water plant according to claim 1, characterized by, The preprocessing comprises the following steps: Obtain original operation data with time sequence characteristics; the original operation data comprises raw water turbidity, inlet flow, pH value, ammonia nitrogen content and inlet flow of the sedimentation tank; after cleaning and filtering the obtained original operation data, perform normalization processing; Preprocess the alum flower images by using a SAM algorithm, which comprises the following steps: Perform gray scale conversion on the original BGR alum flower images by using a weighted average method: ; wherein, is the original three-channel image pixel value, is the gray value; After gray scale conversion, perform spatial filtering by using a 5*5 Gaussian kernel; the spatial filtering kernel function is defined as: ; wherein, is a position weight for the coordinate in the Gaussian kernel, is a coordinate offset from the center within the Gaussian kernel, is a standard deviation; Realize adaptive binarization based on the dynamic calculation of the global optimal threshold value by using an OSTU algorithm; the formula is as follows: ; wherein, are foreground / background pixel ratios, respectively, are foreground / background pixel means, respectively, is the within-class mean, is the between-class variance, is the binarization threshold value; Close the holes and smooth the edges of the flocculation by using an opening operation based on a 5*5 rectangular kernel, and then perform erosion and expansion; the formula is as follows: ; Wherein, A is the processed alum flower image, is an opening operation, B is a 5x5 structure matrix element, , respectively represent the erosion and expansion operations; Use the optimized binary expansion on the original image to suppress the non-background and generate a region of interest image.
3. The method of claim 1, wherein the alum process is a coagulation process. In the LSTM-Transformer network prediction model, first, use an LSTM model to encode the input sequence to obtain the local features of the sequence, then transmit the output of the LSTM model to a Transformer model as input to extract the dependent features and the global features of the sequence, and finally perform prediction.
4. The alum process cascade control method for a water plant according to claim 3, characterized by, The structure of the LSTM-Transformer network prediction model comprises: Add a Dropout layer after each LSTM model, and repeat three layers; In the Transformer model, sequentially arrange a multi-head attention layer, a residual connection, a Dropout layer and a full connection layer; Select a ReLU function as the activation function, select an Adam optimizer, and select a suitable window length; Root mean square error (RMSE) is used as the core evaluation index of the length of the sliding window: ; wherein with are the actual and measured values, respectively, is the number of samples.
5. The method for alum process cascade control of a water treatment plant according to claim 1, wherein, The calculation method of the geometric characteristics and physical parameters is as follows: The area integral of a two-dimensional closed region is converted into the boundary line integral by using Green's formula, and the formula is: ; wherein, is the area of a single alite grain, represents the pixel coordinate of the contour boundary point, is the total number of contour points; pixel area accumulation is performed for each segmented region, and finally the total area of the coagulum is obtained ; The continuous boundary is discretized into a combination of horizontal, vertical, or diagonal line segments by using the chain approximation method, and the segment length is accumulated segment by segment: ; wherein, is the length of each segment, is the number of discretized continuous boundary segments; the length is accumulated for each segment to finally obtain the total length of the coagulum ; The irregularly shaped concrete is equivalent to a circular shape with the same area, and a geometric simplification model is established, and the formula is: ; wherein, is the actual area of the profile, is the equivalent diameter of a single alveolus, in units consistent with the pixel size; The closed contours in the binary image are identified by a edge tracking algorithm, each of which is considered as a single individual of the algal bloom, and the number of the algal bloom is recorded as ; The calculation method of the physical parameters and the settling velocity is as follows: Kinematic viscosity : Calculated using VFT equation: ; wherein, D, C are constants, T is the water temperature; The equivalent density of the floc particles is calculated by a non-linear adjustment formula , ; wherein, is the equivalent diameter of the floc; Deduce the mechanical radius by area-perimeter ratio method : ; wherein, is the total area of the coagulum, is the total length of the coagulum, is the number of coagula; Settling velocity The calculation method is as follows: ; wherein is the density of the fluid, is the acceleration due to gravity.
6. The method for alum process cascade control of a water treatment plant according to claim 1, wherein, The objective function of the MPC controller is: ; in, is the effluent turbidity output predicted at step i, is the setting value of step i, is the weight of the control variable, is the manipulated variable weight, It is The control input increment of the step, To predict the horizon, To control the field of view, is the objective function of the MPC controller, k is the time step index; The MPC controller uses the sequential least squares programming algorithm to solve the optimal control sequence, and extracts the first value as the optimal set value of the settling velocity of the secondary loop.
7. The method of claim 6, wherein the alum process is a coagulation process. The formula of the sequential least squares programming algorithm is as follows: ; ; in, is the objective function, is the constraint condition, is the Lagrangian function, is the Lagrange multiplier, is the Lagrangian function in The Hessian matrix at , is the search direction, The objective function is The transpose of the gradient at ; The following constraint conditions are met: ; ; wherein is the gradient of the constraint function at is the equality constraint quantity, is the total constraint quantity, is the function value of the constraint function at . 8. The method of claim 1, wherein the alum process cascade control method is used in a water treatment plant. The prediction value of the water turbidity prediction model is corrected through real-time instrument readings: The deviation between the corrected water turbidity prediction value and the water turbidity set value, and the settling velocity change value obtained by the SLSQP algorithm optimization are included in the objective function of the MPC controller, and the optimal value of the settling velocity at the next time is solved by using the SLSQP algorithm, as the input of the secondary loop; In the secondary loop, the settling velocity is calculated by dividing the alum flower image, the settling velocity prediction value output by the settling velocity prediction model is dynamically corrected according to the calculated settling velocity, and the feedback alum addition amount is calculated by the PID controller.
9. A computer system comprising a memory, a processor and a computer program stored on the memory, characterized in that, The processor executes the computer program to realize the steps of the method as claimed in claims 1-8.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the steps of the method as claimed in claims 1-8.
Citation Information
Patent Citations
Automatic control algorithm for feeding vitriol in tap water by coagulation
CN101556458A
Water plant alum adding control method based on feedforward-feedback composite control
CN111777217A
Coagulant adding cascade control method based on double-stage attention mechanism
CN118426430A
Water plant coagulating sedimentation effect estimation method and system based on alumen ustum target tracking, medium and equipment
CN119580150A
Coagulant addition control method and system in sewage treatment
CN119806071A
Cited By
Water plant raw water quality data fault diagnosis method and system
CN121144761A
