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.

Optimization and normal modes

In this section we will see how to visualize geometry optimization trajectories, as well as molecular vibration modes using py3Dmol.

Geometry optimization

Let’s assume we have run the geometry optimization and saved all the steps in xyz format in a file. To animate the optimization trajectory we first need a routine which reads the configurations from file.

Using this routine, we can plot the energies during optimization, as well as animate the trajectory.

<Figure size 700x400 with 1 Axes>
Loading...

If instead we would like to see each configuration individually, we can create an interactive widget with a slider. As in the previous section, we need a routine which reads an individual configuration at a time and returns the corresponding py3Dmol viewer.

Vibrational normal modes

Now let’s see how to animate and visualize vibrational normal modes. For this, we will need to determine the molecular Hessian and perform a vibrational analysis.

In order to perform a vibrational analysis we need a Molecule object which stores the optimized geometry. To create the Molecule object we will read the last geometry from the xyz file we used in the previous subsection.

Now we have the frequencies, normal modes and IR intensities. In order to animate a specific normal mode, we need to write a routine which selects the mode of interest and returns it in the format required by py3Dmol. We would also like to plot the IR spectrum and, for this, we also need a routine which adds a Gaussian or Lorentzian broadening to the calculated IR spectrum.

After adding the broadening, we can plot the spectrum and then animate a specific normal mode, selected based on its index.

<Figure size 700x400 with 1 Axes>



       Normal mode 64: 1078.97 cm-1, 68.44 km/mol.
Loading...

To make a more interactive normal mode selection, we can create a slider using the ipywidgets Python module for Jupyter notebooks. To make use of the slider widget, we first need a routine which can plot the IR spectrum and animate a specific normal mode selected based on its index.