Ammonia online monitoring method based on microbial electrochemical sensor

CN122612698APending Publication Date: 2026-08-21贵州省山地资源研究所
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610896248.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-22
Publication Date
2026-08-21

AI Technical Summary

Technical Problem

[0005]针对现有技术的不足,本发明提供了基于微生物电化学传感器的水氨在线监测方法,解决了现有微生物传感器监测水质毒性时电信号易受环境波动干扰、毒性类型难以区分以及生物膜遭受重度抑制时难以在线恢复的问题

Benefits of technology

1、本发明通过在滑动时间窗口内计算电流序列的方差来确认基线,并利用多项式拟合求导提取电流变化的速率与加速度。避免了直接差分计算带来的滞后误差,滤除了水体流速变化引起的局部信号抖动。结合电流变化速率与加速度的零交叉状态来控制底液的重新导入,降低了环境背景波动对进样周期的干扰,使监测系统的状态切换更加稳定。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122612698A_ABST
    Figure CN122612698A_ABST
Patent Text Reader

Abstract

The present application relates to water quality environmental monitoring technical field, disclose a kind of water ammonia online monitoring method based on microorganism electrochemical sensor, including recording baseline when current sequence variance is below threshold;After introducing water sample to be measured, extract current rate of change and acceleration, control flow control network to reimport bottom liquid when zero-crossing state occurs;Two-dimensional phase space hysteresis loop containing standardization current and current rate of change is constructed, and ammonia concentration is calculated according to the envelope area and extreme characteristics of the loop;The spatial offset distance of phase trajectory deviating from steady-state benchmark is calculated, and when the distance is over limit, the set working potential is applied to control potentiostat to promote biofilm detachment.The present application uses fitting derivation to filter signal jitter, reduces the cross interference of different toxicity by multi-dimensional evaluation of phase space, and uses potential switching to accelerate the online recovery of biofilm under severe inhibition, improves the accuracy and persistence of water ammonia online monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of water quality environmental monitoring technology, specifically to a method for online monitoring of ammonia in water based on a microbial electrochemical sensor. Background Technology

[0002] With increasingly stringent requirements for water environmental protection, online continuous monitoring of pollutants such as ammonia in water bodies has become increasingly important. Microbial electrochemical sensors utilize the current generated by the metabolism of organic matter on the electroactive biofilm on the anode surface. When substances with inhibitory effects, such as ammonia, are present in the water, the metabolic activity of microorganisms is interfered with, leading to a decrease in the output current signal. By analyzing this current change process, online assessment of characteristic pollutants in water bodies can be achieved.

[0003] Existing microbial electrochemical sensors suffer from limited monitoring accuracy and insufficient operational stability in practical water applications. In complex aquatic environments, fluctuations in injection flow rate, temperature changes, and minute differences in the composition of the base solution can all cause random fluctuations in the background current signal. Traditional monitoring procedures typically rely on set absolute current thresholds or simple subtraction of adjacent data to determine the timing of injection and extract characteristic baselines. This method, which depends on a single absolute value jump, is highly sensitive to background noise, easily generating false triggers, leading to inaccurate baseline recordings, and consequently affecting subsequent concentration conversions.

[0004] Meanwhile, since various toxic substances can inhibit biofilm metabolism, the decrease in current output by the sensor only reflects the final manifestation of inhibition. In actual water samples, there are often interference sources such as heavy metals and organic toxins. Current technologies mainly rely on the decrease in current signal to estimate ammonia concentration, lacking multi-dimensional feature extraction of dynamic processes such as signal attenuation and recovery. This approach struggles to distinguish between ammonia-induced biochemical inhibition and inhibition caused by other toxic substances, and is prone to feature cross-coupling when encountering complex water quality shocks, leading to deviations in ammonia concentration monitoring results. Furthermore, when the monitoring system continuously samples or encounters high-concentration water sample shocks, the biofilm attached to the electrode surface becomes deeply stagnant. Existing monitoring systems, when encountering such severe inhibition, mostly rely on the flow control network to switch to the bottom liquid for prolonged natural flushing. Because pollutants have a certain degree of penetration and residue within the biofilm, simple physical fluid replacement is inefficient, and the natural recovery of electroactive bacteria is very slow. Passive waiting not only prolongs the system's downtime blind zone but also leads to the permanent inactivation of some biofilm, failing to meet the requirements of continuous, high-frequency online monitoring. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides an online monitoring method for ammonia in water based on a microbial electrochemical sensor. This method solves the problems of existing microbial sensors being susceptible to interference from environmental fluctuations when monitoring water toxicity, difficulty in distinguishing toxicity types, and difficulty in online recovery when biofilms are severely inhibited.

[0006] To achieve the above objectives, the present invention provides the following technical solution: The first aspect of this invention provides a method for online monitoring of ammonia in water based on a microbial electrochemical sensor, applied to a system including a reaction tank, a controller, a flow control network comprising valve groups, a bottom liquid pipeline and a water sample pipeline, a potentiostat and a host computer, comprising the following steps: A potentiostat applies an initial working potential to the working electrode of the anode in the reaction tank, a bottom liquid pipeline introduces bottom liquid, and the host computer records the baseline current when the variance of the current sequence is lower than the fluctuation threshold. Switch to the water sample pipeline to introduce the water sample to be tested. The host computer acquires the current sequence and extracts the current change acceleration. When a zero crossover occurs, it controls the flow control network to re-introduce the bottom liquid. The host computer establishes a two-dimensional phase space hysteresis loop and calculates the ammonia concentration based on the envelope area of ​​the two-dimensional phase space hysteresis loop when determining the occurrence of ammonia inhibition. The host computer calculates the spatial offset distance between the two-dimensional phase space hysteresis loop coordinates and the baseline current coordinates. When the spatial offset distance exceeds the preset conditions, the potentiostat applies the set working potential and restores the initial working potential when it is below the closing threshold.

[0007] Preferably, the host computer records the baseline current when the variance of the current sequence is below the fluctuation threshold, including: Obtain a continuous current sequence and construct a sliding time window in memory; The time shift of the latest sampling point within the sliding time window is defined as the local time coordinate origin, and the variance of the sampling points retained within the sliding time window is calculated as the variance of the current sequence. When the duration for which the variance of the current sequence is continuously monitored to be lower than the preset fluctuation threshold reaches the preset stable time threshold, the average value of the sampling points within the current sliding time window is extracted as the baseline current, the internal operating status flag is reset, and the system enters the monitoring standby state.

[0008] By combining data dispersion with time-based judgment logic, a stable reference benchmark for biochemical reactions can be established instead of monitoring single absolute numerical jumps.

[0009] Preferably, the extraction of current change acceleration includes: A continuous polynomial equation is constructed by fitting the sample points cached within the sliding time window using the least squares algorithm. Perform differentiation on the continuous polynomial equation, taking the first derivative at the local time coordinate origin as the rate of change of current at the current physical moment, and the second derivative at the local time coordinate origin as the acceleration of the change of current at the current physical moment.

[0010] The processing based on direct mapping of algebraic coefficients to physical time derivatives avoids the time lag error caused by conventional data difference calculations and filters out high-frequency signal jitter caused by the fluid environment.

[0011] Preferably, controlling the flow control network to reintroduce the base fluid when a zero-crossing state occurs includes: When the host computer detects that the absolute value of the current change rate is less than the zero-crossing threshold for several consecutive sampling cycles and the current change acceleration remains positive, it determines that a zero-crossing state has occurred. A timeout-forced reversal mechanism is introduced. When the preset maximum allowable injection time is reached, the controller controls the flow control network to reintroduce the base fluid and records the extreme current. Continuous differentiation is used to calculate and locate the extreme state of the signal under external toxicity perturbations.

[0012] Preferably, establishing a two-dimensional phase space hysteresis loop includes: The baseline current is used as a reference to calculate the standardized current at each sampling time. A phase space mapping relationship is constructed with the standardized current as the horizontal axis coordinate and the current change rate as the vertical axis coordinate. The phase space mapping relationship forms a set of phase trajectory points in the two-dimensional coordinate system and is connected to form a two-dimensional phase space hysteresis loop. When the elapsed time after the reintroduction of the base fluid reaches the preset maximum recovery period and the Euclidean distance between the end point and the starting point of the phase trajectory point set is greater than or equal to the preset closure tolerance, the two-dimensional phase space hysteresis loop is forcibly closed by constructing a linear interpolation line segment between the end point and the starting point.

[0013] Preferably, the determination of initiating ammonia inhibition includes: The minimum value of the horizontal axis coordinate in the phase trajectory point set is taken as the maximum suppression depth, the minimum value of the vertical axis coordinate in the phase trajectory point set is taken as the maximum suppression rate, and the maximum value of the vertical axis coordinate in the phase trajectory point set is taken as the maximum recovery rate. The envelope area is obtained by performing area calculation on a closed two-dimensional phase space hysteresis loop using the polygon area theorem. The characteristic index is calculated based on the numerical relationship between the maximum inhibition rate, maximum recovery rate, maximum inhibition depth, and envelope area. The characteristic index is compared with a preset judgment interval; if the characteristic index falls within the preset judgment interval, ammonia inhibition is determined. Multidimensional extreme parameters and integral parameters jointly generate a dimensionless evaluation system to distinguish the characteristics of various biochemical toxicity responses and reduce cross-coupling interference.

[0014] Preferably, the calculation of ammonia concentration includes: A pre-defined polynomial regression equation is used in memory as a concentration mapping model. The ammonia concentration is obtained by substituting the envelope area into the polynomial regression equation. When the ammonia concentration exceeds the preset environmental safety benchmark value, the abnormal warning logic is triggered and a message containing the ammonia concentration is generated. The message is uploaded to the remote monitoring center through the communication interface, and the message is reported at the set cycle within the set alarm dead zone time of the same exceedance event.

[0015] Preferably, the process of calculating the spatial offset distance includes: Extract the standardized current and current change rate at the current moment, calculate the transient deviation component from the steady-state reference point at the current moment, where the standardized current at the steady-state reference point approaches 1 and the current change rate approaches 0; The spatial offset distance is obtained by weighting the values ​​of the standardized current and the rate of change of current deviating from the steady-state reference point using weighting coefficients. The weighting coefficients are assigned based on the reciprocal of the variance of the standardized current and the rate of change of current during the historical non-toxic water sample operation cycle. An exponential moving average algorithm is used to smooth the spatial offset distance to obtain a smoothed distance parameter, which is then used as the basis for determining whether a preset blocking threshold has been exceeded. Multiple state parameters are fused and smoothed in the time domain to reduce false triggering caused by local signal pulses in state determination.

[0016] Preferably, applying the set operating potential includes: When the smoothing distance parameter exceeds the preset hindrance critical threshold and the duration exceeds the preset tolerance time window, it is determined that the biofilm on the surface of the anode working electrode has encountered deep hindrance and sends a potential jump command to the potentiostat. The potentiostat responds to the potential jump command and switches the working potential of the anode working electrode to the set working potential. The set working potential is an alternating pulse potential or a desorption potential whose amplitude is positively offset from the initial working potential by a preset voltage value. If, after multiple repeated interventions and the cumulative number of retries reaches the maximum number of intervention retry attempts, the smoothing distance parameter does not fall below the preset stagnation threshold, an isolation command is issued to control the potentiostat to cut off the polarization output, creating an open circuit. The controller then controls the flow control network to lock the valve assembly in the bottom liquid pipeline conduction position. The adjusted polarization potential at the electrode interface promotes the desorption of toxic deposits from the cell membrane surface, allowing severely inhibited electroactive bacterial flora to regain activity online.

[0017] Preferably, after restoring the initial operating potential, the method further includes: When the smoothing distance parameter continuously falls back to the preset steady-state convergence tolerance band and the current change rate remains near zero within the preset time window, it is determined that the two-dimensional phase space hysteresis loop has formed a complete geometric closure. After the complete geometric closure of the two-dimensional phase space hysteresis loop, the feature parameters extracted in the current detection cycle are encapsulated into a data file and archived. Execute the reset command, and control the flow control network to switch to flushing mode through the controller to replace the residual water sample inside the pipeline with the bottom liquid, and simultaneously clear the set of phase trajectory points residing in memory and reset the spatial offset distance.

[0018] This invention provides a method for online monitoring of ammonia in water based on a microbial electrochemical sensor. It has the following beneficial effects: 1. This invention establishes a baseline by calculating the variance of the current sequence within a sliding time window and extracts the rate and acceleration of current change using polynomial fitting and differentiation. This avoids the hysteresis error caused by direct difference calculations and filters out local signal fluctuations caused by changes in water flow velocity. By combining the zero-crossing state of the current change rate and acceleration to control the reintroduction of the bottom fluid, the interference of environmental background fluctuations on the sampling cycle is reduced, making the state switching of the monitoring system more stable.

[0019] 2. This invention constructs a two-dimensional phase-space hysteresis loop with standardized current as the horizontal axis and current change rate as the vertical axis, and calculates characteristic indices using the maximum inhibition depth, inhibition rate, and envelope area of ​​this loop. This transforms traditional single-current amplitude monitoring into a multi-dimensional dynamic process assessment, enabling the differentiation between ammonia-induced inhibition and inhibition caused by other water toxins based on the dynamic trajectory of biochemical reactions. This reduces cross-interference when different toxic substances are superimposed, and improves the accuracy of ammonia concentration conversion.

[0020] 3. This invention assesses the degree of biofilm inhibition by calculating the spatial offset distance of the phase trajectory point from the steady-state reference. When the offset distance exceeds a preset condition, the potentiostat is controlled to actively apply a set desorption potential or pulse potential to the working electrode. When the sensor is subjected to a high-concentration water sample impact, causing the biofilm to become deeply blocked, the forced switching of the working potential promotes the desorption of toxic deposits at the electrode interface, accelerates the recovery of electroactive bacteria activity, and reduces the downtime recovery time after the system is severely contaminated. Attached Figure Description

[0021] Figure 1 This is a system architecture diagram of the present invention; Figure 2 This is a flowchart of the method of the present invention; Figure 3 This is a schematic diagram illustrating the principle of two-dimensional phase space mapping and loop closure construction of the present invention. Figure 4 This is a schematic diagram illustrating the principle of extreme value parameter extraction and envelope area integration in this invention. Figure 5 This is a schematic diagram illustrating the principle of characteristic index decoupling and ammonia concentration mapping in this invention. Figure 6This is the normalized current evolution timing diagram of the present invention; Figure 7 This is a timing diagram showing the evolution of the current change rate in this invention.

[0022] The components include: 1. Reaction tank; 2. Controller; 3. Potentiostat; 4. Host computer; 5. Valve assembly; 6. Bottom liquid pipeline; and 7. Water sample pipeline. Detailed Implementation

[0023] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] See attached document Figure 1 The present invention provides an online monitoring system for ammonia in water based on a microbial electrochemical sensor, comprising a reaction tank 1, a controller 2, a flow control network, a potentiostat 3, and a host computer 4.

[0025] Reaction cell 1 is divided into an anode chamber and a cathode chamber by a proton exchange membrane. The working anode electrode is located in the anode chamber. A flow control network is electrically connected to controller 2. The flow control network includes valve assembly 5, a bottom liquid line 6, and a water sample line 7. The bottom liquid line 6 and the water sample line 7 are respectively connected to the sample inlet of the anode chamber. Controller 2 controls valve assembly 5 to switch the conduction state of either the bottom liquid line 6 or the water sample line 7. The working electrode of potentiostat 3 is connected to the working anode electrode. Potentiostat 3 applies a working potential to the working anode electrode and acquires the current response sequence. Host computer 4 establishes communication connections with both controller 2 and potentiostat 3.

[0026] See attached document Figure 2 This invention provides a method for online monitoring of ammonia in water based on a microbial electrochemical sensor, comprising the following steps: S100, the potentiostat 3 applies an initial working potential to the anode working electrode, the controller 2 controls the flow control network to open the bottom liquid pipeline 6, the bottom liquid flows continuously into the anode chamber through the bottom liquid pipeline 6, the host computer 4 acquires the continuous current sequence collected by the potentiostat 3 and calculates the current variance, when the current variance is lower than the set fluctuation threshold, the host computer 4 records the current mean as the baseline current. S200, the controller 2 receives the detection trigger command and controls the valve group 5 to switch to the water sample pipeline 7. The water sample to be tested is injected into the anode chamber through the water sample pipeline 7. The host computer 4 synchronously receives the decay current sequence output by the reaction tank 1, and constructs a sliding time window for the decay current sequence to perform local polynomial fitting calculation, extracting the current change rate and current change acceleration. When the host computer 4 determines that the current change rate has a zero crossover state and the current change acceleration remains positive, it sends a hardware interrupt signal to the controller 2. The controller 2 responds to the hardware interrupt signal and controls the valve group 5 to switch back to the bottom liquid pipeline 6. S300, the host computer 4 extracts transient response data of the inhibition and elution stages, establishes a two-dimensional phase space hysteresis loop with standardized current as the abscissa and current change rate as the ordinate, extracts the extreme parameters and envelope area of ​​the two-dimensional phase space hysteresis loop, calculates the characteristic index based on the extreme parameters and envelope area, and compares the characteristic index with the preset interval to determine the inhibition type of the water sample. When the inhibition is determined to be caused by ammonia in water, the host computer 4 calculates the ammonia concentration based on the envelope area. S400, during the elution stage when the bottom liquid line 6 is open, the host computer 4 calculates the spatial offset distance between the coordinates on the two-dimensional phase space hysteresis loop and the baseline current coordinates. When the spatial offset distance and elution time exceed the preset conditions, the host computer 4 sends a potential jump command to the potentiostat 3. The potentiostat 3 responds to the potential jump command by stepping the working potential of the anode working electrode from the initial working potential to the set working potential. The host computer 4 continuously monitors the spatial offset distance. When the spatial offset distance is lower than the closing threshold, it controls the potentiostat 3 to restore the anode working electrode to the initial working potential.

[0027] In the process of establishing sensor monitoring benchmarks, the specific implementation of the potentiostat 3 applying an initial working potential to the anode working electrode and the controller 2 controlling the flow control network to open the bottom liquid pipeline 6 includes the following sub-steps: S101, In this embodiment, the potentiostat 3 is configured to operate in timing current mode and applies an initial operating potential of a set amplitude to the anode working electrode deployed inside the anode chamber. As a preferred method, this initial operating potential The value range is generally set to +200mV to +400mV (relative to the Ag / AgCl reference electrode). Within this range, the initial operating potential... This provides a suitable oxidative driving force for the electrogenic biofilm attached to the surface of the anolyte, maintaining extracellular electron transport. This helps avoid cell membrane rupture and death caused by excessively high polarization potential, or the masking of toxic response characteristics due to weak background current caused by excessively low potential. In this step, the hardware output channel of the potentiostat 3 establishes a closed three-electrode test circuit with the anolyte, the counter electrode in the cathode chamber, and the reference electrode. For the specific spatial arrangement of the three-electrode system and the selection of the reference electrode, those skilled in the art can perform conventional configuration based on the actual structure of the reaction cell 1. The construction method is well-known in the art and will not be elaborated here.

[0028] S102, in order to match the polarization environment of the electrochemical system, the controller 2 outputs a digital command signal to the flow control network to drive the valve group 5 to perform a physical valve position switching action. The electromagnetic coil inside the valve group 5 responds to the digital command signal and acts to block the internal fluid channel of the water sample pipeline 7, while simultaneously opening the internal fluid channel of the bottom liquid pipeline 6.

[0029] S103, the bottom fluid is supplied via the conductive bottom fluid line 6 at a constant volumetric flow rate. The sample is continuously injected into the anode chamber inlet, and a physical mass transfer boundary layer tends to form on the surface of the working anode electrode. Generally, because the background signal of a microbial sensor originates from the metabolism of living cells, it is highly susceptible to fluctuations caused by nutrient deficiency. Therefore, the background solution contains carbon source substrates and conductive electrolytes to maintain the basal cellular metabolism of electrogenic microorganisms. Volumetric flow rate. The specific values ​​can be obtained by calibrating the effective volume of the anode chamber of reaction tank 1 with the expected hydraulic retention time. It is typically configured to maintain laminar flow within the anode chamber. At a constant volumetric flow rate... The resulting convective mass transfer effect and initial operating potential Driven by the dual polarization effects, the substrate consumption rate inside the anode chamber and the interfacial electron transfer rate tend towards a dynamic physical equilibrium. The electrochemical output state of reaction cell 1 gradually transitions from an open-circuit state to a steady-state discharge state. The unidirectional continuous flow of the substrate into the anode chamber helps maintain a relatively constant background concentration in the reaction environment, establishing a physical reference standard for the host computer 4 to subsequently identify external transient disturbance signals.

[0030] As reaction tank 1 approaches dynamic physical equilibrium, host computer 4 simultaneously initiates real-time monitoring and data preprocessing of the sensor's electrochemical output signal. The specific implementation includes the following sub-steps: S104, the host computer 4 sends a continuous data reading command to the potentiostat 3 via communication connection, acquiring discrete current response data of the anode working electrode surface at a fixed sampling frequency fs. In this embodiment, considering that the transient response timescale of the electrogenic microbial metabolic process and extracellular electron transfer is usually between tens of seconds and minutes, if the sampling frequency is set too high, it will introduce additional high-frequency noise from fluid pulsation and instrument capacitor charging and discharging; while if the sampling frequency is too low, it will miss the extreme inflection point of the toxicity inhibition signal. As a preferred method, the sampling frequency... The value range is set to 0.5Hz to 5Hz. Data acquired within this frequency range can better reflect the characteristic frequency band of microbial electrochemical reactions.

[0031] S105, to extract the dynamic change characteristics of the current without introducing phase delay, the host computer 4 constructs a sliding time window in memory for the received discrete current response data. Specifically, the host computer 4 is configured with a fixed-length data queue with first-in, first-out (FIFO) characteristics. The system pushes the latest acquired current data into the queue and simultaneously pops the oldest historical data. Through dynamic updates, a fixed number of data points are maintained within the sliding time window. A series of consecutive sampling points. The time span of the sliding time window is defined as follows: Its value is determined by the sampling frequency. Total number of data points in the window Jointly decided, satisfying the relational expression .parameter The selection of the sampling time is related to the hydraulic residence time of reaction tank 1. It is typically configured such that the time span ΔT covers a signal evolution period of 10 to 30 seconds, ensuring sufficient data within the window to mitigate random noise. Furthermore, at the initial stage of the monitoring task, when the number of sampling points within the data queue has not yet reached [a certain threshold], [further details are needed]. At this time, the system is in a data pre-filling state and will not perform subsequent local time coordinate construction and polynomial fitting operations. Only after the data queue is full will it enter the regular sliding update and feature extraction process.

[0032] S106, during the sliding update process of the data queue, the host computer 4 constructs local time coordinates for the data points within the window. Because traditional absolute timestamps accumulate over long periods of system operation, large time values ​​can cause reduced floating-point precision or computational overflow during subsequent polynomial fitting and matrix inversion operations. To address this issue, the host computer 4 shifts the time of the most recently entered sampling point within the sliding time window and defines it as the origin of the local time coordinates, i.e., sets a local time parameter. Using this origin as a reference, the remaining time within the sliding time window... The local time coordinates of each historical sampling point correspond to the distribution in the interval. By constructing the aforementioned local time coordinate system, the system maps the ever-growing global time coordinates to a bounded, constant interval, which helps avoid the risk of overflow in numerical computation and also provides a numerical basis for directly extracting the true derivative of the current physical moment through the coefficients of algebraic equations.

[0033] After constructing the discrete data queue, to assess whether the background signal from the sensor has stabilized, the host computer 4 continuously performs statistical calculations on the data within the sliding time window to determine whether the system meets the conditions for entering the subsequent monitoring process. The specific implementation of this stage includes the following sub-steps: S107, when the host computer 4 completes the data update at each sliding time window, it reads the data contained in the queue. Each discrete current response data point is labeled as... , where the serial number Corresponding to 1 to To quantify the fluctuation level of the current signal, the host computer calculates the arithmetic mean of the data set. Furthermore, the variance of the current sequence is calculated. The mathematical expression used for variance calculation is as follows: In this computational system, variance This reflects the dispersion of microbial metabolic electricity generation processes within a local time interval. Unbiased sample variance is used for calculation here to reduce statistical bias caused by a small number of local sampling points and to more accurately estimate the overall noise fluctuations of the system. Compared to simply monitoring the instantaneous absolute value jumps in current, using the variance of window data can filter out some high-frequency random interference, thereby extracting more reliable signal change characteristics.

[0034] S108, obtain the real-time variance. Then, the host computer 4 compares it with a pre-set fluctuation threshold. A comparison is performed. In this embodiment, the fluctuation threshold... The value is calibrated based on the hardware signal-to-noise ratio of the potentiostat 3 and the deviation of the biofilm's basal metabolism during stable injection in the bottom fluid pipeline 6. As a preferred method, this fluctuation threshold... The standard value is typically set to 1.5-2 times the variance of the background current noise obtained under normal continuous operation of the base fluid. Considering that occasional bubble bursts or uneven mass transfer in the fluid pipeline can cause temporary convergence of the variance within a local time period, the host computer 4 incorporates a time-dimensional anti-false-judgment mechanism in its software logic, namely, continuous monitoring of the variance. Below the fluctuation threshold The duration of the required stability period. When the required duration reaches the set stability time threshold, the host computer 4 determines that the electrochemical reaction in reaction tank 1 has reached physical steady state. Generally, the stability time threshold can be set to 3-5 times the hydraulic retention time of reaction tank 1 to ensure that the previous fluid in reaction tank 1 has been replaced and that the biofilm metabolism has adapted to the current environment and established a new equilibrium.

[0035] S109, after confirming that the electrochemical reaction has reached steady state, the host computer 4 extracts the arithmetic mean within the current sliding time window. And store it as a baseline current. This baseline current The baseline electrochemical activity level of the biofilm in reaction tank 1 was characterized under the current physical and chemical environment. After completing the numerical extraction and buffering, the host computer 4 reset the internal operating status flag, causing the system to transition from the initial baseline search state to the monitoring standby state, in order to wait for the response to the external detection trigger command.

[0036] After the system has locked the baseline current and is in monitoring standby mode, external environmental fluids need to be introduced to assess their impact on microbial activity. The specific implementation of this stage includes the following sub-steps: S201, controller 2 receives a detection trigger command through its input / output ports. In this embodiment, the source of the detection trigger command can have multiple equivalent implementation methods. For example, it can be a periodic measurement interrupt signal generated by an internal system timer, or a hardware level signal sent by an external liquid level sensor when the monitoring tank reaches a set water level. Alternatively, it can be a remote real-time measurement command issued through the human-machine interface of the host computer 4. After the controller 2 captures the trigger command, it outputs a drive control level to the valve group 5 in the flow control network. The mechanical actuator in the valve group 5 then actuates, cutting off the flow path of the bottom liquid pipeline 6 and simultaneously opening the flow path of the water sample pipeline 7.

[0037] S202, the water sample to be tested is introduced into the open water sample pipeline 7 at a set injection volume flow rate. The sample is injected into the anode chamber of reaction cell 1. To reduce non-biochemical interference caused by changes in hydrodynamic conditions to the sensor output signal, as a preferred method, the injection volumetric flow rate is... The flow rate of the substrate solution was configured to be essentially consistent with that of the previous step. After the water sample enters the anode chamber, its internal chemical components come into contact with the electrogenic biofilm on the surface of the anode working electrode. When the water sample contains bioinhibitory substances such as ammonia, the activity of related metabolic enzymes or the transmembrane electron transport chain within the microbial cells will be inhibited to some extent. This inhibition disrupts the original balance of substrate metabolism and electron transfer within reaction tank 1, causing a decrease in the macroscopic current collected by the anode working electrode.

[0038] S203: Simultaneously with the controller 2 issuing the valve group 5 switching command, the host computer 4 uses its internal timer to trigger data synchronization and recording. Normally, a certain physical dead volume exists within the piping space of the hardware system, and the fluid needs a certain transmission delay to flow from the valve switching position to the surface of the anode working electrode. Regarding this transmission delay time The sample can be obtained by those skilled in the art based on the inner diameter and length of the water sample pipeline 7 and the set injection volume flow rate. The standard conversion is a well-known technique in this field and will not be elaborated upon here.

[0039] S204, considering the spatial lag in fluid transport, the host computer 4 internally times out the transmission delay time. Subsequently, the discrete current response data continuously uploaded by potentiostat 3 was officially marked as valid and extracted and recorded as a decaying current sequence. ,in This represents a relative time variable starting from the actual moment the water sample reaches the electrode surface. This sequence reflects the current drop process caused by the inhibition of microorganisms by exogenous substances. (The text then abruptly shifts to a different topic: obtaining the decay current sequence.) During this phase, the host computer 4 continues to maintain the sliding update of the data queue, so that a fixed number of the latest sampling points remain in the computing memory, thereby providing continuous data support for the subsequent differential analytical algorithm.

[0040] After obtaining an effective decay current sequence, the system needs to extract the dynamic change characteristics of the signal in real time. Traditional numerical differential methods are prone to amplifying high-frequency noise and have time lag. To obtain accurate transient dynamic parameters, the specific implementation of this stage includes the following sub-steps: S205, host computer 4, for caching within the sliding time window. A second-order local polynomial model is constructed using discrete sampling points. In this embodiment, the local time coordinate of each sampling point is set as follows: The corresponding current measurement value is The expression for the continuous polynomial equation is: In the formula, It is a local time variable, and its value range corresponds to the previously constructed... interval; , , The coefficients are the polynomial fitting coefficients to be solved. As a preferred approach, a second-order polynomial is chosen here because the second-order curve can better approximate the nonlinear decay trajectory of the suppressed current signal, and can also reduce the edge oscillation error caused by using a higher-order polynomial.

[0041] S206, To determine the coefficients of the aforementioned polynomial, the host computer 4 uses a least squares algorithm for fitting operations. The optimization objective of this algorithm is to minimize the sum of the squared errors between the fitted calculated values ​​and the actual measured values ​​for all discrete sampling points within the window. Specifically, the host computer 4 will... The data array of each sampling point is converted into matrix form, and the coefficient matrix is ​​calculated by solving the standard normal equations. Since a local time coordinate system was established in the previous steps, the relative local time of each sampling point within the window changes each time the window slides and updates. The time vector matrix remains constant. Based on this characteristic, the host computer 4 can pre-calculate the pseudo-inverse matrix composed of the time vector matrix during the system initialization phase and store it in memory. During real-time monitoring, the host computer 4 only needs to combine the pre-stored constant pseudo-inverse matrix with the real-time updated current column vector within the current window. A single matrix multiplication can quickly compute the current coefficient vector [a,b,c]T. This processing logic reduces the overhead of matrix inversion in loop operations.

[0042] S207, after obtaining the fitting coefficients, the host computer 4 performs a delay-free analytical differentiation operation to extract feature parameters. Typical central difference or moving average differentiation algorithms rely on symmetrical data before and after the target point, introducing a phase delay of half a window length when processing real-time sequence endpoints. To overcome this physical time lag, the host computer 4 utilizes the established continuous polynomial equation to directly perform analytical differentiation at the corresponding current physical moment. Based on the principles of calculus, the polynomial model is differentiated with respect to local time variables. Find the first derivative to obtain the continuous rate function. Further, by taking the second derivative, a continuous acceleration function is obtained. Since the latest data point is located precisely at the origin of the local coordinate system, the host computer will... By directly substituting these values ​​into the derivative function above, the rate of change of current at the current actual physical moment can be extracted without delay. and the acceleration of current change This differential method, based on direct mapping of algebraic coefficients, not only smooths out random noise but also ensures the timeliness of the sensor's response to transient toxic disturbances.

[0043] After obtaining the transient rate of change of current and acceleration, the system needs to determine whether the inhibition process of the biofilm has reached its dynamic limit, so as to restore the culture environment of reaction tank 1 in a timely manner. The specific implementation of this stage includes the following sub-steps: S208, the host computer 4 obtains the aforementioned continuously changing rate... Symbolic calculus is performed to find the topological minimum point in the decaying current sequence. According to the calculus extremum theorem, when the current trajectory is concave and the derivative crosses zero, the following condition is satisfied: And the aforementioned acceleration At this point, the current drops to its lowest point. From the perspective of bioelectrochemical reactions, this phenomenon reflects that the inhibitory effect of exogenous toxic substances on microbial metabolism has reached its maximum at the current concentration, and a transient equilibrium has been established between the diffusion of toxic substances and substrate consumption within the system. Considering that actual hardware acquisition usually involves basis fluctuations and analog-to-digital conversion quantization errors, the calculated floating-point rate is required to... Achieving a value equal to zero is quite challenging in engineering implementation. To address this technical issue, the host computer (computer 4) has configured a threshold value for determining if a value approaches zero within its software. When the rate is detected absolute value For multiple consecutive sampling periods, the value is less than this threshold. And acceleration When the value remains positive, the host computer system successfully captures the topological minimum point. As a preferred method, the zero-touch threshold is used. The specific value can be set to 1 to 2 times the root mean square value of the background current noise at the system baseline steady state, which helps to balance the sensitivity of feature recognition and anti-interference capability. The number of consecutive sampling periods mentioned above can generally be configured to 3 to 5 to eliminate false triggering caused by single-point calculation noise.

[0044] S209. In actual water monitoring scenarios, if a high-concentration toxic water sample is encountered, the biofilm faces the risk of irreversible inactivation, leading to a continuous decrease in current and a prolonged failure to reach a minimum inflection point; or, in non-toxic water samples, the current only exhibits gentle fluctuations and fails to form extreme value characteristics. If the system relies solely on the above topological extreme value conditions as the single control trigger source, the program logic will fall into a long waiting state. To ensure the completeness of the algorithm logic, the host computer 4 introduces a mechanism based on the maximum allowable sample introduction time. The timeout forced switchback mechanism. This is the maximum permissible injection time. The settings are primarily based on matching the tolerance limits of the selected electrogenic microorganisms and the expected monitoring response cycle. In this embodiment, the maximum allowable sample introduction time is... The typical setting is 10 to 15 minutes.

[0045] S210, when the host computer 4 successfully determines the topological minimum point, or the internal timer reaches the aforementioned maximum allowable injection time. At this time, the system initiates state-dependent switchback control logic. The host computer 4 sends a switchback command to the controller 2, which then drives valve group 5 in the flow control network to perform a reset action. Valve group 5 closes the flow channel of the water sample pipeline 7 and reopens the bottom liquid pipeline 6. The continuous injection of the bottom liquid gradually replaces the residual water sample in the anode chamber, providing the damaged biofilm with a carbon source substrate and a suitable electrolyte environment to maintain basal metabolism, thereby promoting the gradual recovery of transmembrane electron transport activity in microbial cells. Within the same clock cycle as the switchback command, the host computer 4 extracts the discrete current response data at the current moment and uses it as the extreme current. Store this extreme current. Baseline current locked in the preceding steps Together, they constitute the core parameters for subsequent quantification of water toxicity index.

[0046] See attached document Figure 3 After completing the physical process of water sample injection and bottom fluid retraction, the host computer 4 recorded the complete inhibition and recovery current sequences. To further analyze the nonlinear kinetic characteristics of the biochemical reaction, the system needs to convert the one-dimensional time-domain signal to a multi-dimensional phase space for geometric analysis. The specific implementation of this stage includes the following sub-steps: S301, the host computer 4 extracts the discrete current sequence and its corresponding current change rate sequence recorded throughout the entire monitoring period. To reduce the impact of differences in background activity of biofilms from different batches on feature extraction, the host computer 4 needs to perform standardization processing on the current data. This standardization process converts absolute current values ​​into relative suppression ratios, making measurement results from different sensors or different periods physically comparable. Specifically, based on the baseline current established above... Using the normalized current parameters at various time points as a reference, the host computer (4) calculates these parameters. Based on this, a two-dimensional phase space coordinate system is constructed in memory. This coordinate system uses the normalized current as the horizontal axis. The rate of change of the output current is fitted using a local polynomial. As the ordinate The constructed phase space mapping expression is as follows: ; ; In the formula, The index number for the discrete time series; For the first The actual current measurement value at each sampling point; The rate of change of current is obtained by analytical differentiation without delay at the same moment. Through mapping, the host computer 4 reconstructs the isolated time series into a set of phase trajectory points containing state evolution information. .

[0047] S302, as monitoring time progresses, the set of phase trajectory points connects in the two-dimensional phase plane to form a continuous curve reflecting the dynamic state of the microorganism. During the normal toxicity inhibition and bottom fluid recovery cycle, this phase trajectory starts near the coordinate point (1,0). When the toxic substance is injected into reaction tank 1 and induces inhibition, the current decreases and the rate becomes negative. Since the standardized current is always positive, the trajectory points must extend into the fourth quadrant until they reach the corresponding extreme current. The topological minimum inflection point. After the system switches back to the bottom fluid, the biofilm activity gradually recovers, the current increases and the rate turns positive, the trajectory point crosses from the fourth quadrant back to the first quadrant, and finally tends towards the starting position. This physical evolution process objectively reflects the complete biochemical cycle of biofilm inhibition and recovery, forming a complete hysteresis loop structure in geometric space.

[0048] S303, in the actual operating environment of this embodiment, if the water sample to be tested contains highly toxic substances such as heavy metals, the biofilm is unlikely to recover to its initial baseline activity within a limited time, causing the phase trajectory to fail to close naturally at the end of the physical time. Without corresponding closure logic, the subsequent numerical integration algorithm aimed at calculating the loop characteristic parameters will fail to define the integration region, leading to program errors or divergent calculation results. To solve this algorithm logic dead zone, the host computer 4 introduces a forced closure mechanism based on conditional tolerance. When the Euclidean distance between the trajectory endpoint and the starting point is less than the set closure tolerance... When the loop is deemed to have closed naturally, the system determines that the loop closure is complete. If the recovery time reaches the maximum recovery period set by the system, and the Euclidean distance is still greater than or equal to the closure tolerance... At this time, the host computer 4 mathematically forces the closure of the two-dimensional loop by constructing a linear interpolation segment between the end point and the start point. As a preferred method, closure tolerance... The value can be set to a dimensionless value between 0.02 and 0.05. The specific calculation formula for the Euclidean distance and the specific implementation of linear interpolation can be written by those skilled in the art based on conventional computational geometry principles; these are well-known techniques in the field and will not be elaborated upon here.

[0049] See attached document Figure 4 After successfully constructing and closing a two-dimensional hysteresis loop in phase space, the host computer 4 needs to extract feature parameters from this geometric topology that can quantify the toxic effects. The specific implementation of this stage includes the following sub-steps: S304, The host computer 4 traverses the previously generated set of phase trajectory points. One-dimensional dynamic extreme parameters are extracted. Specifically, the host computer retrieves the minimum value of the horizontal axis coordinate in the trajectory data queue through numerical comparison operations, and defines it as the maximum suppression depth. From a biochemical perspective, this parameter characterizes the minimum residual proportion of transmembrane electron transport network activity under the impact of current toxic substances. Similarly, the host computer retrieves the minimum and maximum values ​​from the data column on the vertical axis and defines them as the maximum inhibition rate. With maximum recovery rate Among them, the maximum inhibition rate This reflects the transient peak rate at which toxic molecules penetrate the biological membrane and inhibit the activity of related enzyme systems; the maximum recovery rate. This reflects the peak level of self-repair of the microbial metabolic system after the bottom fluid is replaced. These extreme parameters are used in multidimensional space to construct boundary conditions that reflect the local transient behavior of biochemical reactions.

[0050] S305, to obtain global features describing the entire process of toxicity, the host computer 4 performs envelope area integration on the aforementioned closed hysteresis loop. Since the phase trajectory is actually composed of a finite number of discrete sampling coordinate points, conventional continuous differential functions are difficult to execute directly in the digital systems of microcontrollers or industrial control computers. In this embodiment, the host computer 4 treats the discrete trajectory point set as a closed polygon in a two-dimensional plane and uses the polygon area theorem (such as the shoelace formula) to perform discrete quadrature calculation. The envelope area is then obtained. The core computational relationship is represented as follows: In the formula, The area of ​​the envelope; This represents the total number of nodes in the set of points on the closed trajectory. and Corresponding to the first The x and y coordinates of each node; the absolute value sign is used to avoid negative area values ​​due to different clockwise or counterclockwise evolution directions of the trajectory. This envelope area is physically equivalent to the cumulative activity loss caused by the biofilm metabolic system deviating from steady state during the entire toxicity inhibition and base fluid recovery cycle. Compared to the extreme value parameter of a single point, the envelope area can more comprehensively cover the hidden toxicity information that triggers slow-type inhibition. For the specific implementation of the underlying judgment condition for polygon boundary closure and the cross-product accumulation code, those skilled in the art can configure it based on conventional computational geometry principles; unnecessary redundant discussion using formulas will not be used here.

[0051] S306, To differentiate the toxicology of different chemical substances, the host computer 4 calculates a dimensionless characteristic index based on the extracted extreme value parameters and envelope area. From the actual reaction process observed in biochemical monitoring, electrogenic biomembranes experience a decrease in electrical signals upon exposure to toxicity, which gradually recovers after the toxin is removed. Different molecular structures of toxins exhibit varying binding and adhesion forces to cell membrane receptors, leading to differences in the kinetic processes of inhibition and recovery. This characteristic index... The specific algebraic expression for decoupling the kinetic characteristics caused by water toxicity is as follows: In the formula, This represents the minimum rate of change of the signal (i.e., the maximum suppression rate). This represents the maximum rate of change of the signal (i.e., the maximum recovery rate). This represents the lowest relative activity of the normalized signal (reflecting the maximum suppression depth). The hysteresis envelope area is obtained by integration; The smallest positive real number preset for the system (e.g., a value of 10). -6 ), used to prevent the envelope area from being reduced when the water sample is non-toxic. The algorithm dead zone occurs when the value approaches zero, triggering a division-by-zero overflow. From a biochemical perspective, the formula... This reflects the symmetry between inhibition and recovery rates, while The inhibition depth per unit area of ​​active loss was then evaluated. Different types of toxins cause biofilms to exhibit their own corresponding characteristic index ranges.

[0052] See attached document Figure 5 After obtaining the multidimensional feature vector containing local and global response parameters, the system needs to further analyze the nonlinear correlation between the features, transforming the geometric parameters into specific biochemical substance concentration indicators. The specific implementation of this stage includes the following sub-steps: S307, Obtain Feature Indices Subsequently, the host computer 4 compares the values ​​with the preset judgment interval to identify the inhibition type of the current water sample. For ammonia nitrogen (water ammonia) pollutants, it exhibits typical reversible competitive inhibition of electrogenic microorganisms. When switching back to the non-toxic bottom liquid, ammonia molecules easily desorb from the cell membrane, and the recovery rate... It is faster, therefore its characteristic index It typically exists within a relatively stable, specific range. In this embodiment, the host computer 4 presets a judgment range corresponding to ammonia inhibition. The upper and lower limits of this interval were determined by injecting multiple ammonia nitrogen samples of known standard concentrations into reaction tank 1 in the early stages, recording and calculating the characteristic indices multiple times, and then taking the lower and upper bounds of the confidence interval (e.g., 95% confidence level) of their statistical distribution. When the real-time calculation... When the current falls within this range, the host computer 4 determines that the toxic substance causing the current decay in reaction cell 1 is ammonia; if Less than the lower limit This indicates that the biofilm recovery is relatively slow, and the system determines that it has suffered from other types of inhibition, such as heavy metals, that cause irreversible damage; as a logical complement, if Greater than the upper limit If the system determines that the problem is caused by a high concentration of easily degradable organic matter or sensor measurement noise, it will directly mark the anomaly and exit the subsequent ammonia concentration calculation.

[0053] S308, after determining that the inhibition type induced by the water sample is ammonia, the host computer 4 initiates the corresponding concentration calculation program. Based on the kinetics of ammonia inhibition, within the non-lethal concentration range, the cumulative activity loss of the biofilm (i.e., the envelope area)... The envelope area shows a positive correlation with the ammonia concentration in the water. Therefore, the host computer directly uses the envelope area obtained from the integration in the previous steps. The ammonia concentration of the water sample was calculated as a single independent variable. .

[0054] S309, as a preferred approach, the host computer 4 has a pre-configured polynomial regression equation based on empirical calibration as a concentration mapping model in its memory space. This calculation model is expressed as: ; In the formula, , , These are the concentration mapping coefficients pre-defined for the system. Before system deployment, offline calibration tests are conducted by extracting ammonia nitrogen water samples with known standard concentrations. The least squares method is then used to fit multiple sets of envelope area and standard concentration sample data to obtain the aforementioned constant coefficients. Considering background interference present in actual water bodies, the coefficients... Typically used as a baseline intercept term, this regression equation is employed to offset the effects of minute current fluctuations in the system's base fluid. While effectively filtering out high-frequency noise, it can also characterize the nonlinear relationship between the toxicity hysteresis loop area and ammonia concentration within a set allowable error range.

[0055] S310, in online operation, the host computer 4 calculates the predicted ammonia concentration using the above equation and compares it with a preset environmental safety benchmark (e.g., the ammonia nitrogen concentration limit for a specific category of water quality specified in the commonly used surface water environmental quality standards). When the mapped concentration value exceeds the safety benchmark, the host computer 4 triggers an anomaly warning logic and generates a message containing concentration parameters, which is then uploaded to the remote monitoring center via the communication interface. To prevent communication congestion caused by frequent message transmissions during continuous exceedances, the system sets an alarm dead zone time in the software logic, reporting messages only once within the same exceedance event or at a set period. Through this multi-dimensional feature decoupling and judgment diversion, the monitoring system achieves effective conversion from underlying electrochemical signals to surface water pollution levels.

[0056] After mapping specific pollutant concentrations, to meet the real-time early warning requirements of continuous online monitoring, the system needs to dynamically track the evolution trajectory of biofilm metabolic state within reaction tank 1. The specific implementation of this stage includes the following sub-steps: S401, the host computer 4 extracts the real-time standardized current and corresponding current change rate of the current sampling period. To quantify the immediate impact of the current water quality state on the biofilm metabolic process, the host computer 4 establishes a reference coordinate system with the healthy baseline state as the origin. In this embodiment, under normal operating conditions, the steady-state characteristics of the biofilm in a non-toxic bottom liquid environment are characterized by a standardized current approaching 1 and a current change rate approaching 0. The host computer 4 then uses the current real-time coordinates... By comparing point by point with the steady-state reference point (1,0), the transient deviation components in the horizontal and vertical directions are analyzed. This transient deviation reflects the current drop and metabolic rate fluctuation induced by the toxic shock.

[0057] S402, to reduce state overlap and misjudgment caused by multivariate independent evaluation, the host computer 4 uses an analytical geometric model to fuse the above two-dimensional deviation components into a single spatial distance index. Considering the differences in the numerical span of different physical dimensions, the system introduces weighting coefficients to balance the magnitudes in the distance calculation model. Calculate the spatial offset distance. The core formula expression is: In the formula, The spatial offset distance at the current moment; and These are the standardized current and the rate of change of current at the current sampling moment, respectively; and These are the scaling weights for the horizontal and vertical axes, respectively. This spatial offset distance... In a physical sense, this characterizes the severity of the current system state deviating from a healthy baseline; a higher value indicates a better inhibitory effect of water toxicity on microbial metabolism. To avoid subjective errors caused by artificially set weights, the weighting coefficients are... and The system adaptively assigns values ​​based on the reciprocal of the variance of two-dimensional data within the historical operating cycle of non-toxic water samples. This parameter configuration logic falls under the conventional data dimensionality reduction techniques in this field, and will not be elaborated upon here using formulas.

[0058] S403. In actual water quality monitoring scenarios, the water flow disturbance caused by the switching of valve group 5 in the flow control network or external electromagnetic interference can lead to high-frequency jitter in transient coordinate points. If the system relies solely on the distance value of a single point for subsequent state determination, it is prone to triggering false alarms due to instantaneous noise spikes, causing the warning logic to be frequently triggered erroneously due to high-frequency noise. To compensate for this calculation deficiency, the host computer 4 performs smoothing filtering on the real-time output spatial offset distance sequence. As a preferred method, the system adopts an exponential moving average algorithm, dynamically weighting the calculated distance value at the current moment with the smoothed historical value at the previous sampling moment based on a set smoothing coefficient, thereby obtaining the final smoothed distance parameter. This allows the smoothed distance parameter to effectively filter out high-frequency interference while retaining the low-frequency change trend reflecting water quality deterioration. For the specific iterative formula of the exponential moving average, those skilled in the art can write the code based on conventional digital filtering principles, which is a well-known technology in this field and will not be elaborated here. The smoothing coefficient is usually set to a range of 0.1 to 0.3. This range is based on matching the sensor’s sampling frequency with the typical biochemical response time constant of the biofilm, which helps to balance the system’s transient response sensitivity and anti-interference margin.

[0059] After continuously tracking transient spatial distances, the system needs to identify whether the biofilm has suffered severe toxic impact and trigger hardware repair if necessary. The specific implementation of this stage includes the following sub-steps: S404, the host computer 4 continuously compares the real-time output smoothing distance parameter with the system's preset stagnation threshold. During the normal bottom fluid recovery phase, if biofilm activity recovers naturally, the smoothing distance parameter should gradually fall back to a safe range. In this embodiment, when the smoothing distance parameter exceeds the stagnation threshold and the duration exceeds the set tolerance time window, the host computer 4 determines that the biofilm is currently experiencing deep stagnation. From a biochemical mechanism perspective, this state is usually caused by heavy metal ions or high concentrations of organic toxins adhering to the surface of electroactive bacteria, leading to physical blockage of transmembrane electron transport channels. By introducing anti-jitter logic with a tolerance time window, the system can effectively filter out transient data out-of-bounds caused by fluid disturbances, which helps improve the reliability of stagnation state determination. The specific value of the stagnation threshold is usually set in conjunction with calibration data of historical heavily contaminated samples; while the length of the tolerance time window is matched and configured according to the bottom fluid replacement cycle of the flow control network. For the specific software code implementation of the threshold determination logic with time window, those skilled in the art can write it based on conventional industrial control logic, and will not use inequality symbols for lengthy derivations here.

[0060] S405, after confirming that the biofilm has entered a blocked state, conventional bottom solution rinsing is unlikely to restore sensor activity within the effective time. At this point, the host computer 4 triggers an electrochemical forced intervention program. Specifically, the host computer 4 sends an intervention command to the potentiostat 3 via the communication bus to change the constant polarization potential applied to the working electrode in the reaction tank 1 under normal monitoring conditions. As a preferred method, the potentiostat 3 switches the potential of the working electrode to a specific alternating pulse potential or a desorption potential with a higher anodic oxidation bias. The amplitude of this desorption potential is typically shifted positively by 0.2V to 0.5V compared to the conventional monitoring working potential. Applying this specific bias can generate electrostatic repulsion at the electrode-biofilm interface, or weaken the coordination bond between toxic molecules and the microbial cell membrane through local electrochemical oxidation, thereby promoting the desorption of toxic substances from the biofilm surface and their flow out of the reaction tank 1 with the bottom solution. As a preferred embodiment, to avoid irreversible electroporation rupture of the cell membrane caused by prolonged high pressure, the alternating pulse potential is configured as a positive square wave pulse with a frequency between 1Hz and 5Hz and a duty cycle of 10% to 30%, and the duration of a single forced intervention is set to 10 to 30 seconds. This specific combination of parameters can maximize the physical desorption work while maintaining the survival of microorganisms.

[0061] S406, after completing the set cycle of electrochemical forced intervention, the host computer 4 controls the potentiostat 3 to return to the original monitoring working potential and extracts the standardized current and smoothed distance parameters of the current biofilm again to assess the degree of activity recovery after forced desorption. If the smoothed distance parameter falls below the hindrance critical threshold, the system determines that the forced intervention is successful, and the sensor resumes normal online monitoring workflow. If the distance parameter remains high after multiple repeated interventions, it indicates that the biofilm has undergone substantial inactivation or physical detachment. To avoid the program falling into an endless intervention loop, the host computer 4 internally sets a maximum number of intervention retries. Under normal circumstances, the upper limit of this maximum number of intervention retries is configured to be 2 to 3 times. When the cumulative number of retries reaches this threshold, the host computer 4 terminates the current monitoring process, generates a sensor replacement and maintenance warning simultaneously on the local control panel and the remote monitoring center, and simultaneously issues an isolation command: controls the potentiostat 3 to cut off the polarization output to the reaction tank 1 to put it in a safe open circuit state, and drives the flow control network to forcibly lock the valve group 5 in the bottom liquid pipeline 6 conduction position. By implementing closed-loop feedback and intervention, we can not only prevent the system from continuously outputting incorrect water quality prediction data using faulty sensors, but also avoid secondary damage to hardware or accidental leakage of contaminated fluids caused by continuous ineffective high-pressure intervention.

[0062] After completing the aforementioned toxicity feature mapping and abnormal state intervention, the system needs to determine the final stage of the phase trajectory evolution process for a single detection cycle and reset the hardware and software environment to prepare for the next sampling. The specific implementation of this stage includes the following sub-steps: S407, the host computer 4 continuously monitors the closure state of the phase space trajectory to confirm whether the biofilm has truly returned to a healthy steady-state baseline. In this embodiment, the host computer 4 continuously reads the smoothed distance parameter and current change rate output in real time. When the smoothed distance parameter continuously falls back into the system's preset steady-state convergence tolerance band, and the current change rate remains near zero within a set time window, the host computer 4 determines that the hysteresis loop in the current phase space has formed a complete geometric closure. The specific upper limit of this steady-state convergence tolerance band is usually set to 2 to 3 times the baseline fluctuation variance under normal non-toxic substrate conditions; the length of the time window is matched and configured based on the typical metabolic stabilization cycle of the biofilm (usually 3 to 5 minutes). Combining the dual determination of spatial distance and change rate helps prevent the system from misjudging local data plateau periods during the slow recovery process as steady-state regression. To prevent the system from falling into an infinite loop of waiting for closure due to irreversible baseline drift caused by long-term sensor aging, when the closed-loop monitoring time exceeds the preset maximum monitoring cycle limit, the host computer 4 will actively interrupt the current monitoring logic and trigger the sensor baseline recalibration procedure. For the specific software state machine design of this convergence determination, those skilled in the art can write it based on conventional industrial control condition branch logic; redundant discussion using Boolean algebra symbols will not be used here.

[0063] S408, after confirming the trajectory closure, signifies the official end of a single water quality toxicity shock and its recovery cycle, the host computer 4 immediately initiates the data archiving process. As a preferred method, the host computer 4 packages the extreme parameters, envelope area, characteristic indices, predicted concentration indicators, and triggered electrochemical intervention records extracted during the current detection cycle into a structured data file. This file is then transferred to the local storage module and synchronously pushed to the remote monitoring center via the communication interface. The complete cycle data is not only used to generate water quality safety assessment logs but also serves as a historical sample with real biochemical response results. This data can be used for adaptive calibration and iterative updates of the mapping coefficients of the aforementioned nonlinear regression model in offline conditions, allowing the accuracy of the system's predictions to gradually improve with increased equipment operating time.

[0064] S409, to maintain consistency of initial conditions in subsequent water quality monitoring cycles, the host computer 4 executes a system state reset command after data archiving is complete. At the hardware level, the host computer 4 sends a control level to adjust the opening of valve group 5 in the flow control network, switching to flushing mode. It uses standard non-toxic base solution to flush reaction tank 1 and the flow pipeline to replace residual test samples in the flow channel. The relevant flushing flow rate and duration are engineered based on the internal volume of reaction tank 1. Typically, the liquid volume for a single reset flush needs to be 3 to 5 times the dead volume of the entire flow pipeline to reduce the risk of cross-contamination. At the software level, the host computer 4 synchronously clears the historical trajectory coordinate point set residing in the memory stack and resets the historical state variables in the spatial offset distance calculator and exponential moving average filter. This synchronous reset operation helps eliminate the interference of chemical residues from the previous detection cycle and the inertia of the underlying algorithm data on the new round of feature extraction, allowing the biofilm sensor to enter the next water quality monitoring cycle in a standardized initial ground state.

[0065] Specific application examples: This embodiment relies on a continuous online water quality monitoring node at the effluent outlet of the secondary sedimentation tank of a large municipal wastewater treatment plant. The specific implementation process is as follows: 1. Implementation Background and System Initialization Hardware deployment configuration: In the on-site monitoring cabinet, the anode chamber of reaction tank 1 is inoculated with a highly electroactive mixed electrogenic biofilm. The host computer 4 transmits the working polarization potential of the potentiostat 3. Set to +300mV (relative to Ag / AgCl reference electrode); sampling frequency Sliding time window points (i.e., time span) ).

[0066] Baseline optimization lock: Controller 2 opens the base fluid line 6 and injects a non-toxic base fluid containing a basic sodium acetate carbon source (flow rate). The host computer monitors the variance of the current data within the real-time monitoring window. Once the variance falls below a set threshold and remains below it for 3 minutes, the system automatically locks the current mean as the baseline current. The system enters standby mode.

[0067] 2. Sample Injection Triggering and Dynamic Delay-Free Analysis See attached document Figure 6 and attached Figure 7 Toxicity shock trigger: The host computer 4 issues a detection command at regular intervals, the flow control network cuts off the bottom liquid, and the sewage treatment plant effluent (assuming a sudden high concentration of ammonia nitrogen, the actual concentration is 15mg / L) is injected into the reaction tank 1.

[0068] Real-time micro-integration extraction: Ammonia nitrogen molecules exert reversible competitive inhibition on the biomembrane, causing the macroscopic current to begin to drop. The host computer 4 directly differentiates the second-order local polynomial at the current physical moment, outputting the real-time rate of change without delay. and acceleration .

[0069] Topological extremum capture: At 85 seconds after sample injection, the host computer detected the rate. The absolute value of three consecutive sampling periods And acceleration The trajectory is determined to have reached the inflection point of the topological minimum (at which point the extreme current drops to a value that is less than the maximum current). The host computer 4 sends a hardware interrupt signal to the controller 2, and the valve group 5 responds instantly by switching back to the bottom liquid line 6 for forced elution.

[0070] 3. Multidimensional mapping of phase space and feature decoupling Coordinate system construction: A two-dimensional phase space trajectory is generated using data from the aforementioned monitoring period. The horizontal axis represents the normalized current. The vertical axis represents the transient rate. .

[0071] Spatial extremum extraction: The maximum suppression depth is extracted through trajectory traversal. Maximum suppression rate (fastest downlink speed) Maximum recovery rate (fastest uplink speed) .

[0072] Area Quadrature and Material Determination: The algorithm uses the polygon formula to quadrature the closed trajectory to obtain the envelope area representing the cumulative activity loss. Then, substitute the values ​​into the formula to calculate the characteristic index: The system compares 1.96 with a preset database and accurately falls within the characteristic range of ammonia in water. Based on this, it was determined that the water quality anomaly was caused by ammonia nitrogen (excluding heavy metal interference).

[0073] Nonlinear concentration mapping: After confirming ammonia nitrogen, the system will... Substitute into the nonlinear regression equation pre-calibrated for the plant site The calculated ammonia nitrogen concentration was 15.4 mg / L. This value exceeded the plant's emission limit of 5 mg / L, and the system immediately generated an exceedance report and uploaded it to the environmental monitoring platform.

[0074] 4. State Reset and Forced Electrochemical Interference Prevention Line Smooth Tracking and Natural Reset: During the base liquid elution stage, the host computer continuously calculates the spatial offset distance between the real-time coordinates and the reference point (1,0). After about 5 minutes, the spatial offset distance smoothly returns to the steady-state convergence tolerance band, the phase space trajectory naturally closes, the system clears the historical stack, and prepares for the next online sampling.

[0075] Anti-lock Intervention: (Assuming heavy metals illegally discharged from a factory are present at the site) If the spatial offset distance remains high after elution for 10 minutes, it indicates severe physical blockage of the electron transport channels in the biofilm. At this point, the host computer 4 triggers an abnormal intervention, sending a potential jump command to the potentiostat 3, applying a positive square wave pulse with an amplitude of +600mV and a frequency of 2Hz to the working electrode for 20 seconds. Utilizing the electrostatic repulsion force generated by the high-voltage pulse, heavy metal ions are forcibly repelled and desorbed from the cell membrane surface. Subsequently, the reference potential of +300mV is restored, at which point the spatial offset distance rapidly decreases, successfully saving the biofilm from permanent inactivation and ensuring the continuity of subsequent online monitoring.

[0076] Experimental verification and effect comparison To verify the advancement of this invention, the R&D team conducted the following comparative verifications under standard laboratory conditions: Experiment 1: Characteristic Index Effectiveness of decoupling toxicity types Comparison: Traditional methods only consider the current drop, while this invention uses the characteristic index of a multi-dimensional phase space. .

[0077] Experimental group: Injected with 15 mg / L ammonia nitrogen (reversible mild toxicity) and 2 mg / L copper ions Cu. 2+ (Heavy metals are highly toxic).

[0078] Result comparison: Traditional methods: The maximum current drop for both is around 30%, and traditional one-dimensional methods cannot distinguish between excessive ammonia nitrogen and heavy metal leakage.

[0079] The method of this invention: ammonia nitrogen is easily desorbed. big, The value remained stable at 1.9 ± 0.2; however, copper ions were extremely difficult to elute. Approaching 0, leading to The system successfully distinguished the type of inhibition 100% of the time, avoiding misclassification in subsequent concentration conversions.

[0080] Experiment 2: Comparison of Concentration Prediction Accuracy Experimental setup: Ten sets of standard ammonia nitrogen solutions with concentrations of 5, 10, 15, 20, and 30 mg / L were prepared. Each solution was analyzed using the traditional one-dimensional minimum mapping method (utilizing...). (fitting) and the two-dimensional envelope area integration method of the present invention (using (Fit) Establish a regression curve.

[0081] Result comparison: One-dimensional method: Due to the influence of environmental background noise, the minimum value is prone to jitter, and the coefficient of determination Root mean square error .

[0082] This invention employs a two-dimensional method: area integrals possess inherent global smoothing and noise filtering properties, encompassing the cumulative effects of suppression and recovery. (Determination coefficient) Root mean square error The prediction accuracy has improved by nearly four times.

[0083] Experiment 3: Real-time verification of delay-free differentiation Comparison of methods: Traditional moving average difference method and the second-order local polynomial direct mapping method of this invention.

[0084] Results: When dealing with sudden toxicity, the traditional difference method has a phase delay of half a window period (about 7.5 seconds), which leads to a lag in the determination of extreme values ​​and excessive exposure of biofilm to toxins. However, the method of this invention uses analytical differentiation of algebraic coefficients, and the phase delay is 0. It can trigger the switch back to the bottom fluid protection within one clock cycle when the topological minimum occurs, and the average recovery time of biofilm is shortened by 42%.

Claims

1. A method for online monitoring of ammonia in water based on a microbial electrochemical sensor, applied to a system including a reaction tank (1), a controller (2), a flow control network comprising a valve group (5), a bottom liquid pipeline (6), and a water sample pipeline (7), a potentiostat (3), and a host computer (4), characterized in that, Includes the following steps: The potentiostat (3) applies an initial working potential to the anode working electrode in the reaction tank (1), the bottom liquid pipeline (6) introduces the bottom liquid, and the host computer (4) records the baseline current when the current sequence variance is lower than the fluctuation threshold. Switch to the water sample pipeline (7) to import the water sample to be tested. The host computer (4) acquires the current sequence and extracts the current change acceleration. When a zero crossover occurs, it controls the flow control network to re-introduce the bottom liquid. The host computer (4) establishes a two-dimensional phase space hysteresis loop and calculates the ammonia concentration based on the envelope area of ​​the two-dimensional phase space hysteresis loop when determining that ammonia inhibition is triggered. The host computer (4) calculates the spatial offset distance between the two-dimensional phase space hysteresis loop coordinates and the baseline current coordinates. When the spatial offset distance exceeds the preset conditions, the potentiostat (3) applies a set working potential and restores the initial working potential when it is below the closing threshold.

2. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 1, characterized in that, The host computer (4) records the baseline current when the variance of the current sequence is lower than the fluctuation threshold, including the following steps: The host computer (4) acquires the continuous current sequence and constructs a sliding time window in memory; The host computer (4) defines the time shift of the latest sampling point in the sliding time window as the local time coordinate origin, and the host computer (4) calculates the variance of the sampling points retained in the sliding time window as the variance of the current sequence. When the duration for which the variance of the current sequence is lower than the preset fluctuation threshold reaches the preset stable time threshold, the host computer (4) extracts the average value of the sampling points within the current sliding time window as the baseline current, and the host computer (4) resets the internal running status flag and enters the monitoring standby state.

3. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 2, characterized in that, Extracting the acceleration due to the change in current includes the following steps: The host computer (4) uses the least squares algorithm to fit and construct a continuous polynomial equation for the sampling points cached within the sliding time window; The host computer (4) performs a differentiation operation on the continuous polynomial equation. The host computer (4) takes the first derivative at the origin of the local time coordinate as the current change rate at the current physical moment and the second derivative at the origin of the local time coordinate as the current change acceleration at the current physical moment.

4. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 3, characterized in that, Controlling the flow control network to reintroduce the base fluid in the event of a zero-crossing state includes the following steps: When the host computer (4) detects that the absolute value of the current change rate is less than the zero-reaching judgment threshold for multiple sampling cycles and the current change acceleration remains positive, it determines that the zero crossover state has occurred. The host computer (4) introduces a timeout forced switchback mechanism. When the preset maximum allowable injection time is reached, the controller (2) controls the flow control network to re-inject the base liquid and record the extreme current.

5. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 4, characterized in that, The host computer (4) establishes the two-dimensional phase space hysteresis loop, including the following steps: The host computer (4) uses the baseline current as a reference to calculate the standardized current at each sampling time, and constructs a phase space mapping relationship with the standardized current as the horizontal axis coordinate and the current change rate as the vertical axis coordinate. The phase space mapping relationship forms a set of phase trajectory points in the two-dimensional coordinate system and connects them to form the two-dimensional phase space hysteresis loop. When the elapsed time after the re-introduction of the base fluid reaches the preset maximum recovery period and the Euclidean distance between the end point and the starting point of the phase trajectory point set is greater than or equal to the preset closure tolerance, the host computer (4) forcibly closes the two-dimensional phase space hysteresis loop by constructing a linear interpolation line segment between the end point and the starting point.

6. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 5, characterized in that, Determining the cause of the ammonia inhibition includes the following steps: The host computer (4) retrieves the minimum value of the horizontal axis coordinate in the phase trajectory point set as the maximum suppression depth, retrieves the minimum value of the vertical axis coordinate in the phase trajectory point set as the maximum suppression rate, and retrieves the maximum value of the vertical axis coordinate in the phase trajectory point set as the maximum recovery rate. The host computer (4) uses the polygon area theorem to perform area calculation on the closed two-dimensional phase space hysteresis loop to obtain the envelope area; The host computer (4) calculates the feature index based on the numerical relationship between the maximum inhibition rate, the maximum recovery rate, the maximum inhibition depth, and the envelope area; The host computer (4) compares the feature index with the preset judgment interval. When the feature index is within the preset judgment interval, it determines that the water ammonia inhibition is triggered.

7. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 6, characterized in that, Calculating ammonia concentration involves the following steps: The host computer (4) has a pre-set polynomial regression equation in its memory as a concentration mapping model. The host computer (4) substitutes the envelope area into the polynomial regression equation to obtain the ammonia concentration. When the ammonia concentration exceeds the preset environmental safety benchmark value, an abnormal early warning logic is triggered and a message containing the ammonia concentration is generated. The message is then uploaded to the remote monitoring center through the communication interface, and the message is reported at a set cycle within the set alarm dead zone time of the same exceeding event.

8. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 5, characterized in that, The process of calculating the spatial offset distance includes: The host computer (4) extracts the standardized current and the rate of change of the current at the current moment, calculates the transient deviation component of the current moment from the steady-state reference base point, and the standardized current of the steady-state reference base point approaches 1 and the rate of change of the current approaches 0. The spatial offset distance is obtained by weighting the deviations of the standardized current and the rate of change of the current from the steady-state reference point using weighting coefficients. The weighting coefficients are assigned values ​​based on the reciprocal of the variance of the standardized current and the rate of change of the current during the historical non-toxic water sample operation cycle. An exponential moving average algorithm is used to perform smoothing filtering on the spatial offset distance to obtain a smoothed distance parameter, which is then used as the basis for determining whether the preset blocking critical threshold has been exceeded.

9. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 8, characterized in that, Applying a set operating potential includes the following steps: When the smoothing distance parameter exceeds the preset hindrance critical threshold and the duration exceeds the preset tolerance time window, the host computer (4) determines that the biofilm on the surface of the anode working electrode encounters deep hindrance and sends a potential jump command to the potentiostat (3). The potentiostat (3) responds to the potential jump command and switches the working potential of the anode working electrode to the set working potential, wherein the set working potential is an alternating pulse potential or a desorption potential whose amplitude is positively offset from the initial working potential by a preset voltage value. If the constant potentiometer (3) has undergone repeated interventions and the cumulative number of retry attempts has reached the maximum number of intervention retry attempts, and the smoothing distance parameter has not fallen back to below the preset stagnation critical threshold, the host computer (4) issues an isolation command to control the constant potentiometer (3) to cut off the polarization output to form an open circuit state, and controls the flow control network through the controller (2) to lock the valve group (5) in the bottom liquid pipeline (6) conduction position.

10. The method for online monitoring of ammonia in water based on a microbial electrochemical sensor according to claim 8, characterized in that, After restoring the initial operating potential, the following steps are also included: When the smooth distance parameter continuously falls back to the preset steady-state convergence tolerance band and the current change rate remains near zero within the preset time window, the host computer (4) determines that the two-dimensional phase space hysteresis loop forms a complete geometric closure. After the complete geometric closure of the two-dimensional phase space hysteresis loop, the feature parameters extracted in the current detection cycle are encapsulated into a data file and archived. The host computer (4) executes a reset command and controls the flow control network to switch to flushing mode through the controller (2) to replace the residual water sample inside the pipeline with the bottom liquid, and simultaneously clears the phase trajectory point set residing in the memory and resets the historical state variables in the spatial offset distance calculator and exponential moving average filter.