import math
from numpy import zeros,linspace
#determine maximum reservior level
#maximum discharge over spillway
#plot inflow and routed hydrograph and find peak flow and peak lag
#Given
e = [100, 100.3, 100.6, 100.9, 101.2, 101.5, 101.8, 102.1, 102.4, 102.7]; #elevation(km)
A = [405, 412, 420, 425, 428, 436, 445, 453, 460, 469]; #area
o = [0, 14.9, 42.2, 77.3, 119, 169, 217, 272, 334, 405]; #outflow
c = zeros(10)
dh = zeros(10)
s = zeros(10)
h = zeros(10)
h1 = zeros(10)
h2 = zeros(10)
for i in range(10):
dh[i] = e[i]-e[i-1];
s[i] = dh[i]/3*(A[i-1]+A[i]+(A[i-1]*A[i])**0.5); #storage between contours
c[i] = c[i-1]+s[i]; #cumulative storage
h[i] = c[i]/1.08; #2s/t
h1[i] = h[i]-o[i]; #2s/t-o
h2[i] = h[i]+o[i]; #2s/t+o
T = linspace(0,102,17)
I = [42, 45, 57, 88, 147, 210, 272, 340, 350, 338, 314, 288, 263, 240, 198, 170, 143, 120]; #inflow
h4 = [0, 0, 60, 122, 185, 266, 362, 455, 545, 605, 623, 620, 600, 575, 550, 515, 470, 430]; #2s/t-0 obtained from curve a
O = [0, 10, 24, 42, 74, 130, 194, 260, 316, 334, 328, 312, 286, 264, 236, 204, 177, 150]; #outflow read from curve a
re = [100.2, 100.39, 100.58, 100.86, 101.26, 101.65, 102.03, 102.31, 102.4, 102.37, 102.3, 102.18, 102.06, 101.9, 101.72, 101.56, 102.4]; #reservior elevation read from curve b
t = zeros(17)
h3 = zeros(17)
for i in range(1,17):
t[i] = I[i-1]+I[i]; #I1+I2
h3[i] = t[i]+h4[i]; #2s/t+O
pt = T[9]-T[8];
d = I[8]-O[9];
#results
print " maximum reservior level = %.2f m."%(re[9]);
print "maximum discharge over spillway = %.2f cumecs."%(O[9]);
print "reduction in peak discharge = %.2f cumecs."%(d);
print "peak lag = %.f hours."%(pt);
import math
from numpy import zeros
#Given
in1 = [8.6, 2.2, 1.8, 0, 0, 13.5, 280.6, 510.2, 136, 52.5, 20.6, 12.3]; #inflow(ha-m)
pan = [2.2, 2.3, 3.1, 8.6, 12.8, 15.6, 12.3, 10.6, 10, 8.2, 5.8, 3]; #pan evaporation
p = [0.8, 1.2, 0, 0, 0, 4.8, 12.2, 18.6, 8.6, 1.5, 0, 0] #precipitation
D = [14.5, 15.8, 16.2, 16.8, 17.5, 18, 18, 17, 16.5, 16, 15.8, 15]; #Demand
s = 0;
r = zeros(12)
E = zeros(12)
P = zeros(12)
S = zeros(12)
# Calculations
for i in range(12):
if in1[i]<10:
r[i] = in1[i]; #D/S requirement
else:
r[i] = 10;
E[i] = 3.6*pan[i]; #Evaporation over reservior area
P[i] = 3.5*p[i]; #Precipitation
I[i] = in1[i]-r[i]-E[i]+P[i]; #Adjusted inflow
S[i] = D[i]-I[i]; #Water required from storage
if S[i]<0:
S[i] = 0;
s = s+S[i];
# Results
print "required useful storage = %.2f ha-m."%(s);
import math
from numpy import zeros
#Given
V = 475; #flow required to be maintained throughout the year
Y = V*365*8.64; #yearly demand
#yearly demand gives the slope of demand curve
t = linspace(0,36,37) #number of season startin from 1960;each year is diveded into 3 seasons.
q = [0, 1050, 300, 50, 3000, 250, 40, 3500, 370, 90, 2000, 150, 120, 1200, 350, 65, 1400, 400, 100, 3600, 200, 80, 3000, 200, 80, 3000, 150, 120, 700, 210, 50, 800, 120, 80, 2400, 320, 120, 3200, 280, 80]; #average discharge
v = [0, 0.9707, 0.4717, 0.0328, 2.7734, 0.3981, 0.0263, 3.2357, 0.5818, 0.0591, 1.8490, 0.2356, 0.0788, 1.1094, 0.5504, 0.0427, 1.2943, 0.6290, 0.0657, 3.3281, 0.3145, 0.0525, 2.7734, 0.2359, 0.0788, 0.6441, 0.3302, 0.028, 0.7396, 0.1887, 0.0525, 2.2188, 0.5032, 0.0788, 2.9583, 0.4403, 0.0525]; #voloume
cv = zeros(37)
cv[0] = v[0];
for i in range(37):
cv[i] = cv[i-1]+v[i];
#each year is divided into three seasons(monsoon,winter and summer).and readings are taken for 12 years
#mass inflow curve is plotted and math.tangent are drawn at the apexes and parellel to demand curve slope;
#the respectiv ordinates represent the deficiency during dry period
#maximum of these ordinates gives the desired reservior capacity
print "storage capacity of reservior = 1.6 million ha-m.";
import math
from numpy import linspace,zeros
#Given
asi = 3.6; #annual sediment inflow(x10**6)
gamma_s = 12; #specific weigth of sediment
vs = asi/12;
ir = 30.; #initial reservior capacity
fr = 60.; #final reservior capacity
r = ir/fr; #initial capacity/inflow ratio
# Calculations
#r = 0.5; hence we start capacity/inflow ratio from 0.5
c = linspace(0.5,0.1,5) #capacity inflow ratio
e = [0.96 ,0.955, 0.95, 0.93, 0.87]; #trap efficiency
ae = zeros(4)
for i in range(4):
ae[i] = (e[i]+e[i+1])/2; #average efficiency for interval
as1 = [0.2872, 0.2857, 0.2820, 0.2700]; #annual sediment trapped
s = 0
y = zeros(4)
for i in range(4):
y[i] = 6/as1[i]; #year to fill
s = s+y[i];
# Results
print " probable life of reservior = %i years."%(s);
import math
#corresponding maximum level of water above spillway crest
#Given
I = [60, 480, 900, 470, 270, 160, 110, 80, 60]; #inflow
#for the first time interval 0 hours to 3 hours
I1 = I[0];
I2 = I[1];
t = 3*3600.;
ti = (I1+I2)*t/2; #total inflow
#outflow = 1.62*h1**1.5;
#storage change = (30+3h1)h1
#from the basic equation i.e total inflow = total outflow+change in storage
#on solving we get
#h1**2+0.54h1**1.5+10h1-0.972 = 0;
#solving it by trial and error method;we get
h1 = 0.0954;
#for the second time interval 3 hours to 6 hours
I1 = I[1];
I2 = I[2];
t = 3*3600.;
ti = (I1+I2)*t/2; #total inflow
#outflow = 0.0477+1.62*h2**1.5;
#storage change = (30+3h2)h2
#from the basic equation i.e total inflow = total outflow+change in storage
#on solving we get
#h2**2+0.54h2**1.5+10h2-3.4312 = 0;
#solving it by trial and error method;we get
h2 = 0.323;
#for the third time interval 6 hours to 9 hours
I1 = I[2];
I2 = I[3];
t = 3*3600.;
ti = (I1+I2)*t/2; #total inflow
#outflow = 0.2974+1.62*h3**1.5;
#storage change = (30+3h3)h3
#from the basic equation i.e total inflow = total outflow+change in storage
#on solving we get
#h3**2+0.54h3**1.5+10h3-5.7012 = 0;
#solving it by trial and error method;we get
h3 = 0.522;
#for the fourth time interval 9 hours to 12 hours
I1 = I[3];
I2 = I[4];
t = 3*3600.;
ti = (I1+I2)*t/2; #total inflow
#outflow = 0.611+1.62*h4**1.5;
#storage change = (30+3h4)h4
#from the basic equation i.e total inflow = total outflow+change in storage
#on solving we get
#h4**2+0.54h4**1.5+10h4-6.6208 = 0;
#solving it by trial and error method;we get
h4 = 0.601;
#for the fifth time interval 12 hours to 15 hours
I1 = I[4];
I2 = I[5];
t = 3*3600;
ti = (I1+I2)*t/2; #total inflow
#outflow = 0.7548+1.62*h5**1.5;
#storage change = (30+3h5)h5
#from the basic equation i.e total inflow = total outflow+change in storage
#on solving we get
#h5**2+0.54h5**1.5+10h5-6.8936 = 0;
#solving it by trial and error method;we get
h5 = 0.624;
#for the sixth time interval 12 hours to 15 hours
I1 = I[5];
I2 = I[6];
t = 3*3600.;
ti = (I1+I2)*t/2; #total inflow
#outflow = 0.7985.62*h6**1.5;
#storage change = (30+3h6)h6
#from the basic equation i.e total inflow = total outflow+change in storage
#on solving we get
#h6**2+0.54h6**1.5+10h6-6.8492 = 0;
#solving it by trial and error method;we get
h6 = 0.620;
hmax = h5;
q = 300*(h5)**1.5; #equation given
q = round(q*100)/100;
# Results
print "maximum outflow discharge over spillway = %.2f cumecs."%(q);
print "maximum level of water above spillway crest = %.2f m."%(h5);
import math
from numpy import zeros
#Given
t = 240.; #total math.cost of project(million rupees)
s = [32., 88., 72.]; #separable math.cost
eb = [40., 138., 112.]; #estimated benifit
sp = [47., 104., 101.]; #alternate math.single purpose math.cost
#umath.sing remaining benifit method
ts = s[0]+s[1]+s[2]; #total separable math.cost
tj = t-ts; #total joint math.cost
w = 0;
b = zeros(3)
rb = zeros(3)
for i in range(3):
if eb[i]<sp[i]:
b[i] = eb[i]; #benifit limited by alternate math.cost
else:
b[i] = sp[i];
rb[i] = b[i]-s[i]; #remaining benifit
w = w+rb[i];
y = 0;
aj = zeros(3)
ta = zeros(3)
for i in range(3):
aj[i] = tj*rb[i]/w; #allocated joint math.cost
ta[i] = s[i]+aj[i]; #total allocations
y = y+ta[i];
print "Using remaining benifit method.";
print "allocations to each project purposepercent:";
per = zeros(3)
for i in range(3):
per[i] = ta[i]*100/y; #total allocation percent
print "%.2f"%(per[i]);
#umath.sing alternate justifiable method
w = 0;
ac = zeros(3)
for i in range(3):
ac[i] = sp[i]-s[i]; #alternate math.cost less separable math.cost
w = w+ac[i];
y = 0;
ajc = zeros(3)
ta = zeros(3)
for i in range(3):
ajc[i] = tj*ac[i]/w; #allocated joint math.cost
ta[i] = s[i]+ajc[i]; #total allocation
y = y+ta[i];
print "Using alternate justifiable expenditure method method.";
print "allocations to each project purposepercent:";
pr = zeros(3)
for i in range(3):
pr[i] = ta[i]*100/y; #total allocation percent
print "%.2f"%(pr[i]);
import math
from numpy import zeros
#Given
I = [35, 55, 92, 130, 160, 140]; #inflow(cumec/sec)
x = 0.28;
K = 1.6; #studied value
t = 6;
K = K*24; #in hours
co = (-K*x+0.5*t)/(K-K*x+0.5*t);
c1 = (K*x+0.5*t)/(K-K*x+0.5*t);
c2 = (K-K*x-0.5*t)/(K-K*x+0.5*t);
c = co+c1+c2;
#c = 1; which implies (OK)
#from Muskingum equation
p1 = zeros(6)
p2 = zeros(6)
p3 = zeros(6)
O = zeros(6)
O[0] = 35;
print "outflow hydrograph:%.2f"%(O[0]);
for i in range(1,6):
p1[i] = co*I[i];
p2[i] = c1*I[i-1];
p3[i] = c2*O[i-1];
O[i] = p1[i]+p2[i]+p3[i];
O[i] = round(O[i]*100)/100;
print "%.2f"%(O[i]);
import math
from numpy import zeros_like,zeros
#Given
md = [50, 75, 80, 85, 130, 120, 25, 25, 40, 45, 50, 60]; #monthly demand
e = [6, 8, 13, 17, 22, 22, 14,11, 13, 12, 7, 5]; #evaporation
r = [1, 0, 0, 0, 0, 19, 43, 39, 22, 6, 2, 1]; #rain1fall
in1 = [50, 40, 30, 25, 20, 30, 200, 225, 150, 90, 70, 60]; #monthly in1flow
A = 30.; #area of reservior
Cr = 0.4; #run-off coefficient
er = zeros_like(md)
ni = zeros(12)
niv = zeros(12)
nd =zeros(12)
for i in range(12):
er[i] = 0.4*r[i]; #effective rain1fall
ni[i] = er[i]-e[i]; #net in1flow
niv[i] = ni[i]*0.01*A; #net in1flow volume
nd[i] = md[i]-niv[i]; #net demand
cnd = zeros(12)
ci = zeros(12)
cnd[0] = nd[0]; #cumulative demand
ci[0] = in1[0]; #cumulative in1flow
for i in range(1,12):
cnd[i] = cnd[i-1]+nd[i];
ci[i] = ci[i-1]+in1[i];
ed = zeros(12,dtype=float)
es = zeros(12)
print "Excess demand:";
for i in range(12):
ed[i] = cnd[i]-ci[i]; #excess demand
if ed[i]<0:
es[i] = ed[i]; #excess supply
ed[i] = 0;
print "%.2f"%(ed[i]);
print "min1imum storage required = Maximum of excess demand = %.2f Mm**3."%(ed[5]);
import math
from numpy import array,zeros_like
#minimum capacity of reservior
#the initial storage storage required to maintain uniform demand
#Given
in1 = array([2.83, 4.25, 5.66, 18.4, 22.64, 22.64, 19.81, 8.49, 7.1, 7.1, 5.66, 5.66]); #inflow(x10**5)
s = sum(in1)
avd = s/12; #average demand(x10**5)
s = 0
t = 0;
e = zeros_like(in1)
D = zeros_like(in1)
for i in range(12):
e[i] = avd-in1[i];
if e[i]<0:
S[i] = -e[i]; #surplus(x10**5)
s = s+S[i];
else:
D[i] = e[i]; #Deficit(x10**5)
t = t+D[i];
d = (s-(t-D[0]-D[1]-D[2]));
s = s;
print "minimum capacity of reservior = %.2fD+5 cumec."%(s);
print "storage required to maintain uniform demand = %.2fD+5 cumec"%(d);