Find local minima and maxima of a mapped field on an isosurface

This script attempts to find local minima and maxima of a field mapped onto an isosurface. It can be used, for example, to find the local minima and maxima of the electrostatic potential field that has been mapped onto an electron density isosurface.

The main input is the name of the field containing the isosurface and the name of the mapped field. You can optionally write out the values of the mapped field at the points on the isosurface into a text file for processing with other software. Uranium atoms are used as marker atoms to identify the isosurface and you can also optionally choose if you want to keep these after the calculation is complete.

The script works by moving a field probe through the field and looking for places where the field values change across the isovalue as this indicates you have crossed the isosurface. At this point, a binary optimizer is used to work out more precisely where the surface is. When the optimizer completes, the field probe for the mapped field is placed at the same point. A uranium atom is created at that point and the name of the atom is set to the field value of the mapped field. This scan is performed through all three planes to cover the isosurface adequately.

The maxima and minima are located by moving through each uranium atom and calculating close contacts. If all the values of the mapped isosurface of the atoms in the close contacts are above or below the value of main atom, the main atom is denoted as being a local maxima (Ra, green) or minima (Fr, purple). A cutoff for the close contacts is set to 2x grid spacing. Note that this is not perfect and can lead to multiple local minima and maxima being located if they are "stretched" over the molecule.

An example below demonstrates the output from this script.

cmpdA_isosurfaceMinMax.png

Here you can see the blue U atoms indicating the outline of the electron density isosurface with green and purple atoms showing maxima and minima.

As usual, this is an experimental script and am sure there are better ways of doing this as this can be pretty slow.

Cheers

Stephen