# 3.3.2. horton.espfit.cost – ESP cost functions for estimating and testing charges¶

class horton.espfit.cost.ESPCost(A, B, C, natom)

Bases: object

classmethod from_grid_data(coordinates, ugrid, vref, weights, rcut=20.0, alpha=None, gcut=None)
classmethod from_hdf5(grp)
gradient(x)
solve(qtot=None, ridge=0.0)
to_hdf5(grp)
value(x)
value_charges(charges)
worst(qtot=0.0)

Return a worst-case value for the cost function

Optional arguments:

qtot
The total charge of the molecule/crystal

Higher values for the cost function are still possible but if that happens, it is better not to use charges at all.

horton.espfit.cost.setup_weights(coordinates, numbers, grid, dens=None, near=None, far=None)

Define a weight function for the ESPCost

Arguments:

coordinates
An array with shape (N, 3) containing atomic coordinates.
numbers
A vector with shape (N,) containing atomic numbers.
grid
A UniformGrid object.

Optional arguments:

dens

The density-based criterion. This is a three-tuple with rho, lnrho0 and sigma. rho is the atomic or the pro-atomic electron density on the same grid as the ESP data. lnrho0 and sigma are parameters defined in JCTC, 3, 1004 (2007), DOI:10.1021/ct600295n. The weight function takes the form:

exp(-sigma*(ln(rho) - lnrho0)**2)


Note that the density, rho, should not contain depletions in the atomic cores, as is often encountered with pseudo-potential computations. In that case it is recommended to construct a promolecular density as input for this option.

near
Exclude points near the nuclei. This is a dictionary with as items (number, (R0, gamma)).
far
Exclude points far away. This is a two-tuple: (R0, gamma).