horton_part.hirshfeld module

Hirshfeld partitioning

class HirshfeldWPart(coordinates, numbers, pseudo_numbers, grid, moldens, proatomdb, spindens=None, lmax=3, logger=None, grid_type=1, **kwargs)

Bases: AbstractStockholderWPart

Hirshfeld partitioning with Becke-Lebedev grids

__init__(coordinates, numbers, pseudo_numbers, grid, moldens, proatomdb, spindens=None, lmax=3, logger=None, grid_type=1, **kwargs)

Arguments: (that are not defined in WPart)

proatomdb

In instance of ProAtomDB that contains all the reference atomic densities.

property cache

Cache.

calc_radial_distances()

Calculate radial distance w.r.t coordinates.

clear()

Discard all cached results, e.g. because wfn changed

compute_pseudo_population(index)

Compute pseudo population

property coordinates

Center/Atomic coordinates.

Type:

ndarray(M, 3)

property density_cutoff

Get the density cutoff value.

Density values below this cutoff are considered to be invalid.

Returns:

The cutoff value for density.

Return type:

float

do_all()

Computes all properties and return a list of their keys.

do_charges()

Compute atomic charges.

do_density_decomposition()

Compute density decomposition.

do_dispersion()
do_moments()

Compute atomic multiple moments.

Calculates various types of multipoles, including Cartesian, Spherical, and Radial moments. The order of the moments is determined by the lmax parameter.

do_partitioning()

Run partitioning.

do_populations()

Compute atomic populations.

do_prosplines()

Do pro-atom splines

do_spin_charges()

Compute atomic spin charges.

eval_proatom(index, output, grid)

Evaluate the radial density of a proatom on a given grid and store the results in the output array.

This method computes the radial density for a specified atomic index by using a spline representation of the radial density. The computed values are then stored in the provided output array. A small constant is added to the output to avoid zero values, which is crucial for certain methods that require non-zero initial values.

Parameters:
  • index (int) – The index of the atom for which the radial density is to be evaluated.

  • output (1D ndarray) – The array where the evaluated radial density values will be stored. This array is modified in-place.

  • grid (Grid) – The grid points where the radial density is to be evaluated.

  • on_molgrid – Whether evaluate pro-atom density on the molecular grid.

Notes

The method begins by obtaining a spline representation of the radial density using get_proatom_spline. It then uses eval_spline to evaluate this spline over the provided grid, storing the results in the output array. The output is then modified by adding a small constant (1e-100) to each element to ensure non-zero values, which is crucial for certain iterative self-consistent field methods like ISA.

A check is performed using np.isfinite to ensure that all values in the output array are finite.

Warning

The addition of a small constant to the output is a workaround for certain limitations in ISA methods and might need to be adjusted based on specific use cases.

See also

grid.Grid

eval_spline(index, spline, output, grid, label='noname')

Evaluate a given spline at radial distances from a specified atom center and store the results in the output array.

This method calculates the radial distances from the specified atom center to each point in the provided grid. It then evaluates the provided spline function at these distances, storing the results in the given output array.

Parameters:
  • index (int) – The index of the atom whose center is used for calculating radial distances.

  • spline (callable) – The spline function to be evaluated. This should be a function that takes an array of radial distances and returns the corresponding spline values.

  • output (1D ndarray) – The array where the evaluated spline values will be stored. This array is modified in-place.

  • grid (Grid) – An object representing the grid points. It should have an attribute points which is an array of grid point coordinates.

  • label (str, optional) – A label for identification purposes, defaults to “noname”.

Notes

The method computes the Euclidean norm (radial distance) from the atom center, specified by index, to each point in the grid. The spline function is then evaluated at these distances. The results are stored directly in the output array, overwriting any existing data.

fix_proatom_rho(index, rho, deriv)

Check if the radial density for the proatom is correct and fix as needed.

Parameters:
  • index (int) – The atom for which this proatom rho is created.

  • rho (1D np.ndarray) – The radial density

  • deriv (int) – the derivative of the radial density or None.

get_grid(index=None)

Return an integration grid

Optional arguments:

index

The index of the atom. If not given, a grid for the entire system is returned. If self.local is False, a full system grid is always returned.

get_moldens(index=None, output=None)

Retrieves the molecular electron density (moldens) on the atomic grid.

This method converts the molecular electron density to the atomic grid specified by the index. If an output array is provided, the result is stored in that array.

Parameters:
  • index (int or None, optional) – The index of the atom for which the electron density is required. If None, electron density for all atoms is considered. Default is None.

  • output (np.ndarray or None, optional) – An optional array to store the resulting electron density. If provided, the result is saved in this array. Default is None.

Returns:

The molecular electron density on the atomic grid.

Return type:

np.ndarray

get_proatom_rho(iatom, *args, **kwargs)

Get pro-atom density for atom iatom on a radial grid.

Parameters:
  • iatom – The atom index

  • *args – Variable length argument list, used for passing non-keyworded arguments.

  • **kwargs – Arbitrary keyword arguments, used for passing additional data.

get_proatom_spline(index, *args, **kwargs)

Create and return a spline representation of the radial density for a given atomic index.

This method first retrieves the radial density and its derivatives for the specified atomic index. It then ensures the correctness of these values and constructs a spline representation based on the radial grid points.

Parameters:
  • index (int) – The index of the atom for which the radial density spline is to be calculated.

  • *args – Variable length argument list, used for passing non-keyworded arguments.

  • **kwargs – Arbitrary keyword arguments, used for passing additional data.

Returns:

A spline representation of the radial density. If derivatives are available, a CubicHermiteSpline is returned. Otherwise, a CubicSpline is used.

Return type:

CubicSpline or CubicHermiteSpline

Notes

The method internally calls get_proatom_rho to obtain the radial density (rho) and its derivatives (deriv), and fix_proatom_rho to validate and potentially correct these values. It also uses get_rgrid to acquire the radial grid points (rgrid.points). The spline is constructed with these grid points and density values, with the type of spline depending on the availability of derivative information.

get_rgrid(index)

Load radial grid.

Parameters:

index – The atom index.

get_spindens(index=None, output=None)

Retrieves the spin density (spindens) on the atomic grid.

This method converts the spin density to the atomic grid specified by the index. If an output array is provided, the result is stored in that array.

Parameters:
  • index (int or None, optional) – The index of the atom for which the spin density is required. If None, spin density for all atoms is considered. Default is None.

  • output (np.ndarray or None, optional) – An optional array to store the resulting spin density. If provided, the result is saved in this array. Default is None.

Returns:

The spin density on the atomic grid.

Return type:

np.ndarray

get_wcor(index)

Load correction of weights.

property grid

Molecular grid.

property grid_type

Get the type of grids used for partitioning density.

Returns:

The type of grids used in the partitioning process.

Return type:

str

property lmax

The maximum angular momentum index for moment calculations.

property local

Whether local grids are included.

name = 'h'
property natom

The number of atoms in the molecule.

property negative_cutoff

Get the negative cutoff value.

Values less than this threshold are treated as negative in computations.

Returns:

The negative cutoff value.

Return type:

float

property nelec

The number of electrons in the molecule.

property numbers

Atomic numbers

property on_molgrid

Check whether quantities are computed on molecular grids.

These grids are used for evaluating various properties, including:

  • AIM (Atoms-in-Molecule) weight functions: \(w_a(\mathbf{r})\).

  • Pro-atom density: :math:`

ho_a^0(mathbf{r})`.
  • Pro-molecule density: :math:`

ho^0(mathbf{r})`.
  • Mean-square deviation during computations.

bool

True if quantities are computed on molecular grids, False otherwise.

property only_use_molgrid

Check whether intermediate values are computed exclusively using molecular grids.

When set to True, all quantities are computed solely on the molecular grid.

Returns:

True if intermediate values are computed only using the molecular grid, False otherwise.

Return type:

bool

property population_cutoff

Get the population cutoff criterion.

This represents the allowed difference between the sum of proatom parameters and the reference population for determining accuracy of methods.

Returns:

The cutoff value for population differences.

Return type:

float

property proatomdb
property pseudo_numbers

Atomic charges.

property radial_distances

Get the radial distances of points from the atomic coordinates.

The radial distances are calculated as the L2 norm (Euclidean distance) of the points relative to the atomic coordinates.

Notes

Accessing this property triggers the calculation of radial distances via the calc_radial_distances method.

Returns:

A list containing the radial distances of points for each atom.

Return type:

list

setup_grids()

Setup grids used in partitioning.

# 1. atom_grids + mol_grid, use atoms for everything and mol_grid is only used for weights calculation # 2. atom_grids + mol_grid, use mol_grid for everything but atom_grids are used applied contratins. # 3. mol_grid, use mol_grid for everything, like in gLISA+.

to_atomic_grid(index, data)

Load atomic contribution of molecular properties.

update_at_weights(force_on_molgrid=False)

See Part.update_at_weights.

update_pro(index, proatdens, promoldens, force_on_molgrid=False)

Update propars.

Parameters:
  • index (int) – The index of the atom for which the pro-atom and pro-molecule densities are to be updated.

  • proatdens (1D np.ndarray) – The array representing the pro-atom density. This array is updated with the new density values for the specified atom.

  • promoldens (1D np.ndarray) – The array representing the pro-molecule density. This array accumulates the density contributions from each atom, including the one specified by index.

variables_stored_in_cache()

The properties stored in cache obj.

check_proatomdb(numbers, pseudo_numbers, proatomdb)
do_dispersion(part)