# Module MMTK.Field

This module defines field objects that are useful in the analysis and visualization of collective motions in molecular systems. Atomic quantities characterizing collective motions vary slowly in space, and can be considered functions of position instead of values per atom. Functions of position are called fields, and mathematical techniques for the analysis of fields have proven useful in many branches of physics. Fields can be described numerically by values on a regular grid. In addition to permitting the application of vector analysis methods to atomic quantities, the introduction of fields is a valuable visualization aid, because information defined on a coarse regular grid can be added to a picture of a molecular system without overloading it. See also the example Miscellaneous/vector_field.py.

## Class AtomicField: A field whose values are determined by atomic quantities

This is an Glossary:abstract-base-class. To create field objects, use one of its subclasses.

Methods:

- particleValues()

  Returns the values of the field at the positions of the atoms in an appropriate subclass of MMTK.ParticleProperties.ParticleProperty.

- writeToFile(filename, scale=`1.0`, color=`None`)

  Writes a graphical representation of the field to the VRML file named by filename, multiplying all values by scale. color permits the choice of a color for the graphics objects.

- view(scale=`1.0`, color=`None`)

  Shows a graphical representation of the field using a VRML viewer. All values are multiplied by scale. color permits the choice of a color for the graphics objects.

## Class AtomicScalarField: Scalar field defined by atomic quantities

A subclass of MMTK.Field.AtomicField and MMTK.Visualization.Viewable.

Constructor: AtomicScalarField(system, grid_size, values)

system

  any subset of a molecular system

grid_size

  the spacing of a cubic grid on which the field values are stored

values

  an object of class MMTK.ParticleScalar containing the atomic values that define the field

The field values are obtained by averaging the atomic quantities over all atoms in a cube of edge length grid_size surrounding each grid point.

The method graphicsObjects, defined in class MMTK.Visualization.Viewable, returns a small cube for each grid point, whose color indicates the field's value on a symmetric red-to-green color scale defined by the range of the field values. Additional keyword options are:

-- scale=factor, to multiply all field values by a factor

-- range=(min, max), to eliminate graphics objects for values that are smaller than min or larger than max

Methods:

- gradient()

  Returns an MMTK.Field.AtomicVectorField object representing the gradient of the field.

- laplacian()

  Returns an MMTK.Field.AtomicScalarField object representing the laplacian of the field.

## Class AtomicVectorField: Vector field defined by atomic quantities

A subclass of MMTK.Field.AtomicField and MMTK.Visualization.Viewable.

Constructor: AtomicVectorField(system, grid_size, values)

system

  any subset of a molecular system

grid_size

  the spacing of a cubic grid on which the field values are stored

values

  an object of class MMTK.ParticleVector containing the atomic values that define the field

The field values are obtained by averaging the atomic quantities over all atoms in a cube of edge length grid_size surrounding each grid point.

The method graphicsObjects, defined in class MMTK.Visualization.Viewable, returns a small arrow for each grid point. The arrow starts at the grid point and represents the vector value at that point. Additional keyword options are:

-- scale=factor, to multiply all field values by a factor

-- diameter=number, to define the diameter of the arrow objects (default: 1.)

-- range=(min, max), to eliminate graphics objects for values whose lengths are smaller than min or larger than max

-- color=string, to define the color of the arrows

Methods:

- length()

  Returns an MMTK.Field.AtomicScalarField object representing the length of the field vectors.

- divergence()

  Returns an MMTK.Field.AtomicScalarField object representing the divergence of the field.

- curl()

  Returns an MMTK.Field.AtomicVectorField object representing the curl of the field.

- laplacian()

  Returns an MMTK.Field.AtomicVectorField object representing the laplacian of the field.