Electromagnetic flowmeter nonlinear error correction method based on machine learning
By adopting an improved TimeMixer network and a two-stage error correction strategy, the problem of nonlinear error identification and correction in electromagnetic flowmeters under complex operating conditions is solved, achieving high-precision and stable flow measurement, adapting to complex operating conditions, and possessing good scalability for engineering deployment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-03-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing electromagnetic flowmeters struggle to effectively identify and correct nonlinear errors generated under complex operating conditions, resulting in insufficient measurement accuracy and stability. In particular, under the influence of factors such as fluid disturbance, electromagnetic interference, and equipment aging, existing methods struggle to distinguish between trend drift and periodic disturbances, affecting the accuracy of error compensation and the generalization ability of correction strategies.
An improved TimeMixer network is adopted, which combines multi-scale periodic decomposition and trend modeling mechanism to design a two-stage error correction strategy. By using state-aware factor, third-order polynomial and periodic phase modulation, the adaptability and dynamic accuracy of error compensation are improved, and physical consistency constraints are introduced to ensure the credibility of the correction results.
It achieves accurate identification and efficient correction of nonlinear errors under complex working conditions, improving the measurement reliability and adaptability of electromagnetic flowmeters. It has the ability to model errors with high accuracy, good long-term stability, and adaptability to complex working conditions, and supports real-time updates and continuous optimization.
Smart Images

Figure CN121655658A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial instrument data processing and intelligent error compensation technology, and in particular to a nonlinear error correction method for electromagnetic flowmeters based on machine learning. Background Technology
[0002] With the widespread deployment of intelligent industrial instrumentation systems and edge intelligent monitoring applications, electromagnetic flowmeters, as core equipment for liquid flow measurement, directly affect the overall efficiency of process control and energy metering through their measurement accuracy. However, under complex operating conditions, the output signal of electromagnetic flowmeters is often affected by factors such as fluid disturbances, electromagnetic interference, temperature fluctuations, and equipment aging, resulting in significant nonlinear error drift, which severely restricts their stability and reliability in precision metering and automatic control.
[0003] Existing error compensation methods for electromagnetic flowmeters mainly rely on linear correction models based on static calibration curves or on deviation fitting through simplified physical models. However, under conditions of drastic fluctuations in dynamic operating conditions or complex coupling of multiple source parameters, they cannot effectively identify the combined effects of nonlinear errors and periodic disturbances. Some studies have attempted to introduce black-box models such as neural networks for error regression, but these generally suffer from problems such as a lack of physical rationality in feature selection, a high risk of model overfitting, and poor adaptability to long-term operating environments. Furthermore, there is a lack of systematic methods for structurally separating and modeling trend drift and periodic disturbances in flow measurement errors. This makes it difficult for models to distinguish between long-term error accumulation and periodic error disturbances, affecting the accuracy of error compensation. Moreover, existing methods often lack state awareness and operating condition-dependent information, resulting in weak generalization ability of correction strategies and difficulty in achieving stable deployment in various industrial settings.
[0004] Therefore, how to provide a machine learning-based method for correcting nonlinear errors in electromagnetic flowmeters is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] One objective of this invention is to propose a machine learning-based nonlinear error correction method for electromagnetic flowmeters. This invention combines an improved TimeMixer network with multi-scale periodic decomposition and trend modeling mechanisms to establish a deep learning modeling method for the error sources of electromagnetic flowmeters. Furthermore, a two-stage error correction strategy is designed, improving the adaptability and dynamic accuracy of error compensation through state-aware factors, third-order polynomials, and periodic phase modulation. A reliable corrected flow rate value sequence is output through physical consistency constraints of non-negativity, range, and time smoothing. This invention possesses advantages such as high error modeling accuracy, good long-term operational stability, and strong adaptability to complex operating conditions.
[0006] A nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to an embodiment of the present invention includes the following steps: Step 1: Collect the original monitoring data, operating parameters, and reference calibration flow values of the electromagnetic flowmeter during operation; Step 2: Perform data preprocessing on the raw monitoring data, operating parameters, and reference calibration flow values to obtain the standard feature vector sequence and the raw error sequence; Step 3: Input the standard feature vector sequence into the improved TimeMixer network, perform periodic and trend error feature modeling, and generate trend error prediction value sequence and periodic error prediction value sequence. The improved TimeMixer network includes a multi-scale periodic decomposition module, a selective state space modeling module, and a fusion prediction module. Step 4: Using the original error sequence as a supervision label, calculate the joint loss function of the improved TimeMixer network; Step 5: Based on the trend error prediction value sequence and the periodic error prediction value sequence, design a two-stage error correction strategy to perform trend correction and periodic correction on the original flow measurement value sequence, and generate a corrected flow value sequence; Step 6: Apply physical consistency constraints to the corrected flow value sequence to generate a reliable corrected flow value sequence; Step 7: Collect updated operating data from the electromagnetic flowmeter, incrementally update the improved TimeMixer network, and update the reliable calibration flow value sequence in real time.
[0007] Optionally, the raw monitoring data includes raw flow measurement values, electrode voltage signals, and excitation current signals; the operating parameters include medium conductivity, temperature, pressure, Reynolds number, flow velocity standard deviation, and installation location number.
[0008] Optionally, step two specifically includes: The original monitoring data, operating parameters, and reference calibration flow values are resampled and time-aligned according to a set time step to obtain the original monitoring sequence, operating parameter sequence, and reference calibration flow value sequence. The original monitoring sequence includes the original flow measurement value sequence, electrode voltage signal sequence and excitation current signal sequence, and the operating condition parameter sequence includes the medium conductivity sequence, temperature sequence, pressure sequence, Reynolds number sequence, instantaneous flow velocity standard deviation sequence and installation location number sequence; Calculate the time-step difference between the original flow measurement value sequence and the reference calibration flow value sequence to obtain the original error sequence; The original flow measurement sequence, electrode voltage signal sequence, and excitation current signal sequence are subjected to noise suppression using discrete wavelet transform to generate smooth flow measurement sequence, smooth electrode voltage signal sequence, and smooth excitation current signal sequence, specifically: The number of wavelet decomposition levels is set, and the Daubechies wavelet basis function is used to perform multi-scale discrete wavelet decomposition on the original flow measurement value sequence, electrode voltage signal sequence and excitation current signal sequence, respectively, to obtain the approximate coefficient vector and detail coefficient vector of the three types of signals. The detail coefficient vectors of the three types of signals are denoised based on the soft thresholding function to obtain the denoised detail coefficient set of the three types of signals. Based on the approximation coefficient vector and the set of denoised detail coefficients, wavelet reconstruction is performed on the three types of signals to generate smooth flow measurement value sequences, smooth electrode voltage signal sequences, and smooth excitation current signal sequences. The min-max normalization method is used to normalize the smoothed flow measurement sequence, smoothed electrode voltage signal sequence, smoothed excitation current signal sequence, medium conductivity sequence, temperature sequence, pressure sequence, Reynolds number sequence, and instantaneous flow velocity standard deviation sequence to the [0,1] interval. The installation location number is One-Hot encoded and a standard feature vector sequence is formed according to the time step.
[0009] Optionally, step three specifically includes: In the multi-scale periodic decomposition module, the standard feature vector sequence is processed through fast Fourier transform, significant frequency screening, frequency band classification, frequency domain mask construction, and Fourier pseudotransform to output the periodic feature matrix. The low-frequency trend feature matrix is input into the selective state-space modeling module, which adopts the Mamba structure to perform time-series modeling on the low-frequency trend feature matrix to obtain the trend modeling feature matrix. Specifically, at each time step, the feature vector of each channel in the low-frequency trend feature matrix is linearly projected to generate a state input term and a gating control term; the state input term is convolved with the learnable state transition matrix and the input driving weights to generate a state response vector; the gating control term is input into the Sigmoid activation function to generate a gating factor, and then multiplied element-wise with the state response vector to obtain the trend modeling feature matrix. The original error sequence is Z-score standardized to obtain the standard error sequence. The standard error sequence is then linearly transformed by a trainable linear mapping layer to generate an error adjustment vector. The error adjustment vector is multiplied element-wise with the trend modeling feature matrix in the channel dimension to obtain the error trend feature matrix; The periodic feature matrix and the error trend feature matrix are residually concatenated along the feature dimension and then linearly transformed to obtain the fused feature matrix. The fusion prediction module includes a trend regression branch and a periodic regression branch, which are used to output the trend error prediction value sequence and the periodic error prediction value sequence, respectively: In the trend regression branch, local features of the fusion feature matrix are extracted by a one-dimensional convolution with a kernel of 3 to obtain a local trend feature matrix. The local trend feature matrix is then input into a two-layer residual feedforward network. The first layer of the residual feedforward network uses the GELU activation function, and the second layer of the residual feedforward network performs linear projection to output a sequence of trend error prediction values. In the periodic regression branch, local periodic response features are extracted from the fused feature matrix by a one-dimensional convolution with a kernel of 5, generating a local periodic feature matrix. The local periodic feature matrix is then input into a two-layer feedforward neural network. The first layer of the feedforward neural network uses the ReLU activation function, and the second layer of the feedforward neural network performs a linear mapping, outputting a sequence of predicted periodic error values.
[0010] Optionally, in the multi-scale periodic decomposition module, the standard feature vector sequence is processed through Fast Fourier Transform, significant frequency filtering, frequency band classification, frequency domain mask construction, and Fourier quasi-transform to output a periodic feature matrix, specifically including: Perform a Fast Fourier Transform on the standard eigenvector sequence to obtain a complex frequency domain eigenma matrix, where each column of the complex frequency domain eigenma matrix represents the complex frequency domain eigenvector of a channel, and calculate the amplitude spectrum sequence of each channel; Peak detection and frequency filtering are performed on the amplitude spectrum sequence of each channel to obtain the set of significant frequencies for each channel, specifically: Set a sliding window, amplitude threshold, and frequency interval threshold. Perform a sliding window search on the amplitude spectrum sequence of each channel. If the amplitude spectrum of the current frequency index is greater than the amplitude spectrum of the previous frequency index, and greater than the amplitude spectrum of the next frequency index, and greater than or equal to the minimum amplitude threshold, then the current frequency index is taken as a significant frequency. If the index distance between any two significant frequencies is less than the set frequency interval threshold, then the significant frequency with the larger amplitude spectrum is retained. Define a high-frequency disturbance range, a mid-frequency oscillation range, and a low-frequency trend cycle range. These ranges must not overlap and must cover the target analysis frequency range. Based on the high-frequency disturbance range, the mid-frequency oscillation range, and the low-frequency trend period range, the significant frequency set of each channel is classified to obtain the high-frequency significant frequency set, the mid-frequency significant frequency set, and the low-frequency significant frequency set of each channel. Construct the high-frequency mask vector, intermediate-frequency mask vector, and low-frequency mask vector for each channel; The high-frequency mask vector, intermediate-frequency mask vector, and low-frequency mask vector of each channel are multiplied element-wise with the complex frequency domain feature vector of each channel, and an inverse Fourier transform is performed to obtain the high-frequency time domain feature vector, intermediate-frequency time domain feature vector, and low-frequency time domain feature vector of each channel. Mirror filling is used to align the feature vectors of each channel in each frequency band interval by time step, and then the channels are spliced to obtain the high-frequency disturbance feature matrix, the mid-frequency oscillation feature matrix and the low-frequency trend feature matrix; Trainable attention weights are introduced to fuse the high-frequency perturbation feature matrix, the mid-frequency oscillation feature matrix and the low-frequency trend feature matrix through channels, and a periodic feature matrix is generated through one-dimensional convolution transformation and softmax normalization.
[0011] Optionally, step four specifically includes: Align the trend error prediction value series, the periodic error prediction value series with the original error series; Based on the original error sequence, the mean square error and mean absolute error of the trend error prediction sequence and the period error prediction sequence are calculated respectively to obtain the trend mean square error, trend mean absolute error, period mean square error and period mean absolute error. The trend mean square error, trend mean absolute error, period mean square error and period mean absolute error are weighted and fused to obtain the joint loss function of the improved TimeMixer network. Based on the joint loss function, a cross-validation strategy is used to perform supervised training on the improved TimeMixer network.
[0012] Optionally, step five specifically includes: The two-stage error correction strategy includes a trend error correction stage and a periodic error correction stage. During the trend error correction phase, the standard operating condition feature vector sequence is transformed into a state-aware factor sequence through linear mapping and Sigmoid activation. A third-order polynomial is used to perform nonlinear fitting on the trend error prediction value sequence to generate a trend compensation value sequence. The state-aware factor sequence and the trend compensation sequence are multiplied element by element to obtain the trend correction sequence, and the original flow measurement value sequence is subtracted element by element from the trend correction sequence to obtain the intermediate flow value sequence. In the periodic error correction stage, the periodic feature matrix is extracted using an MLP structure with a Swish activation function to obtain the periodic phase feature matrix; the periodic phase feature matrix is then transformed by a linear transformation and activated by a Sigmoid to generate a phase attention weight sequence. Based on the periodic feature matrix, the main frequency amplitude of each time step is extracted, and a periodic amplitude modulation sequence is generated by linear mapping and ReLU activation. The phase attention weight sequence, the period amplitude modulation sequence, and the period error prediction sequence are multiplied element by element to obtain the period correction sequence. The corrected flow value sequence is obtained by subtracting the intermediate flow value sequence and the periodic correction sequence element by element.
[0013] Optionally, step six specifically includes: The physical consistency constraints include nonnegativity constraints, range constraints, and time smoothing consistency constraints. In the non-negativity constraint, the maximum value function is used to obtain the maximum value between the corrected flow rate value and 0 at each time step, generating a sequence of non-negativity flow rate values; In the range constraint, the maximum allowable flow value of the electromagnetic flowmeter is set, and the minimum value function is used to obtain the minimum value of the non-negative flow value and the maximum allowable flow value at each time step, thereby generating a range flow value sequence. In the time-smoothing consistency constraint, a smoothing coefficient is set, with a value range of [0,1]. A first-order sliding smoothing process is then performed on the range flow rate value sequence to generate a reliable corrected flow rate value sequence. Specifically: Multiply the current time step's range flow rate value by the smoothing coefficient, multiply the previous time step's range flow rate value by 1 minus the smoothing coefficient, and add the two together to obtain the physical constraint flow rate value. If the time step is 1, then the physical constraint flow rate is equal to the range flow rate.
[0014] Optionally, the updated operating data includes an updated sequence of original monitoring data, an updated sequence of operating parameters, and a sequence of reference calibration flow values.
[0015] The beneficial effects of this invention are: First, this invention constructs an improved TimeMixer network, which integrates a multi-scale periodic decomposition module, a selective state-space modeling module, and a fusion prediction module. This network can accurately identify the nonlinear error characteristics generated during the operation of the electromagnetic flowmeter. In particular, under complex operating conditions such as excitation interference, temperature drift, and flow disturbance, it effectively extracts periodic disturbance characteristics and slowly changing trend deviations, achieving dual-path modeling of trend error and periodic error.
[0016] Secondly, in the error compensation stage, this invention designs a two-stage error correction strategy based on the trend error prediction value sequence and the periodic error prediction value sequence. It uses a state-aware factor to adjust the trend compensation amount and combines the periodic phase characteristics and periodic amplitude to generate the periodic correction amount. The original flow measurement value sequence is dynamically corrected in stages, which overcomes the problem that traditional methods cannot simultaneously take into account long-period drift and high-frequency error disturbances, and significantly improves the accuracy and adaptability of error correction.
[0017] Furthermore, this invention introduces physical consistency constraints, using non-negativity constraints, range constraints, and time smoothing consistency constraints to ensure that the output reliable corrected flow value sequence has usability and reliability while meeting actual physical boundary conditions and continuity requirements, thus avoiding the phenomenon of correction results exceeding the instrument range or exhibiting drastic jumps. At the same time, it supports incremental training based on updated operating data, enabling continuous optimization of the improved TimeMixer network and real-time updates of the reliable corrected flow value sequence, and possesses good scalability for engineering deployment.
[0018] In summary, the method of this invention fully integrates frequency domain information modeling, state space dynamic learning, and operating condition-driven error compensation mechanism, and has the effects of high error modeling accuracy, strong stability of correction results, and strong adaptability to complex operating conditions. It significantly improves the measurement reliability and intelligence level of electromagnetic flowmeters in complex industrial scenarios. Attached Figure Description
[0019] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0020] Figure 1 This is a schematic diagram of a nonlinear error correction method for electromagnetic flowmeters based on machine learning proposed in this invention; Figure 2 This is a flowchart of the improved TimeMixer network structure in a machine learning-based electromagnetic flowmeter nonlinear error correction method proposed in this invention. Figure 3 This is a flowchart of the two-stage error correction process in a nonlinear error correction method for electromagnetic flowmeters based on machine learning proposed in this invention. Detailed Implementation
[0021] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0022] refer to Figures 1-3 A nonlinear error correction method for electromagnetic flowmeters based on machine learning includes the following steps: Step 1: Collect the original monitoring data, operating parameters, and reference calibration flow values of the electromagnetic flowmeter during operation; Step 2: Perform data preprocessing on the raw monitoring data, operating parameters, and reference calibration flow values to obtain the standard feature vector sequence and the raw error sequence; Step 3: Input the standard feature vector sequence into the improved TimeMixer network, perform periodic and trend error feature modeling, and generate trend error prediction value sequence and periodic error prediction value sequence. The improved TimeMixer network includes a multi-scale periodic decomposition module, a selective state space modeling module, and a fusion prediction module. Step 4: Using the original error sequence as a supervision label, calculate the joint loss function of the improved TimeMixer network; Step 5: Based on the trend error prediction value sequence and the periodic error prediction value sequence, design a two-stage error correction strategy to perform trend correction and periodic correction on the original flow measurement value sequence, and generate a corrected flow value sequence; Step 6: Apply physical consistency constraints to the corrected flow value sequence to generate a reliable corrected flow value sequence; Step 7: Collect updated operating data from the electromagnetic flowmeter, incrementally update the improved TimeMixer network, and update the reliable calibration flow value sequence in real time.
[0023] In this embodiment, the original monitoring data includes the original flow measurement value, electrode voltage signal and excitation current signal; the operating parameters include medium conductivity, temperature, pressure, Reynolds number, flow velocity standard deviation and installation location number, and the reference calibration flow value serves as the flow label required for supervisory modeling.
[0024] In this embodiment, step two specifically includes: The original monitoring data, operating parameters, and reference calibration flow values are resampled and time-aligned according to a set time step to obtain the original monitoring sequence, operating parameter sequence, and reference calibration flow value sequence. The original monitoring sequence includes the original flow measurement value sequence, electrode voltage signal sequence and excitation current signal sequence, and the operating condition parameter sequence includes the medium conductivity sequence, temperature sequence, pressure sequence, Reynolds number sequence, instantaneous flow velocity standard deviation sequence and installation location number sequence; Calculate the time-step difference between the original flow measurement value sequence and the reference calibration flow value sequence to obtain the original error sequence; The original flow measurement sequence, electrode voltage signal sequence, and excitation current signal sequence are subjected to noise suppression using discrete wavelet transform to generate smooth flow measurement sequence, smooth electrode voltage signal sequence, and smooth excitation current signal sequence, specifically: The number of wavelet decomposition levels is set, and the Daubechies wavelet basis function is used to perform multi-scale discrete wavelet decomposition on the original flow measurement value sequence, electrode voltage signal sequence and excitation current signal sequence, respectively, to obtain the approximate coefficient vector and detail coefficient vector of the three types of signals. The detail coefficient vectors of the three types of signals are denoised based on the soft thresholding function to obtain the denoised detail coefficient set of the three types of signals. Based on the approximation coefficient vector and the set of denoised detail coefficients, wavelet reconstruction is performed on the three types of signals to generate smooth flow measurement value sequences, smooth electrode voltage signal sequences, and smooth excitation current signal sequences. The min-max normalization method is used to normalize the smoothed flow measurement sequence, smoothed electrode voltage signal sequence, smoothed excitation current signal sequence, medium conductivity sequence, temperature sequence, pressure sequence, Reynolds number sequence, and instantaneous flow velocity standard deviation sequence to the [0,1] interval. The installation location number is One-Hot encoded and a standard feature vector sequence is formed according to the time step.
[0025] In this embodiment, step three specifically includes: In the multi-scale periodic decomposition module, the standard feature vector sequence is processed through fast Fourier transform, significant frequency screening, frequency band classification, frequency domain mask construction, and Fourier pseudotransform to output the periodic feature matrix. The low-frequency trend feature matrix is input into the selective state-space modeling module, which adopts the Mamba structure to perform time-series modeling on the low-frequency trend feature matrix to obtain the trend modeling feature matrix. Specifically, at each time step, the feature vector of each channel in the low-frequency trend feature matrix is linearly projected to generate a state input term and a gating control term; the state input term is convolved with the learnable state transition matrix and the input driving weights to generate a state response vector; the gating control term is input into the Sigmoid activation function to generate a gating factor, and then multiplied element-wise with the state response vector to obtain the trend modeling feature matrix. The original error sequence is Z-score standardized to obtain the standard error sequence. The standard error sequence is then linearly transformed by a trainable linear mapping layer to generate an error adjustment vector. The error adjustment vector is multiplied element-wise with the trend modeling feature matrix in the channel dimension to obtain the error trend feature matrix; The periodic feature matrix and the error trend feature matrix are residually concatenated along the feature dimension and then linearly transformed to obtain the fused feature matrix. The fusion prediction module includes a trend regression branch and a periodic regression branch, which are used to output the trend error prediction value sequence and the periodic error prediction value sequence, respectively: In the trend regression branch, local features of the fusion feature matrix are extracted by a one-dimensional convolution with a kernel of 3 to obtain a local trend feature matrix. The local trend feature matrix is then input into a two-layer residual feedforward network. The first layer of the residual feedforward network uses the GELU activation function, and the second layer of the residual feedforward network performs linear projection to output a sequence of trend error prediction values. In the periodic regression branch, local periodic response features are extracted from the fused feature matrix by a one-dimensional convolution with a kernel of 5, generating a local periodic feature matrix. The local periodic feature matrix is then input into a two-layer feedforward neural network. The first layer of the feedforward neural network uses the ReLU activation function, and the second layer of the feedforward neural network performs a linear mapping, outputting a sequence of predicted periodic error values.
[0026] In this embodiment, the multi-scale periodic decomposition module outputs a periodic feature matrix by performing fast Fourier transform, significant frequency filtering, frequency band classification, frequency domain mask construction, and Fourier quasi-transform on the standard feature vector sequence. Specifically, this includes: Perform a Fast Fourier Transform on the standard eigenvector sequence to obtain a complex frequency domain eigenma matrix, where each column of the complex frequency domain eigenma matrix represents the complex frequency domain eigenvector of a channel, and calculate the amplitude spectrum sequence of each channel; Peak detection and frequency filtering are performed on the amplitude spectrum sequence of each channel to obtain the set of significant frequencies for each channel, specifically: Set a sliding window, amplitude threshold, and frequency interval threshold. Perform a sliding window search on the amplitude spectrum sequence of each channel. If the amplitude spectrum of the current frequency index is greater than the amplitude spectrum of the previous frequency index, and greater than the amplitude spectrum of the next frequency index, and greater than or equal to the minimum amplitude threshold, then the current frequency index is taken as a significant frequency. If the index distance between any two significant frequencies is less than the set frequency interval threshold, then the significant frequency with the larger amplitude spectrum is retained. Define a high-frequency disturbance range, a mid-frequency oscillation range, and a low-frequency trend cycle range. These ranges must not overlap and must cover the target analysis frequency range. Based on the high-frequency disturbance range, the mid-frequency oscillation range, and the low-frequency trend period range, the significant frequency set of each channel is classified to obtain the high-frequency significant frequency set, the mid-frequency significant frequency set, and the low-frequency significant frequency set of each channel. Construct high-frequency mask vectors, intermediate-frequency mask vectors, and low-frequency mask vectors for each channel. Specifically, set the index of significant frequency positions within the high-frequency disturbance range to 1 and the index of other positions to 0 to form the high-frequency mask vector; set the index of significant frequency positions within the intermediate-frequency oscillation range to 1 and the index of other positions to 0 to form the intermediate-frequency mask vector; set the index of significant frequency positions within the low-frequency trend period range to 1 and the index of other positions to 0 to form the low-frequency mask vector. The high-frequency mask vector, intermediate-frequency mask vector, and low-frequency mask vector of each channel are multiplied element-wise with the complex frequency domain feature vector of each channel, and an inverse Fourier transform is performed to obtain the high-frequency time domain feature vector, intermediate-frequency time domain feature vector, and low-frequency time domain feature vector of each channel. Mirror filling is used to align the feature vectors of each channel in each frequency band interval by time step, and then the channels are spliced to obtain the high-frequency disturbance feature matrix, the mid-frequency oscillation feature matrix and the low-frequency trend feature matrix; Trainable attention weights are introduced to fuse the high-frequency perturbation feature matrix, the mid-frequency oscillation feature matrix and the low-frequency trend feature matrix through channels, and a periodic feature matrix is generated through one-dimensional convolution transformation and softmax normalization.
[0027] This invention introduces Fast Fourier Transform and significant frequency filtering into the multi-scale period decomposition module, achieving effective separation and classification modeling of high-frequency disturbances, mid-frequency oscillations, and low-frequency trend periods in electromagnetic flowmeter signals. By setting a sliding window and frequency interval threshold, key frequency components can be accurately extracted, avoiding spectral aliasing and spurious peak interference. The introduction of frequency domain masking and Fourier pseudo-transform operations helps reconstruct the original time-domain features of each period component, improving the structural clarity of period information. By fusing attention weights and one-dimensional convolution, adaptive fusion modeling of different period components in the channel dimension is achieved, enhancing the flexibility and expressiveness of period modeling. The multi-scale period decomposition module effectively improves the ability of the improved TimeMixer network to identify different error patterns, exhibiting stronger generalization ability and accuracy advantages when dealing with complex disturbance environments and period drift.
[0028] In this embodiment, step four specifically includes: Align the trend error prediction value series, the periodic error prediction value series with the original error series; Based on the original error sequence, the mean square error and mean absolute error of the trend error prediction sequence and the period error prediction sequence are calculated respectively to obtain the trend mean square error, trend mean absolute error, period mean square error and period mean absolute error. The trend mean square error, trend mean absolute error, period mean square error and period mean absolute error are weighted and fused to obtain the joint loss function of the improved TimeMixer network. Based on the joint loss function, a cross-validation strategy is used to perform supervised training on the improved TimeMixer network.
[0029] In this embodiment, step five specifically includes: The two-stage error correction strategy includes a trend error correction stage and a periodic error correction stage. During the trend error correction stage, the standard operating condition feature vector sequence is transformed into a state-aware factor sequence through linear mapping and Sigmoid activation; the standard operating condition feature vector sequence is obtained from the standard feature vector sequence. A third-order polynomial is used to perform nonlinear fitting on the trend error prediction value sequence to generate a trend compensation value sequence. The state-aware factor sequence and the trend compensation sequence are multiplied element by element to obtain the trend correction sequence, and the original flow measurement value sequence is subtracted element by element from the trend correction sequence to obtain the intermediate flow value sequence. In the periodic error correction stage, the periodic feature matrix is extracted using an MLP structure with a Swish activation function to obtain the periodic phase feature matrix; the periodic phase feature matrix is then transformed by a linear transformation and activated by a Sigmoid to generate a phase attention weight sequence. Based on the periodic feature matrix, the main frequency amplitude of each time step is extracted, and a periodic amplitude modulation sequence is generated by linear mapping and ReLU activation. The phase attention weight sequence, the period amplitude modulation sequence, and the period error prediction sequence are multiplied element by element to obtain the period correction sequence. The corrected flow value sequence is obtained by subtracting the intermediate flow value sequence and the periodic correction sequence element by element.
[0030] In this embodiment, step six specifically includes: The physical consistency constraints include nonnegativity constraints, range constraints, and time smoothing consistency constraints. In the non-negativity constraint, the maximum value function is used to obtain the maximum value between the corrected flow rate value and 0 at each time step, generating a sequence of non-negativity flow rate values; In the range constraint, the maximum allowable flow value of the electromagnetic flowmeter is set, and the minimum value function is used to obtain the minimum value of the non-negative flow value and the maximum allowable flow value at each time step, thereby generating a range flow value sequence. In the time-smoothing consistency constraint, a smoothing coefficient is set, with a value range of [0,1]. A first-order sliding smoothing process is then performed on the range flow rate value sequence to generate a reliable corrected flow rate value sequence. Specifically: Multiply the current time step's range flow rate value by the smoothing coefficient, multiply the previous time step's range flow rate value by 1 minus the smoothing coefficient, and add the two together to obtain the physical constraint flow rate value. If the time step is 1, then the physical constraint flow rate is equal to the range flow rate.
[0031] In this embodiment, the updated operating data includes an updated sequence of original monitoring data, an updated sequence of operating parameters, and a sequence of reference calibration flow values.
[0032] Example 1 To verify the feasibility of this invention in practice, the method was applied to an online monitoring system for electromagnetic flowmeters in the intake area of a large-scale water conservancy project. This area has complex flow patterns and frequent fluctuations in operating conditions. In actual operation, the electromagnetic flowmeter is susceptible to factors such as fluctuations in medium conductivity, excitation current disturbances, temperature changes, electrode contamination, and abnormal Reynolds number variations. During long-term operation, problems such as measurement drift, periodic oscillations, and sudden abnormal offsets frequently occur, leading to deviations between the flow monitoring data and the actual reference calibration flow value. Traditional linear compensation methods, wavelet threshold correction methods, and single-cycle frequency domain compensation methods generally suffer from insufficient compensation, loss of periodic characteristics, and inability to effectively correct trend drift under such complex disturbance scenarios, thus failing to meet the high-precision flow monitoring requirements of the water conservancy project.
[0033] In practical deployment, the raw flow measurement values, electrode voltage signals, excitation current signals, and operating parameters such as medium conductivity, temperature, pressure, and Reynolds number collected by the electromagnetic flowmeter are input in real time to the electromagnetic flowmeter online monitoring system. Data preprocessing yields a standard feature vector sequence and a raw error sequence. The standard feature vector sequence is then fed into an improved TimeMixer network. A multi-scale periodic decomposition module identifies high-frequency disturbances, mid-frequency oscillations, and low-frequency trend periods. A selective state-space modeling module extracts trend modeling features, and finally, trend error prediction sequences and periodic error prediction sequences are generated.
[0034] During error correction, a two-stage error correction process is performed using both trend error prediction sequences and periodic error prediction sequences. In the trend correction stage, third-order polynomial fitting compensates for long-term drift, while in the periodic correction stage, phase attention weights and periodic amplitude modulation structures compensate for short-period fluctuations, giving the flow correction stronger adaptability. Furthermore, physical consistency constraints are applied to the corrected flow value sequence, achieving non-negativity constraints, range constraints, and time smoothing consistency constraints, thereby ensuring that the corrected flow value is physically reasonable and conforms to flow field continuity. The electromagnetic flowmeter online monitoring system continuously collects and updates operational data during long-term operation, continuously performing incremental updates on the improved TimeMixer network, enabling the network model to adapt to changes in different seasons, flow regimes, and operating conditions.
[0035] To verify the effectiveness of this invention, a comparative experiment was conducted with traditional linear compensation methods, wavelet threshold correction methods, and single-cycle frequency domain compensation methods. Three consecutive months of operational data were collected, totaling 210,000 monitoring samples. High-precision reference calibration flow values from the water conservancy project site were used as the judgment criteria. The experimental results are shown in Table 1.
[0036] Table 1. Performance Comparison of the Invention Method and Comparative Methods in Electromagnetic Flowmeter Error Correction
[0037] As shown in Table 1, the method of this invention significantly outperforms existing comparative methods in multiple comparative indicators. Regarding the mean square error and mean absolute error of flow, this method reduces them to 1.25 L / s and 0.96 L / s, respectively, a reduction of over 70% compared to traditional linear compensation methods. In terms of uncompensated trend drift and periodic oscillation, the methods of this invention are 1.8% and 2.4%, respectively, significantly lower than the comparative methods, demonstrating the good compatibility and separation of the two-stage error correction strategy for different error modes. In high-perturbation scenarios, the stability score of this method reaches 0.93, significantly higher than other methods, indicating that this method has better generalization ability and robustness. Furthermore, the physical consistency pass rate of this method reaches 99.1%, far exceeding the 84.1% of the traditional linear compensation method, indicating that this method effectively ensures the reliability of data and engineering security in actual deployment environments. Under long-term operation, the model drift amplitude is controlled within 0.74 L / s, significantly reducing the error accumulation problem caused by environmental changes or sensor aging. The method of this invention has significant advantages in nonlinear flow error modeling and correction, and is applicable to electromagnetic flow measurement optimization in complex operating scenarios such as multiple disturbances, high noise, and non-steady state.
[0038] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A nonlinear error correction method for electromagnetic flowmeters based on machine learning, characterized in that, Includes the following steps: Step 1: Collect the original monitoring data, operating parameters, and reference calibration flow values of the electromagnetic flowmeter during operation; Step 2: Perform data preprocessing on the raw monitoring data, operating parameters, and reference calibration flow values to obtain the standard feature vector sequence and the raw error sequence; Step 3: Input the standard feature vector sequence into the improved TimeMixer network, perform periodic and trend error feature modeling, and generate trend error prediction value sequence and periodic error prediction value sequence. The improved TimeMixer network includes a multi-scale periodic decomposition module, a selective state space modeling module, and a fusion prediction module. Step 4: Using the original error sequence as a supervision label, calculate the joint loss function of the improved TimeMixer network; Step 5: Based on the trend error prediction value sequence and the periodic error prediction value sequence, design a two-stage error correction strategy to perform trend correction and periodic correction on the original flow measurement value sequence, and generate a corrected flow value sequence; Step 6: Apply physical consistency constraints to the corrected flow value sequence to generate a reliable corrected flow value sequence; Step 7: Collect updated operating data from the electromagnetic flowmeter, incrementally update the improved TimeMixer network, and update the reliable calibration flow value sequence in real time.
2. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 1, characterized in that, The original monitoring data includes the original flow measurement value, electrode voltage signal and excitation current signal; the operating parameters include medium conductivity, temperature, pressure, Reynolds number, flow velocity standard deviation and installation location number.
3. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 1, characterized in that, Step two specifically includes: The original monitoring data, operating parameters, and reference calibration flow values are resampled and time-aligned according to a set time step to obtain the original monitoring sequence, operating parameter sequence, and reference calibration flow value sequence. The original monitoring sequence includes the original flow measurement value sequence, electrode voltage signal sequence and excitation current signal sequence, and the operating condition parameter sequence includes the medium conductivity sequence, temperature sequence, pressure sequence, Reynolds number sequence, instantaneous flow velocity standard deviation sequence and installation location number sequence; Calculate the time-step difference between the original flow measurement value sequence and the reference calibration flow value sequence to obtain the original error sequence; The original flow measurement sequence, electrode voltage signal sequence, and excitation current signal sequence are subjected to noise suppression using discrete wavelet transform to generate smooth flow measurement sequence, smooth electrode voltage signal sequence, and smooth excitation current signal sequence, specifically: The number of wavelet decomposition levels is set, and the Daubechies wavelet basis function is used to perform multi-scale discrete wavelet decomposition on the original flow measurement value sequence, electrode voltage signal sequence and excitation current signal sequence, respectively, to obtain the approximate coefficient vector and detail coefficient vector of the three types of signals. The detail coefficient vectors of the three types of signals are denoised based on the soft thresholding function to obtain the denoised detail coefficient set of the three types of signals. Based on the approximation coefficient vector and the set of denoised detail coefficients, wavelet reconstruction is performed on the three types of signals to generate smooth flow measurement value sequences, smooth electrode voltage signal sequences, and smooth excitation current signal sequences. The min-max normalization method is used to normalize the smoothed flow measurement sequence, smoothed electrode voltage signal sequence, smoothed excitation current signal sequence, medium conductivity sequence, temperature sequence, pressure sequence, Reynolds number sequence, and instantaneous flow velocity standard deviation sequence to the [0,1] interval. The installation location number is One-Hot encoded and a standard feature vector sequence is formed according to the time step.
4. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 1, characterized in that, Step three specifically includes: In the multi-scale periodic decomposition module, the standard feature vector sequence is processed through fast Fourier transform, significant frequency screening, frequency band classification, frequency domain mask construction, and Fourier pseudotransform to output the periodic feature matrix. The low-frequency trend feature matrix is input into the selective state-space modeling module, which adopts the Mamba structure to perform time-series modeling on the low-frequency trend feature matrix to obtain the trend modeling feature matrix. Specifically, at each time step, the feature vector of each channel in the low-frequency trend feature matrix is linearly projected to generate a state input term and a gating control term; the state input term is convolved with the learnable state transition matrix and the input driving weights to generate a state response vector; the gating control term is input into the Sigmoid activation function to generate a gating factor, and then multiplied element-wise with the state response vector to obtain the trend modeling feature matrix. The original error sequence is Z-score standardized to obtain the standard error sequence. The standard error sequence is then linearly transformed by a trainable linear mapping layer to generate an error adjustment vector. The error adjustment vector is multiplied element-wise with the trend modeling feature matrix in the channel dimension to obtain the error trend feature matrix; The periodic feature matrix and the error trend feature matrix are residually concatenated along the feature dimension and then linearly transformed to obtain the fused feature matrix. The fusion prediction module includes a trend regression branch and a periodic regression branch, which are used to output the trend error prediction value sequence and the periodic error prediction value sequence, respectively: In the trend regression branch, local features of the fusion feature matrix are extracted by a one-dimensional convolution with a kernel of 3 to obtain a local trend feature matrix. The local trend feature matrix is then input into a two-layer residual feedforward network. The first layer of the residual feedforward network uses the GELU activation function, and the second layer of the residual feedforward network performs linear projection to output a sequence of trend error prediction values. In the periodic regression branch, local periodic response features are extracted from the fused feature matrix by a one-dimensional convolution with a kernel of 5, generating a local periodic feature matrix. The local periodic feature matrix is then input into a two-layer feedforward neural network. The first layer of the feedforward neural network uses the ReLU activation function, and the second layer of the feedforward neural network performs a linear mapping, outputting a sequence of predicted periodic error values.
5. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 4, characterized in that, The multi-scale periodic decomposition module outputs a periodic feature matrix by performing fast Fourier transform, significant frequency filtering, frequency band classification, frequency domain mask construction, and Fourier quasi-transform on the standard feature vector sequence. Specifically, this includes: Perform a Fast Fourier Transform on the standard eigenvector sequence to obtain a complex frequency domain eigenma matrix, where each column of the complex frequency domain eigenma matrix represents the complex frequency domain eigenvector of a channel, and calculate the amplitude spectrum sequence of each channel; Peak detection and frequency filtering are performed on the amplitude spectrum sequence of each channel to obtain the set of significant frequencies for each channel, specifically: Set a sliding window, amplitude threshold, and frequency interval threshold. Perform a sliding window search on the amplitude spectrum sequence of each channel. If the amplitude spectrum of the current frequency index is greater than the amplitude spectrum of the previous frequency index, and greater than the amplitude spectrum of the next frequency index, and greater than or equal to the minimum amplitude threshold, then the current frequency index is taken as a significant frequency. If the index distance between any two significant frequencies is less than the set frequency interval threshold, then the significant frequency with the larger amplitude spectrum is retained. Define a high-frequency disturbance range, a mid-frequency oscillation range, and a low-frequency trend cycle range. These ranges must not overlap and must cover the target analysis frequency range. Based on the high-frequency disturbance range, the mid-frequency oscillation range, and the low-frequency trend period range, the significant frequency set of each channel is classified to obtain the high-frequency significant frequency set, the mid-frequency significant frequency set, and the low-frequency significant frequency set of each channel. Construct the high-frequency mask vector, intermediate-frequency mask vector, and low-frequency mask vector for each channel; The high-frequency mask vector, intermediate-frequency mask vector, and low-frequency mask vector of each channel are multiplied element-wise with the complex frequency domain feature vector of each channel, and an inverse Fourier transform is performed to obtain the high-frequency time domain feature vector, intermediate-frequency time domain feature vector, and low-frequency time domain feature vector of each channel. Mirror filling is used to align the feature vectors of each channel in each frequency band interval by time step, and then the channels are spliced to obtain the high-frequency disturbance feature matrix, the mid-frequency oscillation feature matrix and the low-frequency trend feature matrix; Trainable attention weights are introduced to fuse the high-frequency perturbation feature matrix, the mid-frequency oscillation feature matrix and the low-frequency trend feature matrix through channels, and a periodic feature matrix is generated through one-dimensional convolution transformation and softmax normalization.
6. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 1, characterized in that, Step four specifically includes: Align the trend error prediction value series, the periodic error prediction value series with the original error series; Based on the original error sequence, the mean square error and mean absolute error of the trend error prediction sequence and the period error prediction sequence are calculated respectively to obtain the trend mean square error, trend mean absolute error, period mean square error and period mean absolute error. The trend mean square error, trend mean absolute error, period mean square error and period mean absolute error are weighted and fused to obtain the joint loss function of the improved TimeMixer network. Based on the joint loss function, a cross-validation strategy is used to perform supervised training on the improved TimeMixer network.
7. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 1, characterized in that, Step five specifically includes: The two-stage error correction strategy includes a trend error correction stage and a periodic error correction stage. During the trend error correction phase, the standard operating condition feature vector sequence is transformed into a state-aware factor sequence through linear mapping and Sigmoid activation. A third-order polynomial is used to perform nonlinear fitting on the trend error prediction value sequence to generate a trend compensation value sequence. The state-aware factor sequence and the trend compensation sequence are multiplied element by element to obtain the trend correction sequence, and the original flow measurement value sequence is subtracted element by element from the trend correction sequence to obtain the intermediate flow value sequence. In the periodic error correction stage, the periodic feature matrix is extracted using an MLP structure with a Swish activation function to obtain the periodic phase feature matrix; the periodic phase feature matrix is then transformed by a linear transformation and activated by a Sigmoid to generate a phase attention weight sequence. Based on the periodic feature matrix, the main frequency amplitude of each time step is extracted, and a periodic amplitude modulation sequence is generated by linear mapping and ReLU activation. The phase attention weight sequence, the period amplitude modulation sequence, and the period error prediction sequence are multiplied element by element to obtain the period correction sequence. The corrected flow value sequence is obtained by subtracting the intermediate flow value sequence and the periodic correction sequence element by element.
8. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 1, characterized in that, Step six specifically includes: The physical consistency constraints include nonnegativity constraints, range constraints, and time smoothing consistency constraints. In the non-negativity constraint, the maximum value function is used to obtain the maximum value between the corrected flow rate value and 0 at each time step, generating a sequence of non-negativity flow rate values; In the range constraint, the maximum allowable flow value of the electromagnetic flowmeter is set, and the minimum value function is used to obtain the minimum value of the non-negative flow value and the maximum allowable flow value at each time step, thereby generating a range flow value sequence. In the time-smoothing consistency constraint, a smoothing coefficient is set, with a value range of [0,1]. A first-order sliding smoothing process is then performed on the range flow rate value sequence to generate a reliable corrected flow rate value sequence. Specifically: Multiply the current time step's range flow rate value by the smoothing coefficient, multiply the previous time step's range flow rate value by 1 minus the smoothing coefficient, and add the two together to obtain the physical constraint flow rate value. If the time step is 1, then the physical constraint flow rate is equal to the range flow rate.
9. The nonlinear error correction method for an electromagnetic flowmeter based on machine learning according to claim 1, characterized in that, The updated operational data includes an updated sequence of original monitoring data, an updated sequence of operating parameters, and a sequence of reference calibration flow values.
Citation Information
Cited By
Gas flow measurement error correction method and system based on critical flow sonic nozzle
CN121877155A
Gas flow measurement error correction method and system based on critical flow nozzle
CN121877155B
Wafer process fault early warning method and system based on mixed sequence decomposition and Mama architecture
CN122112929A