Crate spherical_cow [−] [src]
Spherical Cow: A high volume fraction sphere packing library.
Usage
First, add spherical-cow
to the dependencies in your project's Cargo.toml
.
[dependencies]
spherical-cow = "0.1"
If you'd like to enable serialization through serde
add this line instead to turn on that feature
spherical-cow = { version = "0.1", features = ["serde-1"] }
Then, add this in your crate root:
extern crate spherical_cow;
Currently this library requires the rust nightly compiler as at depends on the remove_item
function of Vec
.
To calculate the volume_fraction
of a spherical container with radius 2 filled with spheres of radii between 0.05 and 0.1 is straightforward:
extern crate nalgebra; extern crate rand; extern crate spherical_cow; use spherical_cow::shapes::Sphere; use spherical_cow::PackedVolume; use rand::distributions::Range; use nalgebra::Point3; fn main() { // Pack spheres with radii between 0.05 and 0.1 into a spherical container of radius 2, // output quantitative analysis data. let boundary = Sphere::new(Point3::origin(), 2.0); let mut sizes = Range::new(0.05, 0.1); let packed = PackedVolume::new(boundary, &mut sizes); println!("Volume Fraction: {:.2}%", packed.volume_fraction() * 100.); }
A full list of examples can be found in the examples directory.
Research
The method implemented herein is an advancing front algorithm from Valera et al., Computational Particle Mechanics 2, 161 (2015).
Modules
shapes |
Collection of shapes usefull as containers, along with the all important |
util |
Useful helper functions such as a fast ray casting method and volume finder for use with arbitrary shaped triangular meshes. |
Structs
PackedVolume |
To obtain quantitative values of your packing effectiveness, |
Traits
Container |
The |
Functions
pack_spheres |
Packs all habitat spheres to be as dense as possible.
Requires a |