pyEQL Tutorial: Solid-liquid-gas Equilibrium

pyeql-logo.png

pyEQL is an open-source python library for solution chemistry calculations and ion properties developed by the Kingsbury Lab at Princeton University.

Documentation | How to Install | GitHub

Select a modeling engine

When creating a Solution, you can use the engine keyword argument to specify which Electrolyte Modeling Engine you want to use.

Below, we demonstrates the soild-liquid-gas equilibrium with the phreeqc2026 engine. If you would to use a custom database, please refer to engines tutorial.

Create solutions with selected engine

[59]:
from pyEQL import Solution

ENGINE = "phreeqc2026"

Create a solution without equilibrium

[60]:
s1 = Solution({"Ca+2": "1 mol/kg", "Cl-": "2 mol/kg"}, engine=ENGINE)
print(
    f"Ca_total = {s1.get_total_amount('Ca', 'M'):~.5f}\n"
    f"Cl_total = {s1.get_total_amount('Cl', 'M'):~.5f}\n"
    f"C_total  = {s1.get_total_amount('C', 'M'):~.5f}"
)
Ca_total = 0.99705 M
Cl_total = 1.99410 M
C_total  = 0.00000 M

Solid-liquid equilibrium

[61]:
s1.equilibrate(solids=["Calcite"])
print(
    f"Ca_total = {s1.get_total_amount('Ca', 'M'):~.5f}\n"
    f"Cl_total = {s1.get_total_amount('Cl', 'M'):~.5f}\n"
    f"C_total  = {s1.get_total_amount('C', 'M'):~.5f}"
)
Ca_total = 0.99706 M
Cl_total = 1.99410 M
C_total  = 0.00001 M

Liquid-gas equilibrium with atmosphere

[62]:
s2 = Solution({"Ca+2": "1 mol/kg", "Cl-": "2 mol/kg"}, engine=ENGINE)
print(
    f"Ca_total_ori = {s2.get_total_amount('Ca', 'M'):~.5f}\n"
    f"Cl_total_ori = {s2.get_total_amount('Cl', 'M'):~.5f}\n"
    f"O_total_ori = {s2.get_total_amount('O', 'M'):~.5f}\n"
    f"C_total_ori  = {s2.get_total_amount('C', 'M'):~.5f}\n"
)
s2.equilibrate(atmosphere=True)
print(
    f"Ca_total = {s2.get_total_amount('Ca', 'M'):~.5f}\n"
    f"Cl_total = {s2.get_total_amount('Cl', 'M'):~.5f}\n"
    f"O_total = {s2.get_total_amount('O', 'M'):~.5f}\n"  # O2 in the atmosphere
    f"C_total  = {s2.get_total_amount('C', 'M'):~.5f}"  # CO2 in the atmosphere
)
Ca_total_ori = 0.99705 M
Cl_total_ori = 1.99410 M
O_total_ori = 55.34458 M
C_total_ori  = 0.00000 M

Ca_total = 0.99705 M
Cl_total = 1.99410 M
O_total = 55.34488 M
C_total  = 0.00002 M

Liquid-gas equilibrium with self-defined gas

[63]:
s3 = Solution({"Ca+2": "1 mol/kg", "Cl-": "2 mol/kg"}, engine=ENGINE)
s3.equilibrate(gases={"CO2": -2})  # in log units
print(
    f"Ca_total = {s3.get_total_amount('Ca', 'M'):~.5f}\n"
    f"Cl_total = {s3.get_total_amount('Cl', 'M'):~.5f}\n"
    f"C_total  = {s3.get_total_amount('C', 'M'):~.5f}"
)
Ca_total = 0.99705 M
Cl_total = 1.99410 M
C_total  = 0.00024 M

Solid-liquid-gas equilibrium

[64]:
s4 = Solution({"Ca+2": "1 mol/kg", "Cl-": "2 mol/kg"}, engine=ENGINE)
s4.equilibrate(solids=["Alunite"])
s4.equilibrate(atmosphere=True)
print(
    f"Ca_total = {s4.get_total_amount('Ca', 'M'):~.5f}\n"
    f"Cl_total = {s4.get_total_amount('Cl', 'M'):~.5f}\n"
    f"C_total  = {s4.get_total_amount('C', 'M'):~.5f}"
)
Ca_total = 0.99705 M
Cl_total = 1.99410 M
C_total  = 0.00002 M