Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am trying to program code in Python that will generate the blue line in the graph. I have already sucessfully generated the red line
I am trying to program code in Python that will generate the blue line in the graph. I have already sucessfully generated the red line but my code for the blue one is not working. I will attach my code down below once I include the problem statement:
Problem: A centrifugal pump is used to pump water at deg C rho kgmmu x kgmsPv kPa from a reservoir whose surface is m below the centerline of the pump inlet. The pipe is PVC plastic smooth with an inner diameter of mm The pipe length from the submerged pipe inlet to the pump inlet is m There are only two minor losses in the piping system from the pipe inlet to the pump inlet: a sharpedged reentrant inlet KL and a flanged smooth deg regular elbow KLwe dont include a loss associated with the pump inlet itselfwere doing the balance at the point right before the pump entrance The pump manufacturer provides the required net positive suction head as a curve fit: NPSHrequiredm mLpm Q where Q is the volumetric flow rate in LPM Plot NPSH and NPSHrequired for this pump and estimate the maximum volume flow rate in units of Lpm that can be pumped without cavitation. You can approximate the kinetic energy correction factory as
Code thus far:
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
Problem
# Parameters
rho #kgm
mu e #kgms
Pv #Pa
z #m
KLtot
L #m
D #m
epsilon
Patm #Pa
g #ms
## Plot Required NPSH
# Generate flow rates
Q nplinspace # Lmin
# Calculate required NPSH for each flow rate
NPSHrequiredvalues Q
# Plot
pltplotQ NPSHrequiredvalues
pltxlabelFlow Rate Lmin
pltylabelNPSH m
plttitleNPSH vs Flow Rate'
pltgridTrue
pltxlim
pltylim
pltshow
# Colebrook equation
def colebrookeqf Re epsilon, D:
try:
return sqrtf logRe sqrtf
except ZeroDivisionError ValueError:
return floatinf
def calculateNPSHavailf v:
return Patm Pvrhog z f LD KLtotvg
# 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
f opt.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:
# Plot
pltplotQLpm NPSHavailvalues
pltxlabelFlow Rate Lmin
pltylabelNPSH Available m
plttitleNPSH Available vs Flow Rate'
pltgridTrue
pltxlim
pltylim
pltshow
Please verify that your answer generates the required graph
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started