예제 #1
0
파일: MKM.py 프로젝트: glwagner/spectralDNS
        for i, name in enumerate(("U", "V", "W")):
            self.Umean[i, s] = self.f0["Average/"+name][s]
        self.Pmean[s] = self.f0["Average/P"][s]
        for i, name in enumerate(("UU", "VV", "WW", "UV", "UW", "VW")):
            self.UU[i, s] = self.f0["Reynolds Stress/"+name][s]
        

if __name__ == "__main__":
    config.update(
        {
        'solver': 'IPCS',
        'nu': 1./180.,                  # Viscosity
        'Re_tau': 180., 
        'dt': 0.001,                  # Time step
        'T': 100.,                   # End time
        'L': [2, 4*pi, 4.*pi/3.],
        'M': [6, 6, 5]
        },  "Shen"
    )
    config.Shen.add_argument("--compute_energy", type=int, default=100)
    config.Shen.add_argument("--plot_result", type=int, default=100)
    config.Shen.add_argument("--sample_stats", type=int, default=100)
    solver = get_solver(update=update, family="Shen")    
    initialize(**vars(solver))    
    #init_from_file("IPCSRR.h5", **vars(solver))
    set_Source(**vars(solver))
    solver.stats = Stats(solver.U, solver.comm, filename="MKMstats")
    solver.hdf5file.fname = "IPCSRR.h5"
    solver.solve()
    s = solver.stats.get_stats()
예제 #2
0
파일: TG.py 프로젝트: glwagner/spectralDNS
            print t, float(kk), float(ww)

def regression_test(t, tstep, comm, U, curl, float64, dx, L, sum, rank, **kw):
    k = comm.reduce(sum(U.astype(float64)*U.astype(float64))*dx[0]*dx[1]*dx[2]/L[0]/L[1]/L[2]/2) # Compute energy with double precision
    if config.solver == 'NS':
        w = comm.reduce(sum(curl.astype(float64)*curl.astype(float64))*dx[0]*dx[1]*dx[2]/L[0]/L[1]/L[2]/2)
    elif config.solver == 'VV':
        w = comm.reduce(sum(kw['W'].astype(float64)*kw['W'].astype(float64))*dx[0]*dx[1]*dx[2]/L[0]/L[1]/L[2]/2)
    if rank == 0:
        assert round(k - 0.124953117517, 7) == 0
        assert round(w - 0.375249930801, 7) == 0

if __name__ == "__main__":
    config.update(
        {
        'nu': 0.00625,             # Viscosity
        'dt': 0.01,                 # Time step
        'T': 0.1,                   # End time
        'L': [2*pi, 4*pi, 2*pi],
        'M': [5, 5, 5]
        },  "Isotropic"
    )
    config.Isotropic.add_argument("--compute_energy", type=int, default=2)
    solver = get_solver(update=update)
    solver.hdf5file.fname = "NS7.h5"
    solver.hdf5file.components["W0"] = solver.curl[0]
    solver.hdf5file.components["W1"] = solver.curl[1]
    solver.hdf5file.components["W2"] = solver.curl[2]
    initialize(**vars(solver))
    solver.solve()
예제 #3
0
    comm.Gather(u0, uall, root=0)
    if rank == 0:
        uall = uall.reshape((N[0],))
        #x = points
        #pc = zeros(len(x))
        #pc = ST.fct(uall, pc)  # Cheb transform of result
        #solution at x = 0
        #u = n_cheb.chebval(0, pc)
        #u_exact = reference(config.Re, config.t)
        u_exact = exact(points, config.Re, config.t)
        print "Computed error = %2.8e %2.8e " %(sqrt(sum((uall-u_exact)**2)/N[0]), config.dt)

if __name__ == "__main__":
    config.update(
        {
        'solver': 'IPCS',
        'Re': 800.,
        'nu': 1./800.,             # Viscosity
        'dt': 0.5,                 # Time step
        'T': 50.,                   # End time
        'L': [2, 2*pi, 4*pi/3.],
        'M': [6, 5, 1]
        },  "Shen"
    )
    config.Shen.add_argument("--compute_energy", type=int, default=5)
    config.Shen.add_argument("--plot_step", type=int, default=10)
    solver = get_solver(update=update, regression_test=regression_test, family="Shen")    
    initialize(**vars(solver))
    set_Source(**vars(solver))
    solver.solve()
    #e1 = 0.5*energy(pert, N, comm, rank, L)
    #exact = exp(2*imag(OS.eigval)*config.t)
    #if rank == 0:
        #print "Computed error = %2.8e %2.8e " %(sqrt(abs(e1/e0-exact)), config.dt)

    initOS(OS, U0, U_hat0, X, FST, ST, t=config.t)
    pert = (U[0] - U0[0])**2 + (U[1]-U0[1])**2
    e1 = 0.5*energy(pert, N, comm, rank, L)
    #exact = exp(2*imag(OS.eigval)*config.t)
    if rank == 0:
        print "Computed error = %2.8e %2.8e " %(sqrt(e1), config.dt)

if __name__ == "__main__":
    config.update(
        {
        'solver': 'IPCS_GeneralBCs',
        'Re': 8000.,
        'nu': 1./8000.,             # Viscosity
        'dt': 0.01,                 # Time step
        'T': 0.02,                   # End time
        'L': [2, 2*pi, 4*pi/3.],
        'M': [7, 6, 1]
        },  "ShenGeneralBCs"
    )
    config.ShenGeneralBCs.add_argument("--compute_energy", type=int, default=1)
    config.ShenGeneralBCs.add_argument("--plot_step", type=int, default=10)
    solver = get_solver(update=update, regression_test=regression_test, family="ShenGeneralBCs")    
    vars(solver).update(initialize(**vars(solver)))
    set_Source(**vars(solver))
    solver.solve()
예제 #5
0
        plt.draw()
        
    if tstep % config.write_result == 0:
        P = ifft2_mpi(P_hat*1j, P)
        curl = ifft2_mpi(1j*K[0]*U_hat[1]-1j*K[1]*U_hat[0], curl)
        hdf5file.write(tstep)   
        
    if tstep % config.plot_result == 0 and config.plot_result > 0:
        curl = ifft2_mpi(1j*K[0]*U_hat[1]-1j*K[1]*U_hat[0], curl)
        im.set_data(curl[:, :])
        im.autoscale()
        plt.pause(1e-6)
        
if __name__ == '__main__':
    config.update(
    {
      'solver': 'NS2D',
      'nu': 0.001,
      'dt': 0.005,
      'T': 50,
      'write_result': 100,
      'M': [6, 6]}
    )

    config.Isotropic.add_argument("--plot_result", type=int, default=10) # required to allow overloading through commandline
    solver = get_solver(update=update, regression_test=regression_test)
    solver.hdf5file.components["curl"] = solver.curl
    initialize(**vars(solver))
    solver.solve()

예제 #6
0
        
    if tstep % config.write_result == 0:
        P = ifft2_mpi(P_hat*1j, P)
        curl = ifft2_mpi(1j*K[0]*U_hat[1]-1j*K[1]*U_hat[0], curl)
        hdf5file.write(tstep)   
        
    if tstep % config.plot_result == 0 and config.plot_result > 0:
        curl = ifft2_mpi(1j*K[0]*U_hat[1]-1j*K[1]*U_hat[0], curl)
        im.set_data(curl[:, :])
        im.autoscale()
        plt.pause(1e-6)
        
if __name__ == '__main__':
    from cbcdns import config, get_solver
    config.update(
    {
      'nu': 0.001,
      'dt': 0.005,
      'T': 50,
      'write_result': 100}
    )

    config.parser.add_argument("--plot_result", type=int, default=10) # required to allow overloading through commandline
    solver = get_solver()
    solver.hdf5file.components["curl"] = solver.curl
    initialize(**vars(solver))
    solver.update = update
    solver.regression_test = regression_test
    solver.solve()