Example #1
0
File: nbody.py Project: 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"
Example #2
0
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'