#[repr(C)]pub struct Composition {Show 21 fields
pub methane: f64,
pub nitrogen: f64,
pub carbon_dioxide: f64,
pub ethane: f64,
pub propane: f64,
pub isobutane: f64,
pub n_butane: f64,
pub isopentane: f64,
pub n_pentane: f64,
pub hexane: f64,
pub heptane: f64,
pub octane: f64,
pub nonane: f64,
pub decane: f64,
pub hydrogen: f64,
pub oxygen: f64,
pub carbon_monoxide: f64,
pub water: f64,
pub hydrogen_sulfide: f64,
pub helium: f64,
pub argon: f64,
}Expand description
A complete gas composition made up of gas components.
A gas composition contains 21 gas components named by the field names in the struct.
The unit for each component is mole fraction, so the sum of all components should be 1.0.
If the initial sum of components is not 1.0, you can use the normalize function to scale it to 1.0.
§Example
let air = aga8::composition::Composition {
nitrogen: 0.78,
oxygen: 0.21,
argon: 0.009,
carbon_dioxide: 0.000_4,
water: 0.000_6,
..Default::default()
};
assert!((air.sum() - 1.0).abs() < 1.0e-10);Fields§
§methane: f64Methane CH4
nitrogen: f64Nitrogen N
carbon_dioxide: f64Carbon Dioxide CO2
ethane: f64Ethane C2H6
propane: f64Propane C3H8
isobutane: f64Isobutane C4H10
n_butane: f64Butane C4H10
isopentane: f64Isopentane C5H12
n_pentane: f64Pentane C5H12
hexane: f64Isopentane C6H14
heptane: f64Heptane C7H16
octane: f64Octane C8H18
nonane: f64Nonane C9H20
decane: f64Decane C10H22
hydrogen: f64Hydrogen H
oxygen: f64Oxygen O
carbon_monoxide: f64Carbon monoxide CO
water: f64Water H2O
hydrogen_sulfide: f64Hydrogen sulfide H2S
helium: f64Helium He
argon: f64Argon Ar
Implementations§
Source§impl Composition
impl Composition
Sourcepub fn sum(&self) -> f64
pub fn sum(&self) -> f64
Compute the sum of all components.
§Example
let comp = aga8::composition::Composition {
methane: 50.0,
ethane: 25.0,
carbon_dioxide: 25.0,
..Default::default()
};
assert!((comp.sum() - 100.0).abs() < 1.0e-10);Sourcepub fn normalize(&mut self) -> Result<(), CompositionError>
pub fn normalize(&mut self) -> Result<(), CompositionError>
Normalizes the composition sum to 1.0.
§Example
let mut comp = aga8::composition::Composition {
methane: 50.0,
ethane: 50.0,
..Default::default()
};
comp.normalize();
assert!((comp.ethane - 0.5).abs() < 1.0e-10);
assert!((comp.methane - 0.5).abs() < 1.0e-10);Trait Implementations§
Source§impl Clone for Composition
impl Clone for Composition
Source§fn clone(&self) -> Composition
fn clone(&self) -> Composition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for Composition
impl Default for Composition
Source§fn default() -> Composition
fn default() -> Composition
Returns the “default value” for a type. Read more
impl Copy for Composition
Auto Trait Implementations§
impl Freeze for Composition
impl RefUnwindSafe for Composition
impl Send for Composition
impl Sync for Composition
impl Unpin for Composition
impl UnwindSafe for Composition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more