an efficient algorithm for calculating the heat capacity of a large-scale molecular system

6
756 An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System Chao Yang, 1 Donald W. Noid,* 2 Bobby G. Sumpter, 2 Danny C. Sorensen, 3 Robert E. Tuzun 4 1 National Energy Research Scientific Computing Center, Lawrence Berkeley National Laboratory, Berkeley, CA 94720, USA E-mail: [email protected] 2 Chemical & Analytical Sciences Division, Oak Ridge National Laboratory, Oak Ridge, TN 37831-6197, USA E-mail: [email protected]; [email protected] 3 Department of Computational & Applied Mathematics, Rice University, Houston, TX 77005, USA E-mail: [email protected] 4 Department of Computational Science, State University of New York at Brockport, Brockport, NY 14420, USA E-mail: [email protected] 1 Introduction The heat capacity of a large molecular system is defined by C v ¼ k B Z v 0 ðhxc=k B T Þ 2 e hxc=k B T ð1 e hxc=k B T Þ 2 gðxÞdx; ð1Þ where k B is Boltzmann’s constant, c is the speed of light, h is Planck’s constant, and x is the fundamental vibra- tional frequency in cm –1 . [1] The function g(x), often known as the density of states, describes the distribution of the vibrational frequencies of the particle. To be speci- fic, g(x)dx gives the number of vibrational frequencies within the interval (x,x + dx). This definition yields a (cumulative) distribution function [2] rðxÞ¼ Z x 0 gðtÞdðtÞ: ð2Þ Since molecular systems are discrete, the integration in Equation (1) shall be interpreted in the sense of Rie- mann–Stieltjes’ integral. [3] Naturally, the distribution function can be expressed by rðxÞ¼ X n i¼1 hðx x i Þ; ð3Þ where h(x) is the Heaviside function hðxÞ¼ 1 x F 0; 0 otherwise; ð4Þ and n is the total number of fundamental vibrational fre- quencies. Note that n= 3m, where m is the number of atoms within the system. It follows from the relation Full Paper: We present an efficient algorithm for com- puting the heat capacity of a large-scale molecular system. The new algorithm is based on a special Gaussian quadra- ture whose abscissas and weights are obtained by a simple Lanczos iteration. Our numerical results have indicated that this new computational scheme is quite accurate. We have also shown that this method is at least a hundred times faster than the earlier approach that is based on esti- mating the density of states and integrating with a simple quadrature formula. Macromol. Theory Simul. 2001, 10, No. 8 i WILEY-VCH Verlag GmbH, D-69451 Weinheim 2001 1022-1344/2001/0810–0756$17.50+.50/0 Macromol. Theory Simul. 2001, 10, 756–761 The distribution function for a 3 000-atom PE particle.

Upload: chao-yang

Post on 06-Jun-2016

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System

756

An Efficient Algorithm for Calculating the HeatCapacity of a Large-Scale Molecular System

Chao Yang,1 Donald W. Noid,* 2 Bobby G. Sumpter,2 Danny C. Sorensen,3 Robert E. Tuzun4

1 National Energy Research Scientific Computing Center, Lawrence Berkeley National Laboratory,Berkeley, CA 94720, USAE-mail: [email protected]

2 Chemical & Analytical Sciences Division, Oak Ridge National Laboratory, Oak Ridge, TN 37831-6197, USAE-mail: [email protected]; [email protected]

3 Department of Computational & Applied Mathematics, Rice University, Houston, TX 77005, USAE-mail: [email protected]

4 Department of Computational Science, State University of New York at Brockport, Brockport, NY 14420, USAE-mail: [email protected]

1 IntroductionThe heat capacity of a large molecular system is definedby

Cv ¼ kB

Z v

0

ðhxc=kBTÞ2eÿhxc=kBT

ð1ÿ eÿhxc=kBTÞ2gðxÞdx; ð1Þ

where kB is Boltzmann’s constant, c is the speed of light,h is Planck’s constant, and x is the fundamental vibra-tional frequency in cm–1.[1] The function g(x), oftenknown as the density of states, describes the distributionof the vibrational frequencies of the particle. To be speci-fic, g(x)dx gives the number of vibrational frequencieswithin the interval (x,x + dx). This definition yields a(cumulative) distribution function[2]

rðxÞ ¼Z x

0

gðtÞdðtÞ: ð2Þ

Since molecular systems are discrete, the integration inEquation (1) shall be interpreted in the sense of Rie-mann–Stieltjes’ integral.[3] Naturally, the distributionfunction can be expressed by

rðxÞ ¼Xn

i¼1

hðxÿ xiÞ; ð3Þ

where h(x) is the Heaviside function

hðxÞ ¼ 1 x F 0;0 otherwise;

�ð4Þ

and n is the total number of fundamental vibrational fre-quencies. Note that n = 3m, where m is the number ofatoms within the system.

It follows from the relation

Full Paper: We present an efficient algorithm for com-puting the heat capacity of a large-scale molecular system.The new algorithm is based on a special Gaussian quadra-ture whose abscissas and weights are obtained by a simpleLanczos iteration. Our numerical results have indicatedthat this new computational scheme is quite accurate. Wehave also shown that this method is at least a hundredtimes faster than the earlier approach that is based on esti-mating the density of states and integrating with a simplequadrature formula.

Macromol. Theory Simul. 2001, 10, No. 8 i WILEY-VCH Verlag GmbH, D-69451 Weinheim 2001 1022-1344/2001/0810–0756$17.50+.50/0

Macromol. Theory Simul. 2001, 10, 756–761

The distribution function for a 3000-atom PE particle.

Page 2: An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System

An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System 757

gðxÞ ¼ drðxÞdx

; ð5Þ

that g(x) is simply a sum of d-functions, i.e.,

gðxÞ ¼Xn

i¼1

dðxÿ xiÞ: ð6Þ

Clearly, the measure corresponding to the integrationin this case is the point measure {li = 1}, i = 1,2, ...,n,defined on the fundamental frequencies {xi}. It can beextended to any nonnegative point measure {li} such thatPn

i¼1li = n. Under this general definition, we have

rðxÞ ¼Xn

i¼1

lihðxÿ xiÞ; and gðxÞ ¼Xn

i¼1

li dðxÿ xiÞ: ð7Þ

For convenience, let us normalize the point measuresuch that

Pni¼1li = 1. It follows that

Z v

0

rðxÞdx ¼Xn

i¼1

lihðxÿ xiÞ ¼ 1: ð8Þ

In Figure 1, we plot the distribution function of a3000-atom polyethylene (PE) particle constructed in ear-lier studies.[4] As in our previous molecular dynamics/nor-mal mode calculations of polymer particles,[5–7] the inte-grations of the equations of motion and evaluations of theHessian matrix which requires the first and second deri-vatives of the potential energy function are carried out inCartesian coordinates, thus giving an exact definition ofthe kinetic energy and coupling. For simplicity of the PEmodel, we have collapsed the CH2 and CH3 groups into asingle particle (bead) of mass equal to 14.5 amu. Byneglecting the internal structure of those groups, we havereduced the number of equations of motion for the systemand save a significant amount of computational time. Thetotal molecular Hamiltonian is composed of the kineticand potential energy of the system. The potential energyfunction consists of harmonic oscillators for the 2- and 3-body bonded terms and an anharmonic 4-body term forthe torsion. Finally, a non-bonded two-body Lennard–Jones 6–12 interaction is included for all atoms separatedby a sequence of four atoms or more with the distance forcutting off the interaction set to 108C.

The point measure used in Figure 1 is li = 1/n fori = 1,2, ...,n. Using this measure, the heat capacity can beevaluated by

Cv ¼Xn

i¼1

HðxiÞ=n; ð9Þ

where

HðxÞ ¼ kBðhxc=kBTÞ2eÿhxc=kBT

ð1ÿ eÿhxc=kBTÞ2: ð10Þ

The summation in Equation (9) requires all fundamen-tal frequencies {xi} of the molecular system to be com-puted in advance. Since these frequencies are related tothe eigenvalues {ki} of the Hessian matrix F (second deri-vatives of the potential) by

x ¼ 108:9ffiffiffikp

; ð11Þ

the heat capacity calculation ultimately amounts to com-puting the entire spectrum of F. Note that the abovechange of variable from x to k does not alter the evalua-tion of the integrand. The integral defined by Equa-tion (1) is equivalent to

Cv ¼Z v

0

Hð108:9ffiffiffikpÞggðkÞdk; ð12Þ

where ggðkÞdk gives the number of eigenvalues within theinterval (k,k + dk).

For large-scale molecular systems consisting of hun-dreds of thousands of atoms, computing all eigenvaluesof F is very time-consuming. This difficulty leads to acommonly used approach of treating the system as a con-tinuum.[1] Under this assumption, r(x) is considered acontinuous and differentiable function (although it reallyis not). As a result, Cv can be calculated by some simplequadrature rule (e.g., the composite trapezoidal or Simp-son’s rule). A typical quadrature rule partitions the inter-val [x1, xn] uniformly into a number of small subinter-vals [n1 , n2], [n2 , n3], ..., [nm–1, nm]. The integrand is eval-uated at two or three selected points within each subinter-val; the results are then summed together following a par-ticular rule specified by the quadrature. In this approach,g(x) is no longer a sum of d-functions. Instead, it is oftenapproximated by a finite difference formula

gðxÞ ¼ rðxþ DxÞ ÿ rðxÞDx

; ð13Þ

Figure 1. The distribution function for a 3000-atom PE particle.

Page 3: An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System

758 C. Yang, D. W. Noid, B. G. Sumpter, D. C. Sorensen, R. E. Tuzun

where r(x) = |{xi |xi a x} | . The notation | N | is usedhere to denote the number of elements contained in a set{xi}. It follows from Sylvester’s inertia theorem[8] thatr(x) can be determined by decomposing the matrix F-rIinto a product of LDLT, where L is unit lower triangularand D is diagonal. The number of negative entries on thediagonal of D corresponds to r(x). Hence, the major costof this algorithm is the computation required to perform asequence of sparse LDLT factorizations. These factoriza-tions must be carried out in a numerically stable mannerusing the Bunch and Kaufman[9] technique to ensure areliable inertia count. It has been shown[10] that the com-putational procedure based on LDLT factorization andinertia count is considerably faster than the brute-forceapproach of computing all eigenvalues of F.

In this paper, we introduce another way of computingCv. The new algorithm does not rely on treating the mole-cular system as a continuum. It approximates the Rie-mann–Stieltjes integral directly by a special Gaussianquadrature. No eigenvalue of F is computed. Neitherdoes the algorithm require any sparse matrix factoriza-tion. The Gaussian quadrature rule can be computed by afew steps of a Lanczos iteration. The main computationalcost is reduced to that of a few sparse matrix vector mul-tiplications. In the next section, we review Gaussianquadrature and point out its connection with orthogonalpolynomials and the Lanczos process. In Section 4, wegive a recipe for heat capacity calculation based on a spe-cial quadrature rule provided by a Lanczos iteration. Wewill also demonstrate the efficiency and accuracy of thiscalculation.

2 Gaussian QuadratureThe theory of Gaussian quadrature[11–13] is closely relatedto the subject of orthogonal polynomials.[14] Under a par-ticular Gaussian quadrature rule defined by a set ofweights {ci} and abscissas hi , i = 1,2, ...,k, the integrationof a continuous function f (t) with respect to a nonnega-tive measure l(t) can be approximated by

Z b

a

f ðtÞlðtÞdt LXk

i¼1

f ðhiÞci: ð14Þ

Each abscissa hi is a root of a kth degree orthogonalpolynomial bk associated with the inner product p. , .Pdefined below. The coefficients ci are determined in away so that the integral is exact for all polynomials withdegree less than 2k.

For a continuous and nonnegative measure l(t), theusual choice of the inner product for generating asequence of orthogonal polynomials is

pf ; gP ¼Z b

a

f ðtÞgðtÞlðtÞdt: ð15Þ

For a discrete measure li defined on {ti}, i = 1,2, ...,n,the above integral should be interpreted in Riemann–Stieltjes’ sense, i.e.,

pf ; gP ¼Xn

i¼1

f ðtiÞgðtiÞli: ð16Þ

Orthonormal polynomials can be generated via theGram-Schmidt process or the following three-term recur-rence formula[14]

bjþ1bjþ1ðtÞ ¼ ðt ÿ ajÞbjðtÞ ÿ bjbjÿ1ðtÞ; ð17Þ

where

aj ¼ ptbjÿ1; bjÿ1P and bj ¼ ptbjÿ2; bjÿ1P: ð18Þ

It can be shown[14] that the tridiagonal Jacobi matrix

Jk ¼

a1 b2

b1 a2. .

.

. .. . .

.bkÿ1

bkÿ1 ak

0BBBB@1CCCCA ð19Þ

formed by placing ai (i = 1,2, ...,k) on the diagonal and bi

(i = 1,2 ,...,k – 1) on super- and sub-diagonals, providesthe abscissas {hi} and weights {ci} needed in Equa-tion (14). The abscissas {hi} are simply the eigenvaluesof Jk , and ci = si

2, where si is the first entry of the eigen-vector corresponding to hi . These abscissas and weightsessentially form a new distribution function

rrðxÞ ¼Xk

i¼1

cihðxÿ hiÞ; ð20Þ

that can be viewed as an approximation to Equation (3).

3 Connection with the Lanczos IterationThe process of generating orthonormal polynomials asso-ciated with a nonnegative point measure defined on thespectrum of F has a close connection with the Lanczositeration.[15] Given an arbitrary nonzero starting vector m0 ,the Lanczos process produces an orthonormal basis {mj}for the Krylov subspace

KðF; m0; kÞ ¼ spanfm0;Fm0; :::;Fkÿ1m0g: ð21Þ

These basis vectors satisfy a three-term recurrence

bjþ1mjþ1 ¼ Fmj ÿ ajmj ÿ bjmjÿ1; ð22Þ

where

aj ¼ mTj Fmj and bj ¼ mT

j Fmjÿ1; ð23Þ

Page 4: An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System

An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System 759

If we let

Vk ¼ ðm1m2:::mkÞ; fk ¼ bjmkþ1; ð24Þ

and

Tk ¼

a1 b2

b1 a2. .

.

. .. . .

.bkÿ1

bkÿ1 ak

0BBBB@1CCCCA ð25Þ

the Lanczos processes can be succinctly described by thematrix equation

FVk ¼ VkTk þ fkeTk ; ð26Þ

where ek is an elementary unit vector with one in the kth

entry and zero elsewhere.Since mj 7 K(F,m0; j), mj = bj–1(F) m0 for some j – 1st

degree polynomial bj–1. Suppose {(ki , zi)}, i = 1,2, ...,n,are eigenpairs of F and K = diag(k1, k2, ..., kn). If m0 = Zg,where

Z ¼ ðz1z2:::znÞ and g ¼ ð ffiffiffiffiffil1

p ffiffiffiffiffil2

p:::

ffiffiffiffiffiln

p ÞT ð27Þ

then

mTj mi ¼ ðbjÿ1ðFÞm0ÞTðbiÿ1ðFÞm0Þ

¼ ðbjÿ1ðFÞZgÞTðbiÿ1ðFÞZgÞ

¼ gTbjÿ1ðKÞbiÿ1ðKÞg

¼Xn

‘¼1

bjÿ1ðk‘Þbiÿ1ðk‘Þl‘: ð28Þ

The orthonormal condition

mTj mi ¼

1 i ¼ j0 otherwise

�ð29Þ

indicates that the Lanczos algorithm implicitly generatesa sequence of orthonormal polynomials {bj (k)} withrespect to the point measure {lj}. Moreover, the tridiago-nal matrix Tk that appears in Equation (26) matchesexactly with the Jacobi matrix in Equation (19).

4 Numerical ResultsThe discussion above provides the theoretical basis forthe following simple procedure that can be used toapproximate the heat capacity of a large-scale molecularsystem.1. Run a k-step (k s n) Lanczos iteration

FVk ¼ VkTk þ fkeTk ; ð30Þ

2. Compute eigenvalues hi and eigenvectors of Tk . Setci = si

2, where si is the first entry of the i th eigenvector.(The cost of this step can be further reduced by thetechnique of Golub and Welsh,[16] which does notrequire all the eigenvectors of Tk to be computed.)

3. Complete the Gaussian quadrature calculation

Cv LXk

i¼1

Hð108:9ffiffiffiffihi

pÞci: ð31Þ

A minor drawback of the above approach is that thepoint measure {li} with which the integration is carriedout is implicitly defined by the starting vector, m0 , of theLanczos iteration. It is unlikely that this vector containsequal contributions from all eigenvectors of F. Neverthe-less, when a random vector is chosen, all eigenvectors arelikely to be well represented in m0. The difference in mea-sure may lead to different numerical values of Cv . How-ever, the qualitative behavior of Cv (e.g., its variationwith respect to the temperature) can still be captured ifthe difference is negligibly small.

We applied the above procedure to PE particles of var-ious sizes. For the 3 000-atom particle, we comparedGaussian quadrature calculations with the exact integra-tion obtained by

Cv ¼Xn

i¼1

HðxiÞli: ð32Þ

In order to obtain the point measure {li}, we mustcompute all the eigenvectors {zi} of F.

If Z = ( z1z2 ... zn), then

li ¼ ðZTm0Þei: ð33Þ

In Figure 2, we compare the distribution function r(x)associated with the original integral in Equation (1) with

Figure 2. Exact and approximate distribution function for a3000-atom PE particle.

Page 5: An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System

760 C. Yang, D. W. Noid, B. G. Sumpter, D. C. Sorensen, R. E. Tuzun

the approximation constructed by a 20-point Gaussianquadrature. We notice that the approximate distribution(dotted staircase line) closely captures the main featuresof the exact distribution function (solid curve).

As shown in Figure 3, the 20-point Gaussian quadra-ture constructed for the 3000-atom PE particle givesfairly accurate approximation to Cv at a wide range oftemperatures. Notice that the difference between theexact Cv calculated from Equation (32) and the approxi-mation obtained from Equation (31) is negligible. As thenumber of atoms increases, a higher order Gaussian quad-rature is needed. However, we found that for particleswith as many as 24 000 atoms, a 100-point quadrature isquite sufficient to provide the desired accuracy.

Figure 4 illustrates the results of two 20-point Gaussianquadrature calculations associated with two differentmeasures. Both calculations were applied to the 3 000-atom PE particle used in the previous example. The solid

curve corresponds to the calculation obtained from run-ning a Lanczos iteration with m0 =

Pni¼1 zi=

ffiffiffinp

. The pointmeasure associated with this calculation is li = 1/n. Thedashed curve corresponds to a calculation obtained froma random starting vector. Clearly, the difference betweenthese two calculations is negligibly small. Both calcula-tions reveal the same variational pattern of Cv withrespect to the temperature.

As we mentioned earlier, the major cost of the quadra-ture calculation is the sparse matrix vector multiplicationused in the Lanczos process. We also used Daniel, Gragg,Kaufman and Stewart’s[17] reorthogonalizaton scheme tomake sure that the Lanczos basis vectors {mi} are fullyorthonormal. This guarantees that there is no loss of accu-racy in the abscissas and weights used in the quadratureformula. The computational cost is clearly proportional tothe number of atoms in the system and the number ofGaussian points used in the quadrature. Table 1 showscost of heat capacity calculation in terms of CPU seconds.We use pe3k, pe6k and pe12k to denote polyethylene par-ticles with 3000, 6000, and 12000 atoms, respectively.The computation is done on a single processor of IBMSP3 (200 Mhz, 4MB cache). Notice that a 100-pointGaussian quadrature calculation for pe12k took a littleover 100 seconds. This is at least a hundred times fasterthan our earlier approach[10] which took several hours.

5 ConclusionWe presented an algorithm for computing the heat capa-city of a large-scale molecular system. The algorithm isbased on a Gaussian quadrature rule specially designedfor the Riemann–Stieljes integral in Equation (1). Theabscissas and weights of the quadrature are computedfrom a Lanczos iteration. The main computational costconsists of a few sparse matrix vector multiplications.Numerical examples show that this method gives accurateresults. We have also shown that this new algorithm isconsiderably faster than earlier approaches that requireeither computing the full spectrum of the Hessian matrixor performing a sequence of LDLT factorizations.

Acknowledgement: C. Yang is supported by the Director,Office of Science, Division of Mathematical, Information, andComputational Sciences of the US Department of Energy undercontract number DE-AC03-76SF00098. This research usedresources of the National Energy Research Scientific Computing

Figure 3. Exact and approximate Cv for a 3000-atom PE parti-cle at various temperatures.

Figure 4. Approximate Cv of a 3000-atom PE particle evalu-ated with two different measures.

Table 1. The cost of heat capacity calculation.

Particle 20 Point 50 Point 100 Point

pe3k 3.5 10.9 24.5pe6k 7.4 23.1 51.9pe12k 15.3 47.8 107.7

Page 6: An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System

An Efficient Algorithm for Calculating the Heat Capacity of a Large-Scale Molecular System 761

Center, which is supported by the Office of Science of the U.S.Department of Energy. D. W. Noid and B. G. Sumpter are sup-ported by the Division of Material Sciences, Office of BasicEnergy Sciences, US Department of Energy under contract DE-AC05-00OR22725 with UT-Battelle, LLC. D. C. Sorensen issupported in part by NSF Grant CCR-9988393 and by NSFGrant ACI-0082645. R. E. Tuzun is supported by PetroleumResearch Fund administered by the American Chemical Society.

Received: February 27, 2001Revised: July 23, 2001

[1] D. A. McQuarrie, “Statistical Mechanics”, Harper & Row,New York, NY 1976.

[2] B. Fischer, “Polynomial Based Methods for Symmetric Lin-ear Systems”, Wiley & Teubner, Chichester 1996.

[3] A. Friedman, “Modern Analysis”, Dover, New York, NY1980.

[4] M. D. Barnes, K. C. Ng, K. Fukui, B. G. Sumpter, D. W.Noid, Macromolecules 1999, 32, 7183.

[5] D. W. Noid, K. Fukui, B. G. Sumpter, C. Yang, R. E.Tuzun, Chem. Phys. Lett. 2000, 316, 285.

[6] K. Fukui, B. G. Sumpter, D. W. Noid, C. Yang, R. E.Tuzun, J. Polym. Sci., Part B: 2000, 38, 1812.

[7] K. Fukui, B. G. Sumpter, D. W. Noid, C. Yang, R. E.Tuzun, J. Phys. Chem. B 2000, 104, 526.

[8] B. N. Parlett, “The Symmetric Eigenvalue Problem”,Prentice-Hall, Englewood Cliffs, NJ, 1980.

[9] J. R. Bunch, L. Kaufman, Math. Comp. 1977, 31, 162.[10] C. Yang, K. Fukui, B. G. Sumpter, D. W. Noid, R. E.

Tuzun, Macromol. Theory Simul. 2000, 9, 363.[11] W. Gautschi, in: E. B. Christoffel: The influence of his

work in mathematics and the physical sciences, P. Butzer,F. FehØr, Eds., Birkhäuser, Boston 1981, p. 72.

[12] A. H. Stroud, D. Secrest, “Gaussian Quadrature Formu-las”, Prentice Hall, Englewood Cliffs, NJ, 1966.

[13] D. Calvetti, G. H. Golub, W. B. Gragg, L. Reichel, Math.Comp. in press.

[14] G. Szegö, “Orthogonal Polynomials”, American Mathema-tical Society, Providence, RI 1975.

[15] C. Lanczos, J. Res. Natl. Bur. Stand. (U.S.) 1950, 45, 255.[16] G. H. Golub, J. H. Welsh, Math. Comp. 1969, 23, 61.[17] J. Daniel, W. B. Gragg, L. Kaufman, G. W. Stewart, Math.

Comp. 1976, 30, 772.