Skip to content

A package for atom-typing as well as applying and disseminating forcefields


Notifications You must be signed in to change notification settings


Repository files navigation

Foyer: A package for atom-typing as well as applying and disseminating forcefields

Gitter chat CI Anaconda Badge codecov DOI


Foyer is an open-source Python tool for defining and applying force field atom-typing rules in a format that is both human- and machine-readable. It parametrizes chemical topologies, generating, syntactically correct input files for various simulation engines. Foyer provides a framework for force field dissemination, helping to eliminate ambiguity in atom-typing and improving reproducibility (for more information, see our paper or its corresponding pre-print).

About the name: foyer was inspired by the antechamber tool in the Amber ecosystem. Foyer plays a similar role to antechamber, hence the tongue-in-cheek, shared vestibular reference.

Foyer within the MoSDeF Ecosystem

Foyer within the MoSDeF Ecosystem

Foyer defines force fields in an XML format, where SMARTS strings are used to define the chemical context of a particular atom type and “overrides” are used to set rule precedence, rather than a rigid hierarchical scheme. Foyer builds upon the OpenMM .xml force field file, annotated with SMARTS-based atomtypes, e.g.:

  <Type name="opls_135" class="CT" element="C" mass="12.01100" def="[C;X4](C)(H)(H)H" desc="alkane CH3"/>
  <Type name="opls_140" class="HC" element="H" mass="1.00800"  def="H[C;X4]" desc="alkane H"/>

Foyer can apply the forcefield to arbitrary chemical topologies. We currently support:

Application of a force field can be as simple as:

from foyer import Forcefield
import parmed as pmd

untyped_ethane = pmd.load_file('ethane.mol2', structure=True)
oplsaa = Forcefield(forcefield_files='oplsaa.xml')
ethane = oplsaa.apply(untyped_ethane)

# Save to any format supported by ParmEd'')'ethane.gro')

The Foyer package is part of the Molecular Simulation Design Framework (MoSDeF) project. Libraries in the MoSDeF ecosystem are designed to provide utilities necessary to streamline a researcher's simulation workflow. When setting up simulation studies, we also recommend users to follow the TRUE (Transparent, Reproducible, Usable-by-others, and Extensible) standard, which is a set of common practices meant to improve the reproducibility of computational simulation research.

Getting started

Quick Start with Docker

To use foyer in a jupyter-notebook that runs from a docker container with all the dependencies installed use the following command:

$ docker pull mosdef/foyer:latest
$ docker run -it --name foyer -p 8888:8888 mosdef/foyer:latest\
  /opt/conda/envs/foyer-docker/bin/jupyter notebook --ip="*"

Alternatively, you can also start a Bourne shell directly:

$ docker run -it --name foyer mosdef/foyer:latest

To learn more about using foyer with docker, please refer to the documentation here .

Getting started with SMARTS-based atom-typing

Defining force fields:

Example foyer force field files:

Foyer currently includes a subset of the OPLS AA and TraPPE forcefields, currently part of the source distribution:

Additional example force field XML files:

Example template for disseminating force fields:

Using Foyer to perform atom typing:


Installation instructions

Citing Foyer:


Various sub-portions of this library may be independently distributed under different licenses. See those files for their specific terms.

This material is based upon work supported by the National Science Foundation under grants NSF ACI-1047828 and NSF ACI-1535150. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.