volume of spheres inside a clump

Asked by Ruidong LI

Hi! I would like to calculate the volume of spheres inside each clump. How can I do this? Many thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Ruidong LI
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

please be more specific:
- "the volume of spheres" - volume of each sphere? Total volume? ... ?
- "spheres inside each clump" - spheres within the clump overlaps or not?
- ...

A MWE [1] (e.g. two artificial clumps with given expected result) would solve this.

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
Ruidong LI (kyle2000) said :
#2

Thanks for the reminder, Jan.

Actually, I would like to know the total volume of spheres in one clump. Actually, my clumps are generated by using the function 'yade.pack.regularHexa'. The surf is determined by importing the 'GTS' file. What I finally want is the ratio of the total volume of spheres to the corresponding volume of the GTS file.

Not sure whether I clarify my question or not. :(

Many thanks
Ruidong

Revision history for this message
Jan Stránský (honzik) said :
#3

> Not sure whether I clarify my question or not. :(

Not really..

> volume of spheres inside each clump
> I would like to know the total volume of spheres in one clump
> What I finally want is the ratio of the total volume of spheres to the corresponding volume of the GTS file

If you want total volume of spheres, why to bother with individual clumps?

Cheers
Jan

Revision history for this message
Ruidong LI (kyle2000) said :
#4

Dear Jan,

For each clump and corresponding 'gts' file, the ratio of the total volume of the clump (which may be more clear) to the volume of 'gts' can be calculated, right? I want to get this value for each clump.

Best regards,
Ruidong

Revision history for this message
Jan Stránský (honzik) said :
#5

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

Revision history for this message
Ruidong LI (kyle2000) said :
#6

Dear Jan,

Thanks for your help. Your answer helps a lot. But if we want to calculate the volume for the scenario where the spheres overlap, do you have any good ideas for solving this?

Best regards,
Ruidong LI

Revision history for this message
Jan Stránský (honzik) said :
#7

> the scenario where the spheres overlap, do you have any good ideas for solving this?

See parallel discussion [3].
A method similar to voxelPorosity could be used, i.e. discretization / voxelization of the clump space and testing if the point belongs to any sphere or not.

Cheers
Jan

[3] https://answers.launchpad.net/yade/+question/706640

Revision history for this message
Ruidong LI (kyle2000) said :
#8

OK. Thank you so much.