the modified quasichemical model: applications to molten salts

37
KP8108 Advanced Thermodynamics: Applications to Phase and Reaction Equilibria Project report The Modified Quasichemical Model: Applications to molten salts Written by: Kristian Etienne Einarsrud

Upload: vudien

Post on 02-Jan-2017

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Modified Quasichemical Model: Applications to molten salts

KP8108 Advanced Thermodynamics:Applications to Phase and Reaction EquilibriaProject report

The Modified Quasichemical Model:Applications to molten salts

Written by:Kristian Etienne Einarsrud

Page 2: The Modified Quasichemical Model: Applications to molten salts

Abstract

This report is written as a requirement to the course KP8108 Advanced Thermodynamics: Ap-plications to Phase and Reaction Equilibria and treats the theoretical background for the modifiedquasichemical model. The theory is derived for a binary molten salt system exhibiting strong or-dering around some composition. The quasichemical model is implemented in Matlab and is testedon a KCl-MgCl2 system, using only two free parameters to obtain satisfactory results.

Page 3: The Modified Quasichemical Model: Applications to molten salts

Contents

1 Motivation and objective 1

2 Thermodynamic basics 32.1 The thermodynamic postulates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Definitions of postulatory concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.2.1 Equations of state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2.2 Euler homogeneous functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.3 Thermodynamical potentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3.1 The extremum principle for the Gibbs potential . . . . . . . . . . . . . . . . . . 6

3 Theory of solutions 63.1 Raoultian ideal solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.1.1 Deviation from ideality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.2 Regular solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.3 Subregular solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 Modified Quasichemical Model for binary solutions 104.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.2 Derivation of the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.3 Computing properties of interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

5 Results for the KCl-MgCl2 system 155.1 Solution method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.2 Enthalpy of mixing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165.3 Activity coefficient of MgCl2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175.4 Complete model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185.5 Activity of KCl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

6 Closing remarks 23

A Equilibrium distribution 27

B Derivation of excess GFE and activity coefficient 28

C Polynomials to fit experimental data 30

D Matlab scripts 31

i

Page 4: The Modified Quasichemical Model: Applications to molten salts

1 Motivation and objective

KP8108 treats advanced topics in thermodynamics, with emphasis on theoretical issues and imple-mentation of thermodynamic theory. In addition to the theoretical part, an individual project workis required in order to pass the course. This report presents the results of this individual assignment.

According to Callen [1], “thermodynamics is the study of the restrictions on the possible propertiesof matter that follow from the symmetry properties of the fundamental laws of physics”. Furthermore,“Whether we are physicists, chemists, biologists or engineers, our primary interface with nature isthrough the properties of macroscopic matter”. Needless to say, the field of thermodynamics hasimplications and applications in all branches of modern science. However, as stated by Rubı [2],“Thermodynamics is one of the most widely misunderstood branches of physics. Laypeople andscientists alike regularly use concepts such as temperature, pressure and energy without knowing theirrigorous meaning and subtleties.” In order to clarify some of the possible misunderstandings, a briefreview of thermodynamic theory based on the postulatory formulation of Callen [1] and lecture notesfrom the course is given in the first sections of this report.

The course is taken as a part of an ongoing PhD research project, which goal is to “increase thefundamental knowledge of mass and momentum transport in the Hall-Heroult process”. The Hall-Heroult process is the main procedure for industrial production of primary aluminium and is namedafter its inventors who, independently of each other, in 1886 developed and patented an electrolyticprocess by which alumina (Al2O3) is dissolved in an electrolyte consisting mainly of liquid cryolite(Na3AlF6) (Thonstad et al. [3]). A Hall-Heroult cell is a vastly complicated system to study in aholistic manner, due to the dynamical, multiscale and -physics nature of the process. In addition, aninherent coupling between phenomena is present, adding an additional degree of complexity to theproblem. The coupling of various phenomena is shown schematically in figure 1.

Figure 1: Coupling of phenomena in Hall-Heroult cells. The figure sketches the coupling between chemical re-actions (CR), electromagnetism (EM), boundaries (BC), thermodynamics (TD) and hydrodynamics(HD) for the Hall-Heroult cell. It should be noted that diagonally opposite systems (i.e. TD-EMand CH-BC) are coupled via the Joule effect (Ohmic heating) and chemical reactions, respectively.

1

Page 5: The Modified Quasichemical Model: Applications to molten salts

As seen from figure 1, thermodynamics play a major role in the process and knowledge on thefundamental level is thus crucial for further developments. As the thermodynamic aspects of the Hall-Heroult process are exceedingly large, such a treatment is well beyond the scope of the present work.Instead, attention is given to modelling of the decoupled thermodynamic system, i.e. the electrolyticsolution.

Following the section on fundamental theory an introduction to the thermodynamic treatmentof solutions is given. The classical treatment of solutions serves as a framework for the final theorysection of the present work, namely the modified quasichemical model (MQCM). The MQCM has beenextensively used to study molten solutions, alloys and slags [4] as well complicated solutions relevantto the Hall-Heroult process [5]. The success of the MQCM has resulted in commercial softwarepackages such as FactSage [6], where the MQCM serves as a backbone for thermodynamic propertiesin applicable systems. As FactSage is widely adopted in industries relevant to the ongoing PhD, theresearch on this topic is further motivated.

Although the cryolite system (with additives) is of the primary interest for the aluminium industry,the theory given in the present work will be applied to a simpler system, KCl-MgCl2. This is dueto the fact that the behaviour of the NaF-AlF3 (cryolite) system is far from ideality (Solheim [8]),yielding some subtle modifications in the theory. The background work on the MQCM is howeversimilar, and the results of the present work are thus believed to be useful for future applications.

2

Page 6: The Modified Quasichemical Model: Applications to molten salts

2 Thermodynamic basics

Following Callen [1], thermodynamics can be expressed in a postulatory formulation. In the followingsection, the four postulates as of Callen [1] are presented, followed by a section defining the conceptsintroduced by the postulates.

2.1 The thermodynamic postulates

Postulate I. There exists states (equilibrium states) that, macroscopically, are characterized com-pletely by the specification of the internal energy U and a set of extensive parameters S,X1, X2, . . . , Xt.

Postulate II. There exists a function (the entropy, denoted by S) of extensive parameters, defined forall equilibrium states, having the following property: The values assumed by the extensive parameter inabsence of a constraint are those that maximize the entropy over the manifold of constrained equilibriumstates.

Postulate III. The entropy of a composite system is additive over constituent subsystems. Theentropy of each constituent subsystem is thus a first order function of the extensive parameters. Theentropy is continuous and differentiable and is a monotonically increasing function of energy.

Postulate IV. The entropy of any system vanishes in the state for which(∂U

∂S

)X1,X2,...

= 0.

That is, at zero temperature.

2.2 Definitions of postulatory concepts

Properties (or state variables) can either be extensive or intensive. Extensive properties (such asvolume, particle numbers and energy) scale according to the system size, whereas intensive properties(such as pressure, chemical potential and temperature) are invariant under the same scaling.

Considering postulate I for a simple system, the fundamental equation for the energy can beexpressed as

U = U(S, V,N1, . . . , Nr) = U(S, V,N), (2.1)

that is, a function of the extensive properties S (entropy), V (volume) andN1, . . . , Nr (particle numbersof the r species present). Taking the first differential of the fundamental equation one obtains

dU =(∂U

∂S

)V,N

dS +(∂U

∂V

)S,N

dV +r∑i=1

(∂U

∂Ni

)S,V,Nj 6=i

dNi. (2.2)

The partial derivatives represent the intensive properties (shown in section 2.2.2) and are defined as(∂U

∂S

)V,N

= T (Temperature) (2.3)(∂U

∂V

)S,N

= π (Negative pressure) (2.4)(∂U

∂Ni

)S,V,Nj 6=i

= µi (Chemical potential). (2.5)

3

Page 7: The Modified Quasichemical Model: Applications to molten salts

Using the above definitions, the first differential of the fundamental equation can be expressed as

dU = TdS + πdV +∑j

µjdNj . (2.6)

Noting that all terms in the above expression have units of energy, equation 2.6 can be re-written interms of the familiar first law of thermodynamics, i.e.

dU = dQ+dWm +dWc, (2.7)

where dQ represents the quasistatic heat flow, dWm and dWc represent quasistatic mechanical andchemical work, respectively.

2.2.1 Equations of state

The intensive parameters defined in the above paragraph are functions of the extensive parameters,i.e.

T = T (S, V,N) (2.8)π = π(S, V,N) (2.9)µj = µj(S, V,N). (2.10)

Such expressions, yielding the intensive parameters as functions of the extensive, are called equationsof state. Knowledge of all equation of state is equivalent to knowing the fundamental equation of thesystem (Callen [1]). As mentioned previously, intensive parameters are invariant under scaling of thesystem, that is to say, they are homogeneous of zeroth order. This is shown further in the following.

2.2.2 Euler homogeneous functions

Following Warberg [7], Euler homogeneity is defined by

Definition I. A function F is Euler homogenous of degree k in the variables x1, . . . , xn if it satisfies

F = f(X1, . . . , X2, ξn+1, . . . , ξm) = λkf(x1, . . . , x2, ξn+1, . . . , ξm) (2.11)

whereXi = λxi. (2.12)

Taking the first differential of the function f , one obtains

dF =∂f

∂XdX +

∂f

∂ξdξ =

∂f

∂Xxdλ+

∂f

∂Xλdx+

∂f

∂ξdξ = kλk−1fdλ+ λk

∂f

∂xdx+ λk

∂f

∂ξdξ, (2.13)

where the second equality follows from the first differential of X. Assuming linear independence ofthe variables, the pairs of differentials are compared.

∂f

∂Xxdλ = kλk−1fdλ

⇒ λ∂f

∂Xx = kλkf = kF

⇒ ∂f

∂XX = kF. (2.14)

4

Page 8: The Modified Quasichemical Model: Applications to molten salts

Relation 2.14 (Euler’s first theorem) yields a useful property for 1st order homogeneous functions suchas the thermodynamic potentials (described in section 2.3) and the entropy, as it yields the integralof the first differential. Considering equation 2.6, the integral is easily identified as

U = TS + πV +∑j

µjNj . (2.15)

Considering the dx differential, one obtains

∂f

∂Xλdx = λk

∂f

∂xdx

⇒ ∂f

∂X= λk−1∂f

∂x. (2.16)

In other words, differentiation with respect to (the extensive parameter) X reduces the order by one.Again considering the first order function U ,(

∂U

∂V

)S,N

= π, (2.17)

shows that the intensive parameter π is a zeroth order function.The final differential yields

∂f

∂ξ= λk

∂f

∂ξ, (2.18)

i.e., differentiation with respect to (the intensive parameter) ξ does not alter the order. Again, con-sidering U

∂U

∂T= S, (2.19)

that is, differentiation of a first order function (the energy U) with respect to a zeroth order function(the temperature T ) yields a first order function (the entropy S).

2.3 Thermodynamical potentials

In previous sections, the thermodynamic properties are derived from the fundamental relation for en-ergy. However, not all extensive properties are easy to measure or control (such as for instance entropy)and a formalism is sought where a chosen set of intensive parameters form the independent variables.This is possible by means of a Legendre transforms of the energy U , yielding the thermodynamicalpotentials.

The theory derived in future sections is based on the Gibbs-potential details are given only for thispotential in the present work. Details on the derivation of other potentials are found in textbookssuch as ([1] or [7]).

The Gibbs potential G is the Legendre transform of U , simultaneously replacing entropy by tem-perature and volume by pressure, i.e.

U = U(S, V,N), (2.20)

with the definitions∂U

∂S= T and

∂U

∂V= π (2.21)

yields the Legendre transformG = U − TS − πV, (2.22)

5

Page 9: The Modified Quasichemical Model: Applications to molten salts

elimination yieldingG = G(T, π,N). (2.23)

The first differential of 2.23 yields

dG = −SdT − V dπ +∑j

µjdNj . (2.24)

Thus, at constant temperature and pressure (conditions which are readily met), the first differential ofthe Gibbs potential reduces to a differential in particle numbers. The form of equation 2.22 suggestsan alternative form of the Gibbs potential

G = H − TS, (2.25)

where H is the enthalpy. This form of the Gibbs potential is useful for the treatment of solutions, asit yields a simple way of differing between various solution models as discussed in section 3.

2.3.1 The extremum principle for the Gibbs potential

Postulate II is formulated in an entropic basis, and requires that the entropy is maximized for someextensive parameter if the system is to be in equilibrium. The extremum principle can also be definedin Legendre transformed representations. As shown in chapter 6 in Callen [1], the Gibbs extremumprinciple can be formulated as “The equilibrium value of any unconstrained parameter in contact witha thermal and pressure reservoir minimizes the Gibbs potential at constant temperature and pressure,equal to those of the respective reservoirs”.

In other words we require(∂G

∂X1

)X2,X3,...

= 0 and(∂2G

∂X21

)X2,X3,...

≥ 0, (2.26)

in order to obtain the equilibrium distribution for the parameter X1.

3 Theory of solutions

According to Zumdahl [9], a solution is a homogeneous mixture of two or more components. Such amixture constitutes of a solute which is dissolved in a solvent. The formation of a mixture introducesa Gibbs potential of mixing, expressed as

∆G = ∆H − T∆S, (3.1)

where ∆G signifies the difference in Gibbs potential when particles are in the solution and when intheir reference state. The treatment of “mixture potentials” is what differences the various modelspresented in the following.

Solutions come in various forms, ranging from dilute solutions to molten salts and alloys. Dilutesolutions have been studied extensively, both because of practical importance and the somewhat simpleformalism arising from the idea that interactions between solute components can be disregarded. Thisapproximation is however not valid in the opposite extreme, as inter ionic forces could contributesignificantly. This is for instance the case for molten salts.

The term “Molten salt” is rather self descriptive, it is a salt which is melted. For the Hall-Heroultcell, the main salt of interest is cryolite. The melting point of pure cryolite is 1284K, above which it

6

Page 10: The Modified Quasichemical Model: Applications to molten salts

becomes liquid and thus a molten salt. The molten salt thus behaves like a fluid, but has a significantmicrostructure due to the disassociated ions constituting the melt. The thermodynamic properties ofmolten salts are somewhat more complicated than other solutions, due to the fact that there is nosolvent.

The molten salt can be visualized as an array of positively and negatively charged cations andanions, similar to that found in solid crystals, though the structure can be significantly different. Dueto the strong Coulomb repulsion between charges of same sign (and attractive if opposite) a cationwill preferably have an anion as its nearest neighbour. As discussed in Grjotheim and Kvande [10], fora compound like NaCl, the energy required to transfer an anion from its preferred site to a site whereit is surrounded by only anions requires an energy of about 800kJ, approximately 30 times larger thanthe heat of melting of the compound. It is thus reasonable to assume that there are only two kindsof positions in a molten salt, one kind for cations and one kind for anions. This tendency towardsordering differs from ideal solutions, treated in the following.

3.1 Raoultian ideal solutions

Ideal solutions are characterized by negligible interactions between particles. As shown in chapter 9in Gaskell [11], a consequence of non-interacting particles is Raoult’s law

ai = Xi, (3.2)

stating that the activity1 of the i-th component is equal to its mole fraction. The partial mixing Gibbspotential (of the i-th component) is thus given by

∆Gi = RT ln ai = RT lnXi. (3.3)

Hence, for an ideal binary A-B solution, the Gibbs energy of mixing can be expressed as

∆Gid = RT (XA lnXA +XB lnXB) . (3.4)

The assumption of non-interacting particles implies that they should be distributed randomly in thesolution. Hence, the entropy of mixing for a binary A-B solution can be expressed as

∆S′ = k(NA +NB)!NA!NB!

. (3.5)

Using Stirling’s approximation and division with the total mole number, the following expression isobtained

∆S = −R (XA lnXA +XB lnXB) . (3.6)

Comparison with equation 3.1 shows that the enthalpy of mixing, ∆H, is zero for ideal solutions.Due to the simple mathematical relations for ideal solutions, models based on this assumption

are widely used and constitute the basics for the so called Temkin activity model [13]. According toGrjotheim and Kvande [10], this formalism has proved to be very useful in approximate calculationsof thermodynamic properties of molten salts.

1The activity is defined as the ratio of the fugacity of the substance to its fugacity in its standard state. For idealsolutions this ratio reduces to a ratio in pressures.

7

Page 11: The Modified Quasichemical Model: Applications to molten salts

3.1.1 Deviation from ideality

Following Gaskell [11], a nonideal solution is one in which the activities of the components are notequal to their mole fractions. However, as substantial work has been done on ideal models, it is usefulto model nonideality as a modification of ideality. This is done by introducing the activity coefficient,defined by

γi =aiXi. (3.7)

For ideal solutions, γi is unity yielding Raoult’s law. Solutions with γi > 1 are said to have a positivedeviation from Raoult’s law, while γi < 1 signifies a negative deviation. The Gibbs energy of mixingfor a nonideal binary solution can thus be expressed as

∆G = RT (XA ln aA +XB ln aB) = RT (XA ln γA +XB ln γB +XA lnXA +XB lnXB)= ∆Gxs + ∆Gid, (3.8)

where ∆Gxs is the excess Gibbs potential, incorporating the entire nonideal behaviour. If the activitycoefficient is allowed to be temperature dependent, it is readily observed from the Gibbs-Helmholtzequation that nonzero enthalpies of mixing are possible, as

∂∆Gi/T∂T

=∂R ln γi∂T

= −∆Hi

T 2, (3.9)

where ∂R ln γi/∂T 6= 0.

3.2 Regular solutions

Hildebrand [12] defines a regular solution as one where

∆Hi 6= 0 and ∆Si = ∆Sidi = −R lnXi. (3.10)

The excess Gibbs potential is thus related to the enthalpy of mixing in a straightforward manner

∆Gxs = ∆H. (3.11)

Expanding the activity coefficient up to second order in mole fractions, Hildebrand [12] found thefollowing relation for activity coefficients in binary systems

RT ln γB = αX2A (3.12)

RT ln γA = αX2B, (3.13)

where α is a constant. Using the regular expansion model, the excess Gibbs potential (and thus theenthalpy of mixing) reduces to

∆Gxs = ∆H = αXAXB, (3.14)

where the mass balance XA + XB = 1 has been used. Equation 3.13 shows that the excess Gibbspotential and enthalpy of mixing is temperature independent for the regular model.

Regular solution models assume a random distribution of atoms even though the enthalpy of mixingis nonzero. In reality, a random solution is expected only if interactions between particles is negligibleor at so high temperatures that the entropy term overwhelms any tendency for ordering of atoms.

8

Page 12: The Modified Quasichemical Model: Applications to molten salts

3.3 Subregular solutions

The subregular model is a further extension of the regular model, allowing α to be compositiondependent and ∆Gxs to depend on temperature. Following Gaskell [11]

α = α0 + α1XB (3.15)

and

∆Gxs = (α0 + α1XB)XAXB

(1− T

τ

), (3.16)

yielding

∆Sxs =(α0 + α1XB)XAXB

τ≡ (s0 + s1XB)XAXB (3.17)

and∆H = ∆Gxs + ∆Sxs = (α0 + α1XB)XAXB ≡ (h0 + h1XB)XAXB. (3.18)

3.4 Summary

Ideal solutions are characterized by zero enthalpy of mixing and random entropy of mixing. Deviationsfrom ideality can be treated by regular or subregular expansions, writing properties of interest aspolynomials in mole fractions. Regular type models keep the random entropy of mixing but allow fornon-zero enthalpy of mixing through a power series expansion

∆H = XAXB

(h0 + h1XB + h2X

2B + . . .

). (3.19)

Subregular type models extend the regular models, allowing for non-zero excess entropy through apower series expansion

SXS = XAXB

(s0 + s1XB + s2X

2B + . . .

), (3.20)

where coefficients hi and si are related through a temperature coefficient τ . The coefficients in theexpansions are empirical and need to be determined from experiment.

As pointed out by Pelton and Blander [14], the above approaches fail for a system which ex-hibits strong structural ordering around some certain composition, even if a large number of termsare included. Pelton and Blander [14] introduce a physical model for calculation of thermodynamicproperties of ordered systems, based on the quasichemical model of Guggenheim [15]. The modifiedquasichemical model is treated in detail in the following section.

The four main approaches to the modelling of solutions are summarized in the following table

Table 1: Classifications of solution models

Model ∆SM ∆HM

Ideal Random 0Regular Random 6= 0

Subregular Non-random 6= 0Quasichemical Non-random 6= 0

9

Page 13: The Modified Quasichemical Model: Applications to molten salts

4 Modified Quasichemical Model for binary solutions

The following presentation of the Modified Quasichemical Model for binary solutions is based on thepapers by Pelton and Blander [4], [14], [16].

4.1 Introduction

As discussed in Pelton and Blander [14], the formalism based polynomial expansions has been highlysuccessful and phase diagrams and thermodynamic properties have been computed for a wide class ofsolutions using relatively few coefficients. Furthermore, the analytical representation permits for datato be inter- and extrapolated. However, a difficulty arises when a system exhibits a strong structuralordering about a certain composition. In such a system, the enthalpy of mixing tends to exhibit anegative V-shaped peak close to the composition of maximum order, whereas the entropy of mixingtends to take the shape of an M, having a minimum close to the ordered composition. These curvesare not well represented by means of polynomial expansions, even when a large number of terms areincluded. Pelton and Blander [14] thus suggest a set of equations based upon the quasichemical modelof Guggenheim [15] which accounts for the ordering in a manner which gives the required characteristicshapes of ∆HM and ∆SM .

4.2 Derivation of the model

In the modified quasichemical model for binary solutions, particles (anions) A and B are distributedon a quasilattice. Considering a particle occupying an unspecified site, its nearest neighbours can beeither A’s, B’s or a combination. In all cases, the following pair exchange reaction is considered

(AA) + (BB) 2(AB); ∆gAB, (4.1)

where (ij) represents a nearest neighbour pair.2 The above reaction thus states that an (AA) and(BB) pair can be splitted, forming two (AB) pairs, and vice versa. The Gibbs free energy associatedwith the formation of two (AB) pairs is given by ∆gAB. The magnitude and sign of ∆gAB determineswhether the formation of (AB) pairs is thermodynamically favourable or not. Large and negative valuesuggests that (AB) pairs are favourable (ordered solution), whereas clustering of (AA) and (BB) pairs(immiscible solution) occurs in the opposite case. In the limit ∆gAB → −∞ the solution tends towardsa state where only (AB) pairs are present. If ∆gAB = 0, the solution is ideal, meaning that particlesare chemically identical, having no interaction.

Denoting the number of moles of species A and B by nA and nB, respectively, and the number ofmoles of (ij) pairs by nij , the following mass balance is obtained

ZAnA = 2nAA + nAB (4.2)

ZBnB = 2nBB + nAB, (4.3)

where ZA and ZB are the coordination numbers3 of species A and B. The factor 2 arises as an niipair consists of two i particles.

The mole fraction of particle A is defined by

XA =nA

nA + nB= 1−XB. (4.4)

2The cations are assumed to be negligible in the present work, and the pair exchange is thus considered for anionnearest-neighbour pairs

3The coordination number is the total number of neighbours of a particle, i.e., each “A” particle is bonded to ZA

neighbours. In a solid, the coordination number is necessarily the same for all species.

10

Page 14: The Modified Quasichemical Model: Applications to molten salts

In addition, it is useful to introduce coordination equivalent fractions

YA =ZAnA

ZAnA + ZBnB=

ZAXA

ZAXA + ZBXB= 1− YB. (4.5)

The pair fraction Xij is defined by

Xij =nij

nAA + nBB + nAB. (4.6)

Using relations 4.2 and 4.3, the pair fraction can be re-written as

Xij =2nij

ZAnA + ZBnB, (4.7)

yielding2YA = 2XAA +XAB (4.8)

2YB = 2XBB +XAB, (4.9)

for equations 4.2 and 4.3.The Gibbs energy of mixing at a given temperature T is assumed to be given by

∆G′ =nAB

2∆gAB − T∆S′ (4.10)

where ∆S is the entropy of mixing and the factor 1/2 occurs as ∆gAB is the Gibbs free energy resultingfrom the formation of two (AB) pairs. Comparing to equation 3.1, it is observed that the first termplays the role of the enthalpy of mixing.

In order to obtain an expression for the entropy of mixing, the multiplicity of a solution containingnij moles of (ij) pairs must be determined. As shown by Pelton and Blander [14], this is equivalentto the Ising model in three dimensions. A simple model, suggested by Guggenheim [15], distributesthe pairs randomly over the lattice sites, yielding

∆S′AB = −R2

(nAA lnXAA + nBB lnXBB + nAB lnXAB) . (4.11)

The above expression however over counts the number of possible configurations (cf. Pelton et. al[4]). A correction factor is computed from the fact that if the solution where ideal, the entropycontribution from the (ij) pairs should be zero. As shown in Pelton et. al [4], the following holds foran ideal solution

XAA = Y 2A; XBB = Y 2

B; XAB = 2YAYB. (4.12)

The approximated, non-ideal, entropy of mixing is thus given by

∆S′AB = −R(nAA ln

XAA

Y 2A

+ nBB lnXBB

Y 2B

+ nAB lnXAB

2YAYB

), (4.13)

and the Gibbs energy of mixing is thus given by

∆G′ =nAB

2∆gAB +RT (nA lnXA + nB lnXB) +

+ RT

(nAA ln

XAA

Y 2A

+ nBB lnXBB

Y 2B

+ nAB lnXAB

2YAYB

). (4.14)

11

Page 15: The Modified Quasichemical Model: Applications to molten salts

It is readily observed that the ideal (Raoltian) Gibbs energy (cf. section 3.1) is obtained when ∆gAB =0, i.e.

∆G′ = RT (nA lnXA + nB lnXB) = ∆G′id. (4.15)

As discussed in section 2.3.1, the equilibrium distribution of pairs is obtained by(∂∆G′

∂nAB

)nA,nB

= 0. (4.16)

After some algebra (details provided in appendix A), the following requirement on the equilibriumdistribution is obtained

X2AB

XAAXBB= 4 exp

(−∆gAB

RT

). (4.17)

The above expression describes the “equilibrium constant” of the quasichemical reaction givenby the balance equation 4.1. For a given value of ∆gAB, the solution of equation 4.17 togetherwith equations 4.2, 4.3 and 4.6 yields the Gibbs free energy and entropy of the solution at a giventemperature. Figures 2 and 3 respectively show the enthalpy and entropy of mixing for constant valuesof ∆gAB. As seen from the figures, the sought shapes of the curves are obtained when ∆gAB is largeand negative, as expected.

Figure 2: Molar enthalpy of mixing for a AB system computed at 1273.15K with ZA = ZB = 2 and ∆gAB =-21, -42 and -85 kJ.

12

Page 16: The Modified Quasichemical Model: Applications to molten salts

Figure 3: Molar entropy of mixing for a AB system computed at 1273.15K with ZA = ZB = 2 and ∆gAB =0 (ideal solution), -21, -42 and -85 kJ.

13

Page 17: The Modified Quasichemical Model: Applications to molten salts

In order to advance further, some assumption must be made on the form of ∆gAB. FollowingPelton and Blander [14], the pair formation energy is expressed as a polynomial in the coordinationequivalent fractions, i.e.

∆gAB =∑i+j≥0

gijABYiAY

jB, i ≥ 0, j ≥ 0,

=∑k≥0

gkYkb (4.18)

where gkY kb are free parameters to be determined from experimental data. Interpreting ∆gAB as the

enthalpy of mixing, the power series of equation 4.18 corresponds to a regular like model. In principle,given the Gibbs free energy and the equilibrium distribution of bonds, other interesting properties cannow be computed. Those used in the present work are shown in the following section.

4.3 Computing properties of interest

Following the details given in appendix B, the excess GFE can be expressed as

∆G′XS =RT

2(ZAnA + ZBnB)

[YA ln

ξ − 1 + 2YA(ξ + 1)YA

+ YB lnξ − 1 + 2YB(ξ + 1)YB

]. (4.19)

The partial excess GFE is related to the activity coefficients in the solution by

∆GXSi =(∂∆G′XS

∂ni

)nj 6=ni

= RT ln γi. (4.20)

The details of deriving the partial excess GFE are given in appendix B, resulting in

RT ln γA = ∆GXSA =RT

2

[ZA ln

ξ − 1 + 2YA(ξ + 1)YA

]− 2

ZAYAY2B

ξ + 1∂∆gAB∂YB

(4.21)

RT ln γB = ∆GXSB =RT

2

[ZB ln

ξ − 1 + 2YB(ξ + 1)YB

]+ 2

ZBYBY2A

ξ + 1∂∆gAB∂YB

. (4.22)

As shown in section 3.1, the activity of the i-th component can be expressed as

RT ln ai = GXSi +RT lnXi. (4.23)

Following equation 3.18 and the details of appendix B, the enthalpy of mixing can be expressed as

∆H ′ = (ZAnA + ZBnB)YAYB1 + ξ

∆gAB. (4.24)

14

Page 18: The Modified Quasichemical Model: Applications to molten salts

5 Results for the KCl-MgCl2 system

The model presented in the preceeding section is used to model the KCl-MgCl2 system. The freeparameters are determined by curve-fitting to enthalpy of mixing (using experimental data from Kleppaand McCarty [17]) and to the activity coefficient of MgCl2 (using data from Ostvold [18] and Eganand Bracker [19]). The closed model is furthermore used to predict the activity of KCl (using datafrom Ostvold [18] and Egan and Bracker [19]). Reproduced data of the references is given in Peltonet al. [4].

5.1 Solution method

The provided data for enthalpy of mixing has a minimum close to XMgCl2 = 0.4. Transformed tocoordination equivalent fractions, the distribution should have a minimum at YA = YB = 0.5. Usingequation 4.5, the ratio of coordination numbers is found to be

ZAZB

=23. (5.1)

The coordination numbers ZA and ZB are chosen to be 4 and 6, respectively.Experimental data for ∆H and ln γMgCl2 are fitted to high order polynomials (details provided

in appendix C) in order to obtain more points to compare with the model. Given the approximateddata set, the model equations for ∆H and ln γMgCl2 are optimized using the fzero routine in matlab(details provided in appendix D). The form of the closure relation (equation 4.18) is identified bydirect experimentation, requiring that the number of free parameters was as low as possible. Themodel found yielding best results is identified as

∆gAB = g0 + g7Y7B. (5.2)

Given optimized parameters for ∆H and ln γMgCl2 , a joint set of parameters, keeping the l2 error(defined below) as low as possible, was determined by graphical analysis4. The simultaneous set ofparameters was used to predict aKCl.

The l2 error is defined as

l2 =1N

√|f2c − f2

e |, (5.3)

where fc and fe respectively represent computed and experimental values and N represents the numberof points. The l2 error thus serves as an average error estimate.

4This approach was chosen as the original idea of simultaneous fitting did not yield satisfactory results

15

Page 19: The Modified Quasichemical Model: Applications to molten salts

5.2 Enthalpy of mixing

The optimized model for the entropy of mixing (computed with help of HmixFit.m given in appendixD) is given by

∆g∆HAB = −17998− 10789Y 7

B (J/mol), (5.4)

yielding a l2 error of 21.9 J/mol.The model is compared to experimental data of Kleppa and McCarty [17] in figure 4.

Figure 4: Optimized curve for enthalpy of mixing. The red solid line shows the model with optimal parameterswhile black circles show experimental points by Kleppa and McCarty [17].

16

Page 20: The Modified Quasichemical Model: Applications to molten salts

5.3 Activity coefficient of MgCl2

The optimized model for the activity coefficient of MgCl2 (computed with help of HmixFit.m given inappendix D) is given by

∆gγAB = −19450− 14774Y 7B (J/mol), (5.5)

yielding a l2 error of 0.0123.The model is compared to experimental data of Ostvold [18] and Egan and Bracker [19] in figure

5.

Figure 5: Optimized curve for activity coefficient of MgCl2. The red solid line shows the model with optimalparameters while symbols show experimental points by Ostvold [18] and Egan and Bracker [19].

17

Page 21: The Modified Quasichemical Model: Applications to molten salts

5.4 Complete model

The simultaneous optimization of the above parameters is performed by graphical analysis of the l2error in the space spanned by the coefficients of 5.2. A typical plot is given in figure 6.

Figure 6: Typical plot of l2 error for various values of g7. Horizontal axis shows the values for g0. l2 error ofγMgCl2 is scaled by factor 1000 to ease comparison.

As seen from figure 6, the minima of the l2 error curves do not coincide, possibly explaining thefailure of the attempted simultaneous optimization of the two curves. The simultaneous parametersare thus chosen such that both l2 errors are satisfactory small. The chosen parameters yield theexpression

∆gAB = −18470− 10500Y 7B J/mol, (5.6)

yielding l2 errorsl∆H2 = 42.8 J/mol (5.7)

andlγ2 = 0.0233. (5.8)

Comparison with experimental data with the simultaneous parameters is given in figures 7 and 8.

18

Page 22: The Modified Quasichemical Model: Applications to molten salts

Figure 7: Enthalpy of mixing with simultaneous parameters. The red solid line shows the model while blackcircles show experimental points by Kleppa and McCarty [17].

Figure 8: Activity coefficient of MgCl2 with simultaneous parameters. The red solid line shows the modelwhile symbols show experimental points by Ostvold [18] and Egan and Bracker [19].

19

Page 23: The Modified Quasichemical Model: Applications to molten salts

As seen from figures 7 and 8, the overall results are in agreement with the experimental data. Theentropy of mixing is slightly under predicted while the activity coefficient is slightly over predicted.This is however expected from the dependence of g0. A marginal improvement in the predictedactivity coefficient is obtained by choosing g0 closer to the optimal value, however this modificationyields rather poor results for the predicted curve of enthalpy of mixing. This is as expected from theform of the l2 error (figure 6), growing faster for the enthalpy than for the activity coefficient. Forcomparison, curves with simultaneous parameters and optimal parameters for the activity coefficientare given in figures 9 and 10.

Figure 9: Comparison of mixing with simultaneous parameters to activity optimal parameters. The red solidline shows the model while black circles show experimental points by Kleppa and McCarty [17].

20

Page 24: The Modified Quasichemical Model: Applications to molten salts

Figure 10: Comparison of activity coefficients of MgCl2 with simultaneous parameters to activity optimalparameters. Solid lines shows the model while symbols show experimental points by Ostvold [18]and Egan and Bracker [19].

21

Page 25: The Modified Quasichemical Model: Applications to molten salts

5.5 Activity of KCl

Given the simultaneous model (equation 5.6), the activity of KCl is computed. A comparison betweenpredicted values, Raoult’s law and experimental measurements by Ostvold [18] and Egan and Bracker[19] is given in figure 11.

Figure 11: Predicted activity of KCl. The solid red line shows the predicted activity while symbols showexperimental points by Ostvold [18] and Egan and Bracker [19]. The solid blue line shows the idealRaultian behaviour.

As seen from figure 11, the predicted values for the activity of KCl are very close to experimentalpoints, with a l2 error of 7.96·10−4.

22

Page 26: The Modified Quasichemical Model: Applications to molten salts

6 Closing remarks

The present report gives an overview of the thermodynamic background for the theory of solutions.Special attention is given to the Modified Quasichemical Model for binary solutions of Pelton et al.[4]. The Modified Quasichemical Model is used to model the KCl-MgCl2 system, yielding satisfactoryresults when compared to experiments using only two free parameters. The benefit of the ModifiedQuasichemical formalism is that experimental data can be accurately reproduced using a relativelysmall set of consistent parameters. The computations needed to obtain these parameters are howeversomewhat more involved than what needed for more traditional approaches. Nevertheless, the powerof the quasichemical formalism is clear from the promising results.

The quasichemical formalism is further generalized in a series of papers by Chartrand and Pelton[20], [21] and [22], yielding more flexibility and possible applications to ternary and higher ordersystems. The advanced form of the Quasichemical model is necessary to model complicated systemsdirectly relevant for the Hall-Heroult process. This, though feasible (cf. Chartrand and Pelton [5], iswell beyond the scope of the present work.

23

Page 27: The Modified Quasichemical Model: Applications to molten salts

List of symbols

ai : Activity of component i [ ]∆G′ : Gibbs energy of mixing [J]∆G : Molar Gibbs energy of mixing [J/mol]∆gAB : Pair formation energy [J/mol]γi : Activity coefficient of component i [ ]∆H : Molar enthalpy of mixing [J/mol]ni : Mole number of component i [ ]nij : Mole number of pairs ij [ ]R : Universal gas constant [J/(mol·K)]∆S : Molar entropy of mixing [J/(mol·K)]T : Temperature [K]Xi : Mole fraction of component i [ ]Yi : Coordination equivalent mole number [ ]Zi : Coordination number of component i [ ]

24

Page 28: The Modified Quasichemical Model: Applications to molten salts

References

[1] Callen H. B., Thermodynamics and an Introduction to Thermostatistics, second edition. JohnWiley & Sons, 1985.

[2] Rubı J. M., Does Nature Break the Second Law of Thermodynamics?. Scientific American, Novem-ber 2008, pages 40-45, 2008.

[3] Thonstad J., Fellner P., Haarberg G. M., Hıveo J., Kvande H., Sterten A., Aluminium Electrolysis- Fundamentals of the Hall-Heroult Process, 3rd edition. Aluminium-Verlag, 2001.

[4] Pelton A. D., Degterov S. A., Eriksson G., Robelin C. and Dessureault Y. The Modified Quasi-chemical Model I - Binary Solutions, Metallurgical and Materials Transactions B, Volume 31, pp.651-659, 2000.

[5] Chartrand P. and Pelton A. D., A Predictive Thermodynamic model for the Al-NaF-AlF3-CaF2-Al2O3 System. Light Metals, pages 245-252, 2002.

[6] FactSage webpage: http://www.factsage.com

[7] Warberg T. H., Den termodynamiske arbeidsboken. Page 27. Kolofon Forlag AS, 2006.

[8] Solheim A., Private communication. SINTEF Materials and Chemistry, Trondheim, 2008.

[9] Zumdahl S. S., Chemical Principles, Fourth Edition. Houghton Mifflin Company, 2002.

[10] Grjotheim K. and Kvande H., Understanding the Hall-Heroult Process for Production of Alu-minium. Aluminium Verlag, 1986.

[11] Gaskell D. R. Introduction to the Thermodynamics of Materials, Fifth Edition. Taylor and Francisgroup, 2008.

[12] Hildebrand J. H., Solubility XII, Regular Solutions. Journal of American Chemical Society, Vol-ume 51, pp. 66 - 80, 1929.

[13] Temkin M., Mixtures of Fused Salts as Ionic Solutions. Acta Physicochim. URSS, Volume 20,pages 411-420, 1945.

[14] Pelton A. D. and Blander M. Thermodynamic analysis of ordered liquid solutions by a modifiedquasichemical approach - Application to silicate slags, Metallurgical and Materials TransactionsB, Volume 17, pp. 805-815, 1986.

[15] Fowler R. H. and Guggenheim E. A. Statistical Thermodynamics. Cambridge University Press,pp. 591-601, 1939.

[16] Pelton A. D. and Blander M. A Least Squares Optimization Technique for the Analysis of Ther-modynamic Data in Ordered Liquids. CALPHAD, Volume 12, pp. 97-108, 1988.

[17] Kleppa O. J. and McCarty F. G. Thermochemistry of Charge-Unsymmetrical Binary Fused HalideSystems. II. Mixtures of Magnesium Chloride with the Alkali Chlorides and with Silver Chloride,Journal of Physical Chemistry, volume 70, pp. 1249-55, 1966.

[18] Ostvold T. High Temperature Science, volume 4, pp. 51-81, 1972.

25

Page 29: The Modified Quasichemical Model: Applications to molten salts

[19] Egan J. J. and Bracker J. Thermochemistry of Charge-Unsymmetrical Binary Fused Halide Sys-tems. II. Mixtures of Magnesium Chloride with the Alkali Chlorides and with Silver Chloride,Journal of Chemical Thermodynamics, volume 6, pp. 9-16, 1974.

[20] Pelton A. D. and Chartrand P. The Modified Quasi-Chemical Model: Part II. MulticomponentSolutions. Metallurgical and Materials Transactions A, Volume 32A, pp. 1355-1360, 2001.

[21] Chartrand P. and Pelton A. D. The Modified Quasi-Chemical Model: Part III. Two Sublattices.Metallurgical and Materials Transactions A, Volume 32A, pp. 1397-1407, 2001.

[22] Pelton A. D., Chatrand P. and Eriksson G. The Modified Quasi-Chemical Model: Part IV. Two-Sublattice Quadruplet Approximation. Metallurgical and Materials Transactions A, Volume 32A,pp. 1409-1416, 2001.

26

Page 30: The Modified Quasichemical Model: Applications to molten salts

A Equilibrium distribution

The equilibrium distribution in the binary solution is obtained by setting

∂∆G′

∂nAB

∣∣∣∣nA,nB

= 0. (A.1)

The following substitutions are made in equation 4.14

nAA =ZAnA − nAB

2; nBB =

ZBnB − nAB2

(A.2)

andXAB =

2nABZAnA + ZBnB

; XAA =ZAnA − nABZAnA + ZBnB

; XBB =ZBnB − nABZAnA + ZBnB

, (A.3)

thus expressing all pair fractions as functions of nAB.Differentiation yields

0 =12

∆gAB +RT

[12nAB − ZAnAZAnA − nAB

+12nAB − ZBnBZBnB − nAB

+ 1]

+

+ RT

[ln

nAB(ZAnA + ZBnB)YAYB

− 12

lnZAnA − nAB

(ZAnA + ZBnB)Y 2A

− 12

lnZBnB − nAB

(ZBnB + ZBnB)Y 2B

].(A.4)

As the first parenthesis computes to zero, and the denominators in the second cancel, one obtains

0 =12

∆gAB +RT

2[2 lnnAB − ln (ZAnA − nAB)− ln (ZBnB − nAB)]

=12

∆gAB +RT

2[2 lnnAB − ln (4nAAnBB)] . (A.5)

Rearrangement yields

n2AB

nAAnBB= 4 exp

(−∆gAB

RT

)⇒

X2AB

XAAXBB= 4 exp

(−∆gAB

RT

). (A.6)

27

Page 31: The Modified Quasichemical Model: Applications to molten salts

B Derivation of excess GFE and activity coefficient

Considering the equation for equilibrium

X2AB

XAAXBB= 4 exp

(−∆gAB

RT

)= 4Γ, (B.1)

the denominator on the left hand side can be re-written in terms of the coordination equivalentfractions

XAAXBB =(YA −

12XAB

)(YB −

12XAB

)=

14X2AB + YAYB −

12XAB (YA + YB)

=14X2AB + YAYB −

12XAB, (B.2)

where the last equality follows from YA+YB = 1. Inserting in equation (B.1) and solving the quadraticequation for the positive root of XAB one obtains

XAB =−Γ + Γ

√1 + 4YAYB (Γ−1 − 1)

1− Γ. (B.3)

Introducingξ =

√1 + 4YAYB (Γ−1 − 1), (B.4)

one obtains

XAB =Γ (ξ − 1)

1− Γ=

4YAYB (ξ − 1)ξ2 − 1

=4YAYBξ + 1

. (B.5)

The excess Gibbs free energy is given by

∆GXS = ∆G−∆Gid. (B.6)

Substituting equation (B.5) and the mass balance constraints, one obtains

∆G′XS =RT

2(ZAnA + ZBnB)

[(YA −

2YAYB1 + ξ

)lnξ − 1 + 2YA(ξ + 1)YA

+(YB −

2YAYB1 + ξ

)lnξ − 1 + 2YB(ξ + 1)YB

]+

RT

2(ZAnA + ZBnB)

[4YAYBξ + 1

ln2

ξ + 1

]+ (ZAnA + ZBnB)

YAYBξ + 1

∆gAB

=RT

2(ZAnA + ZBnB)

[YA ln

ξ − 1 + 2YA(ξ + 1)YA

+ YB lnξ − 1 + 2YB(ξ + 1)YB

]− RT (ZAnA + ZBnB)

YAYB1 + ξ

[lnξ − 1 + 2YA(ξ + 1)YA

+ lnξ − 1 + 2YB(ξ + 1)YB

− ln4

(1 + ξ)2

]+ (ZAnA + ZBnB)

YAYB1 + ξ

∆gAB. (B.7)

As the two last terms cancel, the excess GFE is identified as

∆G′XS =RT

2(ZAnA + ZBnB)

[YA ln

ξ − 1 + 2YA(ξ + 1)YA

+ YB lnξ − 1 + 2YB(ξ + 1)YB

](B.8)

28

Page 32: The Modified Quasichemical Model: Applications to molten salts

The partial excess GFE of component i can be found by differentiation

∆GXSi =(∂∆G′XS

∂ni

)nj 6=ni

(B.9)

Noting that ξ is a function of the coordination equivalent mole fractions Yi, which again is afraction of mole numbers, the partial excess GFE of component A can be expressed as

∆GXSA =(∂∆G′XS

∂nA

)nB

=RT

2

[ZA ln

ξ − 1 + 2YA(ξ + 1)YA

]+

RT

2

[ZAnA

∂nAlnξ − 1 + 2YA(ξ + 1)YA

+ ZBnB∂

∂nAlnξ − 1 + 2YB(ξ + 1)YB

](B.10)

After some extensive algebra and repeated use of the mass balance relations, the final term can begreatly simplified, yielding the final expressions for the partial excess GFE

∆GXSA =RT

2

[ZA ln

ξ − 1 + 2YA(ξ + 1)YA

]+

(ZAnA + ZBnB)YAYBξ + 1

∂∆gAB∂nA

(B.11)

and

∆GXSB =RT

2

[ZB ln

ξ − 1 + 2YB(ξ + 1)YB

]+

(ZAnA + ZBnB)YAYBξ + 1

∂∆gAB∂nB

. (B.12)

So far, no other models have been applied other than the assumed form of the entropy. Using themodel equation for ∆gAB (equation 4.18), the derivatives can be expressed as

∂∆gAB∂nA

= − ZAYBZAnA + ZBnB

∂∆gAB∂YB

(B.13)

∂∆gAB∂nB

=ZBYA

ZAnA + ZBnB

∂∆gAB∂YB

. (B.14)

Using the above expressions, equations B.11 and B.12 reduce to

∆GXSA =RT

2

[ZA ln

ξ − 1 + 2YA(ξ + 1)YA

]−ZAYAY

2B

ξ + 1∂∆gAB∂YB

(B.15)

and

∆GXSB =RT

2

[ZB ln

ξ − 1 + 2YB(ξ + 1)YB

]+ZBYBY

2A

ξ + 1∂∆gAB∂YB

. (B.16)

29

Page 33: The Modified Quasichemical Model: Applications to molten salts

C Polynomials to fit experimental data

The experimental enthalpy of mixing is found to be best represented by means of a 7th order polynomial

∆H =7∑i=0

hiXiB, (C.1)

with coefficients

Table 2: Coefficients for polynomial representing ∆H

h0 h1 h2 h3 h4 h5 h6 h7

-1.503·106 4.956·106 -6.105·106 3.337·106 -6.901·105 5.827·104 -5.428·104 -2.655·101

The activity coefficient of MgCl2 was found to be best represented by means of a 5th order poly-nomial

log γMgCl2 =5∑i=0

giXiB, (C.2)

with coefficients

Table 3: Coefficients for polynomial representing log γMgCl2

g0 g1 g2 g3 g4 g5

-8.272·101 2.506·102 -2.808·102 1.333·102 -1.524·101 -5.135·100

30

Page 34: The Modified Quasichemical Model: Applications to molten salts

D Matlab scripts

HmixFit.m

The following script serves as the main interface for optimization

function HmixFit()%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Script for optimization of thermodynamic data for binary solutions% Written by Kristian Etienne Einarsrud 2008%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%b = MgCl2%a = KCl

%Set mole fractions for component Bxb = 0:0.01:1;xa = 1 - xb;

%Set number of molesn = 1;na = n*xa;nb = n*xb;

%Aquire enthalpy of mixing from polynomialHExp = HmixPol(xb);%Aquire activity coefficient from polynomiallngbExp = lngbPol(xb);

%Set constantsR = 8.314472;T = 1073.15; %TemperatureZa = 4; %Coordination numbersZb = 6;

%Set coordination equivalent fractionsYa = Za.*na./(Za.*na+Zb.*nb);Yb = Zb.*nb./(Za.*na+Zb.*nb);

%Set initial guessP0 = [-10000,-10000];

%Set options for fsolveoptions = optimset(’MaxIter’,50000,’MaxFunEvals’...

,75000,’TolFun’,1.0e-16,’TolX’,1.0e-16);

%OptimizePH = fsolve(@HmixOpti,P0,options,R,T,Za,Zb,Ya,Yb,HExp,xa,xb);Pg = fsolve(@lnbOpti,P,options,R,T,Zb,Ya,Yb,lngbExp);

31

Page 35: The Modified Quasichemical Model: Applications to molten salts

%Compute optimal enthalpy and activity coefficientHmix = HmixOpti(PH,R,T,Za,Zb,Ya,Yb,0,xa,xb);lngb = lnbOpti(Pg,R,T,Za,Zb,Ya,Yb,0,xa,xb);

%Compute L2-errorHerr = 1/length(Hmix)*sqrt(sum(abs((Hmix-HExp)).^2));gerr = 1/length(lngb)*sqrt(sum(abs((lngb-lngbExp)).^2));

%Store L2-error for post processingerr=[Herr,gerr];

%Plot parameters

32

Page 36: The Modified Quasichemical Model: Applications to molten salts

HmixOpti.m

The following script contains the implementation of the enthalpy of mixing.

function Hd = HmixOpti(P0,R,T,Za,Zb,Ya,Yb,Hs,xa,xb)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HmixOpti is an implementation of the enthalpy of mixing for binary% systems using the Quasichemical model.% Written by Kristian Etienne Einarsrud 2008%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Input:% P0: Parameters for model equation% R: Universal gas constant% T: Temperature% Za: Coordination number component A% Zb: Coordination number component B% Ya: Coordination equivalent mole number component A% Yb: Coordination equivalent mole number component B% Hs: Setvalue for enthalpy of mixing% xa: Mole fraction component A% xb: Mole fraction component B%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Output:% Hd: Difference between model and setvalue%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Set model equationdg = P0(1)+P0(2)*Yb.^7;%Set ksiksi = sqrt(1 + 4*Ya.*Yb.*( exp(dg./(R*T)) - 1));%Compute differenceHd = (Za*xa+Zb*xb).*Ya.*Yb./(ksi+1).*dg - He;

33

Page 37: The Modified Quasichemical Model: Applications to molten salts

lnbOpti.m

The following script contains the implementation of the activity coefficient.

function gd = lnbOpti(P0,R,T,Zb,Ya,Yb,gs)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% lnbOpti is an implementation of the activity coeffient of component B% for binary systems using the Quasichemical model.% Written by Kristian Etienne Einarsrud 2008%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Input:% P0: Parameters for model equation% R: Universal gas constant% T: Temperature% Zb: Coordination number component B% Ya: Coordination equivalent mole number component A% Yb: Coordination equivalent mole number component B% gs: Setvalue for activity coefficient%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Output:% gd: Difference between model and setvalue%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Set model equationdg = P0(1)+P0(2)*Yb.^7;%Set derivative of model equationddg = 7*P0(2)*Yb.^6;%Set ksiksi = sqrt(1 + 4*Ya.*Yb.*( exp(dg./(R*T))-1));%Compute differencegd = 0.5*(Zb*log((ksi-1+2*Yb)./((ksi+1).*Yb)))...

+ 1/(R*T)*(Zb*Yb.*Ya.^2)./(ksi+1).*ddg - gs;

34