Question

In: Computer Science

PYTHON!!!! Exercise 1 - Darcy-Weisbach GUI Let's combine all of our Darcy-Weisbach formulas, give it a...

PYTHON!!!!

Exercise 1 - Darcy-Weisbach GUI

Let's combine all of our Darcy-Weisbach formulas, give it a graphical interface (and finally put it to rest!).

Combine your Darcy-Weisbach formula from Assignment 4 with your improved function for fD for turbulent flow in Assignment 6 (leave it as a function and have your formula call it for the turbulent flow condition). Then create a GUI for your formula to enter the length, diameter and velocity input values, and display the resulting pressure drop. Make sure to give your window a title and include Calculate and Close (or "Quit") buttons.

Solutions

Expert Solution

The head loss Δh (or hf) expresses the pressure loss due to friction in terms of the equivalent height of a column of the working fluid, so the pressure drop is

{\displaystyle \Delta p=\rho g\,\Delta h,}

where

Δh is the head loss due to pipe friction over the given length of pipe (SI units: m);

g is the local acceleration due to gravity (m/s2)

It is straightforward to calculate the pressure drop of fluid flowing in a pipeline with any number of fittings using the fluids library’s fluids.fittings submodule.

15 m of piping, with a sharp entrance and sharp exit, two 30 degree miter bends, one rounded bend 45 degrees, 1 sharp contraction to half the pipe diameter and 1 sharp expansion back to the normal pipe diameter (water, V=3 m/s, Di=0.05, roughness 0.01 mm):

code

>>> Re = Reynolds(V=3, D=0.05, rho=1000, mu=1E-3)
>>> fd = friction_factor(Re, eD=1E-5/0.05)
>>> K = K_from_f(fd=fd, L=15, D=0.05)
>>> K += entrance_sharp()
>>> K += exit_normal()
>>> K += 2*bend_miter(angle=30)
>>> K += bend_rounded(Di=0.05, angle=45, fd=fd)
>>> K += contraction_sharp(Di1=0.05, Di2=0.025)
>>> K += diffuser_sharp(Di1=0.025, Di2=0.05)
>>> dP_from_K(K, rho=1000, V=3)
37920.5114014637

If the diameter of the piping varies, not all of the loss coefficients will be with respect to the same diameter. Each loss coefficient must be converted to one standard diameter before the total pressure drop can be calculated. The following example is solved with the optional pint unit compatibility module.

40 m piping, beveled entrance (10 mm length, 30 degrees, into 5 cm ID pipe) , then a 30 degree miter bend, a sharp contraction to half the pipe diameter (5 m long), a 30 degree miter bend, a rounded 45 degree bend, a sharp expansion to 4 cm ID pipe (15 more meters), and a sharp exit:

>>>

>>> from fluids.units import *
>>> from math import *
>>> material = nearest_material_roughness('steel', clean=True)
>>> epsilon = material_roughness(material)
>>> Q = .01*u.m**3/u.s
>>> rho = 1000*u.kg/u.m**3
>>> mu = 1E-4*u.Pa*u.s
>>> D1 = 5*u.cm
>>> D2 = 2.5*u.cm
>>> D3 = 4*u.cm
>>> L1 = 20*u.m
>>> L2 = 5*u.m
>>> L3 = 15*u.m
>>> V1 = Q/(pi/4*D1**2)

>>>

>>> Re = Reynolds(V=V1, D=D1, rho=rho, mu=mu)
>>> fd = friction_factor(Re, eD=epsilon/D1)
>>> K = K_from_f(fd=fd, L=L1, D=D1)
>>> K += entrance_beveled(Di=D1, l=10*u.mm, angle=30*u.degrees)
>>> K += bend_miter(angle=30*u.degrees)
>>> K += contraction_sharp(Di1=D1, Di2=D2)

>>>

>>> V2 = Q/(pi/4*D2**2)
>>> Re2 = Reynolds(V=V2, D=D2, rho=rho, mu=mu)
>>> fd2 = friction_factor(Re2, eD=epsilon/D2)

>>>

>>> K += change_K_basis(K_from_f(fd=fd2, L=L2, D=D2), D1=D2, D2=D1)
>>> K += change_K_basis(K1=bend_miter(angle=30*u.degrees), D1=D2, D2=D1)
>>> K += change_K_basis(K1=bend_rounded(Di=D2, angle=45*u.degrees, fd=fd2), D1=D2, D2=D1)

>>>

>>> V3 = Q/(pi/4*D3**2)
>>> Re3 = Reynolds(V=V3, D=D3, rho=rho, mu=mu)
>>> fd3 = friction_factor(Re3, eD=epsilon/D3)

>>>

>>> K += change_K_basis(K_from_f(fd=fd3, L=L3, D=D3), D1=D3, D2=D1)
>>> K += diffuser_sharp(Di1=D2, Di2=D3)

>>>

>>> dP_from_K(K, rho=rho, V=V1)
<Quantity(734959.105, 'pascal')>

Related Solutions

Using Python 1. #Now, let's improve our steps() function to take one parameter #that represents the...
Using Python 1. #Now, let's improve our steps() function to take one parameter #that represents the number of 'steps' to print. It should #then return a string that, when printed, shows output like #the following: # #print(steps(3)) #111 #   222 #       333 # #print(steps(6)) #111 #   222 #       333 #           444 #               555 #                   666 # #Specifically, it should start with 1, and show three of each #number from...
Business Statistics A more practical method presents itself:: Let's redo our broker exercise with this modification:...
Business Statistics A more practical method presents itself:: Let's redo our broker exercise with this modification: A. how many standard deviations are the lower and upper bounds from the mean (of the sampled means)? B. Can we use this thought to solve any confidence interval with a flick of the algorithmic finger? C. What happens if we do not know the population mean or standard deviation (oh my!)?
Please define all types of costs in a production process. Give the formulas of calculation if...
Please define all types of costs in a production process. Give the formulas of calculation if necessary. Also, you should strengthen your answers by giving examples for each type of cost functions.
please define all types of costs in a production process? give the formulas of caculations and...
please define all types of costs in a production process? give the formulas of caculations and also give example for each type of cost functions
Regarding Python and Scripting 1. What SQL clause is used to combine rows from two or...
Regarding Python and Scripting 1. What SQL clause is used to combine rows from two or more tables, based on a related column in a relational database. Question options: CONNECT JOIN WHERE 2. The highlighted portion of this program output indicates ____________. Tracks: (u'Thunderstruck', 20) (u'My Way', 15) Question options: Unknown values that are recently inserted into the Tracks table Unicode strings that are capable of storing non-Latin character sets Universal variables that can fit into any column 3. In...
4.9 Branching Practice - Python Exercise #Write the code for the following # Exercise 1 #...
4.9 Branching Practice - Python Exercise #Write the code for the following # Exercise 1 # Ask user for a number using an input statement (no prompt) & assign the input to a variable # Convert the user entry to an integer and assign it to a variable # Condition: user entry is greater than zero # Action: display the following word on screen: positive # Exercise 2 # Ask user for a number using an input statement (no prompt)...
Question: Combine the NET ionic equations of Reaction 1 and Reaction 2 to give the equation...
Question: Combine the NET ionic equations of Reaction 1 and Reaction 2 to give the equation for the ionization of acetic acid. Reaction 1 Full Ionic Equation: H+(aq) + Cl-(aq) + Na+(aq) + OH-(aq) —> Na+(aq) + Cl-(aq) + H2O(l) Reaction 1 Net Ionic Equation: H+(aq) + OH-(aq) —> H2O (l) Reaction 2 Full Ionic Equation: H+(aq) + C2H3O2-(aq) + Na+(aq) + OH-(aq) —> Na+(aq) + C2H3O2-(aq) + H2O(l) Reaction 2 Net Ionic Equation: H+(aq) + OH-(aq) —> H2O(l) Explain...
Python Exercise 2 A program is to display all odd numbers between 10 and 3000. The...
Python Exercise 2 A program is to display all odd numbers between 10 and 3000. The starting value and end value are to be assigned by the programmer, not requested from user.
Please give the excel formulas and steps details Financial ratio data elements (all in $ million...
Please give the excel formulas and steps details Financial ratio data elements (all in $ million except per share data):   Ratio Ratio Value Industry Average Better or worse Current_assets     14,277 Current 1.3 Current_liabilities       7,687 Quick 0.9 Inventory       4,034 Inventory_turnover 23.6 Cost_of_goods_sold     14,371 DSO 61.6 Accounts_receivable       4,911 Fixed_assets_turnover 3.8 Annual_sales     31,657 Total_assets_turnover 0.7 Net_fixed_assets       8,866 Debt_ratio (%) 75.3% Total_assets     37,987 Times_interest_earned 15.3 Total_liabilities     26,365 Net_profit_margin (%) 0.2 EBIT       7,333 ROA (%)...
Please use excel and show all work and formulas. (I will give your work a like...
Please use excel and show all work and formulas. (I will give your work a like if you do this) Size (1000s sq. ft) Selling Price ($1000s) 1.26 117.5 3.02 299.9 1.99 139.0 0.91 45.6 1.87 129.9 2.63 274.9 2.60 259.9 2.27 177.0 2.30 175.0 2.08 189.9 1.12 95.0 1.38 82.1 1.80 169.0 1.57 96.5 1.45 114.9 What are the p-values of the t test (for the slope estimate) and F test? What is the coefficient of determination? What is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT