3 unstable releases

0.2.0 Feb 22, 2024
0.1.1 Feb 20, 2024
0.1.0 Feb 20, 2024

#1067 in Data structures

MIT license

28KB
426 lines

billios - A Soil Library

GitHub Actions Workflow Status Crates.io Version docs.rs

This crate is a collection of soil related data structures and formulae.

Installation

Standard functionality, no additional dependencies are required:

[dependencies]
billios = "0.2.0"

Alternatively, you can install using the cargo add command:

cargo add billios

Code Examples

Example - Sand Used

Using this formula only requires a couple lines of code.

Simply call the new() method with the desired values, then call calculate() to retrieve the result.

Use with constant sand_in_cone value:

use billios::field_test::*;

// This constructor  takes 3 arguments:
//
// cone_pre_test, cone_post_test, sand_in_cone
//
// The first two are straight forward; two float values.
// For the third we use the `None` option. The reason for this
// is becouse the `sand_in_cone` argument is a constant (mostly).
// In general this value does not change often, so we don't have to worry
// about setting it. Instead we just use `None`. If for some reason you
// needed to change the value, you simple pass in a `Some(<f64>).
let sand_used = SandUsed::new(14.65, 8.75, None);

// In order to get the calculated value we call the `calculate()` method:
let result = sand_used.calculate();

assert_eq!(2.31, result);

Use with a custom sand_in_cone value:

use billios::field_test::SandUsed;

let sand_used = SandUsed::new(14.65, 8.75, Some(3.59));
let result = sand_used.calculate();

assert_eq!(2.31, result);

Example - Compaction

Using this formula can a little more complicated than the last example. However it is still pretty straghtforward.

Use with pre-existing dry_density and moisture_content values:

use billios::field_test::*;

let wet_density = WetDensityChoice::Value(177.1429);
let moisture_content = MoistureContentChoice::Value(0.1428571);
let dry_density = DryDensity::new(wet_density, moisture_content);

let result = dry_density.calculate();

assert_eq!(155., result);

Use with dry_density and moisture_content constructors:

It is not necessary to calculate each of the values.

use billios::field_test::*;

let wd = WetDensity::new(4.65, 2.31, None);
let wet_density = WetDensityChoice::constructor(wd);
let mc = MoistureContent::new(1600., 1575., 1400.);
let moisture_content = MoistureContentChoice::constructor(mc);

let dry_density = DryDensity::new(wet_density, moisture_content);
let result = dry_density.calculate();

assert_eq!(155., result);

Todo

  • Implement GitHub Action workflow
  • Create first deployment to crates.io
  • Improve README.md
    • Add the build/crates.io/docs badges
  • Complete documentation
    • Need basic docs atleast for crates.io
    • lib.rs needs attention
  • Add Setter() methods to calculation structs
  • Possibly change choice enums (ex. SandUsedChoices) to SandUsedOption
  • Rework the public API. Namely how things like domain::types are accessed
  • More calculations?
  • Rename utilities.rs?
  • Rename calculations.rs to field_test.rs?

No runtime deps