Expand description
IAPWS-IF97 water/steam properties (Rust)
This crate provides two ways to call into the implementation:
- IF97 low-level functions: region-based
*_p_t/*_rho_tfunctions, using IF97 conventional SI units (p: MPa,T: K,h/u: kJ/kg,s: kJ/(kg·K),v: m³/kg). - Public string-dispatch API:
props/props_si, dispatching by a function name string (e.g."h_pT","T_ph").
§Quick start: XSteam-style API
- Function names are case-insensitive; the implementation applies
trim()+to_ascii_lowercase(). - Input units depend on the selected function name (the table below shows the most common subset).
use xsteamrs::props;
fn rel_close(a: f64, b: f64, rel: f64) -> bool {
if b == 0.0 { (a - b).abs() <= rel } else { ((a - b) / b).abs() <= rel }
}
// Example 1: p(bar) + T(°C) -> h(kJ/kg)
let h = props("h_pT", 1.0, 100.0).unwrap();
assert!(rel_close(h, 2_675.0, 1e-3));
// Example 2: p(bar) + h(kJ/kg) -> T(°C)
let t_c = props("T_ph", 1.0, 100.0).unwrap();
assert!(t_c.is_finite());§XSteam-style units (common subset)
*_p*:pin bar*_T*/*_t*:Tin °C (note: low-level IF97 functions use K)h/u:kJ/kgs:kJ/(kg·K)v:m³/kgrho:kg/m³Cp/Cv:kJ/(kg·K)w:m/smy(dynamic viscosity): XSteam.m default output (typicallyPa·s)tc(thermal conductivity): XSteam.m default output (typicallyW/(m·K))st(surface tension): XSteam.m default output (typicallyN/m)
The supported function names match the public interface in XSteam.m. See the fun list in
XSteam.m#L3826-L3829.
§Using low-level IF97 functions (more explicit types/units)
Low-level functions typically use parameter names like p_mpa and t_k to avoid unit
confusion:
- If you only know
(p, T): callregion_from_p_tand thenh1_p_t/h2_p_t/h3_p_t/h5_p_t, etc. - If you only know
(p, h): call [region_from_p_h] and thent1_p_h/t2_p_h/t3_p_h/t5_p_h, etc. - If you only know
(p, s): call [region_from_p_s] and thent1_p_s/t2_p_s/t3_p_s/t5_p_s, etc.
use xsteamrs::{h1_p_t, psat_mpa_from_t_k};
// Saturation pressure: input T(K), output p(MPa)
let p_sat = psat_mpa_from_t_k(373.15).unwrap();
assert!(p_sat > 0.0);
// Region 1: input p(MPa), T(K), output h(kJ/kg)
let h = h1_p_t(0.101_325, 373.15).unwrap();
assert!(h.is_finite());§Error handling
Prefer handling errors explicitly via If97Result returned by props / props_si.
Enums§
Functions§
- b23_
p_ mpa_ from_ t_ k - b23_
t_ k_ from_ p_ mpa - cp1_p_t
- cp2_p_t
- cp3_p_t
- cp3_
rho_ t - cp5_p_t
- cv1_p_t
- cv2_p_t
- cv3_p_t
- cv3_
rho_ t - cv5_p_t
- h1_p_t
- h2_p_t
- h3_p_t
- h3_
rho_ t - h5_p_t
- p1_h_s
- p2_h_s
- p3_h_s
- p3_
rho_ t - props
- Public string-dispatch API (XSteam units: bar / °C).
- props_
si - psat_
bar_ from_ t_ c - XSteam-style: given temperature
T(°C), compute saturation pressurepsat(bar). - psat_
mpa_ from_ t_ k - Given temperature
T(K), compute saturation pressurepsat(MPa). - region_
from_ p_ t - rho3_
p_ t - s1_p_t
- s2_p_t
- s3_p_t
- s3_
rho_ t - s5_p_t
- t1_p_h
- t1_
p_ rho - t1_p_s
- t2_p_h
- t2_
p_ rho - t2_p_s
- t3_p_h
- t3_p_s
- t5_p_h
- t5_p_s
- tsat_
c_ from_ p_ bar - XSteam-style: given saturation pressure
p(bar), compute saturation temperatureTsat(°C). - tsat_
k_ from_ p_ mpa - Given saturation pressure
p(MPa), compute saturation temperatureTsat(K). - u1_p_t
- u2_p_t
- u3_p_t
- u3_
rho_ t - u5_p_t
- v1_p_t
- v2_p_t
- v3_p_h
- v3_p_s
- v3_p_t
- v5_p_t
- w1_p_t
- w2_p_t
- w3_p_t
- w3_
rho_ t - w5_p_t
Type Aliases§
- If97
Result - IF97 result type.