moleditpy_pmeff-plugin

PMEFF — Python Molecular Editor Force Field

DOI Tests PyPI

A MoleditPy plugin that adds PMEFF, a self-contained universal molecular force field covering the entire periodic table (Z = 1 – 118). It needs no external QM binary — just numpy and rdkit.

Why another force field?

The classic force fields shipped with molecular editors are excellent for organic chemistry but leave gaps: MMFF94 only parameterizes a fixed subset of main-group elements, and even UFF-style tables are hand-tuned per element.

PMEFF takes a different approach. Every parameter is derived from a single per-element property — the Pyykkö single-bond covalent radius — so no element is ever missing a parameter. Drop in a lanthanide, an actinide, a transition metal, or a superheavy element and PMEFF still produces a sensible geometry.

What it does

Once installed, PMEFF registers:

Feature Where Description
PMEFF Right-click the Optimize 3D button Relaxes the current 3D geometry with a dependency-free FIRE 2.0 + L-BFGS optimizer.
PMEFF Single-Point Energy Analysis menu Reports the force-field energy (with per-term decomposition) without modifying the geometry.
PMEFF Minimum Check (Vibrational) Analysis menu Diagonalizes the Hessian at the current geometry and reports whether it is a true minimum or a saddle point.
PMEFF Settings… Settings → PMEFF Setting menu Opens a dialog to toggle individual physics options (persisted to settings.json).

Scope: PMEFF is a pre-DFT geometry-cleanup force field. Its goal is initial structure preparation — removing clashes, correcting bond lengths, angles and torsions, and placing metal centers in the right coordination geometry. It is not designed for high-accuracy thermochemistry. For accurate energies, pair it with the ORCA or PySCF plugins.

The physics

For the full specification — functional forms, parameter derivations, gradient formulas, non-bonded bookkeeping and the optimizer — see the technical reference. In brief, PMEFF has these energy terms:

Optional physics terms

Settings → PMEFF Setting opens a dialog. All settings are persisted in pmeff_plugin/settings.json. The optional terms (defaults shown) are:

Lone pairs are not explicit particles, but their steric effect enters through the hybridization-derived angle targets: sp³ N stays pyramidal, sp³ O stays bent, and a conjugated (sp²) amide nitrogen stays planar.

Geometry optimization uses FIRE 2.0 (Fast Inertial Relaxation Engine) for the far-from-minimum regime and hands over to an L-BFGS finisher in the quadratic basin, with a per-atom displacement clamp for stability and fully analytical gradients for all energy terms — including the dihedral and Coulomb derivatives, which are verified against numeric differentiation in the test suite. All terms are evaluated with vectorized numpy over precompiled index arrays, so evaluation cost is dominated by numpy kernels rather than Python loops. The short-range van der Waals term is truncated at a 12 Å cutoff (electrostatics, being long-range, are not) with the pair list built by an O(N) cell-list search and maintained as a Verlet list during optimization; a CHARMM-style switching function tapers the LJ term to zero over the last 2 Å with zero slope at the cutoff, so both energy and force stay continuous as a pair crosses the boundary. A finite-difference Hessian over the analytic gradient powers the vibrational minimum check.

Note: PMEFF energies are in internal, consistent units meant for relative comparison and geometry guidance, not thermochemistry. The goal is to give the DFT optimizer a sensible starting geometry — not to replace it.

Installation

Copy the pmeff_plugin/ folder into your MoleditPy user plugin directory:

Then restart MoleditPy, or use Plugins → Reload All Plugins.

Standalone Python package (pmeff)

The force-field engine is also published on PyPI as pmeff — the same physics, usable from any Python script without MoleditPy. The core has no dependency beyond NumPy; RDKit is an optional extra for the convenience layer.

pip install pmeff            # core: NumPy only
pip install "pmeff[rdkit]"   # adds the RDKit convenience layer (optimize_mol)

With RDKit — Mol in, relaxed Mol out

The recommended path: hand it an RDKit molecule that has a 3D conformer, and get the same molecule back with its geometry relaxed. Connectivity, bond orders, formal charges and properties are all preserved (a raw coordinate list would throw them away).

from rdkit import Chem
from rdkit.Chem import AllChem
import pmeff

mol = Chem.AddHs(Chem.MolFromSmiles("O[SiH3]"))   # silanol
AllChem.EmbedMolecule(mol, randomSeed=1)          # give it a 3D conformer

mol, result = pmeff.optimize_mol(mol)             # relaxed in place, and returned
print(result.converged, result.energy, result.max_force)
print(Chem.MolToXYZBlock(mol))                    # -> optimized coordinates

optimize_mol takes the same physics switches as the plugin (electronic_effects, use_morse, use_hbond, use_dispersion, use_polar_contraction) plus max_iter and f_tol.

Without RDKit — plain arrays in, coordinates out

For pipelines that don’t use RDKit, describe the molecule with atomic numbers, a bond list and coordinates:

import numpy as np
import pmeff

atomic_numbers = [8, 1, 1]                         # water
bonds = [(0, 1), (0, 2)]
coords = np.array([[0.0, 0, 0], [0.96, 0, 0], [-0.3, 0.9, 0.0]])

coords, result = pmeff.optimize_coords(
    atomic_numbers, bonds, coords, hybridizations=["SP3", None, None]
)
print(result.converged)
print(coords)                                      # optimized (N, 3) array

Optional charges (pmeff.qeq_charges(...)), per-bond orders and hybridizations sharpen the result. The lower-level engine — build_topology, energy_and_gradient, energy_components, optimize, vibrational_analysis — is exported too for custom workflows.

The engine is a copy of pmeff_plugin/forcefield.py (the single source of truth); see PACKAGING.md for the build/release process.

Development

# Run the test suite (uses real numpy + rdkit)
python -m pytest tests/ -v

# With coverage
python -m pytest tests/ --cov=pmeff_plugin --cov-report=term-missing

# Lint
pylint pmeff_plugin/

The engine (pmeff_plugin/forcefield.py) is deliberately Qt-free and RDKit-free at its core — it operates on a plain-number Topology — which makes it fully unit-testable without a GUI. Only the thin boundary functions touch RDKit.

License

GPL-3.0. See LICENSE.