Example #1
0
print T
print M
Nstar =1 #measuring point for each pipe
Hs =np.ndarray((Np,M/Mi*Nt))

fn = "../indata/Alameda_m3"
oldinp = "../indata/Alamedanewer52.0.0.inp"
(fi, fc) = rewritePipes(fn,oldinp, Ns, Ls_m, Mrs, Ds_m, jt, bt, bv, r, h0s, q0s, T, M, a,elevs_m)
n1 = PyNetwork(fi,fc,1)
dt = n1.T/float(n1.M)
Q00 = 0.0087
for i in range(0,Np):
    d = n1.Ds[i]
    A0 = (d*d/4.)*np.ones(n1.Ns[i])
    Q0 = 0*np.ones(n1.Ns[i])
    n1.setIC(i,A0,Q0)
Qb = Q00*np.ones(M+1)
n1.setbVal(0,Qb)

Ttot= 0
Vs = [n1.getTotalVolume()]
for m in range(Nt):
    try:
        n1.runForwardProblem(dt)
    except:
        print "whoops. dt is probably too small. quitting at time T=%f"%((m-1.)*T)
        break
    for j in range(Np):
        N = n1.Ns[j]
        p0 = PyPipe_ps(N,n1.Ds[j], n1.Ls[j],M,a)
        qh = n1.qhist(j)
Example #2
0
m32gal=264.172052 #conversion factor m^3 to gallons
for J in range(10):
    for I in range(10):
        t0 = time.clock()
        h0 = 0.05*J*Ds[0]+0.005
        orf = 0.05*I*Ds[0]+0.005
        n1 = PyNetwork(fi,fc,1)
        p0 = PyPipe_ps(Ns[0],Ds[0],Ls[0],M,a)
        A0 = p0.AofH(h0, True)
        Q0 = 0
        Qin = 0.0087
        Qout = 0.001
        Qin_t=Qin*np.ones(M+1)
        z = orf
        o = np.ones(Ns[0])
        n1.setIC(1,A0*o,Q0*o)
        n1.setbVal(0,Qin_t)
        n1.setbVal(1,z*np.ones(M+1))
        n1.setbVal(2,z*np.ones(M+1))


        t0= time.clock() 
        Vs = [n1.getTotalVolume()]  #store the system volume at times [0, T, 2*T, ...Nt*T]
        for m in range(Nt):
            n1.runForwardProblem(dt)#run the forward problem
            print 'simulation time =%f s'%(T*(m+1))#show what time we're at
            Ntot = 0
            for j in range(Np):
                N = n1.Ns[j]
                qh = n1.qhist(j)
                for n in range(1,M+1,Mi):