コード例 #1
0
def nbody_debug(bodies, time_step):
    """Run simulation with visualization"""

    x_max = 500
    y_max = 500
    z_max = 500
    galaxy = random_galaxy(x_max, y_max, z_max, bodies)
    gfx = gfx_init(x_max, y_max, z_max)
    dt = 100.0  # One hundred year timesteps ensures that we see movement

    start = time.time()
    for _ in range(time_step):
        move(galaxy, dt)
        show(gfx, galaxy)
    stop = time.time()
    print 'Simulated ' + str(bodies) + ' bodies for ' + str(time_step) \
        + ' timesteps in ' + str(stop - start) + ' seconds'
コード例 #2
0
ファイル: nbody.py プロジェクト: stunax/cac
def nbody_benchmark(bodies_list, time_step):
    """Run benchmark simulation without visualization"""

    x_max = 1e18
    y_max = 1e18
    z_max = 1e18
    dt = 1e12
    for i in range(3):
        for bodies in bodies_list:
            solarsystem, asteroids = random_system(x_max, y_max, z_max, 10, bodies)
            start = time.time()
            for _ in range(time_step):
                move(solarsystem, asteroids, dt)
            stop = time.time()

            print "Simulated " + str(bodies) + " bodies for " + str(time_step) + " timesteps in " + str(
                stop - start
            ) + " seconds"
コード例 #3
0
ファイル: nbody.py プロジェクト: etzemis/SignificantProjects
def nbody_benchmark(bodies_list, time_step):
    """Run benchmark simulation without visualization"""

    x_max = 500
    y_max = 500
    z_max = 500
    dt = 1.0  # One year timesteps for better accuracy

    for bodies in bodies_list:
        galaxy = random_galaxy(x_max, y_max, z_max, bodies)

        start = time.time()
        for _ in range(time_step):
            move(galaxy, dt)
        stop = time.time()

        print 'Simulated ' + str(bodies) + ' bodies for ' \
            + str(time_step) + ' timesteps in ' + str(stop - start) \
            + ' seconds'
コード例 #4
0
ファイル: nbody.py プロジェクト: etzemis/SignificantProjects
def nbody_benchmark(bodies_list, time_step):
    """Run benchmark simulation without visualization"""

    x_max = 500
    y_max = 500
    z_max = 500
    dt = 1.0  # One year timesteps for better accuracy

    for bodies in bodies_list:
        galaxy = random_galaxy(x_max, y_max, z_max, bodies)

        start = time.time()
        for _ in range(time_step):
            move(galaxy, dt)
        stop = time.time()

        print 'Simulated ' + str(bodies) + ' bodies for ' \
            + str(time_step) + ' timesteps in ' + str(stop - start) \
            + ' seconds'
コード例 #5
0
ファイル: nbodyvisual.py プロジェクト: stunax/cac
def nbody_debug(n, bodies, time_step):
    """Run simulation with visualization"""

    x_max = 1e18
    y_max = 1e18
    z_max = 1e18
    
    solarsystem, asteroids= random_system(x_max, y_max, z_max, n, bodies)

    P3 = gfx_init(x_max, y_max, z_max)
    dt = 1e12  # One hundred year timesteps ensures that we see movement



    start = time.time()
    for step in range(time_step):
        if step%1 == 0:
            show(P3, solarsystem, asteroids)
        move(solarsystem, asteroids, dt)
        print step
    stop = time.time()
    print 'Simulated ' + str(bodies) + ' bodies for ' + str(time_step) \
        + ' timesteps in ' + str(stop - start) + ' seconds'