0% found this document useful (0 votes)
251 views8 pages

Weir Design Code

This document contains code to calculate the design parameters for a weir and stilling basin. It includes: 1) Hydraulic calculations to determine parameters like specific discharge, scour depth, velocity head, and water levels. 2) Calculation of design dimensions for the weir, stilling basin components like chute blocks and basin blocks, and cutoff walls. 3) Determination of uplift pressures and correction factors to tabulate design values for pile sizes. The code imports necessary libraries, gets user input for site parameters, performs calculations, prints output, and designs the structural components of the weir and stilling basin system.

Uploaded by

Sushant Dahal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
251 views8 pages

Weir Design Code

This document contains code to calculate the design parameters for a weir and stilling basin. It includes: 1) Hydraulic calculations to determine parameters like specific discharge, scour depth, velocity head, and water levels. 2) Calculation of design dimensions for the weir, stilling basin components like chute blocks and basin blocks, and cutoff walls. 3) Determination of uplift pressures and correction factors to tabulate design values for pile sizes. The code imports necessary libraries, gets user input for site parameters, performs calculations, prints output, and designs the structural components of the weir and stilling basin system.

Uploaded by

Sushant Dahal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

import numpy as np

from scipy.optimize import minimize


from scipy.optimize import fsolve
import math

#Input of Necessary Data


Q = float(input('Enter the flood discharge for required time period'))
BL = float(input('Enter the average bed level of river'))
w = float(input('Enter the weir height'))
CrestLevel = BL + w
Lw = float(input('Enter the lenth of weir'))
dmm = float(input('Enter the grain size in mm'))
Cd = float(input('Enter the coefficient of discharge for weir'))
Gc = float(input('Enter the specific gravity for concrete'))
Gb = float(input('Enter the specific gravity for boulder'))
Gp = float(input('Enter the specific gravity for plum concrete'))

#HYDRAULIC CALCULATIONS
q = Q / Lw #specific discharge
print('The specific discharge is=',q)
f = 1.76 * ((dmm)**(0.5)) #silt factor
print('The silt factor is=',f)
R = round((1.35 * ((q ** 2) / f) ** (1 / 3)),2) #ScourDepth
print('The scour depth is=',R)
R_Velocity = round((q / R),2) #Regime Velocity
print('The regime velocity is=',R_Velocity)
Velocity_Head = round((((R_Velocity) ** 2) / (2 * 9.81)),2) #VelocityHead
print('The velocity head is=',Velocity_Head)
Ho = (Q/(Cd*Lw))**(2/3) #HeadOverCrest
print('The head over crest is=',Ho)

#In design of Weir, we have only considered: HIGH FLOOD CONDITION

ds_TEL = BL + Ho
print('The downstream TEL is=',ds_TEL)
ds_HFL = ds_TEL - Velocity_Head
print('The downstream HFL is=',ds_HFL)
us_TEL = CrestLevel + Ho
print('The upstream TEL is=',us_TEL)
us_HFL = us_TEL - Velocity_Head
print('The upstream HFL is=',us_HFL)
HeadLoss = us_TEL - ds_TEL
print('The headloss is=',HeadLoss)

#Calculation of Other parameters from Headloss, q and DS TEL


def equation(q,HL,dsTEL):
x2 = (2 * (q ** 2) / 9.81) / ((4 * HL) ** 3)

def f(m):
return (((m ** 4) * (m + 1)) / ((m - 1) ** 9)) - x2

solver = fsolve(f, 1.01)


y1 = np.around((4 * HL * solver) / ((solver - 1) ** 3),2)
y2 = np.around(solver * y1,2)
v1 = q / y1
v2 = q / y2
yc = np.around(((q**2)/9.81)**(1/3),2)
Ef1 = np.around(y1 + ((v1**2)/(2 * 9.81)),2)
Ef2 = np.around(y2 + ((v2**2)/(2 * 9.81)),2)
L_concretefloor= np.around(5 * (y2 - y1),2)
froude_number = np.around(q / (9.81*(y1**3))**(0.5),2)
JumpFormationLevel = np.around(dsTEL - Ef2,2)
return (yc,y1,y2,Ef1,Ef2,L_concretefloor,froude_number,JumpFormationLevel)

[ayc,ay1,ay2,aEf1,aEf2,aL_concretefloor,afroude_number,aJumpFormationLevel]=equatio
n(q,HeadLoss,ds_TEL)
JumpFormingLevel= np.round(aJumpFormationLevel-0.2,1)

print('The critical depth is=',ayc)


print('The initial depth, y1=',ay1)
print('The sequent depth, y2=',ay2)
print('The Energy before jump, Ef1=',aEf1)
print('The Energy after jump, Ef2=',aEf2)
print('Froude Number, F1=',afroude_number)
print('The Jump Formation Level is=',aJumpFormationLevel)
print('The RL of downstream floor is taken as=',JumpFormingLevel)

#Stilling Basin Design


print('Since the value of Fr is',afroude_number,',according to IS 4997:1968, the
basin is of Type I')

#Length of stilling basin


length1_SB = ay2 * (-0.00123*(afroude_number**3)-
0.0891*(afroude_number**2)+1.2844*afroude_number+1.0465) #This equation was found
by digitizing the graph in IS 4997:1968
length_SB = math.ceil(length1_SB)
print('The length of stilling basin is',length_SB)

#Design of appurtenant structures

#ChuteBlocks
heightCB = 2* ay1
toplengthCB = 2*ay1
widthCB = ay1
spacingCB = 2.5*ay1
leaveAlongEachWall = ay1/2

print('The dimensions of Chute Blocks:')


print('Height=',heightCB)
print('Top Length=',toplengthCB)
print('Width=',widthCB)
print('Spacing between blocks=',spacingCB)
print('Length to be left along each wall=',leaveAlongEachWall)

#BasinBlocks
heightBB = ay1 * ((10**(-5))*(afroude_number**5)-
0.0007*(afroude_number**4)+0.015*(afroude_number**3)-
0.1507*(afroude_number**2)+0.8717*afroude_number-0.5265)
topWidthBB = 0.2 *heightBB
widthBB = heightBB
spacingBB = heightBB
distbetCBandBB = 0.8 * ay2

print('The dimensions of Basin Blocks:')


print('Height=',heightBB)
print('TopWidth=',topWidthBB)
print('Width=',widthBB)
print('Spacing between blocks=',spacingBB)
print('Distance between chute blocks and basin blocks=',distbetCBandBB)

#Endsill
heightES = 0.2 * ay2
lengthES = 2 * heightES
widthES = 0.15 * ay2
spacingES = 0.15 *ay2
topcrestES = 0.02* ay2
numberofesb = math.ceil((Lw+spacingES)/(spacingES+widthES))

print('The dimensions of Endsill:')


print('Height=',heightES)
print('Length=',lengthES)
print('Width=',widthES)
print('Spacing between sills',spacingES)
print('Dimension of top crest',topcrestES)
print('Number of End Sill blocks=',numberofesb)

#CutOff Wall Design


#Here the depth of cutoff is considered 1.5R for us and ds cases

#US Cutoff Wall


usCutoffDepth = 1.5 * R
usCutoffLevel = us_HFL - usCutoffDepth

print('The cutoff wall depth for upstream is=',usCutoffDepth)


print('The cutoff wall depth RL is=',usCutoffLevel)

if usCutoffLevel>BL or (usCutoffLevel-BL)<2:
print('If you are seeing this, either there is no need of cutoff wall or the
depth of cutoff wall calculated is less than 2m')
new = float(input('Assume a depth of cutoff wall for stability purposes'))
usCutoffDepth = new
usCutoffLevel = BL - usCutoffDepth
else:
usCutoffLevel = us_HFL - usCutoffDepth

print('The RL of cutoff wall below BL in us=',BL-usCutoffDepth)

#DS Cutoff Wall


dsCutoffDepth = 1.5 * R
dsCutoffLevel = ds_HFL - dsCutoffDepth

print('The cutoff wall depth for downstream is=',dsCutoffDepth)


print('The cutoff wall depth RL is=',dsCutoffLevel)

if dsCutoffLevel>JumpFormingLevel or (usCutoffLevel-JumpFormingLevel)<2:
print('If you are seeing this, either there is no need of cutoff wall or the
depth of cutoff wall calculated is less than 2m')
new1 = float(input('Assume a depth of cutoff wall for stability purposes'))
dsCutoffDepth = new1
dsCutoffLevel = JumpFormingLevel - dsCutoffDepth
else:
dsCutoffLevel = ds_HFL - dsCutoffDepth
print('The RL of cutoff wall below Floor Level in ds is=',JumpFormingLevel-
dsCutoffDepth)

#Total Floor Length and Exit Gradient

USlope = int(input('Enter the slope of upstream glacis as _: 1'))


DSlope = int(input('Enter the slope of downstream glacis as _: 1'))

lengthofuslope = math.ceil(USlope *(CrestLevel - BL))


lengthofdslope = math.ceil(DSlope *(CrestLevel - JumpFormingLevel))
widthofweir = float(input('Assume width of weir'))
print('The length of upstream glacis',lengthofuslope)
print('The length of downstream glacis',lengthofdslope)

print("Now, you have to select the Khosla's Safe Gradient for Different Types of
Soil")
print('For Shingle, from 0.25 to 0.20')
print('For Course Sand, from 0.20 to 0.17')
print('For Fine Sand, from 0.17 to 0.14')

Ge = float(input('Enter the safe exit gradient as per your soil'))


print('You have safety exit gradient as',Ge)

MaxStatHead = CrestLevel - JumpFormingLevel


print('The Max Static head is',MaxStatHead)
alpha =np.around ((((2*(MaxStatHead/(Ge*dsCutoffDepth*3.14))**2)-1)**2-1)**0.5,1)
print('The value of alpha is',alpha)
totalbreadth =math.ceil((dsCutoffDepth) * alpha)
print('The total breadth is=',totalbreadth)

usimperviousfloor = totalbreadth - lengthofuslope -lengthofdslope - widthofweir -


length_SB
print('The length of upstream impervious floor is=',usimperviousfloor)

#Uplift Pressures Calculation


USAsThick = float(input('Enter the assumed thickness for US Weir'))
DSAsThick = float(input('Enter the assumed thickness for DS Weir'))
EdgeDist = float(input('Enter the edge distance from pile to edge of weir (usually
0.75m)'))

#Upstream Pile Pressure


Kalpha = totalbreadth/usCutoffDepth
Klamda = (1+(1+(Kalpha)**2)**0.5)/2
PhiE = 100 * round((1/3.14) * math.acos((Klamda-2)/Klamda),2)
PhiD = 100 * round((1/3.14) * math.acos((Klamda-1)/Klamda),2)
PhiC1 = 100 - PhiE
PhiD1 = 100 - PhiD
PhiE1 = 100
print('PhiE1=',PhiE1)
print('PhiD1=',PhiD1)
print('PhiC1=',PhiC1)

#Downstream Pile Pressure


Kalpha1 = totalbreadth/dsCutoffDepth
Klamda1 = (1+(1+(Kalpha1)**2)**0.5)/2
PhiE2 = 100 * round((1/3.14) * math.acos((Klamda1-2)/Klamda1),2)
PhiD2 = 100 * round((1/3.14) * math.acos((Klamda1-1)/Klamda1),2)
PhiC2 = 0
print('PhiE2=',PhiE2)
print('PhiD2=',PhiD2)
print('PhiC2=',PhiC2)

#US Correction
D = (BL - USAsThick) - (JumpFormingLevel-dsCutoffDepth)
d = (BL - USAsThick) - (BL-usCutoffDepth)
b1 = totalbreadth - 2 * (EdgeDist)
if (b1>dsCutoffDepth and b1>usCutoffDepth):
print('Mutual Interference effect may be neglected.')
Correction1 = 0
else:
Correction1 = 19 * (D/b1)**0.5 * ((d+D)/totalbreadth)

Correction2 = (PhiD1-PhiC1)/(BL-(JumpFormingLevel-dsCutoffDepth))*(USAsThick)
CorrectPhiC1 = np.around(PhiC1 + Correction1 + Correction2,4)
print('The correct PhiC1=',CorrectPhiC1)

#DS Correction
D = (JumpFormingLevel - DSAsThick) - (BL-usCutoffDepth)
d = (JumpFormingLevel - DSAsThick) - (JumpFormingLevel-dsCutoffDepth)
b1 = totalbreadth - 2 * (EdgeDist)
if (b1>dsCutoffDepth and b1>usCutoffDepth):
print('Mutual Interference effect may be neglected.')
Correction1 = 0
else:
Correction1 = 19 * (D/b1)**0.5 * ((d+D)/totalbreadth)

Correction2 = (PhiE2-PhiD2)/(JumpFormingLevel-(JumpFormingLevel-
dsCutoffDepth))*(DSAsThick)
CorrectPhiE2 = np.around(PhiE2 - Correction1 - Correction2,4)
print('The correct PhiE2=',CorrectPhiE2)

print('After correction:')
print('PhiE1=',PhiE1)
print('PhiD1=',PhiD1)
print('PhiC1=',CorrectPhiC1)
print('PhiE2=',CorrectPhiE2)
print('PhiD2=',PhiD2)
print('PhiC2=',PhiC2)

#Data tabulation

def
KhoslaTableLine1(PhiE1,PhiC2,PhiD1,CorrectPhiC1,CorrectPhiE2,PhiD2,usLevel,dsLevel)
:
MSH = np.around(usLevel - dsLevel,2)
a1 = np.round(PhiE1/100*MSH)
a = np.round(PhiD1/100*MSH,2)
b = np.round(CorrectPhiC1/100*MSH,2)
c = np.round(CorrectPhiE2/100*MSH,2)
d = np.round(PhiD2/100*MSH,2)
d1 = np.round(PhiC2/100*MSH)
return np.round(usLevel,2),np.round(dsLevel,2),MSH,a1,a,b,c,d,d1
def
KhoslaTableLine2(PhiE1,PhiC2,PhiD1,CorrectPhiC1,CorrectPhiE2,PhiD2,usLevel,dsLevel)
:
MSH = np.around(usLevel - dsLevel,2)
a= np.around(dsLevel+ (PhiD1/100)*(usLevel-dsLevel),2)
b= np.around(dsLevel+ (CorrectPhiC1/100)*(usLevel-dsLevel),2)
c= np.around(dsLevel+ (CorrectPhiE2/100)*(usLevel-dsLevel),2)
d= np.around(dsLevel+ (PhiD2/100)*(usLevel-dsLevel),2)
return
np.round(usLevel,2),np.round(dsLevel,2),MSH,np.round(usLevel,2),a,b,c,d,np.round(ds
Level,2)
[aa,bb,cc,dd,ee,ff,gg,hh,ii]=KhoslaTableLine1(PhiE1,PhiC2,PhiD1,CorrectPhiC1,Correc
tPhiE2,PhiD2,CrestLevel,JumpFormingLevel)
[aa2,bb2,cc2,dd2,ee2,ff2,gg2,hh2,ii2]=KhoslaTableLine2(PhiE1,PhiC2,PhiD1,CorrectPhi
C1,CorrectPhiE2,PhiD2,CrestLevel,JumpFormingLevel)
[aa3,bb3,cc3,dd3,ee3,ff3,gg3,hh3,ii3]=KhoslaTableLine1(PhiE1,PhiC2,PhiD1,CorrectPhi
C1,CorrectPhiE2,PhiD2,us_HFL,ds_HFL)
[aa4,bb4,cc4,dd4,ee4,ff4,gg4,hh4,ii4]=KhoslaTableLine2(PhiE1,PhiC2,PhiD1,CorrectPhi
C1,CorrectPhiE2,PhiD2,us_HFL,ds_HFL)

from prettytable import PrettyTable

x = PrettyTable()
x.field_names = ['Flow Cond.', 'USlvl',
'DSlvl','Head','E1','D1','C1','E2','D2','C2']

x.add_row(['max static head',aa,bb,cc,dd,ee,ff,gg,hh,ii])


x.add_row(['',aa2,bb2,cc2,dd2,ee2,ff2,gg2,hh2,ii2])
x.add_row(['Highflow w/con&ret.',aa3,bb3,cc3,dd3,ee3,ff3,gg3,hh3,ii3])
x.add_row(['',aa4,bb4,cc4,dd4,ee4,ff4,gg4,hh4,ii4])
print(x)

#PreJump Profile:
x12=PrettyTable()
x12.field_names = ['Dist from d/s to start of glacis','Glacis Level','High Flood
Ef1','High Flood y1']
i=2

GlacisLevel = CrestLevel
while GlacisLevel>JumpFormingLevel:
GlacisLevel = CrestLevel - i/DSlope
Ef1 = us_TEL - GlacisLevel
p = np.poly1d([2,-Ef1/ayc*2,0,1])
roots = p.roots
output = roots[(roots>0)&(roots<1)]
finaly = np.around(ayc * output,3)
if GlacisLevel>JumpFormingLevel:
x12.add_row([i,GlacisLevel,round(Ef1,3),finaly])
i = i + DSlope
GlacisLevel = aJumpFormationLevel
FinalDistance = 2*(CrestLevel-GlacisLevel)
FEf1 = us_TEL - GlacisLevel
p = np.poly1d([2,-Ef1/ayc*2,0,1])
roots = p.roots
output = roots[(roots>0)&(roots<1)]
finaly = np.around(ayc * output,3)
x12.add_row([FinalDistance,GlacisLevel,np.around(us_TEL-GlacisLevel,3),finaly])
print(x12)

#PostJumpProfile
print('For the post jump profile, the values of Froude number and initial depth
(y1) are ',afroude_number,'and ',ay1,'respectively.')
FroudeSquare = afroude_number**2
print('The value of Froude number sqaure is',FroudeSquare)
nearvalue = int(input("Out of Plate 10.3 (a) in SK Garg's Book, which value is near
your square out of 4, 8, 15, 30 and 60?"))
x13=PrettyTable()
x13.field_names = ['x/y1','y/y1','y','x']
xbyx1=0

if nearvalue == 60:
for xbyx1 in np.arange(0,25,2.5):
ybyy1 = 6*(10**-7)*xbyx1**5 - 6*(10**-5)*xbyx1**4 + 0.0021*xbyx1**3 -
0.035*xbyx1**2 + 0.4782*xbyx1 + 0.959
yvalue = ybyy1 * ay1
xvalue = xbyx1 * ay1
x13.add_row([xbyx1,ybyy1,yvalue,xvalue])

print(x13)
if nearvalue == 30:
for xbyx1 in np.arange(0,25,2.5):
ybyy1 = 5*(10**-7)*xbyx1**5 - 5*(10**-5)*xbyx1**4 + 0.002*xbyx1**3 -
0.035*xbyx1**2 + 0.4842*xbyx1 + 0.9543
yvalue = ybyy1 * ay1
xvalue = xbyx1 * ay1
x13.add_row([xbyx1,ybyy1,yvalue,xvalue])

print(x13)
if nearvalue == 15:
for xbyx1 in np.arange(0,25,2.5):
ybyy1 = -3*(10**-6)*xbyx1**4 + 0.0004*xbyx1**3 - 0.0192*xbyx1**2 +
0.442*xbyx1 + 0.9476
yvalue = ybyy1 * ay1
xvalue = xbyx1 * ay1
x13.add_row([xbyx1,ybyy1,yvalue,xvalue])

print(x13)
if nearvalue == 8:
for xbyx1 in np.arange(0,25,2.5):
ybyy1 = 5*(10**-7)*xbyx1**5 - 5*(10**-5)*xbyx1**4 + 0.002*xbyx1**3 -
0.0427*xbyx1**2 + 0.5017*xbyx1 + 0.9714
yvalue = ybyy1 * ay1
xvalue = xbyx1 * ay1
x13.add_row([xbyx1,ybyy1,yvalue,xvalue])

print(x13)
if nearvalue == 4:
for xbyx1 in np.arange(0,25,2.5):
ybyy1 = 5*(10**-6)*xbyx1**5 - 0.0003*xbyx1**4 + 0.0064*xbyx1**3 -
0.0717*xbyx1**2 + 0.4626*xbyx1 + 0.9838
yvalue = ybyy1 * ay1
xvalue = xbyx1 * ay1
x13.add_row([xbyx1,ybyy1,yvalue,xvalue])

print(x13)
else:
print('If your value is not near these values, proceed manually.')

#Thickness of Floor Calculation


print('First, for high flood condition:')
x14=PrettyTable()
x14.field_names = ['x','distance from us end','Post-jump profile RL','HGL
RL','Unbalanced Head','2/3rd of Unbalanced Head']
positionfromusend = usimperviousfloor+lengthofuslope+widthofweir+FinalDistance
for xbyx1 in np.arange(0,25,2.5):
xvalue = xbyx1 * ay1
dist = positionfromusend + xvalue
HGL = ff4 + (dist)*(gg4-ff4)/totalbreadth
UBhead = HGL - aJumpFormationLevel
UBHF = 2/3*UBhead
x14.add_row([xvalue,dist,aJumpFormationLevel+xvalue,HGL,UBhead,UBHF])

print(x14)

print('Second, for static head condition:')


x15=PrettyTable()
x15.field_names = ['x','distance from us end','Post-jump profile RL','HGL
RL','Unbalanced Head','2/3rd of Unbalanced Head']
positionfromusend = usimperviousfloor+lengthofuslope+widthofweir+FinalDistance
for xbyx1 in np.arange(0,25,2.5):
xvalue = xbyx1 * ay1
dist = positionfromusend + xvalue
HGL = ff2 + (dist)*(gg2-ff2)/totalbreadth
UBhead = HGL - aJumpFormationLevel
UBHF = 2/3*UBhead
x15.add_row([xvalue,dist,aJumpFormationLevel+xvalue,HGL,UBhead,UBHF])

print(x15)

You might also like