xnn.common.models.charge_solve.solve_charges#

xnn.common.models.charge_solve.solve_charges(chi, hardness, gamma, target, fragments=None)[source]#

The constrained minimum of chi.q + 1/2 sum J q^2 + 1/2 q^T gamma q.

Parameters:
  • chi (Tensor) – Electronegativities (n,) (eV per latent charge).

  • hardness (Tensor) – J > 0, (n,) (eV per latent charge squared).

  • gamma (Tensor) – The Coulomb matrix (n, n) of coulomb_matrix() (zero for the coupling-free limit).

  • target (Tensor) – The net latent charge of the structure (scalar), or of every fragment (F,) when fragments is given.

  • fragments (Tensor, optional) – Fragment index of every atom (n,), values 0 .. F-1: one constraint row per fragment instead of one for the structure.

Returns:

The charges q (n,) and the chemical potentials mu, one per constraint row ((1,) or (F,)), with dE/dq_i = mu of its row for every atom at the solution. Both carry gradients with respect to every input, through the residual of the detached factor (first and second derivatives).

Return type:

(Tensor, Tensor)