← Back to team overview

yade-users team mailing list archive

Re: [Question #294531]: Change colour of spheres when based on Movement

 

Question #294531 on Yade changed:
https://answers.launchpad.net/yade/+question/294531

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Clinton,

There could be several problems, why you don't see the spheres colored:
- the PyRynner is called not very often
- the scale is wrong (too small or too large)

follows your first example, for me works ok (particles goes from green to
yellow and to green again)
#########################################
readParamsFromTable(rMean=.05,rRelFuzz=.3,maxLoad=1e6,minLoad=1e4)
from yade.params.table import *

from yade import pack, plot
O.bodies.append(geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
sp=pack.SpherePack()
sp.makeCloud((0,0,0),(1,1,1),rMean=rMean,rRelFuzz=rRelFuzz)
sp.toSimulation()

O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_L3Geom(),Ig2_Facet_Sphere_L3Geom(),Ig2_Wall_Sphere_L3Geom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_L3Geom_FrictPhys_ElPerfPl()]
),
NewtonIntegrator(gravity=(0,0,-9.81),damping=0.5),
PyRunner(command='checkUnbalanced()',realPeriod=2,label='checker'),
PyRunner(command='ccc()',iterPeriod=10,label='checker'),
]
O.dt=.5*PWaveTimeStep()
def checkUnbalanced():
print O.iter
if O.iter<5000: return
if unbalancedForce()>.1: return
O.bodies.append(wall(max([b.state.pos[2]+b.shape.radius for b in O.bodies
if isinstance(b.shape,Sphere)]),axis=2,sense=-1))
global plate
plate=O.bodies[-1]
plate.state.vel=(0,0,-.1)
O.engines=O.engines+[PyRunner(command='addPlotData()',iterPeriod=200)]
checker.command='unloadPlate()'

def unloadPlate():
if abs(O.forces.f(plate.id)[2])>maxLoad:
plate.state.vel*=-1
checker.command='stopUnloading()'

def stopUnloading():
if abs(O.forces.f(plate.id)[2])<minLoad:
plot.saveDataTxt(O.tags['d.id']+'.txt')
O.pause()

def addPlotData():
if not isinstance(O.bodies[-1].shape,Wall):
plot.addData(); return
Fz=O.forces.f(plate.id)[2]
plot.addData(Fz=Fz,w=plate.state.pos[2]-plate.state.refPos[2],unbalanced=unbalancedForce(),i=O.iter)

def ccc():
for s in O.bodies:
s.shape.color=scalarOnColorScale(s.state.displ().norm(),0,1)

O.run()
#########################################


cheers
Jan

PS: when posting a code, try to make it minimal - deleting functions, lines
and comments, that are not important (like plots)


2016-05-29 5:16 GMT+02:00 Clinton Schramm <
question294531@xxxxxxxxxxxxxxxxxxxxx>:

> Question #294531 on Yade changed:
> https://answers.launchpad.net/yade/+question/294531
>
> Clinton Schramm gave more information on the question:
> Sorry for just spamming the code.
>
> I'm not sure how else to explain it.
>
> Cheers
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.