-
Notifications
You must be signed in to change notification settings - Fork 0
/
N_body_sim_manager.py
66 lines (46 loc) · 1.51 KB
/
N_body_sim_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import pygame
from pygame.locals import *
from N_body_Particle import Particle
import N_body_parameters as param
import math
import random
###dense=False
test_collapse=True
dense=False
circular_random=True
#-----------------INITIALIZATION OF PARTICLES
num_particles = param.num_particles_orig
particles=[Particle() for i in range(num_particles)]
fixed_particles=[]
#velocity distribution
if test_collapse:
for p in particles:
p.vel=[0,0]
#position distribution
if dense:
for p in particles:
p.pos =[random.uniform(400,param.screen_size[0]-400),random.uniform(200,param.screen_size[1]-200)]
#position distribution
if circular_random:
for p in particles:
radius =param.ccradius*(random.uniform(0,1))
phi = random.uniform(0,2*math.pi);
x = radius*math.cos(phi);
y = radius*math.sin(phi);
p.pos =[600+x,350+y]
def reset_initial_conditions(N):#used for comparing complexity of BH vs. DC
global num_particles
global particles
num_particles = N
particles=[Particle() for i in range(num_particles)]
return particles
#------------------------OTHER INITIALIZATIONS
run=0
screen_shots=0
pygame.display.init()
pygame.font.init()
icon = pygame.Surface((1,1)); icon.set_alpha(0);pygame.display.set_icon(icon)
pygame.display.set_caption("TIPE N-body sim/Verlet/N large")
surface = pygame.display.set_mode(param.screen_size)
global clock
clock = pygame.time.Clock()