← Back to team overview

yade-users team mailing list archive

Re: [Question #706733]: volume of spheres inside a clump

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Ok, now it makes more sense

> regularHexa

creates non-overlapping spheres, computation is then easier.

###
for b in O.bodies:
    if not b.isClump:
         continue # skip non-clumps
     vol = sum(4/3*pi*O.bodies[memberId].shape.radius**3 for memberId in b.shape.members) # [2]
     print(b.id,vol)
###

the 'vol' computation can be split into more functions to make it more readable:
###
def sphereVolume(radius):
    vol = 4 / 3 * pi * radius ** 3
    return vol
def id2radius(id):
    b = O.bodies[id]
    r = b.shape.radius
    return r

...
    vol = sum(sphereVolume(id2radius(memberId)) for memberId in b.shape.members)
###

Cheers
Jan

[2] https://yade-
dem.org/doc/yade.wrapper.html#yade.wrapper.Clump.members

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