Expand description
§refprop
Safe, ergonomic Rust bindings for NIST REFPROP — thermodynamic and transport properties of refrigerants, pure fluids, and mixtures.
§Highlights
- Pure fluids —
Fluid::new("R134A") - Predefined mixtures —
Fluid::new("R410A")(loaded from.MIX) - Custom mixtures —
Fluid::mixture(&[("R32", 0.5), ("R125", 0.5)]) - CoolProp-style
get()—fluid.get("D", "T", 0.0, "Q", 100.0) - Configurable units — work in °C + bar, K + kPa, or any combination
- Thread-safe — global mutex prevents data races on REFPROP’s singleton state
FluidApitrait — common interface forFluidandParallelFluid, write generic code that works with either backend
§Quick example
use refprop::{Fluid, UnitSystem};
// Engineering units: °C, bar, kg/m³, kJ/kg
let co2 = Fluid::with_units("CO2", UnitSystem::engineering())?;
let p = co2.get("P", "T", -5.0, "Q", 100.0)?;
println!("Psat(-5 °C) = {p:.2} bar");
let d = co2.get("D", "T", -5.0, "Q", 100.0)?;
println!("D_vap(-5 °C) = {d:.2} kg/m³");§Generic code with FluidApi
use refprop::{FluidApi, Fluid, UnitSystem, Result};
fn density(f: &impl FluidApi, t: f64, p: f64) -> Result<f64> {
f.get("D", "T", t, "P", p)
}
let fluid = Fluid::with_units("R134A", UnitSystem::engineering())?;
let d = density(&fluid, 25.0, 10.0)?;§Unit system
Choose units at construction time with UnitSystem presets
(refprop(), engineering(),
si()) or the builder:
use refprop::{UnitSystem, TempUnit, PressUnit};
let units = UnitSystem::new()
.temperature(TempUnit::Celsius)
.pressure(PressUnit::Bar);§Mixtures
use refprop::{Fluid, UnitSystem};
// Predefined (from .MIX file)
let r410a = Fluid::with_units("R410A", UnitSystem::engineering())?;
// Custom composition
let r454c = Fluid::mixture_with_units(
&[("R32", 0.215), ("R1234YF", 0.785)],
UnitSystem::engineering(),
)?;Re-exports§
pub use error::RefpropError;pub use error::Result;pub use fluid::Fluid;pub use traits::FluidApi;pub use properties::CriticalProps;pub use properties::FluidInfo;pub use properties::SaturationProps;pub use properties::ThermoProp;pub use properties::TransportProps;pub use converter::Converter;pub use converter::UnitSystem;pub use converter::TempUnit;pub use converter::PressUnit;pub use converter::DensityUnit;pub use converter::EnergyUnit;pub use converter::EntropyUnit;pub use converter::ViscosityUnit;pub use converter::ConductivityUnit;