ElectrostaticDifferencePotential — Class for calculating the Hartree potential corresponding to a difference density.
A class for calculating the electrostatic difference potential for a configuration.
The configuration for which the electrostatic difference potential should be calculated.
Type: Either a MoleculeConfiguration, BulkConfiguration, or a DeviceConfiguration.
A ElectrostaticDifferencePotential object provides the following methods:
derivatives(x, y, z): Calculate the derivative in the point x,y,z.
evaluate(x, y, z): Evaluate in the point x,y,z
gridCoordinate(i, j, k): Return the coordinate for a given grid index.
nlprint(stream): Print a string containing an ASCII table useful for plotting the electrostatic
difference potential.
scale(scale): Scale the field with a double.
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.
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)
Read in the electrostatic difference potential from a file and calculate the average along the
-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]
For more examples on how to average and handle 3-d grids, see also the examples for ElectronDifferenceDensity.
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.