Thermodynamics is a core topic used to describe the nature around us, or process equipment in the industry. A typical task one is faced with in thermodynamics is that the temperature, pressure and composition of a fluid are known, but how dense the fluid is, how much energy it contains, or how much heat that must be supplied to change its temperature are unknown.

All this information can be obtained from performing calculations with an *equation of state*, which is one of the main tools of thermodynamics. There are many types of equations of state. Some have high precision but take time to provide the answer, while other are reasonably precise and very fast. Some equations of state are very good when you have salts in your mixture, yet other equations of state are well suited to describe polymer solutions. The best choice of equation of state depends on the applications.

**Blog authors:** Morten Hammer, Øivind Wilhelmsen og Ailo Aasen

## Thermopack software that perfoms thermodynamics calculation now available to all

Through decades of research, we have developed a software that performs thermodynamic calculations. A large selection of equations of state has been implemented in this software. Most of these equations of state have been developed by other research groups around the world, but some of them have been developed by us. This software is called ** Thermopack. **Thus far, Thermopack has only been available to us, and it has been a much-appreciated powerhouse.

- Thermopack can be downloaded from https://github.com/thermotools/thermopack
- Free NCCS Webinar Wednesday 11. November 2020 – Thermopack – open source thermodynamics library

With the slogan of SINTEF in mind: **“Technology for a better society” **we want to share Thermopack with everybody, free of charge through the MIT open-source license. Thermopack is written in modern FORTRAN to handle heavy numerical computations associated with process and computational fluid dynamics (CFD) simulations. The thermodynamic framework is easily interfaced from C/C++ and contains a flexible Python wrapper to make plotting easy. The Python interface is also a building block for the Thermopack graphical user interface, where it is possible to plot thermodynamic phase diagrams with the most frequently used equations of state. The graphical user interface is currently running on the Windows and Linux operating systems.

Thermopack can be downloaded from https://github.com/thermotools/thermopack and can be compiled using the GNU and Intel FORTRAN compilers. The software will be continuously updated as we make progress on the description of fluid properties. Our hope and aim is that Thermopack can be helpful to our colleagues both in academia and in the industry that share our ambitions of contributing to a sustainable future for our children. In the next few paragraphs, we will showcase a few examples (out of many), where Thermopack has been a crucial building block.

## A precise description of CO_{2}-H_{2}O mixtures

CO_{2} capture, transport and storage (CCS) must be deployed on a large scale to mitigate global warming. Some of the risks in transport of dense-phase CO_{2} are possible formation of hydrates that can plug equipment, and formation of free water that can cause corrosion. To recognize the process conditions where these risks may occur, a precise thermodynamic description of CO_{2}-water mixtures is needed. In 2017 [1], we carried out a comprehensive comparison and parameter regression of a variety of models to describe the thermodynamic properties of CO_{2}-H_{2}O. The figure below shows a comparison of experimental data that was available at the time (symbols) and predictions from one of the equations of state (solid line), where there is coexistence between vapor and liquid at low pressures, and coexistence of two liquid phases at high pressures. Most of the models developed in that work are now made available, open-source, as part of Thermopack.

## Novel refrigerants for hydrogen liquefaction

Hydrogen can be produced by use of renewable energy from water electrolysis, or from natural gas with steam reforming. When hydrogen is used in fuel cells, the only emissions are heat and water. Hydrogen is therefore an important, clean energy carrier for the future. To transport large amounts of hydrogen across long distances in an economical manner, it must be transported in a dense state. One of the most promising alternatives is then to liquefy it. However, hydrogen liquefaction is highly energy demanding and technologically challenging.

We are currently working to improve the efficiency of hydrogen liquefaction [2]. A possible way to increase the efficiency is to employ novel mixed refrigerants consisting of hydrogen, helium and neon. The only problem is that, until recently, there has been no accurate thermodynamic description of these fluids. The conventional equations of state fail due to the strong quantum effects that become important at the low temperatures found in the hydrogen liquefaction process.

We have recently developed two types of equations of state for that purpose [3-5]. The performance of the Quantum-SAFT equation of state for the helium-neon mixture is shown below [3-4]. This equation of state matches both experimental data (crosses) and data from computational simulations using the underlying molecular force fields (filled circles) away from the critical region. Furthermore, we have also developed precise and fast cubic equations of state that is well suited for process simulations hydrogen liquefaction [5]. All of these equations of state are available in Thermopack.

Solid formation in industrial processes

Increased knowledge on fluid-solid phase transitions is needed, both when they are undesired and can impair processes operation, and when strict control is required. In a recent work, we combined Thermopack with heterogeneous nucleation theory to predict both the freezing and melting temperature of different water-alcohol mixtures with a good agreement between experiments and simulations [6]. The video below shows the crystallization process in-situ.

## CFD simulation of pipeline flow for CO_{2} mixtures

Transport of CO_{2} in pipelines is a key technology to enable large scale CO_{2} capture and storage (CCS). The simulation of fluid flow requires thermodynamic models to predict CO_{2} properties under various conditions and fluid compositions. When working with the homogeneous equilibrium model, or more complex models, the governing equations will be a set of mass-, momentum- and energy balance equations [7]. The fluid state is therefore specified in terms of the density and the energy, and the phase equilibrium must be calculated using an energy-density phase equilibrium calculation, also called “flash calculations”. To enable direct calculation to extract thermodynamic properties during the CFD simulations, Thermopack includes routines for many types of flash calculations, and numerical solvers for the most common thermodynamic operations (e.g., various flash calculations, saturation lines, and critical points). To speed up the CFD calculation, Thermopack also includes support for OpenMP parallelization.

One example from CFD simulations performed using Thermopack is full-bore depressurization of pipelines. In connection to the CFD simulations, it is convenient to visualize the ideal depressurization path in the thermodynamic landscape. The figure below shows an isentropic depressurization from 12.27 MPa and 25.0°C for a mixture of 98.2% CO_{2} and 1.8% N_{2} in a temperature-pressure phase diagram.

## References

- Thermodynamic models to accurately describe the PVTxy-behavior of water / carbon dioxide mixtures, Fluid Phase Equilibria,
**442**, 125, (2017), A. Aasen, M. Hammer, G. Skaugen, J. P. Jakobsen and Ø. Wilhelmsen. - Reducing the exergy destruction in the cryogenic heat exchangers of hydrogen liquefaction processes, International journal of hydrogen energy,
**43**, 5033, (2018), Ø. Wilhelmsen, D. Berstad, A. Aasen, P. Nekså and G. Skaugen. - Equation of state and force fields for Feynman–Hibbs-corrected Mie fluids. I. Application to pure helium, neon, hydrogen, and deuterium, The Journal of Chemical Physics,
**151**, 064508, (2019), A. Aasen, M. Hammer, Å. Ervik, E. A. Müller and Ø. Wilhelmsen. - Equation of state and force fields for Feynman–Hibbs-corrected Mie fluids. II. Application to mixtures of helium, neon, hydrogen, and deuterium, J. Chem. Phys.,
**152**, 074507, (2020), A. Aasen, M. Hammer, E. A. Müller and Ø. Wilhelmsen. - Accurate quantum-corrected cubic equations of state for helium, neon, hydrogen, deuterium and their mixtures, accepted for publication in Fluid Phase Equilibria,
**524**, 112790, (2020), A. Aasen, M. Hammer, S. Lasala, J.N Jaubert and Ø. Wilhelmsen. - Ice formation and growth in supercooled water–alcohol mixtures: Theory and experiments with dual fiber sensors, Fluid Phase Equilibria, (2020),
**552**, 112741, M. S. Wahl, A. Aasen, D. R. Hjelme and Ø. Wilhelmsen. - Pipeline transport of CO
_{2}– models and simulation tools, Int. J. Greenhouse Gas Control,**15**, 174, (2013), P. Aursand, S. T. Munkejord, M. Hammer and Ø. Wilhelmsen.

## 0 comments on “Open source code: Thermopack software perfoms thermodynamic calculations”