(N, n_iter)
| 45 | return sep < sum_r |
| 46 | |
| 47 | def run_oo_sim(N, n_iter): |
| 48 | box_x, box_y = 10., 6. |
| 49 | r_min, r_max = 0.1, 0.3 |
| 50 | print(f'n balls={N}') |
| 51 | for i in range(n_iter): |
| 52 | balls = [] |
| 53 | for j in range(N): |
| 54 | x = r_max + (box_x-2*r_max)*rand() |
| 55 | y = r_max + (box_y-2*r_max)*rand() |
| 56 | R = 0.1 + 0.8*rand() |
| 57 | balls.append( Ball(x,y,R) ) |
| 58 | |
| 59 | coll = np.eye(N, dtype=np.bool) |
| 60 | T_s = time.time() |
| 61 | for j in range(N): |
| 62 | for k in range(j+1,N): |
| 63 | coll[j,k] = balls[j].collides_with(balls[k]) |
| 64 | coll[k,j] = coll[j,k] |
| 65 | |
| 66 | n_coll = (np.sum(coll) - N)//2 |
| 67 | print(f'n coll={n_coll} Hz = ' |
| 68 | f'{1/(time.time()-T_s):.2f}') |
| 69 | |
| 70 | def main(): |
| 71 | run_oo_sim(1000, 10) |
no test coverage detected