collider-stride-triax.py 1.17 KB
Newer Older
1
""" Playground for tuning collider strides depending on maximum velocity. """
2
from __future__ import print_function
3

4
from builtins import range
5
from yade import timing
6 7
import os.path
loadFrom='/tmp/triax.xml'
8
#if not os.path.exists(loadFrom):
9
TriaxialTest(numberOfGrains=2000,noFiles=True).generate(loadFrom)
10 11
O.load(loadFrom)

12 13
collider=typedEngine('InsertionSortCollider')
newton=typedEngine('NewtonIntegrator')
14 15

# use striding; say "if 0:" to disable striding and compare to regular runs
16
if 1:
17
	# length by which bboxes will be made larger
Christian Jakob's avatar
Christian Jakob committed
18
	collider.verletDist=.2*O.bodies[100].shape.radius
19 20 21 22 23 24 25

O.step() # filter out initialization
O.timingEnabled=True
totalTime=0
# run a few times 500 steps, show timings to see what is the trend
# notably, the percentage of collider time should decrease as the max velocity decreases as well
for i in range(0,5):
26
	O.run(1000,True)
27 28
	timing.stats()
	totalTime+=sum([e.execTime for e in O.engines])
29 30
	print('Number of interactions: %d (real ratio: %g)'%(len(O.interactions),float(O.interactions.countReal())/len(O.interactions)))
	print('=======================================================')
31 32
	timing.reset()

33
print('Total time: %g s'%(totalTime/1e9))
34
#quit()