Skip to main content
PLOS One logoLink to PLOS One
. 2011 Sep 12;6(9):e24563. doi: 10.1371/journal.pone.0024563

An Exact Expression to Calculate the Derivatives of Position-Dependent Observables in Molecular Simulations with Flexible Constraints

Pablo Echenique 1,2,3,4,*, Claudio N Cavasotto 5, Monica De Marco 3, Pablo Garca-Risueño 1,2,3, JL Alonso 3,2,4
Editor: Darren R Flower6
PMCID: PMC3171457  PMID: 21931757

Abstract

In this work, we introduce an algorithm to compute the derivatives of physical observables along the constrained subspace when flexible constraints are imposed on the system (i.e., constraints in which the constrained coordinates are fixed to configuration-dependent values). The presented scheme is exact, it does not contain any tunable parameter, and it only requires the calculation and inversion of a sub-block of the Hessian matrix of second derivatives of the function through which the constraints are defined. We also present a practical application to the case in which the sought observables are the Euclidean coordinates of complex molecular systems, and the function whose minimization defines the flexible constraints is the potential energy. Finally, and in order to validate the method, which, as far as we are aware, is the first of its kind in the literature, we compare it to the natural and straightforward finite-differences approach in a toy system and in three molecules of biological relevance: methanol, N-methyl-acetamide and a tri-glycine peptide.

Introduction

In the theoretical and computational modeling of physical systems, including but not limited to condensed-matter materials [1], fluids [2], and biological molecules [3], it is very common to appeal to the concept of constraints. When a given quantity related to the system under study is constrained, it is not allowed to depend explicitly on time (or on any other parameter that describes the evolution of the system in the problem at hand). Instead, a constrained quantity is either set to a constant value (hard or rigid constraints) or to a function of the rest of degrees of freedom (flexible, elastic or soft constraints); in such a way that, if it depends on time, it does so through the latter and not in an explicit manner.

The imposition of constraints is useful in a wide variety of contexts in the fields of computational physics and chemistry: For example, we can use constraints to maintain an exact symmetry of the equations of motion; like in Car-Parrinello molecular dynamics (MD) [4], where the time-dependent Kohn-Sham orbitals need to be orthonormal along the time evolution of the quantum-classical system, a requirement that can be fulfilled by imposing constraints over their scalar product [5]. In a different context, we can use constraints, as in the Blue Moon Ensemble technique [6], to fix some macroscopic, representative degrees of freedom of molecular systems (normally called reaction coordinates), in order to be able to compute free energy profiles along them that would take an unfeasibly long time if we used an unconstrained simulation. Probably the most common application of the idea of constraints, and the one that will be mainly discussed in this work, appears when we fix the fastest, hardest degrees of freedom of molecular systems, such as bond lengths or bond angles, in order to allow for larger time-steps in MD simulations [7], [8].

In any of these cases (assuming that the dimensions of the spaces involved are all finite) the imposition of constraints can be described in the following way: If the state of the system is parameterized by a given set of coordinates Inline graphic, spanning the whole space, Inline graphic, and the associated momenta Inline graphic, a given constrained subspace, Inline graphic, of dimension Inline graphic, can be defined by giving a set of Inline graphic independent relations among the coordinates (In this work, we will only deal with holonomic, scleronomous constraints, i.e., those that are independent both of the momenta and (explicitly) of time.):

graphic file with name pone.0024563.e007.jpg (1)

The condition of these constraints being independent amounts to asking the set of Inline graphic vectors of Inline graphic components

graphic file with name pone.0024563.e010.jpg (2)

to be linearly independent at the relevant points Inline graphic satisfying (1), and it means that Inline graphic is a manifold of constant dimension in these points, which are called regular. Moreover, this independence condition allows, in the vicinity of each point Inline graphic and by virtue of the Implicit Function Theorem [9], [10], to (formally) solve (1) for Inline graphic of the coordinates, which we arbitrarily place at the end of Inline graphic, splitting the original set as Inline graphic, with Inline graphic and Inline graphic. Then, in the vicinity of each point Inline graphic satisfying (1), we can express the relations defining the constrained subspace, Inline graphic, parametrically by

graphic file with name pone.0024563.e021.jpg (3)

where the functions Inline graphic are the ones whose existence the Implicit Function Theorem guarantees. The coordinates Inline graphic are thus termed unconstrained and they parameterize Inline graphic, whereas the coordinates Inline graphic are called constrained and their value is determined at each point of Inline graphic according to (3). In general, the functions Inline graphic will depend on Inline graphic, and the constraints will be said to be flexible [11]. In the particular case in which all the functions Inline graphic are constant along Inline graphic, the constraints are called hard, and all the calculations are considerably simplified. In this work, we tackle the general, more involved, flexible case.

Of course, even if Inline graphic is regular in all of its points, the particular coordinates Inline graphic that can be solved need not be the same along the whole space. One of the simplest examples of this being the circle in Inline graphic, which is given by Inline graphic, an implicit expression whose gradient is non-zero for all Inline graphic. However, if we try to solve, say, for Inline graphic in the whole space Inline graphic, we will run into trouble at Inline graphic; if we try to solve for Inline graphic, we will find it to be impossible at Inline graphic. I.e., the Implicit Function Theorem does guarantee that we can solve for some of the original coordinates at each regular point of Inline graphic, but sometimes the solved coordinate has to be Inline graphic and sometimes it has to be Inline graphic. Nevertheless, we will assume this to be the case throughout this work, as is normally done in the literature [12]–[15], and thus we will consider that Inline graphic is parameterized by the same subset of coordinates Inline graphic for all of its points.

It is also worth mentioning at this point that, not only from the physical point of view all the constraints dealt with in this work are just holonomic constraints, but also the wording used to refer to the two flexible and hard sub-types is multiple in the literature. The first sub-type is called flexible in refs. [13]–[16], elastic in [17], and soft in [15]; whereas the second sub-type is called hard in refs. [15], [16], just constrained in [13], or holonomic in [17], rigid in [14], [15], and fully constrained in [15]. Some of these terms are clearly misleading (elastic, holonomic or fully constrained), and, in any case, so many names for such simple concepts is detrimental to understanding in the field.

The situation is further complicated by the fact that, when studying the statistical mechanics of constrained systems, one can think about two different models for calculating the equilibrium probability density, whose names often collide with the ones used for defining the type of constraints applied. On the one hand, one can implement the constraints by the use of very steep potentials around the constrained subspace; a model sometimes called flexible [18], [19], sometimes called stiff [12], [20]. On the other hand, one can assume the D’Alembert principle [21] and hypothesize that the forces are just the ones needed for the system to never leave the constrained subspace during its dynamical evolution; a model normally called rigid [12], [18], [19]. The two statistical mechanics models have long been recognized to present different equilibrium probability distributions [18]–[20], [22], and this is the major concern in the literature when discussing them. In refs. [11], [12], the reader can find a very detailed discussion of this issue, which we only touch here briefly for completeness.

It is worth remarking that the two types of constraints and the two types of statistical mechanics models can be independently combined; one can have either the stiff or the rigid model, with either flexible or hard constraints, hence making any interference between the two sets of words undesirable. The wording chosen is this work is, on the one hand, fairly common, and on the other hand, non-misleading.

Now, if we take any physical observable Inline graphic, depending only on the coordinates (not on the momenta), and originally defined on the whole space, Inline graphic, its restriction to Inline graphic is given by

graphic file with name pone.0024563.e049.jpg (4)

where the symbol has been deliberately changed in order to indicate that Inline graphic and Inline graphic are different functions.

The derivatives of this observable along Inline graphic are thus

graphic file with name pone.0024563.e053.jpg (5)

where we have assumed the convention that repeated indices (like Inline graphic above) indicate a sum over the relevant range, and we have omitted (as we will often do) the range of variation of the index Inline graphic.

In the case of hard constraints, i.e., when the functions Inline graphic are all constant numbers Inline graphic, the above expression reduces to

graphic file with name pone.0024563.e058.jpg (6)

where Inline graphic must be a known function of Inline graphic (in order to have a well-defined problem), and its derivative is typically easy to compute. However, if the constraints are of the more general, flexible form (the ones tackled in this work), the calculation of the partial derivatives Inline graphic cannot be avoided.

If the constraints are assumed to be flexible, it is common in the literature of molecular modeling to define these functions Inline graphic as the values taken by the coordinates Inline graphic if we minimize either the total or the potential energy with respect to all Inline graphic at fixed Inline graphic [11]–[15]. Since the energy functions used in molecular simulation are typically rather complicated, such as the ones in classical force fields, with a large number of distinct functional terms [23]–[28], or the effective nuclear potential arising from the solution of the electronic Schrödinger equation in the ground-state Born-Oppenheimer approximation [12], [29], the minimization of the energy with respect to the coordinates Inline graphic has to be performed numerically. Hence, the functions Inline graphic, which are the output of this process, do not have a compact analytical expression that can be easily differentiated to include it in eq. (5) (this is even the case in very simple toy systems; see the Results and Discussion section).

In this work, we present a parameter-free, exact algorithm (up to machine precision) to calculate the derivatives Inline graphic in such a case. Although several methods exist in the literature [13]–[15] for performing MD simulations with flexible constraints, nobody has dealt, as far as we are aware, with the computation of these derivatives. Since the general idea can be applied to any situation in which (1) we have flexible constraints, (2) that are defined in terms of the minimization of some quantity with respect to the constrained coordinates, we first introduce, the essential part of the algorithm based on these two points. Then, we develop a more sophisticated application of this idea to the calculation of the derivatives along the constrained subspace of the Euclidean coordinates of molecular systems; a problem that we faced in our group when trying to calculate the correcting terms associated to mass-metric tensor determinants that appear in the equilibrium probability density when constraints are imposed [11], [12], [30]. Finally, we perform a comparison between the results obtained with our exact algorithm and the calculation of the derivatives by finite differences; this serves the double purpose of numerically validating the algorithm and showing the limitations of the latter method, which needs the tuning of a parameter for each particular problem.

Methods

General Algorithm

As we mentioned in the Introduction, we assume that we are dealing with a constrained problem in which the functions Inline graphic in eq. (3) are defined as taking the values of the constrained coordinates Inline graphic that minimize a given function, Inline graphic, for each fixed Inline graphic, i.e.,

graphic file with name pone.0024563.e073.jpg (7)

where Inline graphic is a suitable open set in Inline graphic containing the point Inline graphic. Depending on the particular application, one can ask the minimum that defines the functions Inline graphic to be global or just local. However, in the cases in which Inline graphic is the total or the potential energy of a complex molecular system, it may become very difficult to find its global minimum (due to the shear number of dimensions of the search space), and the local choice is the only reasonable one [11].

In order to calculate the derivatives along Inline graphic of any physical observable function of the coordinates Inline graphic, like the one defined in (4), we can always follow the finite-differences approach. However, as we discuss in the Results and Discussion section, finite differences presents intrinsic inaccuracies which are difficult to overcome, specially as the system grows larger. Let us now introduce a different way to calculate Inline graphic which does not suffer from this drawback.

The starting point is eq. (5) in the Introduction, which we copy here for the comfort of the reader:

graphic file with name pone.0024563.e082.jpg (8)

As we mentioned, the expression of Inline graphic, as well as the functions Inline graphic, must be known if we wish to have a well-defined constrained problem to begin with. Therefore, the only objects that remain to be computed are the partial derivatives Inline graphic.

If we assume that we have available some method to check that the order of the stationary point is the appropriate one (i.e., that it is a minimum, and not a maximum or a saddle point), we can write a set of equations which are equivalent to eq. (7), and which (implicitly) define the functions Inline graphic:

graphic file with name pone.0024563.e087.jpg (9)

Now, we can take the derivative of this expression with respect to a given unconstrained coordinate Inline graphic:

graphic file with name pone.0024563.e089.jpg (10)

where Inline graphic, with Inline graphic, is the Hessian matrix of Inline graphic evaluated at Inline graphic, and Inline graphic is the matrix of unknowns that we want to solve for. In the whole document, we adhere to the practice of using different types of indices in order to indicate different ranges of variation. Here, for example, Inline graphic run from Inline graphic to Inline graphic; Inline graphic run from Inline graphic to Inline graphic; and Inline graphic run from Inline graphic to Inline graphic. In the next section, we need to use more types of indices, but the idea is the same.

It is worth mentioning that similar equations to the ones above can be found in classical mechanics anytime that local coordinates are used (the coordinates Inline graphic in this work). For example, the force in such a case is defined as Inline graphic and the chain rule can be used in a similar way to what we do here. Note, however, that eq. (9) does not contain derivatives with respect to Inline graphic, but to the constrained coordinate Inline graphic. This makes the approach slightly different and, indeed, eq. (10) would become trivial in the most common hard situation tackled in the literature, where Inline graphic, Inline graphic.

Since we are, by hypothesis, in a minimum of Inline graphic with respect to the constrained coordinates Inline graphic, the constrained sub-block Inline graphic of the Hessian is a positive definite matrix, and therefore invertible. Hence, if we multiply eq. (10) by its inverse, denoted by Inline graphic, sum over Inline graphic, exploit the fact that Inline graphic and Inline graphic are symmetric, and conveniently rename the indices, we arrive at:

graphic file with name pone.0024563.e117.jpg (11)

which, as promised, allows us to find the exact derivatives Inline graphic with the only knowledge of the Hessian of Inline graphic at the point Inline graphic, and, upon introduction of the result in eq. (8), also the derivatives along the constrained subspace Inline graphic of any physical observable Inline graphic.

As mentioned, several methods exist in the literature [13]–[15] to perform MD simulations with flexible constraints, however, none of them has tackled the calculation of these derivatives, which are very basic objects presumably to be needed in many future applications (see, e.g., refs. [11], [12]). Of course, it is always possible to compute derivatives using the simple and straightforward method of finite differences. In this work, we use finite differences as a way of validating the new, exact method and ensuring it is error free.

The accuracy of the new algorithm is only limited by the accuracy with which we can calculate the Hessian of Inline graphic at Inline graphic and invert it; there is no tunable parameter that we need to adjust for optimal accuracy, as in the case of finite differences (see below and also Results and Discussion). This makes a difference because, in classical force fields [26] and even in some quantum chemical methods (e.g., see chap. 10 of [31]), the Hessian can be calculated analytically, without the need of finite differences.

Although no optimization of the numerical cost has been pursued in this work, some remarks can be made about it, in comparison with the cost of the finite-differences approach. In order to calculate the partial derivatives Inline graphic with respect to the unconstrained coordinates Inline graphic using finite differences, we need to:

  1. Minimize Inline graphic at fixed Inline graphic to find Inline graphic (this step is common with the new method introduced here).

  2. Calculate Inline graphic (this step is common with the new method introduced here).

  3. Choose a displacement Inline graphic and minimize Inline graphic at the point Inline graphic, where Inline graphic if Inline graphic and Inline graphic if Inline graphic. This yields Inline graphic at a nearby point in Inline graphic with Inline graphic displaced a quantity Inline graphic and the rest of unconstrained coordinates kept the same.

  4. Calculate Inline graphic.

  5. Calculate

graphic file with name pone.0024563.e143.jpg (12)

as the finite-difference approximation to the sought derivative Inline graphic at the point Inline graphic.

Note that the third point of this finite-differences approach is essentially a linear stability analysis. When strongly non-equilibrium points are present, such as in the examples discussed in the last section, this approximation fails and the fact that the new algorithm introduced in this work uses only quantities defined at the point Inline graphic becomes even more important.

Now, assuming that we have a good enough guess for the parameter Inline graphic, the cost of this procedure is dominated by the need to perform Inline graphic minimizations of the function Inline graphic, one in each of the directions corresponding to the unconstrained coordinates Inline graphic. If we denote by Inline graphic the average number of iterations needed for these minimizations to converge, and we define Inline graphic and Inline graphic as the numerical costs (in computer time) of computing Inline graphic and its first derivatives with respect to the constrained coordinates Inline graphic, respectively, we have that the average cost of calculating the sought derivatives Inline graphic using finite differences will be Inline graphic for local optimization methods such as the steepest descent or the conjugate gradient, or Inline graphic for Monte Carlo-based methods in which the derivatives of Inline graphic are not needed, such as simulated annealing [32].

On the other hand, the new algorithm does not require the extra minimizations, but it does require the calculation of the Hessian of Inline graphic with respect to the internal coordinates (whose cost we call Inline graphic), and the computation of the inverse of its constrained sub-block, Inline graphic, applied to each one of the Inline graphic Inline graphic-vectors Inline graphic in eqs. (10) and (11), of cost Inline graphic; resulting in a total cost of Inline graphic.

The comparison between the two costs is not trivial and some remarks about it must be made: First, one must notice that the different individual costs involved, Inline graphic, Inline graphic, Inline graphic and Inline graphic, are strongly dependent on the characteristics (1) of the coordinates Inline graphic used and (2) of the function Inline graphic. For example, if the coordinates Inline graphic are the Euclidean ones and the function Inline graphic is the potential energy of a molecular system as modeled by a typical force field [23]–[28], the most direct algorithms for calculating Inline graphic and its derivatives yield costs Inline graphic, Inline graphic and Inline graphic which are of order Inline graphic, Inline graphic and Inline graphic, respectively [3]. However, if more advanced long-range techniques are used, such as the particle-particle particle-mesh (PPPM) method [33], the fast multipole method [34] or the particle-mesh Ewald summation [35], these costs can be reduced to order Inline graphic or even Inline graphic (for large Inline graphic and forgetting prefactors). Also, as mentioned, if the coordinates used are not the Euclidean ones but some internal coordinates such as the ones used in this work, these costs must change in order to account for the transformation between the two. If force fields are not used but, instead, Inline graphic is the ground-state Born-Oppenheimer energy as calculated using Hartree-Fock [29], then the most naive implementations yield costs for Inline graphic, Inline graphic and Inline graphic which are of order Inline graphic [31]. The cost, Inline graphic, of calculating the inverse of Inline graphic applied to a vector Inline graphic can range from order Inline graphic to order Inline graphic depending on the sparsity of the matrix [32], which, in turn, depends again on the coordinates used and on the structure of Inline graphic. Finally, additional qualifications may complicate the comparison, such as the architecture of the computers in which the algorithms are implemented, parallelization issues, or the fact that, e.g., if we need the Hessian for a different purpose in our simulation, such as the calculation of the corresponding correcting term that appears both in the constrained stiff model and in the Fixman potential [12], then the ‘only’ computational step we are adding is the inversion of a matrix.

Despite the complexity and problem-dependence of the cost assessment, it must be stressed that, even in the cases in which the new algorithm turns out to be more expensive than the alternatives, the fact that it is exact and parameter-free might still make it the preferred choice in problems where high accuracy is needed. Although a parameter-free structure does not guarantee higher accuracy, in this case it does, since our method can be identified as the proper limit of the finite-differences scheme when Inline graphic. This is illustrated in Results and Discussion.

It is also worth remarking that the new method, as mentioned, is not needed to perform MD simulations, which can be run without calculating any of the derivatives tackled in this work [13]–[15]. Our method is only needed when some observable in which these derivatives are included (such as the aforementioned mass-metric tensor determinants) needs to be computed. In such cases, the only two options to get to the final result are either finite differences or our method, and the most convenient of the two has to be chosen; even if its cost is a burden.

Application to Euclidean Coordinates of Molecules

In this section, we will apply the general algorithm introduced above to calculate the derivatives along the constrained subspace of the Euclidean coordinates of molecular systems in a frame of reference (FoR) fixed in the molecule. This problem has been faced by our group when trying to calculate the correcting terms associated with mass-metric tensor determinants that appear in the equilibrium probability density when flexible constraints are imposed [11], [12], [30]. More specifically, these derivatives are needed to calculate the determinant of the induced mass-metric tensor Inline graphic that appears in the constrained rigid model, according to the formulae derived in ref. [30].

In such a case, the system of interest is a set of Inline graphic mass points termed atoms. The three Euclidean coordinates of atom Inline graphic in a FoR fixed in the laboratory are denoted by Inline graphic, and its mass by Inline graphic, with Inline graphic. However, when no explicit mention to the atom index needs to be made, we will use Inline graphic to denote the Inline graphic-tuple of all the Inline graphic Euclidean coordinates of the system. The masses Inline graphic-tuple, Inline graphic, in such a case, is formed by consecutive groups of three identical masses, corresponding to each of the atoms.

Apart from the Euclidean coordinates, one can also use a given set of curvilinear coordinates (also called sometimes general or generalized), denoted by Inline graphic, to describe the system. Both the coordinates Inline graphic and Inline graphic parameterize the whole space Inline graphic, and the transformation between the two sets and its inverse are respectively given by

graphic file with name pone.0024563.e213.jpg (13a)
graphic file with name pone.0024563.e214.jpg (13b)

We will additionally assume that, for the points of interest, this is a proper change of coordinates, i.e., that the Jacobian matrix

graphic file with name pone.0024563.e215.jpg (14)

has non-zero determinant.

Now, we define a particular FoR fixed in the system to perform some of the calculations. To this end, we select three atoms (denoted by 1, 2 and 3) in such a way that Inline graphic, the position in the FoR of the laboratory of the origin of the FoR fixed in the system, is the Euclidean position of atom 1 (i.e., Inline graphic). The orientation of the FoR Inline graphic fixed in the system is chosen such that atom 2 lies in the positive half of the Inline graphic-axis, and atom 3 is contained in the Inline graphic-plane, with projection on the positive half of the Inline graphic-axis (see fig. 1). The position of any given atom Inline graphic in the new FoR fixed in the system is denoted by Inline graphic. Also, let Inline graphic be the Euler rotation matrix (in the ZYZ convention) that takes a free 3-vector of primed components, Inline graphic, to the FoR fixed in the laboratory, i.e., Inline graphic [21].

Figure 1. Definition of the frame of reference fixed in the system.

Figure 1

Although the aforementioned curvilinear coordinates Inline graphic are a priori general, it is very common to take into account the fact that the typical potential energy functions of molecular systems in absence of external fields do not depend on Inline graphic nor on the angles Inline graphic, and to consequently choose a set of curvilinear coordinates split into Inline graphic, where the first six are these external coordinates, Inline graphic. As we mentioned before, Inline graphic describes the overall position of the system with respect to the FoR fixed in the laboratory, and its overall orientation is specified by the angles Inline graphic. The remaining Inline graphic coordinates Inline graphic are called internal coordinates and determine the positions of the atoms in the FoR fixed in the system [36], [37]. They parameterize what we shall call the internal subspace or conformational space, denoted by Inline graphic, and the coordinates Inline graphic parameterize the external subspace, denoted by Inline graphic; consequently splitting the whole space as Inline graphic (denoting by Inline graphic the Cartesian product of sets).

The position, Inline graphic, of any given atom Inline graphic in the axes fixed in the system is a function, Inline graphic, of only the internal coordinates, Inline graphic, and the transformation from the Euclidean coordinates Inline graphic to the curvilinear coordinates Inline graphic in (13) may be written more explicitly as follows:

graphic file with name pone.0024563.e247.jpg (15)

Although general constraints affecting all the coordinates Inline graphic [like those in (1)] can be imposed on the system, the already mentioned property of invariance of the potential energy function under changes of the external coordinates, Inline graphic, together with the fact that the potential energy can be regarded as ‘producing’ the constraints [12], make physically frequent the use of constraints involving only the internal coordinates, Inline graphic:

graphic file with name pone.0024563.e251.jpg (16)

Under the common assumptions in the Introduction, these constraints allow us to split the internal coordinates as Inline graphic, where the first Inline graphic ones, Inline graphic, are called unconstrained internal coordinates and parameterize the internal constrained subspace, denoted by Inline graphic. The last Inline graphic ones, Inline graphic, correspond to the constrained coordinates in the Introduction and are called. The external coordinates, Inline graphic, together with the unconstrained internal coordinates, Inline graphic, constitute the set of all unconstrained coordinates of the system, Inline graphic, which parameterize the constrained subspace Inline graphic, being Inline graphic.

In this situation, the constraints in eq. (16) are equivalent to

graphic file with name pone.0024563.e263.jpg (17)

and the functions Inline graphic are defined as taking the values of the coordinates Inline graphic that minimize the potential energy with respect to all Inline graphic at fixed Inline graphic [11], [12], [15].

Finally, if these constraints are used, together with (16), the Euclidean position of any atom in the constrained case may be parameterized with the set of all unconstrained coordinates, Inline graphic, as follows:

graphic file with name pone.0024563.e269.jpg (18)

where the name of the transformation functions has been changed from Inline graphic to Inline graphic, and from Inline graphic to Inline graphic, in order to emphasize that the dependence on the coordinates is different between the two cases.

In order to calculate the derivatives along Inline graphic of the primed atoms positions, Inline graphic, with respect to the unconstrained internal coordinates Inline graphic (needed, for example, in eq. (28) of ref. [30] to compute the determinant of the induced mass-metric tensor Inline graphic), we first differentiate with respect to Inline graphic in Inline graphic, arriving to the analogue to eq. (8):

graphic file with name pone.0024563.e280.jpg (19)

Now, the derivatives Inline graphic can be calculated using the general algorithm introduced in the previous section simply noticing that, in this case, Inline graphic is precisely the potential energy of the system. Therefore, the only objects that remain to be computed are the derivatives Inline graphic and Inline graphic, which can be known analytically (they are geometrical [or kinematical] objects, i.e., they do not depend of the potential energy). We now turn to the derivation of an explicit algorithm for finding them and thus completing the calculation that is the objective of this section.

In the supplementary material of ref. [30], we give a detailed and explicit way for expressing any ‘primed’ vector Inline graphic as a function of all the internal coordinates, in the particular coordination scheme known as SASMIC [37]. We could take the final expression there [eq. (5)] and explicitly perform the partial derivatives, however, we shall follow a different approach that is both more straightforward and applicable to a larger family of Z-matrix-like schemes for defining internal coordinates.

In non-redundant internal coordinates schemes, whether they are defined as in ref. [37] or not, each atom is commonly regarded as being incrementally added to the growing molecule for its coordination. This means that the position of the Inline graphic-th atom in the body-fixed axes is uniquely specified by the values of three internal coordinates that are defined with respect to the positions of three other atoms with indices Inline graphic. This is a very convenient practice, and we will assume that we are dealing with a scheme that adheres to it.

Normally, the first of the three internal coordinates used to position atom Inline graphic is the length of the vector joining Inline graphic and Inline graphic. Atom Inline graphic is commonly chosen to be covalently attached to Inline graphic and, then, the length of this vector is naturally termed bond length, and denoted by Inline graphic. A given function Inline graphic embodies the protocol used for defining this atom, Inline graphic, to which each ‘new’ atom Inline graphic is (mathematically) attached; a superindex, as in Inline graphic, indicates composition of functions, and the iteration of such compositions allows us to trace a single-branched chain of atoms that takes from atom Inline graphic to atom 1, at the origin of the ‘primed’ axes. If Inline graphic is a number such that Inline graphic, this chain is given by the following set:

graphic file with name pone.0024563.e301.jpg (20)

It is clear that, if we now change a given bond length Inline graphic associated to atom Inline graphic, atom Inline graphic will move if Inline graphic; simply because atom Inline graphic will move and Inline graphic has been positioned in reference to atom Inline graphic’s position. Thus, if we define

graphic file with name pone.0024563.e309.jpg (21)

for any Inline graphic, Inline graphic, and accordingly denote by Inline graphic the unitary vector in the ‘primed’ FoR that points from atom Inline graphic to atom Inline graphic, a change in the bond length associated to Inline graphic from Inline graphic to Inline graphic (while keeping the rest of the internal coordinates constant) will translate all atoms Inline graphic such that Inline graphic a distance Inline graphic along Inline graphic, having

graphic file with name pone.0024563.e322.jpg (22)

and hence

graphic file with name pone.0024563.e323.jpg (23)

The second internal coordinate, after Inline graphic, that is typically defined to position atom Inline graphic with respect to the ‘already positioned’ part of the molecule is a so-called bond angle Inline graphic. To define this angle, we need an additional atom associated with Inline graphic, which we could denote by Inline graphic. Although one can in principle think of the possibility of using different atoms Inline graphic and Inline graphic to define the bond angle than the one used to define the bond length, the common practice in the literature is to use the same three atoms Inline graphic, Inline graphic and Inline graphic, to define the three internal coordinates associated to Inline graphic. This is also the choice in the SASMIC scheme and the one in this work. The angle Inline graphic is thus defined as 180Inline graphic minus the angle formed between the vectors Inline graphic and Inline graphic (see fig. 2).

Figure 2. Rotation associated to a change in a bond angle.

Figure 2

Definition of the bond angle Inline graphic, associated to atom Inline graphic, and the unitary vector Inline graphic corresponding to the direction around which all atoms Inline graphic with chains Inline graphic containing Inline graphic rotate if Inline graphic is varied while the rest of internal coordinates are kept constant.

Now, the reasoning is the same as in the case of the derivative with respect to Inline graphic: For every atom Inline graphic that is the ‘tip’ of the bond angle Inline graphic, the changes in this angle (keeping the rest of internal coordinates constant) will move atom Inline graphic and therefore all atoms Inline graphic that contain atom Inline graphic in the chain Inline graphic that links them to atom 1.

If we now look at fig. 2, we see that a change from Inline graphic to Inline graphic amounts to rotate all atoms Inline graphic that contain Inline graphic in their chain to the origin an angle Inline graphic around the unitary vector Inline graphic, which is defined by

graphic file with name pone.0024563.e359.jpg (24)

The result, Inline graphic, of rotating a vector Inline graphic around the direction given by the unitary vector Inline graphic an amount Inline graphic is given by the well-known Rodrigues’ rotation formula [21], [38]:

graphic file with name pone.0024563.e364.jpg (25)

However, notice that, in order to define a rotation, it is not enough to specify the angle Inline graphic and the rotation axis Inline graphic, but one additionally needs to specify a fixed point (which can actually be any of the points in a fixed line in the direction of Inline graphic). Therefore, the above expression is only correct for either ‘free’ vectors Inline graphic (i.e., those that are not associated to a given point in space), or for vectors Inline graphic whose starting point lies in the aforementioned fixed line.

The fixed point for the rotation we are interested in can be chosen to be Inline graphic and, using eq. (25), we have that

graphic file with name pone.0024563.e371.jpg (26)

Then, keeping the terms up to first order in Inline graphic, we can easily compute the derivative:

graphic file with name pone.0024563.e373.jpg (27)

which, since a variation of Inline graphic does not move atom Inline graphic (i.e. Inline graphic), allows us to conclude that

graphic file with name pone.0024563.e377.jpg (28)

if Inline graphic.

The third and last internal coordinate that is usually defined to position atom Inline graphic is a so-called dihedral angle Inline graphic. To define this angle, we need a third atom associated with Inline graphic, which we could denote by Inline graphic. The angle Inline graphic is thus defined as the oriented angle formed between the plane containing atoms Inline graphic, Inline graphic and Inline graphic and the plane containing atoms Inline graphic, Inline graphic and Inline graphic. The positive sense of Inline graphic is the one indicated in fig. 3, and, although it is common to find two different covalent arrangements of the four atoms Inline graphic, Inline graphic, Inline graphic and Inline graphic, termed principal and phase dihedral angles, respectively [37], this does not affect the mathematical definition of Inline graphic given in this paragraph, nor the subsequent calculations.

Figure 3. Rotation associated to a change in a dihedral angle.

Figure 3

Definition of the dihedral angle Inline graphic, associated to atom Inline graphic. The positive sense of rotation is indicated in the figure, and we can distinguish between two situations regarding covalent connectivity: a) principal dihedral angle, and b) phase dihedral angle (see ref. [37]).

Regarding the derivative of the ‘primed’ position of atom Inline graphic with respect to a given Inline graphic, the only difference with the bond angle case is that, now, the rotation is performed around the direction given by the unitary vector Inline graphic (see fig. 3). The fixed point can be again chosen as Inline graphic, and eq. (27) (changing Inline graphic by Inline graphic and Inline graphic by Inline graphic), as well as the fact that changes in Inline graphic do not move atom Inline graphic, still hold. Therefore,

graphic file with name pone.0024563.e408.jpg (29)

if Inline graphic.

In order to decide whether or not atom Inline graphic will move upon changes in internal coordinates associated to atoms Inline graphic that do not belong to Inline graphic we must first finish the story about internal coordinates definition. Since the argument above to show that Inline graphic moved when Inline graphic was that Inline graphic itself moved and it was used to position Inline graphic, we must ask

  1. whether or not there can be atoms that are also used to position Inline graphic but that do not belong to Inline graphic, and

  2. what happens when we change the internal coordinates associated to them.

The answers to these two questions depend on the particular scheme used to define the internal coordinates, and we will tackle them referring to the SASMIC scheme [37], which is the one used in this work: According to the SASMIC rules, there are only two situations in which an atom Inline graphic can be used to position atom Inline graphic, and they are depicted in fig. 4.

Figure 4. Special cases.

Figure 4

Special cases of atoms that do not belong to the chain Inline graphic connecting Inline graphic to atom 1, but that are nevertheless used to position Inline graphic.

The first case, in fig. 4a, attains only the first atoms of the molecule. Typically, atom 1 is not a first-row atom, but a hydrogen (such is the case of the three molecules studied, for example, in Results and Discussion). Hence, after positioning atoms 2 and 3, which are typically first-row, it is more representative to choose atom 3 as Inline graphic and atom 1 as Inline graphic when positioning the rest of the atoms Inline graphic attached to atom 2. This makes Inline graphic and hence Inline graphic qualifies as an atom that is used to position Inline graphic but which is not included in the chain Inline graphic.

The second case, in fig. 4b, corresponds to the situation in which the molecule divides in two branches, and it can happen all along its chemical structure. If atom Inline graphic is the atom that defines the only principal dihedral over the bond connecting Inline graphic and Inline graphic (in the SASMIC scheme, only one principal dihedral can be defined on a given bond [37]), and atom Inline graphic belongs to a different branch than the one beginning in Inline graphic (the branches are indicated with grey broad arrows), then the starting atom Inline graphic of the branch to which Inline graphic belongs (Inline graphic can be Inline graphic itself) must be positioned using a phase dihedral in which Inline graphic. Thus, Inline graphic is an atom that is used to position Inline graphic, but which does not belong to the chain Inline graphic connecting Inline graphic to atom 1.

In principle, any change in the internal coordinates of atom Inline graphic, in the first case, or in those of atom Inline graphic, in the second case, may move atom Inline graphic, however, due to the geometrical characteristics of the internal coordinates, this is not the case.

For example, it is easy to see that, in the case depicted in fig. 4a, a variation of the bond length Inline graphic (denoting Inline graphic) does not move atom Inline graphic. Regarding the angles, the dihedral Inline graphic is not defined because Inline graphic, and a change in Inline graphic can be seen to rotate atom Inline graphic with fixed point Inline graphic and around the axis given exactly by Inline graphic as defined in eq. (24). (It is not trivial to see that this motion keeps all the rest of internal coordinates constant, specially the phase dihedral Inline graphic. The authors found it helpful to imagine that atoms 1, 2 and 3 lie in the plane of the paper, with Inline graphic and Inline graphic coming out of it towards the reader; the first orthogonally and the second not.) Therefore, the derivative of the Euclidean position of atom Inline graphic with respect to Inline graphic is also given by eq. (28) in this special case.

In the situation shown in fig. 4b, one can see that neither a change in Inline graphic nor in Inline graphic move atom Inline graphic nor Inline graphic. However, if we change Inline graphic, we need to move atom Inline graphic if we want to keep Inline graphic constant. Therefore, atom Inline graphic moves in such a case and it does so by rotating with the same fixed point Inline graphic and the same axis Inline graphic as in the simpler cases depicted in fig. 3. This means that, again, we can calculate the sought derivative using the already justified eq. (29).

In summary, only changes in bond lengths associated to atoms Inline graphic affect the position of atom Inline graphic:

graphic file with name pone.0024563.e474.jpg (30)

changes both in bond angles associated to atoms Inline graphic and to Inline graphic in fig. 4a affect the position of atom Inline graphic:

graphic file with name pone.0024563.e478.jpg (31)

and changes both in dihedral angles associated to atoms Inline graphic and to those that define the principal dihedral at a branching point that leads to atom Inline graphic (see fig. 4b) can affect the position of atom Inline graphic:

graphic file with name pone.0024563.e482.jpg (32)

Finally, the outline of the algorithm for calculating the sought derivatives Inline graphic along the constrained subspace Inline graphic is:

  1. Calculate the chain Inline graphic that connects atom Inline graphic with atom 1 and identify the special cases depicted in fig. 4.

  2. Calculate the derivatives Inline graphic by solving the system of linear equations in (11).

  3. Calculate the geometric derivatives Inline graphic and Inline graphic, for Inline graphic, using eqs. (30), (31) and (32).

  4. Plug all the calculated quantities into eq. (19) et voilà.

Results and Discussion

In this section, we compare the finite-differences approach (see Methods) to the new algorithm introduced in this work with two objectives in mind: the validation of the new scheme, and the identification of the most important pitfalls of the finite-differences technique, which are absent in the new method. It is worth stressing again that the method presented here is the first of its kind, as far as we are aware, and the finite-differences scheme is just a very natural and straightforward method that is always available when derivatives need to be calculated. In fact, the pitfalls of finite differences which we highlight in this section are very well known, although they have been seldomly presented in the context of molecular force fields. We hope that this section can be additionally useful to revisit this classical topic from a new angle.

To these two ends, we have applied the more specific algorithm introduced in the previous section for the calculation of the derivatives of the Euclidean coordinates of molecular systems to the three biological species in fig. 5: methanol, N-methyl-acetamide (abbreviated NMA), and the tripeptide N-acetyl-glycyl-glycyl-glycyl-amide (abbreviated GLY3). For each one of these molecules, a number of dihedral angles describing rotations around single bonds (and indicated with light-blue arrows in fig. 5) have been chosen as the unconstrained internal coordinates, Inline graphic, spanning the corresponding constrained internal subspace Inline graphic. The rest of internal coordinates Inline graphic (bond lengths, bond angles, phase dihedrals, and principal dihedrals over non-single bonds) are flexibly constrained as described in the previous sections. The numeration of the atoms and the definition of the internal coordinates follow the SASMIC scheme, which is specially adapted to deal with constrained molecular systems [37].

Figure 5. Molecules used in the numerical calculations in this section.

Figure 5

(a) Methanol, (b) N-methyl-acetamide (abbreviated NMA), and (c) the tripeptide N-acetyl-glycyl-glycyl-glycyl-amide (abbreviated GLY3). Hydrogens are conventionally white, carbons are grey, nitrogens blue and oxygens red. The unconstrained dihedral angles that span the corresponding spaces Inline graphic are indicated with light-blue arrows, and some internal coordinates and some atoms that appear in the discussion are specifically labeled. The constrained dihedral angle Inline graphic is indicated by a red arrow in GLY3.

For methanol and NMA, due to the small dimensionality of their constrained subspaces, the working sets of conformations have been generated by systematically scanning their unconstrained internal coordinates at finite steps. For methanol, we produced 19 conformations, in which the central dihedral, Inline graphic, ranges from Inline graphic to Inline graphic in steps of Inline graphic. Similarly, the systematic scanning of the unconstrained dihedrals in NMA produced a set of 588 conformations in which the first and last angles, Inline graphic and Inline graphic, range from Inline graphic to Inline graphic, and the central one, Inline graphic, ranges from Inline graphic to Inline graphic, all in steps of Inline graphic. For GLY3, and in view of the dimensionality of its constrained subspace, 1368 conformations were generated through a Monte Carlo with minimization procedure.

At each one of these conformations, defined by the value of the unconstrained internal coordinates Inline graphic, the constrained coordinates Inline graphic were found by minimizing the potential energy Inline graphic at fixed Inline graphic, thus enforcing the constraints Inline graphic described in Methods. Let us remark that this fixing of the coordinates Inline graphic is just an algorithmic way of sampling the constrained subspace defined by the relations Inline graphic, and it does not imply that the coordinates Inline graphic are constrained; indeed, they could take any value in the set of conformations, whereas the constrained coordinates Inline graphic are fixed by the aforementioned relations. The potential energy and force-field parameters were taken from the AMBER 96 parameterization [39], [40], and local energy minimization with respect to the constrained coordinates was performed with Gaussian 03 [41]. At the minimized points, the Euclidean coordinates, Inline graphic, of all atoms in the system-fixed axes defined in the Methods section were also computed.

In order to find the partial derivatives Inline graphic at the generated points by finite differences, we produced, for each conformation in the working sets, Inline graphic additional conformations, each one with a single coordinate Inline graphic displaced to Inline graphic. After the re-minimization of the constrained coordinates at the new points, we were in possession of all the data needed to compute the estimate of the sought derivative in eq. (12) for all unconstrained coordinates. In order to assess the behaviour and accuracy of the finite-differences approach, we performed these calculations for the values Inline graphic.

On the other hand, to calculate the derivatives Inline graphic using the new scheme introduced in Methods, we do not need to perform any additional minimization, but we need to know the Hessian matrix of the second derivatives of Inline graphic with respect to the internal coordinates. The Hessian in internal coordinates was calculated with the Gaussian 03 package [41].

In order to compare the two methods, we turn first to the smallest system: methanol. In fig. 6a, we can see the value of the derivative Inline graphic of the Inline graphic-coordinate (in the ‘primed’ axes, but we drop the prime from now on) of hydrogen number 5 (see fig. 5) with respect to the unconstrained dihedral angle Inline graphic that describes the rotation of the alcohol group with respect to the methyl one. We can see that the agreement between the new algorithm and the finite-differences approach is good but not perfect, and that the discrepancy between the two is larger for the smallest (Inline graphic) and largest (Inline graphic) values of Inline graphic depicted in the graph.

Figure 6. Derivatives of some selected coordinates of methanol.

Figure 6

Derivatives of (a) the Inline graphic coordinate of atom 5 in methanol, (b) the bond length Inline graphic associated to it, (c) the bond angle Inline graphic, and (d) the dihedral angle Inline graphic as a function of the unconstrained coordinate Inline graphic. Both the results of the new algorithm and those obtained by finite differences (FD) are depicted. The key for the different types of line is the same in the four graphs.

To track the source of this difference, we can take a look at eq. (8), which gives the derivative Inline graphic as a function of simple, ‘geometrical’ terms, Inline graphic and Inline graphic, and the numerical derivatives Inline graphic. Of course, the choice of one method or another does not affect the former, but only the latter. In the particular case of Inline graphic in fig. 6a, if we remove the terms that are zero according to the rules in eqs. (30), (31) and (32), eq. (8) becomes

graphic file with name pone.0024563.e541.jpg (33)

The numerical derivatives appearing in this expression that are related to the three constrained coordinates associated to atom 5 are shown in figs. 6b, 6c and 6d, respectively, where we can see that the discrepancy between the new algorithm and the finite-differences approach is more significant. For the bond angle Inline graphic in fig. 6b, we see that the derivative predicted by finite differences is close to zero for all values of Inline graphic and for all the tested Inline graphics, while the behaviour given by the new algorithm is more rich and substantially different. This large discrepancy is produced by the fact that bond lengths are very stiff coordinates in the energy function that we have used here, together with the default precision of the floating point numbers provided by Gaussian 03 outputs. In table 1, we can see indeed that the last significant figure of bond length Inline graphic only starts to change for Inline graphic, which makes any algorithm based on finite differences very unreliable for this particular quantity if small values of Inline graphic are used. The bond angles and dihedral angles, on the other hand, are somewhat less stiff than bond lengths, as it can also be seen in tab. 1. This makes their derivatives by finite differences more reliable, as one can observe in figs. 6c and 6d, where the discrepancy with the new method is apparent for small Inline graphic, but becomes gradually smaller as we increase it. Of course, since, in the new method presented in this work, all quantities are computed at the non-displaced point Inline graphic, the problem regarding the number of significant figures does not appear. It is also worth remarking that, in the case of finite differences, the point in which this issue will appear depends on the number of bits used to represent coordinates, but it will always appear for some small enough value of Inline graphic.

Table 1. Stiffness of the constrained coordinates in methanol.

Inline graphic (Inline graphic) Inline graphic (Å) Inline graphic (Inline graphic) Inline graphic (Inline graphic)
0.0 1.090694 109.403 119.296
0.01 1.090694 109.404 119.296
0.05 1.090694 109.404 119.297
0.1 1.090694 109.405 119.299
0.5 1.090694 109.409 119.312
1.0 1.090694 109.415 119.329
5.0 1.090693 109.462 119.474
10.0 1.090692 109.525 119.671

Values of the constrained coordinates associated to atom 5 of methanol for different displacements Inline graphic in the unconstrained coordinate Inline graphic. The values correspond to the conformation with Inline graphic, and the number of significant figures presented is the default one provided by Gaussian 03.

As we noticed in fig. 6a, also in the case of the constrained internal coordinates the difference between the two methods starts to grow again when Inline graphic reaches Inline graphic or Inline graphic. This is easily understood if we think that only in the Inline graphic limit the estimate in eq. (12) converges to the actual value of the partial derivative. In fact, as the complexity of the system increases, the error introduced at large Inline graphic may come not only from continuous changes in the location of the constrained minima, but also, as fig. 7 suggests, it may occur that, at a certain value of Inline graphic, the very identity of the minima is altered, thus introducing potentially larger errors. In fig. 7a, we can see that the derivative Inline graphic in GLY3 presents an unusually large error at the conformation 1044. In fig. 7b, we see that the minimum-energy value of Inline graphic, which is the dihedral angle associated to carbon 22, describing the rotation around a given peptide bond (see fig. 5c), presents an abrupt change when Inline graphic reaches Inline graphic. If we think that the energy landscape of GLY3 is indeed a complex and multidimensional one, it is not difficult to imagine that, as we change Inline graphic, i.e., as we increase Inline graphic, the energy landscape is so altered that some minima disappear, some other appear, and the energy ordering among them is changed. In such a case, the structures found by the minimization procedure will be rather different between, say, Inline graphic and Inline graphic, thus producing a large error in the derivatives calculated by finite differences. Again, the new algorithm, which only uses quantities calculated at Inline graphic, does not suffer from this drawback.

Figure 7. Metastability of the local minima in GLY4.

Figure 7

(a) Derivative Inline graphic of the constrained dihedral angle Inline graphic, describing a peptide bond rotation in GLY3, with respect to the unconstrained coordinate Inline graphic for a selected set of conformations in the working set. (b) Minimum-energy value of the constrained dihedral angle Inline graphic in the conformation 1044 of GLY3 for different values of the displacement Inline graphic in the unconstrained coordinate Inline graphic.

To sum up, the finite-differences method contains two sources of error which the new method does not present: one at small values of Inline graphic, related to the finite precision of the floating point numbers representing the internal coordinates, and the other at larger values of Inline graphic, stemming from the very definition of the partial derivative by finite differences, and aggravated by the complexity of the energy landscapes of large systems. If the derivatives are to be calculated using finite differences, an optimal value of Inline graphic must be chosen in each case so that the possible error is minimized. However, already in the simple example of methanol, we saw that the derivatives of different observables, in the same system, may behave differently as we change Inline graphic (compare the bond length derivative in fig. 6b with that of the angles in figs. 6c and 6d). In fig. 8, we additionally see that the search for the optimal Inline graphic may be further complicated by the fact that the behaviour found also depends (strongly) on the system studied, and, in the case of the derivatives of the Euclidean coordinates, on the position of the atom in the molecule.

Figure 8. Dependence of the error as a function of Inline graphic.

Figure 8

Average normalized error in the derivatives by finite differences as a function of Inline graphic (see the text for a more precise definition). (a) Error averaged to all conformations and all atoms of the three molecular systems studied. (b) Error averaged to all conformations of the Inline graphic-coordinate of three particular Inline graphic-row atoms in NMA.

In fig. 8a, we have plotted the normalized average of the absolute value of the error in the derivatives of the Euclidean coordinates, Inline graphic, as a function of Inline graphic for the three molecular systems studied. This quantity is defined, for a given unconstrained coordinate Inline graphic, as

graphic file with name pone.0024563.e594.jpg (34)

where the index Inline graphic indicates the conformation in the working set, running from 1 to Inline graphic, FD stands for ‘finite differences’, NA for ‘new algorithm’, and Inline graphic is a normalizing quantity for each coordinate Inline graphic chosen as

graphic file with name pone.0024563.e599.jpg (35)

The graphics in fig. 8a of this quantity correspond to the unconstrained dihedral angles Inline graphic, Inline graphic and Inline graphic of methanol, NMA and GLY3, respectively (see fig. 5). We observe that the average error as a function of Inline graphic presents significantly different behaviours in the three molecules, never being smaller than a 2%. Additionally, in fig. 8b, we show the same error but this time individualized to the Inline graphic-coordinate of three different Inline graphic-row atoms of NMA: C3, N6 and C8. Although the overall behaviour of the error is similar for the three atoms, its size is not.

All in all, we see that the need to tune for the optimal Inline graphic in the finite-differences approach not only produces unavoidable errors, but also it must be done in a per-system, per-observable basis, clearly complicating and limiting the use of this technique. The new algorithm, on the other hand, is only affected by the source of error related to the accuracy with which the Hessian matrix of the potential energy can be calculated and inverted; apart from this, which is a general drawback of any method implemented in a computer, its mathematical definition is ‘exact’, in the sense that it does not contain any tunable parameter, like Inline graphic, that must be adjusted for optimal accuracy in each particular problem.

Also, and more importantly (since the failure of finite differences was indeed predictable) the good coincidence between the newly introduced, somewhat more involved method and the straightforward finite-differences scheme for the smallest system and in some intermediate range of values of Inline graphic allows us to regard the new scheme as validated and error-free.

Finally, despite what we discussed in the Methods section, namely, that we have not pursued here the numerical optimization of the algorithm introduced, being our main interest to present the general theoretical concepts and to show that the new method is exact and reliable, we close this section with an example of a toy system to provide a clue that the new technique is at least feasible. Before introducing the toy system it is worth noting that the examples tackled in this section are just particular cases, but the technique can be used in different systems and with different potential energy functions. When looking at the computer costs presented below, the reader should bear in mind that they may be not very significant (due to the aforementioned lack of optimization) and not very relevant (due to the choice of a small toy system and a given potential energy function). Of course, if any production runs using the new algorithm are attempted, a thorough numerical optimization and assessment should be performed, which we deem to be a very important next step of our work.

The toy system is a 2-dimensional one, with positions Inline graphic and Inline graphic, and the following potential energy (see fig. 9):

graphic file with name pone.0024563.e611.jpg (36)

Figure 9. Potential energy of the toy system in eq. (36).

Figure 9

The range of Inline graphic and Inline graphic corresponds to the one explored in this work. Contour level lines and colour level indication in the surface have been added for visual comfort. All units are arbitrary.

If we take a large enough Inline graphic, say Inline graphic, we see that the system will present a strong oscillatory motion in the Inline graphic coordinate, around approximately Inline graphic (but not exactly, since the term Inline graphic slightly modifies the position of the minimum), and with harmonic constant approximately equal to Inline graphic. In the spirit of this work, since, due to energetic reasons, the value of Inline graphic will seldomly move far away from the value that minimizes Inline graphic for each Inline graphic, denoted by Inline graphic and implicitly defined by the following equation:

graphic file with name pone.0024563.e624.jpg (37)

we can kill this oscillatory motion by assuming that a flexible constraint Inline graphic exists. In such a case, Inline graphic plays the role of the whole set of unconstrained coordinates Inline graphic in the general formalism, and Inline graphic plays the role of the whole set of constrained coordinates Inline graphic.

Now, if we perform a ‘molecular dynamics’ of this system, then we may need at some point to compute the derivative with respect to Inline graphic of some observable Inline graphic restricted to the constrained subspace Inline graphic (for example, we may need this to calculate mass-metric tensor corrections at each time step [12]). We can do so by using finite differences or the new technique introduced in this work. As we discussed in the Methods section, for both approaches we will need to perform a minimization of Inline graphic at each fixed Inline graphic in order to find Inline graphic and Inline graphic, hence, being this step common, we will not consider it for the assessment of the differences in computational cost between the two methods. The additional computations that will decide which method is faster are:

  • For finite differences: Choose a displaced value of the unconstrained coordinate Inline graphic, minimize Inline graphic with respect to Inline graphic in order to find Inline graphic, as well as Inline graphic, and finally calculate the finite-differences estimation of the sought derivative:

  • graphic file with name pone.0024563.e642.jpg (38)
  • For the new method: Calculate the objects in eq. (11), perform the required inversion to find Inline graphic, calculate the objects in eq. (5), and finally find Inline graphic using this last expression. In this simple case, all the objects to be computed are:

graphic file with name pone.0024563.e645.jpg (39)

The second-order derivatives of the potential energy can be easily calculated:

graphic file with name pone.0024563.e646.jpg (40a)
graphic file with name pone.0024563.e647.jpg (40b)

and we can use them to find the derivative of Inline graphic through eq. (11):

graphic file with name pone.0024563.e649.jpg (41)

The particularization of eq. (5) to this simple case is

graphic file with name pone.0024563.e650.jpg (42)

In this section, for illustrative purposes, we have chosen a simple observable Inline graphic:

graphic file with name pone.0024563.e652.jpg (43)

i.e., the distance of the particle to the origin of coordinates. Hence, the remaining objects that we need to compute in order to apply the new technique to this problem are

graphic file with name pone.0024563.e653.jpg (44a)
graphic file with name pone.0024563.e654.jpg (44b)

We have calculated Inline graphic using both techniques for 11 different values of Inline graphic. This calculation has been performed in a desktop iMac with a 2.66 GHz Intel Core 2 Duo processor and 4GB of 1067 MHz DD3 RAM memory, running MacOSX Snow Leopard. The same compilation-time optimizations have been used in the two cases, and the common times have been subtracted as indicated before. It is also worth remarking that we have used Brent’s method [32] for minimizing Inline graphic, and a different choice will change the comparison. In these conditions, the new technique has proved approximately one order of magnitude faster than finite differences, elapsing Inline graphic Inline graphics/point vs. Inline graphic Inline graphics/point.

In summary, in this work, we have introduced a new, exact, parameter-free method for computing the derivatives of physical observables in systems with flexible constraints. The new algorithm has been numerically validated in small molecules against its most natural alternative, finite differences. In doing so, numerous pitfalls of the latter method have been demonstrated, all arising from the fact that it contains a tunable parameter that has to be optimally adjusted in each particular problem at hand. In a number of numerical experiments, we have shown that the finite-differences approach contains two unavoidable sources of error that are not present in the new method: On the one hand, the finite number of significant figures used to represent, in computers, the values of the optimized coordinates, together with the fact that these constrained coordinates are typically very stiff, make the changes in this quantities often unobservable or at least badly resolved, thus rendering the finite-differences derivatives unreliable for small values of the displacement parameter Inline graphic. On the other hand, the very fact that finite-differences derivatives only converge to the true ones for Inline graphic, complicated with the possibility that the energy landscapes of complex molecular systems may significantly change their structure when the unconstrained coordinates are displaced, introduce new errors as Inline graphic increases. These two sources of errors combined make compulsory the search of an optimal value of Inline graphic in each particular case, and also establish a minimum error below which is not possible to go, as it can be seen in fig. 8. Also, using a simple toy system, we have shown that the new technique can be faster than finite differences in certain situations. The new method introduced here, and it is already being successfully used in a number of works in progress in our group to compute the correcting terms appearing in the equilibrium probability distribution when flexible constraints are imposed on the system [11]. Moreover, given the almost ubiquitous occurrence of the concept of constraints all throughout the fields of computational physics and chemistry, it is expected that the method described in this work will find many applications in present and future problems. Some examples have been already mentioned in the introduction, notably the case of ground-state Born-Oppenheimer MD [42], [43] (using, e.g., Hartree-Fock [29]), which can be regarded as a flexibly constrained problem in which the soft coordinates are the nuclear positions Inline graphic, the hard ones are the electronic orbitals Inline graphic, and the function to be minimized is the expected value Inline graphic of the Inline graphic-dependent electronic Hamiltonian in the Inline graphic-electron Slater determinant Inline graphic.

Acknowledgments

We thank the reviewers of the manuscript for their insightful comments that have contributed to improve the final version.

Footnotes

Competing Interests: The authors have declared that no competing interests exist.

Funding: This work was funded by FIS2009-13364-C02-01 (MICINN, Spain), Grupo de Excelencia “Biocomputación y Física de Sistemas Complejos”, E24/3 (DGA, Spain), and ARAID and Ibercaja grant for young researchers (DGA and Ibercaja, Spain). P. G.-R. is supported by a JAE-Predoc scholarship (CSIC, Spain). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

References

  • 1.Rapaport DC. Cambridge University Press, 2nd edition; 2004. The art of molecular dynamics simulation. [Google Scholar]
  • 2.Allen MP, Tildesley DJ. Oxford: Clarendon Press; 2005. Computer simulation of liquids. [Google Scholar]
  • 3.Frenkel D, Smit B. Orlando FL: Academic Press, 2nd edition; 2002. Understanding molecular simulations: From algorithms to applications. [Google Scholar]
  • 4.Car R, Parrinello M. Unified approach for molecular dynamics and density-functional theory. Phys Rev Lett. 1985;55:2471–2474. doi: 10.1103/PhysRevLett.55.2471. [DOI] [PubMed] [Google Scholar]
  • 5.Hutter J, Curioni A. Car-Parrinello molecular dynamics on massively parallel computers. ChemPhysChem. 2005;6:1788–1793. doi: 10.1002/cphc.200500059. [DOI] [PubMed] [Google Scholar]
  • 6.Carter EA, Ciccotti G, Hynes JT, Kapral R. Constrained reaction coordinate dynamics for the simulation of rare events. Chem Phys Lett. 1989;5:472–477. [Google Scholar]
  • 7.Schlick T, Barth E, Mandziuk M. Biomolecular dynamics at long timesteps: Bridging the timescale gap between simulation and experimentation. Annu Rev Biophys Biomol Struct. 1997;26:181–222. doi: 10.1146/annurev.biophys.26.1.181. [DOI] [PubMed] [Google Scholar]
  • 8.Ryckaert JP, Ciccotti G, Berendsen HJC. Numerical integration of the Cartesian equations of motion of a system with constraints: Molecular dynamics of n-alkanes. J Comput Phys. 1977;23:327–341. [Google Scholar]
  • 9.Dubrovin BA, Fomenko AT, Novikov SP. Berlin: Springer; 1992. Modern Geometry — Methods and Applications. [Google Scholar]
  • 10.Weisstein EW. Ordinary differential equations. from MathWorld – A Wolfram Web Resource. http://mathworld.wolfram.com/OrdinaryDifferentialEquations.html.
  • 11.Echenique P, Cavasotto CN, García-Risueño P. The canonical equilibrium of constrained molecular models. 2011. In progress, http://arxiv.org/abs/1105.0374.
  • 12.Echenique P, Calvo I, Alonso JL. Quantum mechanical calculation of the effects of stiff and rigid constraints in the conformational equilibrium of the alanine dipeptide. J Comput Chem. 2006;27:1748–1755. doi: 10.1002/jcc.20467. [DOI] [PubMed] [Google Scholar]
  • 13.Christen M, van Gunsteren WF. An approximate but fast method to impose flexible distance constraints in molecular dynamics simulations. J Chem Phys. 2005;122:144106. doi: 10.1063/1.1872792. [DOI] [PubMed] [Google Scholar]
  • 14.Hess B, Saint-Martin H, Berendsen HJC. Flexible constraints: An adiabatic treatment of quantum degrees of freedom, with application to the flexible and polarizable mobile charge densities in harmonic oscillators model for water. J Chem Phys. 2002;116:9602. doi: 10.1063/1.1747927. [DOI] [PubMed] [Google Scholar]
  • 15.Zhou J, Reich S, Brooks BR. Elastic molecular dynamics with self-consistent flexible constraints. J Chem Phys. 2000;112:7919. [Google Scholar]
  • 16.Christen M, Christ CD, van Gunsteren WF. Free energy calculations using flexible-constrained, hard-constrained and non-constrained molecular dynamics simulations. ChemPhysChem. 2007;8:1557–1564. doi: 10.1002/cphc.200700176. [DOI] [PubMed] [Google Scholar]
  • 17.Cotter CJ, Reich S. Adiabatic invariance and applications from molecular dynamics to numerical weather prediction. BIT Num Math. 2004;44:439–455. [Google Scholar]
  • 18.Helfand E. Flexible vs. rigid constraints in Statistical Mechanics. J Chem Phys. 1979;71:5000. [Google Scholar]
  • 19.Pechukas P. Comment on: ‘Flexible vs. rigid constraints in Statistical Mechanics’. J Chem Phys. 1980;72:6320. [Google Scholar]
  • 20.Van Kampen NG, Lodder JJ. Constraints. Am J Phys. 1984;52:419–424. [Google Scholar]
  • 21.Goldstein H, Poole C, Safko J. Addison-Wesley, 3rd edition; 2002. Classical Mechanics. [Google Scholar]
  • 22.Gō N, Scheraga HA. On the use of classical statistical mechanics in the treatment of polymer chain conformation. Macromolecules. 1976;9:535. [Google Scholar]
  • 23.Brooks BR, Brooks CL, III, MacKerell AD, Nilsson L, Petrella RJ, et al. CHARMM: The biomolecular simulation program. J Comput Chem. 2009;30:1545–1615. doi: 10.1002/jcc.21287. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 24.Jorgensen WL, Tirado-Rives J. The OPLS potential functions for proteins. Energy minimization for crystals of cyclic peptides and Crambin. J Am Chem Soc. 1988;110:1657–1666. doi: 10.1021/ja00214a001. [DOI] [PubMed] [Google Scholar]
  • 25.Jorgensen WL, Maxwell DS, Tirado-Rives J. Development and testing of the OPLS all-atom force field on conformational energetics and properties of organic liquids. J Am Chem Soc. 1996;118:11225–11236. [Google Scholar]
  • 26.Ponder JW, Case DA. Force fields for protein simulations. Adv Prot Chem. 2003;66:27–85. doi: 10.1016/s0065-3233(03)66002-x. [DOI] [PubMed] [Google Scholar]
  • 27.Case DA, Darden TA, Cheatham TE, III, Simmerling CL, Wang J, et al. San Francisco: University of California; 2008. Amber 10. [Google Scholar]
  • 28.Pearlman DA, Case DA, Caldwell JW, Ross WR, Cheatham TE, III, et al. AMBER, a computer program for applying molecular mechanics, normal mode analysis, molecular dynamics and free energy calculations to elucidate the structures and energies of molecules. Comp Phys Commun. 1995;91:1–41. [Google Scholar]
  • 29.Echenique P, Alonso JL. A mathematical and computational review of Hartree-Fock SCF methods in Quantum Chemistry. Mol Phys. 2007;105:3057–3098. [Google Scholar]
  • 30.Echenique P, Calvo I. Explicit factorization of external coordinates in constrained Statistical Mechanics models. J Comput Chem. 2006;27:1733–1747. doi: 10.1002/jcc.20499. [DOI] [PubMed] [Google Scholar]
  • 31.Jensen F. Chichester: John Wiley & Sons; 1998. Introduction to Computational Chemistry. [Google Scholar]
  • 32.Press WH, Teukolsky SA, Vetterling WT, Flannery BP. The art of scientific computing. New York: Cambridge University Press, 3rd edition; 2007. Numerical recipes. [Google Scholar]
  • 33.Eastwood JW, Hockney RW. Shaping the force law in two-dimensional particle mesh models. J Comput Phys. 1974;16:342–359. [Google Scholar]
  • 34.Greengard L, Rokhlin V. A fast algorithm for particle simulations. J Comput Phys. 1987;73:325–348. [Google Scholar]
  • 35.Darden TA, York D, Pedersen L. Particle mesh Ewald: An N log(N) method for ewald sums in large systems. J Chem Phys. 1993;98:10089–10092. [Google Scholar]
  • 36.Echenique P. Introduction to protein folding for physicists. Contemp Phys. 2007;48:81–108. [Google Scholar]
  • 37.Echenique P, Alonso JL. Definition of Systematic, Approximately Separable and Modular Internal Coordinates (SASMIC) for macromolecular simulation. J Comput Chem. 2006;27:1076–1087. doi: 10.1002/jcc.20424. [DOI] [PubMed] [Google Scholar]
  • 38. Belongie S (last accessed on 08/12/2009). Rodrigues’ rotation formula. from MathWorld – A Wolfram Web Resource. http://mathworld.wolfram.com/ImplicitFunctionTheorem.html.
  • 39.Cornell WD, Cieplak P, Bayly CI, Gould IR, Merz J K M, et al. A second generation forc field for the simulation of proteins, nucleic acids, and organic molecules. J Am Chem Soc. 1995;117:5179–5197. [Google Scholar]
  • 40.Kollman P, Dixon R, Cornell W, Fox T, Chipot C, et al. Van Gunsteren WF, Weiner PK, Wilkinson AJ, editors, Computer Simulations of Biomolecular Systems, Dordrecht: Kluwer Academic Publishing, volume 3. pp; 1997. The development/application of a ‘minimalist’ organic/biochemical molecular mechanic force field using a combination of ab initio calculations and experimental data. pp. 83–96. [Google Scholar]
  • 41.Frisch MJ, Trucks GW, Schlegel HB, Scuseria GE, Robb MA, et al. Gaussian, Inc., Wallingford, CT; 2007. Gaussian 03, Revision E.01. [Google Scholar]
  • 42.Alonso JL, Andrade X, Echenique P, Falceto F, Prada-Gracia D, et al. Efficient formalism for large-scale ab initio molecular dynamics based on time-dependent density functional theory. Phys Rev Lett. 2008;101:096403. doi: 10.1103/PhysRevLett.101.096403. [DOI] [PubMed] [Google Scholar]
  • 43.Andrade X, Castro A, Zueco D, Alonso JL, Echenique P, et al. Modified Ehrenfest formalism for efficient large-scale ab initio molecular dynamics. J Chem Theory Comput. 2009;5:728–742. doi: 10.1021/ct800518j. [DOI] [PubMed] [Google Scholar]

Articles from PLoS ONE are provided here courtesy of PLOS

RESOURCES