Table of Contents
- Objective
- Disclaimer
- Theory and Model Overview
- Practical Example: Calcium Carbonate System in OLI Studio
- Conclusion
- References
Objective
This article explains how OLI software converts equilibrium true species concentrations to apparent (molecular/inflow) species forms using material balance constraints and optimization techniques. Process engineers will understand the underlying principles that enable accurate composition reporting in molecular forms, facilitating integration with plant operations, material accounting, and downstream process calculations. This conversion bridges the gap between thermodynamically rigorous equilibrium speciation and practical engineering applications.
Target Audience: Chemical engineers, process engineers, and technical professionals using OLI Studio, OLI Flowsheet: ESP, or OLI Cloud APIs who need to understand composition reporting and material balance reconciliation.
Disclaimer
⚠️ Warning
The true-to-apparent species conversion is typically an underdetermined problem, meaning that there are usually more inflow species than material balance groups involved. So, it is likely there exists multiple solutions (there exists more than one set of inflow species that satisfy the material balance). The Engine applies some heuristics that resolve this ambiguity. In results comparison, the differences of inflow amount in multiple apparent species sometimes are normal as long as each true species amount are consistent.
Theory and Model Overview
Understanding Species Representation
OLI software employs two distinct representations of chemical species:
True Species: Thermodynamically rigorous equilibrium species that exist in solution after complete speciation. These include aqueous molecules, ions, complexes, and solid phases. True species represent the actual chemical forms present at equilibrium, calculated using activity coefficient models (AQ, MSE, MSE-SRK frameworks).
Examples of true species:
- H2O (water)
- Na(+1)ION (sodium cation)
- Cl(-1)ION (chloride anion)
- NaClAQ (aqueous sodium chloride complex)
- CO2AQ (dissolved carbon dioxide)
- HCO3(-1)ION (bicarbonate ion)
- CaCO3PPT (solid calcium carbonate precipitate)
Apparent Species (Inflow/Molecular Species): Simplified molecular forms representing how chemicals are typically added to a system or reported in engineering contexts. These correspond to common compound formulas used in material specifications, purchase orders, and process documentation.
Examples of apparent species:
- H2O (water)
- NaCl (sodium chloride)
- CO2 (carbon dioxide)
- CaO (calcium oxide)
- Na2O (sodium oxide)
The conversion from true species to apparent (molecular) species is a foundational step in ensuring that simulation results align with practical, regulatory, and operational requirements:
- Engineering Communication: Plant operators and process engineers work with molecular formulas, not ionic species lists.
- Material Accounting: Purchasing, inventory, and cost tracking reference compounds by molecular formula.
- Flowsheet Integration: Upstream and downstream unit operations often require molecular composition inputs.
- Regulatory Reporting: Environmental permits and safety documentation specify compounds in molecular forms.
Material Balance Framework
The conversion process relies on rigorous material balance constraints based on elemental and charge conservation. Each species (true or apparent) is decomposed into fundamental material balance codes representing elements, oxidation states, or functional groups.
📝 Note
MBG (Material Balance Group) is an OLI Specific concept
Material Balance Codes (Matcodes)
OLI defines unique integer codes for each conserved entity:
| Matcode | Entity | Description |
|---|---|---|
| 1 | H(+1) | Hydrogen cation |
| 3 | Na(+1) | Sodium cation |
| 6 | Ca(+2) | Calcium cation |
| 21 | O(-2) | Oxide anion |
| 22 | Cl(-1) | Chloride anion |
| 25 | C(+4) | Carbon in +4 oxidation state |
| 40 | H(0) | Elemental hydrogen |
💡 Tip
Matcodes can be either an oxidation state of an element (H(0) = 40 v.s. H(+1) = 1) or a molecular species (EtO(-1) = 462).
Stoichiometric Representation
Each species is characterized by up to 10 matcode-coefficient pairs describing its elemental composition:
Example 1: NaCl (sodium chloride)
- Matcodes: [3, 22, 0, 0, 0, 0, 0, 0, 0, 0]
- Coefficients: [1.0, 1.0, 0, 0, 0, 0, 0, 0, 0, 0]
- Interpretation: 1 Na(+1) + 1 Cl(-1)
Example 2: CaCO3 (calcium carbonate)
- Matcodes: [6, 25, 21, 0, 0, 0, 0, 0, 0, 0]
- Coefficients: [1.0, 1.0, 3.0, 0, 0, 0, 0, 0, 0, 0]
- Interpretation: 1 Ca(+2) + 1 C(+4) + 3 O(-2)
Material Balance Equations
For each conserved matcode m, the total amount must be preserved during conversion:
where:
- smi is the stoichiometric coefficient of matcode m in apparent species
- ni is the amount (gmol) of apparent species i to be determined
- smj is the stoichiometric coefficient of matcode m in true species j
- cj is the known concentration (gmol) of true species j from equilibrium calculation
- Napparent is the total number of available inflow/molecular species
- Ntrue is the total number of true species in the equilibrium result
This system of linear equations forms the constraint set for the optimization problem. The right-hand side represents the material inventory computed from equilibrium speciation, while the left-hand side determines the molecular species distribution that satisfies conservation laws.
Matrix Formulation
The material balance constraints can be expressed in matrix form:
\[ A \cdot n = b \]
where:
- A is the stoichiometric matrix (M×Napparent) containing coefficients smi
- n is the vector of apparent species amounts (Napparent×1)
- b is the material balance totals vector (M×1) computed from true species
- M is the number of unique matcodes in the chemistry model
Linear Programming Optimization
The conversion problem is mathematically underdetermined: there are typically more apparent species variables than material balance equations. This creates infinite solutions satisfying conservation laws. To select the most chemically reasonable distribution, OLI employs Linear Programming (LP) with a carefully designed objective function.
Optimization Problem Statement
\[ \begin{aligned} \text{maximize} \quad & c^{T} \cdot n \\ \text{subject to} \quad & A \cdot n = b \\ & n \ge 0 \end{aligned} \]
where:
- c is the cost coefficient vector (Napparent×1) assigning preference weights to each apparent species (higher values indicate more favorable species)
- n is the vector of apparent species amounts (Napparent×1) to be determined
- A is the stoichiometric matrix (M×Napparent) containing matcode coefficients smi for each apparent species
- b is the material balance totals vector (M×1) computed from true species concentrations: \( b_{m} = \sum_{j=1}^{N_{\text{true}}} s_{mj} \cdot c_{j} \)
- M is the number of unique matcodes (material balance groups) to be conserved
- Napparent is the total number of available inflow/molecular species
- Non-negativity constraints (n≥0) ensure physically meaningful (positive) amounts
The LP solver identifies the unique solution maximizing the total cost while rigorously satisfying all material balance equations. This approach guarantees:
- Thermodynamic Consistency: Elemental and charge conservation exactly preserved
- Chemical Reasonableness: Preference given to stable, commonly observed molecular forms
- Reproducibility: Deterministic solution for given chemistry model and true species input
- Computational Efficiency: Polynomial-time solution using simplex or interior-point methods
Practical Example: Calcium Carbonate System in OLI Studio
This section demonstrates the true-to-apparent species conversion using a realistic aqueous system containing water, sodium chloride, carbon dioxide, and calcium carbonate. The case was run in OLI Studio.
Step 1: User Input (Inflow Species)
The user specifies the initial composition in molecular forms:
| Inflow Species | Amount (gmol) |
|---|---|
| H2O | 55.5082 |
| CaCO3 | 1.00000 |
| NaCl | 1.00000 |
| CO2 | 1.00000 |
These molecular species represent how chemicals are typically added to a system in engineering practice.
Step 2: Equilibrium Calculation (True Species)
After performing a rigorous phase equilibrium calculation at specified temperature and pressure, the system speciates into thermodynamically stable forms. The liquid phase (L1) contains the following true species:
| True Species | Amount (gmol) | Chemical Form |
|---|---|---|
| H2O | 55.4611 | Water (molecular) |
| Na(+1) | 1.00000 | Sodium cation |
| Cl(-1) | 1.00000 | Chloride anion |
| HCO3(-1) | 0.0339474 | Bicarbonate ion |
| CO2 | 0.0263202 | Dissolved carbon dioxide |
| Ca(+2) | 0.0169875 | Calcium cation |
| CaCO3 | 1.48669e-5 | Aqueous calcium carbonate complex |
| CO3(-2) | 1.43138e-5 | Carbonate ion |
| H3O(+1) | 7.03896e-7 | Hydronium ion |
| CaCl2 | 1.98504e-7 | Aqueous calcium chloride complex |
| OH(-1) | 2.48597e-8 | Hydroxide ion |
| CaOH(+1) | 2.11126e-9 | Calcium hydroxide complex |
| HCl | 1.11682e-14 | Aqueous hydrogen chloride |
| NaOH | 9.93709e-15 | Aqueous sodium hydroxide |
| NaOHCO3(-2) | 7.12511e-15 | Sodium hydroxide carbonate complex |
Key Observations:
- NaCl completely dissociates into Na(+1) and Cl(-1) ions
- CaCO3 partially dissolves, producing Ca(+2), HCO3(-1), CO3(-2), and aqueous complexes
- CO2 remains partially undissociated with equilibrium speciation to HCO3(-1) and CO3(-2)
- Water concentration decreased slightly due to hydration effects
Step 3: Conversion to Molecular Apparent Species
The true-to-apparent conversion algorithm determines the molecular composition that satisfies all material balance constraints. The OLI Engine produces:
| Apparent Species | Amount (gmol) | Molecular Form |
|---|---|---|
| H2O | 55.4781 | Water |
| NaCl | 1.00000 | Sodium chloride |
| CO2 | 0.0602968 | Carbon dioxide |
| CaO | 0.0170026 | Calcium oxide |
| Na2O | 1.14185e-13 | Sodium oxide (trace) |
Step 4: Python Implementation Results (Without Heuristics)
To illustrate the idea, the true to apparent species conversion can be validated by a third-party Python library from scipy.optimize import linprog
We show calculation without the heuristics being applied.
Below are results after we solved naively linear optimization problems with material balance satisfied.
================================================================================
Comparison with OLI Studio Output
================================================================================
Species Python Test (Without applying heuristics) OLI Studio
-------------------------------------------------------------------------------------
H2O 5.341013e+01 5.547810e+01
NACL 0.000000e+00 1.000000e+00
NACL.2H2O 9.214461e-01 0.000000e+00
CO2 0.000000e+00 6.029680e-02
HCL.3H2O 4.454920e-02 0.000000e+00
CAO 0.000000e+00 1.700260e-02
NA5H3CO34 1.401327e-02 0.000000e+00
CA3CL6.1H2O 5.667523e-03 0.000000e+00
NA2CO3.10H2O 4.243804e-03 0.000000e+00
NA2O 0.000000e+00 1.141850e-13
================================================================================
Step 5: Python Implementation Results (With Heuristics Applied)
Below are results after we solved using linear optimization problems with material balance satisfied + heuristics applied. The heuristics assign preferential cost weights favoring simple molecular forms (e.g., NaCl, CO2), vapor species, and anhydrous compounds over hydrated species and complex salts, guiding the LP solver toward chemically intuitive, engineering-relevant apparent species compositions.
================================================================================
Comparison with OLI Studio Output
================================================================================
Species Python (With Heuristics) OLI Studio
--------------------------------------------------------------------------------
H2O 5.547807e+01 5.547810e+01
NACL 1.000000e+00 1.000000e+00
CO2 6.029678e-02 6.029680e-02
CAO 1.700257e-02 1.700260e-02
NA2O 0.000000e+00 1.141850e-13
================================================================================
This comparison demonstrates that replicating OLI Studio's apparent species output requires not only correct material balance formulation but also faithful implementation of the chemical heuristics embedded in the cost function.
Conclusion
True-to-apparent species conversion employs linear programming with material balance constraints and chemically informed cost functions to translate rigorous equilibrium speciation into practical molecular formulas. This automated reconciliation ensures thermodynamic consistency while producing engineering-friendly composition reports. Process engineers benefit from familiar compound names and formulas, facilitating communication, material accounting, and integration with plant data systems. Understanding the underlying optimization principles enables informed chemistry model design and interpretation of molecular composition outputs across OLI software platforms.
References
(1) OLI Systems, Inc. OLI Studio User Guide, Version 12.0; Morris Plains, NJ, 2024.
(2) OLI Systems, Inc. OLI Engine Technical Reference, Version 12.0; Morris Plains, NJ, 2024.
(3) Nocedal, J.; Wright, S. J. Numerical Optimization, 2nd ed.; Springer: New York, 2006.
(4) Dantzig, G. B. Linear Programming and Extensions; Princeton University Press: Princeton, NJ, 1963.