A Rust implementation of the IAPWS-95 standard for calculating thermodynamic properties of water and steam.
The package is published on crates.io. Install it via:
cargo install iapws95use iapws95::iapws95::*;
let t_c = 26.85; // Temperature (°C), 300.0K
let rho = 0.9965560e3; // Density (kg/m³)
let p = tr2p(t_c, rho); // Pressure (MPa)
let u = tr2u(t_c, rho); // Internal energy (kJ/kg)
let h = tr2h(t_c, rho); // Enthalpy (kJ/kg)
let s = tr2s(t_c, rho); // Entropy (kJ/(kg·K))All functions accept temperature in in °C and density in kg/m³:
| Function | Description | Returns |
|---|---|---|
tr2p(t_c, rho) |
Pressure | MPa |
tr2u(t_c, rho) |
Internal energy | kJ/kg |
tr2h(t_c, rho) |
Enthalpy | kJ/kg |
tr2s(t_c, rho) |
Entropy | kJ/(kg·K) |
tr2cv(t_c, rho) |
Constant-volume specific heat | kJ/(kg·K) |
tr2cp(t_c, rho) |
Constant-pressure specific heat | kJ/(kg·K) |
tr2w(t_c, rho) |
Speed of sound | m/s |
tr2jt(t_c, rho) |
Joule-Thomson coefficient | K/MPa |
tr2itt(t_c, rho) |
Isothermal throttling coefficient | kJ/(kg·MPa) |
tr2beta_s(t_c, rho) |
Isentropic temperature-pressure coefficient | 1/K |
use iapws95::iapws95_saturation::sat_t;
if let Some(props) = sat_t(100.0) { // Temperature in °C
println!("p_sat: {} MPa", props.p_sat);
println!("rho_l: {} kg/m³", props.rho_l);
println!("rho_v: {} kg/m³", props.rho_v);
println!("h_l: {} kJ/kg", props.h_l);
println!("h_v: {} kJ/kg", props.h_v);
println!("s_l: {} kJ/(kg·K)", props.s_l);
println!("s_v: {} kJ/(kg·K)", props.s_v);
}No external runtime dependencies. Only uses Rust standard library.
[dev-dependencies]
assert_approx_eq = "1.1.0"
criterion = { version = "0.8.2", features = ["html_reports"] }
seuif97 = "1.0"- IAPWS R6-95(2018) - Revised Release on the IAPWS Formulation 1995
- Wagner, W. & Pruss, A. (2002). The IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance. J. Phys. Chem. Ref. Data, 31(2), 387-535.