# 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"] }
```

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:

use spherical_cow::shapes::Sphere; use spherical_cow::PackedVolume; use rand::distributions::Uniform; use nalgebra::{Matrix, 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).unwrap(); let mut sizes = Uniform::new(0.05, 0.1); let packed = PackedVolume::new(boundary, &mut sizes).unwrap(); 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

errors | Handles any errors that could occur during packing. |

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 |