Tuesday, July 23, 2013

Illustrating energy minimization: a simple python program

Here is a simple python program I wrote to illustrate energy minimization.  The program uses steepest descent and a force field to minimize the energy of a water molecule in internal coordinates.

If you have a Mac or Linux machine you already have python installed (Windows users please Google and/or leave a comment).  You can also get an invite for koding.com and run it there. You can run it by opening a terminal and typing "python Emin.py".

Things to play around with (once you have it running): change the starting geometry, step size (c), number of steps (n_steps), try printing out the geometry, energy and gradient for each step.

You can also try to write a similar program for other molecules (like methane), although once you have van der Waals interactions you will probably have to switch to Cartesian coordinates and things get complicated.

Related blog posts
The force is strong in this one
The autoopt tool in Avogadro
Post a Comment