I am looking for common software packages that implement UFF ideally with an example of how to run it to calculate forces and energies. I see that Rdkit should be capable of doing this for example, but it is unclear how to do so.


1 Answer 1


Many codes implement UFF, including LAMMPS, RDKit, Open Babel.

A few caveats... First off, the original UFF paper is known to have typos and errors. One consistent pain point is that the angle terms have a minimum at 0° so atoms can collapse on each other easily. Most implementations add an harmonic or exponential barrier to avoid this.

Also, there are now a few flavors of UFF, including UFF4MOF .. I don't know of any implementation outside of LAMMPS and friends have indicated that it's still tricky to use.

RDKit Example

Something like this should be what you want. I'm adapting from David Koes's conformer generation script

from rdkit.Chem import AllChem as Chem

mol = Chem.MolFromSmiles("C1CCCCC1")
mol = Chem.AddHs(mol)
conf_ids = Chem.EmbedMultipleConfs(mol, 50, Chem.ETKDG())

for conf in conf_ids:
    converged = not Chem.UFFOptimizeMolecule(mol,confId=conf)                      
    energy = Chem.UFFGetMoleculeForceField(mol,confId=conf).CalcEnergy()
    forces = Chem.UFFGetMoleculeForceField(mol,confId=conf).CalcGrad()

Open Babel / Pybel Example

mol = pybel.readstring("smi", "C1CCCCC1")
# or read from a file

ff = pybel._forcefields["uff"]
success = ff.Setup(mol.OBMol)
ff.ConjugateGradients(100, 1.0e-3)

energy = ff.Energy()
# I don't remember if this is fully adapted to numpy
gradients = ff.GetGradientPtr()

# This definitely works
for atom in mol.atoms:
    grad = ff.GetGradient(atom.OBAtom)
    print(grad.GetX(), grad.GetY(), grad.GetZ())
  • $\begingroup$ I don't use LAMMPS much, but that should be fairly easy too. $\endgroup$ May 1, 2022 at 14:38
  • $\begingroup$ Do you know if its possible to go from 3D coordinates directly to using UFF? My ideal case was to find an ASE calculator for this, but that seems to not exist. LAMMPS seems to have a few indirect implementations but nothing straightforward to use without having to learn the details of LAMMPS. $\endgroup$ May 1, 2022 at 14:40
  • 1
    $\begingroup$ Of course. In RDKit, you'd read in the SDF and then skip the conformer generation and start at the for loop. In the Open Babel case, you'd just read in the molecule and skip to the ff setup part. $\endgroup$ May 1, 2022 at 14:41
  • $\begingroup$ I know there's an Open Babel calculator for ASE: github.com/tkjacobsen/obcalc $\endgroup$ May 1, 2022 at 14:42
  • $\begingroup$ Implementing UFF isn't terribly hard, but I'd start from the RDKit or Open Babel versions to avoid the errors. I haven't implemented the periodic boundary conditions though .. bonds, angles, etc, seem like they'd be a bit tricky. (Fortunately UFF is not supposed to use partial charges.) $\endgroup$ May 1, 2022 at 14:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .