← Back to team overview

yade-users team mailing list archive

Re: [Question #667121]: Problem creating clumps with existing spheres

 

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

    Status: Open => Answered

Jérôme Duriez proposed the following answer:
Hi,

The appendClumped() function does two things from a list of bodies:

- it inserts in the simulation (O.bodies.append() ) the bodies you gave in the list
- it clumps these bodies

As such, it is not intended to be used with existing instances of bodies, such as you're doing here.
See the two following even more minimal examples (thank you very much for your short example though !)

***** DOES NOT WORK : similar to your script, and returning the same error*********
O.bodies.append(sphere([0,0,0], radius=0.5))
O.bodies.append(sphere([1,0,0], radius=0.5))
O.bodies.append(sphere([0,1,0], radius=0.5))

O.bodies.appendClumped([O.bodies[0],O.bodies[2]])
*********************************************************************

*********** WORKS !!! ***************
b0 = sphere([0,0,0], radius=0.5)
b1 = sphere([1,0,0], radius=0.5)
b2 = sphere([0,1,0], radius=0.5)

O.bodies.appendClumped([b0,b2])
*************************************

However, it is true these two examples are not equivalent since you end
up with three bodies in the 1st case, and only two in the second (you
may just add O.bodies.append(b1) to the second example, though)


The best for you is probably to use the O.bodies.clump() function

********* SOLUTION TO YOUR QUESTION ? ******
O.bodies.append(sphere([0,0,0], radius=0.5))
O.bodies.append(sphere([1,0,0], radius=0.5))
O.bodies.append(sphere([0,1,0], radius=0.5))

listOfFutureClumpMembersIds = []
for b in O.bodies:
  if b.state.pos[0]<0.1:
    listOfFutureClumpMembersIds.append(b.id)

O.bodies.clump(listOfFutureClumpMembersIds)
**************************************

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