Turbulent flow in a pipe
Sergio de Campos Junior
Algorithmics for Engineering Modeling
Master of Marine Technology: Hydrodynamics for Ocean Engineering (M-TECH HOE)
Introduction
The study of different flow regimes in pipelines is fundamental to understanding the behaviour of the velocity profile as a result of fluid transport. Predicting this profile makes it possible to understand the interaction of the flow with the pipeline and provide parameters, such as the mass flow rate, that make it possible to design the transport system—the power required for pumping and the thickness of the pipeline, for example. However, obtaining the velocity profile as a function of the pipeline radius requires understanding the flow regime—laminar, transient or turbulent—with which one expects to deal. Once the context is defined, it is possible to use the appropriate equation to estimate the velocity profile in the duct; this estimate, if compared with experimental data from an analogous regime, is inevitably subject to non-adherence.
This work aims to validate or not an estimate for the velocity profile in a duct whose turbulent flow is known experimentally. This estimate will be developed based on linear regressions made from a previously provided database containing data on the velocity profile collected in laboratory tests. The estimation itself comes from applying parameters to the equation that best describes the flow; these parameters, in turn, come from the interpolation prepared based on the regressions.
Finally, it is expected with this work to understand the importance of validating estimates with experimental data and practising computational techniques—such as linear regression, polynomial interpolation, and database parsing—viewed during classes, especially during the practical sessions.
Description of the problem
As exposed in the proposed problem statement, it is intended in this section to make clear the parameters and variables sufficient for the problem description. As already mentioned, turbulent flow is characterized by presenting chaotic behaviour, which implies the rapid variation of pressure and velocity in the field defined by the flow. A high Reynolds number characterizes such a chaotic regime—vide equation below—in this case, the instabilities are related to interactions between viscous terms and nonlinear inertial terms in the linear momentum equations.
Objective and procedure
the desired data is imported from the 6 ".txt" files, which are the databases;
address the data to their respective appropriate formats in the algorithm;
transform the velocity profile function (u(r) to u(y));
linearize the transformed function u(y);
modify the columns of the matrices containing the velocity and position in the duct cross-section so that they are in accordance with the linearized expression obtained in the previous step;
perform linear regression to find the straight line that best represents the data dispersion;
both the linear and angular coefficients of this straight line are determined; each must provide the parameters n and the maximum velocity Umax;
we perform the polynomial interpolation with the Lagrange method to obtain the polynomial that characterizes both functions n(Re) and Umax(Re);
we estimate n and Umax for Re = 35061 and determine the corresponding velocity profile through the equation u(y); and
the estimated data are compared with the experimental data through the percentage error, and the validation is concluded.
The following section explains the code implemented in Python 3.9 according to the described procedure and provides some considerations for running it in the Deepnote environment.
Implementation of the algorithm routine
The algorithm implementation considered what was presented during the practical sessions taught in the academic semester, from how to create functions in Python to how to perform linear regression and polynomial interpolation. Therefore, to obtain the expected results, it can be stated that all the techniques taught was somehow undertaken for the algorithm to be written—some attention will be given to the algorithm that performs linear regression and interpolation since it is understood that both are fundamental within the scope of this course.
The script is organized as follows:
firstly, the libraries understood to be essential for the algorithm to be appropriately executed by the compiler are imported. They are: re ("regular expression", package to help search and return expressions when reading imported files), math, NumPy and matplotlib.puplot;
next, the functions invoked as the compiler processes the script are defined. These are:
FindValue(fullstring), which receives a line in "str" format and returns the parameter values present in the header of the ".txt" file;
Read(filepath), which reads a ". txt" file and returns all the parameters of interest addressed correctly in their formats;
Linearization(DATA, R), which receives the matrix containing the velocity profile and the radius and returns this same matrix with values corrected by the linearization—already described in the previous section;
Linear_Regression(DATA, Re, R), which receives the matrix with the corrected velocity profiles and runs the linear regression, returning the linear and angular coefficients;
Interpolation(Ng, Ns, xi, fi, x), which in possession of its parameters performs the interpolation according to the Lagrange method and returns a list that represents the determined polynomial;
Error (u_exp, u_est), which in possession of both lists containing the experimental velocity and the estimated velocity, returns the percentual Error of both; and
the main() function, which has no parameters, invokes the other functions to execute the algorithm in an orderly fashion and is invoked at the end of the script.
The following subsections further detail the algorithms used to perform linear regression and interpolation according to methods seen during the practical sessions.
Linear Regression
Polynomial Interpolation: Lagrange method
The code: instructions and considerations
Since one is in Deepnote's environment, to execute the code, one needs to run the whole notebook or just the block that contains all the script—we chose in this work to keep the code agglutinated in a single executable block. If the script is executed in a compiler other than Deepnote, the argument of the Read(filepath) function, which is invoked right at the beginning of the main() function, must be modified since the files directory in another compiler will probably be different.
Considering this observation, all steps described in the section "Objective and procedure" should be executed, and all results should be "printed" on the screen so that it will be possible to validate or not the adherence of the estimated and experimental data—it is worth mentioning that the code is commented, which should facilitate its evaluation.
Coefficients of the linearized equation for Re = 5522.0 :
A = 1/n = 0.194 and B = ln(U_max) = 1.77
Coefficients of the linearized equation for Re = 9906.0 :
A = 1/n = 0.167 and B = ln(U_max) = 2.367
Coefficients of the linearized equation for Re = 21337.0 :
A = 1/n = 0.154 and B = ln(U_max) = 3.212
Coefficients of the linearized equation for Re = 31793.0 :
A = 1/n = 0.151 and B = ln(U_max) = 3.628
Coefficients of the linearized equation for Re = 39855.0 :
A = 1/n = 0.134 and B = ln(U_max) = 3.827
Estimated values of n [adm] and U_max [m/s]:
| n |U_max|
[[ 5.16 5.87]
[ 5.99 10.66]
[ 6.49 24.82]
[ 6.6 37.63]
[ 7.45 45.93]]
With interpolation, we estimate for Re = 35061, U_max = 41.22128 m/s and n = 6.83221
The error found between the experimental velocity profile and the estimated one for Re = 35061 is: 5.188 %
The code above should print all the steps already mentioned on the screen. If the present file in ".pdf" format prevents the complete visualisation of the results, they can be found in the following section: "Results and conclusion".
Results and Conclusion
Bibliographic References
BERNHARD. Fluid dynamics - Reynolds number and inertial force - Physics Stack Exchange. 2013. Available at: <https://physics.stackexchange.com/questions/80070/ reynolds-number-and-inertial-force>.
SIMSCALE. What is Reynolds Number? | SimWiki | SimScale. 2021. Available at: <https: //www.simscale.com/docs/simwiki/numerics-background/what-is-the-reynolds-number/>.
AJAYAKUMAR, V. Parsing text with Python · vipinajayakumar. 2018. Available at: <https://www.vipinajayakumar.com/parsing-text-with-python/>.