# coding: utf-8 import sys def SPQ(elv,ELini,hmax): # To obtain the discharge of overflow crest from the water level ELcr=ELini b=20.5 n=4 x=0.1387 Cd=1.971+0.498*x+6.63*x*x a=(1.6-Cd)/(Cd-3.2) h=elv-ELcr q=0.0 if 0.05s} {1:>5s} {2:>10s} {3:>10s} {4:>15s} {5:>15s} {6:>15s} {7:>15s}'.format('i','iUD','time','EL','EL-elv','VOL','q_in','q_out'),file=fout) print('{0:5d} {1:5d} {2:10.3f} {3:10.3f} {4:15e} {5:15e} {6:15e} {7:15e}'.format(i,iUD,ti[i],EL,EL-elv,VOL,q_in[i],q_out),file=fout) # Iterative calculation iUD=1 dh=0.0001 eps=0.0001 itmax=int(1.0/dh)*10 for i in range(0,nd-1): Qin=0.5*(q_in[i]+q_in[i+1])*(ti[i+1]-ti[i])*3600.0 hh=0.0 j=0 while 1: j=j+1; hh=hh+float(iUD)*dh elv=EL; q1=SPQ(elv,ELini,hmax)+outlet elv=EL+hh; q2=SPQ(elv,ELini,hmax)+outlet Qout=0.5*(q1+q2)*(ti[i+1]-ti[i])*3600.0 R=VOL+Qin-Qout elv=RET_H(nn,rh,rv,R) if iUD==1 and j==10: if EL+hh>elv: iUD=-1 hh=0.0 j=0 if iUD==-1 and j==10: if EL+hh