← Back to team overview

yade-users team mailing list archive

Re: [Question #689910]: How to save only the particles that contain in the box below ?

 

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

    Status: Open => Answered

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

please read [1], section "Please, no external links!".

> order

"command" is more suitable English word

> Do you have a suggestion how to save only the particles that contain
in the box below ?

You have several options, e.g. save the packing "manually":
###
def particles_that_contain_in_the_box_below():
   ret = []
   for b in O.bodies:
      if not isinstance(b.shape,Sphere): continue # skip non-spherical, not clear if yes or not
      if b.state.pos[2] < 1: # for example, replace by your "contain in the box below" condition
         ret.append(b)
   return ret

particles = particles_that_contain_in_the_box_below()
with open("particles_that_contain_in_the_box_below.dat","w") as f:
   for particle in particles:
      x,y,z = p.state.pos
      f.write("{} {} {} {}\n".format(x,y,z,particle.shape.radius))
###

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.