Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Constructing the PES by interpolation

The idea behind PES interpolation techniques is to construct the global PES of the molecular ground or excited-state from a set of data points (configurations) calculated quantum-mechanically (QM). For small molecules with few degrees of freedom, depending on the level of theory, the interpolated PES can have similar computational cost as constructing the PES ab initio. On the other hand, the use of an interpolated PES becomes very advantageous, especially when the molecule of interest is embedded in a larger environment (e.g. fluorescent probe in a protein), where this technique allows performing dynamics on the ground or excited state with quantum chemical accuracy, but at molecular mechanics computational cost Rhee & Park (2016).

The idea behind PES interpolation is to write the potential energy at a new configuration q\mathbf{q} as a weighted average between potentials defined from a set of ab initio data points {qa}\{\mathbf{q}_a\}:

V(q)=∑awaVa(q) ,V(\mathbf{q}) = \sum_a w_a V_a(\mathbf{q})\,,

where the weights waw_a depend on the distance (Δa\boldsymbol{\Delta}_a) beween the new configuration q\mathbf{q} and a data configuration qa\mathbf{q}_a. The potentials VaV_a are local harmonic potentials written in terms of Taylor expansions based on the energy (EaE_a), gradient (ga\mathbf{g}_a) and Hessian (Ha\mathbf{H}_a):

Va(q)=Ea+ΔaTga+12ΔaTHaΔa .V_a(\mathbf{q}) = E_a + \boldsymbol{\Delta}^\mathrm{T}_a \mathbf{g}_a + \frac{1}{2} \boldsymbol{\Delta}^\mathrm{T}_a \mathbf{H}_a\boldsymbol{\Delta}_a\, .

The vector q\mathbf{q} designating the position is in the internal coordinate system. The weights are provided by considering the distance between q\mathbf{q} and qa\mathbf{q}_a, such that the weight waw_a is larger for a data point qa\mathbf{q}_a that is closer to q\mathbf{q}. The weights waw_a are normalized weights:

wa=va∑ivi w_a = \frac{v_a}{\sum_i v_i}\,

where the un-normalized weights vav_a can be calculated in different ways, for example a simple weighting scheme is:

va=1∣q−qa∣2p.v_a = \frac{1}{|\mathbf{q}-\mathbf{q_a}|^{2p}}.

The exponent 2p2p determines how fast the algorithm switches between data points Kim & Rhee (2016).

Another approach to determine the un-normalized weights is the Shepard weighting scheme Kim & Rhee (2016):

va=[(∣q−qa∣ra)2p+(∣q−qa∣ra)2q]−1,v_a = \left[ \left(\frac{|\mathbf{q}-\mathbf{q_a}|}{r_a}\right)^{2p} + \left(\frac{|\mathbf{q}-\mathbf{q_a}|}{r_a}\right)^{2q} \right]^{-1},

where rar_a is the confidence radius for qa\mathbf{q_a}.

For a good overview of potential energy surfaces by interpolation, see Rhee & Park (2016).

In this tutorial we will get familiar with constructing the ground state potential energy surface (PES) of a molecule by interpolation.

The ground state potential energy surface of water

Let’s construct the ground state PES for the water molecule by interpolation. We need to carry out the following steps:

  • Transform the coordinates, gradients and Hessians from Cartesian coordinates to internal coordinates,

  • Calculate the ground state energy, gradient, and Hessian for a several molecular configurations which will serve as data points for interpolation,

  • Determine the harmonic potentials and weights,

  • Perform the interpolation and determine the potential energy at new configurations q\mathbf{q}.

Transforming from Cartesian to internal coordinates

We will implement a set of routines to transform the gradient and Hessian to internal coordinates, making use of routines from geomeTRIC. Let’s start by setting up the molecule and calculating the energy, gradient and Hessian.

Source
Loading...

Calculating the energy, gradient, and hessian.

Output
Output
Output

Now that we have an energy, gradient and Hessian, let’s define the Z-matrix for the water molecule and write the routines required to transform from Cartesian coordinates to the internal coordinates defined by the Z-matrix. We will use geomeTRIC to set up the internal coordinates.

The internal coordinates defined through geomeTRIC have routines that allow us to calculate derivatives with respect to Cartesian coordinates (x\mathbf{x}), as required for constructing the Wilson B\mathbf{B}-matrix:

Bij=∂qi∂xj .B_{ij} = \frac{\partial q_i}{\partial x_j}\,.

Let us use these routines to get the B\mathbf{B}-matrix.

In order to transform from Cartesian gradient to internal gradient, we need the inverse of B\mathbf{B}:

∂V∂qi=∑j∂V∂xj∂xj∂qi=∑j∂V∂xjBji−,\frac{\partial V}{\partial q_i} = \sum_j \frac{\partial V}{\partial x_j} \frac{\partial x_j}{\partial q_i} = \sum_j \frac{\partial V}{\partial x_j} B_{ji}^{-},

with BB−=I\mathbf{BB}^{-}=\mathbf{I}. Because B\mathbf{B} is a rectangular matrix, we need to obtain its inverse carefully. From

BBT(BBT)−=I,\mathbf{B}\mathbf{B}^\mathrm{T} \left( \mathbf{B}\mathbf{B}^\mathrm{T} \right)^{-} = \mathbf{I},

we can easily see that B−=BT(BBT)−\mathbf{B}^{-} = \mathbf{B}^\mathrm{T} \left( \mathbf{B}\mathbf{B}^\mathrm{T} \right)^{-} holds, so to get the inverse we have to first construct a square matrix G=BBT\mathbf{G}=\mathbf{B}\mathbf{B}^\mathrm{T}.

G\mathbf{G} is diagnoalized to get its eigenvalues and eigenvectors. The inverse of the non-zero eigenvalues and corresponding eigenvectors will be then used to construct the G−\mathbf{G}^{-} matrix.

Let’s make this piece of code a general routine that we can use for an arbitrary B\mathbf{B} matrix.

Now we have all the ingredients to transform the gradient, but we need the second order derivatives of q\mathbf{q} with respect to x\mathbf{x} to be able to also transform the Hessian. Let’s write a routine to calculate the second-order B-matrix, B(2)\mathbf{B}^{(2)}.

Let’s write the routines which transform the gradient and the Hessian from Cartesian coordinates to internal coordinates. We have to implement the following equations:

gq=G−Bgx\mathbf{g}_q = \mathbf{G}^{-}\mathbf{B}\mathbf{g}_x
Hq=G−B[Hx−gqB(2)]BTG−T\mathbf{H}_q = \mathbf{G}^{-}\mathbf{B}\big[ \mathbf{H}_x - \mathbf{g}_q\mathbf{B}^{(2)}\big]\mathbf{B}^\mathrm{T}\mathbf{G}^{-\mathrm{T}}
def convert_gradient_to_internal(gradient, b_matrix, g_minus):

    # Implement the equation to convert the gradient from Cartesian
    # to internal coordinates.
    
    return gradient_q

Now, let’s write a routine to convert the Hessian.

Ground-state PES by interpolation

Now that we have set up the routines for conversion between Cartesian and internal coordiantes, we can start collecting data points for interpolation. Let’s start with stretching one of the OH bonds and calculate three new points: one when the bond is contracted, one around equilibrium bond length, and one when the bond is stretched.

Calculating the energies, gradients and Hessians for OH =  0.75 A...
Calculating the energies, gradients and Hessians for OH =  0.95 A...
Calculating the energies, gradients and Hessians for OH =  1.35 A...

Now we have to transform the gradient and Hessian from Cartesian to internal coordinates in order to be able to use them for interpolation.

# number of data points:
n_data_pts = len(energies)

# empty lists for the internal gradients and Hessians:
int_gradients = []
int_hessians = []

for i in range(n_data_pts):
    # convert gradients
    ...
    # convert Hessians
    ...
Source

Now that we have the gradients and Hessians in internal coordinates, let’s write a routine which constructs the harmonic potential, given a new molecular configuration q\mathbf{q}.

Va(q)=Ea+ΔaTga+12ΔaTHaΔa .V_a(\mathbf{q}) = E_a + \boldsymbol{\Delta}^\mathrm{T}_a \mathbf{g}_a + \frac{1}{2} \boldsymbol{\Delta}^\mathrm{T}_a \mathbf{H}_a\boldsymbol{\Delta}_a\, .

To be able to use the routine, we first have to create the array of internal coordinates qa\mathbf{q}_a. Let’s add a routine to calculate the values of the internal coordinates we defined previously using geomeTRIC objects. We will need the Cartesian coordinates of the molecule in the different configurations.

Let’s construct the harmonic potentials based on the three data points we calculated previously. To plot the results let’s use an array of new O-H bond distances.

Let’s plot the results.

<Figure size 600x400 with 1 Axes>

Let’s use these for interpolation and compare to the PES calculated with HF. We need to implement the following equations:

V(q)=∑awaVa(q) ,V(\mathbf{q}) = \sum_a w_a V_a(\mathbf{q})\,,
wa=va∑ivi w_a = \frac{v_a}{\sum_i v_i}\,
va=1∣q−qa∣2p.v_a = \frac{1}{|\mathbf{q}-\mathbf{q_a}|^{2p}}.

Let’s see how well the interpolated energies compare to HF energies.

<Figure size 600x400 with 1 Axes>
<Figure size 600x400 with 1 Axes>

Things to consider in this approach include:

  • What happens if you calculate the energy of a configuration which is outside the range of QM data points (eg. an OH bond length larger than the largest value you included)?

  • What happens if you include more or fewer data points in your data base?

References
  1. Rhee, Y. M., & Park, J. W. (2016). Interpolation for molecular dynamics simulations: from ions in gas phase to proteins in solution. Int. J. Quant. Chem., 116, 573–577. 10.1002/qua.25064
  2. Kim, C. W., & Rhee, Y. M. (2016). Constructing an interpolated potential energy surface of a large molecule: A case study with bacteriochlorophyll a model in the Fenna–Matthews–Olson complex. J. Chem. Theory Comput., 12, 5235–5246. 10.1021/acs.jctc.6b00647