Theory¶
PyMPFIT implements the MPFIT algorithm introduced by Ferenczy to calculate partial atomic charges that reproduce the electrostatic potential of a distributed multipole analysis. This is in contrast with traditional (e.g., RESP) partial charge methods that reproduce the molecular electrostatic potential for a given number of atomic sites. In these latter methods, site selection, molecular orientation dependence, or charge assignment of symmetrically related centers seemingly trouble such calculations.
Potential derived charges are, of course, methods in which the charges are not obtained from the wave function, but rather, indirectly via electrostatic potentials. In lieu of computing the entire wave function, constraining some lower moments of the fitted charges to molecular multipole moments serves as a better approach to utilizing information inherent to the wave function. In practice, charges based on distributed multipole potentials and electrostatic potentials are equivalent.
Gaussian Distributed Multipole Analysis¶
The Gaussian Distributed Multipole Analysis (GDMA) introduced by Stone provides a rigorous framework for decomposing a molecular charge density into a series of multipole moments localized on atomic centers. The electrostatic potential at a given point in space, \(\mathbf{r}\), can be expressed as a multipole expansion,
where \(P_n\) are Legendre polynomials and \(\rho(\mathbf{r})\) is an arbitrary, localized charge distribution. Molecular charge distributions are hence defined as
where \(D_{ij}\) is an element of the density matrix, and \(\chi(\mathbf{r})\) is a normalized basis function, expressed as a linear combination of Gaussian primitive functions, i.e., local multipoles
where \(a_i + b_i + c_i\) are equal to the angular momentum quantum number, \(l\), and \(N_i\) is the basis function coefficient. Evaluating the higher moments of the overlap density distribution (i.e., \(\chi_i\chi_j\)) yields the multipole moment of order \(lm\),
where \(R_{lm}\) is a regular solid harmonic. GDMA expands Equation (4) by distributing such moments across atoms and bonds (or even arbitrary virtual sites), serving as a physically interpretable bridge between QM charge density and classical force field electrostatics.
Minimal Basis Iterative Stockholder¶
Minimal Basis Iterative Stockholder (MBIS) introduced by Verstraelen et al. is a variant of the Hirshfeld atoms-in-molecules method that derives atomic charges and multipoles by fitting a pro-density — an atom-centered expansion in \(s\)-type Slater density functions — to the molecular electron density. The pro-density of each atom \(A\) is expanded as
where the populations \(N_{A,i}\) and widths \(\sigma_{A,i}\) of each Slater shell are free parameters. These are refined iteratively to minimize the Kullback–Leibler divergence between the pro-density and a reference electron density \(\rho(\mathbf{r})\),
yielding atomic populations and multipoles that scale linearly with system size and require no empirical radii or precomputed pro-atoms.
MPFIT¶
The MPFIT (multipole fitting) procedure originally outlined by Ferenczy represents the traditional approach to deriving atom-centered partial charges from GDMA output. Formally, this is achieved by minimizing the difference between the potential created by the distributed multipole moments, \(V^{\text{GDMA}}(\mathbf{r})\), and that generated by the fitted charges, \(V^{Q}(\mathbf{r})\),
where \(Q_{lm}^{a}\) denotes the \(m\)th component of the rank-\(l\) multipole moment centered at site \(a\), \(q_i\) are the point charges, and \(I_{lm}^{a}(\mathbf{r}) = r_a^{-(l+1)}C_{lm}(\theta,\phi)\) are irregular solid harmonics. The optimal charges are obtained by minimizing the integrated squared error,
which yields a linear system of the form \(Aq^a = b\), where the elements of \(A\) and \(b\) depend on regular and irregular solid harmonics across atomic centers and multipole ranks. Solving for \(q^a = A^{-1}b\) yields the set of least-squares charges that best reproduce the distributed multipole potential.
The explicit form of the design matrix problem requires additional mathematics. Suppose the distance between the multipole center and the point where the potential is to be calculated (\(r-r_a\)) is greater than the distance between multipoles and the charge site (\(r_{ia}\)), then
where \(R_{lm}(r)\) is a regular spherical harmonic defined as
This allows for simplification of the original equation to,
We can eliminate \(I_{lm}^{a}(r)\) by integration. Namely, the integration of \([f(r)]^2\) yields the optimum set of net charges based on an appropriate integral bound in polar coordinates. Via chain rule, it can be shown that the integrand becomes:
which, after plugging back into the integral, can be formulated as \(Aq = b\) where
and
where
Computing the off-diagonal components of this approach would be cumbersome (\(a\neq b\)), especially in the case of having some grid construction involved in molecular electrostatic potential- or field-derived methods. To this end, recall that the optimization can be broken up into the sum of \(f(r)\) at each spherical layer around point \(a\):
where the \(W_{\rho_1,\rho_2,l}\) factors
weight the importance of the multipoles of rank \(l\). Now, we just need to solve for
where the new \(Aq^a = b\) matrix equation is solved by creating the following \(A\) and \(b\) matrices:
where the partial charges are determined via
where
Constrained MPFIT¶
The unconstrained MPFIT objective \(F = \sum_a F^a\) can be augmented with two classes of constraints for transferable force field development: atom-type equivalence and per-molecule charge conservation. When fitting across multiple molecules simultaneously, these constraints enable transferable charge sets where chemically equivalent atoms in different molecules carry identical charges.
In the constrained formulation, each atom \(i\) contributes a charge \(q_i^a\) at
each multipole site \(a\) for which it is within the cutoff radius (the quse
mask). The total charge on atom \(i\) is
Rather than optimizing all \(q_i^a\) directly, we work with a reduced parameter vector \(\mathbf{p}\) that implicitly enforces atom-type equivalence.
Atom-Type Equivalence¶
Atoms sharing the same type label are constrained to have equal total charges. Let \(\mathcal{T}\) be a set of atoms sharing the same type, and let \(i_1\) be the first atom in \(\mathcal{T}\) (by index order). The reference total charge for the type is defined as the sum of \(i_1\)’s per-site charges, where each \(q_{i_1}^a\) creates a free parameter in \(\mathbf{p}\) for every contributing site (i.e., where \(\text{quse}_{a,i_1} = 1\)):
For every subsequent atom \(i \in \mathcal{T}\) (\(i \neq i_1\)), each contributing site also creates a free parameter in \(\mathbf{p}\), except the last contributing site \(a^*\) (in index order), which absorbs the difference needed to match the reference total:
The per-site charge distributions may differ between atoms in
\(\mathcal{T}\); only the totals are forced equal. If atom \(i\) contributes
to only one site, no free parameters are created and
\(q^{\text{total}}_{\mathcal{T}}\) is copied directly. This reduces the
number of free parameters by one per subsequent atom in \(\mathcal{T}\).
The mapping from \(\mathbf{p}\) to the full per-site charge matrix and
total charges is performed by expandcharge.
Constrained Objective Function¶
The full constrained objective augments the unconstrained MPFIT objective (Equation (16)) with a per-molecule charge conservation penalty:
where \(F^a(\rho_1, \rho_2)\) is defined in Equation (16).
The parameter \(\lambda\) (conchg) controls the strength of the charge
conservation penalty. Larger values of \(\lambda\) enforce stricter conservation
at the cost of a slightly worse multipole fit. \(Q_{\text{mol}}\) is the target
total charge for each molecule (e.g., +1 for a cation, 0 for a neutral).
The gradient of \(F_{\text{total}}\) with respect to the full per-site charges has two contributions. The multipole fitting gradient \(\partial F^a / \partial q_j^a\) follows directly from Equation (18). The charge conservation gradient for atom \(j\) in molecule \(m\) is
The full-space gradient is then projected into the reduced parameter space
via the chain rule through expandcharge, yielding the gradient
\(\nabla_{\mathbf{p}} F_{\text{total}}\) passed to the optimizer.
Optimization¶
The constrained objective is minimized using scipy.optimize.minimize
(L-BFGS-B by default) with the analytic Jacobian. The optimizer
receives the reduced parameter vector \(\mathbf{p}\), which is expanded to
full charges for each function and gradient evaluation. After convergence,
the optimal \(\mathbf{p}\) is expanded one final time to obtain the total
charge per atom \(q_i\).
Virtual Sites¶
Coming soon…