gas-force 0.1.0

Typed ideal-gas state and reference-condition conversions
Documentation
  • Coverage
  • 100%
    43 out of 43 items documented0 out of 37 items with examples
  • Size
  • Source code size: 18.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 501.7 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hidenoriuehara-art

gas-force

gas-force is a dependency-free Rust library for ideal-gas relationships. It keeps pressure, volume, absolute temperature, amount, and volumetric flow in separate validated types.

The library applies the ideal gas equation PV = nRT and can derive any one state variable from the other three. It also converts volume and volumetric flow between two pressure and temperature conditions while preserving the same amount of ideal gas.

Example

use gas_force::{
    GasCondition, IdealGasState, Pressure, Temperature, Volume, convert_volume,
};

let state = IdealGasState::from_pressure_volume_temperature(
    Pressure::kilopascals(100.0)?,
    Volume::liters(24.943_387_854_459_72)?,
    Temperature::celsius(26.85)?,
)?;
assert!((state.amount().as_moles() - 1.0).abs() < 1e-12);

let source = GasCondition::new(
    Pressure::kilopascals(100.0)?,
    Temperature::kelvin(300.0)?,
);
let destination = GasCondition::new(
    Pressure::kilopascals(200.0)?,
    Temperature::kelvin(300.0)?,
);
let converted = convert_volume(Volume::cubic_meters(1.0)?, source, destination)?;
assert!((converted.as_cubic_meters() - 0.5).abs() < 1e-12);

# Ok::<(), gas_force::GasError>(())

Run the bundled example:

cargo run --example ideal_gas

Scope and safety

This crate assumes an ideal gas in equilibrium and absolute pressure. It does not model real-gas compressibility, mixtures, phase change, combustion, leakage, pipe friction, toxicity, ventilation, ignition, equipment limits, or regulatory compliance. It must not be used as a gas-safety decision system.

License

MIT