Skip to content

Instantly share code, notes, and snippets.

@ewancook
Created March 23, 2019 16:41
Show Gist options
  • Save ewancook/aa4082446842efb85c5b94f814957872 to your computer and use it in GitHub Desktop.
Save ewancook/aa4082446842efb85c5b94f814957872 to your computer and use it in GitHub Desktop.
Darcy Friction Factor (VBA)
Function f(e, D, Re)
' Returns: Darcy friction factor
' Parameters:
' e: absolute roughness
' D: duct diameter
' Re: Reynold's number
A = -2 * Log10(e / D / 3.7 + 12 / Re)
B = -2 * Log10(e / D / 3.7 + 2.51 * A / Re)
C = -2 * Log10(e / D / 3.7 + 2.51 * B / Re)
f = (A - (B - A) ^ 2 / (C - 2 * B + A)) ^ -2
End Function
Private Function Log10(x)
Log10 = Log(x) / Log(10)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment