# porosity calculation for clumps

Asked by Bettina Suhr on 2016-11-24

Dear all,

in simulations using clumps of overlapping spheres, I was wondering if the porosity is calculated correctly.
Using the following example, I obtain the same results with yade-1.20.0 and yade-2016.06a:

import numpy as np

#create a clump of two overlapping spheres:
ra=0.5
clump1=O.bodies.appendClumped([ sphere([0,0,0],ra), sphere([ra,0,0],ra) ])
O.bodies.updateClumpProperties(discretization=100)

#define a total volume for porosity calculation
Vtotal=(3*ra)*ra*2

#thanks to Wolfram alpha, the analytic solution should be
print "analytic solution: ", (Vtotal - (2*4.0/3.0 - 5.0/12.0)*np.pi*ra**3)/Vtotal

print "porosity calculated by yade: ", utils.porosity(Vtotal)

# a correct porosity could be calculated like this (?)
def myClumpPorosity(VolTot, density):
mass=sum([ b.state.mass for b in O.bodies if b.isClump])
return (VolTot -mass/density)/VolTot

print "my porosity: ", myClumpPorosity(Vtotal, O.materials[0].density)

Is there a bug in the porosity calculation or did I understand something wrong?
Regards,
Bettina

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
2016-11-24
Last query:
2016-11-24
2016-11-24
 Bruno Chareyre (bruno-chareyre) said on 2016-11-24: #1

Hi Bettina,
You find out that the volume(or mass) of the clump is calculated correctly (your third value).
The porosity is not and that is expected, because the porosity function just take the volumes all clump members without looking at overlaps between them (you can even have negative porosity as a consequence). De facto, the documentation of this function is mentionning spheres and only that, not clumps.
myClumpPorosity() is correct
There is also voxelPorosity, which should be be correct at the price of extra computation time.
Bruno

 Bettina Suhr (bettina-suhr) said on 2016-11-24: #2

Thanks Bruno Chareyre, that solved my question.