import math """Function directory: 1. friction_loss 2. minor_loss 3. flow_velocity 4. area_of_circle 5. weir_sharp_crast 6. spillWay 7. critical_depth_rectanglar 8. weir_v_notch 9. critical_depth_circular """ def friction_loss(Q_gpm, D_diameter_in, L_length_ft, C_friction_loss_factor): """Function that calculates circular pipe friction headloss based on the Hazen-William equation. 7/25/2013 created by t. wang""" # Q_gpm = flow (gpm) # D_diameter_in = pipe diameter (in) # L_lenth_ft = pipe length (ft) # C_friction_loss_factor = Hazen-William C factor H = 10.452 * L_length_ft * (Q_gpm ** 1.85) / (C_friction_loss_factor ** 1.85) / (D_diameter_in ** 4.87) return H def minor_loss(Q_gpm, D_diameter, K_minor_loss_factor): """Function that calculates circular pipe minor headloss 7/25/2013 created by t. wang""" # Q_gpm = flow (gpm) # D_diameter (in) # K_minor_loss_factor = pipe fitting coefficients h = K_minor_loss_factor * (Q_gpm / 448.8 / (math.pi * (D_diameter / 12.0) ** 2.0 / 4)) ** 2 / (2 * 32.2) return h def area_of_circle(d): """Function that defines an area of a circle""" # d = diameter in inch # A = area in squire feet d = d/12.0 a = d**2 * float(math.pi/4) return a def flow_velocity(Q,D): """Function that calculate flow velocity in circular pipe""" # D = diameter (in) # Q = flow (gpm) A = area_of_circle(D) Q = Q / 448.8 V = Q / A return V def weir_sharp_crast(Q, L, Cw): """ Sharp crest weir calculation""" # Q = flow (gpm) # L = width of weir (feet) # Cw = weir conefficient h = (q / (L * Cw)) ** (2.0 / 3.0) return h def spillWay(CD, L, S): """Spill way water depth calculation""" # CD = critical depth (feet) # L = spill way length (feet) # S = slope h = (2 * CD ** 2 + (CD - S * float(L / 3)) ** 2) ** 0.5 - 2 * S * float(L / 3) return h def critical_depth_rectanglar(Q, W): """Critical depth calculation for rectangular channel""" # Q = flow (gpm) # W = width of channel (feet) h = ((Q / 448.83118) ** 2 / (32.2 * W ** 2)) ** (1.0 / 3.0) return h def weir_v_notch(Q, number_of_notch, Cw): """V-notch weir head loss calculation""" # Q = flow (gpm) # Cw = weir conefficient h = (Q / 448.83118 / (number_of_notch * Cw)) ** (2.0 / 5.0) return h def critical_depth_circular(Q, D): """Critical depth calculation for circular channel""" # Q = flow in (gpm) # D = diameter (in) h = (1.01 / (float(D / 12.0)) ** 0.26) * ((Q / 448.83118) ** 2 / (2.0 * 32.2)) ** 0.25 return h #import Hydraulics #import unit_conversion # function call from the module "Hydraulics": Q = float(raw_input('Flow ')) d = float(raw_input('Diameter ')) L = 11000 C = 140 K = 2.5 print ' = %d' %Q, '(gpm),', 6*' ', print 'Diameter = %d' %d, '(in),',6*' ', print 'Length = %d' %L, '(ft),', 6*' ', print 'C-Factor = %d' %C,',', 6*' ', print 'K-Factor = %.2f' %K print 180*'-' # function call from the module "Hydraulics": h = friction_loss(Q, d, L, C) h1 = minor_loss(Q, d, K) v = flow_velocity(Q,d) print'The friction loss is %.2f' %h, '(ft),',6*' ', print'The minor loss is %.2f' %h1, '(ft),',6*' ', print'The flow velocity is %.2f' %v, '(ft/s),',6*' ', P = 5.0 #f = unit_conversion.psi_to_feet(P) #print('The pressure head is %.2f' %f, 'feet, or %.2f' %P, '(psi)') f1 = critical_depth_circular(Q, d) print'critical_depth of pipe = %.2f' %f1, '(ft)'
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question