Flow calculation method, device, electronic device and storage medium
By calculating the residual fluctuation of the electromagnetic flowmeter and dynamically adjusting the weights of the observed and predicted values, the flowmeter error velocity problem caused by noise signals is solved and the accuracy of flow calculation is improved.
Patent Information
- Application Number
- CN202510811835.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-06-17
AI Technical Summary
When electromagnetic flowmeters measure the flow of conductive liquids, the influence of noise signals causes flow rate measurement errors and dynamic changes in flow rate, which reduces the accuracy of flow calculation.
By calculating the residual fluctuation at the target moment and the residual at the same window moment, the weights of the observed value and the predicted value are dynamically adjusted to ensure that they approach the predicted value when the flow rate does not change, and approach the observed value when the flow rate changes, thereby eliminating the influence of the error flow rate.
It improves the accuracy of flow calculation, dynamically adapts to flow rate changes, and reduces the impact of error flow rate on measurement results.
Smart Images

Figure CN120352003B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electromagnetic flowmeter signal processing, and in particular to a flow calculation method, device, electronic device and storage medium. Background Art
[0002] Electromagnetic flowmeters are flow measurement devices based on the law of electromagnetic induction and can be used to measure the flow rate and flow velocity of conductive liquids. Due to the influence of noise signals, there is a certain error between the flow velocity measured by the electromagnetic flowmeter and the actual flow velocity. This error is referred to as the error flow velocity. In addition to being affected by noise signals, the error flow velocity also changes with the actual flow velocity, meaning that the error flow velocity is dynamic. The presence of error flow velocity reduces the accuracy of the flow rate measured by the electromagnetic flowmeter. Therefore, how to dynamically eliminate the error flow velocity to improve the accuracy of flow calculation has become a pressing issue. 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 erroneous flow velocity on the accuracy of flow calculation, thereby improving the accuracy of flow calculation. The specific technical solution is as follows:
[0004] The present invention provides a method for calculating flow rate, which includes:
[0005] Calculating 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;
[0006] Calculate the degree of dispersion between the residual corresponding to the target moment and the residual corresponding to each same-window moment as the residual fluctuation corresponding to the target moment, wherein the same-window moment is other moments in the same time window as the target moment;
[0007] The first weight is used as the weight of the observed value at the target moment, and the second weight is used as the weight of the predicted value at the target moment. The observed value and the predicted value at the target moment are weighted and summed to obtain the calculated value of the target moment, wherein the first weight is positively correlated with the residual fluctuation corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation corresponding to the target moment.
[0008] In a possible embodiment, taking a first weight as the weight of the observed value at the target moment and a second weight as the weight of the predicted value at the target moment, 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:
[0009] If the residual fluctuation corresponding to the target time is greater than the first intensity threshold, the observed value and the predicted value at the target time are weighted and summed 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 to obtain a calculated value at the target time; wherein the third weight is greater than the fourth weight; and the first intensity threshold is calculated based on the flow velocity at the target time;
[0010] If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the fifth weight is used as the weight of the observed value of the target moment, and the sixth weight is used as the weight of the predicted value of the target moment, and the observed value and the predicted value of the target moment are weighted and summed to obtain the calculated value of the target moment; 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.
[0011] In a possible embodiment, if the residual fluctuation amount corresponding to the target time is not greater than the first strength threshold, 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, performing a weighted sum of the observed value and the predicted value at the target time, including:
[0012] If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and is not greater than the first fluctuation amount threshold, the observed value and the predicted value at the target moment are weighted and summed 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; the first fluctuation amount threshold is obtained based on the statistics of the residual fluctuation amounts corresponding to each of the moments in the same window;
[0013] If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold and greater than the first fluctuation threshold, the third weight is used as the weight of the observation value of the target moment, and the fourth weight is used as the weight of the predicted value of the target moment, and the observation value and the predicted value of the target moment are weighted and summed.
[0014] In a possible embodiment, taking a first weight as the weight of the observed value at the target moment and a second weight as the weight of the predicted value at the target moment, 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:
[0015] If the residual fluctuation corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, the observed value and the predicted value at the target moment are weighted and summed using 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 to obtain a calculated value at the target moment; wherein the residual mean is the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window; the seventh weight is greater than the eighth weight; and the second intensity threshold is calculated based on the flow velocity at the target moment;
[0016] If the residual fluctuation 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, the ninth weight is used as the weight of the observed value of the target moment, and the tenth weight is used as the weight of the predicted value of the target moment, and the observed value and the predicted value of the target moment are weighted and summed to obtain the calculated value of the target moment; 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.
[0017] In a possible embodiment, 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, using a ninth weight as the weight of the observed value at the target moment and a tenth weight as the weight of the predicted value at the target moment, performing a weighted sum of the observed value and the predicted value at the target moment, including:
[0018] 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 is not greater than the second intensity threshold and the residual mean is not greater than the second fluctuation amount threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and a weighted sum is performed on the observed value and the predicted value at the target moment; the second fluctuation amount threshold is obtained based on the residual fluctuation amount statistics corresponding to each of the moments in the same window;
[0019] If the residual fluctuation corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold, or the residual mean is not greater than the second intensity threshold and the residual mean is greater than the second fluctuation threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment are weighted and summed.
[0020] In a possible embodiment, the method further includes:
[0021] Calculating 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 positively correlated with the flow velocity at the target time;
[0022] Calculate the product of the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each moment in the same window and the preset multiplier to obtain a fluctuation threshold as the first fluctuation threshold or the second fluctuation threshold, wherein the preset multiplier is positively correlated with the flow rate 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 time; a1, a2, a3, th1, and th2 are all parameters, and a1<a2<a3;
[0026] The fluctuation threshold is calculated as follows:
[0027] ;
[0028] in, is the fluctuation threshold; is the preset magnification; The maximum value of the residual fluctuation corresponding to the target time and the residual fluctuation corresponding to each of the same window time;
[0029] The preset magnification is calculated by the following method, including:
[0030] ;
[0031] in, is the preset ratio; v is the flow rate 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 time and the residuals corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time includes:
[0033] Calculate the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual mean;
[0034] The difference between the residual corresponding to the target time and the residual mean is calculated as the residual fluctuation amount corresponding to the target time.
[0035] In a possible embodiment, the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is calculated as the residual corresponding to the target time in the following manner, including:
[0036] ;
[0037] Wherein, k is the target time, e k is the residual corresponding to the target moment; Y k is the observation value at the target moment; H is the m×n observation matrix; X k is the predicted value at the target moment;
[0038] The mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window is calculated as the residual mean by the following method, including:
[0039] ;
[0040] Among them, γ k is the residual mean; m is the time window of the target moment; k is the target moment; e i is the residual corresponding to the i-th moment in the time window where the target moment is located;
[0041] Calculating the difference between the residual corresponding to the target moment and the residual mean as the residual fluctuation amount corresponding to the target moment in the following manner includes:
[0042] ;
[0043] in, is the residual fluctuation corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean.
[0044] The present application also provides a flow calculation device, comprising:
[0045] A residual calculation module, used to 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;
[0046] a residual fluctuation calculation module, configured to calculate the degree of dispersion between the residual corresponding to the target moment and the residual corresponding to each same-window moment, as the residual fluctuation corresponding to the target moment, wherein the same-window moment is another moment in the same time window as the target moment;
[0047] A calculation value obtaining module is used to perform weighted summation on the observation value and the predicted value at the target moment with a first weight as the weight of the observation value at the target moment and a second weight as the weight of the predicted value at the target moment to obtain the calculation value of 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.
[0048] In a possible embodiment, taking a first weight as the weight of the observed value at the target moment and a second weight as the weight of the predicted value at the target moment, 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:
[0049] If the residual fluctuation corresponding to the target time is greater than the first intensity threshold, the observed value and the predicted value at the target time are weighted and summed 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 to obtain a calculated value at the target time; wherein the third weight is greater than the fourth weight; and the first intensity threshold is calculated based on the flow velocity at the target time;
[0050] If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the fifth weight is used as the weight of the observed value of the target moment, and the sixth weight is used as the weight of the predicted value of the target moment, and the observed value and the predicted value of the target moment are weighted and summed to obtain the calculated value of the target moment; 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.
[0051] In a possible embodiment, if the residual fluctuation amount corresponding to the target time is not greater than the first strength threshold, 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, performing a weighted sum of the observed value and the predicted value at the target time, including:
[0052] If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and is not greater than the first fluctuation amount threshold, the observed value and the predicted value at the target moment are weighted and summed 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; the first fluctuation amount threshold is obtained based on the statistics of the residual fluctuation amounts corresponding to each of the moments in the same window;
[0053] If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold and greater than the first fluctuation threshold, the third weight is used as the weight of the observation value of the target moment, and the fourth weight is used as the weight of the predicted value of the target moment, and the observation value and the predicted value of the target moment are weighted and summed.
[0054] In a possible embodiment, taking a first weight as the weight of the observed value at the target moment and a second weight as the weight of the predicted value at the target moment, 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:
[0055] If the residual fluctuation corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, the observed value and the predicted value at the target moment are weighted and summed using 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 to obtain a calculated value at the target moment; wherein the residual mean is the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window; the seventh weight is greater than the eighth weight; and the second intensity threshold is calculated based on the flow velocity at the target moment;
[0056] If the residual fluctuation 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, the ninth weight is used as the weight of the observed value of the target moment, and the tenth weight is used as the weight of the predicted value of the target moment, and the observed value and the predicted value of the target moment are weighted and summed to obtain the calculated value of the target moment; 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, if the residual fluctuation amount corresponding to the target time is not greater than the second intensity threshold and the residual mean is not greater than the second intensity threshold, using a ninth weight as the weight of the observed value at the target time and a tenth weight as the weight of the predicted value at the target time, performing a weighted sum of the observed value and the predicted value at the target time, including:
[0058] 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 is not greater than the second intensity threshold and the residual mean is not greater than the second fluctuation amount threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and a weighted sum is performed on the observed value and the predicted value at the target moment; the second fluctuation amount threshold is obtained based on the residual fluctuation amount statistics corresponding to each of the moments in the same window;
[0059] If the residual fluctuation corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold, or the residual mean is not greater than the second intensity threshold and the residual mean is greater than the second fluctuation threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment 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 based on 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 the flow velocity at the target time;
[0062] The fluctuation threshold calculation module is used to calculate the product of the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each moment in the same window and a preset multiplier to obtain the fluctuation threshold as the first fluctuation threshold or the second fluctuation threshold, wherein the preset multiplier is positively correlated with the flow rate at the target moment.
[0063] In a possible embodiment, the intensity threshold is calculated in the following manner, 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, and th2 are all parameters, and a1<a2<a3;
[0066] The fluctuation threshold is calculated as follows:
[0067] ;
[0068] in, is the fluctuation threshold; is the preset magnification; The maximum value of the residual fluctuation corresponding to the target time and the residual fluctuation corresponding to each of the same window time;
[0069] The calculation is done by ,include:
[0070] ;
[0071] in, is the preset magnification; v is the flow rate 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 time and the residuals corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time includes:
[0073] Calculate the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual mean;
[0074] The difference between the residual corresponding to the target time and the residual mean is calculated as the residual fluctuation amount corresponding to the target time.
[0075] In a possible embodiment, the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is calculated as the residual corresponding to the target time in the following manner, including:
[0076] ;
[0077] Wherein, k is the target time, e k is the residual corresponding to the target moment; Y k is the observation value at the target moment; H is the m×n observation matrix; X k is the predicted value at the target moment;
[0078] The residual corresponding to the target moment and the mean of the residuals corresponding to the respective moments in the same window are calculated as the residual mean in the following manner, including:
[0079] ;
[0080] Among them, γ k is the residual mean; m is the time window of the target moment; k is the target moment; e i is the residual corresponding to the i-th moment in the time window where the target moment is located;
[0081] Calculating the difference between the residual corresponding to the target moment and the residual mean as the residual fluctuation amount corresponding to the target moment in the following manner includes:
[0082] ;
[0083] in, is the residual fluctuation corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean.
[0084] An embodiment of the present application further provides an electronic device, including:
[0085] Memory for storing computer programs;
[0086] The processor is configured to implement any of the above-mentioned flow calculation methods when executing the program stored in the memory.
[0087] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned flow calculation methods is implemented.
[0088] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-described flow calculation methods.
[0089] Beneficial effects of the embodiments of the present application:
[0090] The embodiments of the present application provide a flow calculation method, device, electronic device and storage medium. Since the error flow rate can be regarded as constant when the flow rate remains unchanged and changes in 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 is caused by the error flow rate. Therefore, when the flow rate remains unchanged and changes in 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 difference 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 discreteness between the residual corresponding to the target moment and the residual corresponding to each same window moment as the residual fluctuation amount corresponding to the target moment, the more concentrated the residual corresponding to the target moment and the residual corresponding to each same window moment are, the smaller the residual fluctuation amount should be. Therefore, the smaller the residual fluctuation, the more stable the difference between the observed value and the predicted value of the electromagnetic flowmeter, and it can be considered that the flow rate at the target moment has not changed. Correspondingly, the error flow rate can also be considered to have not changed. The correspondence between the past observed values and the predicted values (that is, the past prediction method) and the correspondence between the current observed values and the predicted values (that is, the current prediction method) are the same. At this time, the predicted value obtained based on the past prediction method is more accurate, and the predicted value is more accurate than the observed value. Therefore, if the residual fluctuation corresponding to the target moment is small, then when obtaining the calculated value at the target moment, the second weight of the more accurate predicted value should be set larger, and the first weight of the less accurate observation value should be set smaller. Here, the smaller or larger residual fluctuation corresponding to the target time does not refer to the absolute size, but refers to the size relative to the flow rate when it does not change. That is, the smaller residual fluctuation corresponding to the target time means that the residual fluctuation corresponding to the target time is smaller than the maximum residual fluctuation when the flow rate does not change at the target time; the smaller or larger first weight and second weight do not refer to the absolute size, but refer to the size relative to the flow rate change. That is, the larger the second weight of the predicted value is, the larger the second weight of the predicted value is when the flow rate does not change is greater than the second weight of the predicted value when the flow rate changes; the smaller the first weight of the observed value is, the smaller the first weight of the observed value is when the flow rate does not change is less than the first weight of the observed value when the flow rate changes. The same applies to the following. Conversely, the larger the residual fluctuation, the more unstable the difference between the observed value and the predicted value of the electromagnetic flowmeter, which means that the flow rate at the target time has changed. Correspondingly, the error flow rate will also change. The correspondence between the past observed value and the predicted value is different from the correspondence between the current observed value and the predicted value.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 corresponding to the target moment is large, when obtaining the calculated value at the target moment, 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 embodiment of the present application, based on the positive correlation between the first weight and the residual fluctuation corresponding to the target moment and the negative correlation between the second weight and the residual fluctuation 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 velocity does not change, and closer to the observed value when the flow velocity changes, thereby achieving dynamic elimination of the influence of the error flow velocity on the accuracy of flow calculation, thereby improving the accuracy of flow calculation.
[0091] Of course, it is not necessary to achieve all the advantages described above at the same time when implementing any product or method of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0093] Figure 1 A schematic diagram of a first flow chart of a flow calculation method provided in an embodiment of the present application;
[0094] Figure 2 A second flow chart of the flow calculation method provided in an embodiment of the present application;
[0095] Figure 3a A third flow chart of the flow calculation method provided in an embodiment of the present application;
[0096] Figure 3b A fourth flow chart of the flow calculation method provided in an embodiment of the present application;
[0097] Figure 4a A fifth flow chart of the flow calculation method provided in an embodiment of the present application;
[0098] Figure 4b A sixth flow chart of the flow calculation method provided in an embodiment of the present application;
[0099] Figure 5 A schematic diagram of a system structure for implementing a flow calculation method provided in an embodiment of the present application;
[0100] Figure 6 A schematic diagram of the flow velocity noise reduction effect provided by an embodiment of the present application;
[0101] Figure 7 A schematic diagram of the error flow rate change trend provided in an embodiment of the present application;
[0102] Figure 8 A schematic diagram of the noise reduction effect of the fixed observation noise system provided in an embodiment of the present application;
[0103] Figure 9 Another schematic diagram of the flow velocity noise reduction effect provided by an embodiment of the present application;
[0104] Figure 10 A schematic diagram of the structure of a flow calculation device provided in an embodiment of the present application;
[0105] Figure 11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0106] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field based on this application are within the scope of protection of this application.
[0107] In order to more clearly illustrate the flow calculation method provided by the present application, the possible application scenarios of the flow calculation method provided by the present application will be exemplified below. It can be understood that the following examples are only possible application scenarios of the flow calculation method provided by the present application. In other possible embodiments, the flow calculation method provided by the present application can be applied to other possible application scenarios, and the following examples do not impose any limitations on this.
[0108] Electromagnetic flowmeters are flow measurement devices based on the law of electromagnetic induction. They can be used to obtain information such as the flow velocity and flow rate of conductive liquids flowing through them. Due to their advantages of being mechanically free, corrosion-resistant, and highly accurate, electromagnetic flowmeters are widely used in both industrial and civilian applications, and are particularly used to measure the flow rate of conductive liquids. In industrial production or operating condition monitoring scenarios, high requirements are generally placed on the accuracy and stability of electromagnetic flowmeters, which in turn requires high accuracy of the flow signal measured by the electromagnetic flowmeter. In practical applications, electromagnetic flowmeters often encounter complex operating conditions, resulting in a high level of noise. This noise can lead to poor stability in the flow signal output by the electromagnetic flowmeter and significant fluctuations in flow rate measurement. Due to the influence of noise, there is a certain error between the flow velocity measured by the electromagnetic flowmeter and the actual flow velocity. This error is referred to as the error flow rate. The presence of the error flow rate reduces the accuracy of the flow signal measured by the electromagnetic flowmeter.
[0109] To improve the accuracy of flow signals, a Kalman filter is typically used to predict the current flow signal based on the flow signals (i.e., observed values) measured by the electromagnetic flowmeter at both past and current times, yielding a predicted value for the current moment. The Kalman filter's prediction process can be simply understood as summarizing the flow signals measured by the electromagnetic flowmeter at both past and current times to arrive at a prediction for the current flow signal, and then performing a prediction based on this summed-up prediction.
[0110] However, since the error flow rate is not only affected by the noise signal under special working conditions, it also changes with the change of the true flow rate, and the error flow rate is positively correlated with the true flow rate, therefore, when the true flow rate at the current moment remains unchanged, the error flow rate at the past moment is basically the same as the error flow rate at the current moment, that is, it can be considered that the error flow rate is unchanged, then the correspondence between the observed value and the predicted value at the past moment is the same as the correspondence between the observed 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 of the past moment; and when the true flow rate at the current moment changes, the error flow rate at the past moment is different from the error flow rate at the current moment, then the correspondence between the observed value and the predicted value at the past moment is different from the correspondence between the observed value and the predicted value at the current moment, then the predicted value at the current moment predicted based on the prediction method of the past moment is not accurate enough. Therefore, when the true flow rate changes, it is impossible to eliminate the influence of the error flow rate on the accuracy of the flow signal by predicting the predicted value at the current moment according to the past prediction method, and it is also impossible to improve the accuracy of the obtained flow signal. Therefore, how to dynamically eliminate the error flow rate to improve the accuracy of flow calculation has become an urgent problem to be solved.
[0111] Currently, a Kalman filter can be used to filter the flow demodulation results. Dynamically adjusting the filter parameters based on the filter difference sequence can achieve high-precision measurement of constant water flow, reliable measurement of solid-liquid two-phase flow, and rapid tracking of variable flow. However, the filter difference sequence in this approach cannot effectively identify flow velocity changes, especially in micro-flow conditions. This makes it difficult to dynamically eliminate erroneous flow velocity, resulting in low flow calculation accuracy.
[0112] Based on this, in order to dynamically eliminate the influence of error flow rate on the accuracy of flow calculation, thereby improving the accuracy of flow calculation, the embodiment of the present application provides a flow calculation method, see Figure 1 , methods include:
[0113] S101, calculating 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.
[0114] S102, calculating the degree of dispersion between the residual corresponding to the target time and the residual corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time.
[0115] The same window moments are other moments that are in the same time window as the target moment.
[0116] S103, taking 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, performing weighted summation on the observed value and the predicted value at the target moment to obtain a calculated value at the target moment.
[0117] Among them, the first weight is positively correlated with the residual fluctuation corresponding to the target time, and the second weight is negatively correlated with the residual fluctuation corresponding to the target time.
[0118] Applying the embodiments of the present application, since the error flow rate can be regarded as constant when the flow rate remains unchanged and changes in 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 is caused by the error flow rate. Therefore, when the flow rate remains unchanged and changes in 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 difference 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 discreteness between the residual corresponding to the target time and the residual 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 residual corresponding to each same window time are, the smaller the residual fluctuation amount should be. Therefore, the smaller the residual fluctuation, the more stable the difference between the observed value and the predicted value of the electromagnetic flowmeter, and it can be considered that the flow rate at the target moment has not changed. Correspondingly, the error flow rate can also be considered to have not changed. The correspondence between the past observed values and the predicted values (that is, the past prediction method) and the correspondence between the current observed values and the predicted values (that is, the current prediction method) are the same. At this time, the predicted value obtained based on the past prediction method is more accurate, and the predicted value is more accurate than the observed value. Therefore, if the residual fluctuation corresponding to the target moment is small, then when obtaining the calculated value at the target moment, the second weight of the more accurate predicted value should be set larger, and the first weight of the less accurate observation value should be set smaller. Here, the smaller or larger residual fluctuation corresponding to the target time does not refer to the absolute size, but refers to the size relative to the flow rate when it does not change. That is, the smaller residual fluctuation corresponding to the target time means that the residual fluctuation corresponding to the target time is smaller than the maximum residual fluctuation when the flow rate does not change at the target time; the smaller or larger first weight and second weight do not refer to the absolute size, but refer to the size relative to the flow rate change. That is, the larger the second weight of the predicted value is, the larger the second weight of the predicted value is when the flow rate does not change is greater than the second weight of the predicted value when the flow rate changes; the smaller the first weight of the observed value is, the smaller the first weight of the observed value is when the flow rate does not change is less than the first weight of the observed value when the flow rate changes. The same applies to the following. Conversely, the larger the residual fluctuation, the more unstable the difference between the observed value and the predicted value of the electromagnetic flowmeter, which means that the flow rate at the target time has changed. Correspondingly, the error flow rate will also change. The correspondence between the past observed value and the predicted value is different from the correspondence between the current observed value and the predicted value. 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 corresponding to the target moment is large, when obtaining the calculated value of the target moment, 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 embodiment 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 velocity does not change, and is closer to the observed value when the flow velocity changes, thereby dynamically eliminating the influence of the error flow velocity on the accuracy of the flow calculation, thereby improving the accuracy of the flow calculation.
[0119] The following is an exemplary description of the aforementioned S101-S103:
[0120] In S101, in a possible embodiment, the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time can be directly used as the residual corresponding to the target time.
[0121] In another possible embodiment, the residual corresponding to the target time may also be calculated using the following formula (1), including:
[0122]
[0123] Among them, k is the target time, e k is the residual corresponding to the target moment; Y k is the observation value at the target time; H is the m×n observation matrix; X k is the predicted value at the target time.
[0124] In S102, the period of the time window can be set according to user needs. For example, the period of the time window can be set to 5 unit time, 10 unit time, 15 unit time, etc. For example, assuming that the period of the time window is 5 unit time, the target time is T=10, the time window in which the target time is located is T=10 to T=15, and other time points in the same time window as the target time, that is, the time points in the same window, are each time point from T=11 to T=15.
[0125] For each same-window moment, the method for calculating the residual corresponding to the same-window moment is similar to the method for calculating the residual corresponding to the target moment, with the only difference being that the observed value and predicted value of the electromagnetic flowmeter at the target moment are replaced with the observed value and predicted value of the electromagnetic flowmeter at the same-window moment. That is, the difference between the observed value and predicted value of the electromagnetic flowmeter at the same-window moment is calculated as the residual corresponding to the same-window moment. The specific calculation method can be found in the relevant description of S101 above and will not be repeated here. The method for calculating the residual fluctuation amount corresponding to the target moment will be exemplified below and will not be repeated here.
[0126] In S103, the first weight is positively correlated with the residual fluctuation amount corresponding to the target moment, which means that, with other factors remaining unchanged, the first weight increases as the residual fluctuation amount corresponding to the target moment increases, and decreases as the residual fluctuation amount corresponding to the target moment decreases. The second weight is negatively correlated with the residual fluctuation amount corresponding to the target moment, which means that, with other factors remaining unchanged, the second weight decreases as the residual fluctuation amount corresponding to the target moment increases, and increases as the residual fluctuation amount corresponding to the target moment decreases. In this application, increasing may refer to monotonically increasing or non-monotonic increasing, and decreasing may refer to monotonically decreasing or non-monotonic decreasing.
[0127] Since the residual fluctuation is calculated by calculating the degree of dispersion between the residual corresponding to the target time and the residual corresponding to each time window, if the residual fluctuation at the target time is large, the residual corresponding to the target time and the residual corresponding to each time window are more dispersed, which means that the difference between the residual corresponding to the target time and the residual corresponding to each time window is large, and the stability of the residual corresponding to the target time is poor. Since the residual corresponding to the target time is calculated by calculating the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time, the stability of the residual corresponding to the target time is poor, indicating 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 is understandable that when the flow rate remains constant, the error flow rate remains constant. 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 constant, the difference between the observed value and the predicted value of the electromagnetic flowmeter at different times should be within a preset range. The preset range is set according to the flow rate. It can be considered that when the flow rate remains constant, 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, and correspondingly, the error flow rate will also change. The correspondence between the past observed value and the predicted value is different from the correspondence between the observed value and the predicted value at the current time, that is, 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 corresponding to the target moment is large, the observed value is more accurate when the calculated value at the target moment is obtained, and the first weight of the observed value can be set larger. If the predicted value is not accurate enough, the second weight of the predicted value can be set smaller.
[0129] Similarly, if the residual fluctuation at the target time is small, the residual at the target time and the residuals at each time window are more concentrated, indicating that the difference between the residual at the target time and the residuals at each time window is small, and the residual at the target time is more stable. Since the residual at the target time is calculated by calculating the difference between the observed and predicted values of the electromagnetic flowmeter at the target time, the stability of the residual at the target time is better, indicating that the difference between the observed and predicted values of the electromagnetic flowmeter at the target time is more stable.
[0130] It is understandable 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 difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is stable, it can be considered that the flow rate at the target time has not changed, and correspondingly, the error flow rate has not changed. The correspondence between the past observed value and the predicted value is the same as the correspondence 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 based on the past prediction method is more accurate, and is more accurate than the observed value. Therefore, if the residual fluctuation corresponding to the target time is small, then when the calculated value at the target time is obtained, the predicted value is more accurate, and the second weight of the predicted value can be set larger. If the observed value is not accurate enough, the first weight of the observed value can be set smaller. Therefore, the first weight is positively correlated with the residual fluctuation corresponding to the target time, and the second weight is negatively correlated with the residual fluctuation corresponding to the target time.
[0131] The above S101-S103 have been described as an example. Referring to the above description, the flow calculation method provided by this application relies 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 describe the method of calculating the residual fluctuation amount corresponding to the target time as an example. In one possible embodiment, see Figure 2 , the flow calculation method provided in this application includes:
[0132] S101, calculating 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] S101 has been exemplarily described above. Please refer to the aforementioned related description of S101 and will not be repeated here.
[0134] S1021, calculating the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual mean.
[0135] Specifically, the residual mean is calculated using the following formula (2), including:
[0136]
[0137] Among them, γ 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 in the time window of the target moment. Among them, m can be set to the excitation frequency of the electromagnetic flowmeter, or it can be set arbitrarily according to user needs. For example, m can be set to 5 , 10, 15 and so on.
[0138] S1022, calculating the difference between the residual corresponding to the target time and the residual mean as the residual fluctuation corresponding to the target time.
[0139] The absolute value of the difference between the residual and the residual mean at the target time is taken as the residual fluctuation at the target time. Specifically, the residual fluctuation at the target time is calculated using the following formula (3), including:
[0140]
[0141] in, is the residual fluctuation corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean.
[0142] S103, taking 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, performing weighted summation on the observed value and the predicted value at the target moment to obtain a calculated value at the target moment.
[0143] Among them, the first weight is positively correlated with the residual fluctuation corresponding to the target time, and the second weight is negatively correlated with the residual fluctuation corresponding to the target time.
[0144] S103 has been exemplarily described above. Please refer to the aforementioned related description of S103 and will not be repeated here.
[0145] By selecting this embodiment, the residual corresponding to the target moment and the mean of the residuals corresponding to each moment in the same window can be calculated as the residual mean; the difference between the residual corresponding to the target moment and the residual mean can be calculated as the residual fluctuation corresponding to the target moment, so that the residual fluctuation corresponding to the target moment can be calculated relatively simply, and the first weight and the second weight can be set according to the calculated residual fluctuation corresponding to the target moment, and the first weight is positively correlated with the residual fluctuation corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation corresponding to the target moment, so as to obtain a more accurate calculated value of the target moment, thereby dynamically eliminating the influence of the error flow rate on the accuracy of the flow calculation, thereby improving the accuracy of the flow calculation.
[0146] In other possible embodiments, the residual fluctuation corresponding to the target time may be calculated by: calculating the mean of the residual corresponding to the target time and the residual corresponding to each time point in the same window as the residual mean; and taking the average of the differences between the residual corresponding to the target time and the residual mean at the adjacent time points as the residual fluctuation corresponding to the target time. Adjacent time points are the time point before and the time point after the target time.
[0147] Specifically, the residual fluctuation corresponding to the target time is calculated by the following formula (4), including:
[0148]
[0149] in, is the residual fluctuation 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 next moment after the target moment; γ k is the residual mean.
[0150] The above has been an example of how to calculate the residual fluctuation corresponding to the target time. As mentioned above, in addition to the calculation of the residual fluctuation corresponding to the target time, the flow calculation method provided by this 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 following will continue to explain the setting of the first weight and the second weight by way of example. In a possible embodiment, see Figure 3a , the flow calculation method provided in this application includes:
[0151] S101, calculating 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.
[0152] S102, calculating the degree of dispersion between the residual corresponding to the target time and the residual corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time.
[0153] The same window moments are other moments that are in the same time window as the target moment.
[0154] S101 - S102 have been exemplarily described above. Please refer to the aforementioned related descriptions of S101 - S102 and will not be repeated here.
[0155] S1031, if the residual fluctuation corresponding to the target moment is greater than the first intensity threshold, the third weight is used as the weight of the observation value at the target moment, and the fourth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment.
[0156] The third weight is greater than the fourth weight; and the first intensity threshold is calculated based on the flow velocity at the target moment.
[0157] S1032, if the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the fifth weight is used as the weight of the observation value at the target moment, and the sixth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment.
[0158] 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.
[0159] In S1031-S1032, since the first intensity threshold is calculated based on the flow velocity at the target time, it can be used to reflect the theoretical maximum fluctuation amount estimated based on the flow velocity at the target time. Specifically, a correspondence between flow velocity and maximum residual fluctuation amount is pre-set. The flow velocity at the target time is substituting this correspondence into the maximum residual fluctuation amount corresponding to the flow velocity at the target time. The maximum residual fluctuation amount corresponding to the flow velocity at the target time is thus the first intensity threshold.
[0160] Then, when the residual fluctuation corresponding to the target moment is greater than the first intensity threshold, it means that the residual fluctuation corresponding to the target moment is greater than the maximum residual fluctuation corresponding to the flow velocity at the target moment, which means 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 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 corresponding to the target moment is no greater than the first intensity threshold, it can be considered that the flow rate at the target moment has not changed, and correspondingly, the error flow rate has not changed, 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 more accurate, and is more accurate than the observed value. Therefore, if the residual fluctuation corresponding to the target moment is no greater than the first intensity threshold, then 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 should be greater than the fifth weight.
[0162] For the observation value, it is more accurate when the residual fluctuation amount corresponding to the target time is greater than the first intensity threshold, and it is not accurate enough when the residual fluctuation amount corresponding to the target time is not greater than the first intensity threshold. Therefore, the third weight when the residual fluctuation amount corresponding to the observation value at the target time is greater than the first intensity threshold should be greater than the fifth weight when the residual fluctuation amount corresponding to the observation value at the target time 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 not accurate enough when the residual fluctuation corresponding to the target time is greater than the first intensity threshold, and is more accurate when the residual fluctuation corresponding to the target time is not greater than the first intensity threshold. Therefore, the fourth weight of the predicted value when the residual fluctuation corresponding to the target time is greater than the first intensity threshold should be smaller than the sixth weight when the residual fluctuation corresponding to the observed value at the target time 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 theoretical maximum fluctuation at the target moment can be reflected by the first intensity threshold calculated based on the flow rate at the target moment, so that it is possible to more accurately judge whether the flow rate has changed by judging whether the residual fluctuation corresponding to the target moment is greater than the first intensity threshold, and dynamically adjust the weight of the observation value and the weight of the prediction value according to the judgment result, so as to obtain a more accurate calculation value at the target moment by performing a weighted summation of the observation value and the prediction 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.
[0165] In order to further improve the accuracy of determining whether the flow rate has changed, in a possible embodiment, see Figure 3b , the flow calculation method provided in this application includes:
[0166] S101, calculating 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.
[0167] S102, calculating the degree of dispersion between the residual corresponding to the target time and the residual corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time.
[0168] The same window moments are other moments that are in the same time window as the target moment.
[0169] S1031, if the residual fluctuation corresponding to the target moment is greater than the first intensity threshold, the third weight is used as the weight of the observation value at the target moment, and the fourth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment.
[0170] Among them, the third weight is greater than the fourth weight.
[0171] S101-S1031 have been exemplarily described above. Please refer to the aforementioned related descriptions of S101-S1031 and will not be repeated here.
[0172] S10321, if the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold and is not greater than the first fluctuation threshold, then the fifth weight is used as the weight of the observation value at the target moment, and the sixth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment.
[0173] 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 threshold is obtained based on the residual fluctuation statistics corresponding to each moment in the same window.
[0174] S10322, if the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold and greater than the first fluctuation threshold, then the third weight is used as the weight of the observation value at the target moment, and the fourth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment.
[0175] In S10321-S10322, since the first fluctuation threshold is derived based on the residual fluctuation statistics corresponding to each time point in the same window, the first fluctuation threshold can be used to reflect the theoretical maximum fluctuation obtained based on the residual fluctuation statistics corresponding to each time point in the same window. Therefore, if the flow rate remains unchanged, the residual fluctuation corresponding to the target time point should not exceed the first fluctuation threshold. Therefore, when the residual fluctuation corresponding to the target time point is greater than the first fluctuation threshold, it can be considered that the flow rate at the target time point has changed, and accordingly, the error flow rate has also changed, and the previous prediction method and the current prediction method are different. In this case, the predicted value obtained based on the previous prediction method is not accurate enough. The observed value is more accurate than the predicted value. Therefore, if the residual fluctuation corresponding to the target time point is greater than the first fluctuation threshold, when obtaining the calculated value at the target time point, 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 should be greater than the fourth weight.
[0176] When the residual fluctuation corresponding to the target time is no greater than the first fluctuation threshold, it can be considered that the flow rate at the target time has not changed, and correspondingly, the error flow rate has not changed, and the previous prediction method and the current prediction method are the same. At this time, the predicted value obtained based on the previous prediction method is more accurate, and is more accurate than the observed value. Therefore, if the residual fluctuation corresponding to the target time is no greater than the first fluctuation threshold, then 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 should be greater than the fifth weight.
[0177] For the observation value, when the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the observation value is more accurate when the residual fluctuation corresponding to the target moment is greater than the first fluctuation threshold, and is not accurate enough when the residual fluctuation corresponding to the target moment is not greater than the first fluctuation threshold. Therefore, the third weight when the residual fluctuation corresponding to the observation value at the target moment is greater than the first fluctuation threshold should be greater than the fifth weight when the residual fluctuation corresponding to the observation value at the target moment is not greater than the first fluctuation threshold, that is, the third weight is greater than the fifth weight.
[0178] For the predicted value, when the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the predicted value is not accurate enough when the residual fluctuation corresponding to the target moment is greater than the first fluctuation threshold, and is relatively accurate when the residual fluctuation corresponding to the target moment is not greater than the first fluctuation threshold. Therefore, the fourth weight of the predicted value when the residual fluctuation corresponding to the target moment is greater than the first fluctuation threshold should be smaller than the sixth weight when the residual fluctuation corresponding to the observed value at the target moment is not greater than the first fluctuation threshold, that is, the sixth weight is greater than the fourth weight.
[0179] By selecting this embodiment, when it is determined that the flow rate has not changed based on the first intensity threshold, the first fluctuation threshold obtained based on the residual fluctuation statistics corresponding to each moment in the same window can reflect the theoretical maximum fluctuation at the target moment, so that it is possible to further accurately determine whether the flow rate has changed by determining whether the residual fluctuation corresponding to the target moment is greater than the first fluctuation threshold, and obtain a further judgment result. The weights of the observation values and the weights of the prediction values are dynamically adjusted according to the further judgment result, so as to obtain a more accurate calculation value at the target moment by performing a weighted summation of the observation values and the prediction values 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 in this application includes:
[0181] S101, calculating 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.
[0182] S102, calculating the degree of dispersion between the residual corresponding to the target time and the residual corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time.
[0183] The same window moments are other moments that are in the same time window as the target moment.
[0184] S101 - S102 have been exemplarily described above. Please refer to the aforementioned related descriptions of S101 - S102 and will not be repeated here.
[0185] S1033, if the residual fluctuation corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, the seventh weight is used as the weight of the observation value at the target moment, and the eighth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed 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 residual corresponding to each moment in the same window; the seventh weight is greater than the eighth weight; and the second intensity threshold is calculated based on the flow velocity at the target moment.
[0187] S1034, if the residual fluctuation 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 the ninth weight is used as the weight of the observation value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed 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, which will not be repeated here.
[0190] Because the second intensity threshold is calculated based on the flow velocity at the target time, it can be used to reflect the theoretical maximum fluctuation estimated based on the flow velocity at the target time. Specifically, a correspondence between flow velocity and maximum residual fluctuation is pre-set. Substituting the flow velocity at the target time into this correspondence, the maximum residual fluctuation corresponding to the flow velocity at the target time is obtained. This maximum residual fluctuation corresponding to the flow velocity at the target time is the second intensity threshold.
[0191] Then, when the residual fluctuation corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, it means that the residual fluctuation corresponding to the target moment is greater than the maximum residual fluctuation corresponding to the flow velocity at the target moment, and 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 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 observation value should be set larger, and the eighth weight of the less accurate prediction value should be set smaller, that is, the seventh weight is greater than the eighth weight.
[0192] When the residual fluctuation 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, it can be considered that the flow rate at the target moment has not changed, and correspondingly, the error flow rate has not changed, 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 more accurate, and the predicted value is more accurate than the observed value. Therefore, if the residual fluctuation 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 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 observation value, it is more accurate when the residual fluctuation corresponding to the target time is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, and it is not accurate enough when the residual fluctuation corresponding to the target time is not greater than the second intensity threshold and the residual mean is not greater than the second intensity threshold. Therefore, the seventh weight when the residual fluctuation corresponding to the observation value at the target time is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold should be greater than the ninth weight when the residual fluctuation corresponding to the observation value at the target time is not greater than the second intensity threshold and the residual mean 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 not accurate enough when the residual fluctuation corresponding to the target time is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold. It is more accurate when the residual fluctuation corresponding to the target time is not greater than the second intensity threshold and the residual mean is not greater than the second intensity threshold. Therefore, the eighth weight of the predicted value when the residual fluctuation corresponding to the target time is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold should be smaller than the tenth weight when the residual fluctuation corresponding to the observed value at the target time is not greater than the second intensity threshold and the residual mean 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 rate at the target moment can reflect the theoretical maximum fluctuation at the target moment, so that it is possible to more accurately judge whether the flow rate has changed by judging whether the residual fluctuation corresponding to the target moment is greater than the second intensity threshold and whether the residual mean is greater than the second intensity threshold. The weights of the observation values and the predicted values are dynamically adjusted according to the judgment results, so as to obtain a more accurate calculated value at the target moment by performing a weighted summation of the observation values and the predicted values 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.
[0196] In order to further improve the accuracy of determining whether the flow rate has changed, in a possible embodiment, see Figure 4b , the flow calculation method provided in this application includes:
[0197] S101, calculating 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.
[0198] S102, calculating the degree of dispersion between the residual corresponding to the target time and the residual corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time.
[0199] The same window moments are other moments that are in the same time window as the target moment.
[0200] S1033, if the residual fluctuation corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, the seventh weight is used as the weight of the observation value at the target moment, and the eighth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment.
[0201] Among them, the residual mean is the mean of the residual corresponding to the target moment and the residual corresponding to each moment in the same window; the seventh weight is greater than the eighth weight.
[0202] S101-S1033 have been exemplarily described above. Please refer to the aforementioned related descriptions of S101-S1033 and will not be repeated here.
[0203] S10341, if the residual fluctuation corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation corresponding to the target moment is not greater than the second fluctuation threshold, and the residual mean is not greater than the second intensity threshold and the residual mean is not greater than the second fluctuation threshold, then the ninth weight is used as the weight of the observation value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed 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 threshold is obtained based on the residual fluctuation statistics corresponding to each moment in the same window.
[0205] S10342, if the residual fluctuation corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold, or the residual mean is not greater than the second intensity threshold and the residual mean is greater than the second fluctuation threshold, then the ninth weight is used as the weight of the observation value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment.
[0206] In S10341-S10342, since the second fluctuation threshold is derived based on the residual fluctuation statistics corresponding to each time point in the same window, the second fluctuation threshold can be used to reflect the theoretical maximum fluctuation obtained based on the residual fluctuation statistics corresponding to each time point in the same window. Therefore, if the flow rate remains unchanged, the residual fluctuation and residual mean corresponding to the target time point should not exceed the second fluctuation threshold. Therefore, when the residual fluctuation corresponding to the target time point is greater than the second fluctuation threshold or the residual mean is greater than the second fluctuation threshold, it can be considered that the flow rate at the target time point has changed, and accordingly, the error flow rate has also changed, and the previous prediction method and the current prediction method are different. In this case, the predicted value obtained based on the previous prediction method is not accurate enough. The observed value is more accurate than the predicted value. Therefore, if the residual fluctuation corresponding to the target time point is greater than the second fluctuation threshold or the residual mean is greater than the second fluctuation threshold, when obtaining the calculated value at the target time point, 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 should be greater than the eighth weight.
[0207] When the residual fluctuation corresponding to the target moment is not greater than the second fluctuation threshold and the residual mean is not greater than the second fluctuation threshold, it can be considered that the flow rate at the target moment has not changed, and correspondingly, the error flow rate has not changed, 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 more accurate, and the predicted value is more accurate than the observed value. Therefore, if the residual fluctuation corresponding to the target moment is not greater than the second fluctuation threshold and the residual mean is not greater than the second fluctuation threshold, then 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.
[0208] For the observation value, when the residual fluctuation 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, the observation value is more accurate when the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold or the residual mean is greater than the second fluctuation threshold. It is not accurate enough when the residual fluctuation corresponding to the target moment is not greater than the second fluctuation threshold and the residual mean is not greater than the second fluctuation threshold. Therefore, the seventh weight when the residual fluctuation corresponding to the observation value at the target moment is greater than the second fluctuation threshold or the residual mean is greater than the second fluctuation threshold should be greater than the ninth weight when the residual fluctuation corresponding to the observation value at the target moment is not greater than the second fluctuation threshold and the residual mean is not greater than the second fluctuation threshold, that is, the seventh weight is greater than the ninth weight.
[0209] For the predicted value, when the residual fluctuation 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, the predicted value is not accurate enough when the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold or the residual mean is greater than the second fluctuation threshold. It is more accurate when the residual fluctuation corresponding to the target moment is not greater than the second fluctuation threshold and the residual mean is not greater than the second fluctuation threshold. Therefore, the eighth weight of the predicted value when the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold or the residual mean is greater than the second fluctuation threshold should be less than the tenth weight when the residual fluctuation corresponding to the observed value at the target moment is not greater than the second fluctuation threshold and the residual mean is not greater than the second fluctuation threshold, that is, the tenth weight is greater than the eighth weight.
[0210] By selecting this embodiment, when it is determined that the flow rate has not changed based on the second intensity threshold, the second fluctuation threshold obtained based on the residual fluctuation statistics corresponding to each moment in the same window can reflect the theoretical maximum fluctuation at the target moment, so that it is possible to further accurately determine whether the flow rate has changed by determining whether the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold, and obtain a further judgment result. The weights of the observation values and the weights of the prediction values are dynamically adjusted according to the further judgment result, so as to obtain a more accurate calculation value at the target moment by performing a weighted summation of the observation values and the prediction values 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.
[0211] The above has been described in an exemplary manner for setting the first weight and the second weight, see Figure 3a and Figure 4aAs can be seen from the embodiment shown, 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 following will provide an exemplary description of the settings of the first intensity threshold and the second intensity threshold. The first intensity threshold and the second intensity threshold in this application can be equal or different.
[0212] Specifically, the first intensity threshold or the second intensity threshold can be set in the following manner: based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time, the intensity threshold is calculated 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 positively correlated with the flow velocity at the target time.
[0213] The calculated intensity threshold is positively correlated with the electromagnetic flowmeter's pipe cross-sectional area, meaning that, with other factors remaining unchanged, the calculated intensity threshold increases as the electromagnetic flowmeter's pipe cross-sectional area increases and decreases as the electromagnetic flowmeter's pipe cross-sectional area decreases. The calculated intensity threshold is positively correlated with the target flow velocity, meaning that, with other factors remaining unchanged, the calculated intensity threshold increases as the target flow velocity increases and decreases as the target flow velocity decreases.
[0214] Specifically, the intensity threshold is calculated by the following formula (5), including:
[0215]
[0216] Where △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, and th2 are all parameters, and a1<a2<a3.
[0217] a1, a2, a3, th1, and th2 can be set based on past experience or user needs. For example, a1=0.003, a2=0.024, a3=0.036, th1=2m / s, and th2=6m / s. In this example, the intensity threshold is calculated using 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 as the first intensity threshold or the second intensity threshold, and the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target moment. The first intensity threshold or the second intensity threshold is set for each different target moment, so that the first intensity threshold or the second intensity threshold can be dynamically adjusted for different target moments, and the first intensity threshold or the second intensity threshold can be set more reasonably to more accurately judge whether the flow velocity has changed based on the first intensity threshold or the second intensity threshold, and dynamically adjust the weight of the observation value and the weight of the prediction value according to the judgment result, and obtain a more accurate calculation value at the target moment by weighted summation of the observation value and the prediction 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.
[0220] The above has been described in an exemplary manner for setting the first intensity threshold and the second intensity threshold, see Figure 3b and Figure 4b In the embodiment shown, it can be seen that, in addition to the first intensity threshold and the second intensity threshold, the determination of whether the flow rate has changed also depends on the setting of the first fluctuation volume threshold and the second fluctuation volume threshold. Therefore, the following will provide an exemplary description of the setting of the first fluctuation volume threshold and the second fluctuation volume threshold. In this application, the first fluctuation volume threshold and the second fluctuation volume threshold can be equal or different.
[0221] Specifically, the first fluctuation volume threshold or the second fluctuation volume threshold can be set in the following manner: calculate the product of the maximum value of the residual fluctuation volume corresponding to the target moment and the residual fluctuation volume corresponding to each moment in the same window and the preset multiplier to obtain the fluctuation volume threshold as the first fluctuation volume threshold or the second fluctuation volume threshold, wherein the preset multiplier is positively correlated with the flow rate at the target moment.
[0222] The preset magnification and the flow rate at the target time mean that, with other factors remaining unchanged, the preset magnification increases as the flow rate at the target time increases, and decreases as the flow rate at the target time decreases.
[0223] The residual fluctuation corresponding to the target time and the residual fluctuation corresponding to each window time are recorded as , N is the residual fluctuation corresponding to the target time and the number of residual fluctuations corresponding to each time in the same window, that is, N is the number of observations output by the electromagnetic flowmeter in a time window. In the example where the time window m is 3 seconds, N is equivalent to the number of observations output by the electromagnetic flowmeter in 3 seconds. The maximum value of the residual fluctuation corresponding to the target time and the residual fluctuation corresponding to each time in the same window is recorded as ,but . That is to say is the unidirectional 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 obey the normal distribution, that is, ,in, is the standard deviation, which is used to characterize the width of the distribution of residuals.
[0225] Specifically, the fluctuation threshold is calculated as follows:
[0226]
[0227] in, is the fluctuation threshold; is the preset magnification; It is the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each moment in the same window.
[0228] The preset magnification is calculated by the following formula (8), including:
[0229]
[0230] in, is the preset ratio; v is the flow rate at the target moment; b1, b2, b3, th1, and th2 are all parameters, and b1<b2<b3.
[0231] b1, b2, b3, th1, and th2 can be set based on past experience or user needs. For example, b1=1.3, b2=1.5, b3=1.8, th1=2m / s, and th2=6m / s. In this example, the preset magnification is calculated using the following formula (9), that is, formula (8) can be replaced by the following formula (9):
[0232]
[0233] By selecting this embodiment, a fluctuation threshold can be obtained by calculating the residual fluctuation corresponding to the target moment and the product of the maximum value of the residual fluctuation corresponding to each moment in the same window and a preset multiplier, as the first fluctuation threshold or the second fluctuation threshold, wherein the preset multiplier is positively correlated with the flow velocity at the target moment, and the fluctuation threshold at the target moment is positively correlated with the flow velocity at the target moment. The first fluctuation threshold or the second fluctuation threshold is set for each different target moment, so that the first fluctuation threshold or the second fluctuation threshold can be dynamically adjusted for different target moments, and the first fluctuation threshold or the second fluctuation threshold can be set more reasonably to more accurately judge whether the flow velocity has changed based on the first fluctuation threshold or the second fluctuation threshold, dynamically adjust the weight of the observation value and the weight of the prediction value according to the judgment result, and obtain a more accurate calculation value at the target moment by weighted summing the observation value and the prediction 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 aforementioned S103 can be implemented by a Kalman filter. Specifically, the observation value is used as the initial prediction value, and the prediction value is updated by the measurement 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] Among them, X k is the state quantity at the kth moment; X k-1 is the state quantity at the k-1th 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 kth moment; V k is the measurement noise, and V k ∈[0, R]; R is the covariance matrix of the observation noise; A is the n×n state transfer matrix; H is the m×n observation matrix; W k and V k Since the traffic signal is a one-dimensional signal, m=n=1.
[0237] The predicted value at the kth moment is calculated using the following formula (12):
[0238]
[0239] in, is the predicted value at the kth moment; is the optimal estimate at the k-1th moment; A is the n×n state transfer matrix.
[0240] The prior error covariance value at the kth moment is calculated using the following formula (13):
[0241]
[0242] in, is the prior error covariance value at the kth moment; A is the n×n state transfer matrix; A T is the transposed matrix of the state transfer matrix A; P k-1 is the optimal estimation deviation covariance at the k-1th moment; Q is the covariance matrix of the state noise.
[0243] The Kalman filter gain at the kth moment is calculated using the following formula (14):
[0244]
[0245] Among them, K k is the Kalman filter gain at the kth moment, which is used to characterize the credibility of the latest measurement value, that is, the weight component; is the prior error covariance value at the kth moment; H is the m×n observation matrix; H T is the transposed matrix of the observation matrix H; R is the covariance matrix of the observation noise.
[0246] The state estimation value at the kth moment is calculated by the following formula (15), which is also the calculated value at the kth moment:
[0247]
[0248] in, is the estimated value of the state at the kth moment; is the predicted value at the kth moment; K k is the Kalman filter gain at the kth moment; Y k is the observation value at the kth moment; H is the m×n observation matrix.
[0249] The optimal estimated deviation covariance at the kth moment is updated by the following formula (16):
[0250]
[0251] Among them, P k is the optimal estimated deviation covariance at the kth moment after the update, that is, the n×n posterior covariance matrix; I is the n×n order unit matrix; K k is the Kalman filter gain at the kth moment and is an n×m-order matrix; is the prior error covariance value at the kth moment and is an n×n matrix; H is the m×n observation matrix.
[0252] In practical applications, the initialization filter parameters of the Kalman filter , state estimation bias covariance P0=1, state noise covariance Q=0.01, observation noise covariance R=4. The selection of P0 and P1 will affect the initial filter convergence speed and filtering effect to a certain extent. Therefore, in actual use, to prevent interference introduced by tooling, spike interference can be removed in advance to make the filtering effect more stable. Spike interference can be measured using the median or other statistical methods, which will not be elaborated here.
[0253] When the flow rate changes, the Q in the Kalman filter is set to 0.01, that is, Q=0.01. When the flow rate does not change, Q is set to 0.01×10 -6 , that is, Q = 0.01 × 10 -6 When the flow rate changes, R is set to 4, that is, R=4. When the flow rate does not change, R is set using 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 the Q, the more inaccurate the predicted value, and the smaller the Q, the more accurate the predicted value. It can be understood that if the predicted value is less accurate, the confidence of the predicted value is lower, and if the predicted value is more accurate, the confidence of the predicted value is higher. Therefore, Q can be used to reflect the confidence of the predicted value, and Q is negatively correlated with the confidence of the predicted value. The aforementioned second weight is also used to reflect the confidence of the predicted value, and the second weight is positively correlated with the confidence 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 observation value. The larger R is, the more inaccurate the observation value is, and the smaller R is, the more accurate the observation value is. It can be understood that if the observation value is less accurate, the confidence of the observation value is lower, and if the observation value is more accurate, the confidence of the observation value is higher. Therefore, R can be used to reflect the confidence of the observation value, and R is negatively correlated with the confidence of the observation value. The aforementioned first weight is also used to reflect the confidence of the observation value, and the first weight is positively correlated with the confidence of the observation 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 by using a Kalman filter, the flow calculation method provided by the present application can be performed as follows: Figure 5 The system implementation shown in Figure 5 ,The system includes: Kalman filter, flow rate monitoring system, and noise adaptation module.
[0258] Figure 5 The illustrated system implements the flow calculation method provided in this application in the following manner: an electromagnetic flowmeter measures a flow signal, and the flow signal measured by the electromagnetic flowmeter is equivalent to the aforementioned observed value. The observed value is input into a Kalman filter to predict a predicted value. The flow rate monitoring system determines whether the flow rate has changed based on the observed value and the predicted value, and obtains a judgment result. The noise adaptation module sets the Q and R in the Kalman filter based on the judgment result obtained by the flow rate 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 noise-reduced flow signal. The electromagnetic flowmeter then measures a new flow signal, that is, a new observed value. The Kalman filter predicts the new observed value based on the set Q and R to obtain a new predicted value. The flow rate monitoring system determines whether the flow rate has changed based on the new observed value and the new predicted value, and obtains a new judgment result. The noise adaptation module resets the 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 reset Q and R to obtain a new noise-reduced flow signal. By analogy, the above process is continuously executed in a cycle to achieve noise reduction of each flow signal measured by the electromagnetic flowmeter.
[0259] In the above process, the flow velocity noise reduction effect can be as follows: Figure 6 As shown, the error flow rate change trend can be shown as Figure 7 As shown, the noise reduction effect of the fixed observation noise system can be as follows Figure 8 As shown, another effect diagram of the flow velocity noise reduction effect can be shown as Figure 9 As shown. Figure 6 、 Figure 8 as well as Figure 9 In the figure, the solid lines are the original signals, and the dotted lines are the noise-reduced signals. Figure 6 、 Figure 7 、 Figure 8 as well as Figure 9 In the figure, the horizontal axis is used to represent the sampling period, and the vertical axis is used to represent the flow rate signal.
[0260] Corresponding to the aforementioned flow calculation method, the present application embodiment also provides a flow calculation device, see Figure 10 , the device comprises:
[0261] The residual calculation module 1001 is used to 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;
[0262] The residual fluctuation calculation module 1002 is used to calculate the degree of dispersion between the residual corresponding to the target time and the residual corresponding to each time in the same window as the target time, as the residual fluctuation corresponding to the target time, where the time in the same window is the other time in the same time window as the target time.
[0263] The calculation value obtaining module 1003 is used to perform weighted summation on the observation value and the predicted value at the target moment with the first weight as the weight of the observation value at the target moment and the second weight as the weight of the predicted value at the target moment to obtain the calculation 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.
[0264] In a possible embodiment, a first weight is used as the weight of the observed value at the target moment, a second weight is used as the weight of the predicted value at the target moment, and a weighted sum is performed on the observed value and the predicted value at the target moment to obtain a calculated value at the target moment, including:
[0265] If the residual fluctuation corresponding to the target time is greater than the first intensity threshold, the observed value at the target time and the predicted value at the target time are weighted and summed, 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, to obtain the calculated value at the target time; wherein the third weight is greater than the fourth weight; and the first intensity threshold is calculated based on the flow velocity at the target time;
[0266] If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the fifth weight is used as the weight of the observation value at the target moment, and the sixth weight is used as the weight of the predicted value at the target moment. The observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value of the target moment; wherein 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.
[0267] In a possible embodiment, if the residual fluctuation amount corresponding to the target time is not greater than the first strength threshold, the fifth weight is used as the weight of the observed value at the target time, and the sixth weight is used as the weight of the predicted value at the target time, and a weighted sum is performed on the observed value and the predicted value at the target time, including:
[0268] If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold and not greater than the first fluctuation threshold, the observed value and the predicted value at the target moment are weighted and summed 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. The first fluctuation threshold is obtained based on the statistics of the residual fluctuations corresponding to each moment in the same window.
[0269] If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold and greater than the first fluctuation threshold, the third weight is used as the weight of the observation value at the target moment, and the fourth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed.
[0270] In a possible embodiment, a first weight is used as the weight of the observed value at the target moment, a second weight is used as the weight of the predicted value at the target moment, and a weighted sum is performed on the observed value and the predicted value at the target moment to obtain a calculated value at the target moment, including:
[0271] If the residual fluctuation corresponding to the target time is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, the seventh weight is used as the weight of the observed value at the target time, and the eighth weight is used as the weight of the predicted value at the target time, and the observed value and the predicted value at the target time are weighted and summed to obtain the calculated value at the target time; the residual mean is the mean of the residual corresponding to the target time and the residual corresponding to each time in the same window; the seventh weight is greater than the eighth weight; and the second intensity threshold is calculated based on the flow velocity at the target time;
[0272] If the residual fluctuation 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, the ninth weight is used as the weight of the observation value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment. The observation value and the predicted value at the target moment are weighted and summed to obtain the calculated value of the target moment; among which, 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.
[0273] In a possible embodiment, if the residual fluctuation amount corresponding to the target time is not greater than the second strength threshold and the residual mean is not greater than the second strength threshold, the ninth weight is used as the weight of the observed value at the target time, and the tenth weight is used as the weight of the predicted value at the target time, and the observed value and the predicted value at the target time are weighted and summed, including:
[0274] If the residual fluctuation corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation corresponding to the target moment is not greater than the second fluctuation threshold, and the residual mean is not greater than the second intensity threshold and the residual mean is not greater than the second fluctuation threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment are weighted and summed; the second fluctuation threshold is obtained based on the residual fluctuation statistics corresponding to each moment in the same window;
[0275] If the residual fluctuation corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold, or the residual mean is not greater than the second intensity threshold and the residual mean is greater than the second fluctuation threshold, then the ninth weight is used as the weight of the observation value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observation value and the predicted value at the target moment are weighted and summed.
[0276] In a possible embodiment, the device further includes:
[0277] an intensity threshold calculation module, configured to calculate an intensity threshold as a first intensity threshold or a second intensity threshold based on a pipe cross-sectional area of the electromagnetic flowmeter and a flow velocity at a target time; wherein the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and with the flow velocity at the target time;
[0278] The fluctuation threshold calculation module is used to calculate the product of the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each moment in the same window and the preset multiplier to obtain the fluctuation threshold as the first fluctuation threshold or the second fluctuation threshold, wherein the preset multiplier is positively correlated with the flow rate at the target moment.
[0279] In one possible embodiment, Intensity thresholds, including:
[0280] ;
[0281] Where △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, and th2 are all parameters, and a1<a2<a3;
[0282] The volatility threshold is calculated as follows:
[0283] ;
[0284] in, is the fluctuation threshold; is the preset magnification; It is the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each moment in the same window;
[0285] Calculated by ,include:
[0286] ;
[0287] in, is the preset ratio; v is the flow rate at the target moment; b1, b2, b3, th1, and 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 time and the residuals corresponding to each time in the same window as the residual fluctuation amount corresponding to the target time includes:
[0289] Calculate the mean of the residual corresponding to the target moment and the residual corresponding to each moment in the same window as the residual mean;
[0290] The difference between the residual corresponding to the target time and the residual mean is calculated as the residual fluctuation corresponding to the target time.
[0291] In a possible embodiment, the difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is calculated as the residual corresponding to the target time in the following manner, including:
[0292] ;
[0293] Among them, k is the target time, e k is the residual corresponding to the target moment; Y k is the observation value at the target time; H is the m×n observation matrix; X k is the predicted value at the target moment;
[0294] The residual corresponding to the target moment and the mean of the residuals corresponding to each moment in the same window are calculated as the residual mean by the following method, including:
[0295] ;
[0296] Among them, γ k is the residual mean; m is the time window of the target moment; k is the target moment; e i is the residual corresponding to the i-th moment in the time window where the target moment is located;
[0297] The difference between the residual and the residual mean corresponding to the target time is calculated as the residual fluctuation corresponding to the target time in the following way, including:
[0298] ;
[0299] in, is the residual fluctuation corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean.
[0300] The present application also provides an electronic device, such as Figure 11 Shown, including:
[0301] Memory 1101, used for storing computer programs;
[0302] The processor 1102 is configured to implement the following steps when executing the program stored in the memory 1101:
[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 moment and the residual corresponding to each time in the same window as the target moment as the residual fluctuation amount corresponding to the target moment, where the time in the same window is the other time in the same time window as the target moment;
[0305] The first weight is used as the weight of the observed value at the target moment, and the second weight is used as the weight of the predicted value at the target moment. The observed value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment, wherein the first weight is positively correlated with the residual fluctuation corresponding to the target moment, and the second weight is negatively correlated with the residual fluctuation corresponding to the target moment.
[0306] The electronic device may be the electromagnetic flowmeter itself, or may be other devices electrically connected to the electromagnetic flowmeter, such as a laptop computer, a server, etc.
[0307] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 1102 , the communication interface, and the memory 1101 communicate with each other via the communication bus.
[0308] The communication bus mentioned in the electronic devices mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into address buses, data buses, control buses, etc. For ease of illustration, only a single thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0309] The communication interface is used for communication between the above electronic device and other devices.
[0310] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0311] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can 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, and discrete hardware components.
[0312] In another embodiment provided in the present application, a computer-readable storage medium is further provided, wherein 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 flow calculation methods are implemented.
[0313] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any flow calculation method in the above embodiments.
[0314] In the above embodiments, all or part of the embodiments can be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented 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 can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disk, hard disk, tape), optical media (e.g., DVD), or solid-state drive (SSD).
[0315] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0316] Each embodiment in this specification is described in a related manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the embodiments of the apparatus, electronic device, computer-readable storage medium, and computer program product containing instructions are generally similar to the method embodiments, so their description is relatively simple. For relevant portions, reference can be made to the description of the method embodiments.
[0317] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.
Claims
1. A flow calculation method, characterized in that: The method comprises: Calculating 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; Calculate the degree of dispersion between the residual corresponding to the target moment and the residual corresponding to each same-window moment as the residual fluctuation corresponding to the target moment, wherein the same-window moment is other moments in the same time window as the target moment; Taking a first weight as the weight of the observed value at the target moment and a second weight as the weight of the predicted value at the target moment, performing a weighted sum of the observed value and the predicted value at the target moment to obtain a 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; Calculating an intensity threshold as a first intensity threshold based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time; wherein the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time; The first weight is used as the weight of the observed value at the target moment, the second weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment, including: If the residual fluctuation corresponding to the target time is greater than the first intensity threshold, the observed value and the predicted value at the target time are weighted and summed 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 to obtain a calculated value at the target time; wherein the third weight is greater than the fourth weight; and the first intensity threshold is calculated based on the flow velocity at the target time; If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the fifth weight is used as the weight of the observed value of the target moment, and the sixth weight is used as the weight of the predicted value of the target moment, and the observed value and the predicted value of the target moment are weighted and summed to obtain the calculated value of the target moment; 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.
2. The method according to claim 1, characterized in that If the residual fluctuation amount corresponding to the target moment is not greater than the first strength threshold, taking the fifth weight as the weight of the observed value at the target moment and taking the sixth weight as the weight of the predicted value at the target moment, performing a weighted sum of the observed value and the predicted value at the target moment, including: If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and is not greater than the first fluctuation amount threshold, the observed value and the predicted value at the target moment are weighted and summed 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; the first fluctuation amount threshold is obtained based on the statistics of the residual fluctuation amounts corresponding to each of the moments in the same window; If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold and greater than the first fluctuation threshold, the third weight is used as the weight of the observation value of the target moment, and the fourth weight is used as the weight of the predicted value of the target moment, and the observation value and the predicted value of the target moment are weighted and summed.
3. The method according to claim 1, characterized in that The first weight is used as the weight of the observed value at the target moment, the second weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment, including: If the residual fluctuation corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, the observed value and the predicted value at the target moment are weighted and summed using 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 to obtain a calculated value at the target moment; wherein the residual mean is the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window; the seventh weight is greater than the eighth weight; and the second intensity threshold is calculated based on the flow velocity at the target moment; If the residual fluctuation 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, the ninth weight is used as the weight of the observed value of the target moment, and the tenth weight is used as the weight of the predicted value of the target moment, and the observed value and the predicted value of the target moment are weighted and summed to obtain the calculated value of the target moment; 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.
4. The method according to claim 3, characterized in that If the residual fluctuation amount corresponding to the target moment is not greater than the second strength threshold and the residual mean is not greater than the second strength threshold, taking the ninth weight as the weight of the observed value at the target moment and taking the tenth weight as the weight of the predicted value at the target moment, performing a weighted summation on the observed value and the predicted value at the target moment, including: 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 is not greater than the second intensity threshold and the residual mean is not greater than the second fluctuation amount threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and a weighted sum is performed on the observed value and the predicted value at the target moment; the second fluctuation amount threshold is obtained based on the residual fluctuation amount statistics corresponding to each of the moments in the same window; If the residual fluctuation corresponding to the target moment is not greater than the second intensity threshold and the residual fluctuation corresponding to the target moment is greater than the second fluctuation threshold, or the residual mean is not greater than the second intensity threshold and the residual mean is greater than the second fluctuation threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment are weighted and summed.
5. The method according to claim 2, characterized in that The method further comprises: Calculating an intensity threshold as the first intensity threshold based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time; wherein the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time; Calculate the product of the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each moment in the same window and the preset multiplier to obtain a fluctuation threshold as the first fluctuation threshold, wherein the preset multiplier is positively correlated with the flow rate at the target moment.
6. The method according to claim 4, characterized in that The method further comprises: Calculating an intensity threshold as the second intensity threshold based on the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time; wherein the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and the flow velocity at the target time; Calculate the product of the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each moment in the same window and the preset multiplier to obtain a fluctuation threshold as the second fluctuation threshold, wherein the preset multiplier is positively correlated with the flow rate at the target moment.
7. The method according to claim 5 or 6, characterized in that The intensity threshold is calculated by: ; 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, and th2 are all parameters, and a1<a2<a3; The fluctuation threshold is calculated as follows: ; in, is the fluctuation threshold; is the preset magnification; The maximum value of the residual fluctuation corresponding to the target time and the residual fluctuation corresponding to each of the same window time; The preset magnification is calculated by the following method, including: ; in, is the preset ratio; v is the flow rate at the target moment; b1, b2, b3, th1, th2 are all parameters, and b1<b2<b3.
8. The method according to claim 1, characterized in that The calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual fluctuation amount corresponding to the target moment includes: Calculate the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual mean; The difference between the residual corresponding to the target time and the residual mean is calculated as the residual fluctuation amount corresponding to the target time.
9. The method according to claim 8, characterized in that The difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is calculated as the residual corresponding to the target time in the following manner, including: ; Wherein, k is the target time, e k is the residual corresponding to the target moment; Y k is the observation value at the target moment; H is the m×n observation matrix; X k is the predicted value at the target moment; The residual corresponding to the target moment and the mean of the residuals corresponding to the respective moments in the same window are calculated as the residual mean in the following manner, including: ; Among them, γ k is the residual mean; m is the time window of the target moment; k is the target moment; e i is the residual corresponding to the i-th moment in the time window where the target moment is located; Calculating the difference between the residual corresponding to the target moment and the residual mean as the residual fluctuation amount corresponding to the target moment in the following manner includes: ; in, is the residual fluctuation corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean.
10. A flow calculation device, characterized in that: The device comprises: A residual calculation module, used to 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; a residual fluctuation calculation module, configured to calculate the degree of dispersion between the residual corresponding to the target moment and the residual corresponding to each same-window moment, as the residual fluctuation corresponding to the target moment, wherein the same-window moment is another moment in the same time window as the target moment; a calculated value obtaining module, configured to perform a weighted summation of the observed value and the predicted value at the target moment, using a first weight as the weight of the observed value at the target moment and a second weight as the weight of the predicted value at the target moment, to obtain a 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; a first intensity threshold calculation module, configured to calculate an intensity threshold as a first intensity threshold based on a pipe cross-sectional area of the electromagnetic flowmeter and a flow velocity at the target time; wherein the calculated intensity threshold is positively correlated with the pipe cross-sectional area of the electromagnetic flowmeter and with the flow velocity at the target time; The first weight is used as the weight of the observed value at the target moment, the second weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment, including: If the residual fluctuation corresponding to the target time is greater than the first intensity threshold, the observed value and the predicted value at the target time are weighted and summed 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 to obtain a calculated value at the target time; wherein the third weight is greater than the fourth weight; and the first intensity threshold is calculated based on the flow velocity at the target time; If the residual fluctuation corresponding to the target moment is not greater than the first intensity threshold, the fifth weight is used as the weight of the observed value of the target moment, and the sixth weight is used as the weight of the predicted value of the target moment, and the observed value and the predicted value of the target moment are weighted and summed to obtain the calculated value of the target moment; 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.
11. The device according to claim 10, characterized in that If the residual fluctuation amount corresponding to the target moment is not greater than the first strength threshold, taking the fifth weight as the weight of the observed value at the target moment and taking the sixth weight as the weight of the predicted value at the target moment, performing a weighted sum of the observed value and the predicted value at the target moment, including: If the residual fluctuation amount corresponding to the target moment is not greater than the first intensity threshold and is not greater than the first fluctuation amount threshold, the observed value and the predicted value at the target moment are weighted and summed 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; the first fluctuation amount threshold is obtained based on the statistics of the residual fluctuation amounts corresponding to each of the moments in the same window; 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, performing a weighted sum of the observed value and the predicted value at the target moment 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; The first weight is used as the weight of the observed value at the target moment, the second weight is used as the weight of the predicted value at the target moment, and the observed value and the predicted value at the target moment are weighted and summed to obtain the calculated value at the target moment, including: If the residual fluctuation corresponding to the target moment is greater than the second intensity threshold or the residual mean is greater than the second intensity threshold, the observed value and the predicted value at the target moment are weighted and summed using 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 to obtain a calculated value at the target moment; wherein the residual mean is the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window; the seventh weight is greater than the eighth weight; and the second intensity threshold is calculated based on the flow velocity at the target moment; If the residual fluctuation corresponding to the target moment is not greater than the second strength threshold and the residual mean is not greater than the second strength threshold, then using 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, performing a weighted sum of the observed value and the predicted value at the target moment to obtain a calculated value for the target moment; 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; If the residual fluctuation amount corresponding to the target moment is not greater than the second strength threshold and the residual mean is not greater than the second strength threshold, taking the ninth weight as the weight of the observed value at the target moment and taking the tenth weight as the weight of the predicted value at the target moment, performing a weighted summation on the observed value and the predicted value at the target moment, including: 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 is not greater than the second intensity threshold and the residual mean is not greater than the second fluctuation amount threshold, then the ninth weight is used as the weight of the observed value at the target moment, and the tenth weight is used as the weight of the predicted value at the target moment, and a weighted sum is performed on the observed value and the predicted value at the target moment; the second fluctuation amount threshold is obtained based on the residual fluctuation amount statistics corresponding to each of the moments in the same window; 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 greater than the second fluctuation amount threshold, or if the residual mean is not greater than the second intensity threshold and the residual mean is greater than the second fluctuation amount threshold, then using 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, weighted summing the observed value and the predicted value at the target moment is performed; The device further comprises: 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 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 the flow velocity at the target time; a fluctuation threshold calculation module, configured to calculate the product of the maximum value of the residual fluctuation corresponding to the target moment and the residual fluctuation corresponding to each of the moments in the same window and a preset multiplier, to obtain a fluctuation threshold value as the first fluctuation threshold value or the second fluctuation threshold value, wherein the preset multiplier is positively correlated with the flow velocity at the target moment; The intensity threshold is calculated by: ; 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, and th2 are all parameters, and a1<a2<a3; The fluctuation threshold is calculated as follows: ; in, is the fluctuation threshold; is the preset magnification; The maximum value of the residual fluctuation corresponding to the target time and the residual fluctuation corresponding to each of the same window time; The calculation is done by ,include: ; in, is the preset magnification; v is the flow rate at the target moment; b1, b2, b3, th1, th2 are all parameters, and b1<b2<b3; The calculating the degree of dispersion between the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual fluctuation amount corresponding to the target moment includes: Calculate the mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window as the residual mean; Calculate the difference between the residual corresponding to the target time and the residual mean as the residual fluctuation corresponding to the target time; The difference between the observed value and the predicted value of the electromagnetic flowmeter at the target time is calculated as the residual corresponding to the target time in the following manner, including: ; Wherein, k is the target time, e k is the residual corresponding to the target moment; Y k is the observation value at the target moment; H is the m×n observation matrix; X k is the predicted value at the target moment; The mean of the residual corresponding to the target moment and the residuals corresponding to each moment in the same window is calculated as the residual mean by the following method, including: ; Among them, γ k is the residual mean; m is the time window of the target moment; k is the target moment; e i is the residual corresponding to the i-th moment in the time window where the target moment is located; Calculating the difference between the residual corresponding to the target moment and the residual mean as the residual fluctuation amount corresponding to the target moment in the following manner includes: ; in, is the residual fluctuation corresponding to the target moment; e k is the residual corresponding to the target moment; γ k is the residual mean.
12. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the method according to any one of claims 1 to 9 when executing a program stored in a 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 a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Cited By
Electromagnetic flowmeter online calibration method and system and electromagnetic flowmeter
CN121558157A