Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please solve this using python coding. Thank you. will give thumbs up. Here is a stem file 6 (10 pts) A pipe-flow fluids

Can someone please solve this using python coding.
Thank you. will give thumbs up.
image text in transcribed
Here is a stem file image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
6 (10 pts) A pipe-flow fluids problem: Oil with a density (p=950 kg/m) and kinematic viscosity (v=2x10 m/s) flows through a 30-cm-diameter (d=0.3m) pipe that is 100 m long with a head loss of h = 8 m. The roughness ratio of the pipe is (e/d=0.0002) and we can assume the flow is turbulent. Find the average velocity (1) and flow rate (Q=V_A) for the oil. g=9.81 m/s? LV ,- d 28 2.51 We can calculate the head loss using the Darcy friction factor as: ga--2.0108( where, the friction factor is given by: 3.7 'Re, where, Re, Vid 1. Write a function def Reynolds (V, nu,d): to calculate Reynolds number b. Write a function def FrictionFactor (relrough, Re): to calculate the friction factor c. Write a function def Avgvel (nu, dia, length): to calculate the average velocity of the oil d. Write a function def main(): to call AvgVel with the appropriate parameters and print to the screen the average oil velocity and volumetric flow rate (with units). c. Finally, in your main function, determine the diameter of pipe necessary for a head loss of only 6m in a 100m long pipe, keeping viscosity and flow rate constant. Notes: The velocity V is unknown in parts a., b., and c as are the friction factor and Reynolds numbers. You will likely need to use your secant method to iteratively find the solution. According to the Moody diagram for friction factors, 0.008 when guess correct if II pass T = # use the secant method to find the friction factor return f # part c def Avqvel (nu, dia, length, loss): Given a head loss, pipe diameter, viscosity and pipe length, I use the secant method to match the head loss (see eqn on assignment) to the given/desired head loss by changing the velocity. Of course, changing velocity also changes Re and f, so those need to be recalculated for every value of velocity that the secant method tries. :param nu: the kinematic viscosity iparam dia: the pipe diameter param length: the pipe length param loss: the given head loss :return: the average velocity of the fluid in the pipe !!! relrough = 0.0002 # pipe roughness (see assignment) 9.81 # gravity :param dia: the pipe diameter iparam length: the pipe length :param Loss: the given head loss :return the average velocity of the fluid in the pipe 1 D relrough = 0.0002 # pipe roughness (see assignment) g = 9.81 # gravity def Findy(V): # I'll make this a callback function for Secant pass AV = # use secant method to find average velocity return AV 10 1 2 *3 # part d # part d Edef main(): Main function for solving parts d) and e). We have three equations given. Each has V in it. We need to use the secant method to find the root (1.e., correct value of V) to match the given head loss in part d) to that calculated by the first equation (ht=(9*****2)/(d+2+g)). Of course, changing V also changes Re and S, so those need to be recalculated for every guess of V in the secant method search for the correct value of v. In part e), Q is fixed, but we seek to find the pipe diameter that will reduce the head loss to only on (1.e., potentially selecting a new pipe for a new pipeline design). Increasing pipe diameter will reduce v and thus, change and Re, so these three values will have to be recalculated each time I guess a new diameter in the secant function. Areturn: # Part d): first find the average velocity for head loss of an # Part d): first find the average velocity for head loss of 8m nu = 2E-5 # the kinematic viscosity in m^2/s dia = 0.30 # the original pipe diameter in m = 100 # the pipe length in m loss = 8 # the original head loss in m 9 = 9.81 # acceleration of gravith m/s^2 V # call to calculate the average velocity of oil in the pipe print("Average Velocity = {:0.41} m/s".Format(V)) Q = # calculate the volumetric flow rate in m^3/sec print("The flow rate = {:0.46) 3/s".Format(Q)) # Part e: now, use the Secant nethod to find a diameter that gives on of head loss for the same target = 6 relrough = 0.0002 det hl(a): # a function to calculate head loss given Q and d target = 6 relrough = 0.0002 def hl(d): # a function to calculate head Loss given Q and a Here, we are varying d and calculating head loss for a fixed Q. Varying d changes V, Re, J. and head loss Raram d: the pipe diameter :return: head loss pass fcn = lambda d: # use this function (difference between hl(a) and target) as the callback for secant dL =_ #use secant function to find value for diameter to match target head loss print("Diameter for {:0.11} m of head loss = {:0.38) m".Format(target, dL))

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

Step: 3

blur-text-image

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

LO12.3 Explain how demand is seen by a pure monopoly.

Answered: 1 week ago