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
- The shortest addition chain computes integer powers of a number.(the paper in chinese)
- 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)->f64Example
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
| Propertry | Unit | Symbol | o_id | o_id(i32) |
|---|---|---|---|---|
| Pressure | MPa | p | OP | 0 |
| Temperature | °C | t | OT | 1 |
| Density | kg/m³ | ρ | OD | 2 |
| Specific Volume | m³/kg | v | OV | 3 |
| Specific enthalpy | kJ/kg | h | OH | 4 |
| Specific entropy | kJ/(kg·K) | s | OS | 5 |
| Specific exergy | kJ/kg | e | OE | 6 |
| Specific internal energy | kJ/kg | u | OU | 7 |
| Specific isobaric heat capacity | kJ/(kg·K) | cp | OCP | 8 |
| Specific isochoric heat capacity | kJ/(kg·K) | cv | OCV | 9 |
| Speed of sound | m/s | w | OW | 10 |
| Isentropic exponent | k | OKS | 11 | |
| Specific Helmholtz free energy | kJ/kg | f | OF | 12 |
| Specific Gibbs free energy | kJ/kg | g | OG | 13 |
| Compressibility factor | z | OZ | 14 | |
| Steam quality | x | OX | 15 | |
| Region | r | OR | 16 | |
| Isobari cubic expansion coefficient | 1/K | ɑv | OEC | 17 |
| Isothermal compressibility | 1/MPa | kT | OKT | 18 |
| Partial derivative (∂V/∂T)p | m³/(kg·K) | (∂V/∂T)p | ODVDT | 19 |
| Partial derivative (∂V/∂p)T | m³/(kg·MPa) | (∂v/∂p)t | ODVDP | 20 |
| Partial derivative (∂P/∂T)v | MPa/K | (∂p/∂t)v | ODPDT | 21 |
| Isothermal throttling coefficient | kJ/(kg·MPa) | δt | OIJTC | 22 |
| Joule-Thomson coefficient | K/MPa | μ | OJTC | 23 |
| Dynamic viscosity | Pa·s | η | ODV | 24 |
| Kinematic viscosity | m²/s | ν | OKV | 25 |
| Thermal conductivity | W/(m.K) | λ | OTC | 26 |
| Thermal diffusivity | m²/s | a | OTD | 27 |
| Prandtl number | Pr | OPR | 28 | |
| Surface tension | N/m | σ | OST | 29 |
| Static Dielectric Constant | ε | OSDC | 30 | |
| Isochoric pressure coefficient | 1/K | β | OPC | 31 |
| Isothermal stress coefficient | kg/m³ | βp | OBETAP | 32 |
| Fugacity coefficient | fi | OFI | 33 | |
| Fugacity | MPa | f* | OFU | 34 |
| Relative pressure coefficient | 1/K | αp | OAFLAP | 35 |
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)