ElectronLocalizationFunction

class ElectronLocalizationFunction(configuration, density_mesh_cutoff=None)

A class for calculating the electron localization function for a configuration.

Parameters:
absolute()
Returns:

A new grid containing the absolute values (or modulus) of the current field.

Return type:

GridValues

axisProjection(projection_type=None, axis=None, spin=None, projection_point=None, coordinate_type=None)

Project a 3D Grid onto one of the cartesian axes.

Parameters:
  • projection_type ('sum' | 'average' | 'avg' | 'line') – Which type of projection to perform.
    Default: 'sum'

  • axis ('a' | 'b' | 'c') – Onto which axis to project the data.
    Default: 'c'

  • spin (Spin.Up | Spin.Down | Spin.RealUpDown | Spin.ImagUpDown) – Which spin component to project.
    Default: Spin.Up

  • projection_point (numpy.array) – Coordinates of the point through which to take a lineout.
    Default: numpy.array([0.0, 0.0, 0.0])

Returns:

A 2-tuple of 1D numpy.arrays containing the axis values and the projected data.

Return type:

tuple of numpy arrays

derivatives(x, y, z, spin=None)

Calculate the derivative in the point (x, y, z).

Parameters:
  • x (PhysicalQuantity of type length.) – The Cartesian x coordinate.

  • y (PhysicalQuantity of type length.) – The Cartesian y coordinate.

  • z (PhysicalQuantity of type length.) – The Cartesian z coordinate.

  • spin (Spin.All | Spin.Up | Spin.Down | Spin.RealUpDown | Spin.ImagUpDown | Spin.UpUp | Spin.DownDown) – The spin component to project on.
    Default: Spin.All

Returns:

The gradient at the specified point for the given spin. For Spin.All, a tuple with (Spin.Up, Spin.Down, Spin.RealUpDown, Spin.ImagUpDown) components is returned.

Return type:

PhysicalQuantity of type unitless

downsample(downsampling_a=None, downsampling_b=None, downsampling_c=None)

Generate a new GridValues object where the grid is downsampled. Along periodic directions an FFT downsampling is performed. Along non-periodic directions antialiasing and downsampling is performed.

Parameters:
  • downsampling_a (int) – The new number of grid points along the A direction.
    Default: No downsampling.

  • downsampling_b (int) – The new number of grid points along the B direction.
    Default: No downsampling.

  • downsampling_c (int) – The new number of grid points along the C direction.
    Default: No downsampling.

evaluate(x, y, z, spin=None)

Evaluate in the point (x, y, z).

Parameters:
  • x (PhysicalQuantity of type length) – The Cartesian x coordinate.

  • y (PhysicalQuantity of type length) – The Cartesian y coordinate.

  • z (PhysicalQuantity of type length) – The Cartesian z coordinate.

  • spin (Spin.Up | Spin.Down | Spin.RealUpDown | Spin.All | Spin.ImagUpDown | Spin.UpUp | Spin.DownDown) – The spin component to project on.
    Default: The spin this object was calculated for.

Returns:

The value at the specified point for the given spin. For Spin.All, a tuple with (Spin.Up, Spin.Down, Spin.RealUpDown, Spin.ImagUpDown) components is returned.

Return type:

PhysicalQuantity of type unitless

gridCoordinate(i, j, k)

Return the coordinate for a given grid index.

Parameters:
  • i (int) – The grid index in the A direction.

  • j (int) – The grid index in the B direction.

  • k (int) – The grid index in the C direction.

Returns:

The Cartesian coordinate of the given grid index.

Return type:

PhysicalQuantity of type length.

metatext()
Returns:

The metatext of the object or None if no metatext is present.

Return type:

str | None

nlprint(stream=None)

Print a string containing an ASCII table useful for plotting the AnalysisSpin object.

Parameters:

stream (python stream) – The stream the table should be written to.
Default: NLPrintLogger()

primitiveVectors()
Returns:

The primitive vectors of the grid.

Return type:

PhysicalQuantity of type length.

scale(scale)

Scale the field with a float.

Parameters:

scale (float) – The parameter to scale with.

setMetatext(metatext)

Set a given metatext string on the object.

Parameters:

metatext (str | None) – The metatext string that should be set. A value of “None” can be given to remove the current metatext.

shape()
Returns:

The number of grid points in each direction.

Return type:

tuple of three int.

spin()
Returns:

The spin the electron localization function is calculated for, always Spin.All.

Return type:

Spin.All

spinProjection(spin=None)

Query method to get a spin component of the ElectronLocalizationFunction object.

Parameters:

spin (Spin.Up | Spin.Down | Spin.RealUpDown | Spin.ImagUpDown) – The spin component for which to return the electron localization function object.
Default: Spin.Up

toArray()
Returns:

The values of the grid as a numpy array slicing off any units.

Return type:

numpy.array

uniqueString()

Return a unique string representing the state of the object.

unit()
Returns:

The unit of the data in the grid.

Return type:

A physical unit.

unitCell()
Returns:

The unit cell of the grid.

Return type:

PhysicalQuantity of type length.

volumeElement()
Returns:

The volume element of the grid represented by three vectors.

Return type:

PhysicalQuantity of type length.

Usage Examples

Calculate the electron localization function and save it to a file:

# Set up configuration
molecule_configuration = MoleculeConfiguration(
    elements=[Nitrogen, Hydrogen, Hydrogen, Hydrogen],
    cartesian_coordinates=[[ 6.13508 ,  5.790587,  2.75    ],
                           [ 6.13508 ,  6.73176 ,  2.336663],
                           [ 6.95016 ,  5.32    ,  2.336663],
                           [ 5.32    ,  5.32    ,  2.336663]]*Angstrom
    )


# Define the calculator
calculator = LCAOCalculator()
molecule_configuration.setCalculator(calculator)

# Calculate and save the effective potential
elf = ElectronLocalizationFunction(molecule_configuration)
nlsave('results.nc', molecule_configuration)
nlsave('results.nc', elf)

nh3_elf.py

For examples on working with 3D grids, see HartreePotential and ElectronDensity.

Notes