OptimaSolver.jl minimizes a Gibbs energy under linear mass-balance constraints, the problem every chemical equilibrium reduces to. Its default method is the active-set Newton iteration of the Optima C++ library of Allan Leal (ETH Zürich), in an independent Julia port; a log-barrier interior-point method and a Newton method on the optimality conditions in the space of the Lagrange multipliers, which ChemistryLab.jl uses to certify its answers, complete it. Whichever method produced it, an answer is checked by a KKT certificate, and ForwardDiff derivatives pass through the solve to any order. Part of the MicroPoroChemoMechanics ecosystem.
Key features
- A certificate, not a stopping test —
kkt_certificatechecks the optimality conditions at any point, whatever produced it; for a convex problem they are sufficient, so it proves the global minimum - Three methods, one problem — the active set holds unstable species on their bounds and takes a null-space Newton step on a basis the matrix supports, pricing an absent component by the dual ratio test; the interior point takes its Newton step through a Schur complement; the multiplier-space Newton holds bounded species in an exact active set
- Unknowns that are not amounts — the extents of reactions advanced over a time step or the potential of a charged surface are solved with the amounts, each fixed by its own equation
- A start from a linear program —
lp_startsolves the pure-phase program by a verified simplex; an impossible budget comes back with its Farkas proof rather than as a failed iteration - Every row at its own scale — each mass balance is judged against what it holds, so a trace nine orders of magnitude below the major elements is kept to its own amount
- Exact derivatives — dual numbers in the budget, the data or the parameters return the derivatives of the solution by the implicit-function theorem, nested to any order
- Solvents and their solutes — a phase given
invertrecovers its solutes in one call, through one equation in the ionic strength for activity models of the Debye–Hückel family
Installation
OptimaSolver.jl is registered in Julia’s General registry:
using Pkg
Pkg.add("OptimaSolver")Origin, credits and license
OptimaSolver.jl began as an independent Julia port of Optima (github.com/reaktoro/optima, © 2020–2024 Allan Leal), not affiliated with its authors. The interior-point method keeps that lineage: the canonicalization of the conservation matrix, the Schur-complement Newton step, the stability classification of the variables and the sensitivity of the answer come from that library and from Leal, Blunt & LaForce (2014), Efficient chemical equilibrium calculations for geochemical speciation and reactive transport modelling, Geochimica et Cosmochimica Acta 131, 301–322, doi:10.1016/j.gca.2014.01.038. Its log-barrier formulation and filter line search follow Wächter & Biegler (2006), Mathematical Programming 106, 25–57, doi:10.1007/s10107-004-0559-y.
The multiplier-space Newton method, the KKT certificate, the phase-stability tests, the linear-programming start and the derivatives of the answer are original to OptimaSolver.jl, more than half of its code. They implement published methods: Brinkley (1947), doi:10.1063/1.1746420; White, Johnson & Dantzig (1958), doi:10.1063/1.1744264; Karpov, Chudnenko & Kulik (1997), doi:10.2475/ajs.297.8.767; and Michelsen (1982) for phase stability, doi:10.1016/0378-3812(82)85001-2.
The Julia port and the original parts are © 2025–2026 Jean-François Barthélémy (Cerema, UMR MCD), under LGPL-2.1-or-later.
How to cite
Cite OptimaSolver.jl by its DOI, 10.5281/zenodo.19534031, and, for the interior-point algorithm, Leal, Blunt & LaForce (2014).
