Spherical Cow: A high volume fraction sphere packing library


#1

Hi all,

I’d like to introduce you to my first (published) library spherical-cow.

Packing spheres of random size into a container of arbitrary geometry is useful in many research areas. For example: blunt force trauma to the skull can be studied without the need for lengthy prison sentences by simulating a skull densely packed with spheres and your favourite physics engine.

This library implements an advancing front algorithm obtaining volume fractions of over 60% under standard benchmarking conditions. This is the highest VF I’ve seen for size-varying radii. Since the optimal VF for this kind of packing is currently unknown to mathematicians, we can conjecture that spherical-cow can pack your spheres better than anyone else can.

Since this is my first crate I’d really appreciate some feedback on the coding style, where I can improve things to be more in line with standard styles and ideas. Tests, benchmarks, better error handling etc are all on the way, and if you have any requests for features: feel free to drop an issue on the tracker.


#2

As a physicist, this name gets two thumbs up


#3

Love the logo! Colourful, humourous, and a perfect illustration just how arbitrary the volumes are that you support :thumbsup:
So, is your next project going to deal with fluid dynamics and be called “in a vacuum”? :wink:

As for API advice, the (very successful) Libz-Blitz community has codified their combined recommendations into a handy set of Rust API guidelines.
This represents the current state-of-the-art best practices for rust libraries.
I hope this can get you started in the right direction, even if it is all very general.