Skip to content

thermalogic/iapws95_rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IAPWS-95 Thermodynamic Properties Library

A Rust implementation of the IAPWS-95 standard for calculating thermodynamic properties of water and steam.

Quick Start

Installation

The package is published on crates.io. Install it via:

cargo install iapws95

Usage

use 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))

API Reference

Single-Phase Properties

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

Saturation Properties

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);
}

Dependencies

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"

References

  1. IAPWS R6-95(2018) - Revised Release on the IAPWS Formulation 1995
  2. 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.

About

IAPWS-95 Thermodynamic Properties Library (Rust Implementation)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages