Name

ElectrostaticDifferencePotential — Class for calculating the Hartree potential corresponding to a difference density.

Synopsis

Namespace: NanoLanguage
ElectrostaticDifferencePotential(configuration)

Description

A class for calculating the electrostatic difference potential for a configuration.

ElectrostaticDifferencePotential Arguments

configuration

The configuration for which the electrostatic difference potential should be calculated.

Type: Either a MoleculeConfiguration, BulkConfiguration, or a DeviceConfiguration.

ElectrostaticDifferencePotential Methods

A ElectrostaticDifferencePotential object provides the following methods:

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

    x

    The cartesian x coordinate.

    Type: physical quantity with type length.

    y

    The cartesian y coordinate.

    Type: physical quantity with type length.

    z

    The cartesian z coordinate.

    Type: physical quantity with type length.

  • evaluate(x, y, z): Evaluate in the point x,y,z

    x

    The cartesian x coordinate.

    Type: physical quantity with type length.

    y

    The cartesian y coordinate.

    Type: physical quantity with type length.

    z

    The cartesian z coordinate.

    Type: physical quantity with type length.

  • gridCoordinate(i, j, k): Return the coordinate for a given grid index.

    i

    The grid index in the A direction.

    Type: integer

    j

    The grid index in the B direction.

    Type: integer

    k

    The grid index in the C direction.

    Type: integer

  • nlprint(stream): Print a string containing an ASCII table useful for plotting the electrostatic difference potential.

    stream

    The stream the electrostatic difference potential should be written to.

    Type: A stream that supports strings being written to using 'write'.

    Default: sys.stdout
  • scale(scale): Scale the field with a double.

    scale

    The parameter to scale with.

    Type: float

  • shape(): Query function for getting the shape of the data.

  • toArray(): Return the values of the grid as a numpy array slicing off any units.

  • unit(): Get the unit of the data in the grid.

  • unitCell(): Return the unit cell for the grid.

  • volumeElement(): Get the volume element of the grid.

Usage Examples

Calculate the electrostatic difference potential and save it to a file

# Set up configuration
molecule_configuration = MoleculeConfiguration(
    elements=[Nitrogen, Hydrogen, Hydrogen, Hydrogen],
    cartesian_coordinates=[[ 0.     ,  0.      ,  0.124001],
                           [ 0.     ,  0.941173, -0.289336],
                           [ 0.81508, -0.470587, -0.289336],
                           [-0.81508, -0.470587, -0.289336]]*Angstrom 
    )

# Define a calculator
calculator = HuckelCalculator()
molecule_configuration.setCalculator(calculator)

# Calculate and save the electrostatic difference potential
potential = ElectrostaticDifferencePotential(molecule_configuration)
nlsave('results.nc', potential)

nh3_potential.py

Read in the electrostatic difference potential from a file and calculate the average along the z-axis.

# Import an ElectrostaticDifferencePotential object
potential = nlread('results.nc', ElectrostaticDifferencePotential)[0]

# Calculate the mean
v_z = numpy.apply_over_axes(numpy.mean,potential[:,:,:],[0,1]).flatten()
v_z *= potential[:,:,:].unit()

# Print out the result
dX, dY, dZ = potential.volumeElement()
dz = dZ.norm()

shape = potential.shape()
for i in range(shape[2]):
    print dz*i, v_z[i]

nh3_potential_average.py

For more examples on how to average and handle 3-d grids, see also the examples for ElectronDifferenceDensity.

Notes

  • To export the grid data of an electrostatic difference potential, use the method nlprint.

  • For the ATK-SE package, the class ElectrostaticDifferencePotential represents the electrostatic difference potential, i.e. the difference between the electrostatic potential of the self-consistent valence charge density and the electrostatic potential from a superposition of atomic valence densities.