how to replace particle

Asked by lip on 2019-04-15

hello
i want to know how to replace particles by thier id. For example, i have created many sphere particles using makecloud function, but i want to replace some sphere particles with polyhedra particles.Is there any function can help me do that job?
i would appreciate it if you can help me

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
2019-04-15
Last reply:
2019-04-15
Jan Stránský (honzik) said : #1

Hello,
I don't know about any pre-defined function. But it is not difficult:
###
bID = ... # id of existing particle
b = O.bodies[bID] # body instance
pos,r = b.state.pos, b.shape.radius # position and radius
b2 = createDuplicate(pos,2*r) # define this function according to your needs
O.bodies.erase(bID) # delete existing particle
newID = O.bodies.append(b2) # and adds new particle. Note that ID is different

def createDuplicate(pos,size): # for example
   from yade import polyhedra_utils
   return polyhedra_utils.polyhedralBall(.5*size,30,mat,pos)
###

cheers
Jan

Can you help with this problem?

Provide an answer of your own, or ask lip for more information if necessary.

To post a message you must log in.