Crate if97

source ·
Expand description

IF97

IF97 is the high-speed package of IAPWS-IF97 in Rust. It is suitable for computation-intensive calculations,such as heat cycle calculations, simulations of non-stationary processes, real-time process monitoring and optimizations.

Through the high-speed package, the results of the IAPWS-IF97 are accurately produced at about 5-15x speed-up compared to the powi() of the Rust standard library.

  • The comparison results of the computing-time are obtained using the criterion.rs.

The Fast Algorithm

  1. The shortest addition chain computes integer powers of a number.(the paper in chinese)
  2. The recursive algorithm computes the polynomial values of the base variable and its derivatives

In IF97, 36 thermodynamic, transport and further properties can be calculated.

The following input pairs are implemented:

(p,t) (p,h) (p,s) (p,v) 

(t,h) (t,s) (t,v) 

(p,x) (t,x) (h,x) (s,x) 

(h,s)  

Usage

The type of functions are provided in the if97 package:

fn(f64,f64,i32) -> f64;
  • the first,second input parameters: the input propertry pairs
  • the third input parameter: the property ID of the calculated property - o_id
  • the return: the calculated property value of o_id
pt(p:f64,t:f64,o_id:i32)->f64
ph(p:f64,h:f64,o_id:i32)->f64
ps(p:f64,s:f64,o_id:i32)->f64
pv(p:f64,v:f64,o_id:i32)->f64

th(t:f64,h:f64,o_id:i32)->f64
ts(t:f64,s:f64,o_id:i32)->f64
tv(t:f64,v:f64,o_id:i32)->f64

px(p:f64,x:f64,o_id:i32)->f64
tx(p:f64,x:f64,o_id:i32)->f64
hx(h:f64,x:f64,o_id:i32)->f64
sx(s:f64,x:f64,o_id:i32)->f64

hs(h:f64,s:f64,o_id:i32)->f64

Example

use if97::*;
fn main() {
    
    let p:f64 = 3.0;
    let t:f64= 300.0-273.15;
   
    let h=pt(p,t,OH);
    let s=pt(p,t,OS);
    let v=pt(p,t,OV);
    println!("p={p:.6} t={t:.6} h={t:.6} s={s:.6} v={v:.6}");   
}

Properties

PropertryUnitSymbolo_ido_id(i32)
PressureMPapOP0
Temperature°CtOT1
Densitykg/m³ρOD2
Specific Volumem³/kgvOV3
Specific enthalpykJ/kghOH4
Specific entropykJ/(kg·K)sOS5
Specific exergykJ/kgeOE6
Specific internal energykJ/kguOU7
Specific isobaric heat capacitykJ/(kg·K)cpOCP8
Specific isochoric heat capacitykJ/(kg·K)cvOCV9
Speed of soundm/swOW10
Isentropic exponentkOKS11
Specific Helmholtz free energykJ/kgfOF12
Specific Gibbs free energykJ/kggOG13
Compressibility factorzOZ14
Steam qualityxOX15
RegionrOR16
Isobari cubic expansion coefficient1/KɑvOEC17
Isothermal compressibility1/MPakTOKT18
Partial derivative (∂V/∂T)pm³/(kg·K)(∂V/∂T)pODVDT19
Partial derivative (∂V/∂p)Tm³/(kg·MPa)(∂v/∂p)tODVDP20
Partial derivative (∂P/∂T)vMPa/K(∂p/∂t)vODPDT21
Isothermal throttling coefficientkJ/(kg·MPa)δtOIJTC22
Joule-Thomson coefficientK/MPaμOJTC23
Dynamic viscosityPa·sηODV24
Kinematic viscositym²/sνOKV25
Thermal conductivityW/(m.K)λOTC26
Thermal diffusivitym²/saOTD27
Prandtl numberPrOPR28
Surface tensionN/mσOST29
Static Dielectric ConstantεOSDC30
Isochoric pressure coefficient1/KβOPC31
Isothermal stress coefficientkg/m³βpOBETAP32
Fugacity coefficientfiOFI33
FugacityMPaf*OFU34
Relative pressure coefficient1/KαpOAFLAP35

Constants

  • αp - Relative pressure coefficient 1/K
  • βp - Isothermal stress coefficient, kg/m³
  • cp - Specific isobaric heat capacity kJ/(kg·K)
  • cv - Specific isochoric heat capacity kJ/(kg·K)
  • ρ - Density kg/m³
  • (∂p/∂t)v - Partial derivative MPa/K
  • η - Dynamic viscosity Pa.s dv
  • (∂V/∂P)T - Partial derivative m³/(kg·MPa)
  • (∂V/∂T)p - Partial derivative m³/(kg·K)
  • e - Specific exergy kJ/kg
  • δt - Isobaric cubic expansion coefficient 1/K
  • f - Specific Helmholtz free energy kJ/kg
  • fi- Fugacity coefficient
  • f* - Fugacity MPa
  • g - Specific Gibbs free energy kJ/kg
  • h - Specific enthalpy kJ/kg
  • δt - Isothermal throttling coefficient kJ/(kg·MPa)
  • μ - Joule-Thomson coefficient K/MPa joule
  • k - Isentropic exponent
  • kT - Isothermal compressibility 1/MPa
  • ν - Kinematic viscosity m²/s
  • p - Pressure MPa
  • β - Isochoric pressure coefficient 1/K
  • Pr - Prandtl number
  • r - Region
  • s - Specific entropy kJ/(kg·K) )
  • ε - Static Dielectric Constant
  • σ - Surface tension N/m
  • t - Temperature °C
  • λ - Thermal conductivity W/(m.K) tc
  • a - Thermal diffusivity m²/s
  • u - Specific internal energy kJ/kg
  • v - Specific Volume m³/kg
  • w - Speed of sound m/s
  • x - Steam quality
  • z - Compressibility factor

Functions

  • hs(h,s,o_id) - the propertry of o_id (thermodynamic,transport,etc)
  • hx(h,x,o_id) - the propertry of o_id (thermodynamic)
  • ph(p,h,o_id) - the propertry of o_id (thermodynamic,transport,etc)
  • ps(p,s,o_id) - the propertry of o_id (thermodynamic,transport,etc)
  • pt(p,t,o_id) - the propertry of o_id(thermodynamic,transport,etc)
  • pv(p,v,o_id) - the propertry of o_id (thermodynamic,transport,etc)
  • px(p,x,o_id) - the propertry of o_id (thermodynamic)
  • sx(s,x,o_id) - the propertry of o_id (thermodynamic)
  • th(t,h,o_id) - the propertry of o_id(thermodynamic,transport,etc)
  • ts(t,s,o_id) - the propertry of o_id (thermodynamic,transport,etc)
  • tv(t,v,o_id) - the propertry of o_id (thermodynamic,transport,etc)
  • tx(t,x,o_id) - the propertry of o_id (thermodynamic)