I created a Python script to manipulate the MOPAC output, saving a XYZ file with all the structures from the optimization step. Then, the XYZ can be loaded into Jmol software and do the animation. The steps are:
- Add the following keywords to the MOP file: AUX(6,COMP, XP, XS, XW)
- Run as "mopac fname_root.mop > fname_root.log"
- Edit the Jupiter notebook variable "fname_root" accordingly OR add the "fname_root" as an argument to the script.
- Running the script/notebook will create an XYZ file with the structure of each optimization step. This file can be visualized using Jmol (an animation can be done)
- A file "fname_root.dat" is created with two columns: optimization_step energy, useful to analyze the energy of the system at each optimization step.
Note: If using AUX(5,COMP, XP, XS, XW) keyword, a file with the optimization steps will be created automatically with the name: fname_opt.aux (this file has the same structure as "fname_root.log"
You can download the scripts from here.
Also, I share below a bash script to create the movie after exporting each frame as an image file. This script is intended to be run in a folder where the XYZ files are located (as it is, it will do a batch job creating a movie from each of the XYZ files). Don't forget to change the metadata for the movie!
#!/bin/bash## Script to create MP4 movies from XYZ trajectory files.##rm trajectorymovie.jmol 2> /dev/nullcat > trajectorymovie.jmol <<!frank offbackground whiteset ambient 10; set diffuse 60; set specular 70frame 1 num_frames = getProperty("modelInfo.modelCount") for (var i = 1; i <= num_frames; i = i+1) var filename = "movie-"+("0000"+i)[-3][0]+".jpg" write IMAGE 732 616 JPG @filename frame next end for!for filename in *.xyz; do extension="${filename##*.}" filenamem1=$(basename "$filename") filenamem="${filenamem1%.*}" filenamem2=$(basename "$filenamem") filenamem3="${filenamem2%.*}" mkdir out_${filenamem} cd out_${filenamem} ln -s ../${filename} . jmol ${filename} -b -L -n -s ../trajectorymovie.jmol ffmpeg -framerate 100 -i movie-%04d.jpg -c:v libx264 -map_metadata -1 -metadata title="${filenamem}" -metadata author="I. Camps" -metadata year="2024" -pix_fmt yuv420p ${filenamem}.mp4 zip -9 -m Frames_${filenamem}.zip *.jpg cd .. done