# how to yield color nephogram of velocity in yade

Asked by lip on 2019-06-29

hello
i was simulating the collapse of particle collummn, and i want to know how to yield color nephogram of velocity in yade. i have tried to use function scalarOnColorScale,but it did not work well.
below is my code:
from yade import polyhedra_utils,pack,plot,utils
import random

m = FrictMat(young=5e7,poisson=.3)
n = PolyhedraMat(young=5e7,poisson=.3)

O.materials.append((m,n))

#the boundary of particle deposit
v1=((0,0,0),(0,3.2,0),(0,0,40),(0,3.2,40),(-0.1,0,0),(-0.1,3.2,0),(-0.1,0,40),(-0.1,3.2,40))
v2=((0,0,0),(0,0,40),(18,0,0),(18,0,40),(0,0.1,0),(0,0.1,40),(18,0.1,0),(18,0.1,40))
v3=((0,3.1,0),(0,3.1,40),(18,3.1,0),(18,3.1,40),(0,3.2,0),(0,3.2,40),(18,3.2,0),(18,3.2,40))
v4=((0,0,0),(0,3.2,0),(18,3.2,0),(18,0,0),(0,0,-0.1),(0,3.2,-0.1),(18,3.2,-0.1),(18,0,-0.1))
v5=((3,0.1,0),(3,3.1,0),(3,0.1,40),(3,3.1,40),(3.1,0.1,0),(3.1,3.1,0),(3.1,0.1,40),(3.1,3.1,40))
b1 = polyhedra_utils.polyhedra(material=n,v=v1,fixed=True) # you can set wire at
b2 = polyhedra_utils.polyhedra(material=n,v=v2,fixed=True)
b3 = polyhedra_utils.polyhedra(material=n,v=v3,fixed=True)
b4 = polyhedra_utils.polyhedra(material=n,v=v4,fixed=True)
wall = polyhedra_utils.polyhedra(material=n,v=v5,fixed=True)
b1.shape.wire=True
b2.shape.wire=True
b3.shape.wire=True
b4.shape.wire=True

O.bodies.append((b1,b2,b3,b4,wall))

#sphere particles mixed with polyhedra
sp=pack.SpherePack()
sp.makeCloud((0.2,0.2,5),(2.8,2.8,75),psdSizes=[0.399999999,0.4000000,0.8],psdCumm=(0.00001,0.8,1),seed=1,porosity=10)

for center,radius in sp:
if radius >= 0.2:
t = polyhedra_utils.polyhedra(n,(0.5,0.5,0.5))
t.state.pos = center # sets polyhedron position according to sphere position
O.bodies.append(t)
else:
O.bodies.append(t)
#simulation

O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Polyhedra_Aabb(),Bo1_Sphere_Aabb()]),
InteractionLoop(
[Ig2_Polyhedra_Polyhedra_PolyhedraGeom(),Ig2_Sphere_Polyhedra_ScGeom(),Ig2_Sphere_Sphere_ScGeom()],
[Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys(),Ip2_FrictMat_PolyhedraMat_FrictPhys(),Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack(),Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()]
),
# GravityEngine(gravity=(0,0,-9.81)),
NewtonIntegrator(damping=0.5, gravity=(0, 0, -9.81)),
PyRunner(command='checkUnbalanced()', realPeriod=3, label='checker'),
PyRunner(command='changecolor()', realPeriod=3)
]

O.dt=10e-4
O.trackEnergy=True

def changecolor():
for b in O.bodies:
if b.id>4:
t=b.state.vel.norm()
b.shape.color=scalarOnColorScale(4*t,0,pi/2.)

def checkUnbalanced():
print unbalancedForce()
if unbalancedForce()<.05:
for b in O.bodies:
b.state.vel=(0,0,0)
O.pause()

O.saveTmp()

## Question information

Language:
English Edit question
Status:
Expired
For:
Assignee:
No assignee Edit question
Last query:
2019-06-29
2019-07-15
 Bruno Chareyre (bruno-chareyre) said on 2019-06-29: #1

>it did not work well.