Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Procedure a Start Microsoft Excel. Open the Visual Basic Editor. Create a new mo

ID: 3746655 • Letter: P

Question

Procedure a Start Microsoft Excel. Open the Visual Basic Editor. Create a new module. You are going to create a moody friction factor function using the Haaland oqaation. Change the module name from modulel to Friction b. Create function haaland Re, eod). The function will determine the friction fatoe given the Reynolds Number and the relative roughness (D). Make sure you specify that variables Nr and cod are Double, and the function return vaue is Doble Laminar Flow Equation (Re 2000) 64 Re Turbulent Flow Equation (Re 4000) 691 3.7 Transition Flow Equation (2000Re 4000) aminar(4000- Re) +fTurbutene (Re-2000) 2000 N.B. I: n VBA. Log) is the matural log base e), nor bx Sppovides a log hase 10hon N.B.2: VBA does not anderstand brackets, owly parenthesis NB.3: VBd will not automatically solve an equation. The left side needs to be a ariable Function haaland f(Nr As Double, eod As Double) As Double skeleto code-you flesh out it statenent If (Nr ) Then Error condition haaland E- Elself (Nr2000) Then Laninar Flow haaland f-64./Nr Elself (N 4000) Then Turbulent Flow Your code here Else Transition Zone Your Code Heret Compute both Laminar and Turbulent herej then weighted avg End If End Function A standalone base 10 log function is strengly recommended Funetion log10_f(x As Double) As Double Compute the base 10 log of a number log10-1+ End Punetion log(X)/log(10#) d. Create a graph of Haaland friction factor. Format the table and the graph according to the class guidelines

Explanation / Answer

Answer:

Please find the screenshot and the vba code below.

Screenshot:

VBA Code:

Private Function log10_f(x As Double) As Double
    'Compute base 10 of a number
    log10_f = Log(x) / Log(10#)
End Function
Private Function fLaminar(Re As Double) As Double
    'Laminar f calculation
    fLaminar = 64# / Re
End Function
Private Function fTurbulent(Re As Double) As Double
    'Turbulent f calculation
    Dim f As Double
    f = (1 / (-1.8 * log10_f((((eod / 3.7) ^ 1.31) + (6.91 / Nr)))))
    fTurbulent = f * f
End Function
Private Function haaland_f(Nr As Double, eod As Double) As Double
    Dim f As Double
    'If statement
    If (Nr <= 0) Then
        'Error condition
        haaland_f = 0#
    ElseIf (Nr <= 2000) Then
        'Laminar flow
        haaland_f = fLaminar(Nr)
    ElseIf (Nr >= 4000) Then
        'Turbulent flow
        haaland_f = fTurbulent(Nr)
    Else
        'Transition zone
        haaland_f = ((fLaminar(4000 - Nr)) + (fTurbulent(Nr - 2000))) / 2000
    End If
End Function


Sub Friction()
    Dim Re As Double
    Dim eod As Double
    Dim result As Double
    Re = CDbl(InputBox("Please enter value of Reynold's Number (Re): "))
    eod = CDbl(InputBox("Please enter value of Relative Roughness (eod): "))
    result = haaland_f(Re, eod)
    MsgBox "Friction Value = " & result
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote