示例#1
0
def check_RungeKutta4_exact_multi(platform, func_src, func_pyf):
    from runge_kutta import RungeKutta


    #----------------------------------------------------
    # Allocate
    #----------------------------------------------------
    ps = PreSetup()
    nx, dt, tmax, yinit = ps.nx, ps.dt, ps.tmax, ps.yinit

    y = ArrayAs(platform, yinit, 'y')

    rk = RungeKutta(platform, nx, dt)


    #----------------------------------------------------
    # Core function
    #----------------------------------------------------
    lib = platform.source_compile(func_src, func_pyf)
    func_core = platform.get_function(lib, 'func')
    func_core.prepare('iDOO', nx)   # (t, y, ret)

    func = lambda t, y, ret: func_core.prepared_call(t,y,ret)
    comm = lambda k: None


    #----------------------------------------------------
    # RK4
    #----------------------------------------------------
    t = 0
    for tstep in xrange(tmax):
        rk.update_rk4(t, y, func, comm)
        t += dt

    aa_equal(ps.exact_func(t), y.get(), 13)
示例#2
0
    tmax = 10
    tgap = 1

    print 'tmax\t\t', tmax
    print 'tgap\t\t', tgap
    print '-'*47
    print ''

    """
    ret_psi = inside.compute_rhs(0, state.psi)
    numpy.save('compute_rhs_psi0.npy', state.psi)
    numpy.save('compute_rhs_psi1.npy', ret_psi)

    numpy.save('./run/%.6d_rank%d_psi.npy' % (0, rank), state.psi)
    numpy.save('./run/%.6d_rank%d_velocity.npy' % (0, rank), state.velocity)
    """

    #----------------------------------------------
    # time loop
    #----------------------------------------------
    for tstep in xrange(1,tmax+1):
        tloop.update_rk4(state.psi)

        if tstep%tgap == 0:
            print 'tstep=\t%d/%d (%g %s)\r' % (tstep, tmax, tstep/tmax*100, '%'),
            sys.stdout.flush()

            #numpy.save('./run/%.6d_rank%d_psi.npy' % (tstep, rank), state.psi)

    print ''
示例#3
0
    print 'tmax\t\t', tmax
    print 'tgap\t\t', tgap
    print '-'*47
    print ''

    """
    ret_psi = inside.compute_rhs_test(psi, 0)
    numpy.save('compute_rhs_psi0.npy', psi)
    numpy.save('compute_rhs_psi1.npy', ret_psi)

    """
    #numpy.save('./run/%.6d_rank%d_psi.npy' % (0, rank), psi)
    #numpy.save('./run/%.6d_rank%d_velocity.npy' % (0, rank), velocity)

    #----------------------------------------------
    # time loop
    #----------------------------------------------
    t = 0
    for tstep in xrange(1,tmax+1):
        rk.update_rk4(t, psi, se.update_element, se.average_boundary)
        t += dt

        if tstep%tgap == 0:
            print 'tstep=\t%d/%d (%g %s)\r' % (tstep, tmax, tstep/tmax*100, '%'),
            sys.stdout.flush()

            #numpy.save('./run/%.6d_rank%d_psi.npy' % (tstep, rank), psi)

    print ''