IF97 is the high-speed package of IAPWS-IF97 in Rust with C and Python binding. 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-20x speed-up compared to using the powi()
of the Rust standard library in the for
loop directly when computing the basic equations of Region 1,2,3.
The Fast Methods
powi()
with the for
loopIn IF97, 36 thermodynamic, transport and further properties can be calculated.
The following 12 input pairs are implemented:
```txt (p,t) (p,h) (p,s) (p,v)
(t,h) (t,s) (t,v)
(p,x) (t,x) (h,x) (s,x)
(h,s)
```
Install the crate
bash
cargo add if97
The type of functions are provided in the if97 package:
```txt struct oidregionargs { oid: i32, region: i32, }
fn
option
parameter: the region of IAPWS-IF97```txt
pt
th
hs
px(p:f64,x:f64,oid:i32)->f64 tx(p:f64,x:f64,oid:i32)->f64 hx(h:f64,x:f64,oid:i32)->f64 sx(s:f64,x:f64,oid:i32)->f64
``` Example
```rust 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);
// set the region
let v=pt(p,t,(OV,1));
println!("p={p:.6} t={t:.6} h={t:.6} s={s:.6} v={v:.6}");
} ```
Building the dynamic link library
bash
cargo build -r --features cdecl
* stdcall: Win32 API functions
bash
cargo build -r --features stdcall
The convenient compiled dynamic link libraries are provided in the ./dynamic_lib/
The functions in C ```c double pt(double p,double t,short oid); double ph(double p,double h,short oid); double ps(double p,double s,short oid); double pv(double p,double v,short oid);
double tv(double t,double v,short oid); double th(double t,double h,short oid); double ts(double t,double s,short o_id);
double hs(double h,double s,short o_id);
double px(double p,double x,short oid); double tx(double t,double x,short oid); double hx(double h,double x,short oid); double sx(double s,double x,short oid); ```
Examples
```c
extern double pt(double p,double t,short o_id);
int main(void) { double p = 16.0; double t = 530.0; double h = pt(p, t, OH); double s = pt(p, t, OS); printf("p,t %f,%f h= %f s= %f\n", p, t, h, s); return EXIT_SUCCESS; } ```
Install
bash
pip install if97
Examples
```python from if97 import *
OH=4 OS=5
p=16.0 t=535.1 h=pt(p,t,OH) s=pt(p,t,OS) print(f"p={p}, t={t} h={h:.3f} s={s:.3f}") ``` T-S Diagram
| Propertry | Unit | Symbol | oid | oid(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|