A method for measuring water flow velocity

Through Doppler effect and support vector regression algorithm, a compensation model of frequency shift-flow velocity-temperature is established, which solves the problems of low accuracy and poor real-time performance in traditional water level measurement methods, and realizes high-precision measurement and real-time compensation of water flow velocity.

CN118671376BActive Publication Date: 2024-11-22HANGZHOU HONGHU ELECTRONIC TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411162740.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-11-22
Estimated Expiration
2044-08-23

AI Technical Summary

Technical Problem

Traditional water level measurement methods have problems such as low measurement accuracy, poor real-time performance and high labor costs. Especially in the measurement of water flow velocity, ultrasonic propagation is greatly affected by temperature and environmental factors, resulting in measurement errors.

Method used

The Doppler effect is used to measure the flow rate of the water flow. By collecting Doppler ultrasonic signals and ambient temperature, a nonlinear compensation model of frequency shift-flow rate-temperature is established using fast Fourier transform and support vector regression algorithm to eliminate the temperature influence and improve the measurement. Accuracy.

Benefits of technology

High-precision measurement of water flow rate is achieved, reducing the impact of temperature and environmental factors on the measurement results, and improving the real-time and reliability of measurements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118671376B_ABST
    Figure CN118671376B_ABST
Patent Text Reader

Abstract

The present application discloses a method for measuring water flow velocity, which relates to the field of ultrasonic measurement technology, including: collecting Doppler ultrasonic signals and ambient temperature; sampling the collected Doppler ultrasonic signals, and performing fast Fourier transform on the sampled data to obtain a spectrum; calculating the frequency shift deviation in the spectrum, and calculating the flow velocity of the water flow according to the frequency shift deviation; obtaining a data set of standard fluids with known flow velocity under different environmental parameters; the data set includes frequency shift deviation, flow velocity and temperature; according to the data set, using a support vector regression algorithm, training a frequency shift-flow velocity-temperature multivariate regression compensation model; using the calculated flow velocity and the collected ambient temperature as input, and obtaining the flow velocity value after ambient temperature compensation through the trained multivariate regression compensation model as the final water flow velocity output. In view of the low water flow velocity measurement accuracy in the prior art, the present application eliminates the temperature influence by compensating the temperature to improve the flow velocity measurement accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of ultrasonic measurement technology, and in particular to a method for measuring water flow velocity. Background Art

[0002] With the rapid development of social economy and the continuous improvement of water resources management requirements, accurate measurement of water level information plays an increasingly important role in flood prevention and early warning, reservoir scheduling, agricultural irrigation, shipping management and other fields. Traditional water level measurement methods mainly include manual observation method, buoy method, pressure water level gauge method, etc., which have defects such as low measurement accuracy, poor real-time performance and high labor cost, and are difficult to meet the needs of modern water conservancy projects for high-precision, automation and informationization of water level measurement.

[0003] In recent years, new non-contact water level measurement technologies such as sonar and radar have been developed and applied to a certain extent. Among them, ultrasonic ranging has attracted widespread attention due to its advantages such as easy installation, wide measurement range, and easy automation. However, the propagation speed of ultrasonic waves in the air will change with the change of ambient temperature, resulting in temperature drift errors in the ranging results. At the same time, the propagation of ultrasonic waves in the air is easily affected by environmental factors such as wind, fog, and rain, which will also introduce additional measurement errors. Summary of the invention

[0004] In view of the problem of low water flow velocity measurement accuracy in the prior art, the present application provides a method for measuring water flow velocity, which measures water flow velocity through the Doppler effect, eliminates temperature influence by training a compensation temperature model with a large amount of standard data, and improves measurement accuracy.

[0005] Technical solution, the purpose of this application is achieved through the following technical solution.

[0006] The present application provides a method for measuring the flow velocity of water flow, including: collecting Doppler ultrasonic signals and ambient temperature. A pair of ultrasonic transducers are used as transmitting and receiving probes, and ultrasonic waves are driven to be transmitted through a DDS circuit, and echo signals are received and amplified, filtered, mixed, etc., to obtain an intermediate frequency Doppler frequency shift signal. At the same time, ambient temperature information is collected. The collected Doppler frequency shift signal is sampled, and then the time domain signal is converted into a frequency domain signal using a fast Fourier transform (FFT) to obtain a Doppler spectrum diagram. The frequency shift information can be analyzed from the spectrum diagram. The frequency component with the largest amplitude is extracted from the spectrum diagram, and its offset relative to the transmitting frequency, that is, the Doppler frequency shift, is calculated. According to the Doppler frequency shift formula, a preliminary estimate of the flow velocity of the water flow is calculated using parameters such as the frequency shift, the sound velocity, and the transmitting frequency. A series of Doppler frequency shift data of standard fluids with known flow velocities at different temperatures are collected in advance to construct a data set containing frequency shift, flow velocity, and temperature. This data set is used for subsequent training of a mapping compensation model of frequency shift-flow velocity-temperature. The support vector regression (SVR) algorithm is used to train the data set obtained in the previous step to establish a nonlinear multivariate regression compensation model between frequency shift bias, ambient temperature and standard flow velocity. SVR can fit complex nonlinear relationships well. The estimated water flow velocity and the actual ambient temperature collected are input into the trained SVR compensation model to obtain the final flow velocity measurement value after ambient temperature compensation correction. This application uses the frequency shift effect of Doppler ultrasound to measure water flow velocity, and establishes a nonlinear compensation model from frequency shift-temperature to flow velocity through the SVR machine learning algorithm, which effectively solves the impact of ambient temperature changes on measurement accuracy.

[0007] Furthermore, in step S1, collecting Doppler ultrasonic signals includes: selecting a pair of ultrasonic transducers with a center frequency of 1 MHz as a transmitting probe and a receiving probe. The transmitting probe is used to transmit ultrasonic waves, and the receiving probe is used to receive ultrasonic echo signals. A direct digital synthesis (DDS) circuit is used to generate two sine wave signals: 1 MHz and 990 kHz. The 1 MHz signal is amplified by power to drive the transmitting probe to transmit ultrasonic waves, and the 990 kHz signal is used as a reference signal for the mixing circuit.

[0008] When ultrasonic waves propagate in flowing water, the frequency of the echo signal will shift due to the Doppler effect. The magnitude of this frequency shift is proportional to the water velocity. Specifically: Principle of Doppler frequency shift effect: When ultrasonic waves propagate at a frequency of f in water with a velocity of v, the frequency of the echo signal will shift due to the movement of the water. The shifted frequency The relationship between the original frequency f satisfies the Doppler frequency shift formula: , where Δf is the Doppler frequency shift and c is the propagation speed of ultrasound in still water. The receiving probe receives the frequency shift signal: Due to the Doppler frequency shift effect, the frequency of the echo signal deviates from the transmitting frequency f and becomes The receiving probe receives the frequency-shifted echo signal and converts it into an electrical signal for transmission to the ultrasonic receiving circuit for processing. Amplification and filtering of the ultrasonic receiving circuit: The receiving circuit first uses a multi-stage amplifier to amplify the echo signal to increase the signal amplitude and signal-to-noise ratio. The amplifier generally uses a low-noise, high-gain operational amplifier. Multi-stage amplification can provide sufficiently high gain while ensuring linearity.

[0009] The amplified signal may contain high-frequency noise and interference components, which need to be filtered out with a bandpass filter. The bandpass filter only allows signals within a specific frequency range to pass through, filtering out low-frequency and high-frequency interference. The filter generally adopts an active capacitor-resistor structure, and achieves the required passband frequency and stopband attenuation by reasonably setting the resistance and capacitance values. In the ultrasonic water flow rate measurement system, the mixing circuit is an important signal processing link. Its main purpose is to convert the received high-frequency Doppler frequency shift signal into an intermediate frequency signal that is easy to process. Specifically, the mixing circuit receives two input signals: one is the echo signal amplified and filtered by the ultrasonic receiving circuit, and its frequency is ; The other is the 990kHz reference sine signal generated by the DDS circuit, and its frequency is .

[0010] The mixer circuit uses the nonlinear product relationship of two input signals to generate a mixing signal containing the sum frequency and the difference frequency. Assume that the echo signal is: , the reference signal is: , then the mixing output signal is: ; According to the trigonometric function formula, the above formula can be expanded as: ; where frequency The corresponding sum frequency component, Corresponding to the difference frequency component.

[0011] In the output signal of the mixer circuit, the difference frequency component This is the intermediate frequency Doppler shift signal we want to extract. Assume that the transmitting frequency f=1MHz and the reference frequency , then the intermediate frequency signal frequency is: , where Δf is the Doppler frequency shift, reflecting the magnitude of the water flow velocity. In order to filter out the high-frequency and high-frequency components generated during the mixing process and other spurious components, a low-pass filter needs to be connected in series at the end of the mixer circuit. The cutoff frequency of the filter should be slightly higher than the frequency shift The maximum possible value is set to avoid filtering out useful signals. After being processed by the mixer circuit and low-pass filter, the final output signal has a center frequency of about 10kHz and a frequency offset of The intermediate frequency Doppler shift signal. The signal has a low frequency and is easy to amplify, convert to AD and process digital signals, which greatly reduces the difficulty of system implementation.

[0012] Furthermore, in step S2, the collected intermediate frequency Doppler shift signal is sampled and spectrum analyzed, including: using an analog-to-digital converter (ADC) to convert the analog intermediate frequency Doppler shift signal output by the mixing circuit into a digital signal for subsequent digital signal processing. The selection of ADC needs to consider parameters such as sampling rate and quantization bit number: the sampling rate should satisfy the Nyquist sampling theorem, that is, the sampling frequency should be at least twice the highest frequency of the signal to avoid spectrum aliasing. The higher the number of quantization bits, the lower the quantization noise and the larger the dynamic range of the signal. Generally, a 12-bit or 16-bit ADC can meet the requirements. The ADC outputs a discrete digital sequence, which represents the amplitude value of the intermediate frequency Doppler shift signal at different times.

[0013] Fast Fourier Transform (FFT) is an efficient signal processing algorithm that can convert time domain signals into frequency domain signals and generate spectrum diagrams. Specifically, the basic principle of FFT: FFT is a fast algorithm of Discrete Fourier Transform (DFT). The definition of DFT is: ;in is the time domain sampling point, is the frequency domain sampling point, N is the number of sampling points, and j is the imaginary unit. Direct calculation of DFT requires The number of complex multiplication and addition operations is very large. FFT decomposes DFT into several sub-DFTs through the divide-and-conquer concept, and uses the periodicity and symmetry of DFT to reduce the computational complexity to the calculation steps of FFT: Taking the radix-2 time-selected FFT as an example, the calculation steps are as follows: Divide the N time domain sampling points into two groups according to the odd and even positions, and perform N / 2-point FFT operations on each group. The two groups of N / 2-point FFT results are combined into an N-point FFT result through butterfly operation. The butterfly operation introduces the rotation factor , used to adjust the phase. Recursively execute the N / 2-point FFT until only 2-point FFT is left, which can be directly calculated. Rearrange the output sequence according to the specified bit order to obtain the final N-point FFT result. The frequency resolution of FFT: The N frequency domain sampling points output by FFT have corresponding frequencies ,in is the sampling rate. The interval between adjacent frequency points is , which is the frequency resolution of FFT. Sampling rate The choice of the number of sampling points N requires a trade-off. The bandwidth of the spectrum can be increased, and increasing N can improve the frequency resolution, but both will increase the amount of calculation and storage overhead.

[0014] Generation of spectrum diagram: N frequency domain sampling points of FFT output , take its amplitude , we can get the signal strength at each frequency point. is the horizontal axis, the amplitude The spectrum is plotted with y as the vertical axis. The spectrum diagram intuitively shows the energy distribution of the signal at different frequencies. The greater the energy of the frequency component, the higher the corresponding amplitude peak. The frequency offset of the Doppler shift signal It can be determined by finding the peak with the largest amplitude in the spectrum. The frequency resolution of the peak is determined by the frequency resolution of the FFT. Decide.

[0015] Furthermore, in step S3, the Doppler frequency shift is extracted according to the spectrum diagram, and the water flow velocity is calculated, including: Extraction of the frequency of the Doppler frequency shift signal: According to the spectrum diagram generated in step S2, the frequency component with the largest amplitude is searched, and its corresponding frequency value is the frequency of the Doppler frequency shift signal The search algorithm can use a simple maximum value search, or some optimization algorithms such as threshold method, interpolation method, etc. to improve the accuracy of frequency estimation. The extracted frequency It contains two parts: Doppler frequency shift and spectral resolution introduced errors ,in .frequency The accuracy directly affects the accuracy of flow velocity estimation.

[0016] Calculation of Doppler frequency shift: According to the Doppler effect theory, the Doppler frequency shift It is proportional to the frequency f of the transmitted ultrasound, proportional to the water velocity v, and related to the ultrasonic incident angle θ: Therefore, when the transmission frequency f and the frequency shift signal frequency are known, In the case of , the Doppler frequency shift Δf can be calculated by the difference between the two: , it should be noted that, and f are both intermediate frequency signal frequencies after mixing processing, and the difference between them is the actual Doppler frequency shift.

[0017] Calculation of water flow velocity: Based on the Doppler frequency shift , combined with the ultrasonic emission frequency f, propagation speed c and incident angle θ, and substituted into the Doppler frequency shift formula, the water flow velocity v can be calculated: , where the propagation speed c of ultrasound in water depends on factors such as water temperature and salinity, and can generally be obtained using empirical formulas or lookup tables; the incident angle θ is determined by the installation method of the transducer, and is usually 45° or 60° to obtain higher sensitivity. , known parameters f, c, θ are substituted into the formula to obtain the estimated value of the water flow velocity v. Step S3 realizes the conversion from frequency domain signal to water flow physical quantity through spectrum analysis and Doppler frequency shift theory, completing the last step of flow velocity measurement.

[0018] Further, in step S4, by performing Doppler ultrasonic measurement on a standard fluid with a known flow rate, the frequency shift deviation, flow rate and temperature data under different environmental parameters are obtained, and a data set is constructed, including: selecting a standard fluid with a known flow rate as the measurement object, and the selected standard fluid needs to be able to easily adjust and control its flow rate to obtain measurement data under different flow rate conditions. Common flow rate controllable devices include: a water tank, by changing the water inlet flow rate and the water outlet flow rate of the water tank, the flow rate in the water tank can be adjusted. The size of the water tank should be large enough to ensure the uniformity of the flow rate distribution. A pipeline, by changing the opening of the flow control valve at the inlet of the pipeline, the flow rate in the pipeline can be adjusted. The diameter of the pipeline should be large enough to reduce the influence of the boundary layer effect. A circulating water tank, by changing the speed of the water pump or adjusting the bypass valve, the flow rate in the circulating water tank can be controlled. The circulating water tank can achieve flow rate regulation within a large range. When selecting a flow rate controllable device, factors such as the flow rate adjustment range, accuracy, and stability should be comprehensively considered.

[0019] Calibration of flow rate: In order to ensure that the flow rate value of the standard fluid is accurate and reliable, it is necessary to use other accurate flow rate measurement methods to calibrate it. Common flow rate calibration methods are: Electromagnetic flowmeter: Using Faraday's law of electromagnetic induction, measure the induced electromotive force generated when the conductive fluid moves in the magnetic field, and then calculate the flow rate. The electromagnetic flowmeter has high measurement accuracy and is suitable for conductive liquids. Pitot tube: Using the Bernoulli equation, measure the difference between the dynamic pressure and static pressure of the fluid to calculate the flow rate of the fluid. The Pitot tube has a simple structure and high measurement accuracy, and is suitable for gas and liquid. Ultrasonic flowmeter: Use the flight time difference when ultrasonic waves propagate in the fluid to calculate the flow rate of the fluid. Ultrasonic flowmeters are non-invasive, have high measurement accuracy, and are suitable for various fluids. When selecting a flow rate calibration method, factors such as its measurement accuracy, scope of application, and ease of installation should be considered, and necessary uncertainty analysis should be performed.

[0020] Temperature control and measurement: Since temperature affects the sound velocity and viscosity of the fluid, and thus affects the results of Doppler shift velocity measurement, it is necessary to accurately control and measure the temperature of the standard fluid. Common temperature control and measurement equipment include: Constant temperature water bath: The liquid in the water bath is maintained at a set temperature by heating, cooling, and stirring. Placing the standard fluid in a constant temperature water bath can achieve precise temperature control. Temperature sensor: Use temperature sensors such as thermocouples and thermistors to directly measure the temperature of the standard fluid. The temperature sensor should have sufficiently high measurement accuracy and response speed. Infrared thermometer: An instrument that uses infrared radiation to measure the surface temperature of an object. It can measure the temperature distribution on the surface of the fluid without contact. When selecting temperature control and measurement equipment, factors such as its temperature control range, accuracy, stability, and compatibility with the fluid should be considered.

[0021] Acquisition of Doppler ultrasonic signals: Use the Doppler ultrasonic measurement system designed in step S1 to measure the standard fluid. By changing the flow rate of the water tank and adjusting the temperature of the constant temperature water bath, Doppler ultrasonic echo signals under different flow rates and temperature conditions can be obtained. For each flow rate-temperature combination, the ultrasonic signal is repeatedly collected multiple times to reduce random errors. During the acquisition process, the relative position of the ultrasonic transducer and the fluid must be constant, and the incident angle must remain unchanged. Acquisition of the spectrum: The collected Doppler ultrasonic signal is processed according to the method in step S2. The analog signal is converted into a digital signal through digital-to-analog conversion, and the time domain signal is converted into a frequency domain signal through FFT to obtain the spectrum under different flow rate-temperature conditions. The quality of the spectrum will affect the accuracy of the subsequent frequency shift deviation extraction, so it is necessary to reasonably set parameters such as the sampling rate and the number of FFT points, and perform necessary smoothing and noise reduction on the spectrum.

[0022] Calculation of frequency shift deviation: According to the method in step S3, analyze the spectrum under each velocity-temperature condition, extract the frequency component with the largest amplitude, calculate the difference between it and the transmission frequency, and obtain the Doppler frequency shift deviation. The calculation accuracy of the frequency shift deviation determines the accuracy of the velocity estimation, so it is necessary to optimize the frequency extraction algorithm, such as using interpolation, curve fitting and other methods to improve the resolution of frequency measurement. When constructing the data set of frequency shift deviation, velocity and temperature, determine the sampling points of the velocity-temperature combination: According to the application scenario and requirements of Doppler ultrasonic velocity measurement, determine the sampling range and interval of velocity and temperature. The sampling points should cover a sufficiently wide velocity range (such as 0.1m / s to 10m / s) and temperature range (such as 0°C to 40°C) to enhance the representativeness of the data set. In the velocity-temperature two-dimensional sampling space, the distribution of sampling points should be as uniform as possible, and grid sampling, random sampling and other methods can be used. The number of sampling points should be sufficient to obtain sufficient data volume to support subsequent modeling and analysis. The known velocity and temperature values ​​of each velocity-temperature sampling point are matched with the representative value of the preprocessed frequency shift offset to construct a triplet (velocity, temperature, frequency shift offset). The triplets of all sampling points are organized into a data set in a certain order (such as sorting by velocity from small to large). Each triplet represents the frequency shift offset obtained by Doppler ultrasonic measurement under a specific velocity-temperature condition.

[0023] Furthermore, in step S5, a support vector regression (SVR) algorithm is used to train a frequency shift-flow velocity-temperature multivariate regression compensation model based on the frequency shift offset-flow velocity-temperature data set constructed in step S4.

[0024] The data set constructed in step S4 is randomly divided into a training set and a test set. Usually, the training set is used to train the SVR model, and the test set is used to evaluate the performance and generalization ability of the model. The division ratio of the training set and the test set can be determined according to the amount of data and the complexity of the model. Generally, the training set accounts for 70% to 80%, and the test set accounts for 20% to 30%. The division process should try to ensure that the distribution of the training set and the test set in terms of flow velocity, temperature and other characteristics is similar to avoid overfitting. The frequency shift bias and temperature characteristics in the training set and the test set are normalized respectively, and mapped to the interval of [0, 1] or [-1, 1]. Normalization can eliminate the influence of different feature dimensions and improve the convergence speed and stability of the model. Common normalization methods include maximum and minimum value normalization, zero mean normalization, etc. The normalization process should use the same transformation for the training set and the test set to ensure the applicability of the model on the test set. An adaptive multi-kernel learning strategy is adopted, and the radial basis function (RBF) of the SVR algorithm is selected as the kernel function. The RBF kernel function is a commonly used nonlinear kernel function with good expression ability and numerical stability. The form of the RBF kernel function is , where γ is the parameter of the kernel function, which controls the width of the kernel function. The value of γ can be optimized by methods such as cross-validation.

[0025] In the support vector regression (SVR) algorithm, mapping the normalized training set from the low-dimensional feature space to the high-dimensional feature space is a key step. This mapping process is achieved through the radial basis function (RBF) kernel function. For each sample point in the training set, its feature vector consists of two components: frequency shift and temperature, which are recorded as For any two sample points in the training set and , the Gaussian distance between them is defined as: , the Gaussian distance is actually the weighted square root of the square of the difference in frequency shift and temperature, reflecting the degree of difference between the two sample points in frequency shift and temperature characteristics. The kernel function technique is a method of mapping a low-dimensional feature space to a high-dimensional feature space. By introducing the kernel function, the explicit calculation of the high-dimensional feature vector is avoided. For the RBF kernel function, the corresponding high-dimensional feature mapping is: , , where L is an implicit feature space whose dimension may be infinite. Map the low-dimensional feature vector x to a point in the high-dimensional feature space. Through the kernel function technique, the inner product of the sample point in the high-dimensional feature space can be directly calculated without explicitly calculating the high-dimensional feature vector: , this inner product value reflects the similarity between two sample points in the high-dimensional feature space. For the normalized training set, for each sample point , using the RBF kernel function to calculate its difference from all other sample points in the training set The kernel function value of , and a kernel matrix is ​​obtained. Each row of the kernel matrix corresponds to the feature vector of a sample point in the high-dimensional feature space, and each column corresponds to an implicit high-dimensional feature. Through the kernel matrix, the normalized training set is mapped from the low-dimensional feature space to the high-dimensional feature space. In the high-dimensional feature space, the nonlinear relationship between sample points may become simpler and linearly separable.

[0026] For each training sample point mapped to the high-dimensional feature space , introduce slack variables and ,in Indicates the deviation of the sample point above the interval band of the insensitive loss function. It indicates the deviation of the sample point below the interval band of the ε-insensitive loss function. The purpose of introducing the slack variable is to allow a certain degree of fitting error and improve the robustness and generalization ability of the model. The ε-insensitive loss function defines the tolerance between the predicted value and the true value. The prediction error within the ε-interval band will not be counted as a loss.

[0027] In the support vector regression (SVR) algorithm, constructing and solving the convex quadratic programming problem is a key step in training the model. Convex quadratic programming problem of SVR: Given a training set ,in is the feature vector of the i-th sample point, is the corresponding target value. The goal of SVR is to find a function , so that The difference between y and y is as small as possible, and the function As smooth as possible.

[0028] The convex quadratic programming problem of SVR is defined as:

[0029]

[0030] Among them, w is the weight vector of the decision function, b is the bias term, and C is the penalty coefficient, which controls the balance between empirical risk and regularization term. is the L2 norm of w, indicating the function The smoothness of the model; C is the regularization coefficient, which controls the complexity of the model and the tolerance to training errors; and is the slack variable introduced by the i-th sample point, representing Deviation above and below the ε-interval band; ε is the tolerance between the predicted value and the true value; It is a function that maps x to a high-dimensional feature space, usually implicit in the kernel function.

[0031] Lagrange multiplier method: In order to solve the convex quadratic programming problem of SVR, Lagrange multipliers are introduced and , and , construct the Lagrangian function: .

[0032] Solving the dual problem: According to Lagrange duality, the optimal solution to the original problem is equivalent to the optimal solution to the dual problem. The dual problem is defined as:

[0033]

[0034] in, is the sample point and The dual problem is a problem that only involves Lagrange multipliers. and The convex quadratic programming problem can be solved using efficient optimization algorithms such as the sequential minimal optimization (SMO) algorithm and the interior point method to obtain the optimal and .

[0035] Support vectors and weight coefficients:

[0036] According to the KKT (Karush-Kuhn-Tucker) condition, the optimal solution satisfies the following properties:

[0037]

[0038] For the difference between the predicted value and the true value is less than ε, the corresponding and is also 0, these sample points do not contribute to the model. or The sample points are called support vectors. They are located on the boundary of the ε-interval band or outside the interval band and play a decisive role in the model.

[0039] The weight coefficient w can be obtained by the support vector and The calculation results are:

[0040]

[0041] The final support vector regression decision function can be expressed as: , where b* is the bias term, which can be obtained through the functional boundary conditions of the support vector:

[0042] .

[0043] The SVR algorithm constructs a convex quadratic programming problem, introduces slack variables and ε-insensitive loss functions, and uses the Lagrange multiplier method to convert it into a dual problem for solution to obtain the optimal Lagrange multiplier. and The support vector is the corresponding and For non-zero training sample points, the weight coefficient w can be obtained by and The difference between , and the bias term b can be calculated by the support vector. The convex quadratic programming problem has a global optimal solution, avoiding the problem of local optimality. The introduction of slack variables and ε-insensitive loss function improves the robustness and generalization ability of the model, allowing a certain degree of fitting error. The original problem is transformed into a dual problem by the Lagrange multiplier method, avoiding the explicit calculation of the high-dimensional feature space and reducing the computational complexity. The sparsity of the support vector makes the model have good interpretability and computational efficiency, and only the support vector plays a role in the prediction of the model. The introduction of the kernel function enables the SVR algorithm to handle nonlinear problems. By selecting a suitable kernel function, it can adapt to different data distributions and task requirements. According to the obtained support vectors and weight coefficients, a nonlinear multivariate regression model between frequency shift bias, temperature and flow velocity is constructed as a multivariate regression compensation model of frequency shift-flow velocity-temperature.

[0044] Furthermore, in the support vector regression (SVR) algorithm, choosing a suitable kernel function is one of the key factors affecting the model performance. Adopting an adaptive multi-kernel learning strategy, the optimal kernel function can be automatically selected from multiple candidate kernel functions to improve the model's fitting ability and generalization performance. Constructing candidate kernel functions: Radial basis function (RBF), also known as Gaussian kernel function, is a kernel function commonly used in the SVR algorithm. The mathematical definition of RBF kernel function is: , where γ is the kernel width parameter, which controls the scale and complexity of the kernel function. In the adaptive multi-kernel learning strategy, multiple RBF kernel functions with different γ parameters are constructed as candidate kernel functions. Usually a γ value in a large range is selected, such as {0.01, 0.1, 1, 10, 100}, covering different scales and complexities.

[0045] Training sub-models: For each candidate kernel function, use the SVR algorithm to train a sub-model separately. The specific steps include: Mapping the training set data to the corresponding kernel function space. Constructing the convex quadratic programming problem of SVR, introducing slack variables and ε-insensitive loss function. Using the Lagrange multiplier method, transform the original problem into a dual problem and solve it to obtain the optimal Lagrange multiplier. and . Calculate the weight coefficient w and the bias term b to obtain the SVR sub-model. Repeat the above steps to train an SVR sub-model for each candidate kernel function to obtain multiple sub-models.

[0046] Training residual model: Based on the training set data, calculate the prediction residual of each sub-model: ,in, For training samples The corresponding real flow rate value is is the decision function learned by the ith sub-model. The prediction residual is used as the new training target, and a residual model is trained using the SVR algorithm. The residual model is used to learn the residual patterns of different sub-models and capture the deviations and errors of sub-model predictions.

[0047] Weighted combination prediction: For a new input sample x, use the trained multiple sub-models and residual model to make predictions: each sub-model gives a prediction value The residual model gives a residual prediction value The predicted value of the sub-model and the residual predicted value are weighted and combined to obtain the final predicted value: ,in, is the weight of the j-th sub-model, is the weight of the residual model. The weight can be optimized by cross-validation and other methods.

[0048] Model evaluation and selection: Use the validation set data to evaluate the performance of the adaptive multi-core SVR model and each sub-model. Common evaluation indicators include root mean square error (RMSE) and mean absolute error (MAE): , , where n is the number of samples in the validation set, is the true value of the i-th sample, is the predicted value of the model on the i-th sample. The candidate kernel function with the smallest RMSE and MAE is selected as the optimal kernel function, and the corresponding sub-model and adaptive multi-kernel SVR model are selected as the final model. The adaptive multi-kernel learning strategy constructs multiple RBF kernel functions with different kernel width parameters, trains multiple SVR sub-models and a residual model, and weightedly combines their prediction results to achieve adaptive kernel function selection and model integration. Automatically selecting the optimal kernel function avoids the tediousness and subjectivity of manual parameter adjustment. Through the integration of multiple sub-models, the fitting ability and robustness of the model are improved, and the bias and variance of a single model are reduced. The residual model is introduced to learn the residual patterns of different sub-models, capture the bias and error of sub-model predictions, and further improve the prediction accuracy. The weights are optimized using methods such as cross-validation to achieve the adaptive combination of sub-models and residual models, and improve the generalization performance of the model.

[0049] Furthermore, in the frequency shift flowmeter, there is a complex nonlinear relationship between the frequency shift offset, temperature and flow velocity. Constructing a nonlinear multivariate regression model between the frequency shift offset, temperature and flow velocity can effectively realize the multivariate regression compensation of frequency shift-flow velocity-temperature. Based on the support vector regression (SVR) algorithm, combined with kernel function mapping and convex quadratic programming problem solving, an efficient and accurate nonlinear decision function can be constructed. High-dimensional feature mapping: Map the low-dimensional feature vector composed of frequency shift offset and temperature to a high-dimensional feature space, and use the selected kernel function to calculate the inner product between sample points. Commonly used kernel functions include radial basis function (RBF), polynomial kernel function, etc. High-dimensional feature mapping can improve the expressive power of features and characterize more complex nonlinear relationships between frequency shift offset, temperature and flow velocity in high-dimensional space.

[0050] Construct a convex quadratic programming problem: Construct a convex quadratic programming problem for SVR in a high-dimensional feature space. Solve the dual problem: Use the Lagrange multiplier method to transform the original problem into a dual problem: Use optimization algorithms such as the sequential minimal optimization (SMO) algorithm and the interior point method to solve the dual problem and obtain the optimal Lagrange multiplier. and . Select support vectors: Based on the optimal Lagrange multiplier and , select the sample points whose corresponding multipliers are non-zero as support vectors. The support vectors are on the boundary of the ε-interval band or outside the interval band, and play a key role in the decision-making of the model. The number of support vectors is usually much smaller than the number of training samples, which reflects the sparsity and computational efficiency of the SVR model.

[0051] Constructing a nonlinear decision function: Using the support vectors and the corresponding weight coefficients, a nonlinear decision function between frequency shift bias, temperature and flow velocity is constructed as a multiple regression compensation model of frequency shift-flow velocity-temperature:

[0052] , where x is the characteristic vector composed of the frequency shift and temperature to be predicted, is the ith support vector, and . is the corresponding optimal Lagrange multiplier, and b is the bias term.

[0053] The weight coefficient w can be expressed by the optimal Lagrange multiplier and The difference is calculated as: , the bias term b can be solved by weighted average of the slack variables of the support vector:

[0054] ,in, is the support vector. is the number of support vectors. Model prediction: For a given frequency shift offset and temperature input x, a nonlinear decision function f(x) is used to calculate the predicted flow velocity output. The decision function maps the frequency shift offset and temperature to a high-dimensional feature space, and the predicted value of the flow velocity is obtained through a linear combination of the kernel function value of the support vector and the weight coefficient and the bias term b.

[0055] A nonlinear multivariate regression model between frequency shift, temperature and flow velocity was constructed, and the multivariate regression compensation of frequency shift-flow velocity-temperature was realized by the SVR algorithm. The kernel function was used to map low-dimensional features to high-dimensional space, which improved the expressiveness of features and characterized the complex nonlinear relationship between frequency shift, temperature and flow velocity. By constructing a convex quadratic programming problem and introducing slack variables, the robustness and generalization ability of the model were improved, allowing a certain degree of fitting error. The Lagrange multiplier method was used to transform the original problem into a dual problem, avoiding explicit calculations in high-dimensional feature space and improving computational efficiency. The nonlinear decision function was constructed based on the support vector, which reflected the sparsity and computational efficiency of the SVR model. Only the support vector played a role in the prediction of the model. The penalty coefficient C and kernel function parameters were optimized by cross-validation and other methods to improve the generalization performance and prediction accuracy of the model.

[0056] Furthermore, in the support vector regression (SVR) algorithm, by introducing Lagrange multipliers and slack variables, the original convex quadratic programming problem is transformed into a dual problem, and the support vector is selected according to the optimal Lagrange multiplier. Set slack variables and Lagrange multipliers: For each training sample point mapped to the high-dimensional feature space , introduce a pair of slack variables and , and a pair of Lagrange multipliers and . Slack variables and It is used to measure the error between the predicted value and the true value of the sample point, allowing a certain degree of fitting error to improve the robustness of the model. and is the sample point A corresponding pair of multipliers is used to transform the convex quadratic programming problem into a dual problem for solution.

[0057] Transformation into a dual problem: By introducing Lagrange multipliers, the convex quadratic programming problem of SVR is transformed into its dual problem. The dual problem transforms the weight vector w and the slack variable in the original problem into and Eliminate and use the Lagrange multiplier instead and It simplifies the solution of the optimization problem.

[0058] Solve the dual problem: Use the sequential minimal optimization (SMO) algorithm, interior point method and other optimization algorithms to solve the dual problem and obtain the optimal Lagrange multiplier and The SMO algorithm selects a pair of multipliers by heuristic The optimization is performed to decompose the multidimensional optimization problem into a series of two-dimensional sub-problems to improve the computational efficiency. The interior point method transforms the inequality constraints into equality constraints by constructing a barrier function, and searches for the optimal solution within the feasible domain, which has global convergence and stability.

[0059] Select support vectors: Based on the optimal Lagrange multiplier and The value of , selects the training sample points that meet the following conditions as support vectors: ,in, is the individual penalty coefficient of the i-th sample point, which controls the importance and influence of the sample point. The support vector is on the boundary of the ε-interval band or outside the interval band, which plays a key role in the decision of the model. The Lagrange multiplier of the non-support vector and All are 0, and do not participate in model construction and prediction. Individual penalty coefficient It can be set based on prior knowledge such as confidence level and noise level of sample points, or optimized through methods such as cross-validation.

[0060] Constructing the decision function: Using the support vector and the corresponding Lagrange multiplier, construct the nonlinear decision function of SVR: , where x is the feature vector to be predicted, is the ith support vector, and is the corresponding optimal Lagrange multiplier, and b is the bias term. Selecting support vectors based on the optimal Lagrange multiplier is one of the core steps of the SVR algorithm. By introducing slack variables and Lagrange multipliers, the original problem is transformed into a dual problem, which simplifies the solution of the optimization problem and improves the computational efficiency. Selecting support vectors based on the optimal Lagrange multiplier reflects the sparsity and computational efficiency of the SVR model. Only support vectors play a role in the decision-making of the model. The support vectors on the boundary of the ε-interval band or outside the interval band characterize the error between the predicted value and the true value of the sample point, which improves the robustness and generalization ability of the model. By setting the individual penalty coefficient, the sample point can be differentiated according to its importance and influence, which improves the adaptability and flexibility of the model. The Lagrange multiplier of the non-support vector is 0, which does not participate in the construction and prediction of the model, reducing the computational complexity and storage overhead.

[0061] Furthermore, in the support vector regression (SVR) algorithm, the original convex quadratic programming problem is transformed into its dual problem by introducing Lagrange multipliers, and the kernel function technique is used to replace the inner product operation with the kernel function operation to obtain a dual problem based on the kernel function. Select the Gaussian kernel function: According to methods such as cross-validation, compare kernel functions of different types and parameters, such as radial basis function (RBF), polynomial kernel function, etc., and select the Gaussian kernel function with the smallest root mean square error (RMSE) and mean absolute error (MAE) as the kernel function of the SVR algorithm. The Gaussian kernel function has good nonlinear mapping capabilities and numerical stability, and is suitable for complex nonlinear relationships between frequency shift bias, temperature and flow velocity. The form of the Gaussian kernel function is: , where σ is the bandwidth parameter of the kernel function, which controls the scale and smoothness of the kernel function.

[0062] Introducing the kernel function technique: Using the kernel function technique, the inner product operation in the objective function and constraint conditions of the dual problem is Replace with kernel function operation , we get the dual problem based on kernel function. The kernel function technique avoids the explicit calculation of inner products in high-dimensional feature space, simplifies the solution of optimization problems, and improves computational efficiency. The dual problem based on kernel function has the following form:

[0063] Constructing the objective function: The objective function of the dual problem consists of three parts: It represents the quadratic term that maximizes the Lagrange multiplier and the kernel function value, and describes the similarity and correlation between sample points. Represents the L1 regularization term that minimizes the Lagrange multiplier, controlling the complexity of the model and the tolerance to errors. Maximizing the weighted sum of the Lagrange multiplier and the true value of the sample point characterizes the model's fitting ability and prediction accuracy. The overall goal of the objective function is to maximize the model's fitting ability and prediction accuracy while minimizing the model's complexity and error.

[0064] Constructing constraints: The constraints of the dual problem consist of two parts: : The sum of the Lagrange multipliers α_i and α_i^ is equal to zero, ensuring that the optimal solution to the dual problem satisfies the KKT condition, , the absolute value of each Lagrange multiplier does not exceed the individual penalty coefficient of its corresponding sample point , which controls the importance and influence of the sample points. The overall goal of the constraints is to ensure that the optimal solution of the dual problem satisfies the KKT condition and to perform differentiated processing according to the importance and influence of the sample points.

[0065] Solve the dual problem: Use optimization algorithms such as the sequential minimal optimization (SMO) algorithm and the interior point method to solve the dual problem based on the kernel function and obtain the optimal Lagrange multiplier and The SMO algorithm selects a pair of multipliers by heuristic The optimization is performed to decompose the multidimensional optimization problem into a series of two-dimensional sub-problems to improve the computational efficiency. The interior point method transforms the inequality constraints into equality constraints by constructing a barrier function, and searches for the optimal solution within the feasible domain, which has global convergence and stability.

[0066] By introducing Lagrange multipliers, the convex quadratic programming problem is transformed into its dual problem, and the kernel function technique is used to replace the inner product operation with the kernel function operation, which is one of the important steps of the SVR algorithm. The kernel function technique avoids the explicit calculation of the inner product in the high-dimensional feature space, simplifies the solution of the optimization problem, and improves the computational efficiency. By introducing Lagrange multipliers, the original problem is transformed into a dual problem, and the constraints are transformed into equality and inequality constraints, which facilitates the solution of the optimization algorithm. The objective function of the dual problem characterizes the similarity between sample points, the complexity and fitting ability of the model, and balances the generalization performance and prediction accuracy of the model. The constraints ensure that the optimal solution of the dual problem meets the KKT condition, and differentiates the sample points according to their importance and influence, which improves the adaptability and flexibility of the model.

[0067] Compared with the prior art, the advantages of this application are:

[0068] Using the Doppler effect to measure water flow velocity avoids the measurement error caused by direct contact with the water surface and improves the accuracy of water level measurement. By collecting Doppler ultrasonic signals and performing sampling and fast Fourier transform, the frequency shift deviation in the spectrum can be accurately calculated, thereby obtaining a high-precision initial value of the water flow velocity.

[0069] Ambient temperature is introduced as a compensation parameter, and a frequency shift-flow velocity-temperature multivariate regression compensation model is trained based on a large number of frequency shift deviation-flow velocity-temperature data sets of known flow rate standard fluids at different temperatures. This can effectively eliminate the influence of ambient temperature on water flow velocity measurement, realize real-time online temperature compensation, and ensure the reliability of the measurement results.

[0070] An adaptive multi-kernel learning strategy is adopted, and multiple Gaussian kernel functions with different kernel width parameters are selected to train multiple support vector regression sub-models. By weighted combining the prediction results of the sub-models, a more accurate nonlinear correspondence between frequency shift bias, temperature and flow velocity can be fitted, thereby improving the generalization ability and robustness of the compensation model.

[0071] When constructing the frequency shift-flow velocity-temperature multivariate regression compensation model, by introducing slack variables and solving the dual problem of the support vector regression algorithm, the training samples that contribute most to the measurement error can be automatically determined as support vectors, which can reduce the uncertainty introduced by these samples in a targeted manner and improve the prediction accuracy of the model.

[0072] Using kernel function techniques to map input parameters such as frequency shift offset and temperature from low-dimensional feature space to high-dimensional space and constructing decision functions in high-dimensional space can effectively extract the nonlinear correlation characteristics between input parameters and enhance the adaptability of the compensation model to complex environments.

[0073] The frequency shift and temperature are used as the input of the compensation model, and the water flow velocity is used as the output. The trained model can directly predict the water flow velocity after temperature compensation. The process is simple and efficient. Substituting the flow velocity result into the water level calculation formula can obtain an accurate water level measurement value. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 is a schematic diagram of an exemplary application scenario of a method for measuring water flow velocity according to some embodiments of the present application;

[0075] Figure 2 is an exemplary flow chart of a method for measuring water flow velocity according to some embodiments of the present application;

[0076] Figure 3 is a schematic diagram of ultrasonic transmission and reception according to some embodiments of the present application;

[0077] Figure 4 is an exemplary flow chart of obtaining an initial flow rate according to some embodiments of the present application;

[0078] Figure 5 It is an exemplary flow chart of constructing a multivariate regression compensation model according to some embodiments of the present application. DETAILED DESCRIPTION

[0079] The method and system provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0080] Figure 1 is a schematic diagram of an exemplary application scenario of a method for measuring water flow velocity according to some embodiments of the present application, Figure 2This is an exemplary flow chart of a method for measuring water flow velocity shown in some embodiments of the present application, a method for measuring water flow velocity, comprising: collecting Doppler ultrasonic signals and ambient temperature; sampling the collected Doppler ultrasonic signals, and performing fast Fourier transform on the sampled data to obtain a spectrum diagram; calculating the frequency shift deviation in the spectrum diagram, and calculating the flow velocity of the water flow based on the frequency shift deviation; obtaining a data set of standard fluids with known flow velocities under different environmental parameters; the data set includes frequency shift deviation, flow velocity and temperature; according to the data set, using a support vector regression algorithm to train a frequency shift-flow velocity-temperature multivariate regression compensation model; using the calculated flow velocity and the collected ambient temperature as input, and obtaining the flow velocity value after ambient temperature compensation through the trained multivariate regression compensation model as the final water flow velocity output.

[0081] Figure 3This is a schematic diagram of ultrasonic transmission and reception according to some embodiments of the present application. A pair of ultrasonic transducers with a center frequency of 1 MHz are used as a transmitting probe and a receiving probe respectively. The two probes are fixed on the outer wall of the pipeline, relatively installed on the same diameter line of the pipeline, and at a certain angle to the axis of the pipeline. A DDS (direct digital synthesis) circuit is used to generate two sine wave signals of 1 MHz and 990 kHz. The DDS circuit directly synthesizes sine wave signals in a digital manner, and has the advantages of frequency stability and programmable control. After the 1 MHz sine wave signal generated by the DDS circuit is amplified by the power amplifier, the transmitting probe is driven to continuously transmit ultrasonic signals at a frequency of 1 MHz. The power amplifier provides sufficient driving current and voltage to ensure that the transmitting probe can generate high-quality ultrasonic waves. The 990 kHz sine wave signal generated by the DDS circuit is used as a reference signal of the mixing circuit for subsequent Doppler frequency shift signal frequency conversion processing. When the ultrasonic wave emitted by the transmitting probe passes through the fluid medium, the echo signal will undergo a Doppler frequency shift effect due to the movement of the fluid. The receiving probe receives the echo signal after the frequency shift and transmits it to the ultrasonic receiving circuit for processing. The ultrasonic receiving circuit performs multi-stage amplification and bandpass filtering on the received weak echo signal. The multi-stage amplification circuit uses a low-noise operational amplifier to amplify the echo signal to a suitable amplitude range. The bandpass filtering circuit uses an active filter to filter out low-frequency noise and high-frequency interference in the echo signal, and obtains an amplified and filtered echo signal with a center frequency of about 1MHz. The amplified and filtered echo signal is transmitted to the mixing circuit for frequency conversion. The mixing circuit mixes the echo signal with the 990kHz reference sine wave signal by an analog multiplier, and uses the trigonometric function product and difference formula to shift the frequency of the echo signal to the intermediate frequency range through nonlinear mixing to obtain a mixed signal with a center frequency of about 10kHz. The mixing process can effectively reduce the design difficulty and cost of subsequent circuits. The obtained mixed signal is filtered through a low-pass filter to filter out the high-frequency components (such as frequency components near 2MHz) generated during the mixing process, and only retain the Doppler frequency shift signal in the intermediate frequency range. The cutoff frequency of the low-pass filter can be designed to be around 20kHz to ensure the integrity of the Doppler frequency shift signal. The low-pass filtered signal is output as the collected intermediate frequency Doppler shift signal, and its frequency offset is proportional to the fluid velocity. The spectrum of the Doppler shift signal is distributed in the range of 10kHz±fd_max, where fd_max is the maximum Doppler shift, which can be estimated based on the velocity range and the transducer installation angle. The ambient temperature signal in the pipeline is collected synchronously. The temperature sensor (such as PT100 platinum resistance) is installed on the inner wall of the pipeline to measure the real-time temperature of the fluid, and the temperature signal and the Doppler shift signal are transmitted to the subsequent signal processing unit.

[0082] The collected Doppler ultrasonic signal is sampled, and the sampled data is fast Fourier transformed to obtain a spectrum diagram. The intermediate frequency Doppler frequency shift signal is subjected to digital-to-analog conversion (ADC), and the analog signal is converted into a digital signal to obtain a discrete sampling data sequence. The ADC uses a high-precision, high-speed sampling chip, such as a 16-bit, 100KSPS successive approximation ADC. According to the Nyquist sampling theorem, the sampling frequency should be at least twice the highest frequency of the Doppler frequency shift signal. A sampling frequency of about 40kHz can be selected to ensure complete reconstruction of the signal. The sampled digital signal sequence is preprocessed, including removing DC bias and adding windows. The DC bias eliminates low-frequency interference by calculating the signal mean and subtracting it; adding windows (such as Hamming windows, Hamming windows, etc.) can reduce spectrum leakage and improve spectrum resolution. The preprocessed digital signal sequence is subjected to fast Fourier transform (FFT), and the time domain signal is converted into a frequency domain signal to obtain the spectrum data of the intermediate frequency Doppler frequency shift signal. FFT is an efficient algorithm for discrete Fourier transform (DFT). It reduces the computational complexity of N-point DFT from O( ) is reduced to O ( The selection of the number of FFT transformation points N requires a balance between spectrum resolution and computational efficiency, and 1024 points, 2048 points, etc. are commonly used.

[0083] The spectrum data obtained by FFT transformation is in complex form, including real and imaginary parts. According to the complex modulus calculation formula, the spectrum amplitude value at each frequency point is calculated: ,in, is the amplitude value of the kth frequency point, and are the real and imaginary parts of the spectrum data respectively. According to the number of FFT transformation points N and sampling frequency , calculate the actual frequency value corresponding to each frequency point: ,in, is the actual frequency value corresponding to the kth frequency point, is the sampling frequency. The frequency resolution of the spectrum is , the frequency range is [0, fs / 2]. The calculated spectrum amplitude value and the corresponding frequency values The data points that make up the spectrum graph. The spectrum graph uses frequency as the horizontal axis and amplitude as the vertical axis, reflecting the energy distribution of the signal at different frequencies. The spectrum graph can be displayed in real time through the drawing function of the host computer software or embedded platform. In the spectrum graph, the spectrum peak position corresponding to the Doppler frequency shift signal represents the Doppler frequency shift amount, and the peak amplitude reflects the strength of the echo signal. Through the peak search algorithm, such as the quadratic curve fitting method, the frequency value of the Doppler frequency shift signal can be accurately extracted for subsequent flow velocity calculation.

[0084] Figure 4The exemplary flow chart of obtaining the initial flow velocity shown in some embodiments of the present application is to calculate the frequency shift deviation in the spectrum graph, and calculate the flow velocity of the water flow according to the frequency shift deviation, including: extracting the frequency value corresponding to the frequency component with the largest amplitude according to the obtained spectrum graph data as the frequency value of the Doppler frequency shift signal. The specific method is: among the data points in the spectrum graph, search for the data point with the largest amplitude value, and record its corresponding frequency value . by Take the center as the center, and perform quadratic curve fitting in its left and right neighborhoods (such as ±5 frequency points) to find the frequency value corresponding to the extreme point of the fitting curve as the accurate Doppler frequency shift signal frequency value. If there are multiple frequency components with large amplitudes in the spectrum graph, you can select the target frequency component by setting the amplitude threshold or frequency range to eliminate the influence of the interfering frequency components. Calculate the frequency value of the extracted Doppler shift signal With the ultrasonic frequency The difference between the two is used to obtain the Doppler frequency shift : ,in, is the known frequency of transmitted ultrasonic waves, usually around 1 MHz. Doppler frequency shift The positive and negative signs indicate the direction of fluid flow. A positive value indicates that the fluid flow direction is the same as the ultrasonic emission direction, and a negative value indicates that the fluid flow direction is opposite to the ultrasonic emission direction. , combined with the ultrasonic propagation speed c in water and the ultrasonic emission angle , calculate the flow velocity v of the water flow: , where c is the propagation speed of ultrasound in water, which is related to the temperature and salinity of the water and can be calculated by looking up a table or an empirical formula. The commonly used value is 1450-1500m / s; θ is the angle between the ultrasonic emission direction and the water flow direction, which is determined by the installation position and angle of the transmitting probe and the receiving probe. It is usually designed to be between 45°-60° to obtain a larger frequency shift and higher measurement sensitivity. The propagation speed c of ultrasound in water changes with the temperature and salinity of the water. In order to improve the accuracy of flow velocity measurement, c needs to be compensated according to the actual water temperature and salinity. Compensation methods include: Table lookup method: According to the measured water temperature and salinity, find the corresponding c value in the pre-established velocity-temperature-salinity lookup table. Empirical formula method: According to the water temperature and salinity, the c value is calculated using an empirical formula, such as the UNESCO formula: c = 1449.2 + 4.6T - 0.055T^2 + 0.00029T^3 + (1.34-0.01T)(S-35) + 0.016z, where T is the water temperature (°C), S is the salinity (‰), and z is the water depth (m). The calculated water flow velocity v is used as output for subsequent flow calculation and display. To reduce the impact of random errors, the velocity values ​​calculated from multiple consecutive spectrograms can be averaged or median filtered.

[0085] Obtain a data set of standard fluids with known flow rates under different environmental parameters; select standard fluids with known flow rates as the measurement object, such as glycerol aqueous solutions of different concentrations or special ultrasonic flowmeter calibration fluids. The viscosity and sound velocity characteristics of the standard fluid should be similar to those of the actual measured fluid to ensure the representativeness and applicability of the data set. Use precise flow control equipment, such as mass flow meters or weighing methods, to quantitatively transport the standard fluid under different flow rate conditions to obtain a series of standard fluid samples with known flow rates. The selection of flow rate conditions should cover the flow rate range of the measured fluid and use equal or logarithmic intervals, such as 0.1, 0.5, 1, 2, 5, 10 m / s, etc. Under each flow rate condition, use a constant temperature water bath or temperature control system to adjust the temperature of the standard fluid to obtain standard fluid samples under different temperature conditions. The selection of temperature conditions should cover the temperature range of the measured fluid and consider the effect of temperature on the sound velocity and viscosity of the fluid, such as 10°C, 20°C, 30°C, 40°C, 50°C, etc. For the standard fluid sample under each flow rate and temperature condition, an ultrasonic flowmeter is used to collect its Doppler ultrasonic signal. The installation position, angle and parameter setting of the ultrasonic flowmeter should be consistent with the actual application to ensure data consistency. The collected Doppler ultrasonic signal is sampled and fast Fourier transformed to obtain a spectrum under different flow rates and temperature conditions. The frequency range, resolution and amplitude scale of the spectrum should be set uniformly to facilitate subsequent data processing and comparison. For the obtained spectrum, the frequency shift deviation is calculated to obtain the frequency shift deviation data under different flow rates and temperature conditions. The calculation of the frequency shift deviation should take into account factors such as ultrasonic emission frequency, emission angle and sound velocity compensation to improve the accuracy of the data. The known flow rate value, temperature value and the corresponding calculated frequency shift deviation value of the standard fluid are matched to construct a data set in the form of a triple, such as ,in is the flow rate value of the i-th sample, is the temperature value, is the frequency shift bias value. The constructed data set is preprocessed, including outlier removal, data normalization and other operations. Outliers may be introduced by factors such as measurement errors and signal interference, and need to be identified and eliminated through statistical methods or expert knowledge. Data normalization can unify data of different dimensions to the same scale, such as within the range of 0-1, to improve the effect of subsequent modeling. The preprocessed data set is randomly divided into training set, validation set and test set, generally in a ratio of 7:2:1 or 8:1:1. The training set is used to train the parameters of the compensation model, the validation set is used to select and tune the model hyperparameters, and the test set is used to evaluate the generalization performance of the model.

[0086] Figure 5This is an exemplary flow chart for constructing a multivariate regression compensation model according to some embodiments of the present application. In order to train an accurate frequency shift-flow rate-temperature multivariate regression compensation model, it is first necessary to preprocess the acquired frequency shift bias, flow rate and temperature data sets. The data set is randomly divided into a training set and a test set, generally divided in a ratio of 8:2 or 7:3. The training set is used to train the parameters of the compensation model, and the test set is used to evaluate the performance of the trained model. In order to eliminate the influence of the differences in the dimensions and numerical ranges of different characteristic parameters, the frequency shift bias and temperature in the training set and the test set need to be normalized respectively. Commonly used normalization methods include maximum and minimum value normalization and z-score normalization. Maximum and minimum value normalization achieves normalization by linearly scaling the eigenvalues ​​to the [0, 1] interval; z-score normalization achieves normalization by subtracting the mean from the eigenvalue and dividing it by the standard deviation, so that the normalized eigenvalues ​​obey the standard normal distribution. Normalization can accelerate the training convergence of the model and improve the training stability.

[0087] The normalized frequency shift and temperature features are input into the Gaussian kernel function. By calculating the Gaussian distance between the feature vectors, the kernel function technique is used to map the frequency shift and temperature from the original two-dimensional feature space to the high-dimensional space. In the high-dimensional feature space, the complex nonlinear relationship between frequency shift, temperature and flow velocity can be effectively expanded and characterized. The inner product of any two sample points in the high-dimensional space can be equivalently replaced by the kernel function value, avoiding the complexity of directly calculating the high-dimensional coordinates. Suppose the original sample point is ,in is the frequency shift offset, is the temperature, is the corresponding velocity label value. The high-dimensional feature space coordinate after mapping is Through kernel function mapping, the training sample set Transformed into a sample set in a high-dimensional feature space ,The training process of the support vector regression algorithm is carried out on this high dimensional sample set.

[0088] When using an adaptive multi-kernel learning strategy to select the kernel function of the support vector regression algorithm, it is first necessary to construct multiple Gaussian kernel functions with different kernel width parameters σ as candidate kernel functions. The value of σ is usually determined based on experience or cross-validation experiments, and multiple discrete σ values ​​within a larger range can be selected, such as σ∈{0.1, 0.5, 1, 2, 5, 10}. Different σ values ​​correspond to different Gaussian kernel action ranges, which can capture the correlation patterns of frequency shift bias, temperature, and flow velocity at different scales. For each candidate Gaussian kernel function, an independent support vector regression sub-model is trained. The support vector regression algorithm introduces an ε-insensitive loss function and a regularization term to find an optimal decision function in the feature space. , so that The difference between the actual label value y of the training sample does not exceed ε. At the same time, by introducing slack variables, the fitting error of some sample points is allowed to exceed ε to improve the generalization performance of the model. Multiple support vector regression sub-models are trained in parallel, and each sub-model corresponds to a candidate kernel function.

[0089] After obtaining multiple trained sub-models, the prediction residual of each sub-model is calculated based on the training set data. For the i-th sub-model, its prediction residual is Defined as: ,in, For training samples The corresponding real flow rate value is is the decision function learned by the ith sub-model. The prediction residuals of all sub-models form a new training set , using the residual set as the training target, train a residual support vector regression model. The residual model is used to learn the residual patterns of different sub-models, which can capture the regularity of the sub-model prediction errors and further improve the fitting ability of the overall compensation model. The training process of the residual support vector regression model is similar to that of the ordinary support vector regression, using ε-insensitive loss function and kernel function mapping. After obtaining all sub-models and residual models, the final prediction result of the adaptive multi-kernel support vector regression model is obtained by weighted combination. : ,in, is the decision function of the ith sub-model, is the combined weight of the i-th sub-model; is the decision function of the residual model, is the combined weight of the residual model. The combined weight can be optimized by minimizing the prediction error on the validation set.

[0090] In order to evaluate and select the optimal Gaussian kernel function, the validation set data is used to calculate the root mean square error (RMSE) and mean absolute error (MAE) of the adaptive multi-kernel support vector regression model and each sub-model on the validation set. RMSE and MAE are commonly used performance evaluation indicators for regression models. RMSE emphasizes the penalty for large errors, while MAE gives equal weight to the error size. Finally, the Gaussian kernel function with the smallest RMSE and MAE on the validation set is selected as the optimal kernel function of the support vector regression algorithm. Through the adaptive multi-kernel learning strategy, the optimal kernel function can be automatically selected from multiple candidate kernel functions, the fitting performance of the support vector regression algorithm can be improved, and the compensation model's ability to characterize the complex frequency shift-flow velocity-temperature relationship can be enhanced, which is conducive to further improving the accuracy of water level measurement.

[0091] When the normalized training set is input into the radial basis function for kernel function mapping, for each training sample point , by calculating it and other sample points The Gaussian distance between them is used to convert the original frequency shift offset and temperature features into the inner product form in the high-dimensional feature space. The calculation formula of Gaussian distance is: , where φ represents the radial basis function mapping and K represents the Gaussian kernel function. Through the kernel function technique, the inner product of two sample points in the high-dimensional feature space can be directly calculated without explicitly calculating the high-dimensional coordinates. The Gaussian distance between sample points reflects the similarity of the frequency shift deviation and temperature in the high-dimensional space. The smaller the distance, the closer the frequency shift deviation and temperature combination of the two sample points are, and the more likely the corresponding flow velocity values ​​are to be similar.

[0092] For each training sample point after mapping to the high-dimensional feature space ,in represents the feature vector in the high-dimensional feature space, Represents the corresponding flow rate label value, introducing a slack variable and To measure the degree of deviation of sample points outside the interval band of the ε-insensitive loss function. The ε-insensitive loss function is defined as: ,in, is the decision function learned by the support vector regression algorithm. The loss function is 0 in the interval band of [-ε, +ε], and the loss outside the interval band is proportional to the distance from the interval band.

[0093] For sample points outside the interval band, a relaxation variable is introduced and To measure the degree of deviation from the interval zone:

[0094]

[0095] Indicates the actual flow rate value of the sample point Above the decision function ε - the upper limit of the interval band, that is, the deviation of the sample point above the interval band; Indicates the actual flow rate value of the sample point Below the decision function ε is the lower bound of the interval band, that is, the deviation of the sample point below the interval band.

[0096] By introducing slack variables, the support vector regression algorithm allows the fitting error of some sample points to exceed ε while minimizing the empirical risk, thereby increasing the fault tolerance and generalization performance of the model. The size of the slack variable reflects the severity of the sample point's deviation from the ε-interval band. During the training process, by penalizing the size of the slack variable, the sensitivity of the model to noise sample points and outliers can be controlled, thereby improving the robustness of the model.

[0097] When training the support vector regression model, the objective function consists of two parts: empirical risk and regularization term. The optimal decision function coefficient and slack variable are solved by minimizing the objective function. The support vector regression optimization problem after introducing slack variables can be expressed as: , where w is the weight vector of the decision function, b is the bias term, and C is the penalty coefficient, which controls the balance between the empirical risk and the regularization term. When the training set data mapped to the high-dimensional feature space is input into the support vector regression algorithm, the convex quadratic programming problem of the support vector regression algorithm needs to be constructed first. For each training sample point , introduce slack variables and and the Lagrange multiplier and The slack variable is used to measure the degree of deviation of the sample point outside the interval band of the ε-insensitive loss function, and the Lagrange multiplier is used to transform the convex quadratic programming problem into a dual problem for solution.

[0098] In order to solve the convex quadratic programming problem, the Lagrange multiplier is introduced. and , transform it into a dual problem. Let the Lagrangian function be: Lagrangian multiplier method: In order to solve the convex quadratic programming problem of SVR, the Lagrangian multiplier is introduced and , and , construct the Lagrangian function: According to Lagrange duality, the dual problem of the original problem is: , the Lagrangian function L is applied to w, b, , Find the partial derivative and set it to 0, and we get: Solving the dual problem: According to Lagrange duality, the optimal solution to the original problem is equivalent to the optimal solution to the dual problem. The dual problem is defined as: ,in, is the sample point and The dual problem is a problem that only involves Lagrange multipliers. and The convex quadratic programming problem can be solved using efficient optimization algorithms such as the sequential minimal optimization (SMO) algorithm and the interior point method to obtain the optimal and .

[0099] By solving the above dual problem, we can obtain the optimal Lagrange multiplier and . According to the optimal value of the multiplier, choose or The training sample points are used as support vectors. These support vectors correspond to the slack variables in the original problem. or Sample points that are not 0 are sample points outside the interval band of the ε-insensitive loss function. The final support vector regression decision function can be expressed as: , where b is the bias term, which can be obtained through the functional boundary conditions of the support vector: , the weight coefficient w can be obtained by the optimal Lagrange multiplier and The difference is calculated as: , the bias term b can be solved by weighted average of the slack variables of the support vector: ,in, is the support vector. is the number of support vectors. Substituting the bias term b into the nonlinear decision function, we get the multivariate regression compensation model of frequency shift-flow velocity-temperature: , where v represents the compensated flow rate output; represents the frequency shift and temperature corresponding to the i-th support vector; is the selected Gaussian kernel function.

[0100] In the online measurement process of the ultrasonic flow meter, the calculated instantaneous frequency shift deviation fd and the collected ambient temperature T are used as the input of the decision function and substituted into the trained multivariate regression compensation model to obtain the flow rate value after ambient temperature compensation. : , As the final water velocity output of the ultrasonic flowmeter, the frequency shift offset and ambient temperature are used to compensate the velocity measurement results online, which improves the measurement accuracy and adaptability of the flowmeter. The nonlinear decision function constructed by the support vector regression algorithm can effectively fit the complex nonlinear relationship between frequency shift offset, temperature and flow velocity, overcome the limitations of traditional linear compensation methods, and provide a new solution for optimizing the measurement performance of ultrasonic flowmeters.

[0101] Specifically, a river has a set of training sample data of frequency shift deviation, temperature and flow velocity as follows:

[0102] Sample No. Frequency shift deviation (Hz) Temperature (℃) Flow rate (m / s) 1 -10.5 20.3 0.15 2 -8.2 22.1 0.23 3 -6.7 23.5 0.32 4 -3.1 25.8 0.47 5 2.4 27.2 0.58 6 5.9 28.6 0.71 7 8.6 29.4 0.82 8 12.3 30.9 0.95

[0103] Through cross-validation experiments, the Gaussian kernel function is selected As the kernel function of the support vector regression algorithm, .

[0104] For each training sample point , introduce slack variables and , and the Lagrange multiplier and . Set the interval width of the ε-insensitive loss function ε=0.05 and the penalty coefficient C=10. Use the SMO algorithm to solve the above dual problem and obtain the optimal Lagrange multiplier:

[0105] According to the value of the optimal multiplier, select or The sample points are used as support vectors to obtain the support vector set: The final support vector regression decision function is: ,in, is the bias term, which can be obtained through the functional boundary conditions of the support vector: , so for any given frequency shift and temperature , the corresponding flow velocity value can be predicted by the support vector regression decision function : .

Claims

1. A method for measuring the velocity of a water flow, include: S1, collects Doppler ultrasonic signals and ambient temperature; S2, sampling the collected Doppler ultrasonic signal, and performing fast Fourier transform on the sampled data to obtain a spectrum diagram; S3, calculating the frequency shift deviation in the spectrum diagram, and calculating the flow velocity of the water flow according to the frequency shift deviation; S4, obtaining a data set of a standard fluid with a known flow rate under different environmental parameters; the data set includes frequency shift deviation, flow rate and temperature; S5, based on the data set, the support vector regression algorithm is used to train the frequency shift-flow velocity-temperature multivariate regression compensation model; S6, taking the calculated flow velocity and the collected ambient temperature as input, and obtaining the flow velocity value after ambient temperature compensation through the trained multivariate regression compensation model as the final water flow velocity output; S5, based on the data set, the support vector regression algorithm is used to train the frequency shift-flow velocity-temperature multivariate regression compensation model, including: The constructed dataset is randomly divided into training set and test set; Normalize the frequency shift and temperature in the training set and test set respectively; Adopting adaptive multi-kernel learning strategy, radial basis function of support vector regression algorithm is selected as kernel function; The normalized training set is input into the radial basis function, and the Gaussian distance between the frequency shift offset and the temperature is calculated, and the kernel function technique is used to map the normalized training set from the low-dimensional feature space to the high-dimensional feature space; For each training sample point mapped to the high-dimensional feature space , introduce slack variables and ,in Indicates the deviation of the sample point above the interval band of the ε-insensitive loss function, Indicates the deviation of the sample point below the interval band of the ε-insensitive loss function; Construct the convex quadratic programming problem of the support vector regression algorithm and transform it into a dual problem to solve, and obtain the support vector and weight coefficient; According to the obtained support vectors and weight coefficients, a nonlinear multiple regression model among frequency shift deviation, temperature and flow velocity is constructed as a multiple regression compensation model of frequency shift-flow velocity-temperature. Adopting the adaptive multi-kernel learning strategy, the radial basis function of the support vector regression algorithm is selected as the kernel function, including: Construct multiple different kernel width parameters The Gaussian kernel function of is taken as the candidate kernel function; When training the support vector regression model, multiple candidate kernel functions are used simultaneously, and a support vector regression sub-model is trained separately for each kernel function to obtain multiple sub-models; Based on the training set data, the prediction residual of each sub-model is calculated, and the prediction residual is used as the new training target to train a residual support vector regression model to learn the residual patterns of different sub-models; The prediction results of multiple sub-models and the prediction results of the residual support vector regression model are weighted combined to obtain an adaptive multi-core support vector regression model; Using the validation set, calculate the root mean square error (RMSE) and mean absolute error (MAE) of the adaptive multi-kernel support vector regression model and each sub-model on the validation set, and select the Gaussian kernel function with the smallest RMSE and MAE as the kernel function; A nonlinear multiple regression model between frequency shift, temperature and flow velocity is constructed as a multiple regression compensation model of frequency shift-flow velocity-temperature, including: The training set data mapped to the high-dimensional feature space is input into the support vector regression algorithm, and the convex quadratic programming problem of the support vector regression algorithm is constructed and the slack variables are set. and and the penalty coefficient C; Solve the dual problem of the support vector regression algorithm and obtain the optimal Lagrange multiplier and , select support vectors based on the optimal Lagrange multiplier; Using support vectors and corresponding weight coefficients , construct a nonlinear decision function between frequency shift bias, temperature and flow velocity as a multiple regression compensation model of frequency shift-flow velocity-temperature; Among them, the nonlinear decision function is composed of the linear combination of the support vector, the kernel function value of the sample point to be predicted, the weight coefficient, and the bias term b; Weight coefficient By optimal Lagrange multiplier and The difference is calculated; The bias term b is obtained by solving the weighted slack variables of the support vector; The frequency shift deviation and temperature are used as inputs of the decision function, and the flow rate is used as the output of the decision function; Based on the optimal Lagrange multiplier and Select support vectors, including: For each training sample point mapped to the high-dimensional feature space , set the slack variables and , and the Lagrange multiplier and ; Among them, the Lagrange multiplier and The sample points A corresponding pair of multipliers is used to transform the convex quadratic programming problem into a dual problem for solution; By introducing Lagrange multipliers, the convex quadratic programming problem of support vector regression algorithm is transformed into its dual problem; Solve the dual problem of the support vector regression algorithm and obtain the optimal Lagrange multiplier and ; According to the optimal Lagrange multiplier and Select a value that satisfies or The training sample points are used as support vectors; among them, is the individual penalty coefficient of the i-th sample point; By introducing Lagrange multipliers, the convex quadratic programming problem is transformed into its dual problem, including: The Gaussian kernel function with the smallest RMSE and MAE is used as the kernel function of the support vector regression algorithm. ; Using the kernel function technique, the inner product operation in the objective function and constraint conditions of the dual problem is Replace with kernel function operation , we get the dual problem based on kernel function; Among them, the objective function is to maximize the sum of the Lagrange multiplier and the kernel function value minus the product of the Lagrange multiplier and the weighted relaxation variable; The constraints are Lagrange multipliers and The sum of is equal to zero, and the absolute value of each Lagrange multiplier does not exceed the individual penalty coefficient of the corresponding sample point ; Solve the dual problem based on the kernel function and obtain the optimal Lagrange multiplier and .

2. The method for measuring water flow velocity according to claim 1, Features: S1, collecting Doppler ultrasonic signals, including: A pair of ultrasonic transducers with a center frequency of 1 MHz are used as the transmitting probe and the receiving probe respectively; The DDS circuit is used to generate a 1MHz sine wave signal and a 990kHz sine wave signal; the 1MHz sine wave signal drives the transmitting probe to transmit ultrasonic waves after power amplification; the 990kHz sine wave signal is used as a reference signal for the mixing circuit; The receiving probe receives the echo signal generated by the Doppler frequency shift of the ultrasonic wave, and transmits the echo signal to the ultrasonic receiving circuit; The ultrasonic receiving circuit performs multi-stage amplification and bandpass filtering on the received echo signal to obtain an amplified and filtered echo signal; transmitting the amplified and filtered echo signal to a mixing circuit; The mixing circuit mixes the amplified and filtered echo signal with the generated 990kHz sine wave signal, and down-converts the frequency of the echo signal to the intermediate frequency range through nonlinear mixing to obtain a mixed signal; The obtained mixed signal is filtered through a low-pass filter to filter out the high-frequency components generated in the mixing process, and an intermediate frequency Doppler shift signal with a center frequency within a preset range is obtained as the collected Doppler ultrasonic signal output.

3. The method for measuring water flow velocity according to claim 2, Features: S2, sampling the collected Doppler ultrasonic signal, and performing fast Fourier transform on the sampled data to obtain a spectrum diagram, including: Performing digital-to-analog conversion on the intermediate frequency Doppler frequency shift signal, converting the analog signal into a digital signal, and obtaining sampling data of the intermediate frequency Doppler frequency shift signal; Performing a fast Fourier transform on the obtained sampling data of the intermediate frequency Doppler frequency shift signal, converting the time domain signal into a frequency domain signal, and obtaining spectrum data of the intermediate frequency Doppler frequency shift signal; According to the spectrum data, the spectrum amplitude value and the corresponding frequency value are extracted to generate a spectrum graph.

4. The method for measuring water flow velocity according to claim 3, Features: S3, calculating the frequency shift deviation in the spectrum diagram, and calculating the flow velocity of the water flow according to the frequency shift deviation, including: According to the spectrum diagram, the frequency value corresponding to the frequency component with the largest amplitude is extracted as the frequency value of the Doppler frequency shift signal; The difference between the frequency value of the extracted Doppler frequency shift signal and the frequency of the transmitted ultrasonic wave is calculated to obtain the Doppler frequency shift amount; According to the calculated Doppler frequency shift, the flow velocity v of the water flow is calculated using the following formula: Among them, v represents the velocity of water flow, c represents the propagation speed of ultrasonic wave in water, represents the calculated Doppler frequency shift; f represents the frequency of transmitting ultrasonic waves; Indicates the angle between the ultrasonic emission direction and the water flow direction.

5. The method for measuring water flow velocity according to any one of claims 2 to 4, Features: S4, obtaining a data set of a standard fluid with a known flow rate under different environmental parameters; The data set contains frequency shift offset, flow rate and temperature, including: Obtain a standard fluid with a known flow rate as a measurement object; Using the method in step S1, collecting Doppler ultrasonic signals of the standard fluid under different flow rates and temperature conditions; The collected Doppler ultrasonic signal is sampled and fast Fourier transformed using the method in step S2 to obtain a spectrum diagram under different flow velocity and temperature conditions; For the obtained spectrum, the frequency shift deviation is calculated using the method in step S3 to obtain frequency shift deviation data under different flow rates and temperature conditions; The flow rate conditions, temperature conditions, and corresponding frequency shift offsets are matched to construct a data set.

Citation Information

Cited By

  • Hydrometric station flow measurement method and system

    CN120869068A