This is the C implementation of the high-speed IAPWS-IF97 package SEUIF97. It is suitable for computation-intensive calculations,such as the simulation of non-stationary processes, on-line process monitoring and optimizations.
Through the high-speed library, IAPWS-IF97 results are generated with high accuracy and at speeds significantly faster than the repeated squaring method or the standard C library's math.pow()
SEUIF97 is also faster than approximate equations and other fast-calculation algorithms for water and steam properties.
- Shortest Addition Chain Algorithm: Used for the rapid computation of integer powers via optimal multiplication sequences.
- Power Caching Strategy : Precomputes only distinct powers to avoid redundant calculations, directly retrieving them to speed up polynomial evaluation.
- Recurrence Method for Multi-Polynomial Evaluation: Computes a base polynomial, then utilizes derivative relationships to derive the rest via base scaling to maximize efficiency.
Please refer to The acceleration methods for more details on the algorithm.
Building the shared library
You can build the library using either make or cmake:
- make
make- cmake
cmake -B ./build/
cmake --build ./build/ --config ReleaseThe compiled shared libraries
The shared libraries libseuif97.dll building with MinGW-GCC/GCC are available in the /shared_lib/ directory:
The SEUIF97 library provides comprehensive functions for calculating water and steam properties, as well as the thermodynamic processes of steam turbines.
Water and Steam Properties
SEUIF97 supports 12 distinct input state pairs for calculating 36 thermodynamic, transport, and derived properties (see Properties).
Input Pairs:
$(p,t), (p,h), (p,s), (p,v)$ $(t,h),(t,s), (t,v)$ $(p,x), (t,x),(h,x),(s,x)$ $(h,s)$
The type of property functions are provided in the package
??(in1,in2,o_id)- the first,second input parameters : the input property pairs
- the third input parameters: the ID of the calculated property - o_id
- the return: the calculated property value of
o_id
Thermodynamic Process of Steam Turbine
-
Isentropic Enthalpy Drop:ishd(pi,ti,pe)
pi - inlet pressure(MPa); ti -inlet temperature(°C) pe - outlet pressure(MPa)
-
Isentropic Efficiency(0~100): ief(pi,ti,pe,te) (superheated steam zone)
pi - inlet pressure(MPa); ti - inlet temperature(°C) pe - outlet pressure(MPa); te - outlet temperature(°C)
The Function Prototype in C
// Functions of Properties
double pt(double p, double t, int o_id);
double ph(double p, double h, int o_id);
double ps(double p, double s, int o_id);
double pv(double p, double v, int o_id);
double th(double t, double h, int o_id);
double ts(double t, double s, int o_id);
double tv(double t, double v, int o_id);
double hs(double h, double s, int o_id);
double px(double p, double x, int o_id);
double tx(double t, double x, int o_id);
double hx(double h, double x, int o_id);
double sx(double s, double x, int o_id);
//The Functions for Thermodynamic Process of Steam Turbine
double ishd(double pi, double ti, double pe);
double ief(double pi, double ti, double pe, double te);To use the shared library in your preferred programming language, follow these steps:
-
Put the shared library in the default path of OS or the programming language
-
Windows(x86/64)
- copy
libseuif97.dllin the Windows/x86 or Windows/x64 folder to a default path of Windows32/64's DLL,for example:C:\Windows\System
- copy
-
Linux(x64)
- copy
libseuif97.soin the Linux/x64 folder to a default path of Linux shared lib :/usr/lib/
- copy
-
-
Add the specific API file for your programming language to its corresponding
APIpath.- Note: API paths vary by language. Please refer to the specific Examples provided for your programming language to locate the correct path and setup instructions.
Interfaces and examples are provided in the /demo/ directory, supporting a wide range of languages and environments
- C/C++, Python, C#, Java, Excel VBA, MATLAB, Rust, Fortran, Pascal, Golang, Modelica
You can modify the provided interfaces to match your own API needs.
| Language | Interface |
|---|---|
| C/C++ | seuif97.h |
| Python | seuif97.py |
| C# | seuif97.cs |
| Excel VBA | seuif97.bas |
| Java | seuif97.java |
| MATLAB64 | seuif97.m |
| Rust | seuif97.rs |
| Fortran | seuif97.f08 |
| Pascal | seuif97.pas |
| Modelica | seuif97.mo |
| Golang | Example demo.go |
The Selected Examples
Python
C++
| Property | Unit | Symbol | o_id |
|---|---|---|---|
| Pressure | MPa | p | 0 |
| Temperature | °C | t | 1 |
| Density | kg/m^3 | ρ | 2 |
| Specific Volume | m^3/kg | v | 3 |
| Specific enthalpy | kJ/kg | h | 4 |
| Specific entropy | kJ/(kg·K) | s | 5 |
| Specific exergy | kJ/kg | e | 6 |
| Specific internal energy | kJ/kg | u | 7 |
| Specific isobaric heat capacity | kJ/(kg·K) | cp | 8 |
| Specific isochoric heat capacity | kJ/(kg·K) | cv | 9 |
| Speed of sound | m/s | w | 10 |
| Isentropic exponent | k | 11 | |
| Specific Helmholtz free energy | kJ/kg | f | 12 |
| Specific Gibbs free energy | kJ/kg | g | 13 |
| Compressibility factor | z | 14 | |
| Steam quality | x | 15 | |
| Region | r | 16 | |
| Isobaric cubic expansion coefficient | 1/K | ɑv | 17 |
| Isothermal compressibility | 1/MPa | kT | 18 |
| Partial derivative (∂V/∂T)p | m^3/(kg·K) | (∂V/∂T)p | 19 |
| Partial derivative (∂V/∂P)T | m^3/(kg·MPa) | (∂V/∂P)T | 20 |
| Partial derivative (∂p/∂t)v | MPa/K | (∂p/∂t)v | 21 |
| Isothermal throttling coefficient | kJ/(kg·MPa) | δt | 22 |
| Joule-Thomson coefficient | K/MPa | μ | 23 |
| Dynamic viscosity | kg/(m·s) | η | 24 |
| Kinematic viscosity | m^2/s | ν | 25 |
| Thermal conductivity | W/(m.K) | λ | 26 |
| Thermal diffusivity | um^{2}/s | a | 27 |
| Prandtl number | Pr | 28 | |
| Surface tension | N/m | σ | 29 |
-
王培红,贾俊颖,程懋华. 水和水蒸汽热力性质IAPWS-IF97公式的通用计算模型[J]. 动力工程,2001,21(6):1564-1567 [ pdf ]
-
芮嘉敏,孙振业,程懋华. 基于最短加法链状态空间树的IAPWS-IF97快速计算方法[J]. 汽轮机技术,2017,59(4):245-247 [ pdf ]
- Cheng Maohua. (2023). The C implementation of the high-speed IAPWS-IF97 package: SEUIF97 (1.2.0). Zenodo. https://doi.org/10.5281/zenodo.8242452