Question: Given the following parameters, use the Colebrook equation, the formula for Reynold's number, and v = Q / A as well as the following formula
Given the following parameters, use the Colebrook equation, the formula for Reynold's number, and v QA as well as the following formula for NPSHavail with the end goal of creating a plot in Python that graphs NPSHavail in m vs volumetric flow rate Q in Liters per minute NPSHavail f vall in SI units
Note: I have already tried to figure this out but my code keeps not working. I have attached my code below:
import numpy as np
import scipy.optimize as opt
from scipy.optimize import fsolve
import matplotlib.pyplot as plt
from math import pi sqrt log
# Parameters
rho #kgm
mu e #kgms
Pv #Pa
z #m
KLtot
L #m
D #m
epsilon
Patm #Pa
g #ms
df # Colebrook equation
def colebrookeqf Re epsilon, D:
try:
return sqrtf logRe sqrtf
except ZeroDivisionError ValueError:
return floatinf
# NPSH Available
def calculateNPSHavailf v:
return f v
# Generate flow rates
Qms nplinspace
# Calculate NPSH available for each flow rate
NPSHavailvalues
for Q in Qms:
v Q pi D
Re rho v D mu
initialguess max Re D Q
f fsolvecolebrookeq argsRe epsilon, D
NPSHavail calculateNPSHavailf v
NPSHavailvalues.appendNPSHavail
# Convert to Lpm
QLpm Qms
# Print the first few values of QLpm and NPSHavailvalues
printFlow Rates Lmin: QLpm:
printNPSH Available m: NPSHavailvalues:
# Check for NaN or infinite values in NPSHavailvalues
printNaN or Infinite values:", npisnanNPSHavailvaluesany or npisinfNPSHavailvaluesany
# Plot
pltplotQLpm NPSHavailvalues
pltxlabelFlow Rate Lmin
pltylabelNPSH Available m
plttitleNPSH Available vs Flow Rate'
pltgridTrue
pltxlim
pltylim
pltshow
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
