xnn.common.models.charge_solve#

Global charge solve for LES: charge equilibration with the latent Ewald kernel.

The latent charges of one channel are not read off the atom features but chosen to minimise, per structure:

E(q) = sum_i chi_i q_i + 1/2 sum_i J_i q_i^2 + E_lr(q),   with sum_i q_i = Q,

where chi (an electronegativity, from the q head) and J > 0 (a hardness, learned) come from the network and E_lr is the Ewald energy of EwaldSummation for that channel, so each charge responds to every other charge in the system, not only to its receptive field (the charge-induced-dipole energy of an ion in a polar liquid is the case this exists for). Without the Coulomb coupling the solution is the net-charge constraint of constrain() with weights 1/J; with J large it is the local head.

E_lr is an exact quadratic form, E_lr = 1/2 q^T gamma q; coulomb_matrix() writes gamma in closed form from the same kernel functions. The stationarity conditions chi + J q + gamma q = mu with the constraint row form one symmetric augmented system, solved by LU with the derivatives taken through the residual (lu_solve_implicit()): forces and stress then need no charge response (the energy is the minimised functional itself), and force training gets its mixed second derivatives at O(N^2) in the backward.

Module Attributes

ION_CHARGES

each of these atoms is its own fragment with this charge; every other fragment is neutral unless the structure carries a fragment_charges label

Functions

bonded_fragments(atomic_numbers, edge_index, ...)

Fragment index of every atom, (N,), from covalent connectivity.

charge_energy(chi, hardness, q)

Per-atom chi_i q_i + 1/2 J_i q_i^2, (n,); the Ewald part is EwaldSummation's energy of the same charges.

coulomb_matrix(ewald, pos[, cell])

gamma with E_lr(q) = 1/2 q^T gamma q for one structure (coulomb_matrix() of ewald).

covalent_radii()

Covalent radii in Angstrom indexed by atomic number, (119,) (the D4 reference table).

fragment_targets(fragments, atomic_numbers, ions)

The net charge of every fragment in e, (F,).

gaussian_coulomb_matrix(pos, sigma[, cell, ...])

A with E = 1/2 q^T A q the Coulomb energy of Gaussian charges, one structure.

ion_charge_table([ions])

Formal ion charges indexed by atomic number, (119,); zero for the rest.

solve_charges(chi, hardness, gamma, target)

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