energy.py 1.66 KB
Newer Older
1 2
from yade import pack,plot

3
readParamsFromTable(useL3Geom=True,nonviscDamp=0,frictAngle=0,useClumps=False,noTableOk=True)
4
from yade.params import table
5 6

if 1:
7 8 9
	sp=pack.SpherePack();
	# bunch of balls, with an infinite plane just underneath
	if not table.useClumps: sp.makeCloud((0,0,0),(1,1,1),.05,.5);
10 11 12
	# use clumps of 2 spheres instead, to have rotation without friction 
	else: sp.makeClumpCloud((0,0,0),(1,1,1),[pack.SpherePack([((0,0,0),.05),((0,0,.08),.02)])],periodic=False)
	sp.toSimulation()
13 14
else: O.bodies.append(sphere((0,0,2),radius=.5)) # one single bouncing ball
O.bodies.append(wall(position=0,axis=2,sense=1))
15 16 17

O.engines=[
	ForceResetter(),
18
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]),
19
	InteractionLoop([Ig2_Sphere_Sphere_L3Geom(approxMask=0),Ig2_Wall_Sphere_L3Geom(approxMask=0)],[Ip2_FrictMat_FrictMat_FrictPhys(frictAngle=table.frictAngle)],[Law2_L3Geom_FrictPhys_ElPerfPl(noSlip=False,noBreak=False)]) if table.useL3Geom else InteractionLoop([Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],[Ip2_FrictMat_FrictMat_FrictPhys(frictAngle=table.frictAngle)],[Law2_ScGeom_FrictPhys_CundallStrack()]),
Christian Jakob's avatar
Christian Jakob committed
20
	NewtonIntegrator(damping=table.nonviscDamp,kinSplit=True,gravity=(0,0,-9.81)),
21
	PyRunner(iterPeriod=1,command='addPlotData()'),
22
]
23
O.dt=.1*PWaveTimeStep()
24

25
def addPlotData():
26
	Ek,maxId=kineticEnergy(findMaxId=True)
27
	plot.addData(i=O.iter,total=O.energy.total(),maxId=maxId,**O.energy)
28

29 30
# turn on energy tracking
O.trackEnergy=True
31
O.saveTmp()
32 33
# the callable should return list of strings, plots will be updated automatically
plot.plots={'i':[O.energy.keys,None,'total']}
34

35 36 37
#from yade import timing
#O.timingEnabled=True
#timing.stats()
Christian Jakob's avatar
Christian Jakob committed
38
plot.plot(subPlots=False)