175265085 fluid-phase-equilibria-74-1992-l-15

15
Fluid Phase Equilibria, 74 (1992) 1-15 Elsevier Science Publishers B.V., Amsterdam Calculation of Thermodynamic Equilibrium Properties. Jorgen M. Mollerup and Michael L. Michelsen. Department of Chemical Engineering. Building 229, DTH, 2800 Lyngby, Denmark. (Received October 4, 1991; accepted in final form January 27 1991) Keywords: Calculation procedure, Helmholtz surface, derived properties. ABSTRACT A formalism for calculation of equilibrium properties from a model of the Helmholtz function is presented. A modular approach which enables modification of single features of the model without rewriting the entire computer code is emphasized. The formalism ensures a fully thermodynamic consistent set of relations and leads to efficient code. Identity tests for checking calculated fugacities and their partial derivatives are presented. INTRODUCTION Calculation of thermodynamic properties from an equation of state may appear a trivial problem which only requires adherence to basic definitions. The increasing complexity of thermodynamic models, however, requires a systematic approach in order to avoid inefficient or even incorrect code, and we therefore find it appropriate to present some ideas which we have found valuable for generating modular and efficient code for calculation of thermodyna- mic properties. Our main aim is to describe a procedure which ensures that the resulting thermodynamic model is fully consistent. An additional objective is to present a formalism based on a modular approach, which enables us to modify a single feature of the model, e.g. a mixing rule for one of the model parameters, without rewriting the entire code. Finally we wish to demonstrate that the suggested approach leads to a computationally efficient code, in particular when derived properties, such as composition derivatives of fugacity coefficients, are desired. 0378-3812/92/$05.00 0 1992 Elsevier Science Publishers B.V. All rights reserved

Transcript of 175265085 fluid-phase-equilibria-74-1992-l-15

Page 1: 175265085 fluid-phase-equilibria-74-1992-l-15

Fluid Phase Equilibria, 74 (1992) 1-15 Elsevier Science Publishers B.V., Amsterdam

Calculation of Thermodynamic Equilibrium Properties.

Jorgen M. Mollerup and Michael L. Michelsen.

Department of Chemical Engineering.

Building 229, DTH, 2800 Lyngby, Denmark. (Received October 4, 1991; accepted in final form January 27 1991)

Keywords: Calculation procedure, Helmholtz surface, derived properties.

ABSTRACT

A formalism for calculation of equilibrium properties from a model of the Helmholtz function

is presented. A modular approach which enables modification of single features of the model

without rewriting the entire computer code is emphasized. The formalism ensures a fully

thermodynamic consistent set of relations and leads to efficient code. Identity tests for checking

calculated fugacities and their partial derivatives are presented.

INTRODUCTION

Calculation of thermodynamic properties from an equation of state may appear a trivial

problem which only requires adherence to basic definitions. The increasing complexity of

thermodynamic models, however, requires a systematic approach in order to avoid inefficient

or even incorrect code, and we therefore find it appropriate to present some ideas which we

have found valuable for generating modular and efficient code for calculation of thermodyna-

mic properties.

Our main aim is to describe a procedure which ensures that the resulting thermodynamic

model is fully consistent. An additional objective is to present a formalism based on a modular

approach, which enables us to modify a single feature of the model, e.g. a mixing rule for one

of the model parameters, without rewriting the entire code. Finally we wish to demonstrate

that the suggested approach leads to a computationally efficient code, in particular when

derived properties, such as composition derivatives of fugacity coefficients, are desired.

0378-3812/92/$05.00 0 1992 Elsevier Science Publishers B.V. All rights reserved

Page 2: 175265085 fluid-phase-equilibria-74-1992-l-15

2 J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (1992) l-15

THE HELMHOLTZ SURFACE AND ITS DERIVATIVES

Given an equation of state

P - WPJ) (1)

where x is the vector of mixture mole fractions, the textbook approach to calculate mixture

fugacity coefficients is by means of an integral, i.e.

(2)

where Z is the compressibility factor, Z=Pv/RT. Interchange of the order of integration and

differentiation in eqn. (2) leads to the equivalent, more convenient expression

V

RTLn9,--$/(P-F)dV-RTenz 1*

- aA ‘(T,V,n)/%, - RT &J z

where

A’(T,V,@ - -

(3)

(4)

A’ is the residual Helmholtz function, i.e. the Helmholtz function of the mixture, given as a

function of temperature T, total volume V, and the vector of mixture mole numbers II, minus

that of the equivalent ideal gas mixture at (T,V,n). R is a homogeneous function of degree 1

in the extensive variables (V,n) and, given an expression for A’, all other properties can be

derived solely by differentiation. The pressure equation itself, normally used to define the

‘equation of state’, is actually just one of these derivatives given by

pm_- a,,+? av

(5)

The expression for the residual Helmholtz energy is thus the key equation in equilibrium

thermodynamics (Michelsen 1981), where all other residual properties are calculated as partial

derivatives in the independent variables T, V, and n, as shown in Table I in the Appendix. In

Page 3: 175265085 fluid-phase-equilibria-74-1992-l-15

J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibrfa 74 (1992) 1-15 3

particular, it is important to recognize that mole numbers rather than mole fractions are the

independent variables. Derivatives with respect to mole fractions are best avoided, as they re-

quire a definition of the ‘dependent’ mole fraction and in addition lead to more complex ex-

pressions missing many important symmetry properties.

Should we wish to modify our thermodynamic model, it is far most convenient to introduce

such modifications directly in the expression for A’. Modified mixture parameters should

depend only on T, V, and n and preserve the homogeneity of A’. This approach reduces the

risk of errors and inconsistencies or misconceptions such as ‘pressure dependent interaction

coefficients’.

In addition many model concepts relate directly to the Hehnholtx function rather than to a

pressure equation. This applies for example to a corresponding states model, to a ‘chemical

model, and to a model based on statistical mechanics, where the Helmholtx function is given

directly in terms of the canonical partition function, A = - kT In Q.

Finally since the Helmholtx energy is a first order homogeneous function in the extensive

variables V and n we can from Euler’s theorem of a homogeneous function write the following

mathematical constraint

A,dT - WA, - Crt&“, - 0 i

In general we use the notation F,, for the partial derivative of the function or parameter F with

respect to the variable y keeping all other variables constant. That is

A,- a4 ( 1 aT “y- s

A,- M ( 1 av rr - - P

(7)

(9)

Equation (6) is known as the Gibbs-Duhem equation.

Page 4: 175265085 fluid-phase-equilibria-74-1992-l-15

4 J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (19%) l-15

CALKULATION OF THE DERIVATIVES OF THE HELMHOLTZ SURFACE.

When a particular mathematical model is chosen for the Hehnholtz energy derived properties

such as fugacity coefficients, enthalpy, heat capacity etc. are obtained as partial derivatives with

respect to the independent variables T, V, and n, cf. Table I in the Appendix. Although not

necessary it is somewhat more convenient to work with the reduced residual Helmholtz energy,

defined by

F-A’ RT

(10)

Normally our model provides an expression for F in terms of T, V, total moles n, and one or

more ‘mixture parameters’, a, b, . . . . e.g.,

where the mixture parameters are prescribed functions of T, V, and n. It is important to realize

that making these parameters functions of other thermodynamic properties, such as e.g. pres-

sure, converts the algebraic model into a probably intractable differential equation. In the

following we shall assume that mixture parameters are specified explicit functions of tempera-

ture, volume, and composition.

We recommend that the calculation of the derivatives of F is performed as a two-step proce-

dure. In the first step; F is differentiated with respect to its primary variables, i.e. T, V, n, and

the mixture parameters, and in the second step the derivatives of the mixture parameters are

evaluated. This results in a set of ‘model derivatives’ independent of the chosen mixing rules

and a set of ‘parameter derivatives’ which are not directly affected by the form of the chosen

model.

The partial derivatives of F needed for calculation of thermodynamic properties are:

(aF/m)v,, - FT + Fsbr + F8, (12)

(13)

(14)

Page 5: 175265085 fluid-phase-equilibria-74-1992-l-15

.I. M. Mollerup and M. L. Michelsen /Fluid Phase Equilibria 74 (I 992) I-15 5

where we use bi and a, as abbreviated notations for the composition derivatives of b and a.

The ‘model derivatives’ are thus the terms F,,, F,, Fv, Fb, and F,, and the ‘parameter derivati- ves’ are b, b,., bv and the corresponding terms for the a-parameter.

Second order derivatives are found by repeated differentiation and straightforward application of the chain rule. As an example the second composition derivatives are given by

(=) an,anj IT

- F, + F&b, + F,bu + F,,,,ai + &a,

(15)

where we have utilized the symmetry in the second order model derivatives, i.e. Fsb=F,,, etc.

Adaption of the procedures described here does not only lead to an easier and better struc- tured approach for deriving thermodynamic properties but is also very likely to provide an efficient code, in particular when derivatives of fugacity coefficients are required. An illustra- tion is given in Table II in the Appendix for the Density Dependent Local Composition Model developed by Mollerup (1983, 1985) and Math& and Copeman (1983). Additional examples can be found in Michelsen and Mollerup (1986).

An example: The Kedlich-Kwong Equation of State (Mollerup 1986)

The pressure equation is:

p_RT_- o(T) v-b v(v+b)

(16)

were v is the molar volume, and mixing rules for mixture parameters b and a are conventional- ly given by:

(17)

(18)

Page 6: 175265085 fluid-phase-equilibria-74-1992-l-15

6 J.M. Mollerup and M.L. Michelsen / Fluid Phase Equilibria 74 (1992) I-15

where xi and xj are mixture mole fractions.

First we substitute mole numbers for mole fractions and define the two new ‘molar’ mixture

parameters B and D, where

B - nb - c n,b, I

(19)

D - n*a(T) - cc nj~p~(T) i I

and substitute the total volume V for the molar volume v, yielding

P nRT D ---- V-B v(V+B)

We integrate according to equation (4) to obtain the residual Hehnholtz energy

A’(T,V,n) - nRTllL -

and F, the reduced residual Helmholtz energy

F(n,T,VWJ) - n ln v - V-B

(20)

(21)

(22)

(W

The ‘model’ derivatives needed for calculation of fugacity coefficients are thus F,, FP F,, F,

and Fn, given by

F,-lay V-B

(24)

(25)

F” - n(l V

_‘)_D(‘_1) V-B BRT V+B V

(26)

F,, _ n _ V-B

(27)

Page 7: 175265085 fluid-phase-equilibria-74-1992-l-15

J.M. Moilerup and M.L. Micheisen /Fluid Phase Equilibria 74 (1992) 1-15

Derivatives of the fugacity coefficients with respect to temperature, pressure, and composition

require the second order model derivatives F,,, F,,r, F,,,, F F F F F F nB, nD, TP TV, TB, TIM F,, Fva,

htDt Fee, FBD, and FDD- These are readily found by repeated differentiation, and it is imme-

diately evident that the terms F,,, FnT, F,,u, and Fun are identically zero.

These model derivatives of F are combined with the derivatives of the mixture parameters to

yield the derivatives required according to Table I in the Appendix, i.e.

- F,, + F,B, + F,D,

8F l-1 a@” y - F,, + FybB1 + F,D,

- (Fm + Fm Da B, + FmD, + FDDrr V

- F,(B,+B$ + F,B,B,+F,B,,+F,,(B,D,+B,D,)+F,D,,

The derivatives of the mixture parameters are

(33)

Dii - 2au (35)

(29)

(30)

(31)

(32)

(36)

Page 8: 175265085 fluid-phase-equilibria-74-1992-l-15

8 J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (1992) I-15

D, - 7 ni 7 n,@*a~l~*) (37)

and the derivatives of B,

B, - b, BU - 0 (38)

In order to improve model performance the covolume parameter b is often calculated using

a quadratic rather than a linear mixing rule, i.e.

b - CCx*Jr& (39) i i

B is in this case given by

nB - n*b (40)

and its derivatives are found from

B + nBi - 2 cnjbU I

(41)

B, + Bj + nB,, - 2bu (42)

The expressions derived above can be simplified further. The explicit temperature dependence

in the model can be removed by absorbing the RT-term in the D-parameter, defining a new

mixture parameter D’ = D/(RT). This reduces F to a function of only four independent vari-

ables V, n, B and D’.

Introduction of new mixing rules.

An alternative possibility is to introduce a new mixture parameter E, defined by

E-D_ qvj~

BBT Cnjbj j

(43)

This substitution results in simpler ‘model derivatives’ at the expense of more complicated

expressions for the derivatives of E.

Page 9: 175265085 fluid-phase-equilibria-74-1992-l-15

J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (1992) 1-15 9

As an additional example we shall consider the use of a Huron-Vidal type mixing rule for the

a-parameter (Huron and Vidal, 1979):

where g’ is a local composition based expression for the excess Gibbs energy at infinite pres-

sure. The only modifications required to utilize the derivatives derived earlier is the expressions

for the D-parameter and its composition and temperature derivatives:

It is important to realize that D is still treated as an independent parameter in the evaluation

of the model derivatives, although it formally depends on both n and B.

If desired, D is readily replaced by D’, but in the present case a formulation in terms of the

parameter E is more convenient, as it leads to simpler expressions for both the model deriva-

tives and the parameter derivatives. The mixing rule for E becomes:

E-D-C 411 1 ?lg’

BRT i n,-- - GRT RTb,

TEST OF CALCULATED FUGACITY COEFFICIENTS AND PARTIAL DERIVATIVES.

Unfortunately, even a systematic approach does not prevent coding errors, and it is important

that computer codes for calculation of fugacity coefficients and their partial derivatives are

tested for internal consistency. We have found the identities listed in Table III in the Appendix

very useful.

The analytical derivatives can always be tested by numerical evaluation of the derivatives,

preferably carried out by means of central differences, i.e.

q fin,* ,..., n, + c,..n> - finI,% ,... p, - e,..nJ

i)n,- 2s (47)

For composition derivatives e should be chosen as about l@ times the sum of moles, which

should yield results accurate to 8-10 digits. Note that the composition derivatives are homoge-

neous functions of degree -1 in the composition.

Algorithms for calculation of mgacity coefficients which, given temperature, pressure, and

composition, return only fugacity coefficients and the compressibility factor Z can be subjected

Page 10: 175265085 fluid-phase-equilibria-74-1992-l-15

10 J. M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (1992) l-15

to the test relations

and

NOTATION

A=

a

b

B

G&V C

D

E

F

G’

g’ H’

MW

“iaj

n

n

P

R

S’

V

V

XI4

x

Z

Total residual Hehnholtz energy

Mixture parameter in Cubic Equation of State

Mixture parameter (covolume) in Cubic Equation of State

Scaled b-parameter B = nb

Heat capacities for n moles

Number of components in mixture

Scaled a-parameter D = n2a

Modified mixture parameter E = D/(BRT)

Reduced residual Hehnholtz energy AT/(RT)

Total residual Gibbs Energy

Excess molar Gibbs energy expression

Total residual Enthalpy

Mixture molar weight

Molar amounts of components i and j

Total moles in mixture

Vector of total moles

Pressure

The Gas constant

Total residual Entropy

Total volume

Molar volume

Mole fractions of components i and j

Vector of mixture mole fractions

Mixture compressibility factor Z = PV/(nRT)

(48)

(49)

Page 11: 175265085 fluid-phase-equilibria-74-1992-l-15

J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (1992) l-15

SUperscriptS

11

r Residual property = real property minus ideal gas property at the same state

variables.

Greek

Joule-Thompson coefficient

Component fugacity coefficient

REFERENCES

Huron, M.J. and Vidal,J., 1979. “New mixing rules in simple equations of state for representing

vapour-liquid equilibria of strongly non-ideal mixtures”. Fluid Phase Equilibria, 3: 255-271.

Michelsen, M.L., 1981. “Partial derivatives of thermodynamic properties from equations of

state”. Department of Chemical Engineering, DTH.

Mollerup, J.M., 1983. “Correlation of thermodynamic properties using a random-mixture

reference state.” Fluid Phase Equilibria, 15: 139-154.

Math& P.M. and Copeman,T.W., 1983. “Extension of the Peng-Robinson equation of state

to complex mixtures: Evaluation of various forms of the local composition concept.” Fhrid

Phase Equilibria, 13: 91-108.

Mollerup, J.M., 1985. “Correlation of gas solubilities in water and methanol at high pressure.”

Fluid Phase Equilibria, 22: 139-154.

Michelsen, M.L. and Mollerup, J.M., 1986. “Derivatives of thermodynamic properties”. AJChE

Journal, 32: no. 8, 1389-1392.

Mollerup, J.M., 1986. “Thermodynamic properties from a cubic equation of state”. Department

of Chemical Engineering, DTH.

Page 12: 175265085 fluid-phase-equilibria-74-1992-l-15

12

APPENDIX

J.M. Molierup and M.L. Michelsen /Fluid Phase Equilibtia 74 (1992) I-IS

TABLE I Thermodynamic properties calculated as derivatives of the residual Helmholtz surface

A’(T,V,n)--

Pressure and derivatives

2 - PV7nRT

dP ( 1 P_JQ A?? dT,=-? ( 1 avar "

0)

(2)

(3)

(4)

(9

(7)

Page 13: 175265085 fluid-phase-equilibria-74-1992-l-15

J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (1992) I-15

The fugacity coefficient and derivatives

Other thermodynamic properties ’

13

(8)

(9)

(10)

(11)

(12)

(13)

04)

Page 14: 175265085 fluid-phase-equilibria-74-1992-l-15

14 J.M. Molierup and ML Michelsen /Fluid Phase Equilibria 74 (1992) 1 -IS

S’(Tg,n) - S’fzV+) + nR ln2

H’(T,P,n) ” A ‘(T,V$l) + zs’(T,Vp] + PV - MT

G ‘(TT,n) - A ‘(T,V,nj + PV - nZtT - nRT faZ

(16)

07)

(18)

(19)

TqT$,n) - RThlcp, (21)

* Since the ideal gas energy, enthalpy, and heat capacity do not depend on pressure or

volume, their residual properties are independent of whether they are calculated at

specified (n,T,P) or (n,T,V). This is not the case with the entropy, the Gibbs energy and

the Helmholtz energy since g = - 4 and -$ - $ for an ideal gas.

Page 15: 175265085 fluid-phase-equilibria-74-1992-l-15

J.M. Mollerup and M.L. Michelsen /Fluid Phase Equilibria 74 (1992) 1-15 15

TABLE II Relative computer time consumption of the DDLC model

Number of components 2 14

Calculated properties Time consumed

Mathias and Copeman, (1983); ZandPnQi 1 75

Mollerup, (1985); ZandFn$, 1 16

Z, On +,, and derivatives 1.4 32

TABLE III Identity tests of calculated fugacity coefficients and partial derivatives

i- 1,2,...,c

(2)

(3)

(4)

(5)