Exemple #1
0
def test_NS2D(args):
    config.update(
        {
            'nu': 0.01,
            'dt': 0.05,
            'T': 10
        }, 'doublyperiodic')
    solver = get_solver(regression_test=regression_test,
                        mesh='doublyperiodic',
                        parse_args=args)
    context = solver.get_context()
    initialize(solver, **context)
    solve(solver, context)

    config.params.dealias = '3/2-rule'
    initialize(solver, **context)
    solve(solver, context)

    config.params.dealias = '2/3-rule'
    config.params.optimization = 'cython'
    reload_module(solver)
    initialize(solver, **context)
    solve(solver, context)

    config.params.write_result = 1
    config.params.checkpoint = 1
    config.params.dt = 0.01
    config.params.t = 0.0
    config.params.tstep = 0
    config.params.T = 0.04
    solver.regression_test = lambda c: None
    initialize(solver, **context)
    solve(solver, context)
Exemple #2
0
def test_solvers(sol):
    config.update({
        'nu': 0.000625,  # Viscosity
        'dt': 0.01,  # Time step
        'T': 0.1,  # End time
        'convection': 'Vortex'
    })

    solver = get_solver(regression_test=regression_test, parse_args=sol)
    context = solver.get_context()
    initialize(solver, context)
    solve(solver, context)

    config.params.make_profile = 1
    config.params.dealias = '3/2-rule'
    initialize(solver, context)
    solve(solver, context)

    config.params.dealias = '2/3-rule'
    for opt in ('cython', 'numba', 'pythran'):
        config.params.optimization = opt
        reload_module(solver)  # To load optimized methods
        initialize(solver, context)
        solve(solver, context)

    config.params.write_result = 2
    config.params.checkpoint = 2
    config.params.dt = 0.01
    config.params.t = 0.0
    config.params.tstep = 0
    config.params.T = 0.04
    solver.regression_test = lambda c: None
    solve(solver, context)
Exemple #3
0
def test_MHD(sol):
    config.update({
        'nu': 0.000625,  # Viscosity
        'dt': 0.01,  # Time step
        'T': 0.1,  # End time
        'eta': 0.01,
        'L': [2 * pi, 4 * pi, 6 * pi],
        'M': [4, 5, 6],
        'convection': 'Divergence'
    })

    solver = get_solver(regression_test=regression_test, parse_args=sol)
    context = solver.get_context()
    initialize(**context)
    solve(solver, context)

    config.params.dealias = '3/2-rule'
    initialize(**context)
    solve(solver, context)

    config.params.dealias = '2/3-rule'
    config.params.optimization = 'cython'
    reload_module(solver)
    initialize(**context)
    solve(solver, context)

    config.params.write_result = 1
    config.params.checkpoint = 1
    config.dt = 0.01
    config.params.t = 0.0
    config.params.tstep = 0
    config.T = 0.04
    solver.regression_test = lambda c: None
    solve(solver, context)
Exemple #4
0
def test_NS2D(args):
    config.update({'nu': 0.01, 'dt': 0.05, 'T': 10}, 'doublyperiodic')
    solver = get_solver(regression_test=regression_test,
                        mesh='doublyperiodic',
                        parse_args=args)
    context = solver.get_context()
    initialize(**context)
    solve(solver, context)

    config.params.dealias = '3/2-rule'
    initialize(**context)
    solve(solver, context)

    config.params.dealias = '2/3-rule'
    config.params.optimization = 'cython'
    reload_module(solver)
    initialize(**context)
    solve(solver, context)

    config.params.write_result = 1
    config.params.checkpoint = 1
    config.params.dt = 0.01
    config.params.t = 0.0
    config.params.tstep = 0
    config.params.T = 0.04
    solver.regression_test = lambda c: None
    initialize(**context)
    solve(solver, context)
Exemple #5
0
def test_integrators(sol):
    config.update({
        'nu': 0.000625,  # Viscosity
        'dt': 0.01,  # Time step
        'T': 0.1,  # End time
        'convection': 'Vortex'
    })

    solver = get_solver(regression_test=regression_test, parse_args=sol)
    context = solver.get_context()
    for integrator in ('RK4', 'ForwardEuler', 'AB2', 'BS5_adaptive',
                       'BS5_fixed'):
        if integrator in ('ForwardEuler', 'AB2'):
            config.params.ntol = 4
        else:
            config.params.ntol = 7
        config.params.integrator = integrator
        initialize(solver, context)
        solve(solver, context)
Exemple #6
0
def test_integrators(sol):
    config.update(
        {
            'nu': 0.000625,             # Viscosity
            'dt': 0.01,                 # Time step
            'T': 0.1,                    # End time
            'convection': 'Vortex'
        }
    )

    solver = get_solver(regression_test=regression_test, parse_args=sol)
    context = solver.get_context()
    for integrator in ('RK4', 'ForwardEuler', 'AB2', 'BS5_adaptive', 'BS5_fixed'):
        if integrator in ('ForwardEuler', 'AB2'):
            config.params.ntol = 4
        else:
            config.params.ntol = 7
        config.params.integrator = integrator
        initialize(solver, context)
        solve(solver, context)
def test_channel(sol):
    config.update(
        {
            'Re': 8000.,
            'nu': 1. / 8000.,  # Viscosity
            'dt': 0.001,  # Time step
            'T': 0.01,  # End time
            'L': [2 * pi, pi, 2],
            'M': [2, 5, 7],
            'eps': 1e-7
        },
        "channel")

    solver = get_solver(regression_test=regression_test,
                        mesh="channel",
                        parse_args=[sol])
    context = solver.get_context()
    initialize(solver, context)
    set_Source(**context)
    solve(solver, context)

    config.params.dealias = '3/2-rule'
    config.params.optimization = 'cython'
    reload_module(solver)  # Need to reload to enable optimization
    initialize(solver, context)
    solve(solver, context)

    config.params.dealias_cheb = True
    config.params.checkpoint = 5
    config.params.write_result = 2
    initialize(solver, context)
    solve(solver, context)
Exemple #8
0
def test_channel(sol):
    if sol in ('IPCS', 'IPCSR', 'KMM_mpifft4py', 'KMMRK3_mpifft4py'):
        pytest.skip(sol+' not currently working')
    config.update(
        {
            'Re': 8000.,
            'nu': 1./8000.,             # Viscosity
            'dt': 0.001,                 # Time step
            'T': 0.01,                   # End time
            'L': [2, 2*pi, 4*pi/3.],
            'M': [7, 5, 2],
            'eps': 1e-7
        },  "channel"
    )

    solver = get_solver(regression_test=regression_test,
                        mesh="channel",
                        parse_args=[sol])
    context = solver.get_context()
    initialize(solver, context)
    set_Source(**context)
    solve(solver, context)

    config.params.dealias = '3/2-rule'
    config.params.optimization = 'cython'
    reload_module(solver) # Need to reload to enable optimization
    initialize(solver, context)
    solve(solver, context)

    config.params.dealias_cheb = True
    config.params.checkpoint = 5
    config.params.write_result = 2
    initialize(solver, context)
    solve(solver, context)
def test_channel(sol):
    config.update(
        {
            'Re': 8000.,
            'nu': 1./8000.,              # Viscosity
            'dt': 0.001,                 # Time step
            'T': 0.01,                   # End time
            'L': [2, 2*pi, 4*pi/3.],
            'M': [7, 5, 2],
            'eps': 1e-7
        }, "channel"
    )

    solver = get_solver(regression_test=regression_test,
                        mesh="channel",
                        parse_args=[sol])
    context = solver.get_context()
    initialize(solver, context)
    set_Source(**context)
    solve(solver, context)

    config.params.dealias = '3/2-rule'
    config.params.optimization = 'cython'
    reload_module(solver) # Need to reload to enable optimization
    initialize(solver, context)
    solve(solver, context)

    config.params.dealias_cheb = True
    config.params.checkpoint = 5
    config.params.write_result = 2
    initialize(solver, context)
    solve(solver, context)
Exemple #10
0
def test_solvers(sol):
    config.update(
        {
            'nu': 0.000625,             # Viscosity
            'dt': 0.01,                 # Time step
            'T': 0.1,                    # End time
            'convection': 'Vortex'
        }
    )

    solver = get_solver(regression_test=regression_test,
                        parse_args=sol)
    context = solver.get_context()
    initialize(solver, context)
    solve(solver, context)

    config.params.make_profile = 1
    config.params.dealias = '3/2-rule'
    initialize(solver, context)
    solve(solver, context)

    config.params.dealias = '2/3-rule'
    for opt in ('cython', 'numba', 'pythran'):
        config.params.optimization = opt
        reload_module(solver)  # To load optimized methods
        initialize(solver, context)
        solve(solver, context)

    config.params.write_result = 2
    config.params.checkpoint = 2
    config.params.dt = 0.01
    config.params.t = 0.0
    config.params.tstep = 0
    config.params.T = 0.04
    solver.regression_test = lambda c: None
    solve(solver, context)
Exemple #11
0
    solver.comm.Gather(u0, uall, root=0)
    if solver.rank == 0:
        uall = uall.reshape((params.N[0],))
        x0 = context.X[0][:, 0, 0]
        #x = x0
        #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(params.Re, params.t)
        u_exact = exact(x0, params.Re, params.t)
        print("Computed error = %2.8e %2.8e " %(np.sqrt(np.sum((uall-u_exact)**2)/params.N[0]), params.dt))

if __name__ == "__main__":
    config.update(
        {'Re': 800.,
         'nu': 1./800.,             # Viscosity
         'dt': 0.5,                 # Time step
         'T': 50.,                   # End time
         'L': [2, 2*np.pi, 4*np.pi/3.],
         'M': [6, 5, 2]
        }, "channel"
    )
    config.channel.add_argument("--compute_energy", type=int, default=5)
    config.channel.add_argument("--plot_step", type=int, default=10)
    solver = get_solver(update=update, regression_test=regression_test, mesh="channel")
    context = solver.get_context()
    initialize(**context)
    set_Source(**context)
    solve(solver, context)
Exemple #12
0
            curl = solver.get_curl(**context)
            im.set_data(curl[:, :])
            im.autoscale()
            plt.pause(1e-6)

def regression_test(context):
    params = config.params
    solver = config.solver
    dx, L = params.dx, params.L
    U = solver.get_velocity(**context)
    k = solver.comm.reduce(sum(U.astype(float64)*U.astype(float64))*dx[0]*dx[1]/L[0]/L[1]/2)
    U[0] = -sin(context.X[1])*cos(context.X[0])*exp(-2*params.nu*params.t)
    U[1] = sin(context.X[0])*cos(context.X[1])*exp(-2*params.nu*params.t)
    ke = solver.comm.reduce(sum(U.astype(float64)*U.astype(float64))*dx[0]*dx[1]/L[0]/L[1]/2)
    if solver.rank == 0:
        print("Error {}".format(k-ke))
        assert round(float(k - ke), params.ntol) == 0

if __name__ == '__main__':
    config.update(
        {'nu': 0.01,
         'dt': 0.05,
         'T': 10,
         'write_result': 100,
         'M': [6, 6]}, 'doublyperiodic')
    config.doublyperiodic.add_argument("--plot_result", type=int, default=10) # required to allow overloading through commandline
    sol = get_solver(update=update, regression_test=regression_test, mesh="doublyperiodic")
    context = sol.get_context()
    initialize(sol, **context)
    solve(sol, context)
Exemple #13
0
    U[0] = -sin(context.X[1]) * cos(context.X[0]) * exp(
        -2 * params.nu * params.t)
    U[1] = sin(context.X[0]) * cos(context.X[1]) * exp(
        -2 * params.nu * params.t)
    ke = solver.comm.reduce(
        sum(U.astype(float64) * U.astype(float64)) * dx[0] * dx[1] / L[0] /
        L[1] / 2)
    if solver.rank == 0:
        print("Error {}".format(k - ke))
        assert round(k - ke, params.ntol) == 0


if __name__ == '__main__':
    config.update(
        {
            'nu': 0.01,
            'dt': 0.05,
            'T': 10,
            'write_result': 100,
            'M': [6, 6]
        }, 'doublyperiodic')
    config.doublyperiodic.add_argument(
        "--plot_result", type=int,
        default=10)  # required to allow overloading through commandline
    sol = get_solver(update=update,
                     regression_test=regression_test,
                     mesh="doublyperiodic")
    context = sol.get_context()
    initialize(**context)
    solve(sol, context)
Exemple #14
0
    # current timestep
    U_hat[:] = f["U/Vector/3D/0"][su]
    context.g[:] = 1j*context.K[1]*U_hat[2] - 1j*context.K[2]*U_hat[1]
    f.close()

if __name__ == "__main__":
    config.update(
        {'nu': 1./180.,                  # Viscosity
         'Re_tau': 180.,
         'dt': 0.0005,                  # Time step
         'T': 100.,                    # End time
         'L': [2, 2*np.pi, np.pi],
         'M': [6, 6, 6],
         'dealias': '3/2-rule'
        }, "channel"
    )
    config.channel.add_argument("--compute_energy", type=int, default=10)
    config.channel.add_argument("--plot_result", type=int, default=100)
    config.channel.add_argument("--sample_stats", type=int, default=1000)
    config.channel.add_argument("--print_energy0", type=int, default=10)
    #solver = get_solver(update=update, mesh="channel")
    solver = get_solver(update=update, mesh="channel")
    context = solver.get_context()
    initialize(solver, context)
    #init_from_file("KMM666d.h5_c.h5", solver, context)
    set_Source(**context)
    solver.stats = Stats(context.U, solver.comm, filename="KMMstatsq")
    context.hdf5file.filename = "KMM666e"
    solve(solver, context)