Traffic calculation method and device, electronic equipment and storage medium
By calculating the residual and residual fluctuations between the observed and predicted values of the electromagnetic flowmeter, the weights are dynamically adjusted to eliminate the influence of the error flow rate, which improves the accuracy of the flow rate calculation and solves the error flow rate problem caused by the noise signal.
Patent Information
- Application Number
- CN202510811835.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-06-17
Smart Images

Figure CN120352003A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electromagnetic flowmeter signal processing, and particularly to a flow calculation method, device, electronic device and storage medium. Background Art
[0002] An electromagnetic flowmeter is a flow measurement device based on the electromagnetic induction law and can be used to measure the flow rate and velocity of conductive liquids. Due to the influence of noise signals, there is a certain error between the measured velocity of the electromagnetic flowmeter and the true velocity. In the following text, this error is referred to as the error velocity. The error velocity not only is affected by noise signals but also changes with the change of the true velocity, that is, the error velocity is dynamically changing. The existence of the error velocity will lead to a decrease in the accuracy of the flow rate measured by the electromagnetic flowmeter. Therefore, how to dynamically eliminate the error velocity to improve the accuracy of flow calculation has become an urgent problem to be solved. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide a flow calculation method, device, electronic device and storage medium to dynamically eliminate the influence of the error velocity on the accuracy of flow calculation, thereby improving the accuracy of flow calculation. The specific technical solutions are as follows:
[0004] The embodiments of the present application provide a flow calculation method, and the method includes:
[0005] Calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment;
[0006] Calculate the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each co-window moment as the residual fluctuation amount corresponding to the target moment, where the co-window moment is other moments within the same time window as the target moment;
[0007] Use the first weight as the weight of the observed value at the target moment and the second weight as the weight of the predicted value at the target moment, and perform weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment, where the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment.
[0008] In a possible embodiment, the step of using the first weight as the weight of the observed value at the target moment and the second weight as the weight of the predicted value at the target moment, and performing weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment includes:
[0009] If the residual fluctuation amount corresponding to the target time is greater than the first intensity threshold, the observed value of the target time is weighted with the third weight, and the predicted value of the target time is weighted with the fourth weight, and the weighted sum of the observed value and the predicted value of the target time is obtained, where the third weight is greater than the fourth weight; the first intensity threshold is calculated based on the flow velocity at the target time;
[0010] If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold, the observed value of the target time is weighted with the fifth weight, and the predicted value of the target time is weighted with the sixth weight, and the weighted sum of the observed value and the predicted value of the target time is obtained, where the sixth weight is greater than the fifth weight, the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight.
[0011] In a possible embodiment, the step of, if the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold, weighting the observed value of the target time with the fifth weight and weighting the predicted value of the target time with the sixth weight, and performing a weighted sum of the observed value and the predicted value of the target time includes:
[0012] If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and not greater than the first fluctuation amount threshold, the observed value of the target time is weighted with the fifth weight, and the predicted value of the target time is weighted with the sixth weight, and the weighted sum of the observed value and the predicted value of the target time is performed; the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each of the same-window times;
[0013] If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and greater than the first fluctuation amount threshold, the observed value of the target time is weighted with the third weight, and the predicted value of the target time is weighted with the fourth weight, and the weighted sum of the observed value and the predicted value of the target time is performed.
[0014] In a possible embodiment, the step of weighting the observed value of the target time with the first weight and weighting the predicted value of the target time with the second weight, and performing a weighted sum of the observed value and the predicted value of the target time to obtain the calculated value of the target time includes:
[0015] If the residual fluctuation amount corresponding to the target time is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold, then the weight of the observed value at the target time is the seventh weight, and the weight of the predicted value at the target time is the eighth weight. The observed value and the predicted value at the target time are weighted and summed to obtain the calculated value at the target time. Wherein, the residual mean value is the mean value of the residual corresponding to the target time and the residuals corresponding to each co-window time; the seventh weight is greater than the eighth weight; the second intensity threshold is calculated based on the flow velocity at the target time.
[0016] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight. The observed value and the predicted value at the target time are weighted and summed to obtain the calculated value at the target time. Wherein, the tenth weight is greater than the ninth weight, the seventh weight is greater than the ninth weight, and the tenth weight is greater than the eighth weight.
[0017] In a possible embodiment, the step of, if the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight, and the observed value and the predicted value at the target time are weighted and summed, includes:
[0018] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation threshold, and the residual mean value is not greater than the second intensity threshold and the residual mean value is not greater than the second fluctuation threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight. The observed value and the predicted value at the target time are weighted and summed; the second fluctuation threshold is statistically obtained based on the residual fluctuation amounts corresponding to each co-window time.
[0019] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is greater than the second fluctuation threshold, or, the residual mean value is not greater than the second intensity threshold and the residual mean value is greater than the second fluctuation threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight. The observed value and the predicted value at the target time are weighted and summed.
[0020] In a possible embodiment, the method further includes:
[0021] Calculate an intensity threshold as the first intensity threshold or the second intensity threshold according to the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target moment; wherein, the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and is positively correlated with the flow velocity at the target moment;
[0022] Calculate the product of the residual fluctuation amount corresponding to the target moment and the maximum value of the residual fluctuation amounts corresponding to each of the same-window moments and a preset magnification factor to obtain a fluctuation amount threshold as the first fluctuation amount threshold or the second fluctuation amount threshold, wherein the preset magnification factor is positively correlated with the flow velocity at the target moment.
[0023] In a possible embodiment, the intensity threshold is calculated in the following manner, including:
[0024] ;
[0025] wherein, △Flow is the intensity threshold; S is the pipe cross-sectional area of the electromagnetic flowmeter; v is the flow velocity at the target moment; a1, a2, a3, th1, th2 are all parameters, and a1 < a2 < a3;
[0026] The fluctuation amount threshold is calculated in the following manner:
[0027] ;
[0028] wherein, is the fluctuation amount threshold; is the preset magnification factor; is the maximum value of the residual fluctuation amount corresponding to the target moment and the residual fluctuation amounts corresponding to each of the same-window moments;
[0029] The preset magnification factor is calculated in the following manner, including:
[0030] ;
[0031] wherein, is the preset magnification factor; v is the flow velocity at the target moment; b1, b2, b3, th1, th2 are all parameters, and b1 < b2 < b3.
[0032] In a possible embodiment, calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual fluctuation amount corresponding to the target moment includes:
[0033] Calculate the mean value of the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual mean value;
[0034] Calculate the difference between the residual corresponding to the target moment and the mean value of the residuals as the residual fluctuation amount corresponding to the target moment.
[0035] In a possible embodiment, calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment includes:
[0036] ;
[0037] where k is the target moment, and e k is the residual corresponding to the target moment; Y k is the observed value at the target moment; H is an observation matrix of m×n; X k is the predicted value at the target moment;
[0038] Calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the mean value of the residuals includes:
[0039] ;
[0040] where γ k is the mean value of the residuals; m is the time window where the target moment is located; k is the target moment; e i is the residual corresponding to the i-th moment within the time window where the target moment is located;
[0041] Calculating the difference between the residual corresponding to the target moment and the mean value of the residuals as the residual fluctuation amount corresponding to the target moment includes:
[0042] ;
[0043] where is the residual fluctuation amount corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the mean value of the residuals.
[0044] The embodiment of the present application further provides a flow calculation device, and the device includes:
[0045] A residual calculation module, configured to calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment;
[0046] A residual fluctuation amount calculation module, configured to calculate the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each co-window moment respectively as the residual fluctuation amount corresponding to the target moment, where the co-window moment is other moments within the same time window as the target moment;
[0047] A calculation value obtaining module, configured to perform weighted summation on the observed value and the predicted value of the target moment with the first weight as the weight of the observed value of the target moment and the second weight as the weight of the predicted value of the target moment to obtain the calculation value of the target moment, where the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment.
[0048] In a possible embodiment, the performing weighted summation on the observed value and the predicted value of the target moment with the first weight as the weight of the observed value of the target moment and the second weight as the weight of the predicted value of the target moment to obtain the calculation value of the target moment includes:
[0049] If the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, then perform weighted summation on the observed value and the predicted value of the target moment with the third weight as the weight of the observed value of the target moment and the fourth weight as the weight of the predicted value of the target moment to obtain the calculation value of the target moment; where the third weight is greater than the fourth weight; the first intensity threshold is calculated based on the flow rate of the target moment;
[0050] If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, then perform weighted summation on the observed value and the predicted value of the target moment with the fifth weight as the weight of the observed value of the target moment and the sixth weight as the weight of the predicted value of the target moment to obtain the calculation value of the target moment; where the sixth weight is greater than the fifth weight, and the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight.
[0051] In a possible embodiment, the if the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, then perform weighted summation on the observed value and the predicted value of the target moment with the fifth weight as the weight of the observed value of the target moment and the sixth weight as the weight of the predicted value of the target moment includes:
[0052] If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and not greater than the first fluctuation amount threshold, then use the fifth weight as the weight of the observed value at the target time and the sixth weight as the weight of the predicted value at the target time, and perform weighted summation on the observed value and the predicted value at the target time; the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each of the same-window times;
[0053] If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and greater than the first fluctuation amount threshold, then use the third weight as the weight of the observed value at the target time and the fourth weight as the weight of the predicted value at the target time, and perform weighted summation on the observed value and the predicted value at the target time.
[0054] In a possible embodiment, the step of using the first weight as the weight of the observed value at the target time and the second weight as the weight of the predicted value at the target time, and performing weighted summation on the observed value and the predicted value at the target time to obtain the calculated value at the target time includes:
[0055] If the residual fluctuation amount corresponding to the target time is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold, then use the seventh weight as the weight of the observed value at the target time and the eighth weight as the weight of the predicted value at the target time, and perform weighted summation on the observed value and the predicted value at the target time to obtain the calculated value at the target time; wherein, the residual mean value is the mean of the residual corresponding to the target time and the residuals corresponding to each of the same-window times; the seventh weight is greater than the eighth weight; the second intensity threshold is calculated based on the flow velocity at the target time;
[0056] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then use the ninth weight as the weight of the observed value at the target time and the tenth weight as the weight of the predicted value at the target time, and perform weighted summation on the observed value and the predicted value at the target time to obtain the calculated value at the target time; wherein, the tenth weight is greater than the ninth weight, and the seventh weight is greater than the ninth weight, and the tenth weight is greater than the eighth weight.
[0057] In a possible embodiment, the step of, if the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then using the ninth weight as the weight of the observed value at the target time and the tenth weight as the weight of the predicted value at the target time, and performing weighted summation on the observed value and the predicted value at the target time includes:
[0058] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold, and the residual mean value is not greater than the second intensity threshold and the residual mean value is not greater than the second fluctuation amount threshold, then the observed value of the target time is weighted with the ninth weight and the predicted value of the target time is weighted with the tenth weight, and the observed value and the predicted value of the target time are weighted and summed; the second fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each of the same-window times;
[0059] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold, or, the residual mean value is not greater than the second intensity threshold and the residual mean value is greater than the second fluctuation amount threshold, then the observed value of the target time is weighted with the ninth weight and the predicted value of the target time is weighted with the tenth weight, and the observed value and the predicted value of the target time are weighted and summed.
[0060] In a possible embodiment, the device further includes:
[0061] An intensity threshold calculation module, configured to calculate an intensity threshold according to the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time, as the first intensity threshold or the second intensity threshold; wherein, the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and is positively correlated with the flow velocity at the target time;
[0062] A fluctuation amount threshold calculation module, configured to calculate the product of the maximum value of the residual fluctuation amount corresponding to the target time and the residual fluctuation amounts corresponding to each of the same-window times and a preset magnification factor to obtain a fluctuation amount threshold, as the first fluctuation amount threshold or the second fluctuation amount threshold, wherein the preset magnification factor is positively correlated with the flow velocity at the target time.
[0063] In a possible embodiment, the intensity threshold is calculated by the following method, including:
[0064] ;
[0065] wherein, △Flow is the intensity threshold; S is the pipe cross-sectional area of the electromagnetic flowmeter; v is the flow velocity at the target time; a1, a2, a3, th1, th2 are all parameters, and a1 < a2 < a3;
[0066] The fluctuation amount threshold is calculated by the following method:
[0067] ;
[0068] wherein, is the fluctuation amount threshold; is the preset magnification; is the maximum value among the residual fluctuation amount corresponding to the target moment and the residual fluctuation amounts corresponding to each of the same-window moments;
[0069] The [specific item] is calculated through the following method , including:
[0070] ;
[0071] wherein, is the preset magnification; v is the flow velocity at the target moment; b1, b2, b3, th1, th2 are all parameters, and b1 < b2 < b3;
[0072] In a possible embodiment, calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual fluctuation amount corresponding to the target moment includes:
[0073] Calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual mean value;
[0074] Calculating the difference between the residual corresponding to the target moment and the residual mean value as the residual fluctuation amount corresponding to the target moment.
[0075] In a possible embodiment, calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment includes:
[0076] ;
[0077] wherein, k is the target moment, e k is the residual corresponding to the target moment; Y k is the observed value at the target moment; H is an m×n observation matrix; X k is the predicted value at the target moment;
[0078] Calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual mean value through the following method includes:
[0079] ;
[0080] wherein, γ k is the residual mean value; m is the time window where the target moment is located; k is the target moment; e i is the residual corresponding to the i-th moment within the time window where the target moment is located;
[0081] Calculate the difference between the residual corresponding to the target moment and the mean value of the residuals as the residual fluctuation amount corresponding to the target moment, including:
[0082] ;
[0083] Wherein, is the residual fluctuation amount corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the mean value of the residuals.
[0084] The embodiment of the present application also provides an electronic device, including:
[0085] A memory for storing a computer program;
[0086] A processor for implementing the flow calculation method described in any one of the above when executing the program stored on the memory.
[0087] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored, and the computer program realizes the flow calculation method described in any one of the above when executed by a processor.
[0088] The embodiment of the present application also provides a computer program product containing instructions, which when running on a computer, causes the computer to execute the flow calculation method described in any one of the above.
[0089] Advantageous effects of the embodiment of the present application:
[0090] A flow calculation method, device, electronic device, and storage medium provided by an embodiment of the present application. Since the error flow velocity can be regarded as unchanged when the flow velocity remains unchanged and other influencing factors such as system noise are ignored, and the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times is caused by the error flow velocity. Therefore, when the flow velocity remains unchanged and other influencing factors such as system noise are ignored, the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times should be stable, that is, the differences between the observed value and the predicted value of the electromagnetic flowmeter at different times should be relatively concentrated. Then, when calculating the degree of dispersion between the residual corresponding to the target time and the residuals corresponding to each same-window time as the residual fluctuation amount corresponding to the target time, the more concentrated the residual corresponding to the target time and the residuals corresponding to each same-window time are, the smaller the residual fluctuation amount should be. Therefore, the smaller the residual fluctuation amount is, the more stable the difference between the observed value and the predicted value of the electromagnetic flowmeter is, and it can be considered that the flow velocity at the target time has not changed. Correspondingly, the error flow velocity can also be regarded as unchanged. The corresponding relationship between the past observed value and the predicted value (i.e., the past prediction method) and the corresponding relationship between the observed value and the predicted value at the current time (i.e., the current prediction method) are the same. At this time, the predicted value obtained by predicting based on the past prediction method is relatively accurate, and compared with the observed value, the predicted value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is small, when obtaining the calculated value at the target time, the second weight of the more accurate predicted value should be set larger, and the first weight of the less accurate observed value should be set smaller. Here, the smaller and larger of the residual fluctuation amount corresponding to the target time do not refer to the absolute size, but refer to the size relative to when the flow velocity has not changed. That is to say, the smaller residual fluctuation amount corresponding to the target time means that the residual fluctuation amount corresponding to the target time is less than the maximum value of the residual fluctuation amount when the flow velocity at the target time has not changed. The smaller and larger of the first weight and the second weight do not refer to the absolute size, but refer to the size relative to when the flow velocity changes. That is to say, setting the second weight of the predicted value larger means that the second weight of the predicted value when the flow velocity has not changed is greater than the second weight of the predicted value when the flow velocity changes; setting the first weight of the observed value smaller means that the first weight of the observed value when the flow velocity has not changed is less than the first weight of the observed value when the flow velocity changes. The same applies hereinafter. Conversely, the larger the residual fluctuation amount is, the more unstable the difference between the observed value and the predicted value of the electromagnetic flowmeter is, and it can be considered that the flow velocity at the target time has changed. Correspondingly, the error flow velocity will also change, and the corresponding relationship between the past observed value and the predicted value and the corresponding relationship between the observed value and the predicted value at the current time are not the same.At this time, the predicted value obtained by the past prediction method is not accurate enough. Compared with the predicted value, the observed value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is large, when obtaining the calculated value at the target time, the first weight of the more accurate observed value should be set larger, and the second weight of the less accurate predicted value should be set smaller. Therefore, in the embodiments of the present application, based on the fact that the first weight is positively correlated with the residual fluctuation amount corresponding to the target time, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target time, the weights of the observed value and the predicted value at the target time can be dynamically adjusted, so that the calculated value at the target time is closer to the predicted value when the flow rate does not change, and closer to the observed value when the flow rate changes, thereby dynamically eliminating the influence of the error flow rate on the accuracy of flow calculation, and improving the accuracy of flow calculation.
[0091] Of course, implementing any product or method of the present application does not necessarily require achieving all the above advantages simultaneously. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other embodiments can also be obtained based on these drawings.
[0093] Figure 1 It is the first flow schematic diagram of the flow calculation method provided by the embodiments of the present application;
[0094] Figure 2 It is the second flow schematic diagram of the flow calculation method provided by the embodiments of the present application;
[0095] Figure 3a It is the third flow schematic diagram of the flow calculation method provided by the embodiments of the present application;
[0096] Figure 3b It is the fourth flow schematic diagram of the flow calculation method provided by the embodiments of the present application;
[0097] Figure 4a It is the fifth flow schematic diagram of the flow calculation method provided by the embodiments of the present application;
[0098] Figure 4b It is the sixth flow schematic diagram of the flow calculation method provided by the embodiments of the present application;
[0099] Figure 5 It is a schematic diagram of a system structure for implementing the flow calculation method provided by the embodiments of the present application;
[0100] Figure 6 A schematic diagram of the flow rate noise reduction effect provided by the embodiment of the present application;
[0101] Figure 7 A schematic diagram of the error flow rate change trend provided by the embodiment of the present application;
[0102] Figure 8 A schematic diagram of the noise reduction effect of the fixed observation noise system provided by the embodiment of the present application;
[0103] Figure 9 Another schematic diagram of the flow rate noise reduction effect provided by the embodiment of the present application;
[0104] Figure 10 A schematic structural diagram of the flow rate calculation device provided by the embodiment of the present application;
[0105] Figure 11 A schematic structural diagram of the electronic device provided by the embodiment of the present application. Detailed implementation manners
[0106] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. 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 of ordinary skill in the art based on the present application belong to the protection scope of the present application.
[0107] In order to more clearly illustrate the flow rate calculation method provided by the present application, the possible application scenarios of the flow rate calculation method provided by the present application will be exemplarily described below. It can be understood that the following examples are only the possible application scenarios of the flow rate calculation method provided by the present application. In other possible embodiments, the flow rate calculation method provided by the present application can be applied to other possible application scenarios, and the following examples do not make any restrictions on this.
[0108] The electromagnetic flowmeter is a flow measurement device based on the law of electromagnetic induction and can be used to obtain information such as the flow velocity and flow rate of conductive liquids flowing through the electromagnetic flowmeter. Since the electromagnetic flowmeter has the advantages of no mechanical components, corrosion resistance, high precision, etc., the electromagnetic flowmeter is widely used in industrial and civil fields and is used to measure the flow rate of conductive liquids. In industrial production or working condition monitoring scenarios, generally, high requirements are placed on the accuracy and stability of the electromagnetic flowmeter, that is, high requirements are placed on the accuracy of the flow signal measured by the electromagnetic flowmeter. In the actual application of the electromagnetic flowmeter, there are often complex working conditions, and there will be more noise signals. These noise signals will make the stability of the flow signal output by the electromagnetic flowmeter poor, and the flow velocity measurement fluctuates greatly. Due to the influence of noise signals, there is a certain error between the flow velocity measured by the electromagnetic flowmeter and the true flow velocity. In the following text, this error is called the error flow velocity. The existence of the error flow velocity will lead to a decrease in the accuracy of the flow signal measured by the electromagnetic flowmeter.
[0109] To improve the accuracy of the flow signal, usually, the Kalman filter can be used to predict the flow signal at the current moment based on the flow signals (i.e., observation values) measured by the electromagnetic flowmeter at past moments and the current moment, and obtain the predicted value at the current moment. The process by which the Kalman filter obtains the predicted value can be simply understood as: based on the flow signals measured by the electromagnetic flowmeter at past moments and the current moment, summarize the prediction method of the flow signal at the current moment, and perform prediction according to the summarized prediction method.
[0110] However, since the error flow velocity is affected not only by the noise signals existing under special working conditions but also changes with the change of the true flow velocity, and the error flow velocity is positively correlated with the true flow velocity. Therefore, when the true flow velocity at the current moment remains unchanged, the error flow velocity at past moments is basically the same as the error flow velocity at the current moment, that is, it can be considered that the error flow velocity is unchanged. Then, the corresponding relationship between the observation value and the predicted value at past moments is the same as the corresponding relationship between the observation value and the predicted value at the current moment, and the predicted value at the current moment can be accurately predicted based on the prediction method at past moments; while when the true flow velocity at the current moment changes, the error flow velocity at past moments is different from the error flow velocity at the current moment, then the corresponding relationship between the observation value and the predicted value at past moments is different from the corresponding relationship between the observation value and the predicted value at the current moment. Then, the predicted value at the current moment predicted based on the prediction method at past moments is not accurate enough. Therefore, when the true flow velocity changes, the method of predicting the predicted value at the current moment according to the past prediction method cannot eliminate the influence of the error flow velocity on the accuracy of the flow signal, and thus cannot improve the accuracy of the obtained flow signal. Therefore, how to dynamically eliminate the error flow velocity to improve the accuracy of flow calculation has become an urgent problem to be solved.
[0111] Currently, by using a Kalman filter to filter the flow rate demodulation result, high-precision measurement of constant flow water flow, reliable measurement of solid-liquid two-phase flow, and fast tracking of variable flow can be achieved by dynamically adjusting the filter parameters according to the filtered differential sequence. However, the filtered differential sequence in the above method cannot effectively identify the change in flow velocity and is difficult to identify the change in flow velocity under micro-flow conditions, resulting in the inability to dynamically eliminate the error flow velocity in the above method, thereby leading to low accuracy of flow calculation.
[0112] Based on this, in order to dynamically eliminate the influence of the error flow velocity on the accuracy of flow calculation and thus improve the accuracy of flow calculation, the embodiments of the present application provide a flow calculation method. See Figure 1 The method includes:
[0113] S101, calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment.
[0114] S102, calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each same-window moment as the residual fluctuation amount corresponding to the target moment.
[0115] Among them, the same-window moment is other moments within the same time window as the target moment.
[0116] S103, using the first weight as the weight of the observed value at the target moment and the second weight as the weight of the predicted value at the target moment, and performing weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment.
[0117] Among them, the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment.
[0118] Applying the embodiments of the present application, since the error flow rate can be regarded as unchanged when the flow rate remains unchanged and other influencing factors such as system noise are ignored, and the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times is caused by the error flow rate. Therefore, when the flow rate remains unchanged and other influencing factors such as system noise are ignored, the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times should be stable, that is, the differences between the observed value and the predicted value of the electromagnetic flowmeter at different times should be relatively concentrated. Then, when calculating the degree of dispersion between the residual corresponding to the target time and the residuals corresponding to each same-window time as the residual fluctuation amount corresponding to the target time, the more concentrated the residual corresponding to the target time and the residuals corresponding to each same-window time are, the smaller the residual fluctuation amount should be. Therefore, the smaller the residual fluctuation amount is, the more stable the difference between the observed value and the predicted value of the electromagnetic flowmeter is, and it can be considered that the flow rate at the target time has not changed. Correspondingly, the error flow rate can also be regarded as unchanged. The corresponding relationship between the past observed value and the predicted value (i.e., the past prediction method) and the corresponding relationship between the observed value and the predicted value at the current time (i.e., the current prediction method) are the same. At this time, the predicted value obtained by predicting based on the past prediction method is relatively accurate, and compared with the observed value, the predicted value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is small, when obtaining the calculated value at the target time, the second weight of the more accurate predicted value should be set larger, and the first weight of the less accurate observed value should be set smaller. Here, the smaller and larger of the residual fluctuation amount corresponding to the target time do not refer to the absolute size, but refer to the size relative to when the flow rate has not changed. That is to say, the smaller residual fluctuation amount corresponding to the target time means that the residual fluctuation amount corresponding to the target time is less than the maximum value of the residual fluctuation amount when the flow rate at the target time has not changed. The smaller and larger of the first weight and the second weight do not refer to the absolute size, but refer to the size relative to when the flow rate changes. That is to say, setting the second weight of the predicted value larger means that the second weight of the predicted value when the flow rate has not changed is greater than the second weight of the predicted value when the flow rate changes; setting the first weight of the observed value smaller means that the first weight of the observed value when the flow rate has not changed is less than the first weight of the observed value when the flow rate changes. The same applies hereinafter. On the contrary, the larger the residual fluctuation amount is, the more unstable the difference between the observed value and the predicted value of the electromagnetic flowmeter is, and it can be considered that the flow rate at the target time has changed. Correspondingly, the error flow rate will also change. The corresponding relationship between the past observed value and the predicted value and the corresponding relationship between the observed value and the predicted value at the current time are not the same. At this time, the predicted value obtained by predicting based on the past prediction method is not accurate enough, and compared with the predicted value, the observed value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is large, when obtaining the calculated value at the target time, the first weight of the more accurate observed value should be set larger, and the second weight of the less accurate predicted value should be set smaller.Therefore, in the embodiments of the present application, based on the fact that the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment, the weights of the observed value and the predicted value at the target moment can be dynamically adjusted, so that the calculated value at the target moment is closer to the predicted value when the flow rate remains unchanged and closer to the observed value when the flow rate changes, thereby dynamically eliminating the influence of the error flow rate on the accuracy of flow calculation and improving the accuracy of flow calculation.
[0119] The foregoing S101 - S103 will be described exemplarily below:
[0120] In S101, in a possible embodiment, the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment can be directly used as the residual corresponding to the target moment.
[0121] In another possible embodiment, the residual corresponding to the target moment can also be calculated through the following formula (1), including:
[0122]
[0123] where k is the target moment, and e k is the residual corresponding to the target moment; Y k is the observed value at the target moment; H is an observation matrix of m×n; X k is the predicted value at the target moment.
[0124] In S102, the period of the time window can be set according to user requirements. For example, the period of the time window can be set to 5 unit times, 10 unit times, 15 unit times, etc. Exemplarily, assuming that the period of the time window is 5 unit times and the target moment is T = 10, the time window where this target moment is located is from T = 10 to T = 15, and the other moments within the same time window as this target moment, that is, the co - window moments, are each moment from T = 11 to T = 15.
[0125] For each co - window moment, the method of calculating the residual corresponding to the co - window moment is similar to the method of calculating the residual corresponding to the target moment. The difference is only that the observed value and the predicted value of the electromagnetic flowmeter at the target moment are replaced with the observed value and the predicted value of the electromagnetic flowmeter at the co - window moment, that is, calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the co - window moment as the residual corresponding to the co - window moment. The specific calculation method can refer to the relevant description in the foregoing S101 and will not be elaborated here. The method of calculating the residual fluctuation amount corresponding to the target moment will be described exemplarily below and will not be elaborated here.
[0126] In S103, the positive correlation between the first weight and the residual fluctuation amount corresponding to the target time means that: when other factors remain unchanged, the first weight increases as the residual fluctuation amount corresponding to the target time increases, and decreases as the residual fluctuation amount corresponding to the target time decreases. The negative correlation between the second weight and the residual fluctuation amount corresponding to the target time means that: when other factors remain unchanged, the second weight decreases as the residual fluctuation amount corresponding to the target time increases, and increases as the residual fluctuation amount corresponding to the target time decreases. The increase in this application can refer to monotonic increase or non-monotonic increase, and the decrease can refer to monotonic decrease or non-monotonic decrease.
[0127] Since the residual fluctuation amount is obtained by calculating the degree of dispersion between the residual corresponding to the target time and the residuals corresponding to each same-window time, therefore, if the residual fluctuation amount corresponding to the target time is large, the residual corresponding to the target time and the residuals corresponding to each same-window time are relatively dispersed, which also means that the difference between the residual corresponding to the target time and the residuals corresponding to each same-window time is large, and the stability of the residual corresponding to the target time is poor. Since the residual corresponding to the target time is obtained by calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time, therefore, the poor stability of the residual corresponding to the target time indicates that the stability of the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is poor.
[0128] It can be understood that when the flow rate remains unchanged, the error flow rate is unchanged, and the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times is caused by the error flow rate. Therefore, when the flow rate remains unchanged, the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times should be within a preset range, and this preset range is set according to the flow rate. It can also be considered that when the flow rate remains unchanged, the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times should be stable. Therefore, if the stability of the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is poor, it can be considered that the flow rate at the target time has changed. Correspondingly, the error flow rate will also change, and the corresponding relationship between the past observed value and the predicted value is different from the corresponding relationship between the current observed value and the predicted value, that is, the past prediction method and the current prediction method are different. At this time, the predicted value obtained by predicting based on the past prediction method is not accurate enough. Compared with the predicted value, the observed value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is large, when obtaining the calculated value at the target time, the observed value is more accurate, and the first weight of the observed value can be set larger, while the predicted value is not accurate enough, and the second weight of the predicted value can be set smaller.
[0129] Similarly, if the residual fluctuation amount corresponding to the target time is small, the residuals corresponding to the target time and the residuals corresponding to each same-window time are relatively concentrated, which indicates that the difference between the residual corresponding to the target time and the residuals corresponding to each same-window time is small, and the stability of the residual corresponding to the target time is good. Since the residual corresponding to the target time is obtained by calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time, therefore, the good stability of the residual corresponding to the target time indicates that the stability of the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is good.
[0130] It can be understood that, under the condition of constant flow velocity, the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times should be stable. Therefore, if the stability of the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is good, it can be considered that the flow velocity at the target time has not changed. Correspondingly, the error flow velocity has not changed either, and the corresponding relationship between the past observed value and the predicted value is the same as the corresponding relationship between the observed value and the predicted value at the current time, that is, the past prediction method and the current prediction method are the same. At this time, the predicted value obtained by predicting based on the past prediction method is relatively accurate. Compared with the observed value, the predicted value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is small, then when obtaining the calculated value at the target time, the predicted value is more accurate, and thus the second weight of the predicted value can be set larger, and the observed value is not accurate enough, so the first weight of the observed value can be set smaller. Therefore, the first weight is positively correlated with the residual fluctuation amount corresponding to the target time, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target time.
[0131] The foregoing S101 - S103 have been exemplarily described above. Referring to the foregoing description, the flow rate calculation method provided by the present application depends on the calculation of the residual fluctuation amount corresponding to the target time and the setting of the first weight and the second weight. The following will first exemplarily describe the method for calculating the residual fluctuation amount corresponding to the target time. In a possible embodiment, referring to Figure 2 , the flow rate calculation method provided by the present application includes:
[0132] S101, calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time as the residual corresponding to the target time.
[0133] The foregoing S101 has been exemplarily described above. Refer to the relevant description of S101 above and will not be elaborated here.
[0134] S1021, calculate the mean value of the residual corresponding to the target time and the residuals corresponding to each same-window time as the residual mean value.
[0135] Specifically, the residual mean value is calculated through the following formula (2), including:
[0136]
[0137] where γ k is the residual mean; m is the window length of the time window where the target moment is located; k is the target moment; e i is the residual corresponding to the i-th moment within the time window where the target moment is located. Among them, m can be set to the excitation frequency of the electromagnetic flowmeter or can be arbitrarily set according to user requirements. For example, m can be set to 5 、10、15 and so on.
[0138] S1022, calculate the difference between the residual corresponding to the target moment and the residual mean as the residual fluctuation amount corresponding to the target moment.
[0139] Take the absolute value of the difference between the residual corresponding to the target moment and the residual mean as the residual fluctuation amount corresponding to the target moment. Specifically, calculate the residual fluctuation amount corresponding to the target moment through the following formula (3), including:
[0140]
[0141] where is the residual fluctuation amount corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean.
[0142] S103, use the first weight as the weight of the observed value of the target moment and the second weight as the weight of the predicted value of the target moment, and perform weighted summation on the observed value and the predicted value of the target moment to obtain the calculated value of the target moment.
[0143] Among them, the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment.
[0144] An exemplary description of S103 has been given above. Refer to the relevant description of S103 above and will not be elaborated here.
[0145] By selecting this embodiment, the residual fluctuation amount corresponding to the target moment can be relatively simply calculated by calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual mean value, and calculating the difference between the residual corresponding to the target moment and the residual mean value as the residual fluctuation amount corresponding to the target moment, which is convenient for setting the first weight and the second weight according to the calculated residual fluctuation amount corresponding to the target moment, where the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment, so as to obtain a relatively accurate calculated value of the target moment, thereby dynamically eliminating the influence of the error flow rate on the accuracy of the flow calculation, and thus improving the accuracy of the flow calculation.
[0146] In other possible embodiments, the residual fluctuation amount corresponding to the target moment can also be calculated in the following manner: calculate the mean value of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual mean value; take the average value of the differences between the residuals corresponding to the target moment and the adjacent moments and the residual mean value as the residual fluctuation amount corresponding to the target moment. Here, the adjacent moments are the moment before the target moment and the moment after the target moment.
[0147] Specifically, calculating the residual fluctuation amount corresponding to the target moment through the following formula (4) includes:
[0148]
[0149] where, is the residual fluctuation amount corresponding to the target moment; e k is the residual corresponding to the target moment; e k-1 is the residual corresponding to the moment before the target moment; e k+1 is the residual corresponding to the moment after the target moment; γ k is the residual mean value.
[0150] The method for calculating the residual fluctuation amount corresponding to the target moment has been exemplarily described above. As described above, in addition to the calculation of the residual fluctuation amount corresponding to the target moment, the flow calculation method provided by the present application also depends on the setting of the first weight and the second weight. Therefore, how to set the first weight and the second weight will also affect the accuracy of the flow calculation method. Therefore, the method for setting the first weight and the second weight will be further exemplarily described below. In a possible embodiment, referring to Figure 3a , the flow calculation method provided by the present application includes:
[0151] S101, calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment.
[0152] S102. Calculate the degree of dispersion between the residual corresponding to the target time and the residuals corresponding to each of the other times within the same time window as the target time, and use it as the residual fluctuation amount corresponding to the target time.
[0153] Among them, the other times within the same time window are the times other than the target time within the same time window.
[0154] In the above text, S101 - S102 have been described by way of example. One can refer to the relevant descriptions of S101 - S102 above, and will not repeat them here.
[0155] S1031. If the residual fluctuation amount corresponding to the target time is greater than the first intensity threshold, then use the third weight as the weight of the observed value of the target time and the fourth weight as the weight of the predicted value of the target time, and perform a weighted sum of the observed value and the predicted value of the target time to obtain the calculated value of the target time.
[0156] Among them, the third weight is greater than the fourth weight; the first intensity threshold is calculated based on the flow velocity at the target time.
[0157] S1032. If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold, then use the fifth weight as the weight of the observed value of the target time and the sixth weight as the weight of the predicted value of the target time, and perform a weighted sum of the observed value and the predicted value of the target time to obtain the calculated value of the target time.
[0158] Among them, the sixth weight is greater than the fifth weight, and the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight.
[0159] In S1031 - S1032, since the first intensity threshold is calculated based on the flow velocity at the target time, therefore, the first intensity threshold can be used to reflect the theoretically maximum fluctuation amount estimated according to the flow velocity at the target time. Specifically, pre - set the corresponding relationship between the flow velocity and the maximum residual fluctuation amount, and substitute the flow velocity at the target time into this corresponding relationship, then the maximum residual fluctuation amount corresponding to the flow velocity at the target time can be obtained, and this maximum residual fluctuation amount corresponding to the flow velocity at the target time is the first intensity threshold.
[0160] Then, when the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, it indicates that the residual fluctuation amount corresponding to the target moment is greater than the maximum residual fluctuation amount corresponding to the flow velocity at the target moment. Thus, it can be considered that the flow velocity at the target moment has changed. Correspondingly, the error flow velocity will also change, and the past prediction method and the current prediction method are different. At this time, the predicted value obtained based on the past prediction method is not accurate enough. Compared with the predicted value, the observed value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, when obtaining the calculated value at the target moment, the third weight of the more accurate observed value should be set larger, and the fourth weight of the less accurate predicted value should be set smaller, that is, the third weight is greater than the fourth weight.
[0161] When the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, it can be considered that the flow velocity at the target moment has not changed. Correspondingly, the error flow velocity has not changed either, and the past prediction method and the current prediction method are the same. At this time, the predicted value obtained based on the past prediction method is relatively accurate. Compared with the observed value, the predicted value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, when obtaining the calculated value at the target moment, the sixth weight of the more accurate predicted value should be set larger, and the fifth weight of the less accurate observed value should be set smaller, that is, the sixth weight is greater than the fifth weight.
[0162] For the observed value, the observed value is more accurate when the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, and less accurate when the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold. Therefore, the third weight of the observed value when the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold should be greater than the fifth weight of the observed value when the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, that is, the third weight is greater than the fifth weight.
[0163] For the predicted value, the predicted value is less accurate when the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, and more accurate when the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold. Therefore, the fourth weight of the predicted value when the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold should be less than the sixth weight of the observed value when the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, that is, the sixth weight is greater than the fourth weight.
[0164] By selecting this embodiment, the first intensity threshold calculated based on the flow rate at the target moment can reflect the theoretically maximum fluctuation amount at the target moment, so that it is possible to relatively accurately judge whether the flow rate has changed by determining whether the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, and dynamically adjust the weights of the observed value and the predicted value according to the judgment result, so as to obtain a more accurate calculated value of the target moment by weighted summing the observed value and the predicted value of the target moment, thereby dynamically eliminating the influence of the error flow rate on the accuracy of flow rate calculation and improving the accuracy of flow rate calculation.
[0165] In order to further improve the accuracy of judging whether the flow rate has changed, in a possible embodiment, refer to Figure 3b , the flow rate calculation method provided by this application includes:
[0166] S101. Calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment.
[0167] S102. Calculate the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each same-window moment as the residual fluctuation amount corresponding to the target moment.
[0168] Among them, the same-window moment is other moments within the same time window as the target moment.
[0169] S1031. If the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, use the third weight as the weight of the observed value at the target moment and the fourth weight as the weight of the predicted value at the target moment, and perform weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment.
[0170] Among them, the third weight is greater than the fourth weight.
[0171] The above has given an exemplary description of S101 - S1031. For the relevant description of S101 - S1031, reference can be made to the foregoing, and details will not be repeated here.
[0172] S10321. If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and not greater than the first fluctuation amount threshold, use the fifth weight as the weight of the observed value at the target moment and the sixth weight as the weight of the predicted value at the target moment, and perform weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment.
[0173] Among them, the sixth weight is greater than the fifth weight, the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight; the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each same-window moment.
[0174] In S10322, if the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and greater than the first fluctuation amount threshold, then the weight of the observed value at the target time is the third weight, and the weight of the predicted value at the target time is the fourth weight. The observed value and the predicted value at the target time are weighted and summed to obtain the calculated value at the target time.
[0175] In S10321 - S10322, since the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each co - window time, the first fluctuation amount threshold can be used to reflect the theoretically maximum fluctuation amount statistically obtained according to the residual fluctuation amounts corresponding to each co - window time. Then, when the flow velocity remains unchanged, the residual fluctuation amount corresponding to the target time should not exceed the first fluctuation amount threshold. Therefore, when the residual fluctuation amount corresponding to the target time is greater than the first fluctuation amount threshold, it can be considered that the flow velocity at the target time has changed, and correspondingly, the error flow velocity will also change. The past prediction method and the current prediction method are different. At this time, the predicted value obtained based on the past prediction method is not accurate enough. Compared with the predicted value, the observed value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is greater than the first fluctuation amount threshold, when obtaining the calculated value at the target time, the third weight of the more accurate observed value should be set larger, and the fourth weight of the less accurate predicted value should be set smaller, that is, the third weight is greater than the fourth weight.
[0176] When the residual fluctuation amount corresponding to the target time is not greater than the first fluctuation amount threshold, it can be considered that the flow velocity at the target time has not changed, and correspondingly, the error flow velocity has not changed. The past prediction method and the current prediction method are the same. At this time, the predicted value obtained based on the past prediction method is relatively accurate. Compared with the observed value, the predicted value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is not greater than the first fluctuation amount threshold, when obtaining the calculated value at the target time, the sixth weight of the more accurate predicted value should be set larger, and the fifth weight of the less accurate observed value should be set smaller, that is, the sixth weight is greater than the fifth weight.
[0177] For the observed value, when the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold, the observed value is more accurate when the residual fluctuation amount corresponding to the target time is greater than the first fluctuation amount threshold, and less accurate when the residual fluctuation amount corresponding to the target time is not greater than the first fluctuation amount threshold. Therefore, the third weight of the observed value when the residual fluctuation amount corresponding to the target time is greater than the first fluctuation amount threshold should be greater than the fifth weight of the observed value when the residual fluctuation amount corresponding to the target time is not greater than the first fluctuation amount threshold, that is, the third weight is greater than the fifth weight.
[0178] For the predicted value, when the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, the predicted value is not accurate when the residual fluctuation amount corresponding to the target moment is greater than the first fluctuation amount threshold, and is relatively accurate when the residual fluctuation amount corresponding to the target moment is not greater than the first fluctuation amount threshold. Therefore, the fourth weight when the residual fluctuation amount corresponding to the target moment of the predicted value is greater than the first fluctuation amount threshold should be less than the sixth weight when the residual fluctuation amount corresponding to the target moment of the observed value is not greater than the first fluctuation amount threshold, that is, the sixth weight is greater than the fourth weight.
[0179] Selecting this embodiment can, when it is determined according to the first intensity threshold that the flow rate has not changed, further reflect the theoretically maximum fluctuation amount at the target moment based on the first fluctuation amount threshold statistically obtained from the residual fluctuation amounts corresponding to each same-window moment, so that it is possible to further accurately determine whether the flow rate has changed by judging whether the residual fluctuation amount corresponding to the target moment is greater than the first fluctuation amount threshold, obtain a further judgment result, and dynamically adjust the weights of the observed value and the predicted value according to the further judgment result, so as to obtain a more accurate calculated value at the target moment by weighted summing the observed value and the predicted value at the target moment, thereby dynamically eliminating the influence of the error flow rate on the accuracy of the flow calculation and improving the accuracy of the flow calculation.
[0180] In another possible embodiment, see Figure 4a , the flow calculation method provided by this application includes:
[0181] S101, Calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment.
[0182] S102, Calculate the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each same-window moment as the residual fluctuation amount corresponding to the target moment.
[0183] Among them, the same-window moment is other moments within the same time window as the target moment.
[0184] The above has given an exemplary description of S101 - S102. For the relevant descriptions of S101 - S102, reference can be made to the foregoing, and details will not be repeated here.
[0185] S1033, If the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, then use the seventh weight as the weight of the observed value at the target moment and the eighth weight as the weight of the predicted value at the target moment, and perform weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment.
[0186] Among them, the residual mean is the mean of the residual corresponding to the target moment and the residuals corresponding to each moment within the same window; the seventh weight is greater than the eighth weight; the second intensity threshold is calculated based on the flow velocity at the target moment.
[0187] S1034. If the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual mean is not greater than the second intensity threshold, then use the ninth weight as the weight of the observed value at the target moment and the tenth weight as the weight of the predicted value at the target moment, and perform weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment.
[0188] Among them, the tenth weight is greater than the ninth weight, the seventh weight is greater than the ninth weight, and the tenth weight is greater than the eighth weight.
[0189] In S1033 - S1034, the calculation method of the residual mean can refer to the relevant description in the aforementioned S1021 and will not be elaborated here.
[0190] Since the second intensity threshold is calculated based on the flow velocity at the target moment, therefore, the second intensity threshold can be used to reflect the theoretically maximum fluctuation amount estimated according to the flow velocity at the target moment. Specifically, pre-set the corresponding relationship between the flow velocity and the maximum residual fluctuation amount, and substitute the flow velocity at the target moment into this corresponding relationship, then the maximum residual fluctuation amount corresponding to the flow velocity at the target moment can be obtained, and this maximum residual fluctuation amount corresponding to the flow velocity at the target moment is the second intensity threshold.
[0191] Then, when the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, it indicates that the residual fluctuation amount corresponding to the target moment is greater than the maximum residual fluctuation amount corresponding to the flow velocity at the target moment. It can be considered that the flow velocity at the target moment has changed. Correspondingly, the error flow velocity will also change, and the past prediction method and the current prediction method are different. At this time, the predicted value obtained based on the past prediction method is not accurate enough. Compared with the predicted value, the observed value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, then when obtaining the calculated value at the target moment, the seventh weight of the more accurate observed value should be set larger, and the eighth weight of the less accurate predicted value should be set smaller, that is, the seventh weight is greater than the eighth weight.
[0192] When the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, it can be considered that the flow velocity at the target moment has not changed. Correspondingly, the error flow velocity has also not changed, and the past prediction method and the current prediction method are the same. At this time, the predicted value obtained by predicting based on the past prediction method is relatively accurate. Compared with the observed value, the predicted value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, when obtaining the calculated value at the target moment, the tenth weight of the more accurate predicted value should be set larger, and the ninth weight of the less accurate observed value should be set smaller, that is, the tenth weight is greater than the ninth weight.
[0193] For the observed value, the observed value is relatively accurate when the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold, and is less accurate when the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold. Therefore, the seventh weight of the observed value when the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold should be greater than the ninth weight of the observed value when the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, that is, the seventh weight is greater than the ninth weight.
[0194] For the predicted value, the predicted value is less accurate when the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold, and is relatively accurate when the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold. Therefore, the eighth weight of the predicted value when the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold should be less than the tenth weight of the observed value when the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, that is, the tenth weight is greater than the eighth weight.
[0195] By selecting this embodiment, the second intensity threshold calculated based on the flow velocity at the target moment can reflect the theoretically maximum fluctuation amount at the target moment, so that it is possible to relatively accurately judge whether the flow velocity has changed by judging whether the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold and judging whether the residual mean value is greater than the second intensity threshold, and dynamically adjust the weights of the observed value and the predicted value according to the judgment result, so as to obtain a more accurate calculated value at the target moment by weighted summing the observed value and the predicted value at the target moment, thereby dynamically eliminating the influence of the error flow velocity on the accuracy of flow calculation and improving the accuracy of flow calculation.
[0196] To further improve the accuracy of judging whether the flow rate has changed, in a possible embodiment, refer to Figure 4b , the flow rate calculation method provided by this application includes:
[0197] S101. Calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment.
[0198] S102. Calculate the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each same-window moment as the residual fluctuation amount corresponding to the target moment.
[0199] Among them, the same-window moment is other moments within the same time window as the target moment.
[0200] S1033. If the residual fluctuation amount corresponding to the target moment is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold, then use the seventh weight as the weight of the observed value at the target moment and the eighth weight as the weight of the predicted value at the target moment, and perform weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment.
[0201] Among them, the residual mean value is the mean of the residual corresponding to the target moment and the residuals corresponding to each same-window moment; the seventh weight is greater than the eighth weight.
[0202] The above has given an exemplary description of S101 - S1033. You can refer to the relevant descriptions of S101 - S1033 above and will not be elaborated here.
[0203] S10341. If the residual fluctuation amount corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target moment is not greater than the second fluctuation amount threshold, and the residual mean value is not greater than the second intensity threshold and the residual mean value is not greater than the second fluctuation amount threshold, then use the ninth weight as the weight of the observed value at the target moment and the tenth weight as the weight of the predicted value at the target moment, and perform weighted summation on the observed value and the predicted value at the target moment to obtain the calculated value at the target moment.
[0204] Among them, the sixth weight is greater than the fifth weight, and the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight; the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each same-window moment.
[0205] S10342, if the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold, or, the residual mean value is not greater than the second intensity threshold and the residual mean value is greater than the second fluctuation amount threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight, and the weighted sum of the observed value and the predicted value at the target time is calculated to obtain the calculated value at the target time.
[0206] In S10341-S10342, since the second fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each co-window time, the second fluctuation amount threshold can be used to reflect the theoretically maximum fluctuation amount statistically obtained based on the residual fluctuation amounts corresponding to each co-window time. Then, when the flow velocity remains unchanged, the residual fluctuation amount and the residual mean value corresponding to the target time should not exceed the second fluctuation amount threshold. Therefore, when the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold or the residual mean value is greater than the second fluctuation amount threshold, it can be considered that the flow velocity at the target time has changed, and correspondingly, the error flow velocity will also change, and the past prediction method and the current prediction method are different. At this time, the predicted value obtained by the past prediction method is not accurate enough. Compared with the predicted value, the observed value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold or the residual mean value is greater than the second fluctuation amount threshold, when obtaining the calculated value at the target time, the seventh weight of the more accurate observed value should be set larger, and the eighth weight of the less accurate predicted value should be set smaller, that is, the seventh weight is greater than the eighth weight.
[0207] When the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold and the residual mean value is not greater than the second fluctuation amount threshold, it can be considered that the flow velocity at the target time has not changed, and correspondingly, the error flow velocity has not changed, and the past prediction method and the current prediction method are the same. At this time, the predicted value obtained by the past prediction method is relatively accurate. Compared with the observed value, the predicted value is more accurate. Therefore, if the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold and the residual mean value is not greater than the second fluctuation amount threshold, when obtaining the calculated value at the target time, the tenth weight of the more accurate predicted value should be set larger, and the ninth weight of the less accurate observed value should be set smaller, that is, the tenth weight is greater than the ninth weight.
[0208] For the observed value, when the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, the observed value is more accurate when the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold or the residual mean value is greater than the second fluctuation amount threshold, and is less accurate when the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold and the residual mean value is not greater than the second fluctuation amount threshold. Therefore, the seventh weight when the residual fluctuation amount corresponding to the target time of the observed value is greater than the second fluctuation amount threshold or the residual mean value is greater than the second fluctuation amount threshold should be greater than the ninth weight when the residual fluctuation amount corresponding to the target time of the observed value is not greater than the second fluctuation amount threshold and the residual mean value is not greater than the second fluctuation amount threshold, that is, the seventh weight is greater than the ninth weight.
[0209] For the predicted value, when the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, the predicted value is less accurate when the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold or the residual mean value is greater than the second fluctuation amount threshold, and is more accurate when the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold and the residual mean value is not greater than the second fluctuation amount threshold. Therefore, the eighth weight when the residual fluctuation amount corresponding to the target time of the predicted value is greater than the second fluctuation amount threshold or the residual mean value is greater than the second fluctuation amount threshold should be less than the tenth weight when the residual fluctuation amount corresponding to the target time of the observed value is not greater than the second fluctuation amount threshold and the residual mean value is not greater than the second fluctuation amount threshold, that is, the tenth weight is greater than the eighth weight.
[0210] By selecting this embodiment, when it is determined according to the second intensity threshold that the flow velocity has not changed, the second fluctuation amount threshold statistically obtained based on the residual fluctuation amounts corresponding to each same-window time can reflect the theoretically maximum fluctuation amount at the target time, so that it is possible to further and more accurately judge whether the flow velocity has changed by judging whether the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold, obtain a further judgment result, and dynamically adjust the weights of the observed value and the predicted value according to the further judgment result, so as to obtain a more accurate calculated value at the target time by weighted summing the observed value and the predicted value at the target time, thereby dynamically eliminating the influence of the error flow velocity on the flow calculation accuracy and improving the flow calculation accuracy.
[0211] The setting methods of the first weight and the second weight have been exemplarily described above. See Figure 3a and Figure 4aIn the illustrated embodiment, it can be seen that when determining whether the flow rate has changed, it is necessary to rely on the settings of the first intensity threshold and the second intensity threshold. Therefore, the setting methods of the first intensity threshold and the second intensity threshold will be described exemplarily in the following text. The first intensity threshold and the second intensity threshold in this application can be equal or unequal.
[0212] Specifically, the first intensity threshold or the second intensity threshold can be set in the following way: Calculate the intensity threshold based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow rate at the target moment, and use it as the first intensity threshold or the second intensity threshold; among them, the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and is also positively correlated with the flow rate at the target moment.
[0213] The fact that the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter means that: under the condition that other factors remain unchanged, the calculated intensity threshold increases with the increase of the pipe cross-sectional area of the electromagnetic flowmeter and decreases with the decrease of the pipe cross-sectional area of the electromagnetic flowmeter. The fact that the calculated intensity threshold is positively correlated with the flow rate at the target moment means that: under the condition that other factors remain unchanged, the calculated intensity threshold increases with the increase of the flow rate at the target moment and decreases with the decrease of the flow rate at the target moment.
[0214] Specifically, the intensity threshold is calculated through the following formula (5), including:
[0215]
[0216] Among them, △Flow is the intensity threshold; S is the pipe cross-sectional area of the electromagnetic flowmeter; v is the flow rate at the target moment; a1, a2, a3, th1, and th2 are all parameters, and a1 < a2 < a3.
[0217] a1, a2, a3, th1, and th2 can be set according to past experience or user requirements. Exemplarily, a1 = 0.003, a2 = 0.024, a3 = 0.036, th1 = 2m / s, and th2 = 6m / s can be set. In this example, the intensity threshold is calculated through the following formula (6), that is, formula (5) can be replaced by the following formula (6):
[0218]
[0219] By selecting this embodiment, the intensity threshold can be calculated based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target moment, serving as the first intensity threshold or the second intensity threshold. The calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and is also positively correlated with the flow velocity at the target moment. In this way, the first intensity threshold or the second intensity threshold can be set separately for each different target moment, enabling dynamic adjustment of the first intensity threshold or the second intensity threshold for different target moments, setting the first intensity threshold or the second intensity threshold more reasonably, and more accurately judging whether the flow velocity has changed based on the first intensity threshold or the second intensity threshold. According to the judgment result, the weights of the observed value and the predicted value are dynamically adjusted, and by weighted summing the observed value and the predicted value at the target moment, a more accurate calculated value at the target moment is obtained, thereby dynamically eliminating the influence of the error flow velocity on the accuracy of flow calculation and improving the accuracy of flow calculation.
[0220] An exemplary description of the setting methods of the first intensity threshold and the second intensity threshold has been given above. Refer to Figure 3b and Figure 4b the embodiments shown. It can be seen that when judging whether the flow velocity has changed, in addition to the first intensity threshold and the second intensity threshold, it also depends on the settings of the first fluctuation amount threshold and the second fluctuation amount threshold. Therefore, an exemplary description of the setting methods of the first fluctuation amount threshold and the second fluctuation amount threshold will be given below. The first fluctuation amount threshold and the second fluctuation amount threshold in this application can be equal or unequal.
[0221] Specifically, the first fluctuation amount threshold or the second fluctuation amount threshold can be set in the following way: Calculate the product of the residual fluctuation amount corresponding to the target moment and the maximum value of the residual fluctuation amounts corresponding to each same-window moment and a preset magnification factor to obtain the fluctuation amount threshold, serving as the first fluctuation amount threshold or the second fluctuation amount threshold, where the preset magnification factor is positively correlated with the flow velocity at the target moment.
[0222] The preset magnification factor and the flow velocity at the target moment mean that: under the condition that other factors remain unchanged, the preset magnification factor increases as the flow velocity at the target moment increases and decreases as the flow velocity at the target moment decreases.
[0223] Denote the residual fluctuation amount corresponding to the target moment and the residual fluctuation amounts corresponding to each same-window moment as , where N is the number of the residual fluctuation amount corresponding to the target moment and the residual fluctuation amounts corresponding to each same-window moment, that is, N is the number of observed values output by the electromagnetic flowmeter within a time window. In the example where the time window m is 3 seconds, N is equivalent to the number of observed values output by the electromagnetic flowmeter within 3 seconds. Denote the maximum value of the residual fluctuation amount corresponding to the target moment and the residual fluctuation amounts corresponding to each same-window moment as Then That is is the one-way fluctuation amplitude of the residual fluctuation quantity, which can be used to characterize the flow velocity noise intensity.
[0224] The residuals within a time window generally follow a normal distribution, that is , where is the standard deviation, which is used to characterize the distribution width of the residuals.
[0225] Specifically, the fluctuation quantity threshold is calculated in the following way:
[0226]
[0227] where is the fluctuation quantity threshold; is the preset magnification; is the maximum value among the residual fluctuation quantity corresponding to the target moment and the residual fluctuation quantities corresponding to each moment within the same window.
[0228] The preset magnification is calculated by the following formula (8), including:
[0229]
[0230] where is the preset magnification; v is the flow velocity at the target moment; b1, b2, b3, th1, th2 are all parameters, and b1 < b2 < b3.
[0231] b1, b2, b3, th1, th2 can be set according to past experience or user requirements. Exemplarily, b1 = 1.3, b2 = 1.5, b3 = 1.8, th1 = 2m / s, th2 = 6m / s can be set. In this example, the preset magnification is calculated by the following formula (9), that is, formula (8) can be replaced by the following formula (9):
[0232]
[0233] By selecting this embodiment, the threshold of the fluctuation amount can be obtained by calculating the product of the maximum value of the residual fluctuation amount corresponding to the target moment and the residual fluctuation amounts corresponding to each moment in the same window and a preset magnification factor, and used as the first fluctuation amount threshold or the second fluctuation amount threshold. Among them, the preset magnification factor is positively correlated with the flow velocity at the target moment, and the fluctuation amount threshold at the target moment is positively correlated with the flow velocity at the target moment. In this way, the first fluctuation amount threshold or the second fluctuation amount threshold is set separately for each different target moment, so that the first fluctuation amount threshold or the second fluctuation amount threshold can be dynamically adjusted for different target moments, and the first fluctuation amount threshold or the second fluctuation amount threshold can be set more reasonably, so as to more accurately judge whether the flow velocity changes based on the first fluctuation amount threshold or the second fluctuation amount threshold. According to the judgment result, the weights of the observed value and the predicted value are dynamically adjusted, and the calculated value at the target moment is obtained more accurately by weighted summing the observed value and the predicted value at the target moment, thereby dynamically eliminating the influence of the error flow velocity on the accuracy of the flow calculation and improving the accuracy of the flow calculation.
[0234] The foregoing S103 can be implemented by a Kalman filter. Specifically, using the observed value as the initial predicted value, the predicted value is updated through the measured value and the Kalman gain. The state equation in the Kalman filter can be shown as the following formula (10), and the observation equation can be shown as the following formula (11).
[0235]
[0236] Wherein, X k is the state quantity at the k-th moment; X k-1 is the state quantity at the (k - 1)-th moment; W k is the process noise, and W k ∈ [0, Q]; Q is the covariance matrix of the state noise; Y k is the observed value at the k-th moment; V k is the measurement noise, and V k ∈ [0, R]; R is the covariance matrix of the observation noise; A is an n×n state transition matrix; H is an m×n observation matrix; W k and V k are uncorrelated. Since the flow signal is a one-dimensional signal, m = n = 1.
[0237] The predicted value at the k-th moment is calculated through the following formula (12):
[0238]
[0239] Wherein, is the predicted value at the k-th moment; is the optimal estimated value at the (k - 1)-th moment; A is an n×n state transition matrix.
[0240] Calculate the prior error covariance value at the k-th moment through the following formula (13):
[0241]
[0242] where, is the prior error covariance value at the k-th moment; A is an n×n state transition matrix; A T is the transpose matrix of the state transition matrix A; P k-1 is the optimal estimation deviation covariance at the (k - 1)-th moment; Q is the covariance matrix of the state noise.
[0243] Calculate the Kalman filter gain at the k-th moment through the following formula (14):
[0244]
[0245] where, K k is the Kalman filter gain at the k-th moment, used to characterize the credibility of the latest measurement value, that is, the weight component; is the prior error covariance value at the k-th moment; H is an m×n observation matrix; H T is the transpose matrix of the observation matrix H; R is the covariance matrix of the observation noise.
[0246] Calculate the state estimation value at the k-th moment, that is, the calculated value at the k-th moment mentioned above, through the following formula (15):
[0247]
[0248] where, is the state estimation value at the k-th moment; is the predicted value at the k-th moment; K k is the Kalman filter gain at the k-th moment; Y k is the observation value at the k-th moment; H is an m×n observation matrix.
[0249] Update the optimal estimation deviation covariance at the k-th moment through the following formula (16):
[0250]
[0251] where, P k is the updated optimal estimation deviation covariance at the k-th moment, that is, the n×n posterior covariance matrix; I is an n×n identity matrix; K k is the Kalman filter gain at the k-th moment and is an n×m matrix; is the prior error covariance value at the k-th moment and is an n×n matrix; H is an m×n observation matrix.
[0252] In practical applications, the initial filtering parameters of the Kalman filter are as follows: the state estimation deviation covariance P0 = 1, the state noise covariance Q = 0.01, and the observation noise covariance R = 4. The selection of and P0 will to some extent affect the filtering convergence speed and filtering effect in the initial stage. Therefore, in actual use, to prevent interference introduced by the tooling, spike interference removal can be pre-set to make the filtering effect more stable. Spike interference can be removed by using the median or other statistical means, which will not be elaborated here.
[0253] When the flow rate changes, set Q in the Kalman filter to 0.01, that is, let Q = 0.01. When the flow rate does not change, set Q to 0.01×10 -6 That is, Q = 0.01×10 -6 . When the flow rate changes, set R to 4, that is, R = 4. When the flow rate does not change, set R according to the following formula (17):
[0254]
[0255] Since Q is the covariance matrix of the state noise, Q can be used to reflect the inaccuracy of the predicted value. The larger Q is, the less accurate the predicted value is; the smaller Q is, the more accurate the predicted value is. It can be understood that if the predicted value is less accurate, the confidence level of the predicted value is lower; if the predicted value is more accurate, the confidence level of the predicted value is higher. Therefore, Q can be used to reflect the confidence level of the predicted value, and Q is negatively correlated with the confidence level of the predicted value. The aforementioned second weight is also used to reflect the confidence level of the predicted value, and the second weight is positively correlated with the confidence level of the predicted value. Therefore, Q can also be used to characterize the aforementioned second weight, and Q is negatively correlated with the aforementioned second weight.
[0256] Similarly, since R is the covariance matrix of the observation noise, R can be used to reflect the inaccuracy of the observed value. The larger R is, the less accurate the observed value is; the smaller R is, the more accurate the observed value is. It can be understood that if the observed value is less accurate, the confidence level of the observed value is lower; if the observed value is more accurate, the confidence level of the observed value is higher. Therefore, R can be used to reflect the confidence level of the observed value, and R is negatively correlated with the confidence level of the observed value. The aforementioned first weight is also used to reflect the confidence level of the observed value, and the first weight is positively correlated with the confidence level of the observed value. Therefore, R can also be used to characterize the aforementioned first weight, and R is negatively correlated with the aforementioned first weight.
[0257] In the embodiment of implementing the aforementioned S103 through the Kalman filter, the flow rate calculation method provided by the present application can be implemented by a system as Figure 5 shown. Refer to Figure 5 . The system includes: a Kalman filter, a flow rate monitoring system, and a noise adaptation module.
[0258] Figure 5 The system shown implements the flow calculation method provided in this application in the following manner: measure the flow signal through an electromagnetic flowmeter, and the flow signal measured by the electromagnetic flowmeter is equivalent to the aforementioned observed value, and input the observed value into the Kalman filter to obtain a predicted value. The flow velocity monitoring system determines whether the flow velocity has changed based on the observed value and the predicted value to obtain a judgment result. The noise adaptation module sets Q and R in the Kalman filter based on the judgment result obtained by the flow velocity monitoring system, and the Kalman filter filters the flow signal measured by the electromagnetic flowmeter based on the set Q and R to obtain a denoised flow signal. Subsequently, the electromagnetic flowmeter measures a new flow signal, that is, a new observed value, and the Kalman filter predicts the new observed value based on the set Q and R to obtain a new predicted value. The flow velocity monitoring system determines whether the flow velocity has changed based on the new observed value and the new predicted value to obtain a new judgment result. The noise adaptation module re-sets Q and R in the Kalman filter based on the new judgment result, and the Kalman filter filters the new flow signal based on the re-set Q and R to obtain a new denoised flow signal. And so on, continuously execute the above process in a loop to achieve the denoising of each flow signal measured by the electromagnetic flowmeter.
[0259] In the above process, the flow velocity denoising effect can be as shown in Figure 6 shown, the error flow velocity change trend can be as shown in Figure 7 shown, the denoising effect of the fixed observation noise system can be as shown in Figure 8 shown, and another effect diagram of the flow velocity denoising effect can be as shown in Figure 9 shown. In Figure 6 , Figure 8 and Figure 9 , the solid lines are all original signals, and the dashed lines are all denoised signals. In Figure 6 , Figure 7 , Figure 8 and Figure 9 , the abscissa is all used to represent the sampling period, and the ordinate is all used to represent the flow velocity signal.
[0260] Corresponding to the aforementioned flow calculation method, an embodiment of this application also provides a flow calculation device. Refer to Figure 10 , the device includes:
[0261] A residual calculation module 1001, configured to calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment;
[0262] The residual fluctuation amount calculation module 1002 is used to calculate the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the target moment, as the residual fluctuation amount corresponding to the target moment, where the moments within the same window are other moments within the same time window as the target moment;
[0263] The calculated value obtaining module 1003 is used to perform weighted summation on the observed value and the predicted value of the target moment with the first weight as the weight of the observed value of the target moment and the second weight as the weight of the predicted value of the target moment, to obtain the calculated value of the target moment, where the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment.
[0264] In a possible embodiment, performing weighted summation on the observed value and the predicted value of the target moment with the first weight as the weight of the observed value of the target moment and the second weight as the weight of the predicted value of the target moment to obtain the calculated value of the target moment includes:
[0265] If the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, then perform weighted summation on the observed value and the predicted value of the target moment with the third weight as the weight of the observed value of the target moment and the fourth weight as the weight of the predicted value of the target moment to obtain the calculated value of the target moment; where the third weight is greater than the fourth weight; the first intensity threshold is calculated based on the flow rate at the target moment;
[0266] If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, then perform weighted summation on the observed value and the predicted value of the target moment with the fifth weight as the weight of the observed value of the target moment and the sixth weight as the weight of the predicted value of the target moment to obtain the calculated value of the target moment; where the sixth weight is greater than the fifth weight, and the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight.
[0267] In a possible embodiment, if the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, then performing weighted summation on the observed value and the predicted value of the target moment with the fifth weight as the weight of the observed value of the target moment and the sixth weight as the weight of the predicted value of the target moment includes:
[0268] If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and not greater than the first fluctuation amount threshold, then perform weighted summation on the observed value and the predicted value of the target moment with the fifth weight as the weight of the observed value of the target moment and the sixth weight as the weight of the predicted value of the target moment; the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each moment within the same window;
[0269] If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and is greater than the first fluctuation amount threshold, then the observed value at the target time is weighted with the third weight, and the predicted value at the target time is weighted with the fourth weight, and the observed value and the predicted value at the target time are weighted and summed up.
[0270] In a possible embodiment, the observed value at the target time is weighted with the first weight, and the predicted value at the target time is weighted with the second weight, and the observed value and the predicted value at the target time are weighted and summed up to obtain the calculated value at the target time, including:
[0271] If the residual fluctuation amount corresponding to the target time is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold, then the observed value at the target time is weighted with the seventh weight, and the predicted value at the target time is weighted with the eighth weight, and the observed value and the predicted value at the target time are weighted and summed up to obtain the calculated value at the target time; wherein, the residual mean value is the mean value of the residual corresponding to the target time and the residuals corresponding to each co-window time; the seventh weight is greater than the eighth weight; the second intensity threshold is calculated based on the flow rate at the target time;
[0272] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then the observed value at the target time is weighted with the ninth weight, and the predicted value at the target time is weighted with the tenth weight, and the observed value and the predicted value at the target time are weighted and summed up to obtain the calculated value at the target time; wherein, the tenth weight is greater than the ninth weight, and the seventh weight is greater than the ninth weight, and the tenth weight is greater than the eighth weight.
[0273] In a possible embodiment, if the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then the observed value at the target time is weighted with the ninth weight, and the predicted value at the target time is weighted with the tenth weight, and the observed value and the predicted value at the target time are weighted and summed up, including:
[0274] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold, and the residual mean value is not greater than the second intensity threshold and the residual mean value is not greater than the second fluctuation amount threshold, then the observed value at the target time is weighted with the ninth weight, and the predicted value at the target time is weighted with the tenth weight, and the observed value and the predicted value at the target time are weighted and summed up; the second fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each co-window time;
[0275] If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold, or, the residual mean value is not greater than the second intensity threshold and the residual mean value is greater than the second fluctuation amount threshold, then the observed value at the target time is weighted with the ninth weight, and the predicted value at the target time is weighted with the tenth weight, and the observed value and the predicted value at the target time are weighted and summed up.
[0276] In a possible embodiment, the apparatus further includes:
[0277] An intensity threshold calculation module, configured to calculate an intensity threshold according to the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time, as the first intensity threshold or the second intensity threshold; wherein, the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and is positively correlated with the flow velocity at the target time;
[0278] A fluctuation amount threshold calculation module, configured to calculate the product of the maximum value of the residual fluctuation amount corresponding to the target time and the residual fluctuation amounts corresponding to each same-window time and a preset magnification factor, to obtain a fluctuation amount threshold, as the first fluctuation amount threshold or the second fluctuation amount threshold, wherein the preset magnification factor is positively correlated with the flow velocity at the target time.
[0279] In a possible embodiment, The intensity threshold includes:
[0280] ;
[0281] wherein, △Flow is the intensity threshold; S is the pipe cross-sectional area of the electromagnetic flowmeter; v is the flow velocity at the target time; a1, a2, a3, th1, th2 are all parameters, and a1 < a2 < a3;
[0282] The fluctuation amount threshold is calculated by the following method:
[0283] ;
[0284] wherein, is the fluctuation amount threshold; is the preset magnification factor; is the maximum value of the residual fluctuation amount corresponding to the target time and the residual fluctuation amounts corresponding to each same-window time;
[0285] Calculated by the following method , including:
[0286] ;
[0287] wherein, is the preset magnification factor; v is the flow velocity at the target time; b1, b2, b3, th1, th2 are all parameters, and b1 < b2 < b3.
[0288] In a possible embodiment, calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the residual fluctuation amount corresponding to the target moment includes:
[0289] Calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the residual mean value;
[0290] Calculating the difference between the residual corresponding to the target moment and the residual mean value as the residual fluctuation amount corresponding to the target moment.
[0291] In a possible embodiment, calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment by the following method includes:
[0292] ;
[0293] where k is the target moment, and e k is the residual corresponding to the target moment; Y k is the observed value at the target moment; H is an observation matrix of m×n; X k is the predicted value at the target moment;
[0294] Calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the residual mean value by the following method includes:
[0295] ;
[0296] where γ k is the residual mean value; m is the time window where the target moment is located; k is the target moment; e i is the residual corresponding to the i-th moment within the time window where the target moment is located;
[0297] Calculating the difference between the residual corresponding to the target moment and the residual mean value as the residual fluctuation amount corresponding to the target moment by the following method includes:
[0298] ;
[0299] where, is the residual fluctuation amount corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean value.
[0300] The embodiment of the present application also provides an electronic device, as shown in Figure 11 and includes:
[0301] A memory 1101 for storing a computer program;
[0302] When the processor 1102 executes the program stored in the memory 1101, the following steps are implemented:
[0303] Calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time as the residual corresponding to the target time;
[0304] Calculate the degree of dispersion between the residual corresponding to the target time and the residuals corresponding to each same-window time as the residual fluctuation amount corresponding to the target time, where the same-window time is other times within the same time window as the target time;
[0305] Use the first weight as the weight of the observed value at the target time and the second weight as the weight of the predicted value at the target time, and perform weighted summation on the observed value and the predicted value at the target time to obtain the calculated value at the target time, where the first weight is positively correlated with the residual fluctuation amount corresponding to the target time, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target time.
[0306] The electronic device can be the electromagnetic flowmeter itself or other devices electrically connected to the electromagnetic flowmeter, such as a laptop computer, a server, etc.
[0307] And the above-mentioned electronic device may further include a communication bus and / or a communication interface, and the processor 1102, the communication interface, and the memory 1101 complete communication with each other through the communication bus.
[0308] The communication bus mentioned in the above-mentioned electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0309] The communication interface is used for communication between the above-mentioned electronic device and other devices.
[0310] The memory may include a Random Access Memory (RAM), or may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0311] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0312] In another embodiment provided by the present application, a computer-readable storage medium is further provided. A computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the steps of any of the above-mentioned traffic calculation methods are implemented.
[0313] In another embodiment provided by the present application, a computer program product including instructions is further provided. When it runs on a computer, the computer is caused to execute any of the traffic calculation methods in the above embodiments.
[0314] 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 the present application are generated in whole or in part. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (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 that can be accessed 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 (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a Solid State Disk (SSD), etc.
[0315] It should be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0316] Each embodiment in this specification is described in a related manner. For the same and similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the apparatus, electronic device, computer-readable storage medium and computer program product containing instructions, 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.
[0317] The above are only the preferred embodiments of the present application and are not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application are all included in the protection scope of the present application.
Claims
1. A flow calculation method, characterized in that, The method includes: Calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment; Calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each co-window moment as the residual fluctuation amount corresponding to the target moment, where the co-window moments are other moments within the same time window as the target moment; Using the first weight as the weight of the observed value at the target moment and the second weight as the weight of the predicted value at the target moment, and performing a weighted sum of the observed value and the predicted value at the target moment to obtain the calculated value at the target moment, where the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment.
2. The method according to claim 1, wherein The step of using the first weight as the weight of the observed value at the target moment and the second weight as the weight of the predicted value at the target moment, and performing a weighted sum of the observed value and the predicted value at the target moment to obtain the calculated value at the target moment includes: If the residual fluctuation amount corresponding to the target moment is greater than the first intensity threshold, then using the third weight as the weight of the observed value at the target moment and the fourth weight as the weight of the predicted value at the target moment, and performing a weighted sum of the observed value and the predicted value at the target moment to obtain the calculated value at the target moment; where the third weight is greater than the fourth weight; the first intensity threshold is calculated based on the flow velocity at the target moment; If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, then using the fifth weight as the weight of the observed value at the target moment and the sixth weight as the weight of the predicted value at the target moment, and performing a weighted sum of the observed value and the predicted value at the target moment to obtain the calculated value at the target moment; where the sixth weight is greater than the fifth weight, and the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight.
3. The method according to claim 2, characterized in that, The step of if the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold, then using the fifth weight as the weight of the observed value at the target moment and the sixth weight as the weight of the predicted value at the target moment, and performing a weighted sum of the observed value and the predicted value at the target moment includes: If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and not greater than the first fluctuation amount threshold, then using the fifth weight as the weight of the observed value at the target moment and the sixth weight as the weight of the predicted value at the target moment, and performing a weighted sum of the observed value and the predicted value at the target moment; the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each co-window moment; If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and greater than the first fluctuation amount threshold, then using the third weight as the weight of the observed value at the target moment and the fourth weight as the weight of the predicted value at the target moment, and performing a weighted sum of the observed value and the predicted value at the target moment.
4. The method according to claim 1, characterized in that Using the first weight as the weight of the observed value at the target time and the second weight as the weight of the predicted value at the target time, performing weighted summation on the observed value and the predicted value at the target time to obtain the calculated value at the target time, including: If the residual fluctuation amount corresponding to the target time is greater than the second intensity threshold or the residual mean value is greater than the second intensity threshold, using the seventh weight as the weight of the observed value at the target time and the eighth weight as the weight of the predicted value at the target time, performing weighted summation on the observed value and the predicted value at the target time to obtain the calculated value at the target time; wherein, the residual mean value is the mean value of the residual corresponding to the target time and the residuals corresponding to each co-window time; the seventh weight is greater than the eighth weight; the second intensity threshold is calculated based on the flow rate at the target time; If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, using the ninth weight as the weight of the observed value at the target time and the tenth weight as the weight of the predicted value at the target time, performing weighted summation on the observed value and the predicted value at the target time to obtain the calculated value at the target time; wherein, the tenth weight is greater than the ninth weight, and the seventh weight is greater than the ninth weight, and the tenth weight is greater than the eighth weight.
5. The method according to claim 4, characterized in that The step of if the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, using the ninth weight as the weight of the observed value at the target time and the tenth weight as the weight of the predicted value at the target time, performing weighted summation on the observed value and the predicted value at the target time, includes: If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold, and the residual mean value is not greater than the second intensity threshold and the residual mean value is not greater than the second fluctuation amount threshold, using the ninth weight as the weight of the observed value at the target time and the tenth weight as the weight of the predicted value at the target time, performing weighted summation on the observed value and the predicted value at the target time; the second fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each co-window time; If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold, or, the residual mean value is not greater than the second intensity threshold and the residual mean value is greater than the second fluctuation amount threshold, using the ninth weight as the weight of the observed value at the target time and the tenth weight as the weight of the predicted value at the target time, performing weighted summation on the observed value and the predicted value at the target time.
6. The method according to claim 3 or 5, characterized in that, The method further includes: Calculate an intensity threshold based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target moment, as the first intensity threshold or the second intensity threshold; wherein, the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and is positively correlated with the flow velocity at the target moment; Calculate the product of the residual fluctuation amount corresponding to the target moment and the maximum value of the residual fluctuation amounts corresponding to each of the same-window moments and a preset magnification factor to obtain a fluctuation amount threshold, as the first fluctuation amount threshold or the second fluctuation amount threshold, wherein the preset magnification factor is positively correlated with the flow velocity at the target moment.
7. The method according to claim 6, wherein Calculate the intensity threshold through the following method, including: ; Wherein, △Flow is the intensity threshold; S is the pipe cross-sectional area of the electromagnetic flowmeter; v is the flow velocity at the target moment; a1, a2, a3, th1, th2 are all parameters, and a1 < a2 < a3; Obtain the fluctuation amount threshold through the following method: ; Wherein, is the threshold value of the fluctuation amount; is the preset magnification; is the maximum value among the residual fluctuation amount corresponding to the target moment and the residual fluctuation amounts corresponding to the respective same-window moments; Calculate the preset magnification factor through the following method, including: ; wherein, is the preset magnification; v is the flow velocity at the target moment; b1, b2, b3, th1, and th2 are all parameters, and b1 < b2 < b3.
8. The method according to claim 1, wherein Calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual fluctuation amount corresponding to the target moment, including: Calculate the mean value of the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual mean value; Calculate the difference between the residual corresponding to the target moment and the residual mean value as the residual fluctuation amount corresponding to the target moment.
9. The method according to claim 8, wherein Calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment through the following method as the residual corresponding to the target moment, including: ; where k is the target time, and e k is the residual corresponding to the target time; Y k is the observation value at the target time; H is an m×n observation matrix; X k is the predicted value at the target time; Calculate the mean value of the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments through the following method as the residual mean value, including: ; where γ k is the residual mean; m is the time window in which the target time is located; k is the target time; e i is the residual corresponding to the i-th moment within the time window in which the target time is located; Calculate the difference between the residual corresponding to the target moment and the residual mean value through the following method as the residual fluctuation amount corresponding to the target moment, including: ; Among them, is the residual fluctuation amount corresponding to the target time; e k is the residual corresponding to the target time; γ k is the mean value of the residuals.
10. A flow calculation device, characterized in that, The device includes: A residual calculation module, configured to calculate the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment; A residual fluctuation amount calculation module, configured to calculate the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each of the same-window moments as the residual fluctuation amount corresponding to the target moment, wherein the same-window moments are other moments located within the same time window as the target moment; A calculated value obtaining module, configured to perform weighted summation on the observed value and the predicted value at the target moment with the first weight as the weight of the observed value at the target moment and the second weight as the weight of the predicted value at the target moment to obtain the calculated value at the target moment, wherein the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment.
11. The device according to claim 10, wherein Performing weighted summation on the observed value and the predicted value at the target moment with the first weight as the weight of the observed value at the target moment and the second weight as the weight of the predicted value at the target moment to obtain the calculated value at the target moment, including: If the residual fluctuation amount corresponding to the target time is greater than the first intensity threshold, then using the third weight as the weight of the observed value at the target time and the fourth weight as the weight of the predicted value at the target time, perform a weighted sum of the observed value and the predicted value at the target time to obtain the calculated value at the target time; wherein, the third weight is greater than the fourth weight; the first intensity threshold is calculated based on the flow velocity at the target time; If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold, then using the fifth weight as the weight of the observed value at the target time and the sixth weight as the weight of the predicted value at the target time, perform a weighted sum of the observed value and the predicted value at the target time to obtain the calculated value at the target time; wherein, the sixth weight is greater than the fifth weight, and the third weight is greater than the fifth weight, and the sixth weight is greater than the fourth weight; The case where if the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold, then using the fifth weight as the weight of the observed value at the target time and the sixth weight as the weight of the predicted value at the target time, perform a weighted sum of the observed value and the predicted value at the target time, includes: If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and not greater than the first fluctuation amount threshold, then using the fifth weight as the weight of the observed value at the target time and the sixth weight as the weight of the predicted value at the target time, perform a weighted sum of the observed value and the predicted value at the target time; the first fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each of the same-window times; If the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold and greater than the first fluctuation amount threshold, then using the third weight as the weight of the observed value at the target time and the fourth weight as the weight of the predicted value at the target time, perform a weighted sum of the observed value and the predicted value at the target time; The case where using the first weight as the weight of the observed value at the target time and the second weight as the weight of the predicted value at the target time, perform a weighted sum of the observed value and the predicted value at the target time to obtain the calculated value at the target time, includes: If the residual fluctuation amount corresponding to the target time is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, then using the seventh weight as the weight of the observed value at the target time and the eighth weight as the weight of the predicted value at the target time, perform a weighted sum of the observed value and the predicted value at the target time to obtain the calculated value at the target time; wherein, the residual mean is the mean of the residual corresponding to the target time and the residuals corresponding to each of the same-window times; the seventh weight is greater than the eighth weight; the second intensity threshold is calculated based on the flow velocity at the target time; If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight. The observed value and the predicted value at the target time are weighted and summed to obtain the calculated value at the target time. Among them, the tenth weight is greater than the ninth weight, the seventh weight is greater than the ninth weight, and the tenth weight is greater than the eighth weight. If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean value is not greater than the second intensity threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight. The weighted sum of the observed value and the predicted value at the target time includes: If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is not greater than the second fluctuation amount threshold, and the residual mean value is not greater than the second intensity threshold and the residual mean value is not greater than the second fluctuation amount threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight. The observed value and the predicted value at the target time are weighted and summed. The second fluctuation amount threshold is statistically obtained based on the residual fluctuation amounts corresponding to each of the same window times. If the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual fluctuation amount corresponding to the target time is greater than the second fluctuation amount threshold, or the residual mean value is not greater than the second intensity threshold and the residual mean value is greater than the second fluctuation amount threshold, then the weight of the observed value at the target time is the ninth weight, and the weight of the predicted value at the target time is the tenth weight. The observed value and the predicted value at the target time are weighted and summed. The device further includes: An intensity threshold calculation module, configured to calculate an intensity threshold based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow rate at the target time, as the first intensity threshold or the second intensity threshold. Among them, the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and positively correlated with the flow rate at the target time. A fluctuation amount threshold calculation module, configured to calculate the product of the maximum value of the residual fluctuation amount corresponding to the target time and the residual fluctuation amounts corresponding to each of the same window times and a preset magnification to obtain a fluctuation amount threshold, as the first fluctuation amount threshold or the second fluctuation amount threshold. Among them, the preset magnification is positively correlated with the flow rate at the target time. The intensity threshold is calculated by the following method, including: ; Among them, △Flow is the intensity threshold; S is the pipe cross-sectional area of the electromagnetic flowmeter; v is the flow rate at the target time; a1, a2, a3, th1, th2 are all parameters, and a1 < a2 < a3. The fluctuation amount threshold is obtained by the following method: ; Among them, is the threshold value of the fluctuation quantity; is the preset magnification; is the maximum value among the residual fluctuation quantity corresponding to the target moment and the residual fluctuation quantities corresponding to each of the same-window moments; Calculate the said by the following means , including: ; wherein, is the preset magnification; v is the flow velocity at the target moment; b1, b2, b3, th1, and th2 are all parameters, and b1 < b2 < b3; Calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the residual fluctuation amount corresponding to the target moment, including: Calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the residual mean value; Calculating the difference between the residual corresponding to the target moment and the residual mean value as the residual fluctuation amount corresponding to the target moment; Calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target moment as the residual corresponding to the target moment by the following method, including: ; where k is the target time, and e k is the residual corresponding to the target time; Y k is the observation value at the target time; H is an m×n observation matrix; X k is the predicted value at the target time; Calculating the mean value of the residual corresponding to the target moment and the residuals corresponding to each moment within the same window as the residual mean value by the following method, including: ; Among them, γ k is the residual mean value; m is the time window where the target time is located; k is the target time; e i is the residual corresponding to the i-th moment within the time window where the target time is located; Calculating the difference between the residual corresponding to the target moment and the residual mean value as the residual fluctuation amount corresponding to the target moment by the following method, including: ; Among them, is the residual fluctuation corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the mean value of the residuals.
12. An electronic device, characterized in that, Including: A memory for storing a computer program; A processor for implementing the method according to any one of claims 1-9 when executing the program stored on the memory.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1-9 is implemented.
Citation Information
Patent Citations
Improved Kalman filtering method used for target tracking
CN108802707A
Time difference processing method based on Sage-Husa adaptive Kalman filtering
CN116127706A
Method for predicting corrosion in pipeline based on Gaussian residual regression
CN120030901A
Prediction device, prediction method, and prediction program
WO2024127506A1