Skip to content

Commit c4783af

Browse files
committed
Remove time.clock from another demo program
1 parent 0293470 commit c4783af

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Demos_no_notebook/HardSphereGas.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from vpython import *
2-
from time import clock
32

43
# Hard-sphere gas.
54

@@ -48,7 +47,7 @@
4847
p = []
4948
apos = []
5049
pavg = sqrt(2*mass*1.5*k*T) # average kinetic energy p**2/(2mass) = (3/2)kT
51-
50+
5251
for i in range(Natoms):
5352
x = L*random()-L/2
5453
y = L*random()-L/2
@@ -152,24 +151,24 @@ def checkCollisions():
152151

153152
# Update all positions
154153
for i in range(Natoms): Atoms[i].pos = apos[i] = apos[i] + (p[i]/mass)*dt
155-
154+
156155
# Check for collisions
157156
hitlist = checkCollisions()
158157

159-
158+
160159
for i in range(Natoms):
161160
loc = apos[i]
162161
if abs(loc.x) > L/2:
163162
if loc.x < 0: p[i].x = abs(p[i].x)
164163
else: p[i].x = -abs(p[i].x)
165-
164+
166165
if abs(loc.y) > L/2:
167166
if loc.y < 0: p[i].y = abs(p[i].y)
168167
else: p[i].y = -abs(p[i].y)
169-
168+
170169
if abs(loc.z) > L/2:
171170
if loc.z < 0: p[i].z = abs(p[i].z)
172171
else: p[i].z = -abs(p[i].z)
173-
172+
174173
timer = clock()-timer
175174
print(timer)

0 commit comments

Comments
 (0)