Field Segregation

Here is a script that divides a field into multiple sub-fields at a given boundary value.

Input
\$doc: An atomistic document. The default is the zeolite MFI with an AtomVolumesField.
\$field: A field. You can either create one on the spot here (e.g. using CreateSolventField) or use an existing field.
\$boundaryValue: Segregate the field as this isovalue. As an example I extract the value from the isosurface.

Configuration
\$createSegregateFields: do I want a new field for each segregate created in the input document?
\$summaryTable: create a study table summarizing the results.
\$segregatesAboveBoundary: consider fields with values greater than the bondary value
\$segregatesBelowBoundary: consider fields with values less than the bondary value
\$accessibleSegregates: consider accessible (infinitely connected) volumes
\$inaccessibleSegregates: consider inaccessible (finitely connected) volumes

Output
New fields in the input document
A study table summarizing segregate properties.

Notes
New fields are created invisible. Use the volumetric tree view to view them one at a time. Although storage of field data is efficient, dsplaying many high-resolution fields can be time-consuming and memory-hungry.
In a non-periodic field, a segregate is considered infinitely connected if it intersects the field boundary.
Adjusting the color map can help visualization. In particular you probably do not wish any display of out-of-range values.
This script is not fast.

How it works:
Firstly it makes a raster scan through the field to find contiguous areas that are the same side of the boundary value. Then it scans the boundaries to see which regions are connected across the periodic boundary. It searches recursively down these connections to see whether the segregate is isolated or accessible. Finally it creates copies of the fields, with values that do not belong to that segregate set to the boundary value.

Possible enhancements (for the enthusiastic):
Determine the centre-of-mass of each segregate and determine the distribution for the radius of gyration.
Fit a sphere or ellipsoid to a segregate.