Quantcast
Channel: MOPAC: Is there a simple way to display geometry trajectories - Matter Modeling Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by Camps for MOPAC: Is there a simple way to display geometry trajectories

$
0
0

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

Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>