Weirs are commonly used to measure flow at small creeks and other flow systems. We have developed a simple Python function to calculate the discharge from a weir “discharge_weir(C,L,H,n)”. We will check our results using two formulas -Addition formula and Francis formula.
==========================================
def discharge_weir(C,L,H,n): #Weirs allow hydrologists and engineers a simple method of measuring #the volumetric flow rate in small to medium-sized streams # Function for the discharge equation by Addition in 1949, for TRAPEZOIDAL WEIR ''' Q is flow rate C is a constant for structure, when flow in cfs, C=3.37 L is the width of the crest in FEET H is the height of head of water over the crest in FEET n varies with structure (e.g. 3/2 for horizontal weir, 5/2 for v-notch weir) ''' return round(C*L*(H**n),2), 'is the flow in CFS using Addition (1949) formula' ''' for RECTANGULAR WEIRS: The flow rate measurement in a rectangular weir is based on the Bernoulli Equation principles and can be expressed as: Q = 2/3 C L (2 g)1/2 H^(3/2) where Q = flow rate (m3/s) H = head on the weir (m) L = width of the weir (m) g = 9.81 (m/s2) - gravity C= discharge constant for the weir - must be determined ''' #The Francis Formula - Imperial Units def discharge_weir_Francis(C,L,H,n): '''Flow through a rectangular weir can be expressed in imperial units with the Francis formula Q = 3.33 (L - 0.2 H) H^(3/2) where Q = flow rate (ft3/s) H = head on the weir (ft) L = width of the weir (ft) C=3.33 n=3/2=1.5 ''' return round(C*(L-0.2*H)*(H**n),2), 'is the flow in CFS using Francis formula' print discharge_weir(3.37,3.0,2.0,1.5) print discharge_weir_Francis(3.33,3.0,2.0,1.5)
Output
(28.6, 'is the flow in CFS using Addition (1949) formula') (24.49, 'is the flow in CFS using Francis formula'
Run the program online by calling the Python Function:
http://www.codeskulptor.org/#user20_ONn0eFrNzO_2.py