File tree Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 1
1
from vpython import *
2
- from time import clock
3
2
4
3
# Hard-sphere gas.
5
4
48
47
p = []
49
48
apos = []
50
49
pavg = sqrt (2 * mass * 1.5 * k * T ) # average kinetic energy p**2/(2mass) = (3/2)kT
51
-
50
+
52
51
for i in range (Natoms ):
53
52
x = L * random ()- L / 2
54
53
y = L * random ()- L / 2
@@ -152,24 +151,24 @@ def checkCollisions():
152
151
153
152
# Update all positions
154
153
for i in range (Natoms ): Atoms [i ].pos = apos [i ] = apos [i ] + (p [i ]/ mass )* dt
155
-
154
+
156
155
# Check for collisions
157
156
hitlist = checkCollisions ()
158
157
159
-
158
+
160
159
for i in range (Natoms ):
161
160
loc = apos [i ]
162
161
if abs (loc .x ) > L / 2 :
163
162
if loc .x < 0 : p [i ].x = abs (p [i ].x )
164
163
else : p [i ].x = - abs (p [i ].x )
165
-
164
+
166
165
if abs (loc .y ) > L / 2 :
167
166
if loc .y < 0 : p [i ].y = abs (p [i ].y )
168
167
else : p [i ].y = - abs (p [i ].y )
169
-
168
+
170
169
if abs (loc .z ) > L / 2 :
171
170
if loc .z < 0 : p [i ].z = abs (p [i ].z )
172
171
else : p [i ].z = - abs (p [i ].z )
173
-
172
+
174
173
timer = clock ()- timer
175
174
print (timer )
Original file line number Diff line number Diff line change 1
1
import time
2
- try :
3
- _clock = time .perf_counter # time.clock is deprecated in Python 3.3, gone in 3.8
4
- except :
5
- _clock = time . clock
2
+
3
+ _clock = time .perf_counter
4
+
5
+
6
6
_tick = 1 / 60
7
7
8
8
#import platform
Original file line number Diff line number Diff line change 6
6
from math import sqrt , tan , pi
7
7
8
8
import time
9
- try :
10
- clock = time . perf_counter # time.clock is deprecated in Python 3.3, gone in 3.8
11
- except :
12
- clock = time . clock
9
+
10
+ # vpython provides clock in its namespace
11
+ clock = time . perf_counter
12
+
13
13
import sys
14
14
from . import __version__ , __gs_version__
15
15
from ._notebook_helpers import _isnotebook
You can’t perform that action at this time.
0 commit comments