-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_people.py
100 lines (81 loc) · 1.55 KB
/
generate_people.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from __future__ import print_function
from random import random
import numpy as np
names=[
'Ambarish',
'Bruno',
'Cecilia',
'Danilo',
'David',
'Ezequiel',
'Fabio',
'Franco',
'Freddy',
'Hossein',
'Luis',
'Maria',
'Michel',
'Moustafa',
'Muhammad',
'Oscar',
'PabloH.',
'PabloN.',
'Saeed',
'Tiago',
'Vinicius',
'William',
]
line0='ID MASS X Y V_X V_Y'
def rand(norm=1.):
return ( norm*(2.*random()-1.))
f=open('Workshop_people.txt','w')
print(line0,file=f)
G = 0.0374038
ind=0;dind=2.;theta=0
M=0;mass=50
print('ICTP',mass,0,0,0,0,sep='\t',file=f)
for i in range(12):
name=names[i]
M +=mass
ind += dind
mass = random()*(100./(10.+ind/dind))
r = (1+rand(.2))*ind
v = np.sqrt(G*M/r)
# r = random()*ind
# v = rand(.03*(ind-9))
theta += np.pi*.37
x = r*np.cos(theta)
y = r*np.sin(theta)
vx = -v*(y/r)
vy = v*(x/r)
print(name,mass,x,y,vx,vy,sep='\t',file=f)
print(name,mass,x,y,vx,vy,sep='\t')
for i in range(12,22,2):
name = names[i]
M +=mass
ind += dind
mass = random()*(100./(10.+ind/dind-12.))
r = (1+rand(.2))*ind
v = np.sqrt(G*M/r)
# r = random()*ind
# v = rand(.03*(ind-9))
theta += np.pi*.37
x = r*np.cos(theta)
y = r*np.sin(theta)
vx = -v*(y/r)
vy = v*(x/r)
print(name,mass,x,y,vx,vy,sep='\t',file=f)
print(name,mass,x,y,vx,vy,sep='\t')
name2 = names[i+1]
mass2 = .05*mass
dr = 1
r2 = r+dr
v2 = v+np.sqrt(G*mass/dr)
# r = random()*ind
# v = rand(.03*(ind-9))
x2 = r2*np.cos(theta)
y2 = r2*np.sin(theta)
vx2 = -v2*(y2/r2)
vy2 = v2*(x2/r2)
print(name2,mass2,x2,y2,vx2,vy2,sep='\t',file=f)
print(name2,mass2,x2,y2,vx2,vy2,sep='\t')