Struct reservoirs::reservoir::Reservoir[][src]

pub struct Reservoir {
    pub mass: Vec<f64>,
    // some fields omitted
}
Expand description

Struct for recording reservoir characteristics.

Fields

mass: Vec<f64>

Ages (in years) of deposits accumulated in reservoir.

Implementations

Fit reservoir to observed record.

Fit reservoirs to observed record.

Timed fit of reservoirs to observed record.

Goodness-of-fit test suite.

Compare the accumulated mass in a reservoir to another record. Produces two goodness-of-fit statistics in a tuple: the K-S statistic and the Kuiper statistic, respectively. Called by fit_rate, you can use it on individual records too.

Examples
use reservoirs::prelude::*;
fn main() -> Result<(), ResError> {
    let ages = vec![10.0, 42.0, 77.7, 12.0, 99.9, 10000.0, 777.7];
    let mut debris_flows = Reservoir::new()
        .input(&0.78)?
        .output(&0.78)?
        .sim();
    let fit = debris_flows.gof(&ages);
    println!("Fit is {:?}.", fit);
    Ok(())
}

Inherited age refers to age of charcoal upon entering the reservoir. Multiple samples of charcoal from a single deposit produces a vector of inherited ages, represented by the mean expected age of each charcoal sample in a f64 vector. The sample age of charcoal is the sum of its inherited age plus transit time through the reservoir. When simulating a reservoir model, each event entering the reservoir receives a random amount of inherited age sampled from the vector ages.

Examples
use reservoirs::prelude::*;
fn main() -> Result<(), ResError> {
    let start_ages = vec![7.0, 42.0, 401.0, 1234.5, 7777.7, 5.2, 0.1];
    let res = Reservoir::new().inherit(&start_ages);
    Ok(())
}

Assign an input rate to a reservoir. Converts a reference to a float 64 rate into an exponential distribution with lamdba rate using the rand crate.

Examples
use reservoirs::prelude::*;
fn main() -> Result<(), ResError> {
    // new reservoirs have no input rate, call input() to set one
    let mut res = Reservoir::new().input(&0.58)?;
    Ok(())
}

Set model parameters as fields in manager struct.

Create reservoirs using a builder pattern. Calling new() creates an empty reservoir. Use the input and output methods to set rates, which start at None. Set inherited age similarly using the method inherit.

Examples
use reservoirs::prelude::*;
fn main() -> Result<(), ResError> {
    let mut res = Reservoir::new();
    Ok(())
}

Runs sim() a number of times specified by ModelManager struct.

Assign an output rate to a reservoir. Converts a reference to a float 64 rate into an exponential distribution with lamdba rate using the rand crate.

Examples
use reservoirs::prelude::*;
fn main() -> Result<(), ResError> {
    // new reservoirs have no output rate, call input() to set one
    let mut res = Reservoir::new().output(&0.58)?;
    Ok(())
}

Assign a seed to the random number generator, for reproducibility.

  • seed is a number to convert in an RNG seed using the rand crate.
Examples
use reservoirs::prelude::*;
fn main() -> Result<(), ResError> {
    // new reservoirs have a random seed, call range() to set a specific seed
    let mut res = Reservoir::new().range(10101);
    Ok(())
}

Workhorse function for simulating accumulation records in a reservoir. Runs simulations on reservoir objects created using the builder pattern. period specifies the amount of time to simulate accumulation in years. While generally this is a function called in series by other functions, you can use it to simulate a single accumulation record for a reservoir.

Examples
use reservoirs::prelude::*;
fn main () -> Result<(), ResError> {
    // create reservoirs
    let mut fines = Reservoir::new().input(&0.75)?.output(&0.75)?;
    let mut gravels = Reservoir::new().input(&0.54)?.output(&0.54)?;

    // simulate accumulation for 30000 years
    fines = fines.sim();
    gravels = gravels.sim();
    Ok(())
}

Return a stereotypical mass age distribution at the current model parameters.

Returns raw transit times based on model parameters.

Return CDF of transit times based on model parameters.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.