A self-calibration method for excitation stability of electromagnetic flowmeter under sulfur-resistant conditions

By combining decision trees and reinforcement learning models, an excitation stabilization self-calibration method was developed to solve the measurement instability problem caused by changes in the electrode interface of the electromagnetic flowmeter in hydrogen sulfide medium. This method enables real-time identification of electrode status and dynamic adjustment of parameters, ensuring the stability and accuracy of the measurement.

CN123111422APending Publication Date: 2026-11-17SICHUAN VACORDA INSTR MFG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611466530.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-20
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In corrosive media such as hydrogen sulfide, the electrode interface of the electromagnetic flowmeter undergoes sulfide corrosion and electrochemical polarization, leading to signal drift and increased noise. The traditional bidirectional square wave constant current excitation method cannot adapt to the dynamic changes of the electrode interface in real time, affecting the measurement accuracy and stability.

Method used

A self-calibration method for excitation stability, combining decision tree and reinforcement learning models, is adopted. By extracting features from excitation detection signals and adjusting waveforms, the method enables real-time identification of electrode states and dynamic adjustment of parameters, including coarse and fine adjustment of the excitation waveform, thus constructing a closed-loop calibration mechanism.

Benefits of technology

It enables real-time status identification and rapid response of the electrode interface, effectively counteracting measurement interference caused by sulfidation and polarization, and ensuring the long-term stability and measurement accuracy of the flowmeter.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123111422A_ABST
    Figure CN123111422A_ABST
Patent Text Reader

Abstract

This invention discloses a self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions, relating to the field of electromagnetic flowmeter technology. The method includes the following steps: collecting the excitation detection signal of the electromagnetic flowmeter and extracting features from the excitation detection signal to obtain an excitation detection feature vector; inputting the excitation detection feature vector into an improved decision tree model to output an electrode state result; adjusting the excitation waveform of the electromagnetic flowmeter based on the electrode state result to obtain a first excitation waveform correction signal, extracting features from the first excitation waveform correction signal to obtain an excitation waveform correction feature vector; and inputting the excitation waveform correction feature vector into an improved reinforcement learning model to output a second excitation waveform correction signal, thereby achieving self-calibration of the excitation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electromagnetic flowmeter technology, specifically to a self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions. Background Technology

[0002] In industrial flow measurement scenarios involving sulfur-containing media such as petroleum and chemical industries, electromagnetic flowmeters have become core equipment for fluid metering due to their advantages such as the absence of throttling components, high measurement accuracy, and strong adaptability. However, under long-term erosion by corrosive media such as hydrogen sulfide, the flowmeter's measuring electrodes will undergo sulfide corrosion, surface deposition, and electrochemical polarization. The equivalent impedance of the electrode interface will continuously deteriorate, directly causing problems such as induced signal drift, increased noise, and measurement hysteresis. This has become a key technical bottleneck restricting the long-term stable operation of electromagnetic flowmeters under sulfur-resistant conditions.

[0003] Currently, industrial electromagnetic flowmeters generally adopt the traditional control method of bidirectional square wave constant current excitation. This method takes the preset constant excitation current amplitude, fixed excitation period, forward and reverse excitation duration and symmetrical switching sequence as the core, outputs a stable bidirectional square wave excitation current, constructs a uniform and symmetrical working magnetic field, and then induces a differential potential signal that is proportional to the fluid flow velocity to complete the flow measurement.

[0004] However, the excitation cycle, excitation direction switching rhythm, and unidirectional excitation duration of this traditional bidirectional square wave constant current excitation method are all preset static parameters. They cannot sense and adapt to the dynamic time-varying characteristics of the electrode interface under sulfur-resistant conditions in real time. Sulfide corrosion, surface deposition, and electrochemical polarization of the electrode interface will continuously change the amplitude, symmetry, and response characteristics of the interface equivalent impedance. The fixed excitation current amplitude, switching frequency, and commutation transition process cannot be dynamically adjusted online to follow the impedance changes. Ultimately, the flow meter cannot continuously counteract the measurement interference caused by electrode sulfide and polarization, and the long-term operating accuracy and stability continue to decline. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides a self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions, thereby resolving the problems existing in the background technology.

[0006] To achieve the above objectives, the present invention provides the following technical solution: a self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions, comprising the following steps: Step S1: Collect the excitation detection signal of the electromagnetic flowmeter and extract features from the excitation detection signal to obtain the excitation detection feature vector; Step S2: Input the excitation detection feature vector into the improved decision tree model and output the electrode state results; Step S3: Based on the electrode state results, adjust the excitation waveform of the electromagnetic flowmeter to obtain a first excitation waveform correction signal, and extract features from the first excitation waveform correction signal to obtain an excitation waveform correction feature vector. Step S4: Input the excitation waveform correction feature vector into the improved reinforcement learning model and output the second excitation waveform correction signal to achieve self-calibration of excitation.

[0007] Preferably, the collection of the excitation detection signal from the electromagnetic flowmeter includes the following specific steps: A detection pulse is superimposed onto the main excitation current of the electromagnetic flowmeter using a parallel injection method to obtain a detection pulse current; based on the detection pulse current, an excitation detection signal is obtained.

[0008] Preferably, obtaining the excitation detection feature vector includes the following steps: Excitation detection eigenvector F, = ,in In order to maintain consistency, Time constant The reciprocal, The zero-point offset trend, This refers to the lag time.

[0009] Preferably, the step of inputting the excitation detection feature vector into the improved decision tree model and outputting the electrode state result includes the following steps: A training set for constructing a decision tree model is collected. The training set consists of several sets of electrode interface state samples under different sulfidation degrees. Each set of samples contains an excitation detection feature vector and a corresponding electrode state label. The electrode state label is obtained by combining an electrode accelerated sulfidation aging test with interface impedance detection. Based on the training set, construct candidate... - Neighborhood; Candidates are selected using the sparrow search algorithm. -Optimize the neighborhood radius of the neighborhood to obtain the optimal neighborhood radius; Based on the optimal neighborhood radius, a decision tree model is constructed; The excitation detection feature vector is normalized to obtain the normalized excitation detection feature vector; the normalized excitation detection feature vector is then input into the improved decision tree model to output the electrode state result.

[0010] Preferably, the construction candidate - Neighborhood, including the following steps: Calculate the training set in terms of features The absolute distance between samples For the k-th feature dimension, the absolute distance represents the distance between two samples in that feature dimension. The numerical difference corresponds to the difference in the degree of degradation of the two electrode interfaces in this dimension: ; in, Indicates sample and samples In features The absolute distance on, Indicates sample The 1 eigenvalue, Indicates sample The eigenvalues, m and Both are sample indices, and k is the feature index; Based on the absolute distance, candidate samples are obtained for each sample. - Neighborhood, the - Neighborhood is used to filter a set of samples that are similar to the current sample electrode interface state.

[0011] Preferably, the candidate search algorithm is used to select candidates. - Optimize the neighborhood radius of the neighborhood to obtain the optimal neighborhood radius, including the following steps: The sparrow search algorithm is initialized by A population consisting of individual sparrows, each sparrow corresponding to a 4-dimensional neighborhood radius combination. The fitness function of the sparrow search algorithm is: ; in, This indicates the use of the neighborhood radius combination corresponding to the p-th sparrow. The calculated average value of the boundary mixed attribute dependency, Indicates the use of neighborhood radius combination The k-th radius Calculated features The boundary mixing attribute dependency, which is the ability of a single feature dimension to distinguish different electrode interface states; The sparrow search algorithm iterates through a fitness function to ultimately obtain the optimal combination of neighborhood radii. Then the kth feature The optimal neighborhood radius is The optimal neighborhood radius is used to match the numerical distribution characteristics of the corresponding feature, so that the feature can distinguish the state of the electrode interface to the best extent.

[0012] Preferably, the step of adjusting the excitation waveform of the electromagnetic flowmeter based on the electrode state results to obtain a first excitation waveform correction signal includes the following specific steps: The baseline excitation waveform parameter vector of the electromagnetic flowmeter is Construct a strategy mapping function to map the baseline excitation waveform parameter vector as... The input is fed into the strategy mapping function to obtain the adjustment amount of the baseline excitation waveform parameter vector, thereby obtaining the first excitation waveform correction signal.

[0013] Preferably, obtaining the excitation waveform correction feature vector includes the following specific steps: The excitation waveform correction feature vector includes: the average energy of the absolute value of the excitation waveform current signal, the variance energy of the excitation waveform, the symmetry difference value of the charge in the positive and negative half-cycles of the excitation waveform, the duration of the excitation cycle, and the amplitude increment of the enhanced excitation segment.

[0014] Preferably, the step of inputting the excitation waveform correction feature vector into the improved reinforcement learning model and outputting the second excitation waveform correction signal includes the following specific steps: Build an improved reinforcement learning model; The excitation waveform correction feature vector is normalized, and the normalized excitation waveform correction feature vector is input into the reinforcement learning model to obtain the second excitation waveform correction signal.

[0015] Preferably, the construction of the improved reinforcement learning model includes the following specific steps: Construct a Markov decision process; based on the Markov decision process, construct a local dynamics model, solve the local dynamics model using a differential dynamic programming algorithm, and obtain the updated policy function.

[0016] This invention provides a self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions, which involves machine learning technology and has the following beneficial effects: (1) The decision tree model is used to identify the electrode state of the excitation detection feature vector. It can quickly complete the mapping output from four-dimensional continuous features to the state category of the electrode interface. The model structure is simple and the inference delay is low. It can output four types of discrimination results in real time: stable state, polarization enhancement state, deposition enhancement state, and obvious instability state. It provides clear and explicit state basis for subsequent excitation waveform adjustment and ensures the real-time performance and effectiveness of the electrode state identification link.

[0017] (2) An improved decision tree model is adopted, which uses variable precision neighborhood rough set and sparrow search algorithm to adaptively optimize the neighborhood radius of continuous features. The boundary mixed attribute dependency is used as the node splitting measure, which fundamentally solves the inherent defects of traditional neighborhood rough set and decision tree. Traditional neighborhood rough set dependency only calculates the proportion of positive domain samples that can determine the classification 100%, completely discarding the uncertain samples containing classification information in the boundary domain. However, the dynamic characteristics of the electrode interface under sulfur-resistant conditions are highly time-varying and nonlinear. About 30%-40% of the effective samples will fall into the boundary domain. Traditional methods directly discard this part of the information, resulting in a serious decrease in classification accuracy. The boundary mixed attribute dependency proposed in this invention integrates the positive domain dependency of features on decision and the uncertainty of the boundary domain. By reasonably allocating the weights of the two through a trade-off factor, the boundary domain information that was originally discarded is transformed into an effective classification basis. At the same time, combined with the sparrow search algorithm, the optimal neighborhood radius is adaptively optimized for each feature, avoiding the overfitting or underfitting problems caused by a fixed neighborhood radius. It effectively solves the problems of coarse division and easy misjudgment when traditional decision trees process continuous attributes, making the electrode state discrimination results more consistent with the actual characteristics of sulfur-resistant working conditions.

[0018] (3) This invention adopts a two-stage excitation correction architecture based on discrete state-based coarse adjustment of the excitation waveform and reinforcement learning-based fine adjustment of the excitation waveform. This solves the core contradiction that a single adjustment method cannot simultaneously satisfy the rapid suppression of sudden changes and the continuous compensation of slow changes under sulfur-resistant conditions. This is also one of the key designs that distinguishes this invention from the prior art. Under sulfur-resistant conditions, electrodes may experience sudden severe polarization or large-area deposition (such as a sudden increase in the concentration of hydrogen sulfide in the medium). If only reinforcement learning is relied upon for incremental fine adjustment, it will lead to adjustment lag, severe distortion of measurement signals, or even failure. Therefore, this invention adds a coarse adjustment stage based on discrete state before reinforcement learning fine adjustment. It presets targeted parameter adjustment strategies for four types of electrode states. The response time of this coarse adjustment stage is ≤1 excitation cycle, which can complete the correction of large deviations at the first moment of electrode state change, avoid the collapse of the measurement system, and lay a stable foundation for subsequent fine adjustment.

[0019] Sulfation corrosion and deposition at the electrode interface is a slow, continuous degradation process. Coarse adjustment based on discrete states can only address large state deviations and cannot continuously compensate for small, gradual impedance changes, leading to measurement drift over long-term operation. Therefore, this invention adds a fine adjustment stage based on improved reinforcement learning to the coarse adjustment, constructing a closed-loop calibration mechanism for excitation stability. Using excitation waveform correction features and flowmeter output stability features as observation inputs, and updating the confidence region constraint strategy through online fitting of a local linear dynamic model, adaptive fine adjustment of excitation waveform parameters is achieved. Through graded dynamic adjustments of parameters such as excitation current, switching frequency, transition time, and enhanced excitation, the measurement impact caused by abrupt changes in electrode state is quickly suppressed, while continuously compensating for long-term, slowly changing impedance drift. This fundamentally counteracts measurement interference caused by electrode sulfation and polarization, achieving the dual goals of rapid response and continuous stability. This fine adjustment stage can continuously track the slow time-varying characteristics of the electrode interface, compensating for small deviations that coarse adjustment cannot cover, solving the problem that traditional open-loop adjustment cannot adapt to long-term operating condition changes. The two-level adjustment mechanism works in tandem, avoiding both the shortcomings of insufficient accuracy in coarse adjustment and the risks of slow convergence and easy divergence in fine adjustment, thus achieving the dual goals of rapid response and continuous optimization. Attached Figure Description

[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a flowchart illustrating the steps of a self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions proposed in this invention. Figure 2 This is a step hierarchy diagram of obtaining electrode state results in the excitation stability self-calibration method for an electromagnetic flowmeter under sulfur-resistant conditions proposed in this invention; Figure 3 This is a step hierarchy diagram of obtaining the excitation waveform correction feature vector in the excitation stability self-calibration method of an electromagnetic flowmeter under sulfur-resistant conditions proposed in this invention. Detailed Implementation

[0022] The technical solutions of 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.

[0023] Please see Figures 1-3 The present invention provides a technical solution: a self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions.

[0024] Step S1: Collect the excitation detection signal of the electromagnetic flowmeter and extract features from the excitation detection signal to obtain the excitation detection feature vector.

[0025] This step is used to collect the excitation detection signal from the electromagnetic flowmeter and extract features from the signal to obtain the excitation detection feature vector. Specifically, to obtain the excitation detection signal, a detection pulse is superimposed onto the main excitation current using a parallel injection method. This method is achieved by connecting a detection branch consisting of a high-speed switch and a programmable precision-controlled current source in parallel within the excitation coil drive circuit, ensuring that the injection of the detection pulse does not interfere with the constant current characteristics of the main excitation.

[0026] The detection pulse generated by this parallel branch represents a narrow-pulse current detection pulse with the same direction as the main excitation current in the current half-cycle, and its amplitude is... Set to 1% to 5% of the main excitation current amplitude, amplitude The preferred amplitude is 2%. This amplitude ensures that the electrode generates a collectable and effective response signal without interfering with the stable output of the main excitation current. The detection pulse width... Set to 1 millisecond to 5 milliseconds for the probe pulse width. The preferred pulse width is 3 milliseconds. This width is suitable for the conventional excitation cycle of the electromagnetic flowmeter, ensuring complete acquisition of the response characteristics of the electrode interface without the pulse duration obstructing the main excitation timing, thus guaranteeing the normal operation of the excitation system. Ultimately, the current-time relationship of this probe pulse is: ; in, The current value of the probe pulse at time t is a small, narrow pulse excitation superimposed on the main excitation current. It is used to detect the transient impedance response at the electrode interface without interfering with the constant current operation of the main excitation. To detect the amplitude of the pulse, () represents a rectangular window function, and t represents the time variable. This indicates the start time of the probe pulse injection. Indicates the detection pulse width. This indicates that when time t is at [ Within the interval, the function value is 1, and when time t is not within [...]. Within the interval, the function value is 0.

[0027] To ensure that the detection process does not interfere with the steady-state operation of the main excitation and the accuracy of signal acquisition, the detection pulse is injected once during the current stabilization period of both the forward and reverse excitation phases within each main excitation cycle. The current stabilization period refers to the steady-state period after the transient transition process of the main excitation current after the forward and reverse switching is completed, during which the amplitude of the excitation current remains constant without fluctuations or distortions. In other words, the deviation of the instantaneous value of the excitation current from its rated constant value does not exceed ±0.5%, and the current variance of five consecutive sampling points is less than 0.1% of the square of the rated excitation current amplitude. At this time, the excitation coil current is stable, and the injected detection pulse can obtain a stable and effective excitation detection signal.

[0028] Simultaneously with the injection of the probe pulse, an instrument differential amplifier with an input impedance of not less than 100MΩ and a common-mode rejection ratio of not less than 100dB acquires the differential potential signal between the two measuring electrodes. This differential potential signal is the excitation probe signal to be acquired. The signal output by the amplifier is fed into an anti-aliasing analog low-pass filter with a cutoff frequency of 2kHz for filtering, and then processed by an analog-to-digital converter synchronized with the probe pulse trigger signal to set the sampling frequency. Complete the digital acquisition of the signal, sampling frequency The preferred frequency is 10kHz. Here, the cutoff frequency of the anti-aliasing filter is set to be less than half of the sampling frequency, i.e., 5kHz, which can effectively suppress high-frequency noise and prevent spectral aliasing, while preserving the effective frequency band of the probe pulse response signal.

[0029] The acquisition time window fully covered the entire duration of the probe pulse, as well as the electrode interface relaxation phase after the pulse ended. The total acquisition time was denoted as [missing information]. , The preferred 10ms timeframe fully covers the entire process of the probe pulse and the corresponding relaxation phase; after analog-to-digital conversion, a discretized differential voltage signal sequence is obtained. , The differential potential between the two measuring electrodes, whose waveform changes directly reflect the change in the electrode interface impedance, where n is the sampling point index. , The total number of sampling points satisfies .

[0030] The acquired differential voltage signal sequence Perform digital preprocessing to determine the DC component of the signal. : Differential voltage signal sequence Subtract DC component A zero-mean sequence is obtained. : Then, the zero-mean sequence A digital bandpass filter with a passband range of 10Hz to 1kHz is used to suppress power frequency interference and high-frequency noise, and the final output is a pre-processed excitation detection signal sequence. .

[0031] Based on excitation detection signal sequence Four quantitative dynamic response features of the electrode interface were extracted. The first feature is response consistency. This characterizes the symmetry of the equivalent impedance at the interface of the two measuring electrodes. When non-uniform sulfide corrosion occurs on the electrodes, the impedance difference between the two electrodes increases, and the response consistency decreases accordingly. The calculation is performed within the detection pulse action time window (corresponding to the starting index of the sampling point). to ,in, To detect the total number of sampling points within the pulse action window, )sequence The variance, i.e. The first characteristic characterizes the difference in consistency of the response of the two electrodes to the probe excitation. The second characteristic is the reciprocal of the polarization recovery rate. The time constant characterizes the ability of polarization charge to dissipate at the electrode interface. The more severe the electrode polarization, the larger the polarization capacitance, and the slower the charge dissipation. Larger, reciprocal The smaller the value, the better. The time constant is obtained by fitting the response waveform during the relaxation phase using a single exponential function. Take its reciprocal as the feature quantity, and use it to define the sampling interval after the end of the detection pulse in the entire acquisition window. ~N-1 is defined as the relaxation phase at the electrode interface. The relaxation phase after the pulse ends... Data performed using a single exponential function The time constant was obtained through fitting and the least squares method. and take its reciprocal As a characteristic, this feature directly reflects the dissipation rate of polarization charge at the electrode interface. The third feature is the zero-point shift trend. This value characterizes the residual polarization potential of the electrode pair under no-excitation conditions. Sulfide deposition and polarization charge accumulation on the electrode surface lead to a DC potential shift. The larger the value, the more severe the residual polarization at the interface. A continuous value is taken at the end of the electrode interface relaxation stage. One sampling point, To determine the number of sampling points for the relaxation terminal features, 10% of the total relaxation sampling points are selected, and the sampling interval is defined as N-. ~N-1, calculate the sequence within this interval The average value, i.e. This feature characterizes the residual potential shift of the electrode pair when there is no excitation. This serves as the sampling point index. The fourth feature is the signal hysteresis degree, LH, which characterizes the signal delay caused by the capacitive effect of the electrode interface impedance. The larger the interface polarization capacitance, the more pronounced the signal hysteresis, and the larger this value. First, an ideal rectangular window sequence with the same shape as the physical detection pulse is preset. Its amplitude is 1, the starting time is 0, and the width is Each sampling point; calculate During the detection period Normalized cross-correlation function: ; in, For the normalized cross-correlation function value, This is the delay value, and its range is [-]. ]; Find the cross-correlation value Reaching the maximum integer delay Then the lag time This characteristic reflects the signal transmission delay caused by interface impedance.

[0032] Finally, the output of step S1 is an excitation detection feature vector F composed of these four scalar features. The excitation detection feature vector F is then normalized using Z-score to obtain the normalized excitation detection feature vector. This vector comprehensively characterizes the dynamic response characteristics of the current electrode interface under sulfur-resistant conditions and will be used as the input for step S2.

[0033] Step S2: Input the excitation detection feature vector into the improved decision tree model and output the electrode state result.

[0034] The specific implementation of step S2 is an electrode interface state discrimination step based on an improved decision tree. The input to this step is the normalized excitation detection feature vector from step S1. The output is a discrete state category label characterizing the health of the electrode interface. Its set of values ​​is Y. .

[0035] This step employs a decision tree model based on a variable-precision neighborhood rough set and sparrow search algorithm to map the continuous features of excitation detection to the discrete states of the electrode interface. , where G() represents the decision tree model function.

[0036] A training set for constructing the decision tree model is collected. This training set consists of several groups of electrode interface state samples under different sulfidation degrees. Each group of samples includes an excitation detection feature vector and a corresponding electrode state label. The electrode state label is obtained through accelerated sulfidation aging tests combined with interface impedance detection. Specifically, the improved decision tree model is trained and constructed based on a pre-built labeled training dataset, which contains... A sample, denoted as ,in Let be the feature vector of the m-th sample. Labels for discrete state categories.

[0037] It should be noted that the discrete state category labels in the training set are the actual electrode interface state labels corresponding to the samples. The sample labels were calibrated using completely objective quantitative criteria. First, under the baseline working conditions of assembling a brand-new, clean electrode on the flow meter, connecting a standard calibration solution with constant conductivity, and ensuring stable flow rate, no air bubbles in the full pipe, constant temperature, and proper installation, a sufficient number of samples were collected, and the response consistency CR and the reciprocal of the polarization recovery rate were statistically obtained. The initial statistical distribution of the four features—zero-point offset trend (DZ), signal hysteresis (LH)—is based on the initial mean of each feature. with standard deviation Define the normal fluctuation range, and then conduct accelerated sulfidation and aging tests on electrodes in a hydrogen sulfide medium environment. Simultaneously observe the physical state of the electrodes and track the characteristic change trajectory to determine the critical judgment threshold of each characteristic from normal fluctuation to interface degradation. The stable state corresponds to all four characteristics being within ±2 of the initial mean. Within the normal fluctuation range, the polarization enhancement state corresponds to the reciprocal of the polarization recovery rate. 3 below the initial mean At or above, the zero-point shift trend DZ and signal hysteresis LH corresponding to the deposition enhancement state both exceed the initial mean of 2.5. A state of significant instability corresponds to at least three characteristics exceeding the initial mean by 3. And or any one of the above characteristics deviates from the initial mean by 4 All sample labels were determined strictly according to the statistical threshold criteria established in this experiment.

[0038] Decision tree model The construction of the node is a recursive node splitting process, the key of which lies in the improved node splitting metric and continuous attribute processing mechanism.

[0039] For the node currently to be split and its corresponding sample subset First, continuous numerical features need to be processed. For Any two samples and In its first Features The neighborhood similarity is calculated using a variable-precision rough set model that combines geometric and algebraic similarity. Specifically, the feature similarity is first calculated. k=1,2,3,4 correspond to respectively Calculate the absolute distance between samples independently. , The absolute difference between two samples on the k-th feature corresponds to the difference in the degree of degradation of the two electrode interfaces on this feature dimension. The smaller the distance, the closer the sulfidation / polarization degrees of the two samples. Sulfidation corrosion and electrochemical polarization at the electrode interface are continuous and gradual electrochemical processes. Electrodes with similar degrees of degradation have closer values ​​for their interface response characteristic parameters. Indicates sample The 1 eigenvalue, Indicates sample The Each feature value is defined. Based on the absolute distance mentioned above, a sample is defined. In features Single feature variable precision candidate - Neighborhood , - Neighborhood For features whose distance from the current sample is less than the neighborhood radius All sample sets correspond to a group of electrode interface state samples with similar degrees of degradation, that is, sample groups within the same electrode state cluster. The characteristic parameters of the same type of electrode state have spatial clustering characteristics, which conform to the distribution law of continuous and gradual change in electrochemical performance. , This represents the neighborhood radius of the k-th feature in the excitation detection feature vector, used to filter the set of samples similar to the current sample electrode interface state. It should be noted that... To define the distance threshold for the neighborhood, used to quantify the numerical boundary of similar electrode interface states, the radius corresponds to the granularity of electrode state classification. Samples within the same electrode state category exhibit feature value fluctuations within a certain range; this range forms the physical basis of the neighborhood radius. The search range is set to [0.01]. 0.5 ], Let the standard deviation be the k-th feature of the training set. This is a variable precision parameter, with a value of 0.1. For the sample The category of electrode condition to which it belongs.

[0040] The neighborhood radius Not a fixed value, based on candidates - Neighborhood, determined by the sparrow search algorithm for the current node. and characteristics Adaptive optimization is used to determine the optimal neighborhood radius combination for each node based on four features. Specific parameters and procedures are as follows: population size P=30, maximum number of iterations is 50, discoverers comprise 70%, followers 30%, and watchdogs 10%, with a discoverer step size factor... =0.5, follower step size factor =0.8, safety threshold ST=0.6; each sparrow corresponds to a 4-dimensional position vector. The four dimensions of the vector correspond to the candidate neighborhood radii of four features: response consistency, reciprocal of polarization recovery rate, zero-point offset trend, and signal hysteresis. In other words, each position vector represents a set of four-feature neighborhood radii suitable for the current node. The fitness function of the Sparrow Algorithm is the set of neighborhood radius combinations. The calculated average boundary mixture attribute dependency is aimed at maximizing this average to improve the classification ability of each feature. The specific calculation formula is as follows: ; in, This indicates the use of the neighborhood radius combination corresponding to the p-th sparrow. The calculated average value of the boundary mixed attribute dependency, Indicates the use of neighborhood radius combination The k-th radius Calculated features The boundary hybrid attribute dependency is a classification dependency index that integrates information from the positive domain and the boundary domain. It is a single-dimensional feature with the comprehensive ability to distinguish different electrode interface states. The higher the value, the more effectively the feature can distinguish different degrees of sulfidation / polarization. It also integrates the deterministic information of samples with clear states and the uncertain information of samples with transitional states. k is the feature index.

[0041] Boundary Mixed Attribute Dependency Sample subset for the current split node q The boundary hybrid attribute dependency proposed in this invention simultaneously integrates the deterministic contribution (positive domain information) and the uncertain contribution (boundary domain information) of features to the decision classification, solving the problem of low classification accuracy caused by traditional dependency relying solely on positive domain information. The calculation formula is as follows: ; in, For decision-making In features On - Neighborhood The lower approximate set under the relation, Represents decision class In features On - Neighborhood Boundary domain under relation, As a weighting factor, This is used to adjust the weight of the uncertainty information contained in the boundary domain in the dependency calculation. This represents the subset of samples corresponding to the split node q. Indicates the number of sample subsets. ={ ∈ | All samples within their neighborhood belong to the same decision class. The sample set represents the samples whose classification can be determined by this feature, i.e., positive domain samples. All samples contain the same neighborhood. and non The sample set represents samples whose classification cannot be fully determined by this feature but contain classification information. The union of approximate sets under all decision classes, i.e., the current feature. The total number of all samples that can be classified completely and correctly. The sum of the cardinalities of the boundary domains of all decision classes, i.e., the current feature. The total number of all samples that contain categorical information but have uncertainty.

[0042] It should be noted that the trade-off factors The value is 0.3, which is determined by performing a grid search on the validation set (search range [0,1], step size 0.05). This value represents the weight of the boundary domain uncertainty information in the dependency calculation. A value of 0.3 means that the accuracy of the positive domain classification is given priority, while the boundary domain information is used appropriately to improve the classification accuracy.

[0043] The sparrow search algorithm simulates the position update rules of discoverers, followers, and watchers to combine the neighborhood radii corresponding to each individual sparrow. Iterative optimization is performed, with the optimization objective being to maximize the fitness function. When the maximum number of iterations (50) is reached, or the change in the optimal fitness value over 10 consecutive iterations is less than... The iteration stops when any condition is met. After the iteration stops, the optimal neighborhood radius combination that maximizes the dependency of the boundary mixing properties is finally obtained. This optimal combination will be directly applied to the feature splitting calculation of the current node to be split. The optimal neighborhood radius combination is then obtained. Then, extract each feature from it. The corresponding optimal neighborhood radius The optimal neighborhood radius is used to match the numerical distribution characteristics of the corresponding feature, so that the feature's ability to distinguish the state of the electrode interface is optimal. For each feature... and its corresponding optimal radius Calculate the boundary mixed attribute dependency corresponding to this feature. This is then used as the feature splitting metric for the current node. The core advantage of this splitting metric is that it can simultaneously take into account the positive domain dependence of features on the decision classification and the uncertainty information contained in the boundary domain, providing a scientific basis for determining node splitting.

[0044] Iterate through all four electrode interface features and calculate the radius of each feature in its optimal neighborhood. Boundary Mixed Attribute Dependency The feature with the highest dependency is selected as the optimal splitting feature for the current node q. Optimal splitting characteristics The feature that best distinguishes the electrode state samples within the current node is the interface characteristic index that best reflects the differences in electrode states. If the dependency of all features is 0, then the splitting stops and the node is marked as a leaf node.

[0045] For the selected optimal splitting feature First, extract the sample subset of the current node. The feature values ​​of all samples under this feature are sorted in ascending order. The midpoint of the feature values ​​of two adjacent samples is selected as the candidate splitting threshold. Each candidate threshold is substituted into the sample subset for pre-splitting. The comprehensive sample purity of the left and right child nodes after splitting is calculated for each candidate threshold. The comprehensive sample purity is calculated using the weighted Gini coefficient, and the formula is as follows: ; in, The Gini coefficient is used to measure the purity of the electrode states of the left and right child nodes after a node splits. The smaller the Gini coefficient, the more uniform the electrode state categories within the child nodes after the split, and the better the classification effect. For eigenvalues ​​≤ The number of samples in the left child node, For eigenvalues ​​> The number of samples in the right child node. Let Gini coefficient be the value of the left child node. For the left child node belonging to the category Number of samples, Gini coefficient of right child node The calculation method is the same as for the left child node. A smaller Gini coefficient indicates higher sample purity; therefore, selecting a coefficient that... Minimum threshold As the optimal splitting threshold Optimal splitting threshold The optimal characteristic critical value for distinguishing between two types of electrode states corresponds to the characteristic boundary point where the electrode interface transitions from one state category to another.

[0046] Based on the optimal splitting threshold Complete node partitioning: If the optimal splitting feature value of the sample satisfies If the number of samples is less than the minimum sample threshold, the node is assigned to the left child node; otherwise, it is assigned to the right child node. For each child node generated by the split, the entire process of adaptive neighborhood radius optimization, feature selection, threshold determination, and node splitting is recursively executed until a preset model stopping condition is met. The stopping condition includes the current node having fewer samples than the minimum sample threshold. The optimal value is 10, to ensure model robustness and that the decision tree branch depth reaches the maximum limit. The optimal value is 8 to prevent overfitting, all samples within a node belonging to the same electrode state category, and other issues. When a node meets the stopping condition, it is designated as a leaf node, and the leaf node outputs the electrode state category. The decision tree is determined using a majority voting rule based on samples within each node. Following the above process, the tree iterates and grows continuously, constructing a complete binary decision tree structure, ultimately resulting in an improved decision tree model that has achieved convergence during training. After the model training is complete, cost complexity pruning (CCP) is used for post-pruning, and the pruning parameters are the complexity parameters. The selection method, which yields the highest classification accuracy on the validation set, was determined through 5-fold cross-validation. The value is used as the final pruning parameter.

[0047] In the online discrimination phase, the excitation detection feature vector extracted in real time in step S1 is input into the trained improved decision tree model. Starting from the root node of the decision tree, the model compares the values ​​of each dimension of the feature vector with the splitting rules of the current node one by one, and searches down the tree structure layer by layer. Finally, the discrete state category label of the electrode interface state, i.e., the electrode state result, is output. .

[0048] Step S3: Based on the electrode state results, adjust the excitation waveform of the electromagnetic flowmeter to obtain a first excitation waveform correction signal. Extract features from the first excitation waveform correction signal to obtain an excitation waveform correction feature vector.

[0049] The specific implementation of step S3 is an adaptive renormalization step based on state discrimination of the excitation waveform. The input to this step is the electrode interface state discrimination result from step S2. Its value belongs to the discrete state set. .

[0050] During this step, the baseline excitation waveform parameter vector ,in This indicates the rated amplitude of the main excitation current, typically 100mA, with a hardware-allowed range of [50mA, 200mA]. The constant current amplitude of the main excitation circuit under baseline conditions determines the magnetic induction intensity of the main magnetic field generated by the excitation coil, which directly affects the amplitude of the induced signal generated by the fluid cutting the magnetic field lines and the anti-interference capability. When electrode sulfidation leads to an increase in interface impedance and attenuation of the induced signal, the signal strength can be compensated by adjusting this amplitude. and These represent the baseline durations for forward and reverse excitation, respectively. and The typical value is 20ms. and The switching frequency of the excitation magnetic field directly affects the degree of accumulation of electrochemical polarization charge at the electrode interface. This indicates the forward-to-reverse switching transition time, referring to the total time it takes for the current to linearly decrease from the forward rated value to 0 and then linearly rise back to the reverse rated value. A typical value is 2ms, with a hardware-allowed range of [1ms, 10ms]. This indicates the reverse-to-forward switching transition time, referring to the total time it takes for the excitation current to linearly decrease from the reverse rated value to 0, and then linearly rise back to the forward rated value. A typical value is 2ms. and The switching transition time between forward and reverse directions, and between opposite directions, determines the rate of change of the magnetic field. This represents the current amplitude during the short-term enhanced excitation phase, with a baseline value of 0 and a hardware-allowed range of [0, 300mA]. Strengthen excitation current The duration of application is set to a baseline value of 0, with a hardware-allowed range of [0, 5ms]. and The baseline values ​​are all 0. and These represent the amplitude and duration of the short-term enhanced excitation segment, respectively, used to generate instantaneous magnetic field disturbances.

[0051] The baseline excitation waveform parameter vector This indicates one complete excitation cycle of the electromagnetic flowmeter. Current-time waveform within Then the excitation cycle The typical value is 44ms.

[0052] Constructing policy mapping functions , This function will input the state category. Mapped to a baseline parameter vector for the excitation waveform Adjustment amount , To adjust the baseline excitation parameters based on the current electrode condition, the incremental correction includes adjustments to seven parameters, achieving discrete coarse adjustment of the excitation waveform. This indicates the adjustment increment of the rated amplitude of the main excitation current. This is the adjustment increment for the duration of positive steady-state excitation. This represents the adjustment increment for the duration of reverse steady-state excitation. This indicates the increment for adjusting the transition time when switching from forward excitation to reverse excitation. This indicates the increment for adjusting the transition time when switching from reverse excitation to forward excitation. This indicates the adjustment increment of the current amplitude during the short-time enhanced excitation phase. This indicates the adjustment increment for the duration of the short-term enhanced excitation phase.

[0053] Mapping rules According to the status Different and presupposed: when In the polarization enhancement state, the adjustment strategy prioritizes shortening the unidirectional excitation duration to increase the switching frequency, i.e. , And ensure that the adjusted forward and reverse duty cycles are balanced, where the reduction factor The range is between 0.1 and 0.3; when In the deposition enhancement state, the adjustment strategy is to introduce a short-duration enhanced excitation segment during the stable phase of the excitation cycle to generate a stronger instantaneous magnetic field disturbance to weaken the deposits on the electrode surface. Specifically, this is achieved by increasing the current amplitude during the enhanced excitation segment. Its duration Among them, the strengthening coefficient The range is 1.2 to 1.5, duty cycle factor The range is 0.05 to 0.1, representing the proportion of the enhanced excitation segment duration to the entire excitation cycle. To symmetrically accommodate this enhanced segment within each excitation half-cycle, it is necessary to... and Make fine adjustments. The adjustment amount is... and After adjustment, the normal settling periods for forward and reverse excitation are respectively... and The enhanced segments are evenly embedded in the middle of their respective half-cycles.

[0054] when When the signal is in a significantly unstable state, the adjustment strategy is to use a significantly smoother transition excitation to stabilize the severely drifting signal. This is achieved by substantially increasing the transition time of the current commutation to reduce the rate of magnetic field change; the adjustment amount of the transition time is... , The transition factor k ranges from 2.0 to 5.0. After adjustment, the transition time is extended to k times the baseline value.

[0055] when When in a stable state, adjust the quantity vector The zero vector, i.e., the baseline excitation waveform parameter vector. constant.

[0056] After performing the above adjustments on the baseline excitation waveform parameters, the updated excitation waveform operating parameter vector is obtained. Based on the updated parameter vector , The corrected signal of the first excitation waveform after renormalization is obtained. The signal is in one complete excitation cycle. ,in To adjust the rated amplitude of the main excitation current in the post-excitation circuit, This refers to the duration of positive steady-state excitation within a single excitation cycle after adjustment. This refers to the duration of reverse steady-state excitation within a single excitation cycle after adjustment. This refers to the transition time between forward and reverse excitation after adjustment. This refers to the transition time between reverse and forward excitation after adjustment. To adjust the current amplitude of the short-term enhanced excitation section, This refers to the duration of the short-term enhanced excitation phase after adjustment.

[0057] Subsequently, the first excitation waveform correction signal was... Feature extraction is performed to obtain the excitation waveform correction feature vector. The definitions and calculation methods of each characteristic parameter are as follows: , The average energy characterizes the absolute value of the excitation waveform current signal, reflecting the overall intensity level of the waveform; , Characterizing the excitation waveform relative to its current mean ( The variance energy of the waveform current reflects the degree of fluctuation of the waveform current; , The value characterizes the symmetrical difference in charge quantity between the positive and negative half-cycles of the excitation waveform, where the first half is the period of forward excitation and the transition from forward to reverse, and the second half is the period of reverse excitation and the transition from reverse to forward. , The actual duration of the current excitation cycle is determined by the updated forward and reverse excitation durations and the transition time. , Characterizing the amplitude increment of the enhanced excitation segment, where , It has a non-zero value only under the deposition enhancement state, and is 0 under other conditions.

[0058] Finally, step S3 outputs two core results: one is the generated first excitation waveform correction signal. The signal is sent to the excitation drive circuit to achieve the actual adjustment of the excitation magnetic field of the electromagnetic flowmeter; secondly, the calculated excitation waveform correction feature vector is used. The excitation waveform correction eigenvector After Z-score normalization, the normalized excitation waveform correction feature vector is obtained, which is used as the input for step S4 to quantitatively describe the characteristics of this excitation parameter adjustment action and provide data support for subsequent feedback optimization.

[0059] Step S4: Input the excitation waveform correction feature vector into the improved reinforcement learning model and output the second excitation waveform correction signal to achieve self-calibration of excitation.

[0060] This step addresses the slow and continuous degradation trend of the electrode interface by making small, continuous adjustments to parameters such as the excitation current amplitude, forward and reverse duration, and transition time. This continuously compensates for the gradual impedance changes that cannot be covered by coarse adjustments, solving the problem that traditional open-loop adjustments cannot adapt to slow changes in long-term operating conditions, and achieving a long-term stable excitation calibration effect.

[0061] The input for this step is the normalized excitation waveform correction feature vector from step S3. This vector quantization describes the action characteristics of the excitation waveform reshaping strategy executed in step S3.

[0062] Construct a reinforcement learning model based on a confidence region iterative linear quadratic Gaussian. First, construct a Markov decision process and define the state. The observation vector at time t is the eigenvector corrected by the excitation waveform. Stability evaluation characteristics of the current flowmeter output signal Together constitute, that is , The observation vector, composed of the excitation waveform correction characteristics and the flowmeter measurement stability characteristics, objectively characterizes the degree of matching between the electrode interface state at time t and the current excitation parameters. It represents the state of the controlled object in the excitation calibration system. The excitation waveform characteristics correspond to the currently applied control input, and the measurement stability characteristics correspond to the output response of the electrode interface, together reflecting the degree of deterioration in the operating condition. The zero-point drift of the flowmeter's measurement signal characterizes the degree of signal reference offset. ,in Continuous under zero flow conditions =Measured voltage values ​​from 100 sampling points The asymmetry of the forward and reverse measurement signals reflects the influence of the excitation magnetic field symmetry on the measurement. ,in , These are the average measured voltages during the forward and reverse excitation phases within one excitation cycle, respectively. To measure the standard deviation of signal fluctuations and quantify the stationarity of the signal, , for The average voltage of each sampling point.

[0063] action For the excitation waveform parameter vector described in step S3 The continuous fine-tuning amount, i.e. Its physical meaning is the incremental change of each waveform parameter at time t. , , , , , , Actions exceeding the specified range will be truncated to the corresponding boundary value. State transition probability. Indicates the current state Next, take parameter adjustment action. Then, the state evolved to The probability distribution of actions. The continuous fine-tuning increment of the 7-dimensional excitation waveform parameters and the control output of excitation self-calibration directly affect the excitation drive circuit. The output is used to make minor adjustments to 7 parameters, including the main excitation amplitude, forward and reverse duration, switching transition time, and reinforcement section parameters. The range of action is limited by the adjustable boundary of the hardware circuit, ensuring that the adjustment is within the range that the hardware can execute.

[0064] reward function Adopting a quadratic form: ; in, This is a quadratic reward function, consisting of a state penalty term and an action penalty term. It quantifies the overall control effect of the excitation adjustment action and is a core indicator for measuring calibration quality. The first term... The penalty measures zero-point drift, asymmetry, and noise of the measurement signal, corresponding to the goal of improving measurement accuracy; the second item Significant adjustments to the excitation parameters are penalized by constraints that ensure the stable operation of the excitation system. This represents the state at time step t. This represents the action at time step t. Here, T represents the stability evaluation feature at time step t, and T is the transpose sign. and The weight matrix is ​​positive definite, Q=diag(100,50,20), which corresponds to the weights of zero drift, asymmetry, and noise, respectively, and R=0.01. ( (This is a 7th-order identity matrix). Q corresponds to the penalty weights for the three measurement stability indices: zero-point drift, asymmetry, and noise. The larger the weight, the greater the impact of that index on the calibration effect. During optimization, priority should be given to ensuring the convergence of that index. R corresponds to the penalty weights for the adjustment amplitude of the seven excitation parameters. This is used to constrain the drasticness of parameter adjustments and avoid magnetic field oscillations caused by sudden changes in excitation parameters.

[0065] The reward function constrains measurement stability deviations while penalizing large adjustments to excitation waveform parameters, thus balancing measurement accuracy and excitation control stability.

[0066] The reinforcement learning model optimizes a stochastic linear Gaussian policy by alternating between policy evaluation and policy improvement based on a local model. , () represents the multivariate Gaussian distribution function. This represents the feedback gain matrix at time step. This represents the feedforward vector at time step t. Let represent the covariance matrix at time step t. Indicates the current operating condition. At that time, the output excitation parameter adjustment action is performed. The conditional probability strategy and control law of the excitation self-calibration closed-loop system, which outputs the corresponding optimal excitation parameter fine-tuning amount based on the current operating condition of the electrode interface and excitation matching, ultimately generates a second excitation waveform correction signal, is the core control output of the reinforcement learning fine-tuning stage. It can continuously track the slow and continuous sulfidation degradation characteristics of the electrode interface, iteratively optimize the control strategy online, compensate for the small, gradual impedance deviations that cannot be covered by discrete coarse-tuning, and achieve long-term adaptive and stable calibration of excitation parameters.

[0067] In each iteration, the algorithm first uses the current strategy. It continuously interacts with the excitation control process, and the collection length is =Trajectory data at 20 time steps Based on the trajectory data, a local linear Gaussian dynamic model is fitted using the weighted least squares method: a data matrix is ​​constructed. , Introducing exponentially decaying weights. , The time constant is 10 by default, and a diagonal weight matrix is ​​constructed. Solve the weighted least squares problem: ,in Let be the state transition matrix. This is the motion control matrix. Calculate the residuals. = Noise covariance matrix The dynamic model is updated every 5 calibration cycles to ensure tracking of the slow time-varying characteristics of the electrode interface. The local linear Gaussian dynamic model is then... ,in Given the working condition at time step t Fine-tuning of excitation parameters At that time, the operating condition will transition to the next moment. The probability law, This represents the working state vector at time step t. This represents the working state vector at time step t+1. This represents the state transition matrix at time step t. This represents the motion control matrix at time step t. The state covariance matrix at time step t represents the Gaussian distribution of the state. A locally linear Gaussian dynamic model is used to fit the state transition law, providing a mathematical model of the physical process of excitation parameter adjustment, electrode interface response, and measurement state change. It reflects the response law from excitation action to operating condition. Electrode sulfidation and degradation is a slow, continuous process. Under small-range parameter adjustments, the change in measurement state is approximately linear, which conforms to the small-signal response law of electrochemical systems.

[0068] Subsequently, in the fitted local dynamic model Under constraints, solve the stochastic optimal control problem with confidence region constraints. This problem is solved by optimizing the augmented cost function. To complete the policy update, among which Represents the mathematical expectation operator. To adjust rewards in real time, , For adaptive dual variables, It is a quadratic reward function.

[0069] Under the constraints of the fitted local linear Gaussian dynamics model, this invention employs an iterative linear quadratic Gaussian (iLQG, an engineering implementation of differential dynamic programming) algorithm with confidence region constraints to solve the stochastic optimal control problem with confidence region constraints. The specific process is as follows: Initial policy setting: Define the initial linear Gaussian policy as... The initial feedback gain matrix (Zero feedback to avoid unstable control in the initial stage), initial feedforward term (Zero bias, ensuring a neutral distribution of initial actions), initial covariance matrix ( (A 7th-order identity matrix, providing initial exploration noise); value function reverse iteration: from the end of the trajectory Begin by inversely calculating the quadratic approximation of the value function. ,in: , ,in, , These are the coefficients of the quadratic and linear terms of the state cost function. , These are the coefficients of the quadratic and linear terms of the action cost function. , The coefficients for the state-action cross-cost term; policy parameter update: based on the reverse iteration results, calculate the new policy linear feedback matrix. With feedforward vector : , .

[0070] Policy adjustment with confidence region constraint: To ensure the stability of policy updates, a KL divergence confidence region constraint is introduced. , Adjust the step size through line search ∈ The updated intermediate strategy Compared to the old strategy Weighted fusion yields a new strategy that satisfies constraints. ; Noise attenuation during exploration: To balance exploration and utilization, the strategy covariance matrix is ​​updated with exponential decay. Gradually reduce the noise intensity during exploration to improve the stability of later control.

[0071] After offline training is completed, the converged and optimized strategy model is deployed as a real-time excitation control controller and put into the online calibration process.

[0072] The following online closed-loop execution process achieves real-time and stable self-calibration of excitation parameters: 1. Calibration cycle setting: To balance the real-time performance of control with the computational burden of embedded devices, the reinforcement learning fine-tuning module performs excitation parameter fine-tuning every 10 excitation cycles (approximately 0.44 seconds); 2. Action execution and system stabilization waiting: Excitation parameter fine-tuning actions are generated based on the current strategy. And superimposed on the current excitation parameter vector. The updated excitation parameters are obtained. To avoid state observation errors caused by unstable control signals, wait for two excitation cycles (approximately 0.088 seconds) until the excitation system reaches a steady state before acquiring new electrode measurement signals to calculate the operating state at the next moment. 3. Experience Playback and Strategy Update Scheduling: Set up an experience playback buffer with a capacity of 10,000 to store the excitation control experience for each step. To reduce online computational pressure, every 20 calibration cycles, 64 empirical samples are randomly sampled from the buffer, triggering a dynamic model update in step 2 and a policy update in step 3; 4. Abnormal operating condition handling mechanism: If the reward value is lower than -100 for 5 consecutive time steps (indicating severe distortion of the electrode signal and abnormal excitation conditions), the current reinforcement learning fine-tuning process is paused, the current excitation parameters are kept unchanged, and a complete coarse-tuning process of steps S1~S3 is triggered to reinitialize the excitation parameter baseline; 5. Convergence judgment and pure exploitation mode switching: When the average reward value change within 100 consecutive calibration cycles is less than When the excitation control strategy has converged, the strategy covariance matrix is ​​determined to be... Setting it to 0 stops the exploratory noise output, enters the pure utilization mode, and maintains stable excitation parameter control.

[0073] Subsequently, the measurement output signal of the electromagnetic flowmeter under the new excitation parameters was collected, and the signal stability evaluation characteristics at the next moment were calculated. With waveform characteristics Concatenate to construct the working state vector for the next time step. At the same time, complete the current time step reward value The calculation. Experience is stored in a replay buffer and can be used for online fine-tuning of the policy network, thus forming a closed-loop process of execution, evaluation, learning, and adjustment.

[0074] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, the phrase "comprising an element defined as..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0075] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method of self-calibrating the excitation stability of a sulphur resistant electromagnetic flowmeter, characterised in that: Includes the following steps: Step S1: Collect the excitation detection signal of the electromagnetic flowmeter and extract features from the excitation detection signal to obtain the excitation detection feature vector; Step S2: Input the excitation detection feature vector into the improved decision tree model and output the electrode state results; Step S3: Based on the electrode state results, adjust the excitation waveform of the electromagnetic flowmeter to obtain a first excitation waveform correction signal, and extract features from the first excitation waveform correction signal to obtain an excitation waveform correction feature vector. Step S4: Input the excitation waveform correction feature vector into the improved reinforcement learning model and output the second excitation waveform correction signal to achieve self-calibration of excitation.

2. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 1, characterized in that: The process of collecting the excitation detection signal from the electromagnetic flowmeter includes the following specific steps: The detection pulse current is obtained by superimposing the detection pulse onto the main excitation current of the electromagnetic flowmeter using a parallel injection method. The excitation detection signal is obtained based on the detection pulse current.

3. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 2, characterized in that: Obtaining the excitation detection feature vector includes the following steps: Excitation detection eigenvector F, = ,in In order to maintain consistency, Time constant The reciprocal, The zero-point offset trend, This refers to the lag time.

4. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 3, characterized in that: The process of inputting the excitation detection feature vector into the improved decision tree model and outputting the electrode state result includes the following steps: A training set for constructing a decision tree model is collected. The training set consists of several sets of electrode interface state samples under different sulfidation degrees. Each set of samples contains an excitation detection feature vector and a corresponding electrode state label. The electrode state label is obtained by combining an electrode accelerated sulfidation aging test with interface impedance detection. Based on the training set, construct candidate... - Neighborhood; Candidates are selected using the sparrow search algorithm. -Optimize the neighborhood radius of the neighborhood to obtain the optimal neighborhood radius; Based on the optimal neighborhood radius, a decision tree model is constructed; The excitation detection feature vector is normalized to obtain the normalized excitation detection feature vector; the normalized excitation detection feature vector is then input into the improved decision tree model to output the electrode state result.

5. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 4, characterized in that: The construction candidate - Neighborhood, including the following steps: Calculate the training set in terms of features The absolute distance between samples For the k-th feature dimension, the absolute distance represents the distance between two samples in that feature dimension. The numerical difference corresponds to the difference in the degree of degradation of the two electrode interfaces in this dimension: ; in, Indicates sample and samples In features The absolute distance on, Indicates sample The 1 eigenvalue, Indicates sample The eigenvalues, m and Both are sample indices, and k is the feature index; Based on the absolute distance, candidate samples are obtained for each sample. - Neighborhood, the - Neighborhood is used to filter a set of samples that are similar to the current sample electrode interface state.

6. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 5, characterized in that: The candidate is selected through the sparrow search algorithm. - Optimize the neighborhood radius of the neighborhood to obtain the optimal neighborhood radius, including the following steps: The sparrow search algorithm is initialized by A population consisting of individual sparrows, each sparrow corresponding to a 4-dimensional neighborhood radius combination. The fitness function of the sparrow search algorithm is: ; in, This indicates the use of the neighborhood radius combination corresponding to the p-th sparrow. The calculated average value of the boundary mixed attribute dependency, Indicates the use of neighborhood radius combination The k-th radius Calculated features The boundary mixing attribute dependency, which is the ability of a single feature dimension to distinguish different electrode interface states; The sparrow search algorithm iterates through a fitness function to ultimately obtain the optimal combination of neighborhood radii. Then the kth feature The optimal neighborhood radius is The optimal neighborhood radius is used to match the numerical distribution characteristics of the corresponding feature, so that the feature can distinguish the state of the electrode interface to the best extent.

7. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 6, characterized in that: The step of adjusting the excitation waveform of the electromagnetic flowmeter based on the electrode state results to obtain a first excitation waveform correction signal includes the following specific steps: The baseline excitation waveform parameter vector of the electromagnetic flowmeter is Construct a strategy mapping function to map the baseline excitation waveform parameter vector as... The input is fed into the strategy mapping function to obtain the adjustment amount of the baseline excitation waveform parameter vector, thereby obtaining the first excitation waveform correction signal.

8. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 7, characterized in that: The process of obtaining the excitation waveform correction feature vector includes the following specific steps: The excitation waveform correction feature vector includes: the average energy of the absolute value of the excitation waveform current signal, the variance energy of the excitation waveform, the symmetry difference value of the charge in the positive and negative half-cycles of the excitation waveform, the duration of the excitation cycle, and the amplitude increment of the enhanced excitation segment.

9. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 8, characterized in that: The step of inputting the excitation waveform correction feature vector into the improved reinforcement learning model and outputting the second excitation waveform correction signal includes the following specific steps: Build an improved reinforcement learning model; The excitation waveform correction feature vector is normalized, and the normalized excitation waveform correction feature vector is input into the reinforcement learning model to obtain the second excitation waveform correction signal.

10. The self-calibration method for excitation stability of an electromagnetic flowmeter under sulfur-resistant operating conditions according to claim 9, characterized in that: The construction of the improved reinforcement learning model includes the following specific steps: Constructing Markov decision processes; Based on Markov decision processes, a local dynamics model is constructed, and the updated policy function is obtained by solving the local dynamics model using a differential dynamic programming algorithm.