← Back to team overview

yade-users team mailing list archive

Re: [Question #705005]: problem of erasing particle

 

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

Guo, Chang posted a new comment:
Dear Karol,

Thanks for your reply. How can I achieve it in the engine?

This code is not right.
def deletParticle():
    for bid in ParID:
        x=O.bodies[bid].state.pos[0]
        if  (0.2<x<0.3):
            O.bodies.erase(bid)
            ParID.remove(bid)
            print(f'Particle {bid} is deleted.')


sp=pack.SpherePack()
sp.makeCloud([0,0,0],[0.5,0.5,0.5],num=10000)
ParID=[]
for c,r in sp:
    ParID.append(O.bodies.append(sphere(c,r)))

O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb()]),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    GlobalStiffnessTimeStepper(),
    NewtonIntegrator(),
    PyRunner(command='O.wait()', firstIterRun=200),
    PyRunner(command='deletParticle()', firstIterRun=200),
    PyRunner(command='O.run()', firstIterRun=200),
]


O.run()

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