Haaland Friction Equation in Latex via Python

I’ll admit it is a weird title. For this entry I’d like to try out a library I saw Linkedin a few years ago that allegedly converts python code to nice Latex style images. This is to be applied to a script I wrote to estimate pressure-loss due to turbulent flows in pipes. Hopefully this will result in some nicer reports in the future!

The Haaland Equation

The Haaland Friction Equation provides a simple way to estimate the pressure loss of a fluid traveling in a pipe. Wall roughness and flow characteristics such as turbulence will cause the velocity of the fluid near the wall to slow down – thus increasing the overall velocity – which in turn causes a pressure loss.

One of the most popular explicit equations to approximate the friction coefficient caused by these flow characteristics is the Haaland Equation – developed by S.E Haaland in 1983 at NTNU.

Script and Latex Tests

The scripts has a few inputs; Velocity, Pipe Diameter, Pipe Length, Wall Roughness, Fluid Density and Dynamic Viscosity – from this we compute Reynolds numbers, Massflow, Turbulence Intensity and Length.

From this we can compute a head loss pressure and the flow coefficient Kv for simple geometries.

This is how the script looks after application of “handcalc” in a jupyter notebook.

%%render params 1
fluidDensity = 998*kg                 
fluidDynamicViscocity = 0.001* N/m #N/m
pipeDiameter = 0.210*m
pipeLength = 6.00*m
flowVelocity = 6.5*m/s 
epsilon = 8e-5*m                 #wall-roughness
gravity = 9.81*m/s**2.0
%%render 
Re = (fluidDensity*flowVelocity*pipeDiameter)/fluidDynamicViscocity
Le = 4.4*pow(Re.value, 1.0/6.0)*pipeDiameter
pipeArea = pi*(pipeDiameter/2.0)**2.0
Massflow = pipeArea*flowVelocity*3600*s #per hour
I = 0.16*pow(Re.value, -1/8.0)*100.0 #Dimensionless Turb-Intensity

This is AMAZING!

Combined with the forallpeople library that provides SI units this is kick-ass! There is guaranteed some knobs and switches which makes this extremely useful for any type of use for mechanical computations.

Out of the gate – this works fantastic! Will definitely try to use this for a few projects and report back!

References

Leave a Reply

Your email address will not be published.