The implementation of thermodynamic equations of state for physical property prediction (density, heat capacity, enthalpy, phase fractions, etc) is traditionally an esoteric process. With Juliaâ€™s clean syntax and efficient multiple-dispatch system, it is possible to produce extremely lucid code without trade-offs in efficiency, while also being infinitely extensible. We hope to show that Julia is a powerful tool that can transform the art of thermodynamic modelling in both academia and industry.

Thermodynamic models represent a key tool for a variety of applications; this includes the study of complex systems (electrolytes, polymers, pharmaceuticals, etc), process modelling and molecular design. However, it is not uncommon for thermodynamic models to involve hundreds of different components, especially with the more modern equations of state like those built from Statistical Associating Fluid Theory (SAFT), whose ability to model complex phenomena (such as hydrogen bonding and London dispersion interactions) comes at the cost of complicated mathematical formulation. Most implementations are often abstruse, if they are open to the public at all, which is likely to be the main reason for the high barrier to entry into the field. Beyond those mathematical functions, it is also an exercise in working out the physical properties by exploiting some thermodynamic relations, which may involve the use of highly non-linear solvers for problems with near-singular Jacobians, and solving for the global minima of a non-convex, non-linear problem. The actual execution tends to be application-specific and difficult to extend, even if one had a full understanding of the procedures that are traditionally written in FORTRAN.

Enter Julia, a language that seems to provide the most natural realisation of every step of this process. OpenSAFT is a framework that makes it easy to build SAFT-type (or any free-energy-based) models such that researchers and enthusiasts alike will be able to focus on the actual thermodynamics and algorithms without worrying about the implementation. With the Julia culture that completely embraces Unicode identifiers and terse syntax for mathematical operations, we are able to create nearly one-to-one translations of the mathematical expressions in the literature to code, removing the layer of obfuscation that usually appears when writing high-performance code.

Differential programming is a concept that is extensively used in modern statistical-learning tools, but is still relatively unknown to a lot of the scientific community. We are now able to trivially obtain any-order derivatives of the Helmholtz free energy function, instead of having to work out the corresponding expressions for each model. Suddenly, it all becomes a plug-and-play solution where the user could just write out the model equations, and have OpenSAFT seamlessly obtain all the relevant properties. By careful selection of parameter types, nearly every part of the code can be easily modified or extended so that users will be able to take direct control of the solvers if necessary. This allows people to easily pry into the inner workings of thermodynamic equations of state and study how they can be set up and used.

With Julia, OpenSAFT has the potential to revolutionise thermodynamic research and education, and we think that this effort will also greatly help to bridge the gap between cutting-edge development in academia and actual practical use in industry. Perhaps it could also inspire scientists from other domains to invest in bringing over their work to Julia where everything â€śjust worksâ€ť.