6 releases

0.3.2 Jan 25, 2021
0.3.1 Jan 25, 2021
0.2.2 Jan 18, 2021
0.2.1 Sep 14, 2020
0.1.0 Jul 25, 2020

#87 in #decompression

MIT license

57KB
995 lines

capra

Dive planning library. Currently supports mixed-gas open circuit dives.


lib.rs:

Dive planning library

Quick example

A quick example showing how to use this library:

use capra::modes::open_circuit::OpenCircuitParams;
use capra_core::{common, deco};
use time::Duration;
use capra::modes::OpenCircuit;
use capra::DivePlan;
use capra_core::deco::zhl16::tissue_constants::TissueConstants;
use capra_core::deco::zhl16::variant::Variant::B;
let air = common::Gas::new(21, 0, 79).unwrap();

// Make a new ZHL16 decompression model
let zhl16 = deco::zhl16::ZHL16::new(
    deco::Tissue::default(),
    TissueConstants::new_by_variant(B),
    50,
    70,
);

// Make a dive segment
let dive_segment = common::DiveSegment::new(
    common::SegmentType::DiveSegment,
    45,
    45,
    Duration::minutes(60),
    -10,
    20,
)
.unwrap();

let deco_gases = vec![(air, None)];
let segments = vec![(dive_segment, air)];
let parameters = OpenCircuitParams {
    ascent_rate: -10,
    descent_rate: 20,
    metres_per_bar: 10000.0 / common::DENSITY_SALTWATER,
    sac_bottom: 20,
    sac_deco: 15
};
let open_circuit = OpenCircuit::new(
    zhl16,
    &deco_gases,
    &segments,
    parameters
);

let results = open_circuit.plan();

for (segment, gas) in results.total_segments() {
    println!("{:?}, {:?}", segment, gas);
}

for (gas, qty) in results.gas_used() {
    println!("{:?}: {}", gas, qty);
}

Dependencies

~2.5MB
~55K SLoC