Question

In fluid flow problems, the flow velocity in a long horizontal pipe depends on the pipe material, pipe geometry and fluid pro

solve using paython

0 0
Add a comment Improve this question Transcribed image text
Answer #1
https://trinket.io/python3/88d3a020eb

import matplotlib.pyplot as plt
import numpy as np
import math
def f(x):
e=0.025;
p=701;
mu=0.51e-3;
D=14.64;
tf=e/D;
fp=0.023
return 1/np.sqrt(fp)+2*np.log(tf/3.7065-5.0452*np.log((tf**1.3098)/2.8257+5.8506*(x**(-0.8981)))/x);
def fun(x):
e=0.025;
p=701;
mu=0.51e-3;
D=14.64;
tf=e/D;
yy=-2*np.log(tf/3.7065-5.0452*np.log((tf**1.3098)/2.8257+5.8506*(x**(-0.8981)))/x);
return 1.0/(yy*yy);
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("Reynolds number =",
round(x0, 6));
print("No. of iterations = ", n);
  
else:
print("Can not find a root in ",
"the given inteval");
return x0;
# Driver code
  
# initializing the values
x1 = 10;
x2 = 1000;
E = 0.001e-2;
Re=secant(x1, x2, E);
Re=np.linspace(3000,500000);
ff=fun(Re);
plt.plot(ff,Re);
plt.show();

Add a comment
Know the answer?
Add Answer to:
solve using paython 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