Machine Learning-Based Calibration for Ultrasonic Flow Metering Using Transit-Time and Temperature Measurements

Machine Learning-Based Calibration for Ultrasonic Flow Metering Using Transit-Time and Temperature Measurements

Muammer Catak Fatih Dogan Sabahudin Vrtagic* Bahadir Yesil

College of Engineering and Technology, American University of the Middle East, Egaila 54200, Kuwait

R&D Department, Baylan Water Meters, Izmir 35620, Turkey

Corresponding Author Email: 
Sabahudin.Vrtagic@aum.edu.kw
Page: 
61-70
|
DOI: 
https://doi.org/10.18280/i2m.250202
Received: 
15 December 2025
|
Revised: 
20 February 2026
|
Accepted: 
2 March 2026
|
Available online: 
30 April 2026
| Citation

© 2026 The authors. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

Ultrasonic flow measurement accuracy is significantly affected by calibration uncertainties stemming from temperature fluctuations, flow-dependent nonlinearities, and manufacturer-specific correction factors. This study introduces a data-driven calibration framework that leverages artificial neural networks (ANNs) to enhance flow-rate estimation accuracy without requiring modifications to sensor hardware or signal acquisition procedures. The framework employs multi-layer perceptron (MLP) models that utilize transit times measured in upstream and downstream directions, along with fluid temperature, as inputs to predict the flow-calibration factor governing velocity and volumetric flow computation. Experimental validation is performed on a Diameter Nominal (DN) 25 ultrasonic flow meter across a wide operating range of 15 to 4000 L/h. The ANN-based calibration model achieves a coefficient of determination of 0.914 for calibration factor prediction and consistently reduces flow-rate estimation errors compared to the conventional cross-correlation method. The proposed approach limits maximum error to no more than 2.6% across all tested flow rates, with minimum errors as low as 0.01%, while the cross-correlation method exhibits errors up to 5.7%. Shapley Additive Explanations (SHAP) analysis confirms that the model demonstrates physically consistent dependencies on transit times and temperature, ensuring interpretability. The findings demonstrate that machine-learning-based calibration substantially improves the accuracy and robustness of ultrasonic flow meters, particularly in medium and high flow regimes.

Keywords: 

ultrasonic flow meter, time-of-flight, artificial neural networks, multi-layer perceptron, signal preprocessing, machine learning calibration, flow measurement error compensation

1. Introduction

Recent advances in ultrasonic flow measurement have increasingly taken advantage of artificial intelligence and machine learning techniques to improve measurement accuracy, adaptability, and robustness under varying operational conditions. Several studies have explored integrating artificial neural networks (ANNs), deep learning models, and other data-driven approaches into ultrasonic flow meter systems to address long-standing challenges such as calibration errors, environmental variability, and complex flow profiles. For example, methods that involve the generation of artificial vortices combined with cross-correlation techniques have been shown to improve self-monitoring capabilities and reduce the need for manual calibration [1]. Optimized artificial neural networks (OANNs) have been introduced to extend the linearity range of flow measurements and adapt to varying fluid and pipe conditions, outperforming conventional circuitry in real-world validations [2]. Deep learning models, including recurrent neural networks (RNNs) with long short-term memory (LSTM), have been effectively utilized to improve transit-time difference measurements, yielding lower root mean squared errors (MSE) compared to traditional methods [3]. Furthermore, hybrid approaches that combine random forest (RF) models with ANNs have been used to predict measurement errors, further enhancing accuracy during operation [4]. ANN-based data integration methods, such as three-layer networks, have demonstrated significant error reduction in complex flow environments [5], while genetic algorithm-optimized ANN (GANN) architectures have improved measurement stability and minimized errors in multipath systems [6]. Temperature compensation techniques using backpropagation neural networks have also shown promising results in mitigating thermal influences on measurement precision [7, 8]. Furthermore, self-supervised learning algorithms have been applied to classify two-phase flow regimes with high accuracy and practical applicability [9].

The precise and reliable measurement of flow rates for a diverse range of fluids, covering water, natural gas, crude oil, and various chemical substances, is a cornerstone in the efficient operation of industrial processes and significantly impacts numerous aspects of our daily existence. In industrial environments, accurate flow measurement is essential for maintaining strict process control, ensuring the efficient utilization of resources, preserving high product quality standards, and safeguarding operational safety across a wide range of sectors, including chemical processing, power generation, and manufacturing industries [10-12]. In a chemical manufacturing facility, the precise measurement of reactant flow rates is a principal tool for achieving the desired chemical reaction kinetics, maximizing the yield of the final product, and minimizing the generation of unwanted results. Similarly, within the oil and gas sector, the precise measurement of fluid flow is fundamental for effective reservoir management strategies, the efficient and safe transportation of hydrocarbons through extensive pipeline networks, and the accurate determination of quantities during custody transfer operations, which involve the exchange of ownership of petroleum products [13, 14].

Extending beyond the critical applications within industrial complexes, the measurement of fluid flow plays an equally vital role in the effective management of essential utilities that underpin our daily lives and the functioning of modern societies. The accurate measurement of water flow, for example, is essential for ensuring equitable billing practices for consumers, facilitating the timely detection and localization of leaks within extensive water distribution networks, and enabling the implementation of sustainable and efficient water resource management strategies, particularly in regions grappling with the increasing challenges of water inadequacy and deficiency conditions [15, 16]. Likewise, precise natural gas flow measurement is crucial not only for ensuring accurate billing for residential and commercial consumers but also for effectively monitoring and controlling complex gas distribution systems, thus enhancing safety and reliability. Furthermore, in healthcare settings, accurate delivery of injected fluids and respiratory gases is highly dependent on precise flow measurement technologies, directly affecting patient well-being and treatment effectiveness [17].

Over time, a wide array of innovative techniques has been developed and refined for the purpose of flow measurement, each relying on distinct physical principles and exhibiting its own unique set of advantages and inherent limitations, making them suitable for specific applications and operating conditions. Common flow-measurement techniques include differential pressure flow meters, which estimate flow rate from the pressure drop across a restriction [18]; variable-area flow meters, such as rotameters, where flow rate is indicated by the position of a float within a tapered tube; and mechanical flow meters, including turbine and positive-displacement types, which use the fluid’s kinetic energy or volume to drive internal moving components [19]. Other widely adopted technologies are electromagnetic flow meters, which apply Faraday’s law of electromagnetic induction to measure the flow of electrically conductive fluids within a magnetic field [20], and ultrasonic flow meters, which determine flow rate by analyzing the propagation of sound waves through the fluid [21].

In recent years, ultrasonic flow meters have gained significant attention across a wide range of applications due to their inherent advantages. These include their non-intrusive operation, as they typically do not require direct contact with the fluid, their compatibility with both liquid and gaseous media, and their reliable performance under high-pressure and high-temperature conditions without substantial degradation [22]. This non-intrusive characteristic is particularly beneficial in applications where contamination, corrosion, or pressure drops are concerns.

The need for compact, robust, and precise flow measurement methods also extends to microfluidic and lab-on-chip systems, where conventional calibration approaches become increasingly challenging as physical dimensions shrink and signal strength diminishes. The data-driven calibration strategy developed in this work, based on ANNs, is well-suited to such environments due to its ability to adapt to nonlinear system behavior, compensate for device variability, and reduce reliance on manual calibration. These characteristics make the proposed approach a promising candidate for future microscale flow-sensing applications, including microfluidic chips and point-of-care diagnostic systems.

While numerous studies have applied ANNs to ultrasonic flow measurement, many approaches rely on black-box models or focus on isolated aspects of the measurement process. A critical gap remains in developing practical calibration frameworks that improve measurement accuracy while remaining compatible with existing sensor hardware and signal-processing pipelines. The novelty of this work lies in the application of a data-driven calibration approach based on multilayer perceptron neural networks, which maps measured transit times and temperature directly to the flow calibration factor κ, thereby overcoming limitations of static calibration and linearity assumptions.

This research is specifically focused on the precise measurement of water flow within a standard DN-25 pipe, which corresponds to an internal diameter of precisely 25 millimeters, utilizing the capabilities of ultrasonic sensor technology. A widely adopted and highly effective technique employed in conjunction with ultrasonic sensors for the accurate estimation of water flow rate is the cross-correlation method [23]. This sophisticated signal processing technique operates by analyzing the minute time delay that occurs between ultrasonic signals as they propagate through the flowing fluid in both the upstream and downstream directions. By precisely determining this transit time difference and knowing the acoustic path length, the average velocity of the fluid flow can be accurately calculated, and subsequently, the volumetric flow rate can be determined based on the known cross-sectional area of the pipe. In this study, the cross-correlation method is used as a reference baseline for performance comparison with the proposed machine-learning-based calibration approach.

Recent research efforts have expanded beyond conventional ultrasonic flow sensing toward the development of advanced sensor technologies integrating physical modeling and machine learning. These advancements have laid the groundwork for sensor systems that combine AI with physics-based simulations. A significant development came with the design of machine learning-enabled laser-based sensors to distinguish between pure and seawater using simulations performed in COMSOL Multiphysics, highlighting the synergy between physical modeling and AI classification methods [24].

Further contributions include a conceptual study on salinity prediction, which proposed a sustainable monitoring framework enhanced by adaptive machine learning models [25]. More recently, a laser sensor system was developed for detecting diesel adulteration, utilizing supervised learning techniques to ensure high reliability in fuel quality monitoring [26].

These contributions demonstrate a clear trend toward the integration of machine learning techniques into sensor systems across environmental and industrial applications, aligning closely with the current work’s aim of improving ultrasonic flow measurements through AI-based methods. This trajectory is further reinforced by developments in distributed sensor networks, where machine learning frameworks have been successfully applied to predict operational states and optimize maintenance schedules based on multivariate time-series data. Such studies highlight that integrating data-driven predictive models with physical sensor outputs enhances measurement precision while enabling robust, self-diagnostic capabilities in complex engineering systems [27]. The main contributions of this work are:

•A machine-learning-based calibration approach for ultrasonic flow meters using transit-time and temperature measurements.

•Experimental validation on a DN-25 water flow system across a wide flow range (15–4000 L/h).

•Quantitative accuracy improvement over conventional cross-correlation-based flow estimation.

•Model interpretability using Shapley Additive Explanations (SHAP) analysis to confirm physically meaningful feature dependencies.

2. Materials and Methods

Ultrasonic flow meters measure fluid velocity by transmitting and receiving ultrasonic waves through the fluid. As the waves travel through a moving fluid, their speed is altered by the component of the fluid’s velocity along the wave path. By precisely measuring the transit times of ultrasonic pulses traveling in both the upstream and downstream directions, the average velocity of the fluid within the pipe can be determined, which subsequently allows for the calculation of the volumetric flow rate.

In a typical setup for a DN-25 pipe, two ultrasonic transducers are mounted on the outer surface of the pipe at a known distance $L$ apart along the axial direction. These transducers can function interchangeably as both transmitters and receivers. A short burst of ultrasonic waves is transmitted by one transducer, propagates through the pipe wall, into the fluid, crosses the fluid stream, goes through the opposite pipe wall, and is finally received by the other transducer. This process is then reversed, with the second transducer transmitting and the first receiving.

The key point of ultrasonic flow measurement is accurately determining the time of flight (ToF)–time difference Δt of theultrasonic pulses. Let $t_1$ be the time taken for the ultrasonic pulse to travel from the upstream transducer to the downstream transducer, and $t_2$ be the time taken for the pulse to travel from the downstream transducer to the upstream transducer.

When the fluid is stationary (zero flow), the transit times in both directions are equal $\left(t_{10}=t_{20}\right)$. However, when the fluid is flowing with an average velocity $v$ along the axis of the pipe, the effective speed of the ultrasonic wave in the downstream direction is increased to $c+v \cos (\theta)$, and in the upstream direction, it is decreased to $c-v \cos (\theta)$, where $c$ is the speed of sound in the fluid and $\theta$ is the angle between the ultrasonic path and the pipe axis. The path length of the ultrasonic beam through the fluid is typically $D / \sin (\theta)$, where $D$ is the inner diameter of the pipe. However, for simplicity in this initial explanation, let's consider the axial distance $L$ between the transducers and assume the angle $\theta$ is such that its cosine component along the axial direction is relevant. Therefore, the transit times can be expressed as:

$t_1=\frac{L}{c+v \cos (\theta)}$

$t_2=\frac{L}{c-v \cos (\theta)}$

By rearranging these equations, one can solve for the fluid velocity $v$ :

$v=\frac{L}{2 \cos (\theta)}\left(\frac{1}{t_1}-\frac{1}{t_2}\right)=\frac{L\left(t_2-t_1\right)}{2 \cos (\theta) t_1 t_2}$    (1)

For a given pipe geometry ( $L$ and $\theta$ are fixed) and assuming the speed of sound c remains relatively constant, the fluid velocity $v$ is directly proportional to the difference in the reciprocal of the transit times or, for small velocity differences, approximately proportional to the difference in transit times $\left(t_2-t_1\right)$. Accurate measurement of $t_1$ and $t_2$ is thus crucial for precise flow rate determination. Eq. (1) is theoretically sound; however, in practical applications, it exhibits significant sensitivity to small variations in $t_1$ and $t_2$. Given that these transit times are typically of the order of nanoseconds, even minimal measurement errors or numerical inaccuracies can result in significant deviations in the estimated velocity. As a result, the accuracy and reliability of the flow meter are adversely affected To address this limitation, a calibration factor is typically introduced into the velocity formulation:

$v=\kappa\left(t_1, t_2\right) \frac{\Delta t}{t_1 t_2}$        (2)

where, $\kappa\left(t_1, t_2\right)$ is a calibration parameter, which can be determined through empirical methods or advanced techniques, such as artificial intelligence-based algorithms. It is important to note that the neural network is not applied to raw ultrasonic waveforms or direct ToF estimation; instead, it operates on precomputed measurement-level features to determine the calibration factor.

Figure 1. Illustration of the experimental setup using DN-25

Figure 1 illustrates the typical ultrasonic flow measurement setup for a DN-25 pipe. Two ultrasonic transducers are mounted on opposite sides of the pipe wall at a distance $L$ apart. This configuration is used to measure the ToF of the ultrasonic pulses in both directions, which is critical to determining the velocity of the fluid.

3. Time of Flight and Calibration Factor Estimation Using Machine Learning

3.1 Network architecture

A multi-layer perceptron (MLP) network architecture is employed for calibration factor estimation. Unlike waveform-based approaches that process raw ultrasonic signals, the MLP model utilizes direct measurement-level features as inputs. The network configuration consists of:

  • Input Layer: The input layer comprises three neurons corresponding to the primary measurement variables:
    • $\mathrm{o} \rightarrow t_1:$ Upstream transit time $(\mu \mathrm{s})$
    • $\mathrm{O} \rightarrow t_2$ : Downstream transit time $(\mu \mathrm{s})$
    • $\circ \rightarrow T$ : Fluid temperature ( ${ }^{\circ} \mathrm{C}$ )
  • Hidden Layers: Two hidden layers with non-linear activation functions (ReLU or tanh) are used to capture the complex, non-linear dependencies between the measured transit times, temperature, and the resulting calibration factor. The number of neurons per layer and activation function type were determined through systematic hyperparameter optimization.
  • Output Layer: The output layer consists of a single neuron representing the predicted calibration value (either Δt or κ). A linear activation function is employed in this layer to accommodate the continuous range of the output variable.

3.2 Data and preprocessing

To train and evaluate the ANN, the calibration dataset consists of 950 measurements provided by the flow meter manufacturer. Each measurement includes:

  • Upstream transit time $\left(t_1\right)$.
  • Downstream transit time $\left(t_2\right)$
  • Fluid temperature (T)
  • Manufacturer-calculated calibration factor (κ)
  • Manufacturer-calculated time difference correction (Δt)

Since both Δt and κ are calculated from the same input parameters by the manufacturer, the dataset was split into two independent subsets for separate modeling and optimization.

Preprocessing steps applied to the input features $\left(t_1, t_2, T\right)$:

  1. Yeo-Johnson Power Transformation: Applied to stabilize variance and reduce skewness in the timing measurements.
  2. RobustScaler Normalization: Used to mitigate the influence of outliers in the transit time data.
  3. Data Splitting: The dataset is divided into 80% training and 20% testing. Within the training phase, 20% of the data is reserved for validation to enable early stopping and prevent overfitting.

3.3 Training and optimization

The separate MLP models are developed for predicting Δt and κ. The training process involves:

  • Loss Function: MSE is used to quantify prediction error during training.
  • Optimization Algorithm: The Adam optimizer with adaptive learning rate is employed for weight updates.
  • Early Stopping: Training is monitored on the validation set, with early stopping implemented to halt training when validation performance ceases to improve, preventing overfitting.
  • Hyperparameter Tuning: Systematic grid search with 5-fold repeated cross-validation is performed to identify optimal configurations for:
    • Number and size of hidden layers
    • Activation function type (ReLU vs. tanh)
    • L2 regularization strength (alpha)
    • Solver algorithm (Adam vs. LBFGS)
    • Initial learning rate

The best-performing configuration for each model is selected based on cross-validation R² score on the training data.

3.4 Flow rate estimation

Once the MLP models are trained and validated, they can be used to predict calibration parameters from newly acquired transit time and temperature measurements. The trained models accept the three input features $\left(t_1, t_2, T\right)$ and output the predicted calibration factor.

For flow rate computation, the predicted calibration factor κ is combined with the measured time difference Δt, according to Eq. (2), where $v$ is the fluid velocity.

The average flow velocity $\bar{v}$ is then related to this axial velocity component, depending on the beam path and the flow profile. For a single diametrical path, the measured velocity is approximately the average velocity. For chordal paths, a correction factor based on the assumed flow profile (e.g., parabolic for laminar flow, flatter for turbulent flow) might be needed for high accuracy. The volumetric flow rate $Q$ is then calculated by multiplying the average flow velocity $\bar{v}$ by the cross-sectional area $A$ of the DN-25 pipe:

$Q=\bar{v} A$

For a DN-25 pipe with an inner diameter $D=25 \times 10^{-3}$ m , the cross-sectional area $A$ is:

$A=\pi\left(\frac{D}{2}\right)^2=\pi\left(\frac{25 \times 10^{-3}}{2}\right)^2 \approx 4.9087 \times 10^{-4} \mathrm{~m}^2$

By substituting the velocity $\bar{v}$ (calculated using MLP-predicted κ and manufacturer-provided Δt) into this equation, the water flow rate can be estimated. The performance of this MLP estimation and subsequent flow rate measurement will be evaluated by comparing the results obtained on the testing dataset with the true flow rates.

3.5 Calibration factor estimation

In ultrasonic flow measurement, $\Delta \mathrm{t}$ represents a proprietary parameter provided by the manufacturer. It combines the temperature-compensated time difference and is derived from upstream $\left(t_1\right)$ and downstream $\left(t_2\right)$ transit times. These represent the primary acoustic flight times, which are modulated by the flow velocity profile and fluid temperature ( $T$ ), which can impact the speed of sound, which is the dominant source of zero-flow errors. In this study, $\Delta \mathrm{t}$ is predicted using a neural network that maps these inputs to $\Delta \mathrm{t}$.

Calibration $(\kappa)$ is the scaling factor used with $\Delta t$ and the geometry of the pipe to compute the flow velocity $(\bar{v})$ and the volumetric flow rate. For $\Delta \mathrm{t}$ prediction, we use an MLP network with 3 input neurons ( $t_1, t_2, T$ ), two hidden layers of 20 neurons (ReLU activation), and a single output neuron (linear activation). The network is trained with the Adam optimizer and MSE loss. Early stopping and a validation split of $20 \%$ are used to prevent overfitting. $\Delta t$ is used as the time difference for the numerator of Eq. (2).

For κ prediction, a similar MLP is applied but with two hidden layers of 10 neurons (tanh activation). Training used Adam optimizer, MSE loss, early stopping, and L2 regularization $(\alpha=0.01)$.

We have demonstrated our methods for a DN-25 pipe. The medium of measurement is water, where the speed of sound is 1450 m/s. The microprocessor used is the STM32 32-bit microcontroller based on the ARM Cortex, which works at 1 MHZ. The proposed ANN and calibration workflows are relatively independent of the physical dimensions and can be retrained with data from scaled-down microchannels with minimal modification. The data-driven correction of signal distortions and environmental noise is arguably even more powerful within microfluidic devices, where signal attenuation and complex flow dynamics hinder conventional approaches. The computational efficiency of the final ANN inference step is compatible with embedded, chip-scale ASIC or Field-Programmable Gate Array (FPGA) implementations, opening the door for real-time, on-chip flow sensing in microsystems and lab-on-chip platforms.

4. Results and Discussion

4.1 Machine learning architectures and training of the calibration factor

This stage maps the measured transit times $\left(t_1, t_2\right)$ and temperature ( $T$ ) to two distinct target variables: the calibration factor (κ) and the time difference correction (Δt). For the field calculation of the velocity, using the measurements directly would result in inaccurate conclusions. To avoid such inaccuracies, the manufacturer provides Δt and κ values for a given set of time and temperature measurements. We were provided a dataset of 950 points, including measured initial and final time, temperature, and calculated Δt and κ. Δt and κ were calculated with the same input parameters. Therefore, we split the data set into two distinct sets for independent modeling. We have separately optimized each set to arrive at the highest possible accuracy.

Table 1. Performance metrics comparison for $\Delta \mathrm{t}$ and $\kappa$ predictions

Metric

$\Delta t$ Prediction

$\boldsymbol{\kappa}$ Prediction

R² Score

0.9999

0.9140

RMSE

1.1600

1.0340

MAE

0.6190

0.7130

Mean % Error

2.750%

1.777%

Median % Error

1.527%

1.221%

Note: R² = Coefficient of Determination, RMSE = Root Mean Square Error, MAE = Mean Absolute Error

To ensure statistical validity, we implemented a regression pipeline using Python’s scikit-learn library. We applied a Yeo-Johnson Power Transformation to stabilize variance and a RobustScaler to mitigate outliers in the timing data. Datasets were split into 80% training, 10% validation, and 10% testing. Training ran for up to 500 epochs with early stopping, and hyperparameters were tuned using GridSearchCV. In Table 1, we present the performance metrics for both models.

The Δt model’s high R² shows that manufacturer-supplied Δt values are produced using the input parameters, mainly dependent on $t_2$. In contrast, the κ model’s lower percentage errors make it practical for real-time applications.

4.2 Calibration factor numerical outputs

In this section, we provide details of the modeling for each prediction.

4.2.1 Learning curves

Learning curve is a diagnostic plot that shows how the model’s performance evolves as a function of the size of the training dataset. We display the accuracy (R²). The model is used to estimate both the training set (so far) and the validation set (20% of the total training set) as more data is used to train the model. The curve helps assess whether the model is overfitting (a large gap between training and validation performance) or underfitting (both scores are low). A smooth convergence of the training and validation curves indicates that the model generalizes well to unseen data and benefits from additional training samples.

(a)

(b)

Figure 2. Learning curves for (a) $\Delta \mathrm{t}$ prediction and (b) $\kappa$ prediction

Figure 2 shows how R² changes with training size. In Figure 2(a), Δt prediction reaches near-perfect R² even with small datasets, showing excellent generalization. We are reaching the measurement accuracy level. We see minimal improvement with the increased training size. In Figure 2(b), κ prediction improves gradually with training size, reaching a validation R² of 0.914, indicating effective prediction. κ prediction efficiency is a more gradual increase. Efficiency can be improved with larger datasets. 1.777% mean error shows that even with this small set of data, the model can be used in real-life situations.

4.2.2 Shapley Additive Explanations value analysis

SHAP values are a model-agnostic method for interpreting machine learning predictions by assigning an importance value to each feature for every individual prediction. Rooted in cooperative game theory, SHAP treats each feature as a "player" in a game where the model's prediction is the "payout" and calculates how much each feature contributes to shifting the prediction from the baseline (the average prediction over all data points). In the SHAP summary plots used in this study, the horizontal axis shows the SHAP values in the same units as the model output ( $\Delta \mathrm{t}$ or $\kappa$ ). A positive (negative) SHAP value means the feature increases (decreases) the predicted output relative to the baseline. For instance, if $t_2$ has a SHAP value of +300 , it contributes to increasing the predicted $\Delta \mathrm{t}$ (or $\kappa$ ) by 300 units, while a SHAP value of - 100 indicates $t_2$ lowers the prediction by 100 units. This spread illustrates how the effect of $t_2$ on the prediction depends on its value and its interaction with other features in the neural network.

The color gradient in the plots provides the actual value of the feature for each data point. Red dots represent high feature values (e.g., large $t_2$ ), and blue dots indicate low feature values. This allows us to observe trends such as high $t_2$ values generally contributing positively to $\Delta \mathrm{t}$ predictions (red dots on the positive side) and low $t_2$ values often decrease the predictions (blue dots on the negative side). This combination of SHAP values and color mapping helps to disentangle how both the magnitude and direction of each feature influence the model's predictions, which is especially important for interpreting complex, nonlinear models like MLPs.

The SHAP summary plots show the mean absolute SHAP value for each feature, which reflects its overall importance in the model. These plots allow us to identify dominant predictors (e.g., $t_2$ for Δt prediction) and evaluate whether the model relies excessively on a single variable or distributes influence more evenly across features.

(a)

(b)

Figure 3. Shapley Additive Explanations (SHAP) value analysis for (a) Δt prediction and (b) κ prediction

Figure 3(a) reveals that the $\Delta t$ prediction model relies almost exclusively on $t_2$ ( $>89 \%$ importance), with minimal contribution from $t_1$ or temperature. While this yields high accuracy for larger transit times, the model essentially learns a linear mapping of $t_2$ rather than the complex differential relationship required for low-flow precision. This overfitting to $t_2$ causes significant errors in the low-flow regime where $\Delta \mathrm{t}$. is small. Consequently, the pure $\Delta \mathrm{t}$ prediction model is deemed unsuitable for the final implementation. Instead, the proposed framework utilizes a more balanced $\kappa$ model (Figure 3(b)), which distributes importance more effectively across all inputs.

4.2.3 Actual vs. predicted values

Here we do a visual comparison of the actual and predicted values. In this plot, the horizontal axis represents the actual observed values from the dataset, while the vertical axis shows the corresponding values predicted by the model. A perfect model would produce predictions that fall exactly on the diagonal line (y = x), indicating that the predicted values match the actual values without error.

(a)

(b)

Figure 4. Actual vs. predicted values for (a) Δt prediction and (b) κ prediction

Tight clustering of points along the diagonal line indicates strong agreement between the model’s predictions and the true values, with minimal error. The degree of scatter around the line reveals the residual variance. Figure 4 compares the actual and predicted outputs over 190 points. In Figure 4(a), the Δt prediction points cluster tightly along the diagonal, visualizing the high accuracy. In Figure 4(b), κ prediction shows slightly more spread, but remains closely aligned to the diagonal. For Δt prediction, points are densely concentrated along the diagonal, reflecting the model’s near-perfect fit (R² = 0.9999). For κ prediction, the points also align closely but show slightly more dispersion, consistent with its lower R² (0.914). With an RMSE value of 1.034, the model’s predictions are generally close to the actual values.

Although Figure 4 shows the overall trend, it is important to see the percent error to validate the results for the whole range. In Figure 5, we plot the percent error for both parameters. For κ, the results are mostly uniform and less than 10% (except for 2 points) error confirms that predicted values are a good approximation for the actual values, for a training set of 760 points. For Δt, on the other hand, we see a very good agreement for large values, while for small values of Δt, the error shoots up to 50%.

(a)

(b)

Figure 5. % error vs. actual values for (a) Δt prediction and (b) κ prediction

4.3 Calculation of flow rate

The purpose of this study is to calculate the flow rate. With the predictions described in this section, the calculation of the flow rate using different methodologies is performed. The performance of the proposed ANN-based methodology for precise ToF estimation in ultrasonic flow metering was evaluated across a comprehensive spectrum of flow rates, ranging from 15 L/h to 4000 L/h.

First, we compare experimental measurements of the flow rate to flow rates determined by the conventional cross-correlation technique, a widely employed method in ultrasonic flow measurement. Table 2 presents a comparative analysis of the reference readings, the flow rates estimated by the cross-correlation technique, along with their corresponding percentage errors. DN-25 pipe is exposed to an assumed flow rate that moves the fluid through the pipe. We measured the actual flow rate using the total volume of the liquid displaced. Each assumed flow rate is repeated six times to arrive at the measured value. Since we use a single pipe, sequential flow rates are expected to behave in a similar way. The measured values are smoothed out using a power law interpolation. For completeness, we provide all the values in Table 2. The cross-correlation values for each data point are also given and based on the errors, the interpolation improves the accuracy of our measurements.

It is important to distinguish between the experimental reference values and the ANN-based predictions reported in Tables 2 and 3. The measured flow rates used as reference values were obtained by averaging six repeated experimental measurements at each nominal flow condition, ensuring stability and repeatability of the physical system. In contrast, the ANN-predicted values correspond to individual predictions generated on the test dataset, where each sample represents a single measurement consisting of upstream transit time (t₁), downstream transit time (t₂), and fluid temperature (T). The minimum reported error of 0.01% reflects the closest agreement between the ANN-predicted flow rate and the corresponding averaged experimental reference value for a specific test sample. Therefore, the reported errors represent point-wise prediction accuracy rather than statistical dispersion, and the consistently low errors across the dataset demonstrate the robustness and generalisation capability of the trained model.

In Table 3, we repeat a similar analysis using the proposed ANN-based method. In this method, we use equation 2 to calculate the velocity of fluid and calculate the flow rate accordingly. Although we have completed analyses using both Δt and κ, the inaccuracies at small values of Δt forced us to use sensor output rather than our findings. Therefore, for the calculation of the flow rate in Table 3, we have used κ value from ANN calculations, while actual Δt values from the sensor are used. All parameters used are given in Table 3. Since the data used in the prediction algorithm is not directly related to the experiment, we provide flow rate values close to the assumed flow rate for comparison with the cross-correlation method. Notably, the percentage errors associated with the ANN estimations are demonstrably lower than those obtained using the conventional cross-correlation technique at every measurement point. The error percentages for the cross-correlation method exhibit a significant variability, ranging from a minimum of 0.11% to a maximum of 5.70%, suggesting a sensitivity to specific flow regimes or signal characteristics that the ANN appears to mitigate. In contrast, ANN-based estimations yield a remarkably constrained error range, ranging from a mere 0.01% to 2.6%, underscoring the robustness and enhanced accuracy of the neural network approach in predicting flow rates from ultrasonic sensor data.

At the lower end of the flow rate range, the two methods behave equally well. For instance, at standard flow values of 15 L/h and 25, the cross-correlation technique yields error percentages of 0.76% and 0.94%, respectively. The ANN method has 0.92% and 0.63%. This enhanced sensitivity and accuracy at lower flow rates are of considerable importance in applications such as leak detection in water distribution systems, precise metering in low-flow chemical processes, and accurate fluid delivery in medical devices, where even small deviations from actual flow can have significant implications.

The enhanced accuracy afforded by the ANN is particularly evident at the higher end of the flow rate range. For instance, at standard flow values of 2200 L/h and 4000, the cross-correlation technique yields error percentages of 2.54% and 0.22%, respectively. The ANN method reduces these inaccuracies to 0.88% and 0.01%, representing a substantial improvement in the precision of the measurement under high flow conditions.

In the midrange, ANN shows a higher error range due to a small number of data points available at that range, causing incomplete prediction. With enough data points, ANN shows a much better overall result. This can be fundamentally attributed to its inherent capability to learn intricate and non-linear relationships. Unlike the cross-correlation technique, which relies on a direct linear relationship between transit time difference and flow velocity, the MLP can automatically learn complex, non-linear mappings between measured transit times, temperature, and the calibration factor, effectively compensating for flow-dependent nonlinearities and temperature effects.

Table 2. Experimental values of the flow rates

Flow Rate

Errors

Assumed

Measured

Power Regression

Cross-Correlation

Based on Measured

Based on Regression

L/h

L/h

L/h

L/h

%

%

15

19.18

15.78

15.90

20.78

0.76

25

30.35

25.44

25.72

18.19

0.94

40

46.64

39.58

39.16

18.91

1.06

60

67.77

59.65

59.30

14.21

0.59

80

89.10

77.19

79.90

11.91

3.51

100

109.63

98.73

97.50

12.28

1.25

200

211.55

198.23

196.50

7.59

0.87

400

414.32

377.30

398.80

4.11

5.70

1000

1019.88

987.55

975.20

4.52

1.25

2200

2225.36

2145.40

2091.00

6.26

2.54

4000

4019.11

4008.63

4017.50

0.04

0.22

Table 3. Comparison of calculated and ANN-predicted calibration factor (κ) with corresponding flow rate estimations

Flow Rate

Errors

Inputs

κ

Assumed

Input from Sensor

MLP Output

MLP

ToF (Δt)

t1

t2

Temperature

Calculated

Predicted

L/h

L/h

L/h

%

(ns)

(µs)

(µs)

(Celsius)

 

 

15

16.59

16.59

0.92

1.87

65.32

62.78

16

36.46

36.79

25

25.02

25.18

0.63

2.68

63.6

62.78

30

37.23

37.46

40

40.37

39.99

0.95

4.30

64.88

62.78

19

38.22

37.85

60

60.34

61.66

2.18

5.91

62.78

62.78

40

40.26

41.14

80

80.02

81.83

2.27

7.93

63.6

62.78

30

40.30

41.21

100

99.83

102.42

2.60

10.39

64.88

62.78

19

39.15

40.17

200

200.15

200.40

0.13

19.97

65.31

62.79

16

41.11

41.16

400

399.07

399.43

0.09

38.63

64.86

62.8

19

42.09

42.12

1000

986.88

990.66

0.38

93.79

64.82

62.83

19

42.86

43.03

2200

2070.20

2052.04

0.88

170.14

62.11

62.9

50

47.53

47.11

4000

4002.40

4002.67

0.01

366.95

64.64

63.01

19

44.42

44.43

Note: ANN = artificial neural networks, MLP = multi-layer perceptron, ToF = time of flight

This learning process enables the ANN to effectively compensate for a multitude of factors that can introduce errors in traditional ToF estimation methods, including variations in fluid properties (such as temperature, viscosity, and density), distortions in the flow profile (e.g., turbulent flow regimes), and the presence of noise and artifacts in the acquired ultrasonic signals.

The consistently low error percentages achieved by the ANN across the tested flow range highlight its potential for providing more reliable and accurate flow measurements in real-world industrial settings. This improvement in measurement accuracy can translate to significant benefits, including enhanced efficiency in industrial process control, more precise and fair billing in utility services, improved safety and control in critical fluid handling systems, and more accurate data for process optimization and monitoring.

While the results presented herein are promising, future research endeavors should focus on further validating the robustness and generalization capability of the trained ANN model under a broader spectrum of operating conditions. This includes evaluating its performance experimentally with different pipe sizes and materials, various fluid types exhibiting diverse acoustic properties, and in the presence of varying levels and types of noise interference. Investigating the sensitivity of the ANN to sensor variations and the potential for transfer learning across different ultrasonic sensor configurations would also be valuable steps toward practical industrial deployment. Additionally, exploring the interpretability of the learned features within the ANN could provide further insights into the underlying physical phenomena governing ultrasonic flow measurement and potentially lead to further improvements in the methodology.

5. Conclusion

This manuscript presented a detailed investigation into the application of ANNs for enhancing the accuracy of flow rate measurement using ultrasonic sensors, specifically within a DN-25 pipe. The study highlighted the fundamental principles of ultrasonic flow measurement based on ToF differences and underscored the limitations of traditional cross-correlation techniques, particularly in the presence of noise and non-linear flow characteristics. To address these challenges, an MLP network architecture was proposed for calibration factor prediction using pre-measured transit times and fluid temperature as inputs. The methodology encompasses data preprocessing, hyperparameter optimization, model training, and flow rate calculation using the predicted calibration factors.

The performance of the developed ANN-based flow measurement system was rigorously evaluated over a wide range of standard flow rates and was directly compared with the conventional cross-correlation method. The results demonstrate the superior accuracy and robustness of the ANN approach. The ANN exhibits a particularly notable improvement in accuracy at higher flow rates. Furthermore, the ANN maintains a tighter range of error across all flow conditions, indicating a more reliable and consistent performance. This enhanced accuracy is attributed to the ANN’s ability to learn complex, non-linear relationships directly from the measured transit-time and temperature data, effectively compensating for factors that can introduce inaccuracies in conventional methods.

For improvement in the calibration, we can effectively predict κ. The κ prediction is ideal for real-time use. Δt prediction, on the other hand, requires additional work. The dependence of Δt on t2 renders the MLP approach unusable. We plan to include some feature engineering to improve the reliability of the results. These findings suggest that machine learning can significantly enhance sensor calibration workflows, enabling more robust and adaptive solutions.

In summary, this work provides compelling evidence for the potential of ANNs to revolutionize ultrasonic flow metering by offering a more accurate and robust alternative to traditional signal processing techniques. The ability to learn intricate patterns from data makes the ANN approach a promising avenue for high-precision flow measurement in various industrial and daily-life applications.

While the findings of this study are encouraging, several avenues for future research warrant exploration. Firstly, the generalization capability of the trained ANN should be further investigated by evaluating its performance on different pipe sizes, materials, and fluid types. Secondly, assessing the robustness of the ANN model to varying levels and types of noise, as well as to sensor-to-sensor variability, is crucial for practical implementation. Thirdly, exploring the potential for real-time implementation of the ANN on embedded systems would be a significant step towards wider adoption. Finally, investigating the use of more advanced ANN architectures, such as Convolutional Neural Networks (CNNs) or RNNs, to potentially capture temporal dependencies within the ultrasonic signals more effectively, could lead to further enhancements in accuracy and robustness. Additionally, exploring explainable AI (XAI) techniques to gain insights into the features learned by the ANN could provide valuable information for optimizing the sensor design and deployment. Direct waveform-based learning for ToF estimation is a promising extension of this work and will be investigated in future studies.

  References

[1] Wang, Y.X., Li, Z.H., Zhang, T.H. (2010). Research of ultrasonic flow measurement and temperature compensation system based on neural network. In 2010 International Conference on Artificial Intelligence and Computational Intelligence, Sanya, China, pp. 268-271. https://doi.org/10.1109/AICI.2010.63

[2] Lin, Y., Hans, V. (2006). Improvement of ultrasonic cross-correlation measurement of gas flow by bluff body generated vortices. In XVIII Imeko World Congress, Rio de Janeiro, Brazil. https://www.imeko.org/publications/wc-2006/PWC-2006-TC9-016u.pdf.

[3] Nguyen, T.H.L., Park, S. (2020). Intelligent ultrasonic flow measurement using linear array transducer with recurrent neural networks. IEEE Access, 8: 137564-137573. https://doi.org/10.1109/ACCESS.2020.3012037

[4] Wang, Y.X., Li, Z.H. (2009). Temperature compensation of ultrasonic flow measurement based on the neural network. In 2009 International Conference on Artificial Intelligence and Computational Intelligence, Shanghai, China, pp. 21-24. https://doi.org/10.1109/AICI.2009.325

[5] Kuang, B., Nnabuife, S.G., Whidborne, J.F., Sun, S., Zhao, J., Jenkins, K. (2024). Self-supervised learning-based two-phase flow regime identification using ultrasonic sensors in an S-shape riser. Expert Systems with Applications, 236: 121414. https://doi.org/10.1016/j.eswa.2023.121414

[6] Zhao, H.C., Peng, L.H., Takahashi, T., Hayashi, T., Shimizu, K., Yamamoto, T. (2013). ANN based data integration for multi-path ultrasonic flowmeter. IEEE Sensors Journal, 14(2): 362-370. https://doi.org/10.1109/JSEN.2013.2282466

[7] Santhosh, K.V., Roy, B.K. (2015). A practically validated intelligent calibration technique using optimized ANN for ultrasonic flow meter. International Journal on Electrical Engineering and Informatics, 7(3): 379. https://doi.org/10.15676/ijeei.2015.7.3.2

[8] Hu, L., Qin, L.H., Mao, K., Chen, W.Y., Fu, X. (2016). Optimization of neural network by genetic algorithm for flowrate determination in multipath ultrasonic gas flowmeter. IEEE Sensors Journal, 16(5): 1158-1167. https://doi.org/10.1109/JSEN.2015.2501427

[9] Li, M.N., Li, Z.L., Li, C.H. (2023). In-use measurement of ultrasonic flowmeter based on machine learning. Measurement, 223: 113721. https://doi.org/10.1016/j.measurement.2023.113721

[10] Tavoularis, S., Nedić, J. (2024). Measurement in Fluid Mechanics. Cambridge University Press. 

[11] Landers, R.G., Barton, K., Devasia, S., Kurfess, T., Pagilla, P., Tomizuka, M. (2020). A review of manufacturing process control. Journal of Manufacturing Science and Engineering, 142(11): 110814. https://doi.org/10.1115/1.4048111

[12] Raissi, M., Yazdani, A., Karniadakis, G.E. (2020). Hidden fluid mechanics: Learning velocity and pressure fields from flow visualizations. Science, 367(6481): 1026-1030. https://doi.org/10.1126/science.aaw4741

[13] Barateiro, C.E.R., Makarovsky, C., de Farias Filho, J.R. (2020). Fiscal liquid and gaseous hydrocarbons flow and volume measurement: Improved reliability and performance paradigms for the fourth industrial revolution. Flow Measurement and Instrumentation, 74: 101773. https://doi.org/10.1016/j.flowmeasinst.2020.101773

[14] Meškuotienė, A., Kaškonas, P., Urbanavičius, B.G., Balčiūnas, G., Dobilienė, J. (2022). Analysis of liquid quantity measurement in loading/unloading processes in cylindrical tanks. Computation, 10(7): 122. https://doi.org/10.3390/computation10070122

[15] Liu, J.Y., Qin, K.Y., Zhen, L., Xiao, Y., Xie, G.D. (2020). How to allocate interbasin water resources? A method based on water flow in water-deficient areas. Environmental Development, 34: 100460. https://doi.org/10.1016/j.envdev.2019.100460

[16] Bello, O., Abu-Mahfouz, A.M., Hamam, Y., Page, P.R., Adedeji, K.B., Piller, O. (2019). Solving management problems in water distribution networks: A survey of approaches and mathematical models. Water, 11(3): 562. https://doi.org/10.3390/w11030562

[17] Malbrain, M.L., Wong, A., Nasa, P., Ghosh, S. (2024). Rational Use of Intravenous Fluids in Critically Ill Patients. Springer Nature. 

[18] Gupta, H., Arumuru, V., Jha, R. (2020). Industrial fluid flow measurement using optical fiber sensors: A review. IEEE Sensors Journal, 21(6): 7130-7144. https://doi.org/10.1109/JSEN.2020.3045506

[19] Kopp, J.G., Lipták, B.G. (2020). Variable-area, gap, and vane flowmeters. In Flow Measurement, pp. 162-169.

[20] Acosta-Zamora, K.P., Beltrán, A. (2022). Study of electromagnetically driven flows of electrolytes in a cylindrical vessel: Effect of electrical conductivity, magnetic field, and electric current. International Journal of Heat and Mass Transfer, 191: 122854. https://doi.org/10.1016/j.ijheatmasstransfer.2022.122854

[21] Leontidis, V., Cuvier, C., Caignaert, G., Dupont, P., Roussette, O., Fammery, S., Nivet, P., Dazin, A. (2018). Experimental validation of an ultrasonic flowmeter for unsteady flows. Measurement Science and Technology, 29(4): 045303. https://doi.org/10.1088/1361-6501/aab31e

[22] Mallepally, R.R., Bamgbade, B.A., Rowane, A.J., Rokni, H.B., Newkirk, M.S., McHugh, M.A. (2018). Fluid properties at high pressures and temperatures. The Journal of Supercritical Fluids, 134: 33-40. https://doi.org/10.1016/j.supflu.2017.12.016

[23] Oya, J.R.G., Fort, E.H., Miguel, D.N., Rojas, A.S., Carvajal, R.G., Chavero, F.M. (2023). Cross-correlation-based ultrasonic gas flow sensor with temperature compensation. IEEE Transactions on Instrumentation and Measurement, 72: 1-4. https://doi.org/10.1109/TIM.2023.3270928

[24] Mourched, B., Ferko, N., Abdallah, M., Neji, B., Vrtagic, S. (2022). Machine learning-enabled laser-based sensor for water determination. Applied Sciences, 12(13): 6693. https://doi.org/10.3390/app12136693

[25] Mourched, B., Abdallah, M., Hoxha, M., Vrtagic, S. (2023). Machine-learning-based sensor design for water salinity prediction. Sustainability, 15(14): 11468. https://doi.org/10.3390/su151411468

[26] Mourched, B., AlZoubi, T., Vrtagic, S. (2024). Diesel adulteration detection using a machine learning-enhanced laser sensor. Processes, 12(4): 798. https://doi.org/10.3390/pr12050798

[27] Nagendrappa, B.C., Anjaneyalu, M.B., Veerappa, S.M., Satish, E.G., Chandrasekhar, K. (2025). Optimizing wireless sensor networks with machine learning-based predictive maintenance for industrial internet of things. Mathematical Modelling of Engineering Problems, 12(3): 982-990. https://doi.org/10.18280/mmep.120324