Method and system for on-line monitoring of total nitrogen concentration in biogas slurry
By constructing a multi-parameter fusion partial least squares regression prediction model and combining it with the Bayesian adaptive regularization method, the total nitrogen concentration in biogas slurry can be monitored in real time. This solves the problems of long time consumption, susceptibility to interference, and high cost of traditional detection methods, and achieves efficient and low-cost online monitoring.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHAN ACADEMY OF AGRI SCI
- Filing Date
- 2025-08-13
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies cannot achieve real-time and accurate detection of total nitrogen concentration in biogas slurry. Traditional methods are time-consuming, susceptible to interference, and costly. Existing online monitoring systems have poor dynamic adaptability and cannot meet the real-time monitoring needs of large-scale farms.
By real-time monitoring of dissolved oxygen, turbidity, redox potential, and conductivity, a multi-parameter fusion partial least squares regression prediction model is constructed. Combined with the Bayesian adaptive regularization method, a rapid and low-cost detection of total nitrogen concentration in biogas slurry is achieved.
It improves detection accuracy and stability, reduces operating costs, and enables efficient online monitoring of total nitrogen concentration in biogas slurry, adapting to seasonal fluctuations and time-varying characteristics of biogas slurry composition.
Smart Images

Figure CN120948705B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of environmental monitoring technology, and in particular to an online monitoring method and system for total nitrogen concentration in biogas slurry. Background Technology
[0002] Against the backdrop of intensive and large-scale development in the livestock industry, biogas slurry, as a byproduct of anaerobic fermentation of livestock and poultry waste, is widely used for farmland irrigation due to its rich content of nutrients such as nitrogen, phosphorus, and potassium. Its resource utilization is of great significance for environmental protection and sustainable agricultural development. However, precise control of the total nitrogen concentration in biogas slurry directly affects its ecological and economic value for safe application to the field: excessively high concentrations can easily lead to environmental risks and cause crop burn; excessively low concentrations require increased transportation and application frequency, significantly increasing operating costs. Therefore, real-time and accurate detection of the total nitrogen concentration in biogas slurry is a core technical aspect for optimizing nutrient management and reducing environmental risks.
[0003] Currently, the total nitrogen concentration detection technology and supporting management model still have the following prominent problems: (1) The efficiency and safety of traditional detection methods are in prominent contradiction: the Kjeldahl method requires complex steps such as high-temperature digestion, distillation, and titration, and a single detection takes more than 2 hours. It also involves chemical reagents such as concentrated sulfuric acid, which is difficult to meet the real-time monitoring needs of large-scale farms; (2) The rapid detection technology has insufficient anti-interference ability: electrochemical sensors are easily interfered with by sulfides and heavy metal ions in biogas slurry, resulting in an ammonium nitrogen detection error rate of more than 25%; near-infrared spectroscopy requires repeated calibration for biogas slurry from different sources, and High humidity and suspended matter will significantly reduce the spectral signal-to-noise ratio; (3) Poor dynamic adaptability of online monitoring system: The existing model does not take into account the seasonal fluctuations of biogas slurry composition (such as the reduction of microbial metabolites due to low temperature in winter and the increase of organic nitrogen ratio in summer) and the time variability of microbial metabolites, resulting in long-term monitoring accuracy decay. At the same time, the characteristics of biogas slurry being dark in color and high in turbidity make the detection module susceptible to contamination, requiring frequent cleaning and maintenance; (4) High cost of high-precision multi-parameter fusion equipment: Equipment such as spectrometers need to be calibrated and maintained regularly, and the operation and maintenance costs exceed the affordability of small and medium-sized farms, which restricts the popularization of technology. Summary of the Invention
[0004] To address the problems existing in the prior art, this invention provides an online monitoring method and system for total nitrogen concentration in biogas slurry. By real-time monitoring of dissolved oxygen, turbidity, oxidation-reduction potential (OPR), and conductivity, a multi-parameter fusion partial least squares regression (PLS) prediction model is constructed to achieve rapid and low-cost detection of total nitrogen concentration in biogas slurry.
[0005] This invention provides a method for online monitoring of total nitrogen concentration in biogas slurry, comprising:
[0006] Obtain current characteristic data of biogas slurry, including multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity;
[0007] The current characteristic data of the biogas slurry are input into the least squares regression model to obtain the predicted value of the current total nitrogen concentration of the biogas slurry output by the least squares regression model.
[0008] The least squares regression model is trained by using the characteristic data samples of the biogas slurry as feature variables and the measured total nitrogen concentration of the biogas slurry as the target variable.
[0009] According to the present invention, an online monitoring method for total nitrogen concentration in biogas slurry includes the following training steps for the least squares regression model:
[0010] Initialize the residual matrix of the feature variables based on the feature variables, and initialize the residual matrix of the target variables based on the target variables;
[0011] Calculate the weight vector based on the covariance of the current residual matrix of the feature variable and the current residual matrix of the target variable;
[0012] Calculate the latent variable score based on the weight vector and the current residual matrix of the feature variable;
[0013] Based on the latent variable scores and the current residual matrix of the target variable, the dynamic variance contribution rate is calculated, which is used to characterize the explanatory power of the current latent variable for the total nitrogen concentration.
[0014] The regression strength of each feature variable is adjusted based on the Bayesian adaptive regularization method. The regularization regression coefficient is calculated based on the regression strength, the latent variable score and the current residual matrix of the target variable.
[0015] The current residual matrix of the target variable is updated based on the regularized regression coefficient and the latent variable score, and the current residual matrix of the feature variable is updated based on the latent variable score, until a preset termination condition is met.
[0016] The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model.
[0017] According to the present invention, an online monitoring method for total nitrogen concentration in biogas slurry, before initializing the residual matrix of the characteristic variables according to the characteristic variables and initializing the residual matrix of the target variables according to the target variables, further includes:
[0018] Z-score standardization is performed on the feature variables and the target variable.
[0019] According to the online monitoring method for total nitrogen concentration in biogas slurry provided by the present invention, the regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model, including:
[0020] Based on the regularized regression coefficients, weight vectors, and dynamic variance contribution rate obtained in the last iteration, a regression coefficient matrix is synthesized.
[0021] Based on the regression coefficient matrix, generate a standardized data regression equation;
[0022] The standardized data regression equation is transformed into the original data regression equation by using the mean and standard deviation of the feature variables and the mean and standard deviation of the target variable after Z-score standardization.
[0023] According to the online monitoring method for total nitrogen concentration in biogas slurry provided by the present invention, the formula of the standardized data regression equation is as follows:
[0024] Y = b1X norm1 +b2X norm2 +b3X norm3 +b4X norm4
[0025] Where Y is the standardized target variable, X norm1 To X norm4 These are the standardized feature variables, and b1 to b4 are the regression coefficients of the standardized data.
[0026] The formula for the regression equation of the original data is:
[0027] TN=β0+β1*EC+β2*DO+β3*NTU+β4*OPR
[0028] Wherein, TN, EC, DO, NTU and OPR are the original sensor data of total nitrogen concentration, conductivity, dissolved oxygen, turbidity and redox potential of the biogas slurry, respectively, β0 is the intercept term, and β1 to β4 are the regression coefficients of the original data.
[0029] According to the present invention, an online monitoring method for total nitrogen concentration in biogas slurry adjusts the regression strength of each feature variable using the following formula based on a Bayesian adaptive regularization method:
[0030]
[0031] Where, λ j ω is the regression strength corresponding to the j-th feature variable. (k) It is the weight corresponding to the j-th feature variable in the weight vector obtained in the k-th iteration, t (k)ε is the latent variable score obtained in the k-th iteration, and ε is the preset convergence threshold.
[0032] According to the online monitoring method for total nitrogen concentration in biogas slurry provided by the present invention, the regularized regression coefficient is calculated using the following formula based on the regression strength, the latent variable score, and the current residual matrix of the target variable:
[0033]
[0034] Among them, c (k) The regularized regression coefficients obtained in the k-th iteration are t. (k) Y is the latent variable score obtained in the k-th iteration, where T is the transpose operation. (k-1) λ is the residual matrix of the target variable obtained in the (k-1)th iteration. j It is the regression strength corresponding to the j-th feature variable.
[0035] According to the present invention, an online monitoring method for total nitrogen concentration in biogas slurry updates the current residual matrix of the target variable based on the regularized regression coefficient and the latent variable score using the following formula:
[0036] Y (k) =Y (k-1) -α k ·t (k) c (k)
[0037]
[0038] Among them, Y (k) Y is the residual matrix of the target variable obtained in the k-th iteration. (k-1) Y is the residual matrix of the target variable obtained in the (k-1)th iteration. (i-1) It is the residual matrix of the target variable obtained in the (i-1)th iteration, α k It is the dynamic variance contribution rate obtained in the k-th iteration, t (k) c is the latent variable score obtained in the k-th iteration. (k) The regularized regression coefficients obtained in the k-th iteration are t. (i) is the latent variable score obtained in the i-th iteration, and T is the transpose operation;
[0039] The current residual matrix of the feature variable is updated based on the latent variable score using the following formula:
[0040]
[0041] Among them, X (k) X is the residual matrix of the characteristic variables obtained in the k-th iteration. (k-1)It is the residual matrix of the characteristic variables obtained in the (k-1)th iteration.
[0042] According to the present invention, an online monitoring method for total nitrogen concentration in biogas slurry is provided, wherein the preset termination conditions include the cumulative value of the dynamic variance contribution rate being greater than a first preset threshold, the norm of the residual matrix of the target variable being less than a preset proportion of the standard deviation of the target variable, or the number of latent variables reaching a preset upper limit.
[0043] This invention also provides an online monitoring system for total nitrogen concentration in biogas slurry, comprising:
[0044] The acquisition module is used to acquire the current characteristic data of the biogas slurry, which includes multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity.
[0045] The prediction module is used to input the current characteristic data of the biogas slurry into the least squares regression model to obtain the predicted value of the current total nitrogen concentration of the biogas slurry output by the least squares regression model.
[0046] The least squares regression model is trained by using the characteristic data samples of the biogas slurry as feature variables and the measured total nitrogen concentration of the biogas slurry as the target variable.
[0047] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the online monitoring method for total nitrogen concentration in biogas slurry as described above.
[0048] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the online monitoring method for total nitrogen concentration in biogas slurry as described above.
[0049] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the online monitoring method for total nitrogen concentration in biogas slurry as described above.
[0050] The online monitoring method and system for total nitrogen concentration in biogas slurry provided by this invention overcomes the limitations of traditional single-parameter prediction models by comprehensively considering multiple features among four characteristic variables: dissolved oxygen, turbidity, redox potential, and conductivity, through multi-parameter fusion, thereby improving prediction accuracy and stability. A multi-parameter coupled TN prediction model is constructed using a partial least squares regression algorithm, reducing the dimensionality of high-dimensional sensor data to a latent variable space, effectively solving the multicollinearity problem while retaining key information, ensuring the accuracy and reliability of the model, and achieving efficient online monitoring of TN content in biogas slurry. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0052] Figure 1 This is one of the flowcharts illustrating the online monitoring method for total nitrogen concentration in biogas slurry provided by the present invention;
[0053] Figure 2 This is the second schematic diagram of the online monitoring method for total nitrogen concentration in biogas slurry provided by the present invention;
[0054] Figure 3 This is a schematic diagram of the structure of the online monitoring system for total nitrogen concentration in biogas slurry provided by the present invention. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0056] The following is combined Figure 1 The present invention describes an online monitoring method for total nitrogen concentration in biogas slurry, comprising:
[0057] Step 101: Obtain the current characteristic data of the biogas slurry, including multiple parameters such as dissolved oxygen (DO), turbidity (NTU), oxidation-reduction potential (OPR), and electrical conductivity (EC).
[0058] Step 102: Input the current characteristic data of the biogas slurry into the least squares regression model to obtain the predicted value of the current total nitrogen concentration (TN) of the biogas slurry output by the least squares regression model;
[0059] Step 103: The least squares regression model is obtained by training the model using the feature data samples of the biogas slurry as feature variables and the measured total nitrogen concentration of the biogas slurry as the target variable.
[0060] The sensor module, including an industrial-grade dissolved oxygen sensor, an infrared turbidity sensor, a platinum electrode redox potential sensor, a quadrupole conductivity probe, and a total nitrogen concentration sensor, is used to measure the current characteristic data, characteristic data samples, and total nitrogen concentration of the biogas slurry.
[0061] Signal processing modules, such as STM32 microcontrollers, are used to integrate ADC modules to filter, amplify, and convert the original signals to digital in real time.
[0062] The core module for model computation runs a partial least squares fitting algorithm through an embedded system. It uses a partial least squares regression model trained on historical data as input, multi-parameter sensor data as input, and outputs TN prediction values.
[0063] Experiments show that the determination coefficient R for predicting TN in this embodiment is [missing information]. 2 >0.80, normalized root mean square error (NRMSE) = 0.139 mg / L, which meets the accuracy requirements for industrial monitoring.
[0064] This embodiment overcomes the limitations of traditional single-parameter prediction models by integrating multiple parameters, comprehensively considering various features among dissolved oxygen, turbidity, redox potential, and conductivity. It improves prediction accuracy and stability. By constructing a multi-parameter coupled TN prediction model through partial least squares regression algorithm, the high-dimensional sensor data is reduced to the latent variable space, effectively solving the multicollinearity problem. At the same time, key information is preserved, ensuring the accuracy and reliability of the model and realizing efficient online monitoring of biogas slurry TN content.
[0065] Based on the above embodiments, the training steps of the least squares regression model in this embodiment include:
[0066] Initialize the residual matrix of the feature variables based on the feature variables, and initialize the residual matrix of the target variables based on the target variables;
[0067] Calculate the weight vector based on the covariance of the current residual matrix of the feature variable and the current residual matrix of the target variable;
[0068] Calculate the latent variable score based on the weight vector and the current residual matrix of the feature variable;
[0069] Based on the latent variable scores and the current residual matrix of the target variable, the dynamic variance contribution rate is calculated, which is used to characterize the explanatory power of the current latent variable for the total nitrogen concentration.
[0070] The regression strength of each feature variable is adjusted based on the Bayesian adaptive regularization method. The regularization regression coefficient is calculated based on the regression strength, the latent variable score and the current residual matrix of the target variable.
[0071] The current residual matrix of the target variable is updated based on the regularized regression coefficient and the latent variable score, and the current residual matrix of the feature variable is updated based on the latent variable score, until a preset termination condition is met.
[0072] The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model.
[0073] The core of constructing a partial least squares regression (PLS) algorithm lies in:
[0074] Covariance maximization projection extracts latent variables between feature variables (X:DO, NTU, OPR, EC) and target variable (Y:TN), so that the latent variables preserve the original data features while maximizing the covariance explanatory power of the two.
[0075] Dimensionality reduction and redundancy removal eliminate multicollinearity interference and improve model generalization by projecting high-dimensional sensor data into a low-dimensional latent variable space.
[0076] Iterative parameter optimization, driven by residual matrix updates, iteratively calculates weight vectors, score vectors, and regression coefficients until the preset number of iterations or residual convergence threshold is met, ensuring that the model dynamically adapts to data changes.
[0077] The TN prediction method is based on the partial least squares regression (PLS) algorithm. It constructs a multi-parameter fusion prediction model through latent variable extraction and residual iterative optimization, specifically including the following steps:
[0078] Sample collection and parameter determination: biogas slurry samples were collected, and characteristic parameters such as conductivity, dissolved oxygen, turbidity and redox potential were measured simultaneously using multi-parameter sensors. The TN reference value of the corresponding sample was determined using standard methods.
[0079] Data preprocessing involves using the Z-score standardization method to normalize the raw sensor data, eliminating the dimensional differences between DO, NTU, OPR, and EC. The standardized parameters are then integrated into a multidimensional feature vector to construct a sample dataset. The standardized data is stored, and a mapping relationship between the feature matrix X and the target variable Y is established.
[0080] Initialize the model PLS(Y,X,n_components,bias), where Y is the target variable (TN), X is the feature variable (dissolved oxygen, turbidity, redox potential, conductivity), n_components is the initial number of latent variables, bias is whether to include a bias term, and the initial residual matrix is the standardized feature matrix.
[0081] In the latent variable extraction stage, the covariance weight vector is first calculated based on the standardized feature variable X and the target variable Y. Then, the regularization strength λ of each parameter is dynamically adjusted using the Bayesian adaptive regularization method. j To suppress the interference of multiple common linearity, the weight vector is then multiplied by the current residual matrix to generate the latent variable score vector t, and the dynamic variance contribution weight α is calculated. kThis is to quantify the explanatory power of the latent variable for TN. The feature residual matrix and target residual are updated synchronously after each iteration, and the iteration continues until the termination condition is met.
[0082] Model synthesis integrates the regression coefficients corresponding to each latent variable to generate the final predictive model. The formula applicable to standardized data is Y = b1X. norm1 +b2X norm2 +b3X norm3 +b4X norm4 The formula applicable to the original data is TN=β0+β1*EC+β2*DO+β3*NTU+β4*OPR;
[0083] Real-time prediction and output: Input newly collected standardized sensor data into the trained PLS model, select the prediction mode as standard prediction or iterative prediction according to the centralization flag, calculate the latent variable score and weighted regression coefficient, restore the predicted value through inverse standardization, output the TN concentration and dynamically display it on the terminal interface.
[0084] Initialize the residual matrix, set the initial number of iterations k=1, and input the preset number of latent variables n_components and the convergence threshold ε. Start the iterative calculation. The iterative process includes:
[0085] (a) Calculate the weight vector: based on the current residual matrix X (k-1) With Y (k-1) The covariance is normalized to generate the weight vector ω. (k) ;
[0086] (b) Calculate the latent variable score vector t (k) and its dynamic variance contribution rate α (k) Quantify the explanatory power of current latent variables on changes in TN;
[0087] (c) Bayesian adaptive regularization: Based on the L2 norm of the historical latent variable score vector and the orthogonality of the weight vector, the regularization parameter λ of the regression coefficient is dynamically adjusted. j ;
[0088] (d) Synchronously update feature residuals X (k) and target residual Y (k) .
[0089] After synthesizing the regression coefficient matrix, the model was validated using a test dataset, and the results were analyzed using the normalized root mean square error (NRMSE) and the coefficient of determination (R²). 2 Evaluate the model's predictive accuracy;
[0090] Input EC, DO, NTU, and OPR data of a new biogas slurry sample, and output the TN predicted value based on the trained partial least squares regression model.
[0091] In this embodiment, Bayesian adaptive regularization is achieved by dynamically adjusting the parameter λ. j Suppressing collinearity interference of sensor parameters, λ j The method is inversely correlated with the fluctuation intensity of the historical score vector of latent variables; the residual matrix update adopts a dual update mechanism to simultaneously eliminate explained variance in the feature space and the target space; during model training, the number of latent variables n_components can be dynamically optimized through cross-validation to improve generalization ability. The method is integrated into an online monitoring system, which collects biogas slurry characteristic variable data in real time through sensors, performs TN prediction calculations simultaneously, and generates dynamic monitoring reports and visualization charts.
[0092] Based on the above embodiments, this embodiment further includes the following step before initializing the residual matrix of the feature variables according to the feature variables and initializing the residual matrix of the target variables according to the target variables:
[0093] Z-score standardization is performed on the feature variables and the target variable.
[0094] Samples of biogas slurry were collected and their target variable TN and characteristic variables EC, DO, NTU, and OPR were measured. After storing the target variable and characteristic variable data, they were preprocessed using the Z-score standardization method.
[0095] Based on the above embodiments, this embodiment integrates the regularized regression coefficients obtained from the last iteration to obtain the final least squares regression model, including:
[0096] Based on the regularized regression coefficients, weight vectors, and dynamic variance contribution rate obtained in the last iteration, a regression coefficient matrix is synthesized.
[0097] Based on the regression coefficient matrix, generate a standardized data regression equation;
[0098] The standardized data regression equation is transformed into the original data regression equation by using the mean and standard deviation of the feature variables and the mean and standard deviation of the target variable after Z-score standardization.
[0099] Based on the above embodiments, the formula for the standardized data regression equation in this embodiment is:
[0100] Y = b1X norm1 +b2X norm2 +b3X norm3 +b4X norm4
[0101] Where Y is the standardized target variable, X norm1 To X norm4These are the standardized feature variables, and b1 to b4 are the regression coefficients of the standardized data.
[0102] The formula for the regression equation of the original data is:
[0103] TN=β0+β1*EC+β2*DO+β3*NTU+β4*OPR
[0104] Wherein, TN, EC, DO, NTU and OPR are the original sensor data of total nitrogen concentration, conductivity, dissolved oxygen, turbidity and redox potential of the biogas slurry, respectively, β0 is the intercept term, and β1 to β4 are the regression coefficients of the original data.
[0105] Based on the above embodiments, this embodiment adjusts the regression strength of each feature variable using the Bayesian adaptive regularization method according to the following formula:
[0106]
[0107] Where, λ j ω is the regression strength corresponding to the j-th feature variable. (k) It is the weight corresponding to the j-th feature variable in the weight vector obtained in the k-th iteration, t (k) ε is the latent variable score obtained in the k-th iteration, and ε is the preset convergence threshold.
[0108] Based on the above embodiments, this embodiment calculates the regularized regression coefficients using the following formula, based on the regression strength, the latent variable scores, and the current residual matrix of the target variable:
[0109]
[0110] Among them, c (k) The regularized regression coefficients obtained in the k-th iteration are t. (k) Y is the latent variable score obtained in the k-th iteration, where T is the transpose operation. (k-1) λ is the residual matrix of the target variable obtained in the (k-1)th iteration. j It is the regression strength corresponding to the j-th feature variable.
[0111] Based on the above embodiments, this embodiment updates the current residual matrix of the target variable according to the regularized regression coefficient and the latent variable score using the following formula:
[0112] Y (k) =Y (k-1) -α k ·t (k) c (k)
[0113]
[0114] Among them, Y (k) Y is the residual matrix of the target variable obtained in the k-th iteration. (k-1) Y is the residual matrix of the target variable obtained in the (k-1)th iteration. (i-1) It is the residual matrix of the target variable obtained in the (i-1)th iteration, α k It is the dynamic variance contribution rate obtained in the k-th iteration, t (k) c is the latent variable score obtained in the k-th iteration. (k) The regularized regression coefficients obtained in the k-th iteration are t. (i) is the latent variable score obtained in the i-th iteration, and T is the transpose operation;
[0115] The current residual matrix of the feature variable is updated based on the latent variable score using the following formula:
[0116]
[0117] Among them, X (k) X is the residual matrix of the characteristic variables obtained in the k-th iteration. (k-1) It is the residual matrix of the characteristic variables obtained in the (k-1)th iteration.
[0118] Based on the above embodiments, the preset termination conditions in this embodiment include the cumulative value of the dynamic variance contribution rate being greater than a first preset threshold, the norm of the residual matrix of the target variable being less than a preset proportion of the standard deviation of the target variable, or the number of latent variables reaching a preset upper limit.
[0119] Termination condition determination: Iteration stops when any of the following conditions are met:
[0120] (a) Cumulative Explanation Rate Σα k >95%;
[0121] (b) The norm of the target residual matrix decreases to below 1% of the initial value;
[0122] (c) The maximum number of latent variables n_components is reached = 5.
[0123] Figure 2 A preferred embodiment of the online monitoring method for TN content in biogas slurry according to the present invention includes the following steps:
[0124] F1: Collect N sets of biogas slurry samples. Collect N sets of biogas slurry samples regularly from monitoring points such as the outlet of the biogas slurry treatment pond to ensure that the samples are representative and can cover the state of biogas slurry under different time and different composition changes.
[0125] F2: Measure the target variable and characteristic variables. Measure the target variable TN concentration and four characteristic variables for each biogas slurry sample in step F1. The four characteristic variables include dissolved oxygen (DO), turbidity (NTU), oxidation-reduction potential (OPR), and conductivity (EC).
[0126] F3: Data storage and preliminary inspection. The measured TN concentration and characteristic variable data are stored in tabular form, such as an Excel file, and a preliminary inspection is performed to remove outliers and erroneous data.
[0127] F4: Perform Z-score normalization on the target variable TN concentration Y and the characteristic variables dissolved oxygen X1, turbidity X2, redox potential X3, and conductivity X4 respectively. The normalization formula is as follows: Where μ represents homogeneity and σ represents standard deviation;
[0128] F5: Set the standardized matrix obtained in step F4 as X. norm ∈R N×4 Y norm ∈R N×4 The partial least squares algorithm was used to train the model;
[0129] F6: Based on X (0) =X norm Y (0) =Y norm Initialize the residual matrix to provide initial data for subsequent latent variable extraction and model training;
[0130] F7: Set the maximum number of latent variables n_components = 5, and the convergence threshold ε = 10. -6 .
[0131] F8: Based on F7, latent variables are extracted iteratively. Taking the k-th iteration as an example: According to the formula... Calculate the weight vector ω (k) And extract the latent variable score t (k) =X (k-1) ω (k) ;
[0132] F9: According to the formula Calculate the dynamic variance contribution weights to characterize the explanatory power of the current latent variables for TN;
[0133] F10: Bayesian Adaptive Regularization: Automatically adjusts regression strength based on historical data fluctuations. And calculate the regularized regression coefficients.
[0134] F11: Update the dual residual matrix: eigenresiduals Target residual Y (k) =Y (k-1)-α k ·t (k) c (k) ;
[0135] F12: Determine if the conditions for early termination are met: ① Cumulative explanatory power ∑α k >95%; ② Residual norm ||Y (k) || F <0.01σ Y ③ If the upper limit of n_components is reached, stop if one of the above conditions is met; otherwise, continue the loop.
[0136] F13: After the loop ends, follow the formula. The composite regression coefficient matrix B, where W K =[ω (1) ,ω (2) ,...,ω (K) [C] is a 4×K dimensional weight matrix. K =[c (1) ,c (2) ,...,c (K) [] is a 1×K dimensional regression coefficient vector, and diag(α) is the diagonal element representing the contribution rate α of the dynamic variance. k A K×K dimensional diagonal matrix;
[0137] F14: Generate the standardized data regression equation Y = b1X norm1 +b2X norm2 +b3X norm3 +b4X norm4 Where Y is the standardized TN concentration, and X... norm1 ~X norm4 These are the standardized feature variables, and b1 to b4 are the regression coefficients. In this example, the regression equation for the standardized data is:
[0138] Y = 0.4782 * X norm1 +0.0818*X norm2 +0.4334*X norm3 -0.1596*X norm4 ;
[0139] F15: Generate the original data regression equation. Using the mean and standard deviation from the F4 standardization process, transform the regression equation into the original form TN = β0 + β1*EC + β2*DO + β3*NTU + β4*OPR, where β0 is the intercept term, calculated from the mean and regression coefficients according to the formula. Inverse standardization yields the regression coefficients of the original data, β1 to β4, obtained from the B vector and standard deviation using the formula... Inverse standardization yields the following regression equation for the original data in this example:
[0140] TN=108.79+0.0644*EC+19.3465*DO+0.1502*NTU-0.3431*OPR.
[0141] F16: Check the robustness of the model using an error distribution plot, using R. 2 R and NRMSE are used to evaluate the explanatory power of the model: if the error distribution follows a normal distribution, it indicates that the model has good robustness; 2 If the NRMSE is between 0.7 and 1.0 and < 0.15, the model has been successfully trained and has strong predictive ability, making it suitable for practical predictions. Otherwise, it indicates weak predictive ability, requiring a return to step F3 to eliminate outliers and retrain the model. In this example, R... 2 =0.8034, verifying the strong fitting ability of multi-parameter fusion and PLS algorithm for complex components of biogas slurry; NRMSE=0.139, which is lower than the relative error threshold allowed by TN detectors in industrial standards, indicating that the overall prediction deviation of the model is controllable and meets the requirements of online monitoring.
[0142] F17: Input the real-time collected biogas slurry characteristic parameters into the optimized PLSR model, output the TN prediction value, and trigger the system early warning in combination with the preset pollution threshold to realize the dynamic monitoring of TN content in biogas slurry.
[0143] This embodiment employs a dynamic robustness enhancement mechanism and residual-driven iteration, enabling the model to dynamically update and automatically adjust parameters based on real-time data. It also introduces an adaptive regularization mechanism to effectively suppress mutual interference between sensor parameters, adapt to seasonal fluctuations and time-varying characteristics of biogas slurry components, and ensure long-term monitoring accuracy.
[0144] This method eliminates the need for complex chemical analysis, reducing detection costs and offering strong real-time performance. It controls the iteration process based on dynamic variance contribution rate, automatically terminating redundant calculations while ensuring model interpretability. Detection time is reduced to the second level. Experiments show that the regression coefficient matrix B is a 4×1 floating-point vector with a total storage space of only 16 bytes, perfectly adapting to the memory limitations of embedded systems. It can achieve second-level prediction with only 5 types of sensor data, significantly improving detection efficiency.
[0145] The online monitoring system for total nitrogen concentration in biogas slurry provided by the present invention is described below. The online monitoring system for total nitrogen concentration in biogas slurry described below can be referred to in correspondence with the online monitoring method for total nitrogen concentration in biogas slurry described above.
[0146] like Figure 3 As shown, the system includes an acquisition module 301 and a prediction module 302, wherein:
[0147] The acquisition module 301 is used to acquire the current characteristic data of the biogas slurry, which includes multiple features such as dissolved oxygen, turbidity, redox potential and conductivity.
[0148] The prediction module 302 is used to input the current characteristic data of the biogas slurry into the least squares regression model to obtain the predicted value of the current total nitrogen concentration of the biogas slurry output by the least squares regression model;
[0149] The least squares regression model is trained by using the characteristic data samples of the biogas slurry as feature variables and the measured total nitrogen concentration of the biogas slurry as the target variable.
[0150] This embodiment overcomes the limitations of traditional single-parameter prediction models by integrating multiple parameters, comprehensively considering various features among dissolved oxygen, turbidity, redox potential, and conductivity. It improves prediction accuracy and stability. By constructing a multi-parameter coupled TN prediction model through partial least squares regression algorithm, the high-dimensional sensor data is reduced to the latent variable space, effectively solving the multicollinearity problem. At the same time, key information is preserved, ensuring the accuracy and reliability of the model and realizing efficient online monitoring of biogas slurry TN content.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for online monitoring of total nitrogen concentration in biogas slurry, characterized in that, include: Obtain current characteristic data of biogas slurry, including multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity; The current characteristic data of the biogas slurry are input into the least squares regression model to obtain the predicted value of the current total nitrogen concentration of the biogas slurry output by the least squares regression model. The least squares regression model is obtained by training the model using the feature data samples of the biogas slurry as feature variables and the measured total nitrogen concentration of the biogas slurry as the target variable. The training steps for the least squares regression model include: Initialize the residual matrix of the feature variables based on the feature variables, and initialize the residual matrix of the target variables based on the target variables; Calculate the weight vector based on the covariance of the current residual matrix of the feature variable and the current residual matrix of the target variable; Calculate the latent variable score based on the weight vector and the current residual matrix of the feature variable; Based on the latent variable scores and the current residual matrix of the target variable, the dynamic variance contribution rate is calculated, which is used to characterize the explanatory power of the current latent variable for the total nitrogen concentration. The regression strength of each feature variable is adjusted based on the Bayesian adaptive regularization method. The regularization regression coefficient is calculated based on the regression strength, the latent variable score and the current residual matrix of the target variable. The current residual matrix of the target variable is updated based on the regularized regression coefficient and the latent variable score, and the current residual matrix of the feature variable is updated based on the latent variable score, until a preset termination condition is met. The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model.
2. The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 1, characterized in that, Before initializing the residual matrix of the feature variables based on the feature variables, and before initializing the residual matrix of the target variables based on the target variables, the method further includes: Z-score standardization is performed on the feature variables and the target variable.
3. The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 2, characterized in that, The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model, including: Based on the regularized regression coefficients, weight vectors, and dynamic variance contribution rate obtained in the last iteration, a regression coefficient matrix is synthesized. Based on the regression coefficient matrix, generate a standardized data regression equation; The standardized data regression equation is transformed into the original data regression equation by using the mean and standard deviation of the feature variables and the mean and standard deviation of the target variable after Z-score standardization.
4. The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 3, characterized in that, The formula for the standardized data regression equation is: ; Where Y is the standardized target variable. to These are the standardized feature variables, and b1 to b4 are the regression coefficients of the standardized data. The formula for the regression equation of the original data is: ; Among them, TN, EC, DO, NTU, and OPR are the raw sensor data for the total nitrogen concentration, conductivity, dissolved oxygen, turbidity, and redox potential of the biogas slurry, respectively. It is the intercept term. to These are the regression coefficients of the original data.
5. The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 1, characterized in that, The regression strength of each feature variable is adjusted using the Bayesian adaptive regularization method based on the following formula: ; Where, λ j It is the regression strength corresponding to the j-th feature variable. It is the weight corresponding to the j-th feature variable in the weight vector obtained in the k-th iteration, t (k) is the latent variable score obtained in the k-th iteration, and ɛ is the preset convergence threshold.
6. The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 1, characterized in that, The regularized regression coefficients are calculated using the following formula based on the regression strength, the latent variable scores, and the current residual matrix of the target variable: ; Among them, c (k) The regularized regression coefficients obtained in the k-th iteration are t. (k) Y is the latent variable score obtained in the k-th iteration, where T is the transpose operation. (k-1) λ is the residual matrix of the target variable obtained in the (k-1)th iteration. j It is the regression strength corresponding to the j-th feature variable.
7. The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 1, characterized in that, The current residual matrix of the target variable is updated using the following formula based on the regularized regression coefficients and the latent variable scores: ; ; Among them, Y (k) Y is the residual matrix of the target variable obtained in the k-th iteration. (k-1) Y is the residual matrix of the target variable obtained in the (k-1)th iteration. (i-1) It is the residual matrix of the target variable obtained in the (i-1)th iteration, α k It is the dynamic variance contribution rate obtained in the k-th iteration, t (k) c is the latent variable score obtained in the k-th iteration. (k) The regularized regression coefficients obtained in the k-th iteration are t. (i) is the latent variable score obtained in the i-th iteration, and T is the transpose operation; The current residual matrix of the feature variable is updated based on the latent variable score using the following formula: ; Among them, X (k) X is the residual matrix of the characteristic variables obtained in the k-th iteration. (k-1) It is the residual matrix of the characteristic variables obtained in the (k-1)th iteration.
8. The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 1, characterized in that, The preset termination conditions include the cumulative value of the dynamic variance contribution rate being greater than a first preset threshold, the norm of the residual matrix of the target variable being less than a preset proportion of the standard deviation of the target variable, or the number of latent variables reaching a preset upper limit.
9. An online monitoring system for total nitrogen concentration in biogas slurry, characterized in that, The method for online monitoring of total nitrogen concentration in biogas slurry according to claim 1 includes: The acquisition module is used to acquire the current characteristic data of the biogas slurry, which includes multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity. The prediction module is used to input the current characteristic data of the biogas slurry into the least squares regression model to obtain the predicted value of the current total nitrogen concentration of the biogas slurry output by the least squares regression model. The least squares regression model is trained by using the characteristic data samples of the biogas slurry as feature variables and the measured total nitrogen concentration of the biogas slurry as the target variable.
Citation Information
Patent Citations
Aquaculture dissolved oxygen concentration online forecasting method and system
CN102183621A
Partial least squares-based Gaussian regression soft measurement modeling method
CN108197380A