Crate seuif97

source ·
Expand description

SEUIF97 Build test PyPI Downloads Downloads DOI

This is the Rust implementation of the high-speed IAPWS-IF97 package seuif97 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 forloop directly when computing the basic equations of Region 1,2,3.

The Fast Methods

  1. The multi-step method unleashes the full power of the compiler optimizations while using powi() with the for loop
  2. The recursive method computes the polynomial values of the base variable and its derivatives

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

The following 12 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) 



Install the crate

cargo add seuif97

The type of functions are provided in the package:

struct o_id_region_args {
   o_id: i32,
   region: i32,

fn<R>(f64,f64,R) -> f64
    R: Into<o_id_region_args>,
  • the first,second input parameters(f64) : the input propertry pairs
  • the third and fourth input parametes:
    • the third : the property ID of the calculated property - o_id
    • the fourth option parameter: the region of IAPWS-IF97
  • the return(f64): the calculated property value of o_id





use seuif97::*;
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}");   

The C binding

Building the dynamic link library

  • cdecl
cargo build -r --features cdecl
  • stdcall: Win32 API functions
cargo build -r --features stdcall

The convenient compiled dynamic link libraries are provided in the ./dynamic_lib/

The functions in C

double pt(double p,double t,short o_id);
double ph(double p,double h,short o_id);
double ps(double p,double s,short o_id);
double pv(double p,double v,short o_id);

double tv(double t,double v,short o_id);
double th(double t,double h,short o_id);
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 o_id);
double tx(double t,double x,short o_id);
double hx(double h,double x,short o_id);
double sx(double s,double x,short o_id);


#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define OH 4
#define OS 5

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;

The Example of Rankine Cycle Analysis

The Python binding


pip install seuif97


from seuif97 import *


# ??(in1,in2,o_id)
# ??2?(in1,in2)
print(f"p={p}, t={t} h={h:.3f} s={s:.3f}")


T-S Diagram


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
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
Relative pressure coefficient1/KαpOAFLAP35

Cite as

  • Cheng Maohua. (2023). The Rust implementation of the high-speed IAPWS-IF97 package: SEUIF97 (1.0.9). Zenodo.


  • the paramters:
    o_id: the propertry of id;
    region: the region in the IAPWS-IF97,optional


  • α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


  • hs(h,s,o_id) - the propertry of o_id (thermodynamic,transport,etc)
    hs(h,s,(o_id,reg)) - the propertry of o_id in the region of reg(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)
    ph(p,h,(o_id,reg)) - the propertry of o_id in the region of reg(thermodynamic,transport,etc)
  • ps(p,s,o_id) - the propertry of o_id (thermodynamic,transport,etc)
    ps(p,s,(o_id,reg)) - the propertry of o_id in the region of reg(thermodynamic,transport,etc)
  • pt(p,t,o_id) - the propertry of o_id (thermodynamic,transport,etc)
    pt(p,t,(o_id,reg)) - the propertry of o_id in the region of reg(thermodynamic,transport,etc)
  • pv(p,v,o_id) - the propertry of o_id(thermodynamic,transport,etc)
    pv(p,v,(o_id,reg)) - the propertry of o_id in the region of reg(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)
    th(t,h,(o_id,reg)) - the propertry of o_id in the region of reg(thermodynamic,transport,etc)
  • ts(t,s,o_id) - the propertry of o_id(thermodynamic,transport,etc)
    ts(t,s,(o_id,reg)) - the propertry of o_id in the region of reg(thermodynamic,transport,etc)
  • tv(t,v,o_id) - the propertry of o_id(thermodynamic,transport,etc)
    tv(t,v,(o_id,reg)) - the propertry of o_id in the region of reg(thermodynamic,transport,etc)
  • tx(t,x,o_id) - the propertry of o_id (thermodynamic)