← Back to team overview

yade-users team mailing list archive

Re: [Question #705744]: Divide numerical periodic microstructure box into smaller grided cubes or boxes


Question #705744 on Yade changed:

    Status: Open => Answered

Jan Stránský proposed the following answer:

deleting particles from certain region is not difficult.
As a starting point, see a MWE below.


from yade import pack
pred = pack.inAlignedBox((0, 0, 0), (30, 30, 8))
sphs = pack.regularHexa(pred, radius=1, gap=0)

pores = [ # list of (center,radius) values of the spherical pores
    (Vector3(20, 20, 1), 7),
    (Vector3(6, 6, 6), 5),

def isInPore(body, pore):
    bpos, br = body.state.pos, body.shape.radius
    ppos,pr = pore
    dc = (bpos-ppos).norm() # center distance
    return dc + br < pr # including body radius (entire body is inside pore), could be only center-based or mixed

def makePores():
    for b in O.bodies:
        if any(isInPore(b,pore) for pore in pores):


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