VasiliBaranov / packing-generation

Hard-sphere packing generation in C++ with the Lubachevsky–Stillinger, Jodrey–Tory, and force-biased algorithms and packing post-processing.
MIT License
106 stars 43 forks source link

How is porosity calculated #24

Open rpshi opened 3 years ago

rpshi commented 3 years ago

For a given packing size, for example, [nx,ny,nz], the generated particles may occupy in a region outside of the box defined by nx, ny and nz. I am just wondering how the final porosity is calculated? are you using the volume defined by the packing size defined in generation.conf? or the actual domain size occupied by the generated particles.

Thanks for the great tool!

Best,

VasiliBaranov commented 3 years ago

Hi,

sorry for a long time to reply.

The code assumes periodic boundary conditions: https://en.wikipedia.org/wiki/Periodic_boundary_conditions

So a particle can cross the boundary of the box, but "the same" particle (a periodically shifted copy of a particle) is crossing the box from another side. So the particle and its periodic copies occupy in one box exactly the same volume as one particle that is completely inside the box (4/3 pi R^3)

So you can calculate the density as \sum_i 4/3 pi R_i^3 / (nx ny nz) (where sum happens over all particles). Porosity is then 1 - density.

Hope this helps!

Best Regards, Vasili