Flow measurement method and device based on improved Kalman filter, and electronic equipment

By introducing smooth exponential weighting factor and robust loss function into the Kalman filter, the residual correction amount of the state update equation is adaptively adjusted, which solves the problem of limited measurement accuracy in high dynamic flow environments, and achieves more accurate flow measurement.

CN120352004AActive Publication Date: 2025-07-22ZHEJIANG HEDA TECH +1
View PDF 14 Cites 0 Cited by

Patent Information

Application Number
CN202510422210.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2025-07-22
Estimated Expiration
2045-04-07

AI Technical Summary

Technical Problem

Traditional Kalman filtering algorithms are difficult to effectively adjust in highly dynamically changing flow measurement environments, resulting in limited measurement accuracy, especially in the case of sudden or rapid changes in flow, it is unable to effectively deal with complex flow fluctuations and external noise.

Method used

By introducing a smoothing exponential weighting factor, compensating the state update equation of the Kalman filter, combining the robust loss function and the smoothing function to calculate the weight value, adaptively adjust the residual correction amount in the state update equation, and flow prediction is performed through the compensated Kalman filter.

Benefits of technology

Improves measurement accuracy in complex and irregular flow changes environments, ensures timely response and smooth output, reduces estimation errors, and improves the adaptability and accuracy of flow measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120352004A_ABST
    Figure CN120352004A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a flow measurement method and device based on an improved Kalman filter and electronic equipment. The method comprises the following steps: compensating a residual error correction amount in a state updating equation of a Kalman filter based on a smoothing index weighting factor, and the smoothing index weighting factor is obtained by performing weighting calculation on a smoothing index weighting factor at a previous moment and a temporary weighting factor; the temporary weight factor is calculated by an average value between at least one first weight value calculated based on a robust loss function and at least one second weight value calculated based on a smooth function; and based on the compensated Kalman filter, performing Kalman filtering prediction on the measurement data at the current moment so as to determine the flow according to a prediction result. According to the embodiment of the invention, abnormal values can be inhibited robustly, smooth transition can be realized, timely tracking response and stable output are ensured, and the measurement accuracy in a complex and irregular flow change environment is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification belong to the field of flow measurement, and particularly relate to a flow measurement method, device, and electronic device based on an improved Kalman filter. Background Art

[0002] Ultrasonic flowmeters are widely used in the measurement of fluid flow. To improve the measurement accuracy, algorithms such as Kalman filtering can be combined for signal processing to compensate for noise, errors, and time delays that may occur during the flow measurement process. However, the traditional Kalman filtering algorithm has limitations in processing highly dynamic flow signals. Especially in the case of sudden or rapid changes in flow, it is difficult to make effective adjustments according to the dynamic changes in the complex flow measurement environment, thus affecting the measurement accuracy. Summary of the Invention

[0003] The embodiments of the present disclosure provide a flow measurement method, device, and electronic device based on an improved Kalman filter, aiming to solve one or more of the above problems and other potential problems.

[0004] According to a first aspect of the present disclosure, there is provided a flow measurement method based on an improved Kalman filter. The method includes: compensating the residual correction amount in the state update equation of the Kalman filter based on a smoothing exponential weighting factor, where the smoothing exponential weighting factor is obtained by weighted calculation of the smoothing exponential weighting factor at the previous moment and a temporary weighting factor, and the temporary weighting factor is obtained by calculating the average between at least one first weight value calculated based on a robust loss function and at least one second weight value calculated based on a smoothing function; and performing Kalman filter prediction on the measurement data at the current moment based on the compensated Kalman filter to determine the flow according to the prediction result.

[0005] According to a second aspect of the present disclosure, there is provided a flow measurement device based on an improved Kalman filter. The device includes: a state update equation compensation module configured to compensate the residual correction amount in the state update equation of the Kalman filter based on a smoothing exponential weighting factor, where the smoothing exponential weighting factor is obtained by weighted calculation of the smoothing exponential weighting factor at the previous moment and a temporary weighting factor, and the temporary weighting factor is obtained by calculating the average between at least one first weight value calculated based on a robust loss function and at least one second weight value calculated based on a smoothing function; and a flow calculation module configured to perform Kalman filter prediction on the measurement data at the current moment based on the compensated Kalman filter to determine the flow according to the prediction result.

[0006] According to a third aspect of the present disclosure, there is provided an electronic device, including one or more processors, and a memory associated with the one or more processors, where the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the method provided according to the first solution is executed.

[0007] According to a fourth aspect of the present disclosure, there is provided a computer program product, including a computer program, where when the computer program is executed by a processor, the method provided according to the first aspect is implemented.

[0008] It should be understood that the content described in the Summary of the Invention section is not intended to limit the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understandable through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In combination with the accompanying drawings and with reference to the following detailed description, the above and other features, advantages, and aspects of the embodiments of the present disclosure will become more obvious. In the drawings, the same or similar reference numerals denote the same or similar elements, where:

[0010] Figure 1 A schematic diagram showing an example environment in which multiple embodiments of the present disclosure can be implemented;

[0011] Figure 2 A schematic flowchart showing a flow measurement method based on an improved Kalman filter according to some embodiments of the present disclosure;

[0012] Figure 3 A schematic diagram showing the principle of a flow measurement method based on an improved Kalman filter according to some embodiments of the present disclosure;

[0013] Figure 4 A comparison schematic diagram showing the robustness and smoothness of time-of-flight difference data under different processes according to some embodiments of the present disclosure;

[0014] Figure 5 A comparison schematic diagram showing the hysteresis of flow data under different processes according to some embodiments of the present disclosure;

[0015] Figure 6 A comparison schematic diagram showing the comparison of time-of-flight difference data under zero drift verification under different processes according to some embodiments of the present disclosure;

[0016] Figure 7 A schematic structural diagram showing a flow measurement device based on an improved Kalman filter according to some embodiments of the present disclosure;

[0017] Figure 8 A schematic block diagram showing an electronic device according to some embodiments of the present disclosure. Detailed implementation manners

[0018] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present specification will be clearly and completely described below in conjunction with the embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.

[0019] The terms "including" and "having" and any variations thereof in this specification, the claims and the above drawings are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining" or "in response to detecting".

[0020] As described above, ultrasonic flowmeters mainly measure flow based on the time difference measurement method. It can transmit and receive ultrasonic signals through the device, calculate the flight time difference of the sound wave propagating in the pipeline, and thus deduce the flow rate according to the flight time difference and the ultrasonic propagation speed. The measurement accuracy of the flow rate is significantly affected by environmental factors (such as temperature, humidity, pressure, etc.), and effective compensation needs to be carried out for these changes.

[0021] The update steps of the traditional Kalman filtering algorithm are generally divided into the following five equations:

[0022] Current state prediction equation:

[0023] x(k|k - 1) = F · x(k - 1|k - 1)

[0024] Update covariance equation:

[0025] P(k|k - 1) = F · P(k - 1|k - 1) · F T + Q

[0026] Kalman gain equation:

[0027] K k = P(k|k - 1) · H(k) T · [H(k) · P(k|k - 1) · H(k) T + R k -1 ​

[0028] State update equation:

[0029] x(k|k) = x(k|k - 1)+K k ·[Z(k)-H(k)·x(k|k - 1)]

[0030] Covariance update equation:

[0031] P(k|k) = [I - K k ·H(k)]·P(k|k - 1)

[0032] Among them, x(k|k - 1) represents the prior estimate value, that is, the prediction of the system state at the current moment; x(k - 1|k - 1) represents the posterior estimate value at time k - 1, that is, the state update result at time k - 1; x(k|k) represents the posterior estimate value at the current moment k; F represents the state transition matrix, that is, the change rule of the system from time k - 1 to k; F T represents the transpose matrix of the state transition matrix; P(k|k - 1) represents the predicted error covariance at the current moment k, that is, the uncertainty between the predicted value and the true value of the system state at time k; P(k - 1|k - 1) represents the updated error covariance at the previous moment k - 1; Q represents the process noise covariance, that is, the uncertainty in the prediction process of the system; P(k|k) represents the posterior error covariance matrix at the current moment k; K k represents the Kalman gain; H(k) represents the measurement matrix, which maps the state of the system to the measurement space; H(k) T represents the transpose matrix of the measurement matrix; R k represents the measurement noise covariance matrix; Z(k) represents the actual measurement value at the current moment k; I represents the identity matrix.

[0033] In the above equations, the current state prediction equation is used to assume that the system follows a known dynamic law and infer the state at the next moment. The update covariance equation is used to quantify the uncertainty of the predicted value. The Kalman gain equation is used to adjust the size of the Kalman gain to determine whether to "trust" the predicted value or the measured value during the update. The state update equation is used to correct the predicted value through the measured value and reduce the estimation error. The covariance update equation is used to reduce the uncertainty of the state estimation by using the measurement information. In the actual filtering process, the prediction of the state at the next moment and its uncertainty estimation will be first completed jointly by the current state prediction equation and the update covariance equation, and then the data in the prediction stage will be corrected and updated according to the Kalman gain equation, the state update equation and the covariance update equation respectively. Finally, the prediction will be carried out again based on the corrected and updated data to form a closed-loop iteration.

[0034] Since these environmental changes are usually slow, in traditional Kalman filtering methods, the filter assumes that the process noise and measurement noise of the system are known and constant. However, in the flow measurement of ultrasonic flowmeters, changes in environmental factors directly affect the sound wave propagation speed. In the case of rapid flow changes, complex flow fluctuations and external noise occur, making it impossible for traditional Kalman filtering to effectively handle these dynamic changes and lacking an adaptive adjustment mechanism, resulting in limited measurement accuracy.

[0035] Some existing technologies dynamically adjust the Kalman gain matrix to enable real-time optimization of the filter's response speed according to changes in the system state, thereby reducing the errors caused by the above problems. However, these methods mostly rely on simple gain adjustment and lack adaptive adjustment to the system's dynamic changes. In the face of high-dynamic flow changes, especially when the flow fluctuations are large or the environmental noise is strong, the compensation effect is still limited, and the system stability and measurement accuracy cannot be fully guaranteed.

[0036] In response to this, embodiments of the present disclosure propose a flow measurement method based on an improved Kalman filter. In embodiments of the present disclosure, the method may include setting a smoothing exponential weighting factor to compensate the residual correction amount calculation part of the state update equation in the Kalman filter through this smoothing exponential weighting factor. The smoothing exponential weighting factor is determined by weighted calculation of the smoothing exponential weighting factor at the previous moment and an additionally calculated temporary weighting factor. The temporary weighting factor can be specifically obtained by calculating the first weighting value and the second weighting value using a robust loss function and a smoothing function respectively and then calculating the average value of the two weighting values. In addition, the method may further include inputting the measurement data obtained by the ultrasonic flowmeter at the current moment into the compensated Kalman filter to predict the output prediction result through the Kalman filtering of the Kalman filter. The prediction result may be more accurate measurement data predicted after filtering correction. According to the output prediction result, the flow rate can be determined.

[0037] Through the above method, the state update equation of the Kalman filter can be compensated by the smoothing exponential weighting factor, so that the compensated Kalman filter can adaptively compensate and adjust the value of the residual correction amount in the state update equation according to the smoothing exponential weighting factor that changes with the complex environment, so as to reduce the estimation error caused by the state update equation, and further improve the accuracy of the overall prediction result obtained. In addition, a robust loss function and a smoothing function are also used to calculate a weight value respectively, and a temporary weight factor is calculated according to the average value of these weight values. Then, by performing weighted calculation on the temporary weight factor and the smoothing exponential weighting factor at the previous moment (the smoothing exponential weighting factor can be a preset value at the initial moment), the smoothing exponential weighting factor at the current moment can be obtained. By introducing the temporary weight factor to continuously calculate the latest smoothing exponential weighting factor, the response in the state update can not only robustly suppress outliers, but also smoothly transition, ensuring that the tracking response is timely and the output is stable, thereby improving the measurement accuracy in a complex and irregular traffic change environment.

[0038] Figure 1 FIG. shows a schematic diagram of an exemplary environment 100 in which multiple embodiments of the present disclosure can be implemented. As Figure 1As shown, the environment 100 may include a pipeline 101, an ultrasonic flowmeter, a Kalman filter 104, and a terminal 105. The ultrasonic flowmeter may include an ultrasonic transducer 102 and a converter 103. The ultrasonic transducer 102 is responsible for transmitting and receiving ultrasonic signals. Depending on the working mode, only one transducer may be required, or multiple transducers may be needed to send signals to each other. The converter 103 is used to control the working state of the ultrasonic transducer 102, and collect and process the ultrasonic propagation time data obtained from the ultrasonic transducer 102. There is a fluid in the pipeline 101 that needs to have its flow rate measured, and the fluid generally flows along a certain radial direction of the pipeline 101. Taking the example where two ultrasonic transducers 102 are set, the ultrasonic signals collected by the two ultrasonic transducers 102 are respectively the ultrasonic propagation time data propagating along the flow direction and the ultrasonic propagation time data propagating against the flow direction. According to the difference between the propagation durations of the two ultrasonic propagation time data, the required time-of-flight difference can be determined, and then the flow rate can be calculated based on the time-of-flight difference. Under the influence of a complex environment, the flow rate directly calculated based on the collected ultrasonic propagation time data is inaccurate, and a Kalman filter 104 needs to be used for filtering and prediction processing to obtain a more accurate result. The Kalman filter 104 can directly perform filtering and prediction processing on the flow rate calculated by the ultrasonic flowmeter to obtain a more accurate flow rate, or it can perform filtering and prediction processing on the ultrasonic propagation time data collected by the ultrasonic flowmeter, and then calculate the time-of-flight difference and the flow rate through the filtered ultrasonic propagation time data. Depending on the different positions where the Kalman filter 104 is set, the processing method of the ultrasonic flowmeter for the ultrasonic propagation time data can also be different. For example, the Kalman filter 104 can be set independently, integrated in the ultrasonic flowmeter, or integrated into the terminal 105, etc. In Figure 1Among them, the case where the Kalman filter 104 is independently set will be taken as an example for illustration. The ultrasonic flowmeter sends measurement data (which can be flow rate, ultrasonic propagation time data, etc.) to the Kalman filter 104 for filtering and prediction processing. After the measurement data is filtered and predicted, it will be output as a prediction result into the terminal 105 to determine the final flow rate in the terminal 105, and the flow rate can also be displayed on the display of the terminal 105. The terminal 105 can be any device with computing or processing capabilities. For example, the terminal 105 can include, but is not limited to, mobile phones, tablet computers, desktop computers, servers, etc. In this way, the Kalman filter compensated for the residual correction amount in the state update equation by using a smoothed exponential weighting factor can be used to filter and predict sensor data, so as to achieve adaptive weight compensation through the smoothed exponential weighting factor, enabling the response in the state update to robustly suppress outliers and smoothly transition, ensuring that the tracking response is timely and the output is stable, thereby improving the measurement accuracy in a complex and irregular flow rate change environment.

[0039] Figure 2 The flowchart of the flow measurement method 200 based on an improved Kalman filter according to some embodiments of the present disclosure is shown. The method 200 can be executed by the terminal 105, for example. As Figure 2As shown, at block 202, method 200 may compensate for the residual correction amount in the state update equation of the Kalman filter based on a smoothing exponential weighting factor, which is calculated by weighting the smoothing exponential weighting factor at the previous moment and a temporary weighting factor. The temporary weighting factor is calculated as the average between at least one first weighting value calculated based on a robust loss function and at least one second weighting value calculated based on a smoothing function. In this embodiment, considering the complex and irregular traffic change environment, to filter and reduce the impact of the environment on the accuracy of the sensor data collected by the sensor, it is necessary to perform robust suppression on outliers and smooth the normal data, and this process needs to be adaptively adjusted as the system state changes rapidly. Therefore, in this embodiment, a robust loss function (such as the Huber function) and a smoothing function (such as the Sigmoid function) are set up to calculate the first weighting value and the second weighting value respectively, and the average of the two is used as the temporary weighting factor to adaptively adjust the smoothing exponential weighting factor at each moment through the temporary weighting factor, and then adaptively compensate for the residual correction amount in the state update equation of the Kalman filter (that is, the difference between the actual measurement value and the prior estimate value at the current moment) according to the smoothing exponential weighting factor, so that the Kalman filter can compensate for the filtering process accurately in real time. Among them, the specific values of the first weighting value and the second weighting value can be set to be related to the actual innovation covariance (the covariance of the difference between the actual measurement value and the predicted value), or can be set to be related to the residual, etc. Taking the residual as an example, under the calculation of the robust loss function, the first weighting value can be used to measure the penalty degree of the residual to attenuate the update amplitude according to the size of the residual, while under the calculation of the smoothing function, the second weighting value can be used to adjust the smoothing strength according to the size of the residual to ensure that the weight does not suddenly jump within the critical region. By calculating the average of the first weighting value and the second weighting value to update the smoothing exponential weighting factor, it is possible to take into account both outlier suppression and smooth data smoothing, and improve the adaptive ability of the filtering in dynamic scenarios.

[0040] At block 204, method 200 may perform Kalman filtering prediction on the measurement data at the current moment based on a compensated Kalman filter to determine the flow rate according to the prediction result. In this embodiment, through the compensated Kalman filter, Kalman filtering prediction can be performed on the measurement data obtained at the current moment, and the obtained prediction result can be regarded as the real data after filtering processing and excluding the influence of the dynamic environment. According to the types of the input measurement data being different, the types of the measurement results obtained after filtering will also be different. For example, the measurement result may be the ultrasonic propagation duration data collected by ultrasonic transducers at different positions. At this time, by calculating the difference between the reverse propagation duration and the forward propagation duration, the time-of-flight difference can be determined more accurately, and then the flow rate can be calculated based on the time-of-flight difference. Another example is that the measurement result may directly be the flow rate, and in this case, the measurement result can be directly used as the finally obtained flow rate.

[0041] Figure 3 FIG. shows a schematic diagram of the principle of a flow rate measurement method based on an improved Kalman filter according to some embodiments of the present disclosure. In process 300, in order to enable the Kalman filter 104 to adaptively adjust to a rapidly changing dynamic environment, in this embodiment, the state update equation in the above equation will be adjusted. Specifically, a first weight value 302 will be calculated through a robust loss function 301, and a second weight value 304 will be calculated through a smoothing function 303. Then, by calculating the average value of the first weight value 302 and the second weight value 304, a temporary weight factor 305 can be obtained, and then the smoothing exponential weighting factor 306 at the current moment can be calculated and determined based on the temporary weight factor 305. Through the smoothing exponential weighting factor 306, the state update equation in the Kalman filter 104 can be compensated so that the compensated Kalman filter 104 can perform filtering prediction on the input sensor data 307 to output a filtered prediction result 308.

[0042] where, assuming the smoothing exponential weighting factor is ρ k , the state update equation of the compensated Kalman filter can be:

[0043] x(k|k) = x(k|k - 1) + ρ k ·K k ·[Z(k) - H(k)·x(k|k - 1)]

[0044] The smoothing exponential weighting factor ρ k has the following calculation formula:

[0045] ρ k = (1 - ∝)·ρ k-1 + ∝·ρ temp

[0046] where, ρ k-1Indicates the smoothing exponential weighting factor at the previous moment, ρ temp Indicates the temporary weight factor. ∝ represents the smoothing coefficient, which is used for weighted averaging between the smoothing exponential weighting factor at the previous moment and the temporary weight factor calculated at the current moment. By adjusting the magnitude of ∝, a trade-off can be made between smoothness and response speed: the larger ∝ is, the higher the proportion of new data, and the faster the filter responds; the smaller ∝ is, the more historical information is emphasized, the output is more stable but the response to instantaneous changes is slower. As an example, ∝ can be a fixed coefficient of 0.3.

[0047] In some embodiments of the present disclosure, both the first weight value and the second weight value are negatively correlated with the innovation covariance ratio, which is determined based on the ratio of the actual innovation covariance to the theoretical innovation covariance. The theoretical innovation covariance includes the absolute value of the sum of the prediction error covariance at the current moment and the measurement noise covariance matrix. In this embodiment, the first weight value and the second weight value can be related to the first residual, that is, the ratio of the actual innovation covariance to the theoretical innovation covariance, which can better reflect the relationship between the current actual innovation term and the theoretical innovation term. As an example, the first residual δ x The calculation formula can be:

[0048]

[0049] where c k is the actual innovation covariance, P(k|k - 1) represents the prediction error covariance at the current moment k, R k represents the measurement noise covariance matrix, and ε is a very small positive number, which is used to ensure that the value inside the square root is always non-negative.

[0050] After determining the first residual, the robust loss function can be set as:

[0051]

[0052] where p huber is the first weight value, c0 represents the set threshold, which is used to attenuate the update amplitude according to the magnitude of the residual, and σ controls the rate of exponential decay, usually taking a fixed value between 0 and 1.

[0053] The smoothing function can be set as:

[0054]

[0055] where p Sigmoid is the second weight value, k param represents the smoothing parameter. The smaller its value, the steeper the transition of the smoothing function is considered, which means that the filter is more sensitive to the change of the residual, the response speed is faster, but the smoothness may be reduced. Considering the smooth transition of the filtering, kparam Take a fixed value of 0.3. In this way, when |δ x | is much smaller than c0, the exponential term approaches negative infinity, and the output of the smoothing function approaches 1. When |δ x | is much larger than c0, the output of the smoothing function approaches 0.

[0056] Figure 4 The figure shows a comparison schematic diagram of data waveforms under different processes in terms of robustness and smoothness in some embodiments of the present disclosure. The abscissa in the figure can represent the number of samplings, and the ordinate can represent the time difference of flight. The original data is represented as the time difference of flight data directly obtained without filtering by a Kalman filter. The original Kalman filter data is represented as the time difference of flight data obtained after filtering by a traditional Kalman filter without any compensation. The filtered data of this application is represented as the time difference of flight data obtained after filtering by a Kalman filter compensated by a smoothing exponential weighting factor. Since the characteristics of the data processed by the Kalman filter are consistent in terms of robustness and smoothness after being set up, in order to more intuitively reflect the differences in robustness and smoothness of the data under different processes, different data in a static environment can be directly tested for comparison. In addition, there is a linear relationship between the time difference of flight and the flow rate, and the tests of robustness and smoothness are generally zero-point tests. It is difficult to see the effect by directly comparing the flow rate data. Therefore, the comparison result of the flow rate will be indirectly indicated by the comparison result of the time difference of flight. As can be seen from the figure, although the traditional Kalman filtering algorithm filters out mutation values and outliers to a certain extent to ensure smoothness, excessive smoothing makes the shape of the curve quite different from the original data, and excessive filtering of mutation values makes the overall robustness of the curve not ideal enough. However, for the data curve obtained by the filtering method of this application, the weight of the residual correction amount can be dynamically adjusted through the smoothing exponential weighting factor, so that the prediction result takes into account both smoothness and robustness, and the result is closer to the actual true value.

[0057] In some embodiments of the present disclosure, the method may further include: in response to the innovation covariance ratio being not greater than a preset threshold, determining the temporary weight factor as a fixed value; in response to the innovation covariance ratio being greater than the preset threshold, determining the temporary weight factor as the average value between at least one first weight value calculated based on a robust loss function and at least one second weight value calculated based on a smoothing function. In this embodiment, considering that when the first residual is small, it indicates that the system is in a normal state, and at this time, the filtering does not need to be adjusted to maintain the stable output of the filtering. Only when the first residual is large, it is necessary to adjust the weight to reduce the impact on the filtering result. Therefore, a preset threshold can be set. For example, the threshold c0 used in the robust loss function and the smoothing function can be directly used. When the temporary weight factor is not greater than the preset threshold, the temporary weight factor is determined as a fixed value, such as 1, and when the temporary weight factor is greater than the preset threshold, the average value of the first weight value and the second weight value will be calculated.

[0058] In some embodiments of the present disclosure, method 200 may further compensate the update error covariance at the previous moment in the update covariance equation of the Kalman filter based on a fading factor. The fading factor is determined by the ratio between the trace of the first calculation data and the trace of the second calculation data. The first calculation data includes the predicted error covariance at the current moment, and the second calculation data includes the difference between the actual innovation covariance and the noise covariance. The noise covariance includes the measurement noise covariance and the process noise covariance. In this embodiment, since the measurement of the ultrasonic flowmeter is usually affected by factors such as the sensor response time and signal processing delay, the measurement result shows a lag phenomenon. This lag effect will affect the accuracy of state estimation. Especially in the case of rapid flow changes, the filter may not be able to respond to the changing signal in time. To address this problem, a fading factor β is introduced to compensate for the delay phenomenon in the system response. The compensated update covariance equation can be:

[0059] P(k|k - 1) = β·F·P(k - 1|k - 1)·F T +Q

[0060] The calculation formula of the fading factor β can be:

[0061]

[0062] M k =c k -H(k)·Q·H(k) T -R k

[0063] N k =H(k)·F·P(k - 1|k - 1)·F T ·H(k) T

[0064] Among them, tr() represents the trace of the data, that is, the sum of all elements on the diagonal of the matrix, N k is the first calculation data, M k is the second calculation data.

[0065] When the system state changes rapidly, the first calculation data will significantly exceed the second calculation data, causing the fading factor to change accordingly. As a result, the predicted error covariance obtained by synchronously adjusting and updating the covariance equation is adjusted, and then the Kalman gain is adjusted to enable the filter to respond quickly to mutations. When the system is stable, the fading factor will remain at a fixed value, such as 1, enabling the filter to be updated in a conventional manner. Through this mechanism, the filter can not only effectively compensate for the lag effect caused by state mutations but also maintain smooth and robust filtering performance under steady-state conditions.

[0066] In some embodiments of the present disclosure, the method may further include: in response to the initial moment, the actual innovation covariance is determined as the covariance of the residual value, where the residual value includes the difference between the actual measurement value at the current moment and the prior estimate value; in response to a non-initial moment, the actual innovation covariance is calculated based on the weighted average of the actual innovation covariance at the initial moment by the fading factor at the current moment. In this embodiment, after introducing the fading factor for compensation, it is difficult to accurately obtain the actual innovation covariance through the difference between the actual measurement value and the predicted value. Therefore, the data determined at the initial moment will be weighted and recursively updated according to the fading factor, and the updated result is used as the actual innovation covariance at the current moment to more accurately measure the statistical characteristics of the difference between the measurement value and the predicted value. The actual innovation covariance c k The calculation formula of can be:

[0067]

[0068] Among them, c1 is the residual value.

[0069] Figure 5The figure shows a comparison diagram of traffic data under different processes in terms of hysteresis in some embodiments of the present disclosure. The abscissa in the figure can represent the number of samplings, and the ordinate can represent the traffic. The original data represents the traffic data obtained directly without filtering by the Kalman filter. The original Kalman filter data represents the traffic data obtained after filtering by a traditional Kalman filter without any compensation. The Kalman filter data of the present application represents the traffic data obtained after filtering by a Kalman filter compensated by a fading factor. It can be seen from the figure that in a complex environment where the traffic changes rapidly, when the system undergoes a mutation, the change of data by the traditional Kalman filter algorithm always has a certain hysteresis. However, the data of the present application obtained by introducing the fading factor compensation is closer to the original data in terms of the data change law and there is no significant hysteresis problem.

[0070] In some embodiments of the present disclosure, the method 200 can also update the measurement noise covariance matrix of the Kalman filter based on a dynamic weighting factor. The dynamic weighting factor is calculated from the cumulative change amount of a preset forgetting factor at time steps, and the dynamic weighting factor decreases as the time step increases. In this embodiment, in order to timely compensate for the noise interference caused by the dynamic change of traffic and greatly improve the robustness, adaptability, and measurement accuracy of filtering, the dynamic weighting factor can also be used to update the measurement noise covariance matrix R k in real time.

[0071] The dynamic weighting factor γ k can be calculated by the formula:

[0072]

[0073] where τ represents the forgetting factor, which determines the speed at which the Kalman filter "forgets" past information. The forgetting factor usually takes values between 0 and 1, and a larger τ means more dependence on past data. γ k will change with the number of iteration steps at time steps. By adjusting γ k , the filter can give more weight to new data in a rapidly changing environment, thereby improving the response speed and accuracy of the system.

[0074] In some embodiments of the present disclosure, the process of updating the measurement noise covariance matrix of the Kalman filter based on the dynamic weighting factor can include performing a weighted calculation on the measurement noise covariance matrix at the previous moment and the third calculation data based on the dynamic weighting factor to update the measurement noise covariance matrix at the current moment to the obtained weighted value. The third calculation data includes the difference between the actual innovation covariance and the updated error covariance at the previous moment.

[0075] The measurement noise covariance matrix R kThe update formula can be:

[0076] R k =(1 - γ k )·R k-1 +γ k (c k -H(k)·P(k - 1|k - 1)·H(k) T )

[0077] Through the above weighted calculation method, the balance between the historical measurement noise covariance matrix and the actual measurement value at the current moment can be controlled, enabling the filter to adaptively adjust the degree of dependence on past and current data. Furthermore, the filter can flexibly adjust the noise model in a changing environment, improving the adaptability of measurement.

[0078] Figure 6 Fig. shows a comparison schematic diagram of the time - of - flight difference data under different processes of some embodiments of the present disclosure under zero - drift verification. The abscissa in the figure can represent the number of samplings, and the ordinate can represent the time - of - flight difference. Zero - drift refers to the measurement error of the ultrasonic flowmeter when the flow rate is zero, which is mainly caused by the time - of - flight difference of the forward and reverse signals due to pipeline structure or sensor performance differences. Especially at low flow rates, this error is more significant. Similarly, zero - drift verification is a zero - point test, so the data comparison of the flow rate is characterized by the data comparison of the time - of - flight difference. It can be seen from the figure that in a complex environment with rapidly changing flow rates, compared with the original data without processing, after the present application introduces a dynamic weighting factor to update the measurement noise covariance matrix, the zero - drift range is reduced from ±200 Ps to ±60 Ps, indicating that the filtering algorithm adjusted by the dynamic weighting factor effectively improves the measurement stability by dynamically adjusting the measurement noise covariance matrix.

[0079] Figure 7 Fig. shows a schematic structural diagram of a flow measurement device 700 based on an improved Kalman filter according to some embodiments of the present disclosure. Each embodiment in this specification is described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. As Figure 7As shown, device 700 includes a state update equation compensation module 701 configured to compensate for a residual correction amount in a state update equation of a Kalman filter based on a smoothing exponential weighting factor, where the smoothing exponential weighting factor is obtained by weighted calculation of the smoothing exponential weighting factor at the previous moment and a temporary weighting factor, and the temporary weighting factor is calculated as an average between at least one first weighting value calculated based on a robust loss function and at least one second weighting value calculated based on a smoothing function. In addition, device 700 further includes a flow calculation module 702 configured to perform Kalman filter prediction on measurement data at the current moment based on the compensated Kalman filter to determine a flow according to a prediction result.

[0080] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of this specification are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium accessible by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a Digital Versatile Disc (DVD)), or a semiconductor medium (such as a Solid State Disk (SSD)), etc.

[0081] Figure 8 The block diagram of an electronic device 800 in which multiple embodiments of the present disclosure can be implemented is shown. As Figure 8 shown, the electronic device 800 includes a processor 810, a disk drive 820, an input / output interface 830, a network interface 840, and a memory 850. The above-mentioned processor 810, disk drive 820, input / output interface 830, and network interface 840 can be communicatively connected to the memory 850 through a communication bus 860.

[0082] Among them, the processor 810 can be implemented in ways such as a general-purpose CPU, a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in this application.

[0083] The memory 850 can be implemented in forms such as ROM (Read Only Memory), RAM (Read Access Memory), a static memory, a dynamic storage device, etc. The memory 850 can store an operating system 851 for controlling the operation of the electronic device 800, and a basic input / output system (BIOS) 852 for controlling the low-level operations of the electronic device 800. Additionally, a web browser 853, a data storage management system 854, etc. can also be stored. In short, when implementing the technical solutions provided in this application through software or firmware, the relevant program codes are stored in the memory 850 and are called and executed by the processor 810.

[0084] The input / output interface 830 is used to connect to the input / output module to achieve information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Among them, the input devices can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices can include a display, a speaker, a vibrator, a warning light, etc.

[0085] The network interface 840 is used to connect to a communication module (not shown in the figure) to achieve communication and interaction between the device and other devices. Among them, the communication module can achieve communication through a wired method (such as USB, network cable, etc.) or through a wireless method (such as a mobile network, WIFI, Bluetooth, etc.).

[0086] The bus 860 includes a path for transmitting information between various components of the device (such as the processor 810, the disk drive 820, the input / input interface 830, the network interface 840, and the memory 850).

[0087] It should be noted that although the above device only shows the processor 810, the disk drive 820, the input / input interface 830, the network interface 840, the memory 850, the bus 860, etc., in the specific implementation process, the device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may only include the components necessary to implement the method of this application and does not necessarily include all the components shown in the figure.

[0088] The program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, a special purpose computer, or other programmable data processing device, such that the program codes, when executed by the processor or controller, cause the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine, or entirely on the remote machine or server.

[0089] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. Additionally, although the operations are depicted in a particular order, this should be understood to require that the operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed to achieve the desired result. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the foregoing discussion, these should not be construed as limitations on the scope of the present disclosure. Certain features that are described in the context of separate embodiments may also be implemented in combination in a single implementation. Conversely, various features that are described in the context of a single implementation may also be implemented separately or in any suitable sub-combination in multiple implementations.

[0090] Although the subject matter has been described in language specific to structural features and / or methodological acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

Claims

1. A flow measurement method (200) based on an improved Kalman filter, characterized in that, The method includes: Compensating the residual correction amount in the state update equation of the Kalman filter based on a smoothing exponential weighting factor, where the smoothing exponential weighting factor is calculated by weighting the smoothing exponential weighting factor at the previous moment and a temporary weighting factor, and the temporary weighting factor is calculated as the average between at least one first weighting value calculated based on a robust loss function and at least one second weighting value calculated based on a smoothing function; and Performing Kalman filter prediction on the measurement data at the current moment based on the compensated Kalman filter to determine the flow rate according to the prediction result.

2. The method (200) according to claim 1, characterized in that, Both the first weighting value and the second weighting value are negatively correlated with the innovation covariance ratio, where the innovation covariance ratio is determined based on the ratio of the actual innovation covariance to the theoretical innovation covariance, and the theoretical innovation covariance includes the absolute value of the sum of the prediction error covariance at the current moment and the measurement noise covariance matrix.

3. The method (200) according to claim 2, characterized in that, The method further includes: In response to the innovation covariance ratio not being greater than a preset threshold, the temporary weighting factor is determined as a fixed value; In response to the innovation covariance ratio being greater than the preset threshold, the temporary weighting factor is determined as the average between at least one first weighting value calculated based on a robust loss function and at least one second weighting value calculated based on a smoothing function.

4. The method (200) according to claim 1, wherein, The method further includes: Compensating the update error covariance at the previous moment in the update covariance equation of the Kalman filter based on a fading factor, where the fading factor is determined by the ratio of the trace of the first calculation data to the trace of the second calculation data, the first calculation data includes the prediction error covariance at the current moment, and the second calculation data includes the difference between the actual innovation covariance and the noise covariance, and the noise covariance includes the measurement noise covariance and the process noise covariance.

5. The method (200) according to claim 4, characterized in that, The method further includes: In response to the initial moment, the actual innovation covariance is determined as the covariance of the residual value, where the residual value includes the difference between the actual measurement value at the current moment and the prior estimate value; In response to a non-initial moment, the actual innovation covariance is calculated as the weighted average of the actual innovation covariance at the initial moment based on the fading factor at the current moment.

6. The method (200) according to claim 1, wherein, The method further includes: Updating the measurement noise covariance matrix of the Kalman filter based on a dynamic weighting factor, where the dynamic weighting factor is calculated by the cumulative change amount of a preset forgetting factor over time steps, and the dynamic weighting factor decreases as the time steps increase.

7. The method (200) according to claim 6, characterized in that, The updating the measurement noise covariance matrix of the Kalman filter based on the dynamic weighting factor includes: Based on the dynamic weighting factor, performing a weighted calculation on the measurement noise covariance matrix at the previous moment and the third calculation data to update the measurement noise covariance matrix at the current moment to the obtained weighted value, where the third calculation data includes the difference between the actual innovation covariance and the update error covariance at the previous moment.

8. A flow measurement device (700) based on an improved Kalman filter, characterized in that, The device includes: A state update equation compensation module (701) is configured to compensate for a residual correction amount in a state update equation of a Kalman filter based on a smoothed exponential weighting factor, where the smoothed exponential weighting factor is obtained by weighted calculation of the smoothed exponential weighting factor at the previous moment and a temporary weighting factor, and the temporary weighting factor is obtained by calculating an average value between at least one first weighting value calculated based on a robust loss function and at least one second weighting value calculated based on a smoothing function; and A flow calculation module (702) is configured to perform Kalman filter prediction on measurement data at the current moment based on the compensated Kalman filter, so as to determine the flow according to the prediction result.

9. An electronic device, comprising: One or more processors, and A memory associated with the one or more processors, where the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the steps of the method according to any one of claims 1-7 are executed.

10. A computer program product, comprising a computer program, where when the computer program is executed by a processor, the method according to any one of claims 1-7 is implemented.

Citation Information

Patent Citations

  • Electrical power system dynamic state estimation method base on unscented transformation Kalman filter

    CN101615794A

  • Tight-integration adaptive filtering method of resisting to outliers of global positioning system,

    CN103983996A

  • GPS measurement data processing method based on self-adaptive filtering

    CN107229060A

  • UKF-based power distribution network dynamic robust state estimation method

    CN107565553A

  • Trajectory denoising method based on bidirectional long-short time memory model and Kalman filtering

    CN110232169A