← Back to team overview

yade-users team mailing list archive

Re: [Question #706022]: Is it possible to add hue to each radii sphere radius? Also, after simulation is my calculation wrong?

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

> I have two question

next time, please open separate questions for separate problems ([1],
point 5)

> 1. Is it possible to add color to each radii sphere radius?

yes. e.g.:
###
...
sp.toSimulation()
rMax = max(b.shape.radius for b in O.bodies if isinstance(b.shape,Sphere))
rMin = min(b.shape.radius for b in O.bodies if isinstance(b.shape,Sphere))
def radius2color(r,rMin,rMax):
    factor = (r-rMin)/(rMax-rMin)
    r = factor
    g = 0
    b = 1 - factor
    return (r,g,b)
for b in O.bodies:
    if not isinstance(b.shape,Sphere):
        continue
    b.shape.color = radius2color(b.shape.radius,rMin,rMax)
###

> O.run(1000)
> 2. After simulation, the sphere seems to pack well in the container, but my porosity after calculation if above 80+% did I have mistake in my calculation process?

The problem is that what you print is at the very beginning of the simulation, not "after calculation"
As mentioned in previous question, DO NOT use O.run(N) if you have code after it. Then the code is executed just after the O.run command, i.e. during the first time steps of the simulation.

Use
###
O.run(N,wait=True)
###
or
###
O.run(N)
O.wait()
###

If I use
O.run(20000,wait=True)
instead, I get porosity below 80%, although still very high.
Maybe some boundary effects..
 
Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask

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