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) Htemp = [p0.pbar(qh[idx_t(0,Nstar,n,n1.Ns[j])],False) for n in range(1,M+1,Mi)] Hs[j,m*(M/Mi):(M/Mi)*(m+1)] = Htemp Vs.append(n1.getTotalVolume()) Ttot +=T print Ttot print Vs n1.reset()
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): Px = n1.pressureSpaceSeries(j,n) Utemp = [qh[idx_t(1,k,n,N)]/qh[idx_t(0,k,n,N)] for k in range(1,N+1)] Hs[(n-1)/Mi+m*(M/Mi),Ntot:Ntot+N] = Px Us[(n-1)/Mi+m*(M/Mi),Ntot:Ntot+N] = Utemp Ntot+=N Vs.append(n1.getTotalVolume()) print m print Vs n1.reset() #reset internal counter to zero so network can be run again elapsed_t = time.clock()-t0 print "Wall clock time = %f"%elapsed_t df = pd.DataFrame(data=Hs.astype(float)) df.to_csv('../../../Desktop/filling_sims/data_orf_%d_h0_%d_I%dJ%d.csv'%(int(np.ceil(orf/Ds[0]*100)),h0,I,J), float_format='%.4f') fig,ax = plt.subplots(figsize = (15,5)) what = [25]*Np interesting = np.arange(0,Np) t = np.linspace(0,Ttot, M/Mi*Nt) cNorm = colors.Normalize(vmin=0, vmax=Np+1) smap = cm.ScalarMappable(norm=cNorm, cmap=cm.get_cmap('ocean') ) for k in interesting: ax.plot(t/60,m2psi*Hs[:,sum(Ns[0:k])+what[k]],label="pipe %d"%k,color = smap.to_rgba(k),lw=2) ax.set_xlabel('t (min)') ax.set_ylabel('pressure head (psi)')