Status | |
---|---|
Latest Release | |
Communication | |
Foundation | |
Installation |
The Open Force Field Toolkit, built by the Open Force Field Initiative, is a Python toolkit for the development and application of modern molecular mechanics force fields based on direct chemical perception and rigorous statistical parameterization methods.
The toolkit currently covers two main areas we have committed to stably maintain throughout their lifetimes:
- Tools for using the SMIRKS Native Open Force Field (SMIRNOFF) specification
- Tools for direct chemical environment perception and manipulation
Documentation for the openforcefield
toolkit is hosted at readthedocs.
openforcefield
is a Python toolkit, and supports Python 3.6 and 3.7.
Detailed installation instructions can be found here.
If you need to install via source, see the build and run package requirements listed in the development conda recipe.
This repository provides tools for using the SMIRKS Native Open Force Field (SMIRNOFF) specification, which currently supports an XML representation for force field definition files.
By convention, files containing XML representations of SMIRNOFF force fields carry .offxml
extensions.
Example SMIRNOFF .offxml
force field definitions can be found in openforcefield/data/test_forcefields/
. These force fields are for testing only, and we neither record versions of these files, nor do we guarantee their correctness or completeness.
The SMIRNOFF ForceField
class is essentially a drop-in replacement for the OpenMM ForceField
class.
# Load a molecule into the openforcefield Molecule object
from openforcefield.topology import Molecule
from openforcefield.utils import get_data_file_path
sdf_file_path = get_data_file_path('molecules/ethanol.sdf')
molecule = Molecule.from_file(sdf_file_path)
# Create an openforcefield Topology object from the molecule
from openforcefield.topology import Topology
topology = Topology.from_molecules(molecule)
# Load the smirnoff99Frosst SMIRNOFF force field definition
from openforcefield.typing.engines.smirnoff import ForceField
forcefield = ForceField('test_forcefields/smirnoff99Frosst.offxml')
# Create an OpenMM system representing the molecule with SMIRNOFF-applied parameters
openmm_system = forcefield.create_openmm_system(topology)
# Load a SMIRNOFF small molecule forcefield for alkanes, ethers, and alcohols
forcefield = ForceField('test_forcefields/Frosst_AlkEthOH_parmAtFrosst.offxml')
Detailed examples of using SMIRNOFF with the toolkit can be found in the documentation.
The ChemicalEnvironments
class can be used to parse and manipulate tagged SMARTS strings or single-fragment SMIRKS strings representing chemical environments with tagged atoms.
from openforcefield.typing.chemistry import environment
smirks = "[#6X3,#7:1]~;@[#8;r:2]~;@[#6X3,#7:3]"
angle = environment.AngleChemicalEnvironment(smirks=smirks, toolkit='rdkit')
print(angle.asSMIRKS())
# "[#6X3,#7:1]~;@[#8;r:2]~;@[#6X3,#7:3]"
# add a new atom
atom3 = angle.selectAtom(3)
alpha_ORtypes = [('#8', ['X2'])]
alpha_bondANDtypes = ['!@']
alpha = angle.addAtom(atom3, bondANDtypes = alpha_bondANDtypes, newORtypes = alpha_ORtypes)
print(alpha.asSMIRKS()) # smirks for atom only
# "[#8X2H1;R0]"
print(angle.asSMIRKS())
# "[#6X3,#7:1]~;@[#8;r:2]~;@[#6X3,#7:3]~;!@[#8X2]"
Daylight provides detailed specifications of the SMILES, SMARTS, and SMIRKS languages.
See FAQ.md
for answers to a variety of common problems, such as:
- Why do I need to provide molecules corresponding to the components of my system, or a
Topology
with bond orders? - Can I use an AMBER, CHARMM, or gromacs topology/coordinate file as a starting point for applying a SMIRNOFF force field?
- What if I am starting from a PDB file?
For a full list of contributors, see the GitHub Contributors page.