← Back to team overview

yade-users team mailing list archive

Re: [Question #688837]: calculate the mass of the particles

 

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

    Status: Open => Answered

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

I have tried your code, but the spheres are larger than the cylinders and therefore no spheres are deposited inside any cylinder and their mass is zero.
Please update the code such that it results in something meaningful.

Otherwise the task is easy, something like:
###
cyl1 = pack.inCylinder(...) # [1], predicate for a cylinder
mass = 0.0
for b in O.bodies:
   if cyl1(b.state.pos): # b is inside cyl1
      mass += b.state.mass
###

or a one-liner :-)
mass = sum(b.state.mass for b in O.bodies if cyl1(b.state.pos))

cheers
Jan

[1] https://yade-
dem.org/doc/yade.pack.html#yade._packPredicates.inCylinder

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