Answered step by step
Verified Expert Solution
Link Copied!

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 25\deg C (\rho =997.0 kg/m^3,\mu =8.91x10^(-4) kg/(ms),P_v=3.169 kPa) from a reservoir whose surface is 2.2 m below the centerline of the pump inlet. The pipe is PVC plastic (smooth) with an inner diameter of 24.0 mm. The pipe length from the submerged pipe inlet to the pump inlet is 2.8 m. There are only two minor losses in the piping system from the pipe inlet to the pump inlet: a sharp-edged reentrant inlet (K_L=0.85) and a flanged smooth 90\deg regular elbow (K_L=0.3)(we 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: NPSH_required=2.2m+(0.0013 m/(Lpm^2)) Q^2 where Q is the volumetric flow rate in LPM. Plot NPSH and NPSH_required 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 1.
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, log10
Problem 1
# Parameters
rho =997.0 #kg/m^3
mu =8.91e-4 #kg/m*s
Pv =3169 #Pa
z =2.2 #m
KL_tot =1.15
L =2.8 #m
D =0.024 #m
epsilon =0
P_atm =101325 #Pa
g =9.81 #m/s^2
## Plot Required NPSH
# Generate flow rates
Q = np.linspace(0,100,100) # L/min
# Calculate required NPSH for each flow rate
NPSH_required_values =2.2+0.0013* Q **2
# Plot
plt.plot(Q, NPSH_required_values)
plt.xlabel('Flow Rate (L/min)')
plt.ylabel('NPSH (m)')
plt.title('NPSH vs Flow Rate')
plt.grid(True)
plt.xlim(0,100)
plt.ylim(0,12)
plt.show()
# Colebrook equation
def colebrook_eq(f, Re, epsilon, D):
try:
return 1/ sqrt(f)+2* log10(2.51/(Re * sqrt(f)))
except (ZeroDivisionError, ValueError):
return float('inf')
def calculate_NPSH_avail(f, v):
return ((P_atm - Pv)/(rho*g))- z -(((f * L)/D + KL_tot)*((v**2)/2*g))
# Generate flow rates
Q_m3s = np.linspace(0.1,200,100)
# Calculate NPSH available for each flow rate
NPSH_avail_values =[]
for Q in Q_m3s:
v = Q /(pi *(D /2)**2)
Re =(rho * v * D)/ mu
f = opt.fsolve(colebrook_eq,0.02, args=(Re, epsilon, D))[0]
NPSH_avail = calculate_NPSH_avail(f, v)
NPSH_avail_values.append(NPSH_avail)
# Convert to Lpm
Q_Lpm = Q_m3s #*60*1000
# Print the first few values of Q_Lpm and NPSH_avail_values
print("Flow Rates (L/min):", Q_Lpm[:5])
print("NPSH Available (m):", NPSH_avail_values[:5])
# Plot
plt.plot(Q_Lpm, NPSH_avail_values)
plt.xlabel('Flow Rate (L/min)')
plt.ylabel('NPSH Available (m)')
plt.title('NPSH Available vs Flow Rate')
plt.grid(True)
plt.xlim(0,200)
plt.ylim(0,20)
plt.show()
**Please verify that your answer generates the required graph**
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

What is the purpose of a competitor analysis?

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago