Hi,
I'm new to VBA so please bear with me.
I'm trying to create a UDF function that will calculation turbulent friction faction using churchill equation
The arguments include reynolds number, absolute roughness (mm), internal diameter (mm).
I've followed several tutorials in formulating the following code but the only results i get is either 0 or a #value error.
I would appreciate if someone can point out where i am going wrong?
Thanks in advance
I'm new to VBA so please bear with me.
I'm trying to create a UDF function that will calculation turbulent friction faction using churchill equation
The arguments include reynolds number, absolute roughness (mm), internal diameter (mm).
I've followed several tutorials in formulating the following code but the only results i get is either 0 or a #value error.
Code:
Public Function turbulentFrictonFactor(reynoldsNumber As Double, absoluteRoughness As Double, internalDiameter As Double) As Double
'Constants declaration
Dim constB As Double
Dim constC As Double
Dim denominator1 As Double
Dim denominator2 As Double
Dim denominatorSum As Double
Dim item1 As Double
Dim item2 As Double
'Calculation of constB
denominator1 = (7 / reynoldsNumber) ^ 0.9
denominator2 = 0.27 * (absoluteRoughness / internalDiameter)
denominatorSum = denominator1 + denominator2
constB = (2.457 * Log(1 / denominatorSum)) ^ 16
'Calculation of constC
constC = (37530 / reynoldsNumber) ^ 16
'Calculation of turbulent friction factor.
'where item1 = (8/Re)^12
'where item2 = 1/(B+C)^1.5
item1 = (8 / reynoldsNumber) ^ 12
item2 = 1 / (constB + constC) ^ 1.5
turbulentFrictionFactor = 8 * (item1 + item2) ^ 1 / 12
End Function
I would appreciate if someone can point out where i am going wrong?
Thanks in advance