NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

PyEquIon: A Python Package For Automatic Speciation Calculations of\n Aqueous Electrolyte Solutions

Caio Felippe Curitiba Marcellos, Gerson Francisco da Silva Junior, Ilka do Amaral Soares, Fábio Ramos, Evaristo C. BiscaiaarXiv 2021 · DOI

Abstract

In several industrial applications, such as crystallization, pollution control, and flow assurance, an accurate understanding of the aqueous electrolyte solutions is crucial. Electrolyte equilibrium calculation contributes with the design and optimization of processes by providing important information, such as species concentration, solution pH and potential for solid formation. In this work, a pure Python library distributed under BSD-3 license was developed for the calculation of aqueous electrolyte equilibrium. The package takes as inputs the feed components of a given solution, and it automatically identifies its composing ions and the chemical reactions involved to calculate equilibrium conditions. Moreover, there is no established electrolyte activity coefficient model for a broad range of operational conditions. Hence, in this package, built-in activity coefficient models are structured in a modular approach, so that the non-ideality calculation can be performed by a user provided function, which allows further research in the topic. The package can be used by researchers to readily identify the equilibrium reactions and possible solid phases in a user friendly language.

Introduction

Understanding the behavior of ions in water—known as aqueous speciation—is vital for industries ranging from carbon capture and pollution control to oil and gas flow assurance. However, calculating these equilibria is notoriously difficult. It requires solving a system of nonlinear equations involving mass balances, charge balances, and the "law of mass action." While powerful legacy tools like PHREEQC exist, they often function as "black boxes" that are difficult to modify or embed into modern numerical simulations, such as dynamic crystallization models. PyEquIon addresses these challenges by providing a modular, "pure Python" framework that integrates easily with contemporary research workflows.

The PyEquIon Workflow

The core strength of PyEquIon lies in its automated approach to thermodynamic modeling. Unlike traditional software that requires manual input of every possible reaction, PyEquIon uses a recursive algorithm to identify species and reactions from a structured database.

As shown in the flowchart above, the process begins with the user providing initial compounds and settings. The software then identifies relevant reactions and species from JSON-formatted databases. A key feature is the modularity of the non-ideality model; users can select from built-in models like Debye-Hückel (B-dot), Bromley, SIT, or Pitzer, or even provide their own custom activity coefficient functions. This modularity allows researchers to swap between different mathematical models depending on the concentration of the solution.

Technical Implementation and Performance

To bridge the gap between Python's ease of use and the computational demands of electrolyte modeling, PyEquIon employs several advanced techniques:

  • Recursive Reaction Identification: Users provide a list of feed components, and the software "crawls" a thermodynamic database to automatically identify all possible ions, complexes, and potential solid precipitates.
  • High-Performance Computing: To ensure the solver is fast enough for complex simulations, PyEquIon utilizes numba for just-in-time (JIT) compilation and sympy for automatic symbolic Jacobian generation.
  • Integration-Ready Architecture: The software can export the equilibrium residuals as a standalone Python function, making it easy to plug into Differential-Algebraic Equation (DAE) solvers for dynamic modeling.

Validation and Key Results

The authors validated PyEquIon's accuracy using experimental mean activity coefficient data for common salts like $\text{NaCl}$, $\text{CaCl}_2$, and $\text{MgCl}_2$. For low-concentration solutions, results were found to be identical to those produced by the industry-standard PHREEQC.

In high-concentration scenarios, the software demonstrated its robustness. Using the Pitzer model, PyEquIon showed excellent agreement with experimental data for highly concentrated solutions (e.g., $\text{CaCl}_2$ up to 7.5 M), where simpler models typically fail. Furthermore, the authors successfully embedded PyEquIon into a simulation of calcium carbonate crystallization, tracking pH, supersaturation, and particle size distribution over a 1200-second window, demonstrating its utility for real-world engineering applications.

Conclusion

PyEquIon represents a significant step forward in making electrolyte thermodynamics accessible and reproducible. By moving away from compiled legacy languages to a transparent, pure Python framework, the authors make the underlying physics accessible to a broader range of researchers. While thermodynamic databases are rarely exhaustive and model uncertainty remains a factor in extreme conditions, PyEquIon provides the necessary tools for researchers to readily identify equilibrium reactions and possible solid phases in a user-friendly environment.

Summary updated

BibTeX
@misc{marcellos2021pyequion,
  author = {Caio Felippe Curitiba Marcellos and Gerson Francisco da Silva Junior and Ilka do Amaral Soares and Fábio Ramos and Evaristo C. Biscaia},
  title = {{PyEquIon: A Python Package For Automatic Speciation Calculations of\textbackslash\{\}n Aqueous Electrolyte Solutions}},
  year = {2021},
  eprint = {2101.07246},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2101.07246},
}

Loading related content...

Figure