Question

In fluid flow problems, the flow velocity in a long horizontal pipe depends on the pipe material, pipe geometry and fluid pro use python program
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The code is given below.

import numpy as np
import matplotlib.pyplot as plt

# Given data
rho = 701       # [kg/m^3]
mu = 0.51e-3    # [Ns/m^2]
eps = 0.025e-2  # [m]
D = 14.64e-2    # [cm]
L = 3435        # [m]



def f(R):
    rf = eps/D
    f = (-2*np.log10(rf/3.7065 - 5.0452/R*np.log10(rf**1.1098/2.8257 + 5.8056*R**-0.8981)))**-2 - 0.023
    return f


def secant(x1, x2, E): 
    n = 0; xm = 0; x0 = 0; c = 0;  
    if (f(x1) * f(x2) < 0): 
        while True:  
              
            # calculate the intermediate value  
            x0 = ((x1 * f(x2) - x2 * f(x1)) / 
                            (f(x2) - f(x1)))  
  
            # check if x0 is root of  
            # equation or not  
            c = f(x1) * f(x0)  
  
            # update the value of interval  
            x1 = x2  
            x2 = x0  
  
            # update number of iteration  
            n += 1  
  
            # if x0 is the root of equation  
            # then break the loop  
            if (c == 0):  
                break  
            xm = ((x1 * f(x2) - x2 * f(x1)) / 
                            (f(x2) - f(x1))) 
              
            if(abs(xm - x0) < E): 
                break 
          
        #print("Root of the given equation =",  round(x0, 6))  
        #print("No. of iterations = ", n)  
          
    else: 
        print("Can not find a root in ", 
                   "the given inteval")
  
    return x0

# initializing the values  
x1 = 1e5  
x2 = 5e5
E = 0.001e-2  
Re = secant(x1, x2, E)  


# Velocity
V = mu*Re/rho/D

print("Reynolds Number =",  round(Re, 2))  
print("Velocity = ", round(V,4)," m/s") 

R = np.linspace(3e3,5e5,1000)
plt.plot(R,f(R)+0.023)
plt.xlabel("Reynolds Number")
plt.ylabel("Friction Factor")
plt.grid(True)

plt.show()

Output

Reynolds Number 395076.47 Velocity 1.9633 m/s =

0.045 0.040 0.035 Friction Factor 0.030 0.025 100 O 400 500000 200000 300000 Reynolds Number

Please rate the solution if found satisfactory.

Add a comment
Know the answer?
Add Answer to:
use python program In fluid flow problems, the flow velocity in a long horizontal pipe depends...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT