-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.py
32 lines (30 loc) · 871 Bytes
/
variables.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
import numpy as np
SPEED = 0.03
with open('output.data') as f:
numberOfParticles = None
particle = 0
velocity = [0,0]
time = None
for line in f:
if (not numberOfParticles):
numberOfParticles = int(line)
continue
if (time == None):
time = int(line)
continue
numbers = line.split()
angle = float(numbers[-1])
velocity[0] += np.cos(angle)
velocity[1] += np.sin(angle)
particle += 1
if (particle == numberOfParticles):
particle = 0
module = np.sqrt(velocity[0] ** 2 + velocity[1] ** 2)
print("{} {}".format(
time,
module /(numberOfParticles),
)
)
velocity = [0,0]
numberOfParticles = None
time = None