aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
blob: 8fd6b177e6869b68029615126164a12774096ac5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
pub mod unit_of_measurement;

use crate::unit_of_measurement::{Pressure, Temperature, Volume};

const GAS_CONSTANT: f64 = 8.314472;
const MOLAR_MASS_OF_AIR: f64 = 0.0289647; // Kg/mol

fn moles_from_gas_law(pres: Pressure, vol: Volume, temp: Temperature) -> f64 {
    (pres.as_pascals() * vol.as_cubic_metres()) / (GAS_CONSTANT * temp.as_kelvin())
}