-
Notifications
You must be signed in to change notification settings - Fork 0
/
show.py
67 lines (49 loc) · 1.39 KB
/
show.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
from vpython import *
# CONSTANTS
SIGMA = 0.272
CELL_SIZE = 1.2 * SIGMA
ATOM_RADIUS = CELL_SIZE / 10
FILE = "02b"
dataCoordinates = open("data//data.coordinates." + FILE + ".txt", "r")
dataPlot = open("data//data.plot." + FILE + ".txt", "r")
def splitToVector(splitLine):
x = float(splitLine[0])
y = float(splitLine[1])
z = float(splitLine[2])
return vector(x, y, z)
def getNextPosition():
positions = []
line = dataCoordinates.readline()
while line:
splitLine = line.split()
if splitLine:
positions.append(splitToVector(splitLine))
else:
return positions
line = dataCoordinates.readline()
def createPoints(positions):
points = []
for p in positions:
points.append(sphere(pos=p, radius=ATOM_RADIUS))
return points
def changePosition(points, positions):
for i in range(len(points)):
points[i].pos = positions[i]
scene = canvas(width=500, height=500)
scene.autoscale = True
graph(width = 600, height = 200, title = dataPlot.readline().rstrip())
curve = gcurve(color=color.orange)
points = createPoints(getNextPosition())
scene.waitfor('click')
iter = 0
while True:
# sleep(0.5)
gnp = getNextPosition()
if gnp:
changePosition(points, gnp)
else:
break
curve.plot(pos=(iter, float(dataPlot.readline())))
iter += 1
dataCoordinates.close()
dataPlot.close()