Articles | Volume 18, issue 19
https://doi.org/10.5194/gmd-18-6951-2025
https://doi.org/10.5194/gmd-18-6951-2025
Development and technical paper
 | 
09 Oct 2025
Development and technical paper |  | 09 Oct 2025

A bound-constrained formulation for complex solution phase minimization

Nicolas Riel, Boris J. P. Kaus, Albert de Montserrat, Evangelos Moulas, Eleanor C. R. Green, and Hugo Dominguez
Abstract

Prediction of mineral phase assemblages is essential to better understand the dynamics of the solid Earth, such as metamorphic processes, magmatism and the formation of mineral ore deposits. While recently developed thermodynamic databases allow the prediction of stable phase mineral assemblages for an increasing range of pressure, temperature and compositional spaces, the increasing complexity of these databases results in a significant increase of computational cost, hindering our ability to perform realistic models of reactive fluid/magma transport. Presently, prediction of stable phase equilibrium in complex systems is therefore largely limited by how efficiently single phase minimization can be performed, as more than 75 % of the total computational time is generally dedicated to individual solution phase minimization. This limitation becomes critical for non-ideal solution phase models that involve both a large number of chemical components, and mixing on a large number of sites, resulting in many inequality constraints of the form 0xlM1, where xlM is the fraction of element l mixing on site M.

Here, we present a general reformulation of complex non-ideal solution phases from the thermodynamic database of Holland et al. (2018), which comprises equations of state for multiple mineral solid solutions appearing in magmatic systems, as well as multicomponent silicate melt and aqueous fluid phases. Using a nullspace approach, non-linear inequality constraints governing the site fractions are transformed into equality constraints, and the resulting problem is turned into an bound-constrained optimization problem, subsequently optimized using efficient gradient-based methods. To test our formulation, we apply it to several equations of state for solution phases known for their complexity and compare the results of our approach against classical optimization algorithms supporting inequality constraints.

We find that the the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm yields by far the best performance and stability with respect to the other investigated methods, improving the minimization time of individual solution phase by a factor ≥10. We estimate that our new approach can improve the computational time of stable phase equilibrium by a factor ≥5, thus potentially allowing to model realistic reactive fluid/magmatic systems by directly integrating phase equilibrium calculations in multiphase thermomechanical codes.

Share
1 Introduction

While the last decade has seen significant progress in thermomechanical modeling of complex multiphase systems (e.g., Keller et al.2013; Taylor-West and Katz2015; Keller and Katz2016; Keller et al.2017; Turner et al.2017; Keller and Suckale2019; Rummel et al.2020; Katz et al.2022), the coupling with petrological modeling, when addressed at all, remains largely simplified (Riel et al.2019). There are two key obstacles. First, most phase equilibrium modeling tools (e.g., Perple_X, Theriak_Domino, geoPS, MELTS) (Connolly2005; de Capitani and Petrakakis2010; Xiang and Connolly2021; Ghiorso and Sack1995) have been developed with the primary aim of producing phase diagrams and do not offer useful interfaces to integrate with (parallel) geodynamic codes. Second, phase equilibrium modeling is generally achieved by solving a Gibbs energy minimization problem which is computationally challenging. Several numerical strategies have been developed to solve such optimization problems (Ghiorso and Sack1995; Connolly2005; de Capitani and Petrakakis2010; Piro2011; Xiang and Connolly2021) and some of the most efficient algorithms rely on repeated solution model minimization in order to compute for the most stable mineral assemblage (e.g., de Capitani and Petrakakis2010; Xiang and Connolly2021; Riel et al.2022). Although computational performance have been significantly increased over the past few years (Xiang and Connolly2021; Riel et al.2022),single point equilibrium prediction is still costly, with computational times of the order of 10 to 100 ms (e.g., Riel et al.2022). This limitation effectively precludes direct coupling of phase equilibrium calculations with thermomechanical models, which requires performing from thousands to hundreds of thousands of such calculations every timestep.

In order to account for chemical separation in geodynamic models, several computationally cheaper workarounds have been used. This includes the use of pre-computed set of pseudosections (e.g., Magni et al.2014; Bouilhol et al.2015; Rummel et al.2020), parameterizations (e.g., Jackson et al.2003, 2018; Hu et al.2022; Wong and Keller2023) and the ongoing development of neural networks (e.g., Leal et al.2020; Yuan et al.2024; Candioti et al.2024). In (Rummel et al.2020), the authors generated a database of pre-computed results from phase-equilibria modeling covering the explored/expected compositional, pressure and temperature range of the system. While this approach is powerful, it suffers several limitations. First, to generate a relevant petrological database, the geodynamic model has to be run multiple times in order to characterize the effective pressure, temperature and compositional range of the system. Second, the database is by definition discrete which implies that a compositional tolerance has to be applied when computing the stable phase equilibrium, thus leading to mass conservation issues.

https://gmd.copernicus.org/articles/18/6951/2025/gmd-18-6951-2025-f01

Figure 1Ratio of time spent solving the local problem of the equilibrium composition and order in individual solution models (“total local”), to time spent solving the entire problem of establishing which is the most stable of the possible phase equilibria (“global minimization”), using MAGEMin (Riel et al.2022) for two representative test cases. Both tonalite and wet basalt bulk-rock compositions are taken from (Holland et al.2018). In total 619 points were computed from 0 to 12 kbar and from 600 to 900 °C and from 800 to 1100 °C for the tonalite and the wet basalt case, respectively.

Download

Although the heavy computational requirements of stable phase equilibrium modeling remains a major obstacle for direct coupling, recently developed minimization tools yielded a significant improvement in performance (Xiang and Connolly2021; Riel et al.2022). The recent performance increase mainly results from combining/improving existing minimization methods and making use of gradient-based minimization of individual phases to speed up the computations. Several gradient-based minimization methods are currently employed in the different routines computing phase equilibria. Theriak-Domino (de Capitani and Brown1987; de Capitani and Petrakakis2010) uses either steepest gradient or Newton-Raphson methods. Minimization of the solution phase model is achieved using a feasible starting guess and continues until a bound or a site fraction constraint is violated. In our recent phase equilibrium calculation software MAGEMin (Riel et al.2022), the analytical expressions of the equations of state for solution phases are passed to NLopt software package (Johnson2021). Subsequently, the objective function is minimized using the Conservative Convex Separable Approximation with Quadratic penalty (CCSAQ) algorithm (Svanberg2002) which solves for inequality-constrained nonlinear programming problems. During the inner iterations, a series of convex sub-problems approximating the objective function and the constraints are generated and solved until the constraints are satisfied (Svanberg2002). This procedure is repeated until the solution phase model is minimized. The phase equilibria calculator GeoPS (Xiang and Connolly2021) uses the simulated annealing (SA) method. Compared to gradient-based methods, simulated-annealing is a probabilistic technique for approximating the global optimum of a given function (e.g., Pincus1970). Here, constraints can be accounted for as penalties on the objective function.

The first release of MAGEMin followed the thermocalc software (Powell and Holland1988) in treating the physicality of site fractions as a set of inequality constraints expressed as functions of compositional and order variables (Holland et al.2018) (see e.g., Eq. 11). This approach ensures that all site fractions in the present solution phases satisfy the condition ≥0. Furthermore, since the parameterisation of site fractions enforces that the sum of all site fractions associated with a given site equals unity, this automatically guarantees that all individual site fractions are also ≤1. However, the use of inequality constraint in gradient-based methods, results in relatively slow performances and occasional solver failure due to slight violation of inequality constraints. Using the first publicly released version of MAGEMin (Riel et al.2022), we find that the global minimization time is largely dominated by how fast gradient-based minimization of individual solution phases can be performed, with 75 % to 90 % of the computation time dedicated to local minimization to find the equilibrium compositions and state of order of solution models (see Fig. 1). Therefore, it becomes critically important to improve the minimization time of individual solution phase models to further speed-up the overall phase-equilibrium computational time.

Here, we present a revised implementation of the compositional and order variables (xeos) of Holland et al. (2018) within MAGEMin that avoids the need to express the site fraction expressions as non-linear inequality constraints. Elimination of these constraints allows using faster bound-constrained optimization methods, thus considerably improving performance and stability of the code. We compare the accuracy and performance of two well-known gradient-based optimization methods: the conjugate gradient (CG) and the Broyden-Fletcher-Goldfarb-Shanno (BFGS) method.

2 Methodology

2.1 Solution phase formulation

At fixed pressure P and temperature T, the total Gibbs energy of solution phase λ is given by

(1) G λ = i = 1 N λ μ i ( λ ) p i ( λ ) .

where Gλ [J] is the Gibbs energy of the solution phase λ, Nλ the number of end-members of solution phase λ, pi(λ) [mol] is the fraction of end-member i dissolved in solution phase λ and μi(λ) [J mol−1] is the molar chemical potential of end-member i in solution phase λ. An end-member is defined as an independent instance of a solution phase, at a single specified composition, for which the Gibbs energy is fully defined as a function of pressure and temperature only. In a given chemical system, the linear combinations of the end-members span the complete crystallographic site-occupancy space of the solution phase.

The molar chemical potential of a phase is a function of the dissolved end-members within a solution phase (see Ganguly2001 for a review)

(2) μ i ( λ ) = g i ( λ ) 0 + R T ln ( a i ( λ ) id ) + g i ( λ ) ex ,

where R [J mol−1 K−1] is the ideal gas constant, T [K] is the absolute temperature, ai(λ)id [/] is the ideal activity, gi(λ)0 [J mol−1] the reference molar Gibbs energy of the pure end-member (Helgeson1978; Holland and Powell1998) and gi(λ)ex [J mol−1] is the molar excess energy term (Powell and Holland1993; Holland and Powell2003). The ideal activity coefficient ai(λ)id is generally defined as ai(λ)id=pi(λ) for molecular mixing, or else for mixing on crystallographic sites as

(3) a i ( λ ) id = c i s ( X e s , i s ) ν s

where Xes,is is the site fraction of the element es,i that appears on site s in end-member i of phase λ, νs is the number of atoms contained in mixing site s of λ, and ci is a normalization constant that ensures that ai(λ)id is unity for the pure end-member i.

In the asymmetric formalism, giex is given by:

(4) g i ( λ ) ex = - m = 1 N λ - 1 n > m N λ ( ϕ m - ϕ m ) ( ϕ n - ϕ n ) W m , n 2 v i v m + v n ,

where ϕm,n is the proportion of end-members m,n weighted by the asymmetry parameters, as ϕm,n=(pm,nvm,n)/(k=1Nλpkvk), with vm,n,k the van Laar parameters for end-members m,n,k. ϕm,n=1 where m=n and ϕm,n=0 where mn. Wm,n [J mol−1] is the interaction energy between end-members m and n in the solution.

In Holland et al. (2018), composition (the overall ratios of elements) and order (the distribution of elements over mixing sites) in an xeos are parameterized in terms of an independent set of variables (see example below). Given this formulation, the set of Eqs. (1) to (4) can be directly transformed into the following Gibbs free energy minimization problem as function of the compositional and order variable xcv:

(5) min G λ ( x cv ) = i = 1 N λ μ i ( λ ) p i ( λ ) ,

subject to the site fraction of the element

(6) X e s , i s 0 ,

and that the compositional and order variables xcv must be within a lower (lbcv) and upper (ubcv) limit

(7) l b cv x cv u b cv ,

where μi(λ), pi(λ), and Xes,is are functions of the compositional and order variables xcv, and, lbcv and ubcv are the lower and upper bounds on the set of compositional and order variables xcv. The first derivative of f(xcv) is given by

(8) f x cv = μ i ( λ ) p i ( λ ) x cv ,

and the first derivative of the inequality constraints on the site fraction by

(9) X e s , i s x cv .

2.2 A revised formulation

The solid solutions presented in Holland et al. (2018) are formulated on the basis of exchanging chemical species on a finite number of unique crystallographic sites (Bragg–Williams-type formulation, see Myhill and Connolly, 2021 for more details). A key challenge with this formulation is that minimization has to be performed while keeping site fractions ≥0. Our previous implementation (Riel et al.2022) imposed these inequalities constraints directly using NLopt (Johnson2021), which has a significantly higher numerical cost compared to the bound-constrained minimization algorithms. To simplify the optimization problem and reduce computation time, we use an alternative nullspace formulation (similar to HeFESTo, Stixrude and Lithgow-Bertelloni2011), different from the compositional and order variable approach used in e.g., Holland et al. (2018), that transforms the non-linear inequality constraints on the site fractions into linear equality constraints. This reformulation is illustrated below using olivine as a representative example.

The olivine solid solution model (Holland et al.2018) contains 2 mixing sites M1 and M2 and represents a phase that can be expressed by the general formula:

(10) [ Mg 2 + , Fe 2 + ] M 1 [ Mg 2 + , Fe 2 + , Ca 2 + ] 4 M 2 SiO

Here Mg2+ and Fe2+ can be exchanged on crystallographic site M1 and Mg2+, Fe2+ and Ca2+ can be exchanged on site crystallographic M2. In Holland et al. (2018), the site fractions are expressed as:

(11)XMgM1=1-x+Q(12)XFeM1=x-Q(13)XMgM2=(1-x)(1-c)-Q(14)XFeM2=x(1-c)+Q(15)XCaM2=c

where composition has been parameterized using the variables x=(XFeM1+XFeM2)/(XFeM1+XFeM2+XMgM1+XMgM2) and c=XCaM2, and order has been parameterized using the variable Q=x-(XFeM1)/(XFeM1+XMgM1). Note that we have dropped the ion charges in the notation of the equations.

This parameterisation ensures that the site fractions on each of the individual sites are inherently normalized to 1. Two other types of constraint might be built into the parameterisation in a more complex example: (i) charge balance: if variably-charged ions were mixing, charge balance would be maintained during compositional change, and (ii) equidistribution: the xeos might be simplified by equating two site fractions, typically involving minor elements. The resulting set of composition and order variables is an independent set, that fully and uniquely describes the site occupancies at a given composition and state of order, subject to physical constraints arising from the lattice structure of the mineral. The relationship between the number of composition and order variables and the number of site fractions is then given by:

(16) n sf = n x cv + n eq norm + n eq cb + n eq edist ,

with nsf the number of site fractions, nxcv the number of compositional and order variables, neqnorm the number of constraints arising from the normalization of site fractions on a given site to 1, neqcb the number of charge balance equations, equal to 0 or 1, and neqedist the number of equidistribution constraints imposed. Collectively, the normalized charge balance and equidistribution constraints form a set of linear equalities among the site fractions.

In the revised implementation, we retrieve the set of equality constraints Ax=b for olivine from the site fractions Xess={XMgM1,XFeM1,XMgM2,XFeM2,XCaM2}, and compositional and order variables xcv={x,c,Q} as follows. We first take the partial derivatives of site fractions as functions of the compositional and order variables as:

(17) X e s , i s x cv = - 1 0 1 1 0 - 1 c - 1 x - 1 - 1 1 - c - x 1 0 1 0 ,

where Xes,is is the site fraction of the element es,i that appears on site s, xcv the set of compositional and order variables cv and x, c the compositional and order variables of olivine as defined in Holland et al. (2018). Next, we compute the matrix of site mixing coefficients A using symbolic expressions as

(18) A = Null ( ( X e x cv ) T ) = 1 1 0 0 0 0 0 1 1 1 ,

where Null stands for the null space. We then establish the vector of constraints b as

(19) b = { 1 , 1 } ,

which ensures that the sum of the site fractions of mixing sites XM1 and XM2 equal unity. Subsequently, given x=Xess and by linearizing Ax=b we can return the set of linear equalities on the olivine site fractions, which comprises two site normalization expressions:

(20) 1 × X Mg M 1 + 1 × X Fe M 1 = 1.0 ,

and

(21) 1 × X Mg M 2 + 1 × X Fe M 2 + 1 × X Ca M 2 = 1.0 .

Note that, for more complex activity-composition models, and depending on the arbitrary order in which the site fractions are listed, the nullspace operation may not yield expressions that clearly represent the site normalization, charge balance, and equidistribution constraints. However, it will always produce an independent set of linear equalities whose total number is equal to the sum of the number of site normalization constraints, the number of charge balance constraints, and the number of equidistribution constraints. These equalities are mathematically equivalent to the original constraints and can be linearly recombined to recover their straightforward forms.

In the implementation of Riel et al. (2022), MAGEMin solved for the equilibrium composition and state of order of a phase in terms of the variables xcv, subject to the constraint that the values of site fractions should be ≥0. To eliminate the site fraction inequalities from the implementation, we now wish to solve directly for the site fractions, while subjecting them to the equality constraints obtained via the nullspace operation. The resulting problem can be expressed as

(22) min f ( x ) ,

subject to

(23) A x = b ,

where x represent the n site-fractions and Ax=b is the set of p equality constraints (Eq. 18). The linear equality constraints can now be eliminated from the problem, reducing the number of variables solved for back to the number of composition and ordering variables. This is accomplished by parameterizing the feasible set of the constraint equation Ax=b using a particular solution x^Rn and a matrix NzRn×(n-p) that spans the nullspace of A, such that:

(24) { x | A x = b } = { x ^ + N z | z R n - p } .

This parameterization can be obtained by performing a full QR decomposition of the constraint matrix A, written as:

(25) A = Q R 1 0 = Q 1 Q 2 R 1 0 ,

where QRm×m is an orthogonal matrix whose columns q1,,qm form an orthonormal basis for m. These columns are typically grouped into two blocks: Q1, which contains the first p columns and spans the image (row space) of A, and Q2, which contains the remaining mp columns and spans the nullspace of AT. With this decomposition, the set of solutions to the linear equality constraints can be written as:

(26) x = Q 1 R 1 T b + Q 2 z ,

where x^=Q1R1Tb is a particular solution to Ax=b, and Q2z is any vector in the nullspace of A.

In other words, the use of the null space of A (Nz) parameterizes the space such that for any step Δz, x^+NzΔz remains in the feasible domain.

Using the elimination method, Eq. (1) becomes

(27) min f ( x ) = G λ ( X e s , i s ) = i = 1 N λ μ i ( λ ) p i ( λ ) ,

and the parameterized first derivative becomes

(28) f x ( z ) = G λ X e s , i s ( z ) = N z ( ( G λ x ) T N z ) T ,

where Xes,is is the site fraction of the element es,i that appears on site s. Equation (27) is then minimized using the gradient information given by Eq. (28) and the methods presented below.

2.3 Gradient-type iterative methods

Given a bound-constrained optimization problem:

(29) min f ( x ) subject to  x > ϵ

where f(x) is twice continuously differentiable, where ϵ is a small number, typically 10-8. The general gradient-type iterative method to solve this problem is of the form

(30) x k + 1 = x k + α k d k ,

for iteration k≥0, where dk is the search direction and αk is the step-length. In this study, we compute the step-length using a Wolfe line search (Wolfe1969) such that the inequalities

(31) f ( x k + γ k α k d k ) f ( x k ) + ρ γ k α k g k T d k ,

and

(32) g k + 1 T d k σ g k T d k ,

are satisfied, where 0<ρ<σ<1 and γx is the maximum feasible step-length, computed as

(33) γ x = 1 / min ( x k + 1 - ϵ ) abs ( d k ) , if any  x k + d k 0 1 , otherwise .

The maximum feasible step-length γx ensures that the values of site-fractions remain ϵ and form the bounds of the problem. Iterations are then processed until a stopping criterion is satisfied. Because solution phases are not necessarily convex during global Gibbs energy minimization, we set the stopping criteria using the relative change of the objective function. The stopping criteria is met when

(34) abs ( ( f k - f k - 1 ) / f k - 1 ) < tol ,

where tol is a small number typically 10-8.

If the descent direction dk is simply chosen to be dk=-gk we obtain the steepest descent algorithm. However, this approach is known to be prone to oscillation (e.g., Nocedal et al.2002) and slow convergence, and will therefore not be explored. Instead, we test two bound-constrained optimization methods that use the gradient information of the previous iteration(s), namely the conjugate gradient and the Broyden-Fletcher-Goldfarb-Shanno (BFGS) method.

2.3.1 Conjugate gradient method

For the conjugate gradient method, the descent direction is initialized for the first iteration increment k=0 as

(35) d k = - g k ,

and for increment k≥1 as

(36) d k = - g k + β k d k - 1 .

Here, gk is the gradient g(x) of function f(x) at point xk, and βk is the conjugate gradient update parameter. Variants of the conjugate gradient method are defined by using different update parameters βk (see for example Hestenes and Stiefel1952; Rivaie et al.2012, 2015). Here, we employ the three-term conjugate gradient method presented by Liu et al. (2018) with the update parameter βk defined in Rivaie et al. (2015)

(37) β k = g k T ( g k - g k - 1 - d k - 1 ) d k - 1 2 ,

and further extend the descent direction term as

(38) d k = - g k + β k d k - 1 + θ k y k - 1 ,

where yk-1=gk-gk-1 and

(39) θ k = - g k T d k - 1 d k - 1 2 .

A useful property of the three-term conjugate gradient method is that the search direction always satisfies the sufficient descent condition without any line search (Liu et al.2018).

The descent direction is parameterized to satisfy the equality constraints (Eq. 18) such as

(40) d k p = N z ( d k T N z ) T .

2.3.2 BFGS method

The Broyden-Fletcher-Goldfarb-Shanno (BFGS) method is a well-known quasi-Newton method for solving unconstrained and bound-constrained optimization problems (see for instance Fletcher1987; Dennis and Schnabel1996). The quasi-Newton descent direction is given by

(41) d k = - B - 1 g k ,

where B−1 is the inverse of the Hessian matrix. Here, we approximate B−1 using the Sherman-Morrison formula (Sherman and Morrison1950) such as

(42) B k + 1 - 1 = B k - 1 + ( s k T y k + y k T B k - 1 y k ) ( s k s k T ) ( s k T y k ) 2 - B k - 1 y k s k T + s k y k T B k - 1 s k T y k

where sk=xk+1-xk, yk=gk+1-gk and Bk=0-1 is initialized with the identity matrix.

Because of the relatively low dimensionality of the solution phase model (<20) we do not consider the limited-memory BFGS method (L-BFGS) and instead update Bk-1 (Eq. 42) during every iteration. Once the problem has converged (i.e., Eq. 34 is satisfied), we reset the Hessian matrix inverse Bk-1 to the identity matrix and perform additional iteration(s). This ensures that the problem converges to its local minimum in the event the quality of the approximate Hessian matrix inverse Bk-1 is degraded.

As for the conjugate gradient method, the descent direction is parameterized to satisfy the equality constraints (Eq. 18) such as

(43) d k p = N z ( d k T N z ) T .
3 Application

In order to test the bound-constrained solution phase formulation, we selected, from the Holland et al. (2018) set of xeos spaning 11 oxides (Na2O-CaO-K2O-FeO-MgO-Al2O3-SiO2-H2O-TiO2-O-Cr2O3), three solution phases with complex features including high-dimensional composition–order spaces and geologically significant solvi: clinoamphibole (Na2O-CaO-K2O-FeO-MgO-Al2O3-SiO2-H2O-TiO2-O), clinopyroxene (Na2O-CaO-K2O-FeO-MgO-Al2O3-SiO2-TiO2-O-Cr2O3) and spinel (FeO-MgO-Al2O3-TiO2-O-Cr2O3) (Table 1). We use as starting points the set of feasible points of each discretized solution phase. Discretization of the solution phases is achieved using a compositional variable step of 0.25 which yielded 5498, 4124 and 1521 feasible starting points (or pseudocompounds) for clino-amphibole, clinopyroxene and spinel, respectively. Because gradient-based minimization of solution phase models is achieved with respect to a given Gibbs hyperplane (de Capitani and Brown1987; de Capitani and Petrakakis2010; Xiang and Connolly2021; Riel et al.2022), we first compute the phase equilibrium at a given pressure, temperature and bulk-rock composition to retrieve the global minimum Gibbs hyperplane using MAGEMin (Table 1). Although any other arbitrary Gibbs hyperplane can be used for this test, we choose a global minimum hyperplane in order to explore a known spinel solvus, All computations were performed on a Linux (x86_64-linux-gnu) operating system, utilizing a 6-core 11th Gen Intel(R) Core(TM) i5-11400H CPU running at 2.70 GHz.

Table 1Solution phase models parameters.

Download Print Version | Download XLSX

The performance and reliability of the bound-constrained formulations are tested against the inequality constrained formulations using the Sequential Least-Squares Quadratic Programming (SLSQP) (Kraft1988, 1994) and Conservative Convex Separable Approximation with Quadratic penalty (CCSAQ) methods (Svanberg2002). The minimizations using the SLSQP and CCSAQ methods were computed using the C implementation of NLopt (Jackson et al.2018) through MAGEMin as described in Riel et al. (2022) and in the scripts provided in Supplement. Because the algorithms explored in this study (Julia implementation of CG and BFGS methods) exhibited similar accuracy with residual 10-13, the differences in algorithm accuracy are not discussed. Here, a minimization is considered successful when the norm of the distance to the solution is 10-4.

4 Discussion

4.1 Algorithms performance and reliability

The box plots depicted in Fig. 2 illustrate that the performance of the unconstrained CG method is comparable to that of the inequality-constrained CCSAQ method (implemented via NLopt). While the CG method outperforms CCSAQ for amphibole, with minimization times of  2100 µs versus  4200 µs, respectively, the efficiency of CCSAQ is larger for problems with lower dimensionality, such as clinopyroxene and spinel. The SLSQP method demonstrates superior efficiency, with average minimization times of  340 µs for amphibole,  270 µs for clinopyroxene, and  120 µs for spinel. However, the BFGS algorithm outperforms SLSQP, achieving average minimization times of  220 µs for amphibole, 180 µs for clinopyroxene, and  100 µs for spinel; a performance increase of 20 % to 50 %. Additionally, the BFGS method's convergence requires between 25 to 90 iterations across different solution phase models, as indicated in Fig. 3. Notably, the minimum time per iteration is influenced by the dimensionality of the solution phase model, ranging from  4.0 µs per iteration for clino-amphibole to  2.1 µs for spinel (Fig. 3 and Table 1).

https://gmd.copernicus.org/articles/18/6951/2025/gmd-18-6951-2025-f02

Figure 2Minimization time box plot for tested solution phases and optimization methods. SLSQP, Sequential Least-Squares Quadratic Programming (supporting both inequality and equality constraints); CCSAQ, Conservative Convex Separable Approximation with Quadratic penalty; CG, conjugate gradiend; BFGS, Broyden-Fletcher-Goldfarb-Shanno. 5498, 4124 and 1521 starting points for clino-amphibole, clinopyroxene and spinel, respectively. Starting points were generated by evenly sampling the entire feasible space following the method presented in Riel et al. (2022). The numbers below the boxes show the number of successful minimizations over the total number of tested points.

Download

https://gmd.copernicus.org/articles/18/6951/2025/gmd-18-6951-2025-f03

Figure 3Number of iterations versus minimization time for the BFGS method. The red lines show the minimum minimization time per iteration.

Download

Although the average minimization time is a good indicator of the raw performance of the algorithms, reliability of the solvers is of key importance when computing phase equilibria. In this light, we find that the bound-constrained algorithms (CG and BFGS) are far superior to the inequality constraints ones (CCSAQ and SLSQP). For instance, the bound-constrained methods (BFGS and CG) successfully minimize 100 % of the tested starting points (Fig. 2) while the inequality constraints methods show a significant amount of unsuccessful minimization reaching up to 50 % in some cases e.g., clino-amphibole minimization using SLSQP or spinel using CCSAQ (Fig. 2). The unsuccessful minimizations are related to violated inequality constraints and the inability for the algorithms (SLSQP and CCSAQ) to go back to the feasible domain.

Finally, we tested the BFGS algorithm for an equilibrium between two phases separated by a solvus i.e., an objective function containing more than one local minimum. The parameters of the test are given in Table 1 (spinel solvus) and the results are shown in Fig. 4. The bound-constrained formulation and the BFGS method perfectly captures the solvus with consistent minimization time similar to those shown in Fig. 2.

https://gmd.copernicus.org/articles/18/6951/2025/gmd-18-6951-2025-f04

Figure 4Minimization paths for an example of spinel solvus. The spinel solvus has been computed using the Gibbs hyperplane provided in Table 1 which was computed using MAGEMin. Black dots, starting point in the XCrM, XMgT and XTiM site fraction sub-system; yellow circles with black outline, local minimum of the solvus; red and blue lines, minimization paths from starting point to local minimum. Note that the diagram only displays a 3D sub-system of the full 10D system.

Download

4.2 Minimization of perturbed systems

Minimization from discretized starting points allows quantification and comparison of the raw performance and stability of the algorithms (CG, BFGS and CCSAQ, see Fig. 2). However, a phase equilibrium calculation employing gradient-based methods generally involves finding a new local minimum under slightly to moderately perturbed conditions between global iterations (de Capitani and Petrakakis2010; Riel et al.2022) i.e., that the distance between the starting point and the ending point during local minimization of individual phases is small. A measure of this distance can be calculated as the variation of the norm of the Gibbs hyperplane: ΔΓ22, where Γ is the chemical potential of the pure components of the system (oxides in our case, Table 1). In order to test the performance of the SLSQP and BFGS methods under small perturbations, we use as starting points the minima obtained by tests 1 to 3 and apply a perturbation to the Gibbs hyperplane (Table 1). The perturbation is set by applying a random rotation to the objective function which shifts the local minimum from its current position. We explore the effect of such perturbation by computing 10 000 random rotations per solution phase yielding a range of chemical potential ΔΓ22 varying from 0.0 to ca. 60.0. The results of the minimizations of the rotated systems are presented in Fig. 5a–c.

https://gmd.copernicus.org/articles/18/6951/2025/gmd-18-6951-2025-f05

Figure 5Minimization time for perturbed systems. (a–c) SLSQP algorithm applied to clino-amphibole, clinopyroxene and spinel, respectively. (d–f) BFGS algorithm applied to clino-amphibole, clinopyroxene and spinel, respectively. ΔΓ22 is a measure of the distance between the starting guess and the solution. Note that the inequality constrained SLSQP method does not show any correlation between the distance to solution and the minimization. The BFGS method, instead, exhibits a clear trend of decreasing minimization for smaller distances to solution.

Download

For perturbed conditions, we find that the minimization time of the SLSQP algorithm does not scale with the norm of the perturbation (ΔΓ22) (Fig. 5a, b, c). This relationship is independent of the tested solution phase model (Fig. 5a–c). Instead, for the BFGS algorithm, the minimization time scales with the norm of the perturbation (Fig. 5d–f). For a ΔΓ22<10.0 the minimization time is divided by a factor of ca. 2.0 to 3.0 with respect to the mean raw minimization time (Fig. 2) resulting in an average time of 70–80 µs for clino-amphibole, 50–60 µs for clinopyroxene and 30–40 µs for spinel.

We propose a revised xeos implementation using a nullspace approach, that allows using bound-constrained, rather than inequality-constrained, gradient-based optimisation methods. We tested the performance and computational reliability of different algorithms and find that the BFGS method yields the best performance, decreasing the minimization time of individual solution phases by a factor ≥10 compared to CG and CCSAQ methods and by a factor of 1.5 to 2.0 with respect to the SLSQP method (Fig. 2). Under slight perturbations, the minimization time is further decreased by a factor of 2.0 reaching down to  100 µs for clino-amphibole,  80 µs for clinopyroxene and  50 µs for spinel.

Regarding computational reliability, bound-constrained optimization methods(such as CG and BFGS), are clearly preferable over methods with inequality constraints (CCSAQ and SLSQP), which exhibit a considerable proportion of unsuccessful minimizations.

Using an bound-constrained nullspace formulation and the BFGS method, can therefore significantly improve the performance of stable phase calculations. Given that in MAGEMin,  75 % of the computational load is dedicated to local minimization of solution phase models, we estimate a general speed-up of stable phase equilibrium prediction by a factor  5. Such improvement can potentially opens up the possibility of performing 2D reactive models fluid/magma transport.

Code and data availability

All the Julia scripts and data necessary to reproduce the results and figures of this contribution are provided on Zenodo (https://doi.org/10.5281/zenodo.13982544, Riel et al.2024) and GitHub on https://github.com/ComputationalThermodynamics/SandBox (last access: 30 July 2024).

Supplement

The supplement related to this article is available online at https://doi.org/10.5194/gmd-18-6951-2025-supplement.

Author contributions

NR developed and implemented the new formulation, made the analysis and wrote the paper. BJPK, EG, AdM, and VM provided technical support and feedback during development. HD did the additional testing and improvement of the code. All authors actively contributed to the project through regular meetings and provided critical feedback. All authors revised the final version of the paper.

Competing interests

At least one of the (co-)authors is a member of the editorial board of Geoscientific Model Development. The peer-review process was guided by an independent editor, and the authors also have no other competing interests to declare.

Disclaimer

Publisher's note: Copernicus Publications remains neutral with regard to jurisdictional claims made in the text, published maps, institutional affiliations, or any other geographical representation in this paper. While Copernicus Publications makes every effort to include appropriate place names, the final responsibility lies with the authors. Also, please note that this paper has not received English language copy-editing. Views expressed in the text are those of the authors and do not necessarily reflect the views of the publisher.

Acknowledgements

We thank the two anonymous reviewers for their helpful and constructive reviews, which greatly improved the quality of this paper.

Financial support

This study was funded by the European Research Council through the MAGMA project, ERC Consolidator Grant #771143. Nicolas Riel, Boris J. P. Kaus and Evangelos Moulas would also like to acknowledge the German Research Foundation (DFG) – project number 521637679 for financial support.

This open-access publication was funded by Johannes Gutenberg University Mainz.

Review statement

This paper was edited by Mauro Cacace and reviewed by two anonymous referees.

References

Bouilhol, P., Magni, V., van Hunen, J., and Kaislaniemi, L.: A numerical approach to melting in warm subduction zones, Earth and Planetary Science Letters, 411, 37–44, 2015. a

Candioti, L. G., Nathwani, C. L., and Chelle-Michou, C.: Towards fully-coupled thermodynamic-thermomechanical two-phase flow models of transcrustal magmatic systems, in: EGU General Assembly Conference Abstracts, p. 16936, https://doi.org/10.5194/egusphere-egu25-8644, 2024. a

Connolly, J. A. D.: Computation of phase equilibria by linear programming: A tool for geodynamic modeling and its application to subduction zone decarbonation, Earth and Planetary Science Letters, 236, 524–541, 2005. a, b

de Capitani, C. and Brown, T. H.: The computation of chemical equilibrium in complex systems containing non-ideal solutions, Geochimica et Cosmochimica Acta, 51, 2639–2652, https://doi.org/10.1016/0016-7037(87)90145-1, 1987. a, b

de Capitani, C. and Petrakakis, K.: The computation of equilibrium assemblage diagrams with Theriak/Domino software, American Mineralogist, 95, 1006–1016, https://doi.org/10.2138/am.2010.3354, 2010. a, b, c, d, e, f

Dennis, J. E. and Schnabel, R. B.: Numerical methods for unconstrained optimization and nonlinear equations, SIAM, https://doi.org/10.1137/1.9781611971200, 1996. a

Fletcher, R.: Practical methods of optimization, John and Sons, Chichester, https://doi.org/10.1002/9781118723203, 1987. a

Ganguly, J.: Thermodynamic modelling of solid solutions, EMU Notes in Mineralogy, 3, 37–69, 2001. a

Ghiorso, M. S. and Sack, R. O.: Chemical mass transfer in magmatic processes IV. A revised and internally consistent thermodynamic model for the interpolation and extrapolation of liquid-solid equilibria in magmatic systems at elevated temperatures and pressures, Contributions to Mineralogy and Petrology, 119, 197–212, 1995. a, b

Helgeson, H. C.: Summary and critique of the thermodynamic properties of rock-forming minerals, American Journal of Science, 278, 1–229, 1978. a

Hestenes, M. R. and Stiefel, E.: Methods of conjugate gradients for solving, Journal of research of the National Bureau of Standards, 49, 409–436, https://doi.org/10.6028/jres.049.044, 1952. a

Holland, T. and Powell, R.: Activity–composition relations for phases in petrological calculations: an asymmetric multicomponent formulation, Contributions to Mineralogy and Petrology, 145, 492–501, 2003. a

Holland, T. J. B. and Powell, R.: An internally consistent thermodynamic data set for phases of petrological interest, Journal of Metamorphic Geology, 16, 309–343, https://doi.org/10.1111/j.1525-1314.1998.00140.x, 1998. a

Holland, T. J. B., Green, E. C. R., and Powell, R.: Melting of peridotites through to granites: a simple thermodynamic model in the system KNCFMASHTOCr, Journal of Petrology, 59, 881–900, 2018. a, b, c, d, e, f, g, h, i, j

Hu, H., Jackson, M. D., and Blundy, J.: Melting, compaction and reactive flow: Controls on melt fraction and composition change in crustal mush reservoirs, Journal of Petrology, 63, egac097, https://doi.org/10.1093/petrology/egac097, 2022. a

Jackson, M., Blundy, J., and Sparks, R.: Chemical differentiation, cold storage and remobilization of magma in the Earth's crust, Nature, 564, 405–409, 2018. a, b

Jackson, M. D., Cheadle, M. J., and Atherton, M. P.: Quantitative modeling of granitic melt generation and segregation in the continental crust, Journal of Geophysical Research: Solid Earth, 108, https://doi.org/10.1029/2001JB001050, 2003. a

Johnson, S. G.: The NLopt nonlinear-optimization package, https://doi.org/10.7283/633E-1497, 2021. a, b

Katz, R. F., Jones, D. W. R., Rudge, J. F., and Keller, T.: Physics of Melt Extraction from the Mantle: Speed and Style, Annual Review of Earth and Planetary Sciences, 50, 507–540, https://doi.org/10.1146/annurev-earth-032320-083704, 2022. a

Keller, T. and Katz, R. F.: The Role of Volatiles in Reactive Melt Transport in the Asthenosphere, Journal of Petrology, 57, 1073–1108, https://doi.org/10.1093/petrology/egw030, 2016. a

Keller, T. and Suckale, J.: A continuum model of multi-phase reactive transport in igneous systems, Geophysical Journal International, 219, 185–222, https://doi.org/10.1093/gji/ggz287, 2019. a

Keller, T., May, D. A., and Kaus, B. J. P.: Numerical modelling of magma dynamics coupled to tectonic deformation of lithosphere and crust, Geophysical Journal International, 195, 1406–1442, https://doi.org/10.1093/gji/ggt306, 2013. a

Keller, T., Katz, R. F., and Hirschmann, M. M.: Volatiles beneath mid-ocean ridges: Deep melting, channelised transport, focusing, and metasomatism, Earth and Planetary Science Letters, 464, 55–68, 2017. a

Kraft, D.: A software package for sequential quadratic programming, Forschungsbericht- Deutsche Forschungs- und Versuchsanstalt fur Luft- und Raumfahrt, https://primo.uni-due.de/permalink/49HBZ_UDE/1gpd7fl/alma990012356640206446 (last access: 7 October 2025), 1988. a

Kraft, D.: Algorithm 733: TOMP–Fortran modules for optimal control calculations, ACM Transactions on Mathematical Software (TOMS), 20, 262–281, 1994. a

Leal, A. M., Kyas, S., Kulik, D. A., and Saar, M. O.: Accelerating reactive transport modeling: on-demand machine learning algorithm for chemical equilibrium calculations, Transport in Porous Media, 133, 161–204, 2020. a

Liu, J., Feng, Y., and Zou, L.: Some three-term conjugate gradient methods with the inexact line search condition, Calcolo, 55, 1–16, 2018. a, b

Magni, V., Bouilhol, P., and Van Hunen, J.: Deep water recycling through time, Geochemistry, Geophysics, Geosystems, 15, 4203–4216, 2014. a

Nocedal, J., Sartenaer, A., and Zhu, C.: On the behavior of the gradient norm in the steepest descent method, Computational Optimization and Applications, 22, 5–35, 2002. a

Pincus, M.: A Monte Carlo method for the approximate solution of certain types of constrained optimization problems, Operations research, 18, 1225–1228, 1970. a

Piro, M. H. A.: Computation of Thermodynamic Equilibria Pertinent to Nuclear Materials in Multi-Physics Codes, PhD thesis, Royal Military College of Canada (Canada), ISBN 9780494822272, 2011. a

Powell, R. and Holland, T.: An internally consistent dataset with uncertainties and correlations: 3. Applications to geobarometry, worked examples and a computer program, Journal of metamorphic Geology, 6, 173–204, 1988. a

Powell, R. and Holland, T.: On the formulation of simple mixing models for complex phases, American Mineralogist, 78, 1174–1180, 1993. a

Riel, N., Bouilhol, P., van Hunen, J., Cornet, J., Magni, V., Grigorova, V., and Velic, M.: Interaction between mantle-derived magma and lower arc crust: quantitative reactive melt flow modelling using STyx, Geological Society, London, Special Publications, 478, 65–87, 2019. a

Riel, N., Kaus, B. J., Green, E., and Berlie, N.: MAGEMin, an efficient Gibbs energy minimizer: application to igneous systems, Geochemistry, Geophysics, Geosystems, 23, e2022GC010427, https://doi.org/10.1029/2022GC010427, 2022. a, b, c, d, e, f, g, h, i, j, k, l, m

Riel, N., Kaus, B., de Montserrat, A., Moulas, E., Green, E., and Dominguez, H.: An unconstrained formulation for complex solution phase minimization (Codes) (1.0), Zenodo [code, data set], https://doi.org/10.5281/zenodo.13982544, 2024. a

Rivaie, M., Mamat, M., June, L. W., and Mohd, I.: A new class of nonlinear conjugate gradient coefficients with global convergence properties, Applied Mathematics and Computation, 218, 11323–11332, 2012. a

Rivaie, M., Mamat, M., and Abashar, A.: A new class of nonlinear conjugate gradient coefficients with exact and inexact line searches, Applied Mathematics and Computation, 268, 1152–1163, 2015. a, b

Rummel, L., Kaus, B. J. P., Baumann, T. S., White, R. W., and Riel, N.: Insights into the Compositional Evolution of Crustal Magmatic Systems from Coupled Petrological-Geodynamical Models, Journal of Petrology, 61, https://doi.org/10.1093/petrology/egaa029, 2020. a, b, c

Sherman, J. and Morrison, W. J.: Adjustment of an inverse matrix corresponding to a change in one element of a given matrix, The Annals of Mathematical Statistics, 21, 124–127, 1950. a

Stixrude, L. and Lithgow-Bertelloni, C.: Thermodynamics of mantle minerals – II. Phase equilibria, Geophysical Journal International, 184, 1180–1213, https://doi.org/10.1111/j.1365-246X.2010.04890.x, 2011. a

Svanberg, K.: A class of globally convergent optimization methods based on conservative convex separable approximations, SIAM Journal on Optimization, 12, 555–573, https://doi.org/10.1137/S1052623499362822, 2002. a, b, c

Taylor-West, J. and Katz, R. F.: Melt-preferred orientation, anisotropic permeability and melt-band formation in a deforming, partially molten aggregate, Geophysical Journal International, 203, 1253–1262, 2015. a

Turner, A. J., Katz, R. F., Behn, M. D., and Keller, T.: Magmatic focusing to mid-ocean ridges: The role of grain-size variability and non-newtonian viscosity, Geochemistry, Geophysics, Geosystems, 18, 4342–4355, 2017. a

Wolfe, P.: Convergence conditions for ascent methods, SIAM review, 11, 226–235, 1969. a

Wong, Y.-Q., and Keller, T.: A unified numerical model for two-phase porous, mush and suspension flow dynamics in magmatic systems, 233, 769–795, https://doi.org/10.1093/gji/ggac481, 2023. a

Xiang, H. and Connolly, J. A. D.: GeoPS: An interactive visual computing tool for thermodynamic modelling of phase equilibria, Journal of Metamorphic Geology, https://doi.org/10.1111/jmg.12626, 2021. a, b, c, d, e, f, g

Yuan, Q., Asimow, P. D., Gurnis, M., and Antoshechkina, P. M.: Enabling large-scale geodynamic-geochemical modeling via neural network acceleration, in: AGU Fall Meeting Abstracts, vol. 2024, V41E–3161, 2024AGUFMV41E.3161Y, 2024. a

Download
Short summary
Our research focuses on improving the way we predict mineral assemblage. Current methods, while accurate, are slowed by complex calculations. We developed a new approach that simplifies these calculations and speeds them up significantly using a technique called the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm. This breakthrough reduces computation time by more than five times, potentially unlocking new horizons in modeling reactive magmatic systems.
Share