Generate and animate vibrations using Psi4 and Blender

Hi all,

I have been using psi4 and Blender for a while to generate animations, and I think that these are simple and fun enough for other students to get some value out of them.

You can find the scripts here: GitHub - MaxParadiz/AnimateMolecularVibrations: Generate normal modes using Psi4, and then visualize the vibrations in Blender

The workflow consists of running two scripts:

  • A psi4 python script that calculates the normal modes and saves them into a dictionary
  • A blender script that should be run from within’s Blender python console. This script loads the data, generates the van-der-waals sphere representation of the molecule, and provides you with a “Vibrate()” function.

The Vibrate() function is where it gets more fun… Most molecular viewers will allow you to click on each vibration to visualize the mode. But this constraint does not exist here!

The Vibrate() function takes in as arguments lists of modes, amplitudes, and phases. This allows you to generate animations of superposition of modes, to create more organically-looking animations about molecular motion, visualize at how different modes might interact anharmonically, or use a boltzmann-weighted array to get an idea of the “average” molecule’s motion. It is pretty fun to play with.

I also have a script that uses Psi4 and Blender to generate molecular orbital transitions. This one I need to polish, and it is a bit less accessible, but if anyone would like to look at it to get some inspiration you can check it out here: GitHub - MaxParadiz/MOT: Animate molecular orbital transitions using Psi4 and Blender

2 Likes

Looks nice! I’l definitely try to have a proper play at some point when I get time. :slight_smile:

1 Like

Thanks! If you check it out and have any suggestions to improve it, or if you need help getting something to work, just let me know!

After a fair bit of on-and-off fiddling (and eventually working out that I needed a newer versions of Blender than I had installed!), I’ve mostly got it working, although I use Blender very very rarely and have to relearn it each time.

It would be worth adding a few more lines to your README.md file so that it’s clearer how to generate nice looking images.

Unless I’ve missed something, once I’ve pasted the script into the python console within Blender, I then have to add a camera and some lights before being able to render anything.

I also seemed to keep on getting an error because the context had become invalid and had to redefine

scene = bpy.context.scene; scene.frame_start = 1; scene.frame_end = 200

before it would render (although that could well just be my poor attempts at controlling Blender!).

So far, my attempts have only rendered very dark, poorly lit images, so some example light types / positions could be handy.

Another improvement would be to name rendered images with zero padding, so it’s a lot easier to use wildcards when combining them into a video.

I’ll certainly keep on fiddling because we use similar molecular vibration videos in lectures.