Skip to content

EEM Charges

EEM

Class to handle calculation of electronegativity equilibration method charges

calculate_charges(mol) staticmethod

Calculate the partial atomic charges based on the EEM method.

Parameters:

Name Type Description Default
mol Molecule

The molecule with atoms where partial charges are desired

required

Returns:

Type Description
np.ndarray

the partial charges associated the atoms in mol

Source code in chmpy/ext/charges.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@staticmethod
def calculate_charges(mol):
    """
    Calculate the partial atomic charges based on the EEM method.

    Args:
        mol (Molecule): The molecule with atoms where partial charges are desired

    Returns:
        np.ndarray: the partial charges associated the atoms in `mol`
    """
    A = []
    B = []
    for el in mol.elements:
        a, b = EEM_PARAMETERS.get(el.symbol, EEM_PARAMETERS["*"])
        A.append(a)
        B.append(b)
    N = len(mol)
    M = np.zeros((N + 1, N + 1))
    M[-1, :-1] = 1
    M[:-1, -1] = -1
    dists = mol.distance_matrix
    idx = np.triu_indices(N, k=1)
    M[idx] = EEM_KAPPA / dists[idx]
    idx = np.tril_indices(N, k=-1)
    M[idx] = EEM_KAPPA / dists[idx]
    np.fill_diagonal(M, B)
    M[N, N] = 0.0
    y = np.zeros(N + 1)
    y[:N] -= A
    y[N] = mol.charge
    return np.linalg.solve(M, y)[:N]