Skip to main content

Partial atomic charge assignment via multipole moment-based fitting algorithm

Project description

PyMPFIT

GitHub Actions Build Status codecov Documentation Status

PyMPFIT is a free, open-source software for performing partial atomic charge fitting using the Gaussian distributed multipole analysis (GDMA). Features include:

  • Built on open-source libraries: OpenFF Recharge, OpenFF Toolkit, and NumPy
  • Direct interface to Psi4 / GDMA 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

PyMPFIT depends on OpenFF packages which are distributed via conda-forge.

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

Bayesian Virtual Site Fitting

For Bayesian optimization of virtual site parameters:

pip install pyro-ppl arviz matplotlib sphericart-torch

Development Installation

conda create -n pympfit-dev python=3.12 openff-recharge openff-interchange openff-utilities psi4 pygdma -c conda-forge -y
conda activate pympfit-dev
git clone https://github.com/shehan807/pympfit.git
cd pympfit
pip install -e ".[test]"

Works with conda, mamba, or micromamba.

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pympfit-1.0.0.tar.gz (47.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pympfit-1.0.0-py3-none-any.whl (50.9 kB view details)

Uploaded Python 3

File details

Details for the file pympfit-1.0.0.tar.gz.

File metadata

  • Download URL: pympfit-1.0.0.tar.gz
  • Upload date:
  • Size: 47.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pympfit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e29f54057fc8491e7fc360007dfea65b1fe3cd58627b25511c27b62dc353e9f5
MD5 4dafbe2492968cefb09ed7dbcbb04a75
BLAKE2b-256 04320801dec7bae96aaf7666a4e1b70f9ff509320af8c5c81d3f2a67c0f19a66

See more details on using hashes here.

File details

Details for the file pympfit-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pympfit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 50.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pympfit-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9104172ee951fb86957fc1946137df86d76356b1a4ba8a33300046ef4d96ef8c
MD5 1aa1e62ea4cbfd036ea167c61a117df5
BLAKE2b-256 9e155f858889488b0c9e852e5b7070b20912df72c5506f9e230f5b9fe08424e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page