Skip to content
shehan807Public

About

Partial atomic charge assignment via multipole moment-based fitting algorithm

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

2 watching

Forks

Repository files navigation

PyMPFIT is a free, open-source software for performing partial atomic charge fitting to distributed multipoles. The multipoles can come from either the Gaussian distributed multipole analysis (GDMA) or minimal basis iterative stockholder (MBIS) partitioning. Features include:

  • Built on open-source libraries: OpenFF Recharge, OpenFF Toolkit, and NumPy
  • Direct interface to Psi4 for both GDMA and native MBIS multipoles, and from wavefunctions stored within QCFractal (i.e., QCArchive)
  • Generating multipole moments for multi-conformer molecules
  • An SQLite database backend for efficient high-throughput scaling
  • Bayesian methods (Pyro) for flexible virtual site fitting

Installation

Dependencies

PyMPFIT depends on OpenFF packages and Psi4/GDMA, which are distributed via conda-forge. Works with conda, mamba, or micromamba.

conda create -n pympfit python=3.12 openff-recharge openff-interchange openff-utilities psi4 pygdma -c conda-forge -y
conda activate pympfit

Install

pip install pympfit

Optional: Bayesian Virtual Site Fitting

pip install pyro-ppl arviz matplotlib sphericart-torch

Development Installation

git clone https://github.com/shehan807/pympfit.git
cd pympfit
pip install -e ".[test]"

Quick Example

from openff.toolkit import Molecule
from openff.recharge.utilities.molecule import extract_conformers
from pympfit import (
    GDMASettings, Psi4GDMAGenerator, MoleculeGDMARecord,
    MPFITSVDSolver, generate_mpfit_charge_parameter,
)

# Create molecule
molecule = Molecule.from_smiles("CCO")
molecule.generate_conformers(n_conformers=1)
[conformer] = extract_conformers(molecule)

# Compute multipoles via Psi4/GDMA
settings = GDMASettings(method="pbe0", basis="def2-SVP", limit=4)
coords, multipoles = Psi4GDMAGenerator.generate(
    molecule, conformer, settings, minimize=True
)

# Fit partial charges to multipoles
record = MoleculeGDMARecord.from_molecule(molecule, coords, multipoles, settings)
charges = generate_mpfit_charge_parameter([record], MPFITSVDSolver())

import numpy as np

print(f"MPFIT SMILES         : {charges.smiles}")
print(f"MPFIT CHARGES        : {np.round(charges.value, 4)}")

Output:

MPFIT SMILES         : [H:1][O:2][C:3]([H:4])([H:5])[C:6]([H:7])([H:8])[H:9]
MPFIT CHARGES        : [ 0.34    0.6064 -0.6405 -0.1101 -0.1218 -0.113  -0.1281 -0.1534  0.3205]

See examples/tutorials/quickstart.py for more.

MBIS multipoles

MBIS works the same way. Use the MBIS classes in place of the GDMA ones, then either take the raw MBIS charges directly or refit them with MPFIT:

from pympfit import (
    MBISSettings, Psi4MBISGenerator, MoleculeMBISRecord, extract_mbis_charges,
)

mbis_settings = MBISSettings(method="pbe0", basis="def2-SVP")
coords, multipoles = Psi4MBISGenerator.generate(
    molecule, conformer, mbis_settings, minimize=True
)
record = MoleculeMBISRecord.from_molecule(molecule, coords, multipoles, mbis_settings)

# raw MBIS charges straight from Psi4:
charges = extract_mbis_charges(record)
# or refit point charges to the MBIS multipoles:
charges = generate_mpfit_charge_parameter([record], MPFITSVDSolver())

A runnable version is in examples/mbis-charges.py.

License

The main package is released under the MIT license.

Copyright

Copyright (c) 2026, Shehan M. Parmar

Acknowledgements

Project based on the Computational Molecular Science Python Cookiecutter version 1.11.

About

Partial atomic charge assignment via multipole moment-based fitting algorithm

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages