In engineering, fluid flow and programming is a big deal. A thorough understanding of fluid flow fundamentals is a requirement for any mechanical engineer. Whether your sizing a pump for a pipeline, designing a heat exchanger, or trying to alleviate bottlenecks in pipeline gathering systems, fluid flow shows up in many cases in our profession/career. I want to demonstrate a step by step procedure to calculate frictional pressure losses in a pipeline for single phase incompressible flow using a hand calculation. Then I will demonstrate how to code this in excel VBA so the process is repeatable for different cases. To learn more watch my video. The sample code is presented below:
'Gives the pressure gradient in psi/ft in a pipeline
'Uses Oil and Gas Units
Function PressureLossgradbbl(Q, D, SG, u, e)
'Q: flow rate, bbl/day
'D: pipeline diameter, in
'SG: specific gravity
'u: viscosity, sp
'e: roughness, in
g = 32.2
A = WorksheetFunction.Pi() / 4 * D ^ 2
Re = Reynoldsbbl(SG, Q, D, u)
f = FrictionFactor(Re, e, D)
'Darcy Weasback Equation in psi/ft
PressureLossgradbbl = 0.433 * SG * (0.00105) * f * (1 / D) * ((Q / A) ^ 2) / (2 * g)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Reynolds number for pipeline flow
Function Reynoldsbbl(SG, Q, D, u)
'SG: Specific Gravity
'Q: Flow rate,(bbl/day)
'D: Diameter, in
'u: viscosity, cp
Reynoldsbbl = 92.35 * (SG * Q) / (D * u)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Friction Factor
Function FrictionFactor(Re, e, D)
'Re: Reynolds Number
'e: roughness, in
'laminar flow or turbulent('Swamee Jain Friction Factor)?
If Re < 2100 Then
FrictionFactor = 64 / Re
Else
A = e / (3.7 * D)
b = 5.74 / (Re ^ 0.9)
FrictionFactor = 0.25 / (WorksheetFunction.Log10(A + b) ^ 2)
End If
End Function
Amazing Video, Thanks!