M19 (MRBO02) exercises and additional material
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Exercise Week 1: MD

Constructing a force field for the H2O molecule

The first week’s exercise will be to construct a force field for the H2O molecule by fitting the parameters to ab initio calculations. We will first carry out a geometry optimization with CP2K, then we will perform a charge and normal mode analysis, and then we will run an ab initio MD simulation for a single water molecule. After this, we will do force matching to obtain refined parameters for our water model. The second week’s exercise will be to run a classical MD simulation for liquid water system using the force field we parametrized, and then computing the radial distribution function (RDF) for it.

The required iput files can be obtained from here.

Some information regarding the input files

  • The directory 1.1-1H2O-GOPT contains the input file gopt.in for the geometry optimization.

  • The directory 1.2-1H2O-RESP contains the input file resp.in for the charge analysis.

  • The directory 1.3-1H2O-VIBR contains the input file vibr.in for the normal mode analysis.

  • The directory 1.4-1H2O-AIMD contains the input file md.in for the ab initio MD simulation.

  • The directory 1.5-1H2O-MATCH contains the input file ff_match.in for force matching.

1.1. Geometry optimization for a single water molecule

An example input file for the geometry optimization is given below. This input tells CP2K to perform a geometry optimization for H2O molecule using density functional theory with the BLYP exchange-correlation functional.

@SET SYSTEM run-1H2O-GOPT
@SET LIBDIR /home/apps/PCII/cp2k-2022/data

&GLOBAL
  PROJECT ${SYSTEM}          # Name of calculation: run-1H2O-GOPT
  RUN_TYPE GEO_OPT           # Perform a geometry optimization
  PRINT_LEVEL LOW            # Do not output too much information
&END GLOBAL

&FORCE_EVAL
  METHOD QuickStep
  &DFT                       # Use density functional theory
    BASIS_SET_FILE_NAME ${LIBDIR}/GTH_BASIS_SETS
    POTENTIAL_FILE_NAME ${LIBDIR}/GTH_POTENTIALS
    &MGRID
      CUTOFF 250             # plane-wave cutoff for the charge density [Rydbergs]
    &END MGRID
    &SCF
      EPS_SCF 1.0E-6         # convergence threshold for total energy
    &END SCF
    &XC                      # parameters for exchange-correlation functional
      &XC_FUNCTIONAL BLYP
      &END XC_FUNCTIONAL
      &XC_GRID               # some tricks to speed up the calculation of the xc potential
        XC_DERIV       SPLINE2_smooth
        XC_SMOOTH_RHO  NN10
      &END XC_GRID
    &END XC
  &END DFT
  &SUBSYS
    &CELL                    # box containing the molecule: 15x15x15 Angstroms
      ABC [angstrom] 15 15 15
    &END CELL
    &COORD                   # coordinates of the atoms in the box [Angstroms]
      O  0 0 0
      H  0.7 0.7 0
      H -0.7 0.7 0
    &END COORD
    &KIND H                  # basis sets and pseudo-potentials for atomic species
      BASIS_SET TZVP-GTH
      POTENTIAL GTH-BLYP-q1
    &END KIND
    &KIND O
      BASIS_SET TZVP-GTH
      POTENTIAL GTH-BLYP-q6
    &END KIND
  &END SUBSYS
&END FORCE_EVAL

First go to the directory 1.1-1H2O-GOPT, the input file (gopt.in) for the geometry optimization is given there.

The job can be submitted by the command:

cp2k -i gopt.in -o gopt.out

After the calculation is completed, you can check the output file to see if the SCF steps are converged or not.

The file we are mostly interested in is run-1H2O-GOPT-pos-1.xyz. This file contains the atomic positions for each geometry optimization step. You can visualize how the geometry changes using VMD.

Measure bond distances and molecular angles using VMD. Compare your values to the ones calculated in the following paper. Prepare a table similar to the Table I given in the paper and include in your report. (2 Points)

1.2. Charge analysis

Now we can also compute atomic point charges. There are many different models for associating point charges to atoms. The one we will be using is RESP, which fits the electrostatic potential directly in real space. The starting point is the electrostatic potential, which is provided by a quantum mechanical calculation. One then tries to place charges on atoms in such a way that the potential generated by them matches the original potential as closely as possible. Since the charges are intended to be used for interactions with other molecules, the potential is fitted only in the spatial region outside the molecule. The excluded volume is typically defined by the union of the van der Waals spheres around each atom of the molecule.

First go to the directory 1.2-1H2O-RESP and edit the input file resp.in. Change the dummy coordinates with the optimized ones which you can directly take from the last optimization step of run-1H2O-GOPT-pos-1.xyz. Then run the calculation again.

In order to speed up your calculation, you can first copy the file run-1H2O-GOPT-RESTART.wfn to your working directory and rename it to run-1H2O-RESP-RESTART.wfn. This file already contains the converged wave function of the system at the optimized geometry, thus saving CP2K the effort to recompute it.

Once the calulation is finished, check the atomic charges from the output file resp.out.

  1. Compare the atomic charges you calculated to the ones given in the paper. Add your calculated atomic charges to your report. (2 Points)

  2. Using your geometry and fitted point charges, calculate the dipole moment of H2O. How does it compare to the experimental value of 1.85 Debye (measured for isolated water molecules)? Hint: You can have a look at this Fortran code to get an idea on how to do this calculation. (2 Points)

  3. Besides fitting the electrostatic potential, one often defines additional constraints (to be fulfilled exactly) or restraints (to be fulfilled approximately). Analyze resp.in to figure out which constraints and/or restraints are applied in our fit. (2 Points)

1.3. Normal mode analysis

There are several options to determine the force constants for our water model. We calculate it from the frequencies of the vibrational normal modes of our molecule.

Go to the directory 1.3-1H2O-VIBR and replace the dummy coordinates in vibr.in with the optimized geometry and start the calculation of the normal modes.

  1. How many normal modes does the water molecule have and why? (1 Point)

  2. Praprotnik et al. provide vibrational frequencies of the TIP3P model as well as experimental results from gas phase infrared spectroscopy. Compare them to your results and discuss the differences. (2 Points)

  3. (BONUS) Instead of taking the values given by Praprotnik et al., calculate the force constants directly from the frequencies. Hint: Have a look at here (2 Points)

1.4. Ab-initio molecular dynamics simulation

In the case of more complex model potentials (e.g. such as the non-analytic embedded atom model) an 'analytic fit' can become impossible. Alternatively, one may follow the more generally applicable force matching approach: missing parameters of the model potential are chosen such as to best reproduce the forces computed along a MD trajectory (or any other given set of atomic configurations).

Therefore, we will now perform ab initio molecular dynamics (AIMD) of the single water molecule in order to sample its potential energy landscape and compute the forces along the trajectory.

Go to the directory 1.4-1H2O-AIMD and in the md.in input file, replace the initial coordinates for the AIMD by the ones determined from the geometry optimization and start the simulation.

  1. Open the position trajectory run-1H2O-AIMD.xyz using VMD and visualize the trajectory.

  2. What is the physical time duration you have simulated? How much computing time was required per MD step? (1 Point)

  3. What type of ensemble are you simulating? What are the initial and final temperatures of the simulation and why are they different? (2 Points)

  4. Calculate a plot for the O-H bond length versus time step using VMD. Do the same thing for H-O-H bending angle versus time step and determine the averages. (2 Points)

1.5. Force matching

Once the AIMD simulation is done, we can match the force constants. In order to be applicable to a wide range of potentials, the implementation of the parameter search in CP2K does not rely on analytic derivatives of the potentials with respect to the parameters, but uses the trial- and error-like Powell search algorithm.

Go to the directory 1.5-1H2O-MATCH. In the input file ff_match.in, replace the dummy values for the preferred O-H bond length, H-O-H angle and the point charges by the parameters determined from the geometry optimization and the RESP fit. Also, replace the dummy variables for the force constants by the parameters given by Praprotnik et al.. Alternatively, if you did the Task 1.3, you can also use the force constants you calculated, or the ones calculated by CP2K. However, pay attention to the units!

Copy the trajectory run-1H2O-AIMD.xyz and the forces run-1H2O-AIMD.force to the new directory and replace the dummy filenames in ff_match.in. Run ff_match.in to fit the stretching and bending force constants via force matching.

Since we are considering an isolated water molecule, the Lennard-Jones interactions are explicitly set to zero in ff_match.in.

  1. Compare the fitted parameters with the unfitted ones, which of them are closer to the parameters reported by Praprotnik et al.? (1 Point)

  2. Provide a short description of all fitted force field parameters in your report. (3 Points)

Finally, you are ready to use your own force field! The next week’s exercise will be to perform a classical MD simulation for liquid water using the fitted parameters.

References

For more MD exercises with CP2K, please look at here.