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'
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'